feat: Frame Processors: Allow returning Frames (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:
22
ios/Frame Processor/CMSampleBufferRefHolder.h
Normal file
22
ios/Frame Processor/CMSampleBufferRefHolder.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// CMSampleBufferRefHolder.h
|
||||
// VisionCamera
|
||||
//
|
||||
// Created by Marc Rousavy on 15.03.21.
|
||||
// Copyright © 2021 mrousavy. All rights reserved.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreMedia/CMSampleBuffer.h>
|
||||
|
||||
@interface CMSampleBufferRefHolder : NSObject {
|
||||
CMSampleBufferRef buffer;
|
||||
}
|
||||
|
||||
- (instancetype) initWithBuffer:(CMSampleBufferRef)buffer;
|
||||
|
||||
@property (nonatomic) CMSampleBufferRef buffer;
|
||||
|
||||
@end
|
||||
25
ios/Frame Processor/CMSampleBufferRefHolder.m
Normal file
25
ios/Frame Processor/CMSampleBufferRefHolder.m
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// CMSampleBufferRefHolder.m
|
||||
// VisionCamera
|
||||
//
|
||||
// Created by Marc Rousavy on 08.06.21.
|
||||
// Copyright © 2021 mrousavy. All rights reserved.
|
||||
//
|
||||
|
||||
#import "CMSampleBufferRefHolder.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreMedia/CMSampleBuffer.h>
|
||||
|
||||
@implementation CMSampleBufferRefHolder
|
||||
|
||||
- (instancetype) initWithBuffer:(CMSampleBufferRef)buffer {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.buffer = buffer;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@synthesize buffer;
|
||||
|
||||
@end
|
||||
@@ -1,20 +0,0 @@
|
||||
//
|
||||
// Frame.h
|
||||
// VisionCamera
|
||||
//
|
||||
// Created by Marc Rousavy on 15.03.21.
|
||||
// Copyright © 2021 mrousavy. All rights reserved.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <CoreMedia/CMSampleBuffer.h>
|
||||
|
||||
// TODO: Make this Objective-C so it can be imported in Swift?
|
||||
class Frame {
|
||||
public:
|
||||
explicit Frame(CMSampleBufferRef buffer): buffer(buffer) {}
|
||||
|
||||
public:
|
||||
CMSampleBufferRef buffer;
|
||||
};
|
||||
@@ -8,19 +8,21 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#import "Frame.h"
|
||||
#import <jsi/jsi.h>
|
||||
#import <CoreMedia/CMSampleBuffer.h>
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
class JSI_EXPORT FrameHostObject: public Frame, public jsi::HostObject {
|
||||
class JSI_EXPORT FrameHostObject: public jsi::HostObject {
|
||||
public:
|
||||
explicit FrameHostObject(CMSampleBufferRef buffer): Frame(buffer) {}
|
||||
explicit FrameHostObject(CMSampleBufferRef buffer): buffer(buffer) {}
|
||||
~FrameHostObject();
|
||||
|
||||
public:
|
||||
jsi::Value get(jsi::Runtime&, const jsi::PropNameID& name) override;
|
||||
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& rt) override;
|
||||
void destroyBuffer();
|
||||
|
||||
public:
|
||||
CMSampleBufferRef buffer;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user