5#include "rtpstreaming.hpp"
6#include "../size_2d.hpp"
7#include "../string.hpp"
8#include "../shims/stdvariant.hpp"
9#include "../utilities/system_info.hpp"
17 inline HandleGuard<RTPStreaming::StreamConfig>::HandleGuard(
void* handle) noexcept
18 : HandleGuard<RTPStreaming::StreamConfig>(handle, [](
void* handle) { CVB_CALL_CAPI(ReleaseObject(handle)); })
28 namespace RTPStreaming
42 return Internal::DoResCallObjectOut<StreamConfig>([&](
void*& handle)
44 return CVB_CALL_CAPI(CVRTPCreateStreamConfig(handle));
53 return std::make_unique<StreamConfig>(std::move(guard));
56 explicit StreamConfig(HandleGuard<StreamConfig>&& guard) noexcept
57 : handle_(std::move(guard))
69 void* Handle() const noexcept
71 return handle_.Handle();
86 void SetDstAddr(
const String& dstAddr);
93 uint16_t DstPort()
const
95 return Property<uint16_t>(CExports::CVRTPSP_DST_PORT);
103 void SetDstPort(uint16_t port)
105 return SetProperty<uint16_t>(port, CExports::CVRTPSP_DST_PORT);
123 void SetURL(
const String& url);
130 void SetupCodecFromJSON(
const String& codecJSON);
137 void SetupCodecWithName(
const String& codecName);
144 String ReadCodecJSON()
const;
151 String ReadSessionDescriptionProtocol()
const;
156 T Property(CExports::CVRTPStreamProperty property)
const
159 size_t size =
sizeof(T);
160 CVB_CALL_CAPI_CHECKED(CVRTPStreamConfigGetProperty(Handle(), property, &value, size));
165 void SetProperty(
const T& value, CExports::CVRTPStreamProperty property)
167 CVB_CALL_CAPI_CHECKED(CVRTPStreamConfigSetProperty(Handle(), property,
const_cast<T*
>(&value),
sizeof(T)));
174 asciiText.reserve(text.size());
175 for (
const auto& c : text)
176 asciiText.push_back(
static_cast<char>(c));
185 HandleGuard<StreamConfig> handle_;
190 inline String StreamConfig::Property<String>(CExports::CVRTPStreamProperty property)
const
194 CVB_CALL_CAPI_CHECKED(CVRTPStreamConfigGetProperty(Handle(), property,
nullptr, size));
197 CVB_CALL_CAPI_CHECKED(CVRTPStreamConfigGetProperty(Handle(), property, buffer.data(), size));
199 return { buffer.begin(), buffer.end() - 1 };
203 inline void StreamConfig::SetProperty<String>(
const String& value, CExports::CVRTPStreamProperty property)
205 CVB_CALL_CAPI_CHECKED(CVRTPStreamConfigSetProperty(Handle(), property,
const_cast<char*
>(ToBytes(value).c_str()), value.size() + 1));
209 String StreamConfig::DstAddr()
const
211 return Property<String>(CExports::CVRTPSP_DST_ADDR);
214 void StreamConfig::SetDstAddr(
const String& dstAddr)
216 SetProperty<String>(dstAddr, CExports::CVRTPSP_DST_ADDR);
219 String StreamConfig::URL()
const
221 return Property<String>(CExports::CVRTPSP_URL);
224 void StreamConfig::SetURL(
const String& url)
226 SetProperty<String>(url, CExports::CVRTPSP_URL);
229 void StreamConfig::SetupCodecFromJSON(
const String& codecJSON)
231 SetProperty<String>(codecJSON, CExports::CVRTPSP_CodecJSON);
234 void StreamConfig::SetupCodecWithName(
const String& codecName)
236 SetProperty<String>(codecName, CExports::CVRTPSP_CodecName);
239 String StreamConfig::ReadCodecJSON()
const
241 return Property<String>(CExports::CVRTPSP_CodecJSON);
244 String StreamConfig::ReadSessionDescriptionProtocol()
const
246 return Property<String>(CExports::CVRTPSP_SDP);
A configuration defining a RTP stream.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
std::string String
String for wide characters or unicode characters.
Definition: string.hpp:56