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

#pragma once

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

#include "JVideoOrientation.hpp"
#include "VideoOrientation.hpp"

namespace margelo::nitro::video {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct VideoInformation by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    VideoInformation toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldBitrate = clazz->getField<double>("bitrate");
      double bitrate = this->getFieldValue(fieldBitrate);
      static const auto fieldWidth = clazz->getField<double>("width");
      double width = this->getFieldValue(fieldWidth);
      static const auto fieldHeight = clazz->getField<double>("height");
      double height = this->getFieldValue(fieldHeight);
      static const auto fieldDuration = clazz->getField<int64_t>("duration");
      int64_t duration = this->getFieldValue(fieldDuration);
      static const auto fieldFileSize = clazz->getField<int64_t>("fileSize");
      int64_t fileSize = this->getFieldValue(fieldFileSize);
      static const auto fieldIsHDR = clazz->getField<jboolean>("isHDR");
      jboolean isHDR = this->getFieldValue(fieldIsHDR);
      static const auto fieldIsLive = clazz->getField<jboolean>("isLive");
      jboolean isLive = this->getFieldValue(fieldIsLive);
      static const auto fieldOrientation = clazz->getField<JVideoOrientation>("orientation");
      jni::local_ref<JVideoOrientation> orientation = this->getFieldValue(fieldOrientation);
      return VideoInformation(
        bitrate,
        width,
        height,
        duration,
        fileSize,
        static_cast<bool>(isHDR),
        static_cast<bool>(isLive),
        orientation->toCpp()
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JVideoInformation::javaobject> fromCpp(const VideoInformation& value) {
      return newInstance(
        value.bitrate,
        value.width,
        value.height,
        value.duration,
        value.fileSize,
        value.isHDR,
        value.isLive,
        JVideoOrientation::fromCpp(value.orientation)
      );
    }
  };

} // namespace margelo::nitro::video
