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

#pragma once

#include <fbjni/fbjni.h>
#include "FrameOutputOptions.hpp"

#include "JSize.hpp"
#include "JTargetVideoPixelFormat.hpp"
#include "Size.hpp"
#include "TargetVideoPixelFormat.hpp"

namespace margelo::nitro::camera {

  using namespace facebook;

  /**
   * The C++ JNI bridge between the C++ struct "FrameOutputOptions" and the the Kotlin data class "FrameOutputOptions".
   */
  struct JFrameOutputOptions final: public jni::JavaClass<JFrameOutputOptions> {
  public:
    static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/FrameOutputOptions;";

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct FrameOutputOptions by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    FrameOutputOptions toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldTargetResolution = clazz->getField<JSize>("targetResolution");
      jni::local_ref<JSize> targetResolution = this->getFieldValue(fieldTargetResolution);
      static const auto fieldEnablePreviewSizedOutputBuffers = clazz->getField<jboolean>("enablePreviewSizedOutputBuffers");
      jboolean enablePreviewSizedOutputBuffers = this->getFieldValue(fieldEnablePreviewSizedOutputBuffers);
      static const auto fieldAllowDeferredStart = clazz->getField<jboolean>("allowDeferredStart");
      jboolean allowDeferredStart = this->getFieldValue(fieldAllowDeferredStart);
      static const auto fieldPixelFormat = clazz->getField<JTargetVideoPixelFormat>("pixelFormat");
      jni::local_ref<JTargetVideoPixelFormat> pixelFormat = this->getFieldValue(fieldPixelFormat);
      static const auto fieldEnablePhysicalBufferRotation = clazz->getField<jboolean>("enablePhysicalBufferRotation");
      jboolean enablePhysicalBufferRotation = this->getFieldValue(fieldEnablePhysicalBufferRotation);
      static const auto fieldEnableCameraMatrixDelivery = clazz->getField<jboolean>("enableCameraMatrixDelivery");
      jboolean enableCameraMatrixDelivery = this->getFieldValue(fieldEnableCameraMatrixDelivery);
      static const auto fieldDropFramesWhileBusy = clazz->getField<jboolean>("dropFramesWhileBusy");
      jboolean dropFramesWhileBusy = this->getFieldValue(fieldDropFramesWhileBusy);
      return FrameOutputOptions(
        targetResolution->toCpp(),
        static_cast<bool>(enablePreviewSizedOutputBuffers),
        static_cast<bool>(allowDeferredStart),
        pixelFormat->toCpp(),
        static_cast<bool>(enablePhysicalBufferRotation),
        static_cast<bool>(enableCameraMatrixDelivery),
        static_cast<bool>(dropFramesWhileBusy)
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JFrameOutputOptions::javaobject> fromCpp(const FrameOutputOptions& value) {
      using JSignature = JFrameOutputOptions(jni::alias_ref<JSize>, jboolean, jboolean, jni::alias_ref<JTargetVideoPixelFormat>, jboolean, jboolean, jboolean);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        JSize::fromCpp(value.targetResolution),
        value.enablePreviewSizedOutputBuffers,
        value.allowDeferredStart,
        JTargetVideoPixelFormat::fromCpp(value.pixelFormat),
        value.enablePhysicalBufferRotation,
        value.enableCameraMatrixDelivery,
        value.dropFramesWhileBusy
      );
    }
  };

} // namespace margelo::nitro::camera
