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

#include "JHybridVideoViewSpec.hpp"

// Forward declaration of `ResizeMode` to properly resolve imports.
namespace margelo::nitro::aviation { enum class ResizeMode; }
// Forward declaration of `SurfaceType` to properly resolve imports.
namespace margelo::nitro::aviation { enum class SurfaceType; }
// Forward declaration of `VideoTrackSelection` to properly resolve imports.
namespace margelo::nitro::aviation { struct VideoTrackSelection; }
// Forward declaration of `VideoTrackSelectionType` to properly resolve imports.
namespace margelo::nitro::aviation { enum class VideoTrackSelectionType; }
// Forward declaration of `SubtitleTrackSelection` to properly resolve imports.
namespace margelo::nitro::aviation { struct SubtitleTrackSelection; }
// Forward declaration of `SubtitleTrackSelectionType` to properly resolve imports.
namespace margelo::nitro::aviation { enum class SubtitleTrackSelectionType; }
// Forward declaration of `AudioTrackSelection` to properly resolve imports.
namespace margelo::nitro::aviation { struct AudioTrackSelection; }
// Forward declaration of `AudioTrackSelectionType` to properly resolve imports.
namespace margelo::nitro::aviation { enum class AudioTrackSelectionType; }
// Forward declaration of `VideoSource` to properly resolve imports.
namespace margelo::nitro::aviation { struct VideoSource; }
// Forward declaration of `VideoMediaType` to properly resolve imports.
namespace margelo::nitro::aviation { enum class VideoMediaType; }
// Forward declaration of `DrmType` to properly resolve imports.
namespace margelo::nitro::aviation { enum class DrmType; }
// Forward declaration of `HybridPlaybackEngineSpec` to properly resolve imports.
namespace margelo::nitro::aviation { class HybridPlaybackEngineSpec; }
// Forward declaration of `FullscreenConfig` to properly resolve imports.
namespace margelo::nitro::aviation { struct FullscreenConfig; }

#include "ResizeMode.hpp"
#include "JResizeMode.hpp"
#include <functional>
#include "JFunc_void.hpp"
#include <NitroModules/JNICallable.hpp>
#include "SurfaceType.hpp"
#include "JSurfaceType.hpp"
#include "VideoTrackSelection.hpp"
#include "JVideoTrackSelection.hpp"
#include "VideoTrackSelectionType.hpp"
#include "JVideoTrackSelectionType.hpp"
#include <optional>
#include "SubtitleTrackSelection.hpp"
#include "JSubtitleTrackSelection.hpp"
#include "SubtitleTrackSelectionType.hpp"
#include "JSubtitleTrackSelectionType.hpp"
#include <string>
#include "AudioTrackSelection.hpp"
#include "JAudioTrackSelection.hpp"
#include "AudioTrackSelectionType.hpp"
#include "JAudioTrackSelectionType.hpp"
#include "VideoSource.hpp"
#include "JVideoSource.hpp"
#include "VideoMediaType.hpp"
#include "JVideoMediaType.hpp"
#include <unordered_map>
#include "DrmType.hpp"
#include "JDrmType.hpp"
#include <memory>
#include "HybridPlaybackEngineSpec.hpp"
#include "JHybridPlaybackEngineSpec.hpp"
#include "FullscreenConfig.hpp"
#include "JFullscreenConfig.hpp"

namespace margelo::nitro::aviation {

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

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

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

  bool JHybridVideoViewSpec::equals(const std::shared_ptr<HybridObject>& other) {
    if (auto otherCast = std::dynamic_pointer_cast<JHybridVideoViewSpec>(other)) {
      return _javaPart == otherCast->_javaPart;
    }
    return false;
  }

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

  std::string JHybridVideoViewSpec::toString() {
    static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
    auto javaString = method(_javaPart);
    return javaString->toStdString();
  }

