mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-16 02:44:51 +00:00
Cleanup source handling
This commit is contained in:
+27
-7
@@ -9,14 +9,34 @@
|
||||
|
||||
// Forward declaration of `HybridOmniPlayerSpec` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { class HybridOmniPlayerSpec; }
|
||||
// Forward declaration of `HybridOmniPlayerPropsSpec` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { class HybridOmniPlayerPropsSpec; }
|
||||
// Forward declaration of `Source` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct Source; }
|
||||
// Forward declaration of `VideoSrc` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct VideoSrc; }
|
||||
// Forward declaration of `Subtitle` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct Subtitle; }
|
||||
// Forward declaration of `Metadata` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct Metadata; }
|
||||
// Forward declaration of `MixAudioMode` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { enum class MixAudioMode; }
|
||||
|
||||
#include <memory>
|
||||
#include "HybridOmniPlayerSpec.hpp"
|
||||
#include "JHybridOmniPlayerSpec.hpp"
|
||||
#include "HybridOmniPlayerPropsSpec.hpp"
|
||||
#include "JHybridOmniPlayerPropsSpec.hpp"
|
||||
#include "Source.hpp"
|
||||
#include "JSource.hpp"
|
||||
#include "VideoSrc.hpp"
|
||||
#include <vector>
|
||||
#include "JVideoSrc.hpp"
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include "Subtitle.hpp"
|
||||
#include "JSubtitle.hpp"
|
||||
#include "Metadata.hpp"
|
||||
#include "JMetadata.hpp"
|
||||
#include "MixAudioMode.hpp"
|
||||
#include "JMixAudioMode.hpp"
|
||||
|
||||
namespace margelo::nitro::omni {
|
||||
|
||||
@@ -51,9 +71,9 @@ namespace margelo::nitro::omni {
|
||||
|
||||
|
||||
// Methods
|
||||
std::shared_ptr<HybridOmniPlayerSpec> JHybridOmniPlayerFactorySpec::createPlayer(const std::shared_ptr<HybridOmniPlayerPropsSpec>& props) {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JHybridOmniPlayerSpec::JavaPart>(jni::alias_ref<JHybridOmniPlayerPropsSpec::JavaPart> /* props */)>("createPlayer");
|
||||
auto __result = method(_javaPart, std::dynamic_pointer_cast<JHybridOmniPlayerPropsSpec>(props)->getJavaPart());
|
||||
std::shared_ptr<HybridOmniPlayerSpec> JHybridOmniPlayerFactorySpec::createPlayer(const Source& props) {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JHybridOmniPlayerSpec::JavaPart>(jni::alias_ref<JSource> /* props */)>("createPlayer");
|
||||
auto __result = method(_javaPart, JSource::fromCpp(props));
|
||||
return __result->getJHybridOmniPlayerSpec();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace margelo::nitro::omni {
|
||||
|
||||
public:
|
||||
// Methods
|
||||
std::shared_ptr<HybridOmniPlayerSpec> createPlayer(const std::shared_ptr<HybridOmniPlayerPropsSpec>& props) override;
|
||||
std::shared_ptr<HybridOmniPlayerSpec> createPlayer(const Source& props) override;
|
||||
|
||||
private:
|
||||
jni::global_ref<JHybridOmniPlayerFactorySpec::JavaPart> _javaPart;
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
///
|
||||
/// JHybridOmniPlayerPropsSpec.cpp
|
||||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
||||
/// https://github.com/mrousavy/nitro
|
||||
/// Copyright © Marc Rousavy @ Margelo
|
||||
///
|
||||
|
||||
#include "JHybridOmniPlayerPropsSpec.hpp"
|
||||
|
||||
// Forward declaration of `VideoSrc` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct VideoSrc; }
|
||||
// Forward declaration of `Subtitle` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct Subtitle; }
|
||||
// Forward declaration of `Metadata` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct Metadata; }
|
||||
// Forward declaration of `MixAudioMode` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { enum class MixAudioMode; }
|
||||
|
||||
#include "VideoSrc.hpp"
|
||||
#include <vector>
|
||||
#include "JVideoSrc.hpp"
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include "Subtitle.hpp"
|
||||
#include "JSubtitle.hpp"
|
||||
#include "Metadata.hpp"
|
||||
#include "JMetadata.hpp"
|
||||
#include "MixAudioMode.hpp"
|
||||
#include "JMixAudioMode.hpp"
|
||||
|
||||
namespace margelo::nitro::omni {
|
||||
|
||||
std::shared_ptr<JHybridOmniPlayerPropsSpec> JHybridOmniPlayerPropsSpec::JavaPart::getJHybridOmniPlayerPropsSpec() {
|
||||
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
||||
auto castHybridObject = std::dynamic_pointer_cast<JHybridOmniPlayerPropsSpec>(hybridObject);
|
||||
if (castHybridObject == nullptr) [[unlikely]] {
|
||||
throw std::runtime_error("Failed to downcast JHybridObject to JHybridOmniPlayerPropsSpec!");
|
||||
}
|
||||
return castHybridObject;
|
||||
}
|
||||
|
||||
jni::local_ref<JHybridOmniPlayerPropsSpec::CxxPart::jhybriddata> JHybridOmniPlayerPropsSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
||||
return makeCxxInstance(jThis);
|
||||
}
|
||||
|
||||
std::shared_ptr<JHybridObject> JHybridOmniPlayerPropsSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
||||
auto castJavaPart = jni::dynamic_ref_cast<JHybridOmniPlayerPropsSpec::JavaPart>(javaPart);
|
||||
if (castJavaPart == nullptr) [[unlikely]] {
|
||||
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridOmniPlayerPropsSpec::JavaPart!");
|
||||
}
|
||||
return std::make_shared<JHybridOmniPlayerPropsSpec>(castJavaPart);
|
||||
}
|
||||
|
||||
void JHybridOmniPlayerPropsSpec::CxxPart::registerNatives() {
|
||||
registerHybrid({
|
||||
makeNativeMethod("initHybrid", JHybridOmniPlayerPropsSpec::CxxPart::initHybrid),
|
||||
});
|
||||
}
|
||||
|
||||
// Properties
|
||||
std::vector<VideoSrc> JHybridOmniPlayerPropsSpec::getSrc() {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JVideoSrc>>()>("getSrc");
|
||||
auto __result = method(_javaPart);
|
||||
return [&]() {
|
||||
size_t __size = __result->size();
|
||||
std::vector<VideoSrc> __vector;
|
||||
__vector.reserve(__size);
|
||||
for (size_t __i = 0; __i < __size; __i++) {
|
||||
auto __element = __result->getElement(__i);
|
||||
__vector.push_back(__element->toCpp());
|
||||
}
|
||||
return __vector;
|
||||
}();
|
||||
}
|
||||
void JHybridOmniPlayerPropsSpec::setSrc(const std::vector<VideoSrc>& src) {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JVideoSrc>> /* src */)>("setSrc");
|
||||
method(_javaPart, [&]() {
|
||||
size_t __size = src.size();
|
||||
jni::local_ref<jni::JArrayClass<JVideoSrc>> __array = jni::JArrayClass<JVideoSrc>::newArray(__size);
|
||||
for (size_t __i = 0; __i < __size; __i++) {
|
||||
const auto& __element = src[__i];
|
||||
auto __elementJni = JVideoSrc::fromCpp(__element);
|
||||
__array->setElement(__i, *__elementJni);
|
||||
}
|
||||
return __array;
|
||||
}());
|
||||
}
|
||||
std::optional<double> JHybridOmniPlayerPropsSpec::getStartTime() {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getStartTime");
|
||||
auto __result = method(_javaPart);
|
||||
return __result != nullptr ? std::make_optional(__result->value()) : std::nullopt;
|
||||
}
|
||||
void JHybridOmniPlayerPropsSpec::setStartTime(std::optional<double> startTime) {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* startTime */)>("setStartTime");
|
||||
method(_javaPart, startTime.has_value() ? jni::JDouble::valueOf(startTime.value()) : nullptr);
|
||||
}
|
||||
std::vector<Subtitle> JHybridOmniPlayerPropsSpec::getSubtitles() {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JSubtitle>>()>("getSubtitles");
|
||||
auto __result = method(_javaPart);
|
||||
return [&]() {
|
||||
size_t __size = __result->size();
|
||||
std::vector<Subtitle> __vector;
|
||||
__vector.reserve(__size);
|
||||
for (size_t __i = 0; __i < __size; __i++) {
|
||||
auto __element = __result->getElement(__i);
|
||||
__vector.push_back(__element->toCpp());
|
||||
}
|
||||
return __vector;
|
||||
}();
|
||||
}
|
||||
void JHybridOmniPlayerPropsSpec::setSubtitles(const std::vector<Subtitle>& subtitles) {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JSubtitle>> /* subtitles */)>("setSubtitles");
|
||||
method(_javaPart, [&]() {
|
||||
size_t __size = subtitles.size();
|
||||
jni::local_ref<jni::JArrayClass<JSubtitle>> __array = jni::JArrayClass<JSubtitle>::newArray(__size);
|
||||
for (size_t __i = 0; __i < __size; __i++) {
|
||||
const auto& __element = subtitles[__i];
|
||||
auto __elementJni = JSubtitle::fromCpp(__element);
|
||||
__array->setElement(__i, *__elementJni);
|
||||
}
|
||||
return __array;
|
||||
}());
|
||||
}
|
||||
std::optional<Metadata> JHybridOmniPlayerPropsSpec::getMetadata() {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JMetadata>()>("getMetadata");
|
||||
auto __result = method(_javaPart);
|
||||
return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
|
||||
}
|
||||
void JHybridOmniPlayerPropsSpec::setMetadata(const std::optional<Metadata>& metadata) {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JMetadata> /* metadata */)>("setMetadata");
|
||||
method(_javaPart, metadata.has_value() ? JMetadata::fromCpp(metadata.value()) : nullptr);
|
||||
}
|
||||
std::optional<MixAudioMode> JHybridOmniPlayerPropsSpec::getMixAudio() {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JMixAudioMode>()>("getMixAudio");
|
||||
auto __result = method(_javaPart);
|
||||
return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
|
||||
}
|
||||
void JHybridOmniPlayerPropsSpec::setMixAudio(std::optional<MixAudioMode> mixAudio) {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JMixAudioMode> /* mixAudio */)>("setMixAudio");
|
||||
method(_javaPart, mixAudio.has_value() ? JMixAudioMode::fromCpp(mixAudio.value()) : nullptr);
|
||||
}
|
||||
|
||||
// Methods
|
||||
|
||||
|
||||
} // namespace margelo::nitro::omni
|
||||
@@ -1,72 +0,0 @@
|
||||
///
|
||||
/// HybridOmniPlayerPropsSpec.hpp
|
||||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
||||
/// https://github.com/mrousavy/nitro
|
||||
/// Copyright © Marc Rousavy @ Margelo
|
||||
///
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <NitroModules/JHybridObject.hpp>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include "HybridOmniPlayerPropsSpec.hpp"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace margelo::nitro::omni {
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
class JHybridOmniPlayerPropsSpec: public virtual HybridOmniPlayerPropsSpec, public virtual JHybridObject {
|
||||
public:
|
||||
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
||||
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/HybridOmniPlayerPropsSpec;";
|
||||
std::shared_ptr<JHybridOmniPlayerPropsSpec> getJHybridOmniPlayerPropsSpec();
|
||||
};
|
||||
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
||||
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/HybridOmniPlayerPropsSpec$CxxPart;";
|
||||
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
||||
static void registerNatives();
|
||||
using HybridBase::HybridBase;
|
||||
protected:
|
||||
std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
|
||||
};
|
||||
|
||||
public:
|
||||
explicit JHybridOmniPlayerPropsSpec(const jni::local_ref<JHybridOmniPlayerPropsSpec::JavaPart>& javaPart):
|
||||
HybridObject(HybridOmniPlayerPropsSpec::TAG),
|
||||
JHybridObject(javaPart),
|
||||
_javaPart(jni::make_global(javaPart)) {}
|
||||
~JHybridOmniPlayerPropsSpec() override {
|
||||
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
||||
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
||||
}
|
||||
|
||||
public:
|
||||
inline const jni::global_ref<JHybridOmniPlayerPropsSpec::JavaPart>& getJavaPart() const noexcept {
|
||||
return _javaPart;
|
||||
}
|
||||
|
||||
public:
|
||||
// Properties
|
||||
std::vector<VideoSrc> getSrc() override;
|
||||
void setSrc(const std::vector<VideoSrc>& src) override;
|
||||
std::optional<double> getStartTime() override;
|
||||
void setStartTime(std::optional<double> startTime) override;
|
||||
std::vector<Subtitle> getSubtitles() override;
|
||||
void setSubtitles(const std::vector<Subtitle>& subtitles) override;
|
||||
std::optional<Metadata> getMetadata() override;
|
||||
void setMetadata(const std::optional<Metadata>& metadata) override;
|
||||
std::optional<MixAudioMode> getMixAudio() override;
|
||||
void setMixAudio(std::optional<MixAudioMode> mixAudio) override;
|
||||
|
||||
public:
|
||||
// Methods
|
||||
|
||||
|
||||
private:
|
||||
jni::global_ref<JHybridOmniPlayerPropsSpec::JavaPart> _javaPart;
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro::omni
|
||||
+33
-3
@@ -7,6 +7,16 @@
|
||||
|
||||
#include "JHybridOmniPlayerSpec.hpp"
|
||||
|
||||
// Forward declaration of `Source` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct Source; }
|
||||
// Forward declaration of `VideoSrc` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct VideoSrc; }
|
||||
// Forward declaration of `Subtitle` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct Subtitle; }
|
||||
// Forward declaration of `Metadata` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct Metadata; }
|
||||
// Forward declaration of `MixAudioMode` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { enum class MixAudioMode; }
|
||||
// Forward declaration of `PlayerStatus` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { enum class PlayerStatus; }
|
||||
// Forward declaration of `Track` to properly resolve imports.
|
||||
@@ -14,13 +24,24 @@ namespace margelo::nitro::omni { struct Track; }
|
||||
// Forward declaration of `Rendition` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct Rendition; }
|
||||
|
||||
#include "Source.hpp"
|
||||
#include "JSource.hpp"
|
||||
#include "VideoSrc.hpp"
|
||||
#include <vector>
|
||||
#include "JVideoSrc.hpp"
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include "Subtitle.hpp"
|
||||
#include "JSubtitle.hpp"
|
||||
#include "Metadata.hpp"
|
||||
#include "JMetadata.hpp"
|
||||
#include "MixAudioMode.hpp"
|
||||
#include "JMixAudioMode.hpp"
|
||||
#include "PlayerStatus.hpp"
|
||||
#include "JPlayerStatus.hpp"
|
||||
#include "Track.hpp"
|
||||
#include <vector>
|
||||
#include "JTrack.hpp"
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include "Rendition.hpp"
|
||||
#include "JRendition.hpp"
|
||||
|
||||
@@ -54,6 +75,15 @@ namespace margelo::nitro::omni {
|
||||
}
|
||||
|
||||
// Properties
|
||||
Source JHybridOmniPlayerSpec::getSource() {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JSource>()>("getSource");
|
||||
auto __result = method(_javaPart);
|
||||
return __result->toCpp();
|
||||
}
|
||||
void JHybridOmniPlayerSpec::setSource(const Source& source) {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JSource> /* source */)>("setSource");
|
||||
method(_javaPart, JSource::fromCpp(source));
|
||||
}
|
||||
bool JHybridOmniPlayerSpec::getHasPrev() {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("getHasPrev");
|
||||
auto __result = method(_javaPart);
|
||||
|
||||
@@ -50,6 +50,8 @@ namespace margelo::nitro::omni {
|
||||
|
||||
public:
|
||||
// Properties
|
||||
Source getSource() override;
|
||||
void setSource(const Source& source) override;
|
||||
bool getHasPrev() override;
|
||||
bool getHasNext() override;
|
||||
PlayerStatus getStatus() override;
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
///
|
||||
/// JSource.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 "Source.hpp"
|
||||
|
||||
#include "JMetadata.hpp"
|
||||
#include "JMixAudioMode.hpp"
|
||||
#include "JSubtitle.hpp"
|
||||
#include "JVideoSrc.hpp"
|
||||
#include "Metadata.hpp"
|
||||
#include "MixAudioMode.hpp"
|
||||
#include "Subtitle.hpp"
|
||||
#include "VideoSrc.hpp"
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace margelo::nitro::omni {
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
/**
|
||||
* The C++ JNI bridge between the C++ struct "Source" and the the Kotlin data class "Source".
|
||||
*/
|
||||
struct JSource final: public jni::JavaClass<JSource> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/Source;";
|
||||
|
||||
public:
|
||||
/**
|
||||
* Convert this Java/Kotlin-based struct to the C++ struct Source by copying all values to C++.
|
||||
*/
|
||||
[[maybe_unused]]
|
||||
[[nodiscard]]
|
||||
Source toCpp() const {
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto fieldSrc = clazz->getField<jni::JArrayClass<JVideoSrc>>("src");
|
||||
jni::local_ref<jni::JArrayClass<JVideoSrc>> src = this->getFieldValue(fieldSrc);
|
||||
static const auto fieldStartTime = clazz->getField<jni::JDouble>("startTime");
|
||||
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 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);
|
||||
return Source(
|
||||
[&]() {
|
||||
size_t __size = src->size();
|
||||
std::vector<VideoSrc> __vector;
|
||||
__vector.reserve(__size);
|
||||
for (size_t __i = 0; __i < __size; __i++) {
|
||||
auto __element = src->getElement(__i);
|
||||
__vector.push_back(__element->toCpp());
|
||||
}
|
||||
return __vector;
|
||||
}(),
|
||||
startTime != nullptr ? std::make_optional(startTime->value()) : std::nullopt,
|
||||
[&]() {
|
||||
size_t __size = subtitles->size();
|
||||
std::vector<Subtitle> __vector;
|
||||
__vector.reserve(__size);
|
||||
for (size_t __i = 0; __i < __size; __i++) {
|
||||
auto __element = subtitles->getElement(__i);
|
||||
__vector.push_back(__element->toCpp());
|
||||
}
|
||||
return __vector;
|
||||
}(),
|
||||
metadata != nullptr ? std::make_optional(metadata->toCpp()) : std::nullopt,
|
||||
mixAudio != nullptr ? std::make_optional(mixAudio->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<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>);
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
||||
return create(
|
||||
clazz,
|
||||
[&]() {
|
||||
size_t __size = value.src.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];
|
||||
auto __elementJni = JVideoSrc::fromCpp(__element);
|
||||
__array->setElement(__i, *__elementJni);
|
||||
}
|
||||
return __array;
|
||||
}(),
|
||||
value.startTime.has_value() ? jni::JDouble::valueOf(value.startTime.value()) : nullptr,
|
||||
[&]() {
|
||||
size_t __size = value.subtitles.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];
|
||||
auto __elementJni = JSubtitle::fromCpp(__element);
|
||||
__array->setElement(__i, *__elementJni);
|
||||
}
|
||||
return __array;
|
||||
}(),
|
||||
value.metadata.has_value() ? JMetadata::fromCpp(value.metadata.value()) : nullptr,
|
||||
value.mixAudio.has_value() ? JMixAudioMode::fromCpp(value.mixAudio.value()) : nullptr
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro::omni
|
||||
Reference in New Issue
Block a user