-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Separate VisionCamera into two subspecs (#2761)
* feat: Separate VisionCamera into two subspecs * Swift * update podspec * fix: Refactor * some fixes * hmm * fix: Only export ObjC/Swift visible headers * fix: Also drop C++ sources * fix: Move to correct folder * fix: Fix any remaining C++ includes * chore: Format * fix: Fix missingg Swift include * fix: Add PluginRegistry Swift include * Update FrameProcessorPluginRegistry.h * fix: Disable location * fix: Use `public_header_files` instead of `preserve_paths` * Disable FP if needed * fix Podfile * fix: Fix `dispatch_queue_t` in Swift * fix: Disable FPs if not built * Revert "fix: Disable FPs if not built" This reverts commit 82cb560. * Remove Example Plugins from source code
- Loading branch information
Showing
19 changed files
with
331 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
package/ios/CameraViewManager+VisionCameraProxyDelegate.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// CameraViewManager+VisionCameraProxyDelegate.swift | ||
// VisionCamera | ||
// | ||
// Created by Marc Rousavy on 20.04.24. | ||
// | ||
|
||
import Foundation | ||
|
||
#if VISION_CAMERA_ENABLE_FRAME_PROCESSORS | ||
|
||
extension CameraViewManager: VisionCameraProxyDelegate { | ||
func getDispatchQueue() -> DispatchQueue { | ||
return CameraQueues.videoQueue | ||
} | ||
|
||
func getBridge() -> RCTBridge { | ||
return bridge | ||
} | ||
|
||
func setFrameProcessor(_ frameProcessor: FrameProcessor, forView viewTag: NSNumber) { | ||
DispatchQueue.main.async { | ||
let view = self.getCameraView(withTag: viewTag) | ||
view.frameProcessor = frameProcessor | ||
} | ||
} | ||
|
||
func removeFrameProcessor(forView viewTag: NSNumber) { | ||
DispatchQueue.main.async { | ||
let view = self.getCameraView(withTag: viewTag) | ||
view.frameProcessor = nil | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// VisionCameraInstaller.h | ||
// Pods | ||
// | ||
// Created by Marc Rousavy on 20.04.24. | ||
// | ||
|
||
#pragma once | ||
|
||
#import "VisionCameraProxyDelegate.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
A static class to install/inject the VisionCameraProxy into the global JS runtime. | ||
*/ | ||
@interface VisionCameraInstaller : NSObject | ||
|
||
+ (BOOL)installWithDelegate:(id<VisionCameraProxyDelegate>)delegate; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// VisionCameraInstaller.mm | ||
// DoubleConversion | ||
// | ||
// Created by Marc Rousavy on 20.04.24. | ||
// | ||
|
||
#import "VisionCameraInstaller.h" | ||
#import "VisionCameraProxy.h" | ||
#import <Foundation/Foundation.h> | ||
|
||
#import <React/RCTBridge+Private.h> | ||
#import <React/RCTBridge.h> | ||
#import <ReactCommon/RCTTurboModuleManager.h> | ||
|
||
@implementation VisionCameraInstaller | ||
|
||
+ (BOOL)installWithDelegate:(id<VisionCameraProxyDelegate>)delegate { | ||
// TODO: Migrate away from RCTBridge to support new arch. | ||
RCTBridge* bridge = delegate.getBridge; | ||
RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge; | ||
if (!cxxBridge.runtime) { | ||
return NO; | ||
} | ||
|
||
jsi::Runtime& runtime = *(jsi::Runtime*)cxxBridge.runtime; | ||
|
||
// global.VisionCameraProxy | ||
auto visionCameraProxy = std::make_shared<VisionCameraProxy>(runtime, bridge.jsCallInvoker, delegate); | ||
runtime.global().setProperty(runtime, "VisionCameraProxy", jsi::Object::createFromHostObject(runtime, visionCameraProxy)); | ||
|
||
return YES; | ||
} | ||
|
||
@end |
Oops, something went wrong.