///
/// JVideoOutputSettings.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 "VideoOutputSettings.hpp"

#include "JVideoCodec.hpp"
#include "VideoCodec.hpp"
#include <optional>

namespace margelo::nitro::camera {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct VideoOutputSettings by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    VideoOutputSettings toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldCodec = clazz->getField<JVideoCodec>("codec");
      jni::local_ref<JVideoCodec> codec = this->getFieldValue(fieldCodec);
      return VideoOutputSettings(
        codec != nullptr ? std::make_optional(codec->toCpp()) : std::nullopt
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JVideoOutputSettings::javaobject> fromCpp(const VideoOutputSettings& value) {
      using JSignature = JVideoOutputSettings(jni::alias_ref<JVideoCodec>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.codec.has_value() ? JVideoCodec::fromCpp(value.codec.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::camera
