fix(nitro): fix native codegen

This commit is contained in:
2026-07-19 19:59:56 +02:00
parent 5921c2da59
commit 66471967e3
48 changed files with 1179 additions and 82 deletions
+1 -1
View File
@@ -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<JBoolProperty> {
public:
+67
View File
@@ -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 <fbjni/fbjni.h>
#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<JCastStatus> {
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<int>("value");
int ordinal = this->getFieldValue(fieldOrdinal);
return static_cast<CastStatus>(ordinal);
}
public:
/**
* Create a Java/Kotlin-based enum with the given C++ enum's value.
*/
[[maybe_unused]]
static jni::alias_ref<JCastStatus> fromCpp(CastStatus value) {
static const auto clazz = javaClassStatic();
switch (value) {
case CastStatus::CONNECTING:
static const auto fieldCONNECTING = clazz->getStaticField<JCastStatus>("CONNECTING");
return clazz->getStaticFieldValue(fieldCONNECTING);
case CastStatus::CONNECTED:
static const auto fieldCONNECTED = clazz->getStaticField<JCastStatus>("CONNECTED");
return clazz->getStaticFieldValue(fieldCONNECTED);
case CastStatus::AVAILABLE:
static const auto fieldAVAILABLE = clazz->getStaticField<JCastStatus>("AVAILABLE");
return clazz->getStaticFieldValue(fieldAVAILABLE);
case CastStatus::UNAVAILABLE:
static const auto fieldUNAVAILABLE = clazz->getStaticField<JCastStatus>("UNAVAILABLE");
return clazz->getStaticFieldValue(fieldUNAVAILABLE);
case CastStatus::UNSUPPORTED:
static const auto fieldUNSUPPORTED = clazz->getStaticField<JCastStatus>("UNSUPPORTED");
return clazz->getStaticFieldValue(fieldUNSUPPORTED);
default:
std::string stringValue = std::to_string(static_cast<int>(value));
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
}
}
};
} // namespace margelo::nitro::omni
+29 -16
View File
@@ -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<Track> JHybridOmniPlayerSpec::getVideos() {
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JTrack>>()>("getVideos");
auto __result = method(_javaPart);
return [&]() {
size_t __size = __result->size();
return [&](auto&& __input) {
size_t __size = __input->size();
std::vector<Track> __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<Track> JHybridOmniPlayerSpec::getAudios() {
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JTrack>>()>("getAudios");
auto __result = method(_javaPart);
return [&]() {
size_t __size = __result->size();
return [&](auto&& __input) {
size_t __size = __input->size();
std::vector<Track> __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<Track> JHybridOmniPlayerSpec::getSubtitles() {
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JTrack>>()>("getSubtitles");
auto __result = method(_javaPart);
return [&]() {
size_t __size = __result->size();
return [&](auto&& __input) {
size_t __size = __input->size();
std::vector<Track> __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<Rendition> JHybridOmniPlayerSpec::getRendition() {
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JRendition>>()>("getRendition");
auto __result = method(_javaPart);
return [&]() {
size_t __size = __result->size();
return [&](auto&& __input) {
size_t __size = __input->size();
std::vector<Rendition> __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<jni::local_ref<JPlayerStatus>()>("getStatus");
@@ -221,6 +225,11 @@ namespace margelo::nitro::omni {
auto __result = method(_javaPart);
return static_cast<bool>(__result);
}
CastStatus JHybridOmniPlayerSpec::getCastStatus() {
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JCastStatus>()>("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<void(double /* offset */)>("seekBy");
method(_javaPart, offset);
}
void JHybridOmniPlayerSpec::toggleCastStatus() {
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("toggleCastStatus");
method(_javaPart);
}
void JHybridOmniPlayerSpec::playPrev() {
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("playPrev");
method(_javaPart);
@@ -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;
+22
View File
@@ -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 <memory>
#include "HybridOmniPlayerSpec.hpp"
#include "JHybridOmniPlayerSpec.hpp"
#include <optional>
#include "SubtitleAssets.hpp"
#include "JSubtitleAssets.hpp"
#include "JassubAssets.hpp"
#include "JJassubAssets.hpp"
#include <string>
#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<void(jni::alias_ref<jni::JBoolean> /* autoPip */)>("setAutoPip");
method(_javaPart, autoPip.has_value() ? jni::JBoolean::valueOf(autoPip.value()) : nullptr);
}
std::optional<SubtitleAssets> JHybridOmniViewSpec::getSubtitleAssets() {
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JSubtitleAssets>()>("getSubtitleAssets");
auto __result = method(_javaPart);
return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
}
void JHybridOmniViewSpec::setSubtitleAssets(const std::optional<SubtitleAssets>& subtitleAssets) {
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JSubtitleAssets> /* subtitleAssets */)>("setSubtitleAssets");
method(_javaPart, subtitleAssets.has_value() ? JSubtitleAssets::fromCpp(subtitleAssets.value()) : nullptr);
}
// Methods
+2
View File
@@ -56,6 +56,8 @@ namespace margelo::nitro::omni {
void setAutoplay(std::optional<bool> autoplay) override;
std::optional<bool> getAutoPip() override;
void setAutoPip(std::optional<bool> autoPip) override;
std::optional<SubtitleAssets> getSubtitleAssets() override;
void setSubtitleAssets(const std::optional<SubtitleAssets>& subtitleAssets) override;
public:
// Methods
+70
View File
@@ -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 <fbjni/fbjni.h>
#include "JassubAssets.hpp"
#include <optional>
#include <string>
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<JJassubAssets> {
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<jni::JString>("workerUrl");
jni::local_ref<jni::JString> workerUrl = this->getFieldValue(fieldWorkerUrl);
static const auto fieldWasmUrl = clazz->getField<jni::JString>("wasmUrl");
jni::local_ref<jni::JString> wasmUrl = this->getFieldValue(fieldWasmUrl);
static const auto fieldModernWasmUrl = clazz->getField<jni::JString>("modernWasmUrl");
jni::local_ref<jni::JString> modernWasmUrl = this->getFieldValue(fieldModernWasmUrl);
static const auto fieldFontUrl = clazz->getField<jni::JString>("fontUrl");
jni::local_ref<jni::JString> 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<JJassubAssets::javaobject> fromCpp(const JassubAssets& value) {
using JSignature = JJassubAssets(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
static const auto clazz = javaClassStatic();
static const auto create = clazz->getStaticMethod<JSignature>("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
+1 -1
View File
@@ -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<JMetadata> {
public:
+1 -1
View File
@@ -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<JMixAudioMode> {
public:
+4 -1
View File
@@ -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<JNumberProperty> {
public:
@@ -60,6 +60,9 @@ namespace margelo::nitro::omni {
case NumberProperty::ISAUTOQUALITY:
static const auto fieldISAUTOQUALITY = clazz->getStaticField<JNumberProperty>("ISAUTOQUALITY");
return clazz->getStaticFieldValue(fieldISAUTOQUALITY);
case NumberProperty::CASTSTATUS:
static const auto fieldCASTSTATUS = clazz->getStaticField<JNumberProperty>("CASTSTATUS");
return clazz->getStaticFieldValue(fieldCASTSTATUS);
default:
std::string stringValue = std::to_string(static_cast<int>(value));
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
+58
View File
@@ -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 <fbjni/fbjni.h>
#include "PgsAssets.hpp"
#include <optional>
#include <string>
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<JPgsAssets> {
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<jni::JString>("workerUrl");
jni::local_ref<jni::JString> 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<JPgsAssets::javaobject> fromCpp(const PgsAssets& value) {
using JSignature = JPgsAssets(jni::alias_ref<jni::JString>);
static const auto clazz = javaClassStatic();
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
return create(
clazz,
value.workerUrl.has_value() ? jni::make_jstring(value.workerUrl.value()) : nullptr
);
}
};
} // namespace margelo::nitro::omni
+1 -1
View File
@@ -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<JPlayerStatus> {
public:
+1 -1
View File
@@ -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<JRendition> {
public:
+59 -20
View File
@@ -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<JSource> {
public:
@@ -48,34 +48,56 @@ namespace margelo::nitro::omni {
jni::local_ref<jni::JDouble> startTime = this->getFieldValue(fieldStartTime);
static const auto fieldSubtitles = clazz->getField<jni::JArrayClass<JSubtitle>>("subtitles");
jni::local_ref<jni::JArrayClass<JSubtitle>> subtitles = this->getFieldValue(fieldSubtitles);
static const auto fieldFonts = clazz->getField<jni::JArrayClass<jni::JString>>("fonts");
jni::local_ref<jni::JArrayClass<jni::JString>> fonts = this->getFieldValue(fieldFonts);
static const auto fieldMetadata = clazz->getField<JMetadata>("metadata");
jni::local_ref<JMetadata> metadata = this->getFieldValue(fieldMetadata);
static const auto fieldMixAudio = clazz->getField<JMixAudioMode>("mixAudio");
jni::local_ref<JMixAudioMode> mixAudio = this->getFieldValue(fieldMixAudio);
static const auto fieldCastData = clazz->getField<jni::JMap<jni::JString, jni::JString>>("castData");
jni::local_ref<jni::JMap<jni::JString, jni::JString>> castData = this->getFieldValue(fieldCastData);
return Source(
[&]() {
size_t __size = src->size();
[&](auto&& __input) {
size_t __size = __input->size();
std::vector<VideoSrc> __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<Subtitle> __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<std::string> __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<std::string, std::string> __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<JSource::javaobject> fromCpp(const Source& value) {
using JSignature = JSource(jni::alias_ref<jni::JArrayClass<JVideoSrc>>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JArrayClass<JSubtitle>>, jni::alias_ref<JMetadata>, jni::alias_ref<JMixAudioMode>);
using JSignature = JSource(jni::alias_ref<jni::JArrayClass<JVideoSrc>>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JArrayClass<JSubtitle>>, jni::alias_ref<jni::JArrayClass<jni::JString>>, jni::alias_ref<JMetadata>, jni::alias_ref<JMixAudioMode>, jni::alias_ref<jni::JMap<jni::JString, jni::JString>>);
static const auto clazz = javaClassStatic();
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
return create(
clazz,
[&]() {
size_t __size = value.src.size();
[&](auto&& __input) {
size_t __size = __input.size();
jni::local_ref<jni::JArrayClass<JVideoSrc>> __array = jni::JArrayClass<JVideoSrc>::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<jni::JArrayClass<JSubtitle>> __array = jni::JArrayClass<JSubtitle>::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<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::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<jni::JMap<jni::JString, jni::JString>> {
auto __map = jni::JHashMap<jni::JString, jni::JString>::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
);
}
};
+1 -1
View File
@@ -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<JSubtitle> {
public:
+66
View File
@@ -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 <fbjni/fbjni.h>
#include "SubtitleAssets.hpp"
#include "JJassubAssets.hpp"
#include "JPgsAssets.hpp"
#include "JassubAssets.hpp"
#include "PgsAssets.hpp"
#include <optional>
#include <string>
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<JSubtitleAssets> {
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<JJassubAssets>("jassub");
jni::local_ref<JJassubAssets> jassub = this->getFieldValue(fieldJassub);
static const auto fieldPgs = clazz->getField<JPgsAssets>("pgs");
jni::local_ref<JPgsAssets> 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<JSubtitleAssets::javaobject> fromCpp(const SubtitleAssets& value) {
using JSignature = JSubtitleAssets(jni::alias_ref<JJassubAssets>, jni::alias_ref<JPgsAssets>);
static const auto clazz = javaClassStatic();
static const auto create = clazz->getStaticMethod<JSignature>("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
+1 -1
View File
@@ -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<JTrack> {
public:
+1 -1
View File
@@ -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<JVideoSrc> {
public:
@@ -49,6 +49,10 @@ void JHybridOmniViewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /*
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) {
@@ -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
}
@@ -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
@@ -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
@@ -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<Any?>(
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)
}
}
}
@@ -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<Any?>(
title,
album,
artist,
imageLink,
hasPrev,
hasNext
).contentDeepHashCode()
}
companion object {
/**
* Constructor called from C++
@@ -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
}
@@ -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<Any?>(
workerUrl
).contentDeepHashCode()
}
companion object {
/**
* Constructor called from C++
*/
@DoNotStrip
@Keep
@Suppress("unused")
@JvmStatic
private fun fromCpp(workerUrl: String?): PgsAssets {
return PgsAssets(workerUrl)
}
}
}
@@ -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<Any?>(
id,
width,
height,
bitrate,
selected
).contentDeepHashCode()
}
companion object {
/**
* Constructor called from C++
@@ -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<Subtitle>,
@DoNotStrip
@Keep
val fonts: Array<String>?,
@DoNotStrip
@Keep
val metadata: Metadata?,
@DoNotStrip
@Keep
val mixAudio: MixAudioMode?
val mixAudio: MixAudioMode?,
@DoNotStrip
@Keep
val castData: Map<String, String>?
) {
/* 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<Any?>(
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<VideoSrc>, startTime: Double?, subtitles: Array<Subtitle>, metadata: Metadata?, mixAudio: MixAudioMode?): Source {
return Source(src, startTime, subtitles, metadata, mixAudio)
private fun fromCpp(src: Array<VideoSrc>, startTime: Double?, subtitles: Array<Subtitle>, fonts: Array<String>?, metadata: Metadata?, mixAudio: MixAudioMode?, castData: Map<String, String>?): Source {
return Source(src, startTime, subtitles, fonts, metadata, mixAudio, castData)
}
}
}
@@ -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<Any?>(
id,
link,
mimeType,
language,
label
).contentDeepHashCode()
}
companion object {
/**
* Constructor called from C++
@@ -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<Any?>(
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)
}
}
}
@@ -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<Any?>(
id,
label,
language,
selected
).contentDeepHashCode()
}
companion object {
/**
* Constructor called from C++
@@ -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<Any?>(
uri,
mimeType,
headers
).contentDeepHashCode()
}
companion object {
/**
* Constructor called from C++
+88
View File
@@ -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(<NitroModules/NitroHash.hpp>)
#include <NitroModules/NitroHash.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#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<margelo::nitro::omni::CastStatus> final {
static inline margelo::nitro::omni::CastStatus fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
std::string unionValue = JSIConverter<std::string>::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<std::string>::toJSI(runtime, "connecting");
case margelo::nitro::omni::CastStatus::CONNECTED: return JSIConverter<std::string>::toJSI(runtime, "connected");
case margelo::nitro::omni::CastStatus::AVAILABLE: return JSIConverter<std::string>::toJSI(runtime, "available");
case margelo::nitro::omni::CastStatus::UNAVAILABLE: return JSIConverter<std::string>::toJSI(runtime, "unavailable");
case margelo::nitro::omni::CastStatus::UNSUPPORTED: return JSIConverter<std::string>::toJSI(runtime, "unsupported");
default: [[unlikely]]
throw std::invalid_argument("Cannot convert CastStatus to JS - invalid value: "
+ std::to_string(static_cast<int>(arg)) + "!");
}
}
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
if (!value.isString()) {
return false;
}
std::string unionValue = JSIConverter<std::string>::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
+2
View File
@@ -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);
+5
View File
@@ -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 <vector>
#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;
+2
View File
@@ -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);
});
}
+5
View File
@@ -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 <memory>
#include "HybridOmniPlayerSpec.hpp"
#include <optional>
#include "SubtitleAssets.hpp"
namespace margelo::nitro::omni {
@@ -53,6 +56,8 @@ namespace margelo::nitro::omni {
virtual void setAutoplay(std::optional<bool> autoplay) = 0;
virtual std::optional<bool> getAutoPip() = 0;
virtual void setAutoPip(std::optional<bool> autoPip) = 0;
virtual std::optional<SubtitleAssets> getSubtitleAssets() = 0;
virtual void setSubtitleAssets(const std::optional<SubtitleAssets>& subtitleAssets) = 0;
public:
// Methods
+96
View File
@@ -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(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#include <string>
#include <optional>
namespace margelo::nitro::omni {
/**
* A struct which can be represented as a JavaScript object (JassubAssets).
*/
struct JassubAssets final {
public:
std::optional<std::string> workerUrl SWIFT_PRIVATE;
std::optional<std::string> wasmUrl SWIFT_PRIVATE;
std::optional<std::string> modernWasmUrl SWIFT_PRIVATE;
std::optional<std::string> fontUrl SWIFT_PRIVATE;
public:
JassubAssets() = default;
explicit JassubAssets(std::optional<std::string> workerUrl, std::optional<std::string> wasmUrl, std::optional<std::string> modernWasmUrl, std::optional<std::string> 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<margelo::nitro::omni::JassubAssets> 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<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "workerUrl"))),
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "wasmUrl"))),
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modernWasmUrl"))),
JSIConverter<std::optional<std::string>>::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<std::optional<std::string>>::toJSI(runtime, arg.workerUrl));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "wasmUrl"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.wasmUrl));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "modernWasmUrl"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.modernWasmUrl));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "fontUrl"), JSIConverter<std::optional<std::string>>::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<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "workerUrl")))) return false;
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "wasmUrl")))) return false;
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modernWasmUrl")))) return false;
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fontUrl")))) return false;
return true;
}
};
} // namespace margelo::nitro
+4
View File
@@ -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<std::string>::toJSI(runtime, "playbackRate");
case margelo::nitro::omni::NumberProperty::VOLUME: return JSIConverter<std::string>::toJSI(runtime, "volume");
case margelo::nitro::omni::NumberProperty::ISAUTOQUALITY: return JSIConverter<std::string>::toJSI(runtime, "isAutoQuality");
case margelo::nitro::omni::NumberProperty::CASTSTATUS: return JSIConverter<std::string>::toJSI(runtime, "castStatus");
default: [[unlikely]]
throw std::invalid_argument("Cannot convert NumberProperty to JS - invalid value: "
+ std::to_string(static_cast<int>(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;
+84
View File
@@ -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(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#include <string>
#include <optional>
namespace margelo::nitro::omni {
/**
* A struct which can be represented as a JavaScript object (PgsAssets).
*/
struct PgsAssets final {
public:
std::optional<std::string> workerUrl SWIFT_PRIVATE;
public:
PgsAssets() = default;
explicit PgsAssets(std::optional<std::string> 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<margelo::nitro::omni::PgsAssets> 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<std::optional<std::string>>::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<std::optional<std::string>>::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<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "workerUrl")))) return false;
return true;
}
};
} // namespace margelo::nitro
+12 -2
View File
@@ -41,8 +41,10 @@ namespace margelo::nitro::omni { enum class MixAudioMode; }
#include <vector>
#include <optional>
#include "Subtitle.hpp"
#include <string>
#include "Metadata.hpp"
#include "MixAudioMode.hpp"
#include <unordered_map>
namespace margelo::nitro::omni {
@@ -54,12 +56,14 @@ namespace margelo::nitro::omni {
std::vector<VideoSrc> src SWIFT_PRIVATE;
std::optional<double> startTime SWIFT_PRIVATE;
std::vector<Subtitle> subtitles SWIFT_PRIVATE;
std::optional<std::vector<std::string>> fonts SWIFT_PRIVATE;
std::optional<Metadata> metadata SWIFT_PRIVATE;
std::optional<MixAudioMode> mixAudio SWIFT_PRIVATE;
std::optional<std::unordered_map<std::string, std::string>> castData SWIFT_PRIVATE;
public:
Source() = default;
explicit Source(std::vector<VideoSrc> src, std::optional<double> startTime, std::vector<Subtitle> subtitles, std::optional<Metadata> metadata, std::optional<MixAudioMode> mixAudio): src(src), startTime(startTime), subtitles(subtitles), metadata(metadata), mixAudio(mixAudio) {}
explicit Source(std::vector<VideoSrc> src, std::optional<double> startTime, std::vector<Subtitle> subtitles, std::optional<std::vector<std::string>> fonts, std::optional<Metadata> metadata, std::optional<MixAudioMode> mixAudio, std::optional<std::unordered_map<std::string, std::string>> 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<std::vector<margelo::nitro::omni::VideoSrc>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "src"))),
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startTime"))),
JSIConverter<std::vector<margelo::nitro::omni::Subtitle>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subtitles"))),
JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fonts"))),
JSIConverter<std::optional<margelo::nitro::omni::Metadata>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metadata"))),
JSIConverter<std::optional<margelo::nitro::omni::MixAudioMode>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mixAudio")))
JSIConverter<std::optional<margelo::nitro::omni::MixAudioMode>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mixAudio"))),
JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::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<std::vector<margelo::nitro::omni::VideoSrc>>::toJSI(runtime, arg.src));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "startTime"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.startTime));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "subtitles"), JSIConverter<std::vector<margelo::nitro::omni::Subtitle>>::toJSI(runtime, arg.subtitles));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "fonts"), JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.fonts));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "metadata"), JSIConverter<std::optional<margelo::nitro::omni::Metadata>>::toJSI(runtime, arg.metadata));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "mixAudio"), JSIConverter<std::optional<margelo::nitro::omni::MixAudioMode>>::toJSI(runtime, arg.mixAudio));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "castData"), JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::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<std::vector<margelo::nitro::omni::VideoSrc>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "src")))) return false;
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startTime")))) return false;
if (!JSIConverter<std::vector<margelo::nitro::omni::Subtitle>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subtitles")))) return false;
if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fonts")))) return false;
if (!JSIConverter<std::optional<margelo::nitro::omni::Metadata>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metadata")))) return false;
if (!JSIConverter<std::optional<margelo::nitro::omni::MixAudioMode>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mixAudio")))) return false;
if (!JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "castData")))) return false;
return true;
}
};
+92
View File
@@ -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(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#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 <optional>
#include "PgsAssets.hpp"
namespace margelo::nitro::omni {
/**
* A struct which can be represented as a JavaScript object (SubtitleAssets).
*/
struct SubtitleAssets final {
public:
std::optional<JassubAssets> jassub SWIFT_PRIVATE;
std::optional<PgsAssets> pgs SWIFT_PRIVATE;
public:
SubtitleAssets() = default;
explicit SubtitleAssets(std::optional<JassubAssets> jassub, std::optional<PgsAssets> 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<margelo::nitro::omni::SubtitleAssets> 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<std::optional<margelo::nitro::omni::JassubAssets>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "jassub"))),
JSIConverter<std::optional<margelo::nitro::omni::PgsAssets>>::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<std::optional<margelo::nitro::omni::JassubAssets>>::toJSI(runtime, arg.jassub));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "pgs"), JSIConverter<std::optional<margelo::nitro::omni::PgsAssets>>::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<std::optional<margelo::nitro::omni::JassubAssets>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "jassub")))) return false;
if (!JSIConverter<std::optional<margelo::nitro::omni::PgsAssets>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pgs")))) return false;
return true;
}
};
} // namespace margelo::nitro
@@ -56,6 +56,16 @@ namespace margelo::nitro::omni::views {
throw std::runtime_error(std::string("OmniView.autoPip: ") + exc.what());
}
}()),
subtitleAssets([&]() -> CachedProp<std::optional<SubtitleAssets>> {
try {
const react::RawValue* rawValue = rawProps.at("subtitleAssets", nullptr, nullptr);
if (rawValue == nullptr) return sourceProps.subtitleAssets;
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
return CachedProp<std::optional<SubtitleAssets>>::fromRawValue(*runtime, value, sourceProps.subtitleAssets);
} catch (const std::exception& exc) {
throw std::runtime_error(std::string("OmniView.subtitleAssets: ") + exc.what());
}
}()),
hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridOmniViewSpec>& /* 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<const react::Props> HybridOmniViewComponentDescriptor::cloneProps(const react::PropsParserContext& context,
const std::shared_ptr<const react::Props>& props,
@@ -19,6 +19,7 @@
#include <memory>
#include "HybridOmniPlayerSpec.hpp"
#include <optional>
#include "SubtitleAssets.hpp"
#include "HybridOmniViewSpec.hpp"
#include <functional>
@@ -45,6 +46,7 @@ namespace margelo::nitro::omni::views {
CachedProp<std::shared_ptr<HybridOmniPlayerSpec>> player;
CachedProp<std::optional<bool>> autoplay;
CachedProp<std::optional<bool>> autoPip;
CachedProp<std::optional<SubtitleAssets>> subtitleAssets;
CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridOmniViewSpec>& /* ref */)>>> hybridRef;
private:
+1
View File
@@ -7,6 +7,7 @@
"player": true,
"autoplay": true,
"autoPip": true,
"subtitleAssets": true,
"hybridRef": true
}
}
+1 -1
View File
@@ -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<string, string>;
}
export interface CastOptions {
+18 -14
View File
@@ -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;
}
+14 -15
View File
@@ -119,22 +119,21 @@ export const OmniView = ({
const castData = player.source?.castData;
const config = useMemo<HlsMediaConfig>(
() =>
({
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],
);