mirror of
https://github.com/zoriya/react-native-video.git
synced 2026-05-22 23:01:06 +00:00
106 lines
6.2 KiB
C++
Generated
106 lines
6.2 KiB
C++
Generated
///
|
|
/// NativeDrmParams.hpp
|
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
/// https://github.com/mrousavy/nitro
|
|
/// Copyright © 2025 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
|
|
|
|
// Forward declaration of `OnGetLicensePayload` to properly resolve imports.
|
|
namespace margelo::nitro::video { struct OnGetLicensePayload; }
|
|
|
|
#include <string>
|
|
#include <optional>
|
|
#include <unordered_map>
|
|
#include <NitroModules/Promise.hpp>
|
|
#include "OnGetLicensePayload.hpp"
|
|
#include <functional>
|
|
|
|
namespace margelo::nitro::video {
|
|
|
|
/**
|
|
* A struct which can be represented as a JavaScript object (NativeDrmParams).
|
|
*/
|
|
struct NativeDrmParams {
|
|
public:
|
|
std::optional<std::string> type SWIFT_PRIVATE;
|
|
std::optional<std::string> licenseUrl SWIFT_PRIVATE;
|
|
std::optional<std::string> certificateUrl SWIFT_PRIVATE;
|
|
std::optional<std::string> contentId SWIFT_PRIVATE;
|
|
std::optional<std::unordered_map<std::string, std::string>> licenseHeaders SWIFT_PRIVATE;
|
|
std::optional<bool> multiSession SWIFT_PRIVATE;
|
|
std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>> getLicense SWIFT_PRIVATE;
|
|
|
|
public:
|
|
NativeDrmParams() = default;
|
|
explicit NativeDrmParams(std::optional<std::string> type, std::optional<std::string> licenseUrl, std::optional<std::string> certificateUrl, std::optional<std::string> contentId, std::optional<std::unordered_map<std::string, std::string>> licenseHeaders, std::optional<bool> multiSession, std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>> getLicense): type(type), licenseUrl(licenseUrl), certificateUrl(certificateUrl), contentId(contentId), licenseHeaders(licenseHeaders), multiSession(multiSession), getLicense(getLicense) {}
|
|
};
|
|
|
|
} // namespace margelo::nitro::video
|
|
|
|
namespace margelo::nitro {
|
|
|
|
// C++ NativeDrmParams <> JS NativeDrmParams (object)
|
|
template <>
|
|
struct JSIConverter<margelo::nitro::video::NativeDrmParams> final {
|
|
static inline margelo::nitro::video::NativeDrmParams fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
jsi::Object obj = arg.asObject(runtime);
|
|
return margelo::nitro::video::NativeDrmParams(
|
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "type")),
|
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "licenseUrl")),
|
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "certificateUrl")),
|
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "contentId")),
|
|
JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, "licenseHeaders")),
|
|
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "multiSession")),
|
|
JSIConverter<std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const margelo::nitro::video::OnGetLicensePayload&)>>>::fromJSI(runtime, obj.getProperty(runtime, "getLicense"))
|
|
);
|
|
}
|
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::video::NativeDrmParams& arg) {
|
|
jsi::Object obj(runtime);
|
|
obj.setProperty(runtime, "type", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.type));
|
|
obj.setProperty(runtime, "licenseUrl", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.licenseUrl));
|
|
obj.setProperty(runtime, "certificateUrl", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.certificateUrl));
|
|
obj.setProperty(runtime, "contentId", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.contentId));
|
|
obj.setProperty(runtime, "licenseHeaders", JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::toJSI(runtime, arg.licenseHeaders));
|
|
obj.setProperty(runtime, "multiSession", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.multiSession));
|
|
obj.setProperty(runtime, "getLicense", JSIConverter<std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const margelo::nitro::video::OnGetLicensePayload&)>>>::toJSI(runtime, arg.getLicense));
|
|
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, "type"))) return false;
|
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "licenseUrl"))) return false;
|
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "certificateUrl"))) return false;
|
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "contentId"))) return false;
|
|
if (!JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::canConvert(runtime, obj.getProperty(runtime, "licenseHeaders"))) return false;
|
|
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "multiSession"))) return false;
|
|
if (!JSIConverter<std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const margelo::nitro::video::OnGetLicensePayload&)>>>::canConvert(runtime, obj.getProperty(runtime, "getLicense"))) return false;
|
|
return true;
|
|
}
|
|
};
|
|
|
|
} // namespace margelo::nitro
|