3#include "../_cexports/c_webstreaming.h"
4#include "webstreaming.hpp"
5#include "converter.hpp"
6#include "../string.hpp"
7#include "../global.hpp"
16 inline HandleGuard<WebStreaming::Server>::HandleGuard(
void *handle) noexcept
17 : HandleGuard<WebStreaming::Server>(handle, [](
void *handle) { CVB_CALL_CAPI(
ReleaseObject(handle)); })
33 using GuardType = HandleGuard<Server>;
53 return Internal::DoResCallShareOut<Server>(
55 return CVB_CALL_CAPI(CVWSCreateServerTyped(ipAddress.c_str(),
static_cast<CExports::cvbval_t
>(port),
56 converter->Handle(), handle));
58 ipAddress, port, converter);
72 CExports::CVWSCONVERTER converter =
nullptr;
73 CVB_CALL_CAPI_CHECKED(CVWSCreateConverter(CExports::CVWSCT_Raw, converter));
74 HandleGuard<Converter> converterGuard(converter);
75 return Internal::DoResCallShareOut<Server>(
77 return CVB_CALL_CAPI(CVWSCreateServerTyped(ipAddress.c_str(),
static_cast<CExports::cvbval_t
>(port),
78 converterGuard.Handle(), handle));
84 static ServerPtr FromHandle(HandleGuard<Server> &&guard,
const String &ipAddress,
int port,
93 Server(HandleGuard<Server> &&guard,
const String &ipAddress,
int port,
const ConverterPtr &converter,
95 : handle_(std::move(guard))
96 , ipAddress_(ipAddress)
98 , converter_(converter)
109 CExports::cvbint64_t value = -1;
110 CVB_CALL_CAPI_CHECKED(CVWSServerGetPropertyAsInteger(
Handle(), CExports::CVWSSP_ActiveConnections, value));
111 return static_cast<int>(value);
124 CVB_CALL_CAPI_CHECKED(CVWSStreamingSyncSendImage(
Handle(), image.
Handle()));
137 CVB_CALL_CAPI_CHECKED(CVWSStreamingAsyncSendImage(
Handle(), image.
Handle()));
147 return handle_.Handle();
173 HandleGuard<Server> handle_;
The Common Vision Blox image.
Definition decl_image.hpp:45
void * Handle() const noexcept
Classic API image handle.
Definition decl_image.hpp:232
void SendAsync(const Image &image)
Sends an image asynchronously.
Definition server.hpp:135
static ServerPtr Create(const String &ipAddress, int port, const ConverterPtr &converter)
Creates a WebSocket server with given converter.
Definition server.hpp:51
String IPAddress() const noexcept
Get the IP address of the server.
Definition server.hpp:156
int ActiveConnections() const
Get the number of active connections.
Definition server.hpp:107
static ServerPtr Create(const String &ipAddress, int port)
Creates a WebSocket server.
Definition server.hpp:70
int Port() const noexcept
Get destination port.
Definition server.hpp:167
void SendSync(const Image &image)
Sends an image synchronously.
Definition server.hpp:122
void * Handle() const noexcept
Returns C-API style handle to Server Object.
Definition server.hpp:145
cvbbool_t ReleaseObject(OBJ &Object)
Namespace for streaming images via web sockets.
Definition converter.hpp:20
std::shared_ptr< Server > ServerPtr
Convenience shared pointer for Server.
Definition webstreaming.hpp:34
std::shared_ptr< Converter > ConverterPtr
Convenience shared pointer for Converter.
Definition webstreaming.hpp:22
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