/// /// BufferConfig.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() #include #else #error NitroModules cannot be found! Are you sure you installed NitroModules properly? #endif #if __has_include() #include #else #error NitroModules cannot be found! Are you sure you installed NitroModules properly? #endif #if __has_include() #include #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 #include "Resolution.hpp" namespace margelo::nitro::video { /** * A struct which can be represented as a JavaScript object (BufferConfig). */ struct BufferConfig { public: std::optional livePlayback SWIFT_PRIVATE; std::optional minBufferMs SWIFT_PRIVATE; std::optional maxBufferMs SWIFT_PRIVATE; std::optional bufferForPlaybackMs SWIFT_PRIVATE; std::optional bufferForPlaybackAfterRebufferMs SWIFT_PRIVATE; std::optional backBufferDurationMs SWIFT_PRIVATE; std::optional preferredForwardBufferDurationMs SWIFT_PRIVATE; std::optional preferredPeakBitRate SWIFT_PRIVATE; std::optional preferredMaximumResolution SWIFT_PRIVATE; std::optional preferredPeakBitRateForExpensiveNetworks SWIFT_PRIVATE; std::optional preferredMaximumResolutionForExpensiveNetworks SWIFT_PRIVATE; public: BufferConfig() = default; explicit BufferConfig(std::optional livePlayback, std::optional minBufferMs, std::optional maxBufferMs, std::optional bufferForPlaybackMs, std::optional bufferForPlaybackAfterRebufferMs, std::optional backBufferDurationMs, std::optional preferredForwardBufferDurationMs, std::optional preferredPeakBitRate, std::optional preferredMaximumResolution, std::optional preferredPeakBitRateForExpensiveNetworks, std::optional preferredMaximumResolutionForExpensiveNetworks): livePlayback(livePlayback), minBufferMs(minBufferMs), maxBufferMs(maxBufferMs), bufferForPlaybackMs(bufferForPlaybackMs), bufferForPlaybackAfterRebufferMs(bufferForPlaybackAfterRebufferMs), backBufferDurationMs(backBufferDurationMs), preferredForwardBufferDurationMs(preferredForwardBufferDurationMs), preferredPeakBitRate(preferredPeakBitRate), preferredMaximumResolution(preferredMaximumResolution), preferredPeakBitRateForExpensiveNetworks(preferredPeakBitRateForExpensiveNetworks), preferredMaximumResolutionForExpensiveNetworks(preferredMaximumResolutionForExpensiveNetworks) {} }; } // namespace margelo::nitro::video namespace margelo::nitro { // C++ BufferConfig <> JS BufferConfig (object) template <> struct JSIConverter 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>::fromJSI(runtime, obj.getProperty(runtime, "livePlayback")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "minBufferMs")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "maxBufferMs")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "bufferForPlaybackMs")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "bufferForPlaybackAfterRebufferMs")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "backBufferDurationMs")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "preferredForwardBufferDurationMs")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "preferredPeakBitRate")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "preferredMaximumResolution")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "preferredPeakBitRateForExpensiveNetworks")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "preferredMaximumResolutionForExpensiveNetworks")) ); } static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::video::BufferConfig& arg) { jsi::Object obj(runtime); obj.setProperty(runtime, "livePlayback", JSIConverter>::toJSI(runtime, arg.livePlayback)); obj.setProperty(runtime, "minBufferMs", JSIConverter>::toJSI(runtime, arg.minBufferMs)); obj.setProperty(runtime, "maxBufferMs", JSIConverter>::toJSI(runtime, arg.maxBufferMs)); obj.setProperty(runtime, "bufferForPlaybackMs", JSIConverter>::toJSI(runtime, arg.bufferForPlaybackMs)); obj.setProperty(runtime, "bufferForPlaybackAfterRebufferMs", JSIConverter>::toJSI(runtime, arg.bufferForPlaybackAfterRebufferMs)); obj.setProperty(runtime, "backBufferDurationMs", JSIConverter>::toJSI(runtime, arg.backBufferDurationMs)); obj.setProperty(runtime, "preferredForwardBufferDurationMs", JSIConverter>::toJSI(runtime, arg.preferredForwardBufferDurationMs)); obj.setProperty(runtime, "preferredPeakBitRate", JSIConverter>::toJSI(runtime, arg.preferredPeakBitRate)); obj.setProperty(runtime, "preferredMaximumResolution", JSIConverter>::toJSI(runtime, arg.preferredMaximumResolution)); obj.setProperty(runtime, "preferredPeakBitRateForExpensiveNetworks", JSIConverter>::toJSI(runtime, arg.preferredPeakBitRateForExpensiveNetworks)); obj.setProperty(runtime, "preferredMaximumResolutionForExpensiveNetworks", JSIConverter>::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>::canConvert(runtime, obj.getProperty(runtime, "livePlayback"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "minBufferMs"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "maxBufferMs"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "bufferForPlaybackMs"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "bufferForPlaybackAfterRebufferMs"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "backBufferDurationMs"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "preferredForwardBufferDurationMs"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "preferredPeakBitRate"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "preferredMaximumResolution"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "preferredPeakBitRateForExpensiveNetworks"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "preferredMaximumResolutionForExpensiveNetworks"))) return false; return true; } }; } // namespace margelo::nitro