// // Created by Marc Rousavy on 11.06.21. // #pragma once #include #include #include #include #include "Scheduler.h" #include "RuntimeManager.h" #include "reanimated-headers/AndroidScheduler.h" #include "CameraView.h" #include "FrameProcessorPlugin.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(); FrameProcessorRuntimeManager() {} 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_; CameraView* findCameraViewById(int viewId); void initializeRuntime(); void installJSIBindings(); void registerPlugin(alias_ref plugin); void logErrorToJS(const std::string& message); }; } // namespace vision