mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-16 02:44:51 +00:00
feat(android): support chromecast
This commit is contained in:
+2
@@ -19,6 +19,7 @@
|
||||
#include "JFunc_void_double.hpp"
|
||||
#include "JFunc_void_bool.hpp"
|
||||
#include "JFunc_void_PlayerStatus.hpp"
|
||||
#include "JFunc_void_CastStatus.hpp"
|
||||
#include "JFunc_void.hpp"
|
||||
#include "JFunc_void_std__string_std__string.hpp"
|
||||
#include "JFunc_void_std__string.hpp"
|
||||
@@ -65,6 +66,7 @@ void registerAllNatives() {
|
||||
margelo::nitro::omni::JFunc_void_double_cxx::registerNatives();
|
||||
margelo::nitro::omni::JFunc_void_bool_cxx::registerNatives();
|
||||
margelo::nitro::omni::JFunc_void_PlayerStatus_cxx::registerNatives();
|
||||
margelo::nitro::omni::JFunc_void_CastStatus_cxx::registerNatives();
|
||||
margelo::nitro::omni::JFunc_void_cxx::registerNatives();
|
||||
margelo::nitro::omni::JFunc_void_std__string_std__string_cxx::registerNatives();
|
||||
margelo::nitro::omni::JFunc_void_std__string_cxx::registerNatives();
|
||||
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
///
|
||||
/// JCastOptions.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 "CastOptions.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace margelo::nitro::omni {
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
/**
|
||||
* The C++ JNI bridge between the C++ struct "CastOptions" and the Kotlin data class "CastOptions".
|
||||
*/
|
||||
struct JCastOptions final: public jni::JavaClass<JCastOptions> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/CastOptions;";
|
||||
|
||||
public:
|
||||
/**
|
||||
* Convert this Java/Kotlin-based struct to the C++ struct CastOptions by copying all values to C++.
|
||||
*/
|
||||
[[maybe_unused]]
|
||||
[[nodiscard]]
|
||||
CastOptions toCpp() const {
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto fieldReceiverApplicationId = clazz->getField<jni::JString>("receiverApplicationId");
|
||||
jni::local_ref<jni::JString> receiverApplicationId = this->getFieldValue(fieldReceiverApplicationId);
|
||||
return CastOptions(
|
||||
receiverApplicationId != nullptr ? std::make_optional(receiverApplicationId->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<JCastOptions::javaobject> fromCpp(const CastOptions& value) {
|
||||
using JSignature = JCastOptions(jni::alias_ref<jni::JString>);
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
||||
return create(
|
||||
clazz,
|
||||
value.receiverApplicationId.has_value() ? jni::make_jstring(value.receiverApplicationId.value()) : nullptr
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro::omni
|
||||
@@ -0,0 +1,77 @@
|
||||
///
|
||||
/// JFunc_void_CastStatus.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 <functional>
|
||||
|
||||
#include "CastStatus.hpp"
|
||||
#include <functional>
|
||||
#include <NitroModules/JNICallable.hpp>
|
||||
#include "JCastStatus.hpp"
|
||||
|
||||
namespace margelo::nitro::omni {
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
/**
|
||||
* Represents the Java/Kotlin callback `(value: CastStatus) -> Unit`.
|
||||
* This can be passed around between C++ and Java/Kotlin.
|
||||
*/
|
||||
struct JFunc_void_CastStatus: public jni::JavaClass<JFunc_void_CastStatus> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/Func_void_CastStatus;";
|
||||
|
||||
public:
|
||||
/**
|
||||
* Invokes the function this `JFunc_void_CastStatus` instance holds through JNI.
|
||||
*/
|
||||
void invoke(CastStatus value) const {
|
||||
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JCastStatus> /* value */)>("invoke");
|
||||
method(self(), JCastStatus::fromCpp(value));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* An implementation of Func_void_CastStatus that is backed by a C++ implementation (using `std::function<...>`)
|
||||
*/
|
||||
class JFunc_void_CastStatus_cxx final: public jni::HybridClass<JFunc_void_CastStatus_cxx, JFunc_void_CastStatus> {
|
||||
public:
|
||||
static jni::local_ref<JFunc_void_CastStatus::javaobject> fromCpp(const std::function<void(CastStatus /* value */)>& func) {
|
||||
return JFunc_void_CastStatus_cxx::newObjectCxxArgs(func);
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Invokes the C++ `std::function<...>` this `JFunc_void_CastStatus_cxx` instance holds.
|
||||
*/
|
||||
void invoke_cxx(jni::alias_ref<JCastStatus> value) {
|
||||
_func(value->toCpp());
|
||||
}
|
||||
|
||||
public:
|
||||
[[nodiscard]]
|
||||
inline const std::function<void(CastStatus /* value */)>& getFunction() const {
|
||||
return _func;
|
||||
}
|
||||
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/Func_void_CastStatus_cxx;";
|
||||
static void registerNatives() {
|
||||
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_CastStatus_cxx::invoke_cxx)});
|
||||
}
|
||||
|
||||
private:
|
||||
explicit JFunc_void_CastStatus_cxx(const std::function<void(CastStatus /* value */)>& func): _func(func) { }
|
||||
|
||||
private:
|
||||
friend HybridBase;
|
||||
std::function<void(CastStatus /* value */)> _func;
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro::omni
|
||||
@@ -13,6 +13,8 @@ namespace margelo::nitro::omni { enum class NumberProperty; }
|
||||
namespace margelo::nitro::omni { enum class BoolProperty; }
|
||||
// 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 `Track` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct Track; }
|
||||
// Forward declaration of `Rendition` to properly resolve imports.
|
||||
@@ -29,6 +31,9 @@ namespace margelo::nitro::omni { struct Rendition; }
|
||||
#include "PlayerStatus.hpp"
|
||||
#include "JFunc_void_PlayerStatus.hpp"
|
||||
#include "JPlayerStatus.hpp"
|
||||
#include "CastStatus.hpp"
|
||||
#include "JFunc_void_CastStatus.hpp"
|
||||
#include "JCastStatus.hpp"
|
||||
#include "JFunc_void.hpp"
|
||||
#include <string>
|
||||
#include "JFunc_void_std__string_std__string.hpp"
|
||||
@@ -99,6 +104,14 @@ namespace margelo::nitro::omni {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_PlayerStatus::javaobject> /* cb */)>("removePlayerStatusListener_cxx");
|
||||
method(_javaPart, JFunc_void_PlayerStatus_cxx::fromCpp(cb));
|
||||
}
|
||||
void JHybridOmniEventMapSpec::addCastStatusListener(const std::function<void(CastStatus /* value */)>& cb) {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_CastStatus::javaobject> /* cb */)>("addCastStatusListener_cxx");
|
||||
method(_javaPart, JFunc_void_CastStatus_cxx::fromCpp(cb));
|
||||
}
|
||||
void JHybridOmniEventMapSpec::removeCastStatusListener(const std::function<void(CastStatus /* value */)>& cb) {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_CastStatus::javaobject> /* cb */)>("removeCastStatusListener_cxx");
|
||||
method(_javaPart, JFunc_void_CastStatus_cxx::fromCpp(cb));
|
||||
}
|
||||
void JHybridOmniEventMapSpec::addOnEndListener(const std::function<void()>& cb) {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* cb */)>("addOnEndListener_cxx");
|
||||
method(_javaPart, JFunc_void_cxx::fromCpp(cb));
|
||||
|
||||
@@ -60,6 +60,8 @@ namespace margelo::nitro::omni {
|
||||
void removeStateBoolListener(BoolProperty key, const std::function<void(bool /* value */)>& cb) override;
|
||||
void addPlayerStatusListener(const std::function<void(PlayerStatus /* value */)>& cb) override;
|
||||
void removePlayerStatusListener(const std::function<void(PlayerStatus /* value */)>& cb) override;
|
||||
void addCastStatusListener(const std::function<void(CastStatus /* value */)>& cb) override;
|
||||
void removeCastStatusListener(const std::function<void(CastStatus /* value */)>& cb) override;
|
||||
void addOnEndListener(const std::function<void()>& cb) override;
|
||||
void removeOnEndListener(const std::function<void()>& cb) override;
|
||||
void addOnPrevListener(const std::function<void()>& cb) override;
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace margelo::nitro::omni { enum class MixAudioMode; }
|
||||
namespace margelo::nitro::omni { struct PlayerBackend; }
|
||||
// Forward declaration of `AndroidBackend` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { enum class AndroidBackend; }
|
||||
// Forward declaration of `CastOptions` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct CastOptions; }
|
||||
|
||||
#include <memory>
|
||||
#include "HybridOmniPlayerSpec.hpp"
|
||||
@@ -45,6 +47,8 @@ namespace margelo::nitro::omni { enum class AndroidBackend; }
|
||||
#include "JPlayerBackend.hpp"
|
||||
#include "AndroidBackend.hpp"
|
||||
#include "JAndroidBackend.hpp"
|
||||
#include "CastOptions.hpp"
|
||||
#include "JCastOptions.hpp"
|
||||
|
||||
namespace margelo::nitro::omni {
|
||||
|
||||
@@ -79,9 +83,9 @@ namespace margelo::nitro::omni {
|
||||
|
||||
|
||||
// Methods
|
||||
std::shared_ptr<HybridOmniPlayerSpec> JHybridOmniPlayerFactorySpec::createPlayer(const std::optional<Source>& props, const std::optional<PlayerBackend>& backend) {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JHybridOmniPlayerSpec::JavaPart>(jni::alias_ref<JSource> /* props */, jni::alias_ref<JPlayerBackend> /* backend */)>("createPlayer");
|
||||
auto __result = method(_javaPart, props.has_value() ? JSource::fromCpp(props.value()) : nullptr, backend.has_value() ? JPlayerBackend::fromCpp(backend.value()) : nullptr);
|
||||
std::shared_ptr<HybridOmniPlayerSpec> JHybridOmniPlayerFactorySpec::createPlayer(const std::optional<Source>& props, const std::optional<PlayerBackend>& backend, const std::optional<CastOptions>& cast) {
|
||||
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JHybridOmniPlayerSpec::JavaPart>(jni::alias_ref<JSource> /* props */, jni::alias_ref<JPlayerBackend> /* backend */, jni::alias_ref<JCastOptions> /* cast */)>("createPlayer");
|
||||
auto __result = method(_javaPart, props.has_value() ? JSource::fromCpp(props.value()) : nullptr, backend.has_value() ? JPlayerBackend::fromCpp(backend.value()) : nullptr, cast.has_value() ? JCastOptions::fromCpp(cast.value()) : nullptr);
|
||||
return __result->getJHybridOmniPlayerSpec();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace margelo::nitro::omni {
|
||||
|
||||
public:
|
||||
// Methods
|
||||
std::shared_ptr<HybridOmniPlayerSpec> createPlayer(const std::optional<Source>& props, const std::optional<PlayerBackend>& backend) override;
|
||||
std::shared_ptr<HybridOmniPlayerSpec> createPlayer(const std::optional<Source>& props, const std::optional<PlayerBackend>& backend, const std::optional<CastOptions>& cast) override;
|
||||
|
||||
private:
|
||||
jni::global_ref<JHybridOmniPlayerFactorySpec::JavaPart> _javaPart;
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
///
|
||||
/// CastOptions.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 "CastOptions".
|
||||
*/
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
data class CastOptions(
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val receiverApplicationId: String?
|
||||
) {
|
||||
/* primary constructor */
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is CastOptions) return false
|
||||
return Objects.deepEquals(this.receiverApplicationId, other.receiverApplicationId)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return arrayOf<Any?>(
|
||||
receiverApplicationId
|
||||
).contentDeepHashCode()
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Constructor called from C++
|
||||
*/
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
@Suppress("unused")
|
||||
@JvmStatic
|
||||
private fun fromCpp(receiverApplicationId: String?): CastOptions {
|
||||
return CastOptions(receiverApplicationId)
|
||||
}
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
///
|
||||
/// Func_void_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.jni.HybridData
|
||||
import com.facebook.proguard.annotations.DoNotStrip
|
||||
import dalvik.annotation.optimization.FastNative
|
||||
|
||||
|
||||
/**
|
||||
* Represents the JavaScript callback `(value: enum) => void`.
|
||||
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
||||
* or in Kotlin/Java (in which case it is a native callback).
|
||||
*/
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
@Suppress("ClassName", "RedundantUnitReturnType")
|
||||
fun interface Func_void_CastStatus: (CastStatus) -> Unit {
|
||||
/**
|
||||
* Call the given JS callback.
|
||||
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
||||
*/
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
override fun invoke(value: CastStatus): Unit
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the JavaScript callback `(value: enum) => void`.
|
||||
* This is implemented in C++, via a `std::function<...>`.
|
||||
* The callback might be coming from JS.
|
||||
*/
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
@Suppress(
|
||||
"KotlinJniMissingFunction", "unused",
|
||||
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
||||
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
||||
)
|
||||
class Func_void_CastStatus_cxx: Func_void_CastStatus {
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
private val mHybridData: HybridData
|
||||
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
private constructor(hybridData: HybridData) {
|
||||
mHybridData = hybridData
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
override fun invoke(value: CastStatus): Unit
|
||||
= invoke_cxx(value)
|
||||
|
||||
@FastNative
|
||||
private external fun invoke_cxx(value: CastStatus): Unit
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the JavaScript callback `(value: enum) => void`.
|
||||
* This is implemented in Java/Kotlin, via a `(CastStatus) -> Unit`.
|
||||
* The callback is always coming from native.
|
||||
*/
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
||||
class Func_void_CastStatus_java(private val function: (CastStatus) -> Unit): Func_void_CastStatus {
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
override fun invoke(value: CastStatus): Unit {
|
||||
return this.function(value)
|
||||
}
|
||||
}
|
||||
+18
@@ -82,6 +82,24 @@ abstract class HybridOmniEventMapSpec: HybridObject() {
|
||||
return __result
|
||||
}
|
||||
|
||||
abstract fun addCastStatusListener(cb: (value: CastStatus) -> Unit): Unit
|
||||
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
private fun addCastStatusListener_cxx(cb: Func_void_CastStatus): Unit {
|
||||
val __result = addCastStatusListener(cb)
|
||||
return __result
|
||||
}
|
||||
|
||||
abstract fun removeCastStatusListener(cb: (value: CastStatus) -> Unit): Unit
|
||||
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
private fun removeCastStatusListener_cxx(cb: Func_void_CastStatus): Unit {
|
||||
val __result = removeCastStatusListener(cb)
|
||||
return __result
|
||||
}
|
||||
|
||||
abstract fun addOnEndListener(cb: () -> Unit): Unit
|
||||
|
||||
@DoNotStrip
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ abstract class HybridOmniPlayerFactorySpec: HybridObject() {
|
||||
// Methods
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
abstract fun createPlayer(props: Source?, backend: PlayerBackend?): HybridOmniPlayerSpec
|
||||
abstract fun createPlayer(props: Source?, backend: PlayerBackend?, cast: CastOptions?): HybridOmniPlayerSpec
|
||||
|
||||
// Default implementation of `HybridObject.toString()`
|
||||
override fun toString(): String {
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
///
|
||||
/// CastOptions.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 (CastOptions).
|
||||
*/
|
||||
struct CastOptions final {
|
||||
public:
|
||||
std::optional<std::string> receiverApplicationId SWIFT_PRIVATE;
|
||||
|
||||
public:
|
||||
CastOptions() = default;
|
||||
explicit CastOptions(std::optional<std::string> receiverApplicationId): receiverApplicationId(receiverApplicationId) {}
|
||||
|
||||
public:
|
||||
friend bool operator==(const CastOptions& lhs, const CastOptions& rhs) = default;
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro::omni
|
||||
|
||||
namespace margelo::nitro {
|
||||
|
||||
// C++ CastOptions <> JS CastOptions (object)
|
||||
template <>
|
||||
struct JSIConverter<margelo::nitro::omni::CastOptions> final {
|
||||
static inline margelo::nitro::omni::CastOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
||||
jsi::Object obj = arg.asObject(runtime);
|
||||
return margelo::nitro::omni::CastOptions(
|
||||
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receiverApplicationId")))
|
||||
);
|
||||
}
|
||||
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::omni::CastOptions& arg) {
|
||||
jsi::Object obj(runtime);
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "receiverApplicationId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.receiverApplicationId));
|
||||
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, "receiverApplicationId")))) return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro
|
||||
@@ -20,6 +20,8 @@ namespace margelo::nitro::omni {
|
||||
prototype.registerHybridMethod("removeStateBoolListener", &HybridOmniEventMapSpec::removeStateBoolListener);
|
||||
prototype.registerHybridMethod("addPlayerStatusListener", &HybridOmniEventMapSpec::addPlayerStatusListener);
|
||||
prototype.registerHybridMethod("removePlayerStatusListener", &HybridOmniEventMapSpec::removePlayerStatusListener);
|
||||
prototype.registerHybridMethod("addCastStatusListener", &HybridOmniEventMapSpec::addCastStatusListener);
|
||||
prototype.registerHybridMethod("removeCastStatusListener", &HybridOmniEventMapSpec::removeCastStatusListener);
|
||||
prototype.registerHybridMethod("addOnEndListener", &HybridOmniEventMapSpec::addOnEndListener);
|
||||
prototype.registerHybridMethod("removeOnEndListener", &HybridOmniEventMapSpec::removeOnEndListener);
|
||||
prototype.registerHybridMethod("addOnPrevListener", &HybridOmniEventMapSpec::addOnPrevListener);
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace margelo::nitro::omni { enum class NumberProperty; }
|
||||
namespace margelo::nitro::omni { enum class BoolProperty; }
|
||||
// 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 `Track` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct Track; }
|
||||
// Forward declaration of `Rendition` to properly resolve imports.
|
||||
@@ -28,6 +30,7 @@ namespace margelo::nitro::omni { struct Rendition; }
|
||||
#include <functional>
|
||||
#include "BoolProperty.hpp"
|
||||
#include "PlayerStatus.hpp"
|
||||
#include "CastStatus.hpp"
|
||||
#include <string>
|
||||
#include "Track.hpp"
|
||||
#include <optional>
|
||||
@@ -70,6 +73,8 @@ namespace margelo::nitro::omni {
|
||||
virtual void removeStateBoolListener(BoolProperty key, const std::function<void(bool /* value */)>& cb) = 0;
|
||||
virtual void addPlayerStatusListener(const std::function<void(PlayerStatus /* value */)>& cb) = 0;
|
||||
virtual void removePlayerStatusListener(const std::function<void(PlayerStatus /* value */)>& cb) = 0;
|
||||
virtual void addCastStatusListener(const std::function<void(CastStatus /* value */)>& cb) = 0;
|
||||
virtual void removeCastStatusListener(const std::function<void(CastStatus /* value */)>& cb) = 0;
|
||||
virtual void addOnEndListener(const std::function<void()>& cb) = 0;
|
||||
virtual void removeOnEndListener(const std::function<void()>& cb) = 0;
|
||||
virtual void addOnPrevListener(const std::function<void()>& cb) = 0;
|
||||
|
||||
@@ -19,12 +19,15 @@ namespace margelo::nitro::omni { class HybridOmniPlayerSpec; }
|
||||
namespace margelo::nitro::omni { struct Source; }
|
||||
// Forward declaration of `PlayerBackend` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct PlayerBackend; }
|
||||
// Forward declaration of `CastOptions` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct CastOptions; }
|
||||
|
||||
#include <memory>
|
||||
#include "HybridOmniPlayerSpec.hpp"
|
||||
#include "Source.hpp"
|
||||
#include <optional>
|
||||
#include "PlayerBackend.hpp"
|
||||
#include "CastOptions.hpp"
|
||||
|
||||
namespace margelo::nitro::omni {
|
||||
|
||||
@@ -57,7 +60,7 @@ namespace margelo::nitro::omni {
|
||||
|
||||
public:
|
||||
// Methods
|
||||
virtual std::shared_ptr<HybridOmniPlayerSpec> createPlayer(const std::optional<Source>& props, const std::optional<PlayerBackend>& backend) = 0;
|
||||
virtual std::shared_ptr<HybridOmniPlayerSpec> createPlayer(const std::optional<Source>& props, const std::optional<PlayerBackend>& backend, const std::optional<CastOptions>& cast) = 0;
|
||||
|
||||
protected:
|
||||
// Hybrid Setup
|
||||
|
||||
Reference in New Issue
Block a user