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

129 lines
9.9 KiB
C++
Generated

///
/// BufferConfig.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 `LivePlaybackParams` to properly resolve imports.
namespace margelo::nitro::video { struct LivePlaybackParams; }
// Forward declaration of `Resolution` to properly resolve imports.
namespace margelo::nitro::video { struct Resolution; }
#include "LivePlaybackParams.hpp"
#include <optional>
#include "Resolution.hpp"
namespace margelo::nitro::video {
/**
* A struct which can be represented as a JavaScript object (BufferConfig).
*/
struct BufferConfig final {
public:
std::optional<LivePlaybackParams> livePlayback SWIFT_PRIVATE;
std::optional<double> minBufferMs SWIFT_PRIVATE;
std::optional<double> maxBufferMs SWIFT_PRIVATE;
std::optional<double> bufferForPlaybackMs SWIFT_PRIVATE;
std::optional<double> bufferForPlaybackAfterRebufferMs SWIFT_PRIVATE;
std::optional<double> backBufferDurationMs SWIFT_PRIVATE;
std::optional<double> preferredForwardBufferDurationMs SWIFT_PRIVATE;
std::optional<double> preferredPeakBitRate SWIFT_PRIVATE;
std::optional<Resolution> preferredMaximumResolution SWIFT_PRIVATE;
std::optional<double> preferredPeakBitRateForExpensiveNetworks SWIFT_PRIVATE;
std::optional<Resolution> preferredMaximumResolutionForExpensiveNetworks SWIFT_PRIVATE;
public:
BufferConfig() = default;
explicit BufferConfig(std::optional<LivePlaybackParams> livePlayback, std::optional<double> minBufferMs, std::optional<double> maxBufferMs, std::optional<double> bufferForPlaybackMs, std::optional<double> bufferForPlaybackAfterRebufferMs, std::optional<double> backBufferDurationMs, std::optional<double> preferredForwardBufferDurationMs, std::optional<double> preferredPeakBitRate, std::optional<Resolution> preferredMaximumResolution, std::optional<double> preferredPeakBitRateForExpensiveNetworks, std::optional<Resolution> preferredMaximumResolutionForExpensiveNetworks): livePlayback(livePlayback), minBufferMs(minBufferMs), maxBufferMs(maxBufferMs), bufferForPlaybackMs(bufferForPlaybackMs), bufferForPlaybackAfterRebufferMs(bufferForPlaybackAfterRebufferMs), backBufferDurationMs(backBufferDurationMs), preferredForwardBufferDurationMs(preferredForwardBufferDurationMs), preferredPeakBitRate(preferredPeakBitRate), preferredMaximumResolution(preferredMaximumResolution), preferredPeakBitRateForExpensiveNetworks(preferredPeakBitRateForExpensiveNetworks), preferredMaximumResolutionForExpensiveNetworks(preferredMaximumResolutionForExpensiveNetworks) {}
public:
friend bool operator==(const BufferConfig& lhs, const BufferConfig& rhs) = default;
};
} // namespace margelo::nitro::video
namespace margelo::nitro {
// C++ BufferConfig <> JS BufferConfig (object)
template <>
struct JSIConverter<margelo::nitro::video::BufferConfig> final {
static inline margelo::nitro::video::BufferConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
jsi::Object obj = arg.asObject(runtime);
return margelo::nitro::video::BufferConfig(
JSIConverter<std::optional<margelo::nitro::video::LivePlaybackParams>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "livePlayback"))),
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "minBufferMs"))),
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxBufferMs"))),
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bufferForPlaybackMs"))),
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bufferForPlaybackAfterRebufferMs"))),
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "backBufferDurationMs"))),
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preferredForwardBufferDurationMs"))),
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preferredPeakBitRate"))),
JSIConverter<std::optional<margelo::nitro::video::Resolution>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preferredMaximumResolution"))),
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preferredPeakBitRateForExpensiveNetworks"))),
JSIConverter<std::optional<margelo::nitro::video::Resolution>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preferredMaximumResolutionForExpensiveNetworks")))
);
}
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::video::BufferConfig& arg) {
jsi::Object obj(runtime);
obj.setProperty(runtime, PropNameIDCache::get(runtime, "livePlayback"), JSIConverter<std::optional<margelo::nitro::video::LivePlaybackParams>>::toJSI(runtime, arg.livePlayback));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "minBufferMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.minBufferMs));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "maxBufferMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.maxBufferMs));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "bufferForPlaybackMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.bufferForPlaybackMs));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "bufferForPlaybackAfterRebufferMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.bufferForPlaybackAfterRebufferMs));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "backBufferDurationMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.backBufferDurationMs));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "preferredForwardBufferDurationMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.preferredForwardBufferDurationMs));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "preferredPeakBitRate"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.preferredPeakBitRate));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "preferredMaximumResolution"), JSIConverter<std::optional<margelo::nitro::video::Resolution>>::toJSI(runtime, arg.preferredMaximumResolution));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "preferredPeakBitRateForExpensiveNetworks"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.preferredPeakBitRateForExpensiveNetworks));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "preferredMaximumResolutionForExpensiveNetworks"), JSIConverter<std::optional<margelo::nitro::video::Resolution>>::toJSI(runtime, arg.preferredMaximumResolutionForExpensiveNetworks));
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<margelo::nitro::video::LivePlaybackParams>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "livePlayback")))) return false;
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "minBufferMs")))) return false;
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxBufferMs")))) return false;
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bufferForPlaybackMs")))) return false;
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bufferForPlaybackAfterRebufferMs")))) return false;
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "backBufferDurationMs")))) return false;
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preferredForwardBufferDurationMs")))) return false;
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preferredPeakBitRate")))) return false;
if (!JSIConverter<std::optional<margelo::nitro::video::Resolution>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preferredMaximumResolution")))) return false;
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preferredPeakBitRateForExpensiveNetworks")))) return false;
if (!JSIConverter<std::optional<margelo::nitro::video::Resolution>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preferredMaximumResolutionForExpensiveNetworks")))) return false;
return true;
}
};
} // namespace margelo::nitro