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

#include "JHybridCameraFrameOutputSpec.hpp"

// Forward declaration of `HybridNativeThreadSpec` to properly resolve imports.
namespace margelo::nitro::camera { class HybridNativeThreadSpec; }
// Forward declaration of `HybridFrameSpec` to properly resolve imports.
namespace margelo::nitro::camera { class HybridFrameSpec; }
// Forward declaration of `FrameDroppedReason` to properly resolve imports.
namespace margelo::nitro::camera { enum class FrameDroppedReason; }
// Forward declaration of `MediaType` to properly resolve imports.
namespace margelo::nitro::camera { enum class MediaType; }
// Forward declaration of `CameraOrientation` to properly resolve imports.
namespace margelo::nitro::camera { enum class CameraOrientation; }
// Forward declaration of `Size` to properly resolve imports.
namespace margelo::nitro::camera { struct Size; }

#include <memory>
#include "HybridNativeThreadSpec.hpp"
#include "JHybridNativeThreadSpec.hpp"
#include "HybridFrameSpec.hpp"
#include <functional>
#include <optional>
#include "JFunc_bool_std__shared_ptr_HybridFrameSpec_.hpp"
#include <NitroModules/JNICallable.hpp>
#include "JHybridFrameSpec.hpp"
#include "FrameDroppedReason.hpp"
#include "JFunc_void_FrameDroppedReason.hpp"
#include "JFrameDroppedReason.hpp"
#include "MediaType.hpp"
#include "JMediaType.hpp"
#include "CameraOrientation.hpp"
#include "JCameraOrientation.hpp"
#include "Size.hpp"
#include "JSize.hpp"

namespace margelo::nitro::camera {

  std::shared_ptr<JHybridCameraFrameOutputSpec> JHybridCameraFrameOutputSpec::JavaPart::getJHybridCameraFrameOutputSpec() {
    auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
    auto castHybridObject = std::dynamic_pointer_cast<JHybridCameraFrameOutputSpec>(hybridObject);
    if (castHybridObject == nullptr) [[unlikely]] {
      throw std::runtime_error("Failed to downcast JHybridObject to JHybridCameraFrameOutputSpec!");
    }
    return castHybridObject;
  }

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

  std::shared_ptr<JHybridObject> JHybridCameraFrameOutputSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
    auto castJavaPart = jni::dynamic_ref_cast<JHybridCameraFrameOutputSpec::JavaPart>(javaPart);
    if (castJavaPart == nullptr) [[unlikely]] {
      throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridCameraFrameOutputSpec::JavaPart!");
    }
    return std::make_shared<JHybridCameraFrameOutputSpec>(castJavaPart);
  }

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

  // Properties
  std::shared_ptr<HybridNativeThreadSpec> JHybridCameraFrameOutputSpec::getThread() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JHybridNativeThreadSpec::JavaPart>()>("getThread");
    auto __result = method(_javaPart);
    return __result->getJHybridNativeThreadSpec();
  }
  MediaType JHybridCameraFrameOutputSpec::getMediaType() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JMediaType>()>("getMediaType");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  CameraOrientation JHybridCameraFrameOutputSpec::getOutputOrientation() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JCameraOrientation>()>("getOutputOrientation");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  void JHybridCameraFrameOutputSpec::setOutputOrientation(CameraOrientation outputOrientation) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JCameraOrientation> /* outputOrientation */)>("setOutputOrientation");
    method(_javaPart, JCameraOrientation::fromCpp(outputOrientation));
  }
  std::optional<Size> JHybridCameraFrameOutputSpec::getCurrentResolution() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JSize>()>("getCurrentResolution");
    auto __result = method(_javaPart);
    return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
  }

  // Methods
  void JHybridCameraFrameOutputSpec::setOnFrameCallback(const std::optional<std::function<bool(const std::shared_ptr<HybridFrameSpec>& /* frame */)>>& onFrame) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_bool_std__shared_ptr_HybridFrameSpec_::javaobject> /* onFrame */)>("setOnFrameCallback_cxx");
    method(_javaPart, onFrame.has_value() ? JFunc_bool_std__shared_ptr_HybridFrameSpec__cxx::fromCpp(onFrame.value()) : nullptr);
  }
  void JHybridCameraFrameOutputSpec::setOnFrameDroppedCallback(const std::optional<std::function<void(FrameDroppedReason /* reason */)>>& onFrameDropped) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_FrameDroppedReason::javaobject> /* onFrameDropped */)>("setOnFrameDroppedCallback_cxx");
    method(_javaPart, onFrameDropped.has_value() ? JFunc_void_FrameDroppedReason_cxx::fromCpp(onFrameDropped.value()) : nullptr);
  }

} // namespace margelo::nitro::camera
