mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-16 02:44:51 +00:00
feat(android): allow both exoplayer and vlc
This commit is contained in:
+58
@@ -0,0 +1,58 @@
|
||||
///
|
||||
/// JAndroidBackend.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 "AndroidBackend.hpp"
|
||||
|
||||
namespace margelo::nitro::omni {
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
/**
|
||||
* The C++ JNI bridge between the C++ enum "AndroidBackend" and the Kotlin enum "AndroidBackend".
|
||||
*/
|
||||
struct JAndroidBackend final: public jni::JavaClass<JAndroidBackend> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/AndroidBackend;";
|
||||
|
||||
public:
|
||||
/**
|
||||
* Convert this Java/Kotlin-based enum to the C++ enum AndroidBackend.
|
||||
*/
|
||||
[[maybe_unused]]
|
||||
[[nodiscard]]
|
||||
AndroidBackend toCpp() const {
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto fieldOrdinal = clazz->getField<int>("value");
|
||||
int ordinal = this->getFieldValue(fieldOrdinal);
|
||||
return static_cast<AndroidBackend>(ordinal);
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
||||
*/
|
||||
[[maybe_unused]]
|
||||
static jni::alias_ref<JAndroidBackend> fromCpp(AndroidBackend value) {
|
||||
static const auto clazz = javaClassStatic();
|
||||
switch (value) {
|
||||
case AndroidBackend::VLC:
|
||||
static const auto fieldVLC = clazz->getStaticField<JAndroidBackend>("VLC");
|
||||
return clazz->getStaticFieldValue(fieldVLC);
|
||||
case AndroidBackend::EXOPLAYER:
|
||||
static const auto fieldEXOPLAYER = clazz->getStaticField<JAndroidBackend>("EXOPLAYER");
|
||||
return clazz->getStaticFieldValue(fieldEXOPLAYER);
|
||||
default:
|
||||
std::string stringValue = std::to_string(static_cast<int>(value));
|
||||
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro::omni
|
||||
Reference in New Issue
Block a user