// // Created by Marc Rousavy on 11.06.21. // #pragma once #include #include #include #include #include #include "RuntimeManager.h" #include "reanimated-headers/AndroidScheduler.h" #include "CameraView.h" #include "VisionCameraScheduler.h" #include "java-bindings/JFrameProcessorPlugin.h" namespace vision { using namespace facebook; class FrameProcessorRuntimeManager : public jni::HybridClass { public: static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/FrameProcessorRuntimeManager;"; static auto constexpr TAG = "VisionCamera"; static jni::local_ref initHybrid(jni::alias_ref jThis, jlong jsContext, jni::alias_ref jsCallInvokerHolder, jni::alias_ref androidScheduler); static void registerNatives(); explicit FrameProcessorRuntimeManager(jni::alias_ref jThis, jsi::Runtime* runtime, std::shared_ptr jsCallInvoker, std::shared_ptr scheduler) : javaPart_(jni::make_global(jThis)), runtime_(runtime), jsCallInvoker_(jsCallInvoker), scheduler_(scheduler) {} private: friend HybridBase; jni::global_ref javaPart_; jsi::Runtime* runtime_; std::shared_ptr jsCallInvoker_; std::shared_ptr _runtimeManager; std::shared_ptr scheduler_; jni::global_ref findCameraViewById(int viewId); void initializeRuntime(); void installJSIBindings(); void registerPlugin(alias_ref plugin); void logErrorToJS(const std::string& message); void setFrameProcessor(jsi::Runtime& runtime, // NOLINT(runtime/references) int viewTag, const jsi::Value& frameProcessor); void unsetFrameProcessor(int viewTag); }; } // namespace vision