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
41 return Internal::DoResCallObjectOut<StreamConfig>(
42 [&](
void *&handle) {
return CVB_CALL_CAPI(CVRTPCreateStreamConfig(handle)); });
50 return std::make_unique<StreamConfig>(
std::move(guard));
53 explicit StreamConfig(HandleGuard<StreamConfig> &&guard) noexcept
65 void *Handle()
const noexcept
67 return handle_.Handle();
82 void SetDstAddr(
const String &dstAddr);
89 uint16_t DstPort()
const
91 return Property<uint16_t>(CExports::CVRTPSP_DST_PORT);
99 void SetDstPort(uint16_t port)
101 return SetProperty<uint16_t>(port, CExports::CVRTPSP_DST_PORT);
119 void SetURL(
const String &url);
126 void SetupCodecFromJSON(
const String &codecJSON);
133 void SetupCodecWithName(
const String &codecName);
140 String ReadCodecJSON()
const;
147 String ReadSessionDescriptionProtocol()
const;
151 T Property(CExports::CVRTPStreamProperty property)
const
154 size_t size =
sizeof(T);
155 CVB_CALL_CAPI_CHECKED(CVRTPStreamConfigGetProperty(Handle(), property, &value, size));
160 void SetProperty(
const T &value, CExports::CVRTPStreamProperty property)
162 CVB_CALL_CAPI_CHECKED(CVRTPStreamConfigSetProperty(
163 Handle(), property,
const_cast<T *
>(&value),
sizeof(T)));
170 asciiText.reserve(text.size());
171 for (
const auto &c : text)
172 asciiText.push_back(
static_cast<char>(c));
181 HandleGuard<StreamConfig> handle_;
185 inline String StreamConfig::Property<String>(CExports::CVRTPStreamProperty property)
const
189 CVB_CALL_CAPI_CHECKED(CVRTPStreamConfigGetProperty(Handle(), property,
nullptr, size));
192 CVB_CALL_CAPI_CHECKED(CVRTPStreamConfigGetProperty(Handle(), property, buffer.data(), size));
194 return {buffer.begin(), buffer.end() - 1};
198 inline void StreamConfig::SetProperty<String>(
const String &value, CExports::CVRTPStreamProperty property)
200 CVB_CALL_CAPI_CHECKED(
201 CVRTPStreamConfigSetProperty(Handle(), property,
const_cast<char *
>(ToBytes(value).c_str()),
205 String StreamConfig::DstAddr()
const
207 return Property<String>(CExports::CVRTPSP_DST_ADDR);
210 void StreamConfig::SetDstAddr(
const String &dstAddr)
212 SetProperty<String>(dstAddr, CExports::CVRTPSP_DST_ADDR);
215 String StreamConfig::URL()
const
217 return Property<String>(CExports::CVRTPSP_URL);
220 void StreamConfig::SetURL(
const String &url)
222 SetProperty<String>(url, CExports::CVRTPSP_URL);
225 void StreamConfig::SetupCodecFromJSON(
const String &codecJSON)
227 SetProperty<String>(codecJSON, CExports::CVRTPSP_CodecJSON);
230 void StreamConfig::SetupCodecWithName(
const String &codecName)
232 SetProperty<String>(codecName, CExports::CVRTPSP_CodecName);
235 String StreamConfig::ReadCodecJSON()
const
237 return Property<String>(CExports::CVRTPSP_CodecJSON);
240 String StreamConfig::ReadSessionDescriptionProtocol()
const
242 return Property<String>(CExports::CVRTPSP_SDP);
A configuration defining a RTP stream.
cvbbool_t ReleaseObject(OBJ &Object)
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49