mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-11-04 06:37:08 +01:00
Ghostgram for iOS, rebuilt from scratch on Telegram iOS 13.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43 lines
1.4 KiB
Objective-C
43 lines
1.4 KiB
Objective-C
#import <GGCallFrameBridge/GGCallFrameBridge.h>
|
|
|
|
#import <os/lock.h>
|
|
|
|
static os_unfair_lock ggCallFrameLock = OS_UNFAIR_LOCK_INIT;
|
|
static GGCallFrameProcessorBlock ggCallFrameProcessor = nil;
|
|
|
|
@implementation GGCallFrameBridge
|
|
|
|
+ (void)setProcessor:(GGCallFrameProcessorBlock _Nullable)processor {
|
|
GGCallFrameProcessorBlock copied = [processor copy];
|
|
os_unfair_lock_lock(&ggCallFrameLock);
|
|
ggCallFrameProcessor = copied;
|
|
os_unfair_lock_unlock(&ggCallFrameLock);
|
|
}
|
|
|
|
+ (BOOL)hasProcessor {
|
|
os_unfair_lock_lock(&ggCallFrameLock);
|
|
BOOL result = ggCallFrameProcessor != nil;
|
|
os_unfair_lock_unlock(&ggCallFrameLock);
|
|
return result;
|
|
}
|
|
|
|
+ (CVPixelBufferRef _Nullable)copyProcessedPixelBuffer:(CVPixelBufferRef)pixelBuffer isFrontCamera:(BOOL)isFrontCamera rotation:(int)rotation {
|
|
os_unfair_lock_lock(&ggCallFrameLock);
|
|
GGCallFrameProcessorBlock processor = ggCallFrameProcessor;
|
|
os_unfair_lock_unlock(&ggCallFrameLock);
|
|
if (processor == nil) {
|
|
return NULL;
|
|
}
|
|
CVPixelBufferRef result = processor(pixelBuffer, isFrontCamera, rotation);
|
|
if (result == NULL) {
|
|
return NULL;
|
|
}
|
|
if (CVPixelBufferGetWidth(result) != CVPixelBufferGetWidth(pixelBuffer) || CVPixelBufferGetHeight(result) != CVPixelBufferGetHeight(pixelBuffer) || CVPixelBufferGetPixelFormatType(result) != CVPixelBufferGetPixelFormatType(pixelBuffer)) {
|
|
CVPixelBufferRelease(result);
|
|
return NULL;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
@end
|