Repository navigation
Expand file tree
/
Copy pathExecutorchWebRTC.mm
More file actions
58 lines (42 loc) · 1.69 KB
/
Copy pathExecutorchWebRTC.mm
File metadata and controls
58 lines (42 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#import "ExecutorchWebRTC.h"
#import "ExecutorchFrameProcessor.h"
#include "ProcessorProvider.h"
@implementation ExecutorchWebRTC
RCT_EXPORT_MODULE()
static ExecutorchFrameProcessor *_processor = nil;
static dispatch_once_t _registerOnce;
static NSString *const PROCESSOR_NAME = @"executorchBackgroundBlur";
+ (void)ensureRegistered {
dispatch_once(&_registerOnce, ^{
_processor = [[ExecutorchFrameProcessor alloc] init];
[ProcessorProvider addProcessor:_processor forName:PROCESSOR_NAME];
NSLog(@"[ExecutorchWebRTC] Registered %@ processor", PROCESSOR_NAME);
});
}
#pragma mark - Fishjam-compatible API
RCT_EXPORT_METHOD(initialize : (NSString *)modelPath) {
NSLog(@"[ExecutorchWebRTC] initialize: %@", modelPath);
[ExecutorchWebRTC ensureRegistered];
NSString *cleanPath = modelPath;
if ([modelPath hasPrefix:@"file://"]) {
cleanPath = [modelPath substringFromIndex:7];
}
[_processor configureWithModelPath:cleanPath];
}
RCT_EXPORT_METHOD(deinitialize) {
NSLog(@"[ExecutorchWebRTC] deinitialize");
[_processor unloadModel];
}
RCT_EXPORT_METHOD(setBlurRadius : (double)radius) { [_processor setBlurRadius:(float)radius]; }
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isAvailable) { return @YES; }
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getProcessorName) { return PROCESSOR_NAME; }
#pragma mark - Legacy API (for backward compatibility)
RCT_EXPORT_METHOD(setup) { [ExecutorchWebRTC ensureRegistered]; }
RCT_EXPORT_METHOD(configureBackgroundRemoval : (NSString *)modelPath) {
[self initialize:modelPath];
}
RCT_EXPORT_METHOD(configureBackgroundBlur : (NSString *)modelPath blurIntensity : (int)intensity) {
[self initialize:modelPath];
[self setBlurRadius:intensity];
}
@end