From 66471967e363ee1ec0f8e241928809126d92c4ea Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 19 Jul 2026 19:41:10 +0200 Subject: [PATCH] fix(nitro): fix native codegen --- .../generated/android/c++/JBoolProperty.hpp | 2 +- .../generated/android/c++/JCastStatus.hpp | 67 +++++++++++++ .../android/c++/JHybridOmniPlayerSpec.cpp | 45 +++++---- .../android/c++/JHybridOmniPlayerSpec.hpp | 2 + .../android/c++/JHybridOmniViewSpec.cpp | 22 +++++ .../android/c++/JHybridOmniViewSpec.hpp | 2 + .../generated/android/c++/JJassubAssets.hpp | 70 ++++++++++++++ nitrogen/generated/android/c++/JMetadata.hpp | 2 +- .../generated/android/c++/JMixAudioMode.hpp | 2 +- .../generated/android/c++/JNumberProperty.hpp | 5 +- nitrogen/generated/android/c++/JPgsAssets.hpp | 58 +++++++++++ .../generated/android/c++/JPlayerStatus.hpp | 2 +- nitrogen/generated/android/c++/JRendition.hpp | 2 +- nitrogen/generated/android/c++/JSource.hpp | 79 +++++++++++---- nitrogen/generated/android/c++/JSubtitle.hpp | 2 +- .../generated/android/c++/JSubtitleAssets.hpp | 66 +++++++++++++ nitrogen/generated/android/c++/JTrack.hpp | 2 +- nitrogen/generated/android/c++/JVideoSrc.hpp | 2 +- .../c++/views/JHybridOmniViewStateUpdater.cpp | 4 + .../com/margelo/nitro/omni/CastStatus.kt | 26 +++++ .../nitro/omni/HybridOmniPlayerSpec.kt | 8 ++ .../margelo/nitro/omni/HybridOmniViewSpec.kt | 6 ++ .../com/margelo/nitro/omni/JassubAssets.kt | 66 +++++++++++++ .../kotlin/com/margelo/nitro/omni/Metadata.kt | 23 +++++ .../com/margelo/nitro/omni/NumberProperty.kt | 3 +- .../com/margelo/nitro/omni/PgsAssets.kt | 51 ++++++++++ .../com/margelo/nitro/omni/Rendition.kt | 21 ++++ .../kotlin/com/margelo/nitro/omni/Source.kt | 37 ++++++- .../kotlin/com/margelo/nitro/omni/Subtitle.kt | 21 ++++ .../com/margelo/nitro/omni/SubtitleAssets.kt | 56 +++++++++++ .../kotlin/com/margelo/nitro/omni/Track.kt | 19 ++++ .../kotlin/com/margelo/nitro/omni/VideoSrc.kt | 17 ++++ nitrogen/generated/shared/c++/CastStatus.hpp | 88 +++++++++++++++++ .../shared/c++/HybridOmniPlayerSpec.cpp | 2 + .../shared/c++/HybridOmniPlayerSpec.hpp | 5 + .../shared/c++/HybridOmniViewSpec.cpp | 2 + .../shared/c++/HybridOmniViewSpec.hpp | 5 + .../generated/shared/c++/JassubAssets.hpp | 96 +++++++++++++++++++ .../generated/shared/c++/NumberProperty.hpp | 4 + nitrogen/generated/shared/c++/PgsAssets.hpp | 84 ++++++++++++++++ nitrogen/generated/shared/c++/Source.hpp | 14 ++- .../generated/shared/c++/SubtitleAssets.hpp | 92 ++++++++++++++++++ .../c++/views/HybridOmniViewComponent.cpp | 13 ++- .../c++/views/HybridOmniViewComponent.hpp | 2 + .../generated/shared/json/OmniViewConfig.json | 1 + src/types/source.ts | 2 +- src/types/subtitles.ts | 32 ++++--- src/view.web.tsx | 29 +++--- 48 files changed, 1179 insertions(+), 82 deletions(-) create mode 100644 nitrogen/generated/android/c++/JCastStatus.hpp create mode 100644 nitrogen/generated/android/c++/JJassubAssets.hpp create mode 100644 nitrogen/generated/android/c++/JPgsAssets.hpp create mode 100644 nitrogen/generated/android/c++/JSubtitleAssets.hpp create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/CastStatus.kt create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/JassubAssets.kt create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/PgsAssets.kt create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/SubtitleAssets.kt create mode 100644 nitrogen/generated/shared/c++/CastStatus.hpp create mode 100644 nitrogen/generated/shared/c++/JassubAssets.hpp create mode 100644 nitrogen/generated/shared/c++/PgsAssets.hpp create mode 100644 nitrogen/generated/shared/c++/SubtitleAssets.hpp diff --git a/nitrogen/generated/android/c++/JBoolProperty.hpp b/nitrogen/generated/android/c++/JBoolProperty.hpp index af2099a..05e6a4c 100644 --- a/nitrogen/generated/android/c++/JBoolProperty.hpp +++ b/nitrogen/generated/android/c++/JBoolProperty.hpp @@ -15,7 +15,7 @@ namespace margelo::nitro::omni { using namespace facebook; /** - * The C++ JNI bridge between the C++ enum "BoolProperty" and the the Kotlin enum "BoolProperty". + * The C++ JNI bridge between the C++ enum "BoolProperty" and the Kotlin enum "BoolProperty". */ struct JBoolProperty final: public jni::JavaClass { public: diff --git a/nitrogen/generated/android/c++/JCastStatus.hpp b/nitrogen/generated/android/c++/JCastStatus.hpp new file mode 100644 index 0000000..dd50f3d --- /dev/null +++ b/nitrogen/generated/android/c++/JCastStatus.hpp @@ -0,0 +1,67 @@ +/// +/// JCastStatus.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "CastStatus.hpp" + +namespace margelo::nitro::omni { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ enum "CastStatus" and the Kotlin enum "CastStatus". + */ + struct JCastStatus final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/CastStatus;"; + + public: + /** + * Convert this Java/Kotlin-based enum to the C++ enum CastStatus. + */ + [[maybe_unused]] + [[nodiscard]] + CastStatus toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldOrdinal = clazz->getField("value"); + int ordinal = this->getFieldValue(fieldOrdinal); + return static_cast(ordinal); + } + + public: + /** + * Create a Java/Kotlin-based enum with the given C++ enum's value. + */ + [[maybe_unused]] + static jni::alias_ref fromCpp(CastStatus value) { + static const auto clazz = javaClassStatic(); + switch (value) { + case CastStatus::CONNECTING: + static const auto fieldCONNECTING = clazz->getStaticField("CONNECTING"); + return clazz->getStaticFieldValue(fieldCONNECTING); + case CastStatus::CONNECTED: + static const auto fieldCONNECTED = clazz->getStaticField("CONNECTED"); + return clazz->getStaticFieldValue(fieldCONNECTED); + case CastStatus::AVAILABLE: + static const auto fieldAVAILABLE = clazz->getStaticField("AVAILABLE"); + return clazz->getStaticFieldValue(fieldAVAILABLE); + case CastStatus::UNAVAILABLE: + static const auto fieldUNAVAILABLE = clazz->getStaticField("UNAVAILABLE"); + return clazz->getStaticFieldValue(fieldUNAVAILABLE); + case CastStatus::UNSUPPORTED: + static const auto fieldUNSUPPORTED = clazz->getStaticField("UNSUPPORTED"); + return clazz->getStaticFieldValue(fieldUNSUPPORTED); + default: + std::string stringValue = std::to_string(static_cast(value)); + throw std::invalid_argument("Invalid enum value (" + stringValue + "!"); + } + } + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.cpp b/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.cpp index b4da873..e24ba15 100644 --- a/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.cpp +++ b/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.cpp @@ -15,6 +15,8 @@ namespace margelo::nitro::omni { struct Track; } namespace margelo::nitro::omni { struct Rendition; } // Forward declaration of `PlayerStatus` to properly resolve imports. namespace margelo::nitro::omni { enum class PlayerStatus; } +// Forward declaration of `CastStatus` to properly resolve imports. +namespace margelo::nitro::omni { enum class CastStatus; } // Forward declaration of `Source` to properly resolve imports. namespace margelo::nitro::omni { struct Source; } // Forward declaration of `VideoSrc` to properly resolve imports. @@ -38,6 +40,8 @@ namespace margelo::nitro::omni { enum class MixAudioMode; } #include "JRendition.hpp" #include "PlayerStatus.hpp" #include "JPlayerStatus.hpp" +#include "CastStatus.hpp" +#include "JCastStatus.hpp" #include "Source.hpp" #include "JSource.hpp" #include "VideoSrc.hpp" @@ -107,58 +111,58 @@ namespace margelo::nitro::omni { std::vector JHybridOmniPlayerSpec::getVideos() { static const auto method = _javaPart->javaClassStatic()->getMethod>()>("getVideos"); auto __result = method(_javaPart); - return [&]() { - size_t __size = __result->size(); + return [&](auto&& __input) { + size_t __size = __input->size(); std::vector __vector; __vector.reserve(__size); for (size_t __i = 0; __i < __size; __i++) { - auto __element = __result->getElement(__i); + auto __element = __input->getElement(__i); __vector.push_back(__element->toCpp()); } return __vector; - }(); + }(__result); } std::vector JHybridOmniPlayerSpec::getAudios() { static const auto method = _javaPart->javaClassStatic()->getMethod>()>("getAudios"); auto __result = method(_javaPart); - return [&]() { - size_t __size = __result->size(); + return [&](auto&& __input) { + size_t __size = __input->size(); std::vector __vector; __vector.reserve(__size); for (size_t __i = 0; __i < __size; __i++) { - auto __element = __result->getElement(__i); + auto __element = __input->getElement(__i); __vector.push_back(__element->toCpp()); } return __vector; - }(); + }(__result); } std::vector JHybridOmniPlayerSpec::getSubtitles() { static const auto method = _javaPart->javaClassStatic()->getMethod>()>("getSubtitles"); auto __result = method(_javaPart); - return [&]() { - size_t __size = __result->size(); + return [&](auto&& __input) { + size_t __size = __input->size(); std::vector __vector; __vector.reserve(__size); for (size_t __i = 0; __i < __size; __i++) { - auto __element = __result->getElement(__i); + auto __element = __input->getElement(__i); __vector.push_back(__element->toCpp()); } return __vector; - }(); + }(__result); } std::vector JHybridOmniPlayerSpec::getRendition() { static const auto method = _javaPart->javaClassStatic()->getMethod>()>("getRendition"); auto __result = method(_javaPart); - return [&]() { - size_t __size = __result->size(); + return [&](auto&& __input) { + size_t __size = __input->size(); std::vector __vector; __vector.reserve(__size); for (size_t __i = 0; __i < __size; __i++) { - auto __element = __result->getElement(__i); + auto __element = __input->getElement(__i); __vector.push_back(__element->toCpp()); } return __vector; - }(); + }(__result); } PlayerStatus JHybridOmniPlayerSpec::getStatus() { static const auto method = _javaPart->javaClassStatic()->getMethod()>("getStatus"); @@ -221,6 +225,11 @@ namespace margelo::nitro::omni { auto __result = method(_javaPart); return static_cast(__result); } + CastStatus JHybridOmniPlayerSpec::getCastStatus() { + static const auto method = _javaPart->javaClassStatic()->getMethod()>("getCastStatus"); + auto __result = method(_javaPart); + return __result->toCpp(); + } // Methods void JHybridOmniPlayerSpec::setSource(const Source& src) { @@ -239,6 +248,10 @@ namespace margelo::nitro::omni { static const auto method = _javaPart->javaClassStatic()->getMethod("seekBy"); method(_javaPart, offset); } + void JHybridOmniPlayerSpec::toggleCastStatus() { + static const auto method = _javaPart->javaClassStatic()->getMethod("toggleCastStatus"); + method(_javaPart); + } void JHybridOmniPlayerSpec::playPrev() { static const auto method = _javaPart->javaClassStatic()->getMethod("playPrev"); method(_javaPart); diff --git a/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.hpp b/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.hpp index 7c33f70..0eef745 100644 --- a/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.hpp +++ b/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.hpp @@ -72,6 +72,7 @@ namespace margelo::nitro::omni { bool getMuted() override; void setMuted(bool muted) override; bool getIsAutoQuality() override; + CastStatus getCastStatus() override; public: // Methods @@ -79,6 +80,7 @@ namespace margelo::nitro::omni { void play() override; void pause() override; void seekBy(double offset) override; + void toggleCastStatus() override; void playPrev() override; void playNext() override; void selectVideo(const Track& video) override; diff --git a/nitrogen/generated/android/c++/JHybridOmniViewSpec.cpp b/nitrogen/generated/android/c++/JHybridOmniViewSpec.cpp index f316f25..6ba178e 100644 --- a/nitrogen/generated/android/c++/JHybridOmniViewSpec.cpp +++ b/nitrogen/generated/android/c++/JHybridOmniViewSpec.cpp @@ -9,11 +9,24 @@ // Forward declaration of `HybridOmniPlayerSpec` to properly resolve imports. namespace margelo::nitro::omni { class HybridOmniPlayerSpec; } +// Forward declaration of `SubtitleAssets` to properly resolve imports. +namespace margelo::nitro::omni { struct SubtitleAssets; } +// Forward declaration of `JassubAssets` to properly resolve imports. +namespace margelo::nitro::omni { struct JassubAssets; } +// Forward declaration of `PgsAssets` to properly resolve imports. +namespace margelo::nitro::omni { struct PgsAssets; } #include #include "HybridOmniPlayerSpec.hpp" #include "JHybridOmniPlayerSpec.hpp" #include +#include "SubtitleAssets.hpp" +#include "JSubtitleAssets.hpp" +#include "JassubAssets.hpp" +#include "JJassubAssets.hpp" +#include +#include "PgsAssets.hpp" +#include "JPgsAssets.hpp" namespace margelo::nitro::omni { @@ -72,6 +85,15 @@ namespace margelo::nitro::omni { static const auto method = _javaPart->javaClassStatic()->getMethod /* autoPip */)>("setAutoPip"); method(_javaPart, autoPip.has_value() ? jni::JBoolean::valueOf(autoPip.value()) : nullptr); } + std::optional JHybridOmniViewSpec::getSubtitleAssets() { + static const auto method = _javaPart->javaClassStatic()->getMethod()>("getSubtitleAssets"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt; + } + void JHybridOmniViewSpec::setSubtitleAssets(const std::optional& subtitleAssets) { + static const auto method = _javaPart->javaClassStatic()->getMethod /* subtitleAssets */)>("setSubtitleAssets"); + method(_javaPart, subtitleAssets.has_value() ? JSubtitleAssets::fromCpp(subtitleAssets.value()) : nullptr); + } // Methods diff --git a/nitrogen/generated/android/c++/JHybridOmniViewSpec.hpp b/nitrogen/generated/android/c++/JHybridOmniViewSpec.hpp index c6ea10e..324bfe5 100644 --- a/nitrogen/generated/android/c++/JHybridOmniViewSpec.hpp +++ b/nitrogen/generated/android/c++/JHybridOmniViewSpec.hpp @@ -56,6 +56,8 @@ namespace margelo::nitro::omni { void setAutoplay(std::optional autoplay) override; std::optional getAutoPip() override; void setAutoPip(std::optional autoPip) override; + std::optional getSubtitleAssets() override; + void setSubtitleAssets(const std::optional& subtitleAssets) override; public: // Methods diff --git a/nitrogen/generated/android/c++/JJassubAssets.hpp b/nitrogen/generated/android/c++/JJassubAssets.hpp new file mode 100644 index 0000000..db08ae4 --- /dev/null +++ b/nitrogen/generated/android/c++/JJassubAssets.hpp @@ -0,0 +1,70 @@ +/// +/// JJassubAssets.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "JassubAssets.hpp" + +#include +#include + +namespace margelo::nitro::omni { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "JassubAssets" and the Kotlin data class "JassubAssets". + */ + struct JJassubAssets final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/JassubAssets;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct JassubAssets by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + JassubAssets toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldWorkerUrl = clazz->getField("workerUrl"); + jni::local_ref workerUrl = this->getFieldValue(fieldWorkerUrl); + static const auto fieldWasmUrl = clazz->getField("wasmUrl"); + jni::local_ref wasmUrl = this->getFieldValue(fieldWasmUrl); + static const auto fieldModernWasmUrl = clazz->getField("modernWasmUrl"); + jni::local_ref modernWasmUrl = this->getFieldValue(fieldModernWasmUrl); + static const auto fieldFontUrl = clazz->getField("fontUrl"); + jni::local_ref fontUrl = this->getFieldValue(fieldFontUrl); + return JassubAssets( + workerUrl != nullptr ? std::make_optional(workerUrl->toStdString()) : std::nullopt, + wasmUrl != nullptr ? std::make_optional(wasmUrl->toStdString()) : std::nullopt, + modernWasmUrl != nullptr ? std::make_optional(modernWasmUrl->toStdString()) : std::nullopt, + fontUrl != nullptr ? std::make_optional(fontUrl->toStdString()) : 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 fromCpp(const JassubAssets& value) { + using JSignature = JJassubAssets(jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref); + static const auto clazz = javaClassStatic(); + static const auto create = clazz->getStaticMethod("fromCpp"); + return create( + clazz, + value.workerUrl.has_value() ? jni::make_jstring(value.workerUrl.value()) : nullptr, + value.wasmUrl.has_value() ? jni::make_jstring(value.wasmUrl.value()) : nullptr, + value.modernWasmUrl.has_value() ? jni::make_jstring(value.modernWasmUrl.value()) : nullptr, + value.fontUrl.has_value() ? jni::make_jstring(value.fontUrl.value()) : nullptr + ); + } + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JMetadata.hpp b/nitrogen/generated/android/c++/JMetadata.hpp index 1d00f8f..72ef360 100644 --- a/nitrogen/generated/android/c++/JMetadata.hpp +++ b/nitrogen/generated/android/c++/JMetadata.hpp @@ -18,7 +18,7 @@ namespace margelo::nitro::omni { using namespace facebook; /** - * The C++ JNI bridge between the C++ struct "Metadata" and the the Kotlin data class "Metadata". + * The C++ JNI bridge between the C++ struct "Metadata" and the Kotlin data class "Metadata". */ struct JMetadata final: public jni::JavaClass { public: diff --git a/nitrogen/generated/android/c++/JMixAudioMode.hpp b/nitrogen/generated/android/c++/JMixAudioMode.hpp index cb636a0..e252cab 100644 --- a/nitrogen/generated/android/c++/JMixAudioMode.hpp +++ b/nitrogen/generated/android/c++/JMixAudioMode.hpp @@ -15,7 +15,7 @@ namespace margelo::nitro::omni { using namespace facebook; /** - * The C++ JNI bridge between the C++ enum "MixAudioMode" and the the Kotlin enum "MixAudioMode". + * The C++ JNI bridge between the C++ enum "MixAudioMode" and the Kotlin enum "MixAudioMode". */ struct JMixAudioMode final: public jni::JavaClass { public: diff --git a/nitrogen/generated/android/c++/JNumberProperty.hpp b/nitrogen/generated/android/c++/JNumberProperty.hpp index e39332b..eef447b 100644 --- a/nitrogen/generated/android/c++/JNumberProperty.hpp +++ b/nitrogen/generated/android/c++/JNumberProperty.hpp @@ -15,7 +15,7 @@ namespace margelo::nitro::omni { using namespace facebook; /** - * The C++ JNI bridge between the C++ enum "NumberProperty" and the the Kotlin enum "NumberProperty". + * The C++ JNI bridge between the C++ enum "NumberProperty" and the Kotlin enum "NumberProperty". */ struct JNumberProperty final: public jni::JavaClass { public: @@ -60,6 +60,9 @@ namespace margelo::nitro::omni { case NumberProperty::ISAUTOQUALITY: static const auto fieldISAUTOQUALITY = clazz->getStaticField("ISAUTOQUALITY"); return clazz->getStaticFieldValue(fieldISAUTOQUALITY); + case NumberProperty::CASTSTATUS: + static const auto fieldCASTSTATUS = clazz->getStaticField("CASTSTATUS"); + return clazz->getStaticFieldValue(fieldCASTSTATUS); default: std::string stringValue = std::to_string(static_cast(value)); throw std::invalid_argument("Invalid enum value (" + stringValue + "!"); diff --git a/nitrogen/generated/android/c++/JPgsAssets.hpp b/nitrogen/generated/android/c++/JPgsAssets.hpp new file mode 100644 index 0000000..c908ef2 --- /dev/null +++ b/nitrogen/generated/android/c++/JPgsAssets.hpp @@ -0,0 +1,58 @@ +/// +/// JPgsAssets.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "PgsAssets.hpp" + +#include +#include + +namespace margelo::nitro::omni { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "PgsAssets" and the Kotlin data class "PgsAssets". + */ + struct JPgsAssets final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/PgsAssets;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct PgsAssets by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + PgsAssets toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldWorkerUrl = clazz->getField("workerUrl"); + jni::local_ref workerUrl = this->getFieldValue(fieldWorkerUrl); + return PgsAssets( + workerUrl != nullptr ? std::make_optional(workerUrl->toStdString()) : 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 fromCpp(const PgsAssets& value) { + using JSignature = JPgsAssets(jni::alias_ref); + static const auto clazz = javaClassStatic(); + static const auto create = clazz->getStaticMethod("fromCpp"); + return create( + clazz, + value.workerUrl.has_value() ? jni::make_jstring(value.workerUrl.value()) : nullptr + ); + } + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JPlayerStatus.hpp b/nitrogen/generated/android/c++/JPlayerStatus.hpp index e83fc25..a4655f1 100644 --- a/nitrogen/generated/android/c++/JPlayerStatus.hpp +++ b/nitrogen/generated/android/c++/JPlayerStatus.hpp @@ -15,7 +15,7 @@ namespace margelo::nitro::omni { using namespace facebook; /** - * The C++ JNI bridge between the C++ enum "PlayerStatus" and the the Kotlin enum "PlayerStatus". + * The C++ JNI bridge between the C++ enum "PlayerStatus" and the Kotlin enum "PlayerStatus". */ struct JPlayerStatus final: public jni::JavaClass { public: diff --git a/nitrogen/generated/android/c++/JRendition.hpp b/nitrogen/generated/android/c++/JRendition.hpp index b68d92f..6cb1b10 100644 --- a/nitrogen/generated/android/c++/JRendition.hpp +++ b/nitrogen/generated/android/c++/JRendition.hpp @@ -17,7 +17,7 @@ namespace margelo::nitro::omni { using namespace facebook; /** - * The C++ JNI bridge between the C++ struct "Rendition" and the the Kotlin data class "Rendition". + * The C++ JNI bridge between the C++ struct "Rendition" and the Kotlin data class "Rendition". */ struct JRendition final: public jni::JavaClass { public: diff --git a/nitrogen/generated/android/c++/JSource.hpp b/nitrogen/generated/android/c++/JSource.hpp index 4412f30..8ee15a5 100644 --- a/nitrogen/generated/android/c++/JSource.hpp +++ b/nitrogen/generated/android/c++/JSource.hpp @@ -28,7 +28,7 @@ namespace margelo::nitro::omni { using namespace facebook; /** - * The C++ JNI bridge between the C++ struct "Source" and the the Kotlin data class "Source". + * The C++ JNI bridge between the C++ struct "Source" and the Kotlin data class "Source". */ struct JSource final: public jni::JavaClass { public: @@ -48,34 +48,56 @@ namespace margelo::nitro::omni { jni::local_ref startTime = this->getFieldValue(fieldStartTime); static const auto fieldSubtitles = clazz->getField>("subtitles"); jni::local_ref> subtitles = this->getFieldValue(fieldSubtitles); + static const auto fieldFonts = clazz->getField>("fonts"); + jni::local_ref> fonts = this->getFieldValue(fieldFonts); static const auto fieldMetadata = clazz->getField("metadata"); jni::local_ref metadata = this->getFieldValue(fieldMetadata); static const auto fieldMixAudio = clazz->getField("mixAudio"); jni::local_ref mixAudio = this->getFieldValue(fieldMixAudio); + static const auto fieldCastData = clazz->getField>("castData"); + jni::local_ref> castData = this->getFieldValue(fieldCastData); return Source( - [&]() { - size_t __size = src->size(); + [&](auto&& __input) { + size_t __size = __input->size(); std::vector __vector; __vector.reserve(__size); for (size_t __i = 0; __i < __size; __i++) { - auto __element = src->getElement(__i); + auto __element = __input->getElement(__i); __vector.push_back(__element->toCpp()); } return __vector; - }(), + }(src), startTime != nullptr ? std::make_optional(startTime->value()) : std::nullopt, - [&]() { - size_t __size = subtitles->size(); + [&](auto&& __input) { + size_t __size = __input->size(); std::vector __vector; __vector.reserve(__size); for (size_t __i = 0; __i < __size; __i++) { - auto __element = subtitles->getElement(__i); + auto __element = __input->getElement(__i); __vector.push_back(__element->toCpp()); } return __vector; - }(), + }(subtitles), + fonts != nullptr ? std::make_optional([&](auto&& __input) { + size_t __size = __input->size(); + std::vector __vector; + __vector.reserve(__size); + for (size_t __i = 0; __i < __size; __i++) { + auto __element = __input->getElement(__i); + __vector.push_back(__element->toStdString()); + } + return __vector; + }(fonts)) : std::nullopt, metadata != nullptr ? std::make_optional(metadata->toCpp()) : std::nullopt, - mixAudio != nullptr ? std::make_optional(mixAudio->toCpp()) : std::nullopt + mixAudio != nullptr ? std::make_optional(mixAudio->toCpp()) : std::nullopt, + castData != nullptr ? std::make_optional([&]() { + std::unordered_map __map; + __map.reserve(castData->size()); + for (const auto& __entry : *castData) { + __map.emplace(__entry.first->toStdString(), __entry.second->toStdString()); + } + return __map; + }()) : std::nullopt ); } @@ -85,34 +107,51 @@ namespace margelo::nitro::omni { */ [[maybe_unused]] static jni::local_ref fromCpp(const Source& value) { - using JSignature = JSource(jni::alias_ref>, jni::alias_ref, jni::alias_ref>, jni::alias_ref, jni::alias_ref); + using JSignature = JSource(jni::alias_ref>, jni::alias_ref, jni::alias_ref>, jni::alias_ref>, jni::alias_ref, jni::alias_ref, jni::alias_ref>); static const auto clazz = javaClassStatic(); static const auto create = clazz->getStaticMethod("fromCpp"); return create( clazz, - [&]() { - size_t __size = value.src.size(); + [&](auto&& __input) { + size_t __size = __input.size(); jni::local_ref> __array = jni::JArrayClass::newArray(__size); for (size_t __i = 0; __i < __size; __i++) { - const auto& __element = value.src[__i]; + const auto& __element = __input[__i]; auto __elementJni = JVideoSrc::fromCpp(__element); __array->setElement(__i, *__elementJni); } return __array; - }(), + }(value.src), value.startTime.has_value() ? jni::JDouble::valueOf(value.startTime.value()) : nullptr, - [&]() { - size_t __size = value.subtitles.size(); + [&](auto&& __input) { + size_t __size = __input.size(); jni::local_ref> __array = jni::JArrayClass::newArray(__size); for (size_t __i = 0; __i < __size; __i++) { - const auto& __element = value.subtitles[__i]; + const auto& __element = __input[__i]; auto __elementJni = JSubtitle::fromCpp(__element); __array->setElement(__i, *__elementJni); } return __array; - }(), + }(value.subtitles), + value.fonts.has_value() ? [&](auto&& __input) { + size_t __size = __input.size(); + jni::local_ref> __array = jni::JArrayClass::newArray(__size); + for (size_t __i = 0; __i < __size; __i++) { + const auto& __element = __input[__i]; + auto __elementJni = jni::make_jstring(__element); + __array->setElement(__i, *__elementJni); + } + return __array; + }(value.fonts.value()) : nullptr, value.metadata.has_value() ? JMetadata::fromCpp(value.metadata.value()) : nullptr, - value.mixAudio.has_value() ? JMixAudioMode::fromCpp(value.mixAudio.value()) : nullptr + value.mixAudio.has_value() ? JMixAudioMode::fromCpp(value.mixAudio.value()) : nullptr, + value.castData.has_value() ? [&]() -> jni::local_ref> { + auto __map = jni::JHashMap::create(value.castData.value().size()); + for (const auto& __entry : value.castData.value()) { + __map->put(jni::make_jstring(__entry.first), jni::make_jstring(__entry.second)); + } + return __map; + }() : nullptr ); } }; diff --git a/nitrogen/generated/android/c++/JSubtitle.hpp b/nitrogen/generated/android/c++/JSubtitle.hpp index e978370..7e5a136 100644 --- a/nitrogen/generated/android/c++/JSubtitle.hpp +++ b/nitrogen/generated/android/c++/JSubtitle.hpp @@ -18,7 +18,7 @@ namespace margelo::nitro::omni { using namespace facebook; /** - * The C++ JNI bridge between the C++ struct "Subtitle" and the the Kotlin data class "Subtitle". + * The C++ JNI bridge between the C++ struct "Subtitle" and the Kotlin data class "Subtitle". */ struct JSubtitle final: public jni::JavaClass { public: diff --git a/nitrogen/generated/android/c++/JSubtitleAssets.hpp b/nitrogen/generated/android/c++/JSubtitleAssets.hpp new file mode 100644 index 0000000..2dd8723 --- /dev/null +++ b/nitrogen/generated/android/c++/JSubtitleAssets.hpp @@ -0,0 +1,66 @@ +/// +/// JSubtitleAssets.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "SubtitleAssets.hpp" + +#include "JJassubAssets.hpp" +#include "JPgsAssets.hpp" +#include "JassubAssets.hpp" +#include "PgsAssets.hpp" +#include +#include + +namespace margelo::nitro::omni { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "SubtitleAssets" and the Kotlin data class "SubtitleAssets". + */ + struct JSubtitleAssets final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/SubtitleAssets;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct SubtitleAssets by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + SubtitleAssets toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldJassub = clazz->getField("jassub"); + jni::local_ref jassub = this->getFieldValue(fieldJassub); + static const auto fieldPgs = clazz->getField("pgs"); + jni::local_ref pgs = this->getFieldValue(fieldPgs); + return SubtitleAssets( + jassub != nullptr ? std::make_optional(jassub->toCpp()) : std::nullopt, + pgs != nullptr ? std::make_optional(pgs->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 fromCpp(const SubtitleAssets& value) { + using JSignature = JSubtitleAssets(jni::alias_ref, jni::alias_ref); + static const auto clazz = javaClassStatic(); + static const auto create = clazz->getStaticMethod("fromCpp"); + return create( + clazz, + value.jassub.has_value() ? JJassubAssets::fromCpp(value.jassub.value()) : nullptr, + value.pgs.has_value() ? JPgsAssets::fromCpp(value.pgs.value()) : nullptr + ); + } + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JTrack.hpp b/nitrogen/generated/android/c++/JTrack.hpp index 78004e7..4b211d6 100644 --- a/nitrogen/generated/android/c++/JTrack.hpp +++ b/nitrogen/generated/android/c++/JTrack.hpp @@ -18,7 +18,7 @@ namespace margelo::nitro::omni { using namespace facebook; /** - * The C++ JNI bridge between the C++ struct "Track" and the the Kotlin data class "Track". + * The C++ JNI bridge between the C++ struct "Track" and the Kotlin data class "Track". */ struct JTrack final: public jni::JavaClass { public: diff --git a/nitrogen/generated/android/c++/JVideoSrc.hpp b/nitrogen/generated/android/c++/JVideoSrc.hpp index 3c9dd4a..7de2d80 100644 --- a/nitrogen/generated/android/c++/JVideoSrc.hpp +++ b/nitrogen/generated/android/c++/JVideoSrc.hpp @@ -19,7 +19,7 @@ namespace margelo::nitro::omni { using namespace facebook; /** - * The C++ JNI bridge between the C++ struct "VideoSrc" and the the Kotlin data class "VideoSrc". + * The C++ JNI bridge between the C++ struct "VideoSrc" and the Kotlin data class "VideoSrc". */ struct JVideoSrc final: public jni::JavaClass { public: diff --git a/nitrogen/generated/android/c++/views/JHybridOmniViewStateUpdater.cpp b/nitrogen/generated/android/c++/views/JHybridOmniViewStateUpdater.cpp index b2d39b6..faa2588 100644 --- a/nitrogen/generated/android/c++/views/JHybridOmniViewStateUpdater.cpp +++ b/nitrogen/generated/android/c++/views/JHybridOmniViewStateUpdater.cpp @@ -49,6 +49,10 @@ void JHybridOmniViewStateUpdater::updateViewProps(jni::alias_ref /* hybridView->setAutoPip(props->autoPip.value); props->autoPip.isDirty = false; } + if (props->subtitleAssets.isDirty) { + hybridView->setSubtitleAssets(props->subtitleAssets.value); + props->subtitleAssets.isDirty = false; + } // Update hybridRef if it changed if (props->hybridRef.isDirty) { diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/CastStatus.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/CastStatus.kt new file mode 100644 index 0000000..151ecd6 --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/CastStatus.kt @@ -0,0 +1,26 @@ +/// +/// CastStatus.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + +/** + * Represents the JavaScript enum/union "CastStatus". + */ +@DoNotStrip +@Keep +enum class CastStatus(@DoNotStrip @Keep val value: Int) { + CONNECTING(0), + CONNECTED(1), + AVAILABLE(2), + UNAVAILABLE(3), + UNSUPPORTED(4); + + companion object +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerSpec.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerSpec.kt index 6489a68..f8f48ba 100644 --- a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerSpec.kt +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerSpec.kt @@ -102,6 +102,10 @@ abstract class HybridOmniPlayerSpec: HybridObject() { @get:DoNotStrip @get:Keep abstract val isAutoQuality: Boolean + + @get:DoNotStrip + @get:Keep + abstract val castStatus: CastStatus // Methods @DoNotStrip @@ -120,6 +124,10 @@ abstract class HybridOmniPlayerSpec: HybridObject() { @Keep abstract fun seekBy(offset: Double): Unit + @DoNotStrip + @Keep + abstract fun toggleCastStatus(): Unit + @DoNotStrip @Keep abstract fun playPrev(): Unit diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniViewSpec.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniViewSpec.kt index 190485c..bb1c5d2 100644 --- a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniViewSpec.kt +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniViewSpec.kt @@ -43,6 +43,12 @@ abstract class HybridOmniViewSpec: HybridView() { @set:DoNotStrip @set:Keep abstract var autoPip: Boolean? + + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var subtitleAssets: SubtitleAssets? // Methods diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/JassubAssets.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/JassubAssets.kt new file mode 100644 index 0000000..474211e --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/JassubAssets.kt @@ -0,0 +1,66 @@ +/// +/// JassubAssets.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import java.util.Objects + + +/** + * Represents the JavaScript object/struct "JassubAssets". + */ +@DoNotStrip +@Keep +data class JassubAssets( + @DoNotStrip + @Keep + val workerUrl: String?, + @DoNotStrip + @Keep + val wasmUrl: String?, + @DoNotStrip + @Keep + val modernWasmUrl: String?, + @DoNotStrip + @Keep + val fontUrl: String? +) { + /* primary constructor */ + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is JassubAssets) return false + return Objects.deepEquals(this.workerUrl, other.workerUrl) + && Objects.deepEquals(this.wasmUrl, other.wasmUrl) + && Objects.deepEquals(this.modernWasmUrl, other.modernWasmUrl) + && Objects.deepEquals(this.fontUrl, other.fontUrl) + } + + override fun hashCode(): Int { + return arrayOf( + workerUrl, + wasmUrl, + modernWasmUrl, + fontUrl + ).contentDeepHashCode() + } + + companion object { + /** + * Constructor called from C++ + */ + @DoNotStrip + @Keep + @Suppress("unused") + @JvmStatic + private fun fromCpp(workerUrl: String?, wasmUrl: String?, modernWasmUrl: String?, fontUrl: String?): JassubAssets { + return JassubAssets(workerUrl, wasmUrl, modernWasmUrl, fontUrl) + } + } +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Metadata.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Metadata.kt index fa6fd15..e5c86f5 100644 --- a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Metadata.kt +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Metadata.kt @@ -9,6 +9,7 @@ package com.margelo.nitro.omni import androidx.annotation.Keep import com.facebook.proguard.annotations.DoNotStrip +import java.util.Objects /** @@ -38,6 +39,28 @@ data class Metadata( ) { /* primary constructor */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is Metadata) return false + return Objects.deepEquals(this.title, other.title) + && Objects.deepEquals(this.album, other.album) + && Objects.deepEquals(this.artist, other.artist) + && Objects.deepEquals(this.imageLink, other.imageLink) + && Objects.deepEquals(this.hasPrev, other.hasPrev) + && Objects.deepEquals(this.hasNext, other.hasNext) + } + + override fun hashCode(): Int { + return arrayOf( + title, + album, + artist, + imageLink, + hasPrev, + hasNext + ).contentDeepHashCode() + } + companion object { /** * Constructor called from C++ diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/NumberProperty.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/NumberProperty.kt index 96f95c3..cb9de74 100644 --- a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/NumberProperty.kt +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/NumberProperty.kt @@ -21,7 +21,8 @@ enum class NumberProperty(@DoNotStrip @Keep val value: Int) { DURATION(2), PLAYBACKRATE(3), VOLUME(4), - ISAUTOQUALITY(5); + ISAUTOQUALITY(5), + CASTSTATUS(6); companion object } diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/PgsAssets.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/PgsAssets.kt new file mode 100644 index 0000000..184c951 --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/PgsAssets.kt @@ -0,0 +1,51 @@ +/// +/// PgsAssets.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import java.util.Objects + + +/** + * Represents the JavaScript object/struct "PgsAssets". + */ +@DoNotStrip +@Keep +data class PgsAssets( + @DoNotStrip + @Keep + val workerUrl: String? +) { + /* primary constructor */ + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is PgsAssets) return false + return Objects.deepEquals(this.workerUrl, other.workerUrl) + } + + override fun hashCode(): Int { + return arrayOf( + workerUrl + ).contentDeepHashCode() + } + + companion object { + /** + * Constructor called from C++ + */ + @DoNotStrip + @Keep + @Suppress("unused") + @JvmStatic + private fun fromCpp(workerUrl: String?): PgsAssets { + return PgsAssets(workerUrl) + } + } +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Rendition.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Rendition.kt index f28867e..53e16cf 100644 --- a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Rendition.kt +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Rendition.kt @@ -9,6 +9,7 @@ package com.margelo.nitro.omni import androidx.annotation.Keep import com.facebook.proguard.annotations.DoNotStrip +import java.util.Objects /** @@ -35,6 +36,26 @@ data class Rendition( ) { /* primary constructor */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is Rendition) return false + return Objects.deepEquals(this.id, other.id) + && Objects.deepEquals(this.width, other.width) + && Objects.deepEquals(this.height, other.height) + && Objects.deepEquals(this.bitrate, other.bitrate) + && Objects.deepEquals(this.selected, other.selected) + } + + override fun hashCode(): Int { + return arrayOf( + id, + width, + height, + bitrate, + selected + ).contentDeepHashCode() + } + companion object { /** * Constructor called from C++ diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Source.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Source.kt index c8525c7..7b9d03a 100644 --- a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Source.kt +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Source.kt @@ -9,6 +9,7 @@ package com.margelo.nitro.omni import androidx.annotation.Keep import com.facebook.proguard.annotations.DoNotStrip +import java.util.Objects /** @@ -28,13 +29,43 @@ data class Source( val subtitles: Array, @DoNotStrip @Keep + val fonts: Array?, + @DoNotStrip + @Keep val metadata: Metadata?, @DoNotStrip @Keep - val mixAudio: MixAudioMode? + val mixAudio: MixAudioMode?, + @DoNotStrip + @Keep + val castData: Map? ) { /* primary constructor */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is Source) return false + return Objects.deepEquals(this.src, other.src) + && Objects.deepEquals(this.startTime, other.startTime) + && Objects.deepEquals(this.subtitles, other.subtitles) + && Objects.deepEquals(this.fonts, other.fonts) + && Objects.deepEquals(this.metadata, other.metadata) + && Objects.deepEquals(this.mixAudio, other.mixAudio) + && Objects.deepEquals(this.castData, other.castData) + } + + override fun hashCode(): Int { + return arrayOf( + src, + startTime, + subtitles, + fonts, + metadata, + mixAudio, + castData + ).contentDeepHashCode() + } + companion object { /** * Constructor called from C++ @@ -43,8 +74,8 @@ data class Source( @Keep @Suppress("unused") @JvmStatic - private fun fromCpp(src: Array, startTime: Double?, subtitles: Array, metadata: Metadata?, mixAudio: MixAudioMode?): Source { - return Source(src, startTime, subtitles, metadata, mixAudio) + private fun fromCpp(src: Array, startTime: Double?, subtitles: Array, fonts: Array?, metadata: Metadata?, mixAudio: MixAudioMode?, castData: Map?): Source { + return Source(src, startTime, subtitles, fonts, metadata, mixAudio, castData) } } } diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Subtitle.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Subtitle.kt index dd17173..d066f7a 100644 --- a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Subtitle.kt +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Subtitle.kt @@ -9,6 +9,7 @@ package com.margelo.nitro.omni import androidx.annotation.Keep import com.facebook.proguard.annotations.DoNotStrip +import java.util.Objects /** @@ -35,6 +36,26 @@ data class Subtitle( ) { /* primary constructor */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is Subtitle) return false + return Objects.deepEquals(this.id, other.id) + && Objects.deepEquals(this.link, other.link) + && Objects.deepEquals(this.mimeType, other.mimeType) + && Objects.deepEquals(this.language, other.language) + && Objects.deepEquals(this.label, other.label) + } + + override fun hashCode(): Int { + return arrayOf( + id, + link, + mimeType, + language, + label + ).contentDeepHashCode() + } + companion object { /** * Constructor called from C++ diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/SubtitleAssets.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/SubtitleAssets.kt new file mode 100644 index 0000000..fbc9a7a --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/SubtitleAssets.kt @@ -0,0 +1,56 @@ +/// +/// SubtitleAssets.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import java.util.Objects + + +/** + * Represents the JavaScript object/struct "SubtitleAssets". + */ +@DoNotStrip +@Keep +data class SubtitleAssets( + @DoNotStrip + @Keep + val jassub: JassubAssets?, + @DoNotStrip + @Keep + val pgs: PgsAssets? +) { + /* primary constructor */ + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is SubtitleAssets) return false + return Objects.deepEquals(this.jassub, other.jassub) + && Objects.deepEquals(this.pgs, other.pgs) + } + + override fun hashCode(): Int { + return arrayOf( + jassub, + pgs + ).contentDeepHashCode() + } + + companion object { + /** + * Constructor called from C++ + */ + @DoNotStrip + @Keep + @Suppress("unused") + @JvmStatic + private fun fromCpp(jassub: JassubAssets?, pgs: PgsAssets?): SubtitleAssets { + return SubtitleAssets(jassub, pgs) + } + } +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Track.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Track.kt index 2e6acae..cfcaaf4 100644 --- a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Track.kt +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Track.kt @@ -9,6 +9,7 @@ package com.margelo.nitro.omni import androidx.annotation.Keep import com.facebook.proguard.annotations.DoNotStrip +import java.util.Objects /** @@ -32,6 +33,24 @@ data class Track( ) { /* primary constructor */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is Track) return false + return Objects.deepEquals(this.id, other.id) + && Objects.deepEquals(this.label, other.label) + && Objects.deepEquals(this.language, other.language) + && Objects.deepEquals(this.selected, other.selected) + } + + override fun hashCode(): Int { + return arrayOf( + id, + label, + language, + selected + ).contentDeepHashCode() + } + companion object { /** * Constructor called from C++ diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/VideoSrc.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/VideoSrc.kt index 33bf810..db13b56 100644 --- a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/VideoSrc.kt +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/VideoSrc.kt @@ -9,6 +9,7 @@ package com.margelo.nitro.omni import androidx.annotation.Keep import com.facebook.proguard.annotations.DoNotStrip +import java.util.Objects /** @@ -29,6 +30,22 @@ data class VideoSrc( ) { /* primary constructor */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is VideoSrc) return false + return Objects.deepEquals(this.uri, other.uri) + && Objects.deepEquals(this.mimeType, other.mimeType) + && Objects.deepEquals(this.headers, other.headers) + } + + override fun hashCode(): Int { + return arrayOf( + uri, + mimeType, + headers + ).contentDeepHashCode() + } + companion object { /** * Constructor called from C++ diff --git a/nitrogen/generated/shared/c++/CastStatus.hpp b/nitrogen/generated/shared/c++/CastStatus.hpp new file mode 100644 index 0000000..8d9c42c --- /dev/null +++ b/nitrogen/generated/shared/c++/CastStatus.hpp @@ -0,0 +1,88 @@ +/// +/// CastStatus.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +namespace margelo::nitro::omni { + + /** + * An enum which can be represented as a JavaScript union (CastStatus). + */ + enum class CastStatus { + CONNECTING SWIFT_NAME(connecting) = 0, + CONNECTED SWIFT_NAME(connected) = 1, + AVAILABLE SWIFT_NAME(available) = 2, + UNAVAILABLE SWIFT_NAME(unavailable) = 3, + UNSUPPORTED SWIFT_NAME(unsupported) = 4, + } CLOSED_ENUM; + +} // namespace margelo::nitro::omni + +namespace margelo::nitro { + + // C++ CastStatus <> JS CastStatus (union) + template <> + struct JSIConverter final { + static inline margelo::nitro::omni::CastStatus fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + std::string unionValue = JSIConverter::fromJSI(runtime, arg); + switch (hashString(unionValue.c_str(), unionValue.size())) { + case hashString("connecting"): return margelo::nitro::omni::CastStatus::CONNECTING; + case hashString("connected"): return margelo::nitro::omni::CastStatus::CONNECTED; + case hashString("available"): return margelo::nitro::omni::CastStatus::AVAILABLE; + case hashString("unavailable"): return margelo::nitro::omni::CastStatus::UNAVAILABLE; + case hashString("unsupported"): return margelo::nitro::omni::CastStatus::UNSUPPORTED; + default: [[unlikely]] + throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum CastStatus - invalid value!"); + } + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::omni::CastStatus arg) { + switch (arg) { + case margelo::nitro::omni::CastStatus::CONNECTING: return JSIConverter::toJSI(runtime, "connecting"); + case margelo::nitro::omni::CastStatus::CONNECTED: return JSIConverter::toJSI(runtime, "connected"); + case margelo::nitro::omni::CastStatus::AVAILABLE: return JSIConverter::toJSI(runtime, "available"); + case margelo::nitro::omni::CastStatus::UNAVAILABLE: return JSIConverter::toJSI(runtime, "unavailable"); + case margelo::nitro::omni::CastStatus::UNSUPPORTED: return JSIConverter::toJSI(runtime, "unsupported"); + default: [[unlikely]] + throw std::invalid_argument("Cannot convert CastStatus to JS - invalid value: " + + std::to_string(static_cast(arg)) + "!"); + } + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isString()) { + return false; + } + std::string unionValue = JSIConverter::fromJSI(runtime, value); + switch (hashString(unionValue.c_str(), unionValue.size())) { + case hashString("connecting"): + case hashString("connected"): + case hashString("available"): + case hashString("unavailable"): + case hashString("unsupported"): + return true; + default: + return false; + } + } + }; + +} // namespace margelo::nitro diff --git a/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.cpp b/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.cpp index cc7b769..c24beb9 100644 --- a/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.cpp +++ b/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.cpp @@ -36,10 +36,12 @@ namespace margelo::nitro::omni { prototype.registerHybridGetter("muted", &HybridOmniPlayerSpec::getMuted); prototype.registerHybridSetter("muted", &HybridOmniPlayerSpec::setMuted); prototype.registerHybridGetter("isAutoQuality", &HybridOmniPlayerSpec::getIsAutoQuality); + prototype.registerHybridGetter("castStatus", &HybridOmniPlayerSpec::getCastStatus); prototype.registerHybridMethod("setSource", &HybridOmniPlayerSpec::setSource); prototype.registerHybridMethod("play", &HybridOmniPlayerSpec::play); prototype.registerHybridMethod("pause", &HybridOmniPlayerSpec::pause); prototype.registerHybridMethod("seekBy", &HybridOmniPlayerSpec::seekBy); + prototype.registerHybridMethod("toggleCastStatus", &HybridOmniPlayerSpec::toggleCastStatus); prototype.registerHybridMethod("playPrev", &HybridOmniPlayerSpec::playPrev); prototype.registerHybridMethod("playNext", &HybridOmniPlayerSpec::playNext); prototype.registerHybridMethod("selectVideo", &HybridOmniPlayerSpec::selectVideo); diff --git a/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.hpp b/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.hpp index 6ec8b28..8a1bfc5 100644 --- a/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.hpp +++ b/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.hpp @@ -21,6 +21,8 @@ namespace margelo::nitro::omni { struct Track; } namespace margelo::nitro::omni { struct Rendition; } // Forward declaration of `PlayerStatus` to properly resolve imports. namespace margelo::nitro::omni { enum class PlayerStatus; } +// Forward declaration of `CastStatus` to properly resolve imports. +namespace margelo::nitro::omni { enum class CastStatus; } // Forward declaration of `Source` to properly resolve imports. namespace margelo::nitro::omni { struct Source; } @@ -31,6 +33,7 @@ namespace margelo::nitro::omni { struct Source; } #include #include "Rendition.hpp" #include "PlayerStatus.hpp" +#include "CastStatus.hpp" #include "Source.hpp" namespace margelo::nitro::omni { @@ -82,6 +85,7 @@ namespace margelo::nitro::omni { virtual bool getMuted() = 0; virtual void setMuted(bool muted) = 0; virtual bool getIsAutoQuality() = 0; + virtual CastStatus getCastStatus() = 0; public: // Methods @@ -89,6 +93,7 @@ namespace margelo::nitro::omni { virtual void play() = 0; virtual void pause() = 0; virtual void seekBy(double offset) = 0; + virtual void toggleCastStatus() = 0; virtual void playPrev() = 0; virtual void playNext() = 0; virtual void selectVideo(const Track& video) = 0; diff --git a/nitrogen/generated/shared/c++/HybridOmniViewSpec.cpp b/nitrogen/generated/shared/c++/HybridOmniViewSpec.cpp index 80e1382..8077fa4 100644 --- a/nitrogen/generated/shared/c++/HybridOmniViewSpec.cpp +++ b/nitrogen/generated/shared/c++/HybridOmniViewSpec.cpp @@ -20,6 +20,8 @@ namespace margelo::nitro::omni { prototype.registerHybridSetter("autoplay", &HybridOmniViewSpec::setAutoplay); prototype.registerHybridGetter("autoPip", &HybridOmniViewSpec::getAutoPip); prototype.registerHybridSetter("autoPip", &HybridOmniViewSpec::setAutoPip); + prototype.registerHybridGetter("subtitleAssets", &HybridOmniViewSpec::getSubtitleAssets); + prototype.registerHybridSetter("subtitleAssets", &HybridOmniViewSpec::setSubtitleAssets); }); } diff --git a/nitrogen/generated/shared/c++/HybridOmniViewSpec.hpp b/nitrogen/generated/shared/c++/HybridOmniViewSpec.hpp index 239747a..9559192 100644 --- a/nitrogen/generated/shared/c++/HybridOmniViewSpec.hpp +++ b/nitrogen/generated/shared/c++/HybridOmniViewSpec.hpp @@ -15,10 +15,13 @@ // Forward declaration of `HybridOmniPlayerSpec` to properly resolve imports. namespace margelo::nitro::omni { class HybridOmniPlayerSpec; } +// Forward declaration of `SubtitleAssets` to properly resolve imports. +namespace margelo::nitro::omni { struct SubtitleAssets; } #include #include "HybridOmniPlayerSpec.hpp" #include +#include "SubtitleAssets.hpp" namespace margelo::nitro::omni { @@ -53,6 +56,8 @@ namespace margelo::nitro::omni { virtual void setAutoplay(std::optional autoplay) = 0; virtual std::optional getAutoPip() = 0; virtual void setAutoPip(std::optional autoPip) = 0; + virtual std::optional getSubtitleAssets() = 0; + virtual void setSubtitleAssets(const std::optional& subtitleAssets) = 0; public: // Methods diff --git a/nitrogen/generated/shared/c++/JassubAssets.hpp b/nitrogen/generated/shared/c++/JassubAssets.hpp new file mode 100644 index 0000000..2be9b06 --- /dev/null +++ b/nitrogen/generated/shared/c++/JassubAssets.hpp @@ -0,0 +1,96 @@ +/// +/// JassubAssets.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + +#include +#include + +namespace margelo::nitro::omni { + + /** + * A struct which can be represented as a JavaScript object (JassubAssets). + */ + struct JassubAssets final { + public: + std::optional workerUrl SWIFT_PRIVATE; + std::optional wasmUrl SWIFT_PRIVATE; + std::optional modernWasmUrl SWIFT_PRIVATE; + std::optional fontUrl SWIFT_PRIVATE; + + public: + JassubAssets() = default; + explicit JassubAssets(std::optional workerUrl, std::optional wasmUrl, std::optional modernWasmUrl, std::optional fontUrl): workerUrl(workerUrl), wasmUrl(wasmUrl), modernWasmUrl(modernWasmUrl), fontUrl(fontUrl) {} + + public: + friend bool operator==(const JassubAssets& lhs, const JassubAssets& rhs) = default; + }; + +} // namespace margelo::nitro::omni + +namespace margelo::nitro { + + // C++ JassubAssets <> JS JassubAssets (object) + template <> + struct JSIConverter final { + static inline margelo::nitro::omni::JassubAssets fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return margelo::nitro::omni::JassubAssets( + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "workerUrl"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "wasmUrl"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modernWasmUrl"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fontUrl"))) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::omni::JassubAssets& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "workerUrl"), JSIConverter>::toJSI(runtime, arg.workerUrl)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "wasmUrl"), JSIConverter>::toJSI(runtime, arg.wasmUrl)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "modernWasmUrl"), JSIConverter>::toJSI(runtime, arg.modernWasmUrl)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "fontUrl"), JSIConverter>::toJSI(runtime, arg.fontUrl)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!nitro::isPlainObject(runtime, obj)) { + return false; + } + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "workerUrl")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "wasmUrl")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modernWasmUrl")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fontUrl")))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/nitrogen/generated/shared/c++/NumberProperty.hpp b/nitrogen/generated/shared/c++/NumberProperty.hpp index 39116b5..3ceadf3 100644 --- a/nitrogen/generated/shared/c++/NumberProperty.hpp +++ b/nitrogen/generated/shared/c++/NumberProperty.hpp @@ -35,6 +35,7 @@ namespace margelo::nitro::omni { PLAYBACKRATE SWIFT_NAME(playbackrate) = 3, VOLUME SWIFT_NAME(volume) = 4, ISAUTOQUALITY SWIFT_NAME(isautoquality) = 5, + CASTSTATUS SWIFT_NAME(caststatus) = 6, } CLOSED_ENUM; } // namespace margelo::nitro::omni @@ -53,6 +54,7 @@ namespace margelo::nitro { case hashString("playbackRate"): return margelo::nitro::omni::NumberProperty::PLAYBACKRATE; case hashString("volume"): return margelo::nitro::omni::NumberProperty::VOLUME; case hashString("isAutoQuality"): return margelo::nitro::omni::NumberProperty::ISAUTOQUALITY; + case hashString("castStatus"): return margelo::nitro::omni::NumberProperty::CASTSTATUS; default: [[unlikely]] throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum NumberProperty - invalid value!"); } @@ -65,6 +67,7 @@ namespace margelo::nitro { case margelo::nitro::omni::NumberProperty::PLAYBACKRATE: return JSIConverter::toJSI(runtime, "playbackRate"); case margelo::nitro::omni::NumberProperty::VOLUME: return JSIConverter::toJSI(runtime, "volume"); case margelo::nitro::omni::NumberProperty::ISAUTOQUALITY: return JSIConverter::toJSI(runtime, "isAutoQuality"); + case margelo::nitro::omni::NumberProperty::CASTSTATUS: return JSIConverter::toJSI(runtime, "castStatus"); default: [[unlikely]] throw std::invalid_argument("Cannot convert NumberProperty to JS - invalid value: " + std::to_string(static_cast(arg)) + "!"); @@ -82,6 +85,7 @@ namespace margelo::nitro { case hashString("playbackRate"): case hashString("volume"): case hashString("isAutoQuality"): + case hashString("castStatus"): return true; default: return false; diff --git a/nitrogen/generated/shared/c++/PgsAssets.hpp b/nitrogen/generated/shared/c++/PgsAssets.hpp new file mode 100644 index 0000000..5cc5d7c --- /dev/null +++ b/nitrogen/generated/shared/c++/PgsAssets.hpp @@ -0,0 +1,84 @@ +/// +/// PgsAssets.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + +#include +#include + +namespace margelo::nitro::omni { + + /** + * A struct which can be represented as a JavaScript object (PgsAssets). + */ + struct PgsAssets final { + public: + std::optional workerUrl SWIFT_PRIVATE; + + public: + PgsAssets() = default; + explicit PgsAssets(std::optional workerUrl): workerUrl(workerUrl) {} + + public: + friend bool operator==(const PgsAssets& lhs, const PgsAssets& rhs) = default; + }; + +} // namespace margelo::nitro::omni + +namespace margelo::nitro { + + // C++ PgsAssets <> JS PgsAssets (object) + template <> + struct JSIConverter final { + static inline margelo::nitro::omni::PgsAssets fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return margelo::nitro::omni::PgsAssets( + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "workerUrl"))) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::omni::PgsAssets& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "workerUrl"), JSIConverter>::toJSI(runtime, arg.workerUrl)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!nitro::isPlainObject(runtime, obj)) { + return false; + } + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "workerUrl")))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/nitrogen/generated/shared/c++/Source.hpp b/nitrogen/generated/shared/c++/Source.hpp index d84af8b..a3c174e 100644 --- a/nitrogen/generated/shared/c++/Source.hpp +++ b/nitrogen/generated/shared/c++/Source.hpp @@ -41,8 +41,10 @@ namespace margelo::nitro::omni { enum class MixAudioMode; } #include #include #include "Subtitle.hpp" +#include #include "Metadata.hpp" #include "MixAudioMode.hpp" +#include namespace margelo::nitro::omni { @@ -54,12 +56,14 @@ namespace margelo::nitro::omni { std::vector src SWIFT_PRIVATE; std::optional startTime SWIFT_PRIVATE; std::vector subtitles SWIFT_PRIVATE; + std::optional> fonts SWIFT_PRIVATE; std::optional metadata SWIFT_PRIVATE; std::optional mixAudio SWIFT_PRIVATE; + std::optional> castData SWIFT_PRIVATE; public: Source() = default; - explicit Source(std::vector src, std::optional startTime, std::vector subtitles, std::optional metadata, std::optional mixAudio): src(src), startTime(startTime), subtitles(subtitles), metadata(metadata), mixAudio(mixAudio) {} + explicit Source(std::vector src, std::optional startTime, std::vector subtitles, std::optional> fonts, std::optional metadata, std::optional mixAudio, std::optional> castData): src(src), startTime(startTime), subtitles(subtitles), fonts(fonts), metadata(metadata), mixAudio(mixAudio), castData(castData) {} public: friend bool operator==(const Source& lhs, const Source& rhs) = default; @@ -78,8 +82,10 @@ namespace margelo::nitro { JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "src"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startTime"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subtitles"))), + JSIConverter>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fonts"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metadata"))), - JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mixAudio"))) + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mixAudio"))), + JSIConverter>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "castData"))) ); } static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::omni::Source& arg) { @@ -87,8 +93,10 @@ namespace margelo::nitro { obj.setProperty(runtime, PropNameIDCache::get(runtime, "src"), JSIConverter>::toJSI(runtime, arg.src)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "startTime"), JSIConverter>::toJSI(runtime, arg.startTime)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "subtitles"), JSIConverter>::toJSI(runtime, arg.subtitles)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "fonts"), JSIConverter>>::toJSI(runtime, arg.fonts)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "metadata"), JSIConverter>::toJSI(runtime, arg.metadata)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "mixAudio"), JSIConverter>::toJSI(runtime, arg.mixAudio)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "castData"), JSIConverter>>::toJSI(runtime, arg.castData)); return obj; } static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { @@ -102,8 +110,10 @@ namespace margelo::nitro { if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "src")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startTime")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subtitles")))) return false; + if (!JSIConverter>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fonts")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metadata")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mixAudio")))) return false; + if (!JSIConverter>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "castData")))) return false; return true; } }; diff --git a/nitrogen/generated/shared/c++/SubtitleAssets.hpp b/nitrogen/generated/shared/c++/SubtitleAssets.hpp new file mode 100644 index 0000000..676fc2c --- /dev/null +++ b/nitrogen/generated/shared/c++/SubtitleAssets.hpp @@ -0,0 +1,92 @@ +/// +/// SubtitleAssets.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +// Forward declaration of `JassubAssets` to properly resolve imports. +namespace margelo::nitro::omni { struct JassubAssets; } +// Forward declaration of `PgsAssets` to properly resolve imports. +namespace margelo::nitro::omni { struct PgsAssets; } + +#include "JassubAssets.hpp" +#include +#include "PgsAssets.hpp" + +namespace margelo::nitro::omni { + + /** + * A struct which can be represented as a JavaScript object (SubtitleAssets). + */ + struct SubtitleAssets final { + public: + std::optional jassub SWIFT_PRIVATE; + std::optional pgs SWIFT_PRIVATE; + + public: + SubtitleAssets() = default; + explicit SubtitleAssets(std::optional jassub, std::optional pgs): jassub(jassub), pgs(pgs) {} + + public: + friend bool operator==(const SubtitleAssets& lhs, const SubtitleAssets& rhs) = default; + }; + +} // namespace margelo::nitro::omni + +namespace margelo::nitro { + + // C++ SubtitleAssets <> JS SubtitleAssets (object) + template <> + struct JSIConverter final { + static inline margelo::nitro::omni::SubtitleAssets fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return margelo::nitro::omni::SubtitleAssets( + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "jassub"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pgs"))) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::omni::SubtitleAssets& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "jassub"), JSIConverter>::toJSI(runtime, arg.jassub)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "pgs"), JSIConverter>::toJSI(runtime, arg.pgs)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!nitro::isPlainObject(runtime, obj)) { + return false; + } + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "jassub")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pgs")))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.cpp b/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.cpp index 435239d..b282009 100644 --- a/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.cpp +++ b/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.cpp @@ -56,6 +56,16 @@ namespace margelo::nitro::omni::views { throw std::runtime_error(std::string("OmniView.autoPip: ") + exc.what()); } }()), + subtitleAssets([&]() -> CachedProp> { + try { + const react::RawValue* rawValue = rawProps.at("subtitleAssets", nullptr, nullptr); + if (rawValue == nullptr) return sourceProps.subtitleAssets; + const auto& [runtime, value] = (std::pair)*rawValue; + return CachedProp>::fromRawValue(*runtime, value, sourceProps.subtitleAssets); + } catch (const std::exception& exc) { + throw std::runtime_error(std::string("OmniView.subtitleAssets: ") + exc.what()); + } + }()), hybridRef([&]() -> CachedProp& /* ref */)>>> { try { const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr); @@ -72,6 +82,7 @@ namespace margelo::nitro::omni::views { case hashString("player"): return true; case hashString("autoplay"): return true; case hashString("autoPip"): return true; + case hashString("subtitleAssets"): return true; case hashString("hybridRef"): return true; default: return false; } @@ -79,7 +90,7 @@ namespace margelo::nitro::omni::views { HybridOmniViewComponentDescriptor::HybridOmniViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters) : ConcreteComponentDescriptor(parameters, - react::RawPropsParser(/* enableJsiParser */ true)) {} + react::RawPropsParser()) {} std::shared_ptr HybridOmniViewComponentDescriptor::cloneProps(const react::PropsParserContext& context, const std::shared_ptr& props, diff --git a/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.hpp b/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.hpp index 6cee4ed..025014e 100644 --- a/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.hpp +++ b/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.hpp @@ -19,6 +19,7 @@ #include #include "HybridOmniPlayerSpec.hpp" #include +#include "SubtitleAssets.hpp" #include "HybridOmniViewSpec.hpp" #include @@ -45,6 +46,7 @@ namespace margelo::nitro::omni::views { CachedProp> player; CachedProp> autoplay; CachedProp> autoPip; + CachedProp> subtitleAssets; CachedProp& /* ref */)>>> hybridRef; private: diff --git a/nitrogen/generated/shared/json/OmniViewConfig.json b/nitrogen/generated/shared/json/OmniViewConfig.json index d1d9e8c..fac84a7 100644 --- a/nitrogen/generated/shared/json/OmniViewConfig.json +++ b/nitrogen/generated/shared/json/OmniViewConfig.json @@ -7,6 +7,7 @@ "player": true, "autoplay": true, "autoPip": true, + "subtitleAssets": true, "hybridRef": true } } diff --git a/src/types/source.ts b/src/types/source.ts index f87eba6..b291e19 100644 --- a/src/types/source.ts +++ b/src/types/source.ts @@ -9,7 +9,7 @@ export interface Source { mixAudio?: MixAudioMode; // Opaque, consumer-defined payload forwarded verbatim to the cast receiver // as the load request's customData. omni does not interpret it. - castData?: unknown; + castData?: Record; } export interface CastOptions { diff --git a/src/types/subtitles.ts b/src/types/subtitles.ts index 71a7614..ff1bd9f 100644 --- a/src/types/subtitles.ts +++ b/src/types/subtitles.ts @@ -1,16 +1,20 @@ +export interface JassubAssets { + /** URL of `jassub-worker.js`. */ + workerUrl?: string; + /** URL of `jassub-worker.wasm`. */ + wasmUrl?: string; + /** URL of `jassub-worker-modern.wasm`. */ + modernWasmUrl?: string; + /** URL of a fallback font used when the ASS file references none. */ + fontUrl?: string; +} + +export interface PgsAssets { + /** URL of `libpgs.worker.js`. */ + workerUrl?: string; +} + export interface SubtitleAssets { - jassub?: { - /** URL of `jassub-worker.js`. */ - workerUrl?: string; - /** URL of `jassub-worker.wasm`. */ - wasmUrl?: string; - /** URL of `jassub-worker-modern.wasm`. */ - modernWasmUrl?: string; - /** URL of a fallback font used when the ASS file references none. */ - fontUrl?: string; - }; - pgs?: { - /** URL of `libpgs.worker.js`. */ - workerUrl?: string; - }; + jassub?: JassubAssets; + pgs?: PgsAssets; } diff --git a/src/view.web.tsx b/src/view.web.tsx index 39c53ae..b9ca345 100644 --- a/src/view.web.tsx +++ b/src/view.web.tsx @@ -119,22 +119,21 @@ export const OmniView = ({ const castData = player.source?.castData; const config = useMemo( - () => - ({ - hlsJs: { - xhrSetup: (xhr: XMLHttpRequest) => { - const headers = headersRef.current; - if (!headers) return; - for (const [key, value] of Object.entries(headers)) { - if (value) xhr.setRequestHeader(key, value); - } - }, + () => ({ + hlsJs: { + xhrSetup: (xhr: XMLHttpRequest) => { + const headers = headersRef.current; + if (!headers) return; + for (const [key, value] of Object.entries(headers)) { + if (value) xhr.setRequestHeader(key, value); + } }, - googleCast: { - receiver: player.castOptions?.receiverApplicationId, - customData: castData ?? null, - }, - }) as HlsMediaConfig, + }, + googleCast: { + receiver: player.castOptions?.receiverApplicationId, + customData: castData ?? null, + }, + }), [player.castOptions, castData], );