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

#include "JHybridVideoPlayerSourceSpec.hpp"

// Forward declaration of `NativeVideoConfig` to properly resolve imports.
namespace margelo::nitro::video { struct NativeVideoConfig; }
// Forward declaration of `NativeExternalSubtitle` to properly resolve imports.
namespace margelo::nitro::video { struct NativeExternalSubtitle; }
// Forward declaration of `SubtitleType` to properly resolve imports.
namespace margelo::nitro::video { enum class SubtitleType; }
// Forward declaration of `NativeDrmParams` to properly resolve imports.
namespace margelo::nitro::video { struct NativeDrmParams; }
// Forward declaration of `OnGetLicensePayload` to properly resolve imports.
namespace margelo::nitro::video { struct OnGetLicensePayload; }
// Forward declaration of `BufferConfig` to properly resolve imports.
namespace margelo::nitro::video { struct BufferConfig; }
// Forward declaration of `LivePlaybackParams` to properly resolve imports.
namespace margelo::nitro::video { struct LivePlaybackParams; }
// Forward declaration of `Resolution` to properly resolve imports.
namespace margelo::nitro::video { struct Resolution; }
// Forward declaration of `VideoInformation` to properly resolve imports.
namespace margelo::nitro::video { struct VideoInformation; }
// Forward declaration of `VideoOrientation` to properly resolve imports.
namespace margelo::nitro::video { enum class VideoOrientation; }

#include <string>
#include "NativeVideoConfig.hpp"
#include "JNativeVideoConfig.hpp"
#include "NativeExternalSubtitle.hpp"
#include <vector>
#include <optional>
#include "JNativeExternalSubtitle.hpp"
#include "SubtitleType.hpp"
#include "JSubtitleType.hpp"
#include "NativeDrmParams.hpp"
#include "JNativeDrmParams.hpp"
#include <unordered_map>
#include <NitroModules/Promise.hpp>
#include "OnGetLicensePayload.hpp"
#include <functional>
#include "JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload.hpp"
#include <NitroModules/JPromise.hpp>
#include "JOnGetLicensePayload.hpp"
#include "BufferConfig.hpp"
#include "JBufferConfig.hpp"
#include "LivePlaybackParams.hpp"
#include "JLivePlaybackParams.hpp"
#include "Resolution.hpp"
#include "JResolution.hpp"
#include "VideoInformation.hpp"
#include "JVideoInformation.hpp"
#include "VideoOrientation.hpp"
#include "JVideoOrientation.hpp"

namespace margelo::nitro::video {

  jni::local_ref<JHybridVideoPlayerSourceSpec::jhybriddata> JHybridVideoPlayerSourceSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
    return makeCxxInstance(jThis);
  }

  void JHybridVideoPlayerSourceSpec::registerNatives() {
    registerHybrid({
      makeNativeMethod("initHybrid", JHybridVideoPlayerSourceSpec::initHybrid),
    });
  }

  size_t JHybridVideoPlayerSourceSpec::getExternalMemorySize() noexcept {
    static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
    return method(_javaPart);
  }

  void JHybridVideoPlayerSourceSpec::dispose() noexcept {
    static const auto method = javaClassStatic()->getMethod<void()>("dispose");
    method(_javaPart);
  }

  // Properties
  std::string JHybridVideoPlayerSourceSpec::getUri() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getUri");
    auto __result = method(_javaPart);
    return __result->toStdString();
  }
  NativeVideoConfig JHybridVideoPlayerSourceSpec::getConfig() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JNativeVideoConfig>()>("getConfig");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }

  // Methods
  std::shared_ptr<Promise<VideoInformation>> JHybridVideoPlayerSourceSpec::getAssetInformationAsync() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getAssetInformationAsync");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<VideoInformation>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<JVideoInformation>(__boxedResult);
        __promise->resolve(__result->toCpp());
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }

} // namespace margelo::nitro::video
