///
/// ReactNativeVideoDrmOnLoad.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///

#ifndef BUILDING_REACTNATIVEVIDEODRM_WITH_GENERATED_CMAKE_PROJECT
#error ReactNativeVideoDrmOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
#endif

#include "ReactNativeVideoDrmOnLoad.hpp"

#include <jni.h>
#include <fbjni/fbjni.h>
#include <NitroModules/HybridObjectRegistry.hpp>

#include "JHybridPluginManagerSpec.hpp"
#include <NitroModules/DefaultConstructableObject.hpp>

namespace margelo::nitro::videodrm {

int initialize(JavaVM* vm) {
  using namespace margelo::nitro;
  using namespace margelo::nitro::videodrm;
  using namespace facebook;

  return facebook::jni::initialize(vm, [] {
    // Register native JNI methods
    margelo::nitro::videodrm::JHybridPluginManagerSpec::registerNatives();

    // Register Nitro Hybrid Objects
    HybridObjectRegistry::registerHybridObjectConstructor(
      "PluginManager",
      []() -> std::shared_ptr<HybridObject> {
        static DefaultConstructableObject<JHybridPluginManagerSpec::javaobject> object("com/margelo/nitro/videodrm/PluginManager");
        auto instance = object.create();
        auto globalRef = jni::make_global(instance);
        return globalRef->cthis()->shared();
      }
    );
  });
}

} // namespace margelo::nitro::videodrm