  // Properties
  ResizeMode JHybridVideoViewSpec::getResizeMode() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JResizeMode>()>("getResizeMode");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  void JHybridVideoViewSpec::setResizeMode(ResizeMode resizeMode) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JResizeMode> /* resizeMode */)>("setResizeMode");
    method(_javaPart, JResizeMode::fromCpp(resizeMode));
  }
  bool JHybridVideoViewSpec::getPipEnabled() {
    static const auto method = javaClassStatic()->getMethod<jboolean()>("getPipEnabled");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  void JHybridVideoViewSpec::setPipEnabled(bool pipEnabled) {
    static const auto method = javaClassStatic()->getMethod<void(jboolean /* pipEnabled */)>("setPipEnabled");
    method(_javaPart, pipEnabled);
  }
  bool JHybridVideoViewSpec::getPlayInBackground() {
    static const auto method = javaClassStatic()->getMethod<jboolean()>("getPlayInBackground");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  void JHybridVideoViewSpec::setPlayInBackground(bool playInBackground) {
    static const auto method = javaClassStatic()->getMethod<void(jboolean /* playInBackground */)>("setPlayInBackground");
    method(_javaPart, playInBackground);
  }
  std::function<void()> JHybridVideoViewSpec::getOnPipStart() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnPipStart_cxx");
    auto __result = method(_javaPart);
    return [&]() -> std::function<void()> {
      if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
        auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
        return downcast->cthis()->getFunction();
      } else {
        auto __resultRef = jni::make_global(__result);
        return JNICallable<JFunc_void, void()>(std::move(__resultRef));
      }
    }();
  }
  void JHybridVideoViewSpec::setOnPipStart(const std::function<void()>& onPipStart) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onPipStart */)>("setOnPipStart_cxx");
    method(_javaPart, JFunc_void_cxx::fromCpp(onPipStart));
  }
  std::function<void()> JHybridVideoViewSpec::getOnPipStop() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnPipStop_cxx");
    auto __result = method(_javaPart);
    return [&]() -> std::function<void()> {
      if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
        auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
        return downcast->cthis()->getFunction();
      } else {
        auto __resultRef = jni::make_global(__result);
        return JNICallable<JFunc_void, void()>(std::move(__resultRef));
      }
    }();
  }
  void JHybridVideoViewSpec::setOnPipStop(const std::function<void()>& onPipStop) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onPipStop */)>("setOnPipStop_cxx");
    method(_javaPart, JFunc_void_cxx::fromCpp(onPipStop));
  }
  SurfaceType JHybridVideoViewSpec::getSurfaceType() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JSurfaceType>()>("getSurfaceType");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  void JHybridVideoViewSpec::setSurfaceType(SurfaceType surfaceType) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JSurfaceType> /* surfaceType */)>("setSurfaceType");
    method(_javaPart, JSurfaceType::fromCpp(surfaceType));
  }
  std::function<void()> JHybridVideoViewSpec::getOnFullscreenEnter() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnFullscreenEnter_cxx");
    auto __result = method(_javaPart);
    return [&]() -> std::function<void()> {
      if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
        auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
        return downcast->cthis()->getFunction();
      } else {
        auto __resultRef = jni::make_global(__result);
        return JNICallable<JFunc_void, void()>(std::move(__resultRef));
      }
    }();
  }
  void JHybridVideoViewSpec::setOnFullscreenEnter(const std::function<void()>& onFullscreenEnter) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onFullscreenEnter */)>("setOnFullscreenEnter_cxx");
    method(_javaPart, JFunc_void_cxx::fromCpp(onFullscreenEnter));
  }
  std::function<void()> JHybridVideoViewSpec::getOnFullscreenExit() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnFullscreenExit_cxx");
    auto __result = method(_javaPart);
    return [&]() -> std::function<void()> {
      if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
        auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
        return downcast->cthis()->getFunction();
      } else {
        auto __resultRef = jni::make_global(__result);
        return JNICallable<JFunc_void, void()>(std::move(__resultRef));
      }
    }();
  }
  void JHybridVideoViewSpec::setOnFullscreenExit(const std::function<void()>& onFullscreenExit) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onFullscreenExit */)>("setOnFullscreenExit_cxx");
    method(_javaPart, JFunc_void_cxx::fromCpp(onFullscreenExit));
  }
  VideoTrackSelection JHybridVideoViewSpec::getSelectedVideoTrack() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JVideoTrackSelection>()>("getSelectedVideoTrack");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  void JHybridVideoViewSpec::setSelectedVideoTrack(const VideoTrackSelection& selectedVideoTrack) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JVideoTrackSelection> /* selectedVideoTrack */)>("setSelectedVideoTrack");
    method(_javaPart, JVideoTrackSelection::fromCpp(selectedVideoTrack));
  }
  SubtitleTrackSelection JHybridVideoViewSpec::getSelectedSubtitleTrack() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JSubtitleTrackSelection>()>("getSelectedSubtitleTrack");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  void JHybridVideoViewSpec::setSelectedSubtitleTrack(const SubtitleTrackSelection& selectedSubtitleTrack) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JSubtitleTrackSelection> /* selectedSubtitleTrack */)>("setSelectedSubtitleTrack");
    method(_javaPart, JSubtitleTrackSelection::fromCpp(selectedSubtitleTrack));
  }
  AudioTrackSelection JHybridVideoViewSpec::getSelectedAudioTrack() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JAudioTrackSelection>()>("getSelectedAudioTrack");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  void JHybridVideoViewSpec::setSelectedAudioTrack(const AudioTrackSelection& selectedAudioTrack) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JAudioTrackSelection> /* selectedAudioTrack */)>("setSelectedAudioTrack");
    method(_javaPart, JAudioTrackSelection::fromCpp(selectedAudioTrack));
  }
  std::string JHybridVideoViewSpec::getAdTagUrl() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getAdTagUrl");
    auto __result = method(_javaPart);
    return __result->toStdString();
  }
  void JHybridVideoViewSpec::setAdTagUrl(const std::string& adTagUrl) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* adTagUrl */)>("setAdTagUrl");
    method(_javaPart, jni::make_jstring(adTagUrl));
  }
  VideoSource JHybridVideoViewSpec::getSource() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JVideoSource>()>("getSource");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  void JHybridVideoViewSpec::setSource(const VideoSource& source) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JVideoSource> /* source */)>("setSource");
    method(_javaPart, JVideoSource::fromCpp(source));
  }
  bool JHybridVideoViewSpec::getAutoPlay() {
    static const auto method = javaClassStatic()->getMethod<jboolean()>("getAutoPlay");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  void JHybridVideoViewSpec::setAutoPlay(bool autoPlay) {
    static const auto method = javaClassStatic()->getMethod<void(jboolean /* autoPlay */)>("setAutoPlay");
    method(_javaPart, autoPlay);
  }

  // Methods
  void JHybridVideoViewSpec::attachEngine(const std::shared_ptr<HybridPlaybackEngineSpec>& engine) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JHybridPlaybackEngineSpec::javaobject> /* engine */)>("attachEngine");
    method(_javaPart, std::dynamic_pointer_cast<JHybridPlaybackEngineSpec>(engine)->getJavaPart());
  }
  void JHybridVideoViewSpec::detachEngine() {
    static const auto method = javaClassStatic()->getMethod<void()>("detachEngine");
    method(_javaPart);
  }
  void JHybridVideoViewSpec::startPictureInPicture() {
    static const auto method = javaClassStatic()->getMethod<void()>("startPictureInPicture");
    method(_javaPart);
  }
  void JHybridVideoViewSpec::stopPictureInPicture() {
    static const auto method = javaClassStatic()->getMethod<void()>("stopPictureInPicture");
    method(_javaPart);
  }
  void JHybridVideoViewSpec::enterFullscreen(const std::optional<FullscreenConfig>& config) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFullscreenConfig> /* config */)>("enterFullscreen");
    method(_javaPart, config.has_value() ? JFullscreenConfig::fromCpp(config.value()) : nullptr);
  }
  void JHybridVideoViewSpec::exitFullscreen() {
    static const auto method = javaClassStatic()->getMethod<void()>("exitFullscreen");
    method(_javaPart);
  }
  bool JHybridVideoViewSpec::isFullscreen() {
    static const auto method = javaClassStatic()->getMethod<jboolean()>("isFullscreen");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  void JHybridVideoViewSpec::enterNativeFullscreen() {
    static const auto method = javaClassStatic()->getMethod<void()>("enterNativeFullscreen");
    method(_javaPart);
  }
  void JHybridVideoViewSpec::applyVideoTrack(const VideoTrackSelection& selection) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JVideoTrackSelection> /* selection */)>("applyVideoTrack");
    method(_javaPart, JVideoTrackSelection::fromCpp(selection));
  }
  void JHybridVideoViewSpec::applySubtitleTrack(const SubtitleTrackSelection& selection) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JSubtitleTrackSelection> /* selection */)>("applySubtitleTrack");
    method(_javaPart, JSubtitleTrackSelection::fromCpp(selection));
  }
  void JHybridVideoViewSpec::applyAudioTrack(const AudioTrackSelection& selection) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JAudioTrackSelection> /* selection */)>("applyAudioTrack");
    method(_javaPart, JAudioTrackSelection::fromCpp(selection));
  }

} // namespace margelo::nitro::aviation
