Files
2026-03-25 17:28:35 +01:00

122 lines
7.4 KiB
C++
Generated

///
/// NativeVideoConfig.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 `NativeExternalSubtitle` to properly resolve imports.
namespace margelo::nitro::video { struct NativeExternalSubtitle; }
// Forward declaration of `NativeDrmParams` to properly resolve imports.
namespace margelo::nitro::video { struct NativeDrmParams; }
// Forward declaration of `BufferConfig` to properly resolve imports.
namespace margelo::nitro::video { struct BufferConfig; }
// Forward declaration of `CustomVideoMetadata` to properly resolve imports.
namespace margelo::nitro::video { struct CustomVideoMetadata; }
#include <string>
#include "NativeExternalSubtitle.hpp"
#include <vector>
#include <optional>
#include "NativeDrmParams.hpp"
#include <unordered_map>
#include "BufferConfig.hpp"
#include "CustomVideoMetadata.hpp"
namespace margelo::nitro::video {
/**
* A struct which can be represented as a JavaScript object (NativeVideoConfig).
*/
struct NativeVideoConfig final {
public:
std::string uri SWIFT_PRIVATE;
std::optional<std::vector<NativeExternalSubtitle>> externalSubtitles SWIFT_PRIVATE;
std::optional<NativeDrmParams> drm SWIFT_PRIVATE;
std::optional<std::unordered_map<std::string, std::string>> headers SWIFT_PRIVATE;
std::optional<BufferConfig> bufferConfig SWIFT_PRIVATE;
std::optional<CustomVideoMetadata> metadata SWIFT_PRIVATE;
std::optional<bool> initializeOnCreation SWIFT_PRIVATE;
public:
NativeVideoConfig() = default;
explicit NativeVideoConfig(std::string uri, std::optional<std::vector<NativeExternalSubtitle>> externalSubtitles, std::optional<NativeDrmParams> drm, std::optional<std::unordered_map<std::string, std::string>> headers, std::optional<BufferConfig> bufferConfig, std::optional<CustomVideoMetadata> metadata, std::optional<bool> initializeOnCreation): uri(uri), externalSubtitles(externalSubtitles), drm(drm), headers(headers), bufferConfig(bufferConfig), metadata(metadata), initializeOnCreation(initializeOnCreation) {}
public:
// NativeVideoConfig is not equatable because these properties are not equatable: drm
};
} // namespace margelo::nitro::video
namespace margelo::nitro {
// C++ NativeVideoConfig <> JS NativeVideoConfig (object)
template <>
struct JSIConverter<margelo::nitro::video::NativeVideoConfig> final {
static inline margelo::nitro::video::NativeVideoConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
jsi::Object obj = arg.asObject(runtime);
return margelo::nitro::video::NativeVideoConfig(
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri"))),
JSIConverter<std::optional<std::vector<margelo::nitro::video::NativeExternalSubtitle>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "externalSubtitles"))),
JSIConverter<std::optional<margelo::nitro::video::NativeDrmParams>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "drm"))),
JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headers"))),
JSIConverter<std::optional<margelo::nitro::video::BufferConfig>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bufferConfig"))),
JSIConverter<std::optional<margelo::nitro::video::CustomVideoMetadata>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metadata"))),
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "initializeOnCreation")))
);
}
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::video::NativeVideoConfig& arg) {
jsi::Object obj(runtime);
obj.setProperty(runtime, PropNameIDCache::get(runtime, "uri"), JSIConverter<std::string>::toJSI(runtime, arg.uri));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "externalSubtitles"), JSIConverter<std::optional<std::vector<margelo::nitro::video::NativeExternalSubtitle>>>::toJSI(runtime, arg.externalSubtitles));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "drm"), JSIConverter<std::optional<margelo::nitro::video::NativeDrmParams>>::toJSI(runtime, arg.drm));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "headers"), JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::toJSI(runtime, arg.headers));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "bufferConfig"), JSIConverter<std::optional<margelo::nitro::video::BufferConfig>>::toJSI(runtime, arg.bufferConfig));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "metadata"), JSIConverter<std::optional<margelo::nitro::video::CustomVideoMetadata>>::toJSI(runtime, arg.metadata));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "initializeOnCreation"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.initializeOnCreation));
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::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri")))) return false;
if (!JSIConverter<std::optional<std::vector<margelo::nitro::video::NativeExternalSubtitle>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "externalSubtitles")))) return false;
if (!JSIConverter<std::optional<margelo::nitro::video::NativeDrmParams>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "drm")))) return false;
if (!JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headers")))) return false;
if (!JSIConverter<std::optional<margelo::nitro::video::BufferConfig>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bufferConfig")))) return false;
if (!JSIConverter<std::optional<margelo::nitro::video::CustomVideoMetadata>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metadata")))) return false;
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "initializeOnCreation")))) return false;
return true;
}
};
} // namespace margelo::nitro