feat: Frame Processors: Allow returning Frame
s (support for resize and other frame manipulations) (#185)
* batch * Init Frame as box * Use ObjC syntax * Fix access * Revert "Fix access" This reverts commit 7de09e52739d4c2b53f485d5ed696f1665fa5737. * Revert "Use ObjC syntax" This reverts commit e33f05ae8451cc4ee24af41d14dc76a57c157554. * Revert "Init Frame as box" This reverts commit 5adafb6109bfbf7fddb8ddc4af7d306b7b76b476. * use holder * convert buffer <-> jsi object * add docs * add more docs * Update JSIUtils.mm * Update FRAME_PROCESSORS_CREATE_OVERVIEW.mdx * Update CameraView+RecordVideo.swift
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
#import <ReactCommon/CallInvoker.h>
|
||||
#import <React/RCTBridge.h>
|
||||
#import <ReactCommon/TurboModuleUtils.h>
|
||||
#import "../Frame Processor/CMSampleBufferRefHolder.h"
|
||||
#import "../Frame Processor/FrameHostObject.h"
|
||||
|
||||
using namespace facebook;
|
||||
using namespace facebook::react;
|
||||
@@ -66,6 +68,11 @@ jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value)
|
||||
return convertNSArrayToJSIArray(runtime, (NSArray *)value);
|
||||
} else if (value == (id)kCFNull) {
|
||||
return jsi::Value::null();
|
||||
} else if ([value isKindOfClass:[CMSampleBufferRefHolder class]]) {
|
||||
// it's boxed in a CMSampleBufferRefHolder because CMSampleBufferRef is not an NSObject
|
||||
CMSampleBufferRef buffer = [(CMSampleBufferRefHolder*)value buffer];
|
||||
auto frame = std::make_shared<FrameHostObject>(buffer);
|
||||
return jsi::Object::createFromHostObject(runtime, frame);
|
||||
}
|
||||
return jsi::Value::undefined();
|
||||
}
|
||||
@@ -144,6 +151,13 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s
|
||||
if (o.isFunction(runtime)) {
|
||||
return convertJSIFunctionToCallback(runtime, std::move(o.getFunction(runtime)), jsInvoker);
|
||||
}
|
||||
if (o.isHostObject(runtime)) {
|
||||
auto hostObject = o.asHostObject(runtime);
|
||||
auto frame = dynamic_cast<FrameHostObject*>(hostObject.get());
|
||||
if (frame != nullptr) {
|
||||
return [[CMSampleBufferRefHolder alloc] initWithBuffer:frame->buffer];
|
||||
}
|
||||
}
|
||||
return convertJSIObjectToNSDictionary(runtime, o, jsInvoker);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user