CVB++ 15.0
stream.hpp
1#pragma once
2
3
4#include "rtpstreaming.hpp"
5#include "../global.hpp"
6#include "../image.hpp"
7#include "../utilities/system_info.hpp"
8
9#include "stream_config.hpp"
10
11
12namespace Cvb
13{
14
15 CVB_BEGIN_INLINE_NS
16
17 template <>
18 inline HandleGuard<RTPStreaming::Stream>::HandleGuard(void* handle) noexcept
19 : HandleGuard<RTPStreaming::Stream>(handle, [](void* handle) { CVB_CALL_CAPI(ReleaseObject(handle)); })
20 {
21 }
22
23 namespace RTPStreaming
24 {
31 class Stream final
32 {
33
34 public:
35
37
45 static std::unique_ptr<Stream> Create(const StreamConfig& streamConfig)
46 {
47 return Internal::DoResCallObjectOut<Stream>([&](void*& handle)
48 {
49 return CVB_CALL_CAPI(CVRTPCreateSenderStream(streamConfig.Handle(), handle));
50 });
51 }
52
53 static std::unique_ptr<Stream> FromHandle(HandleGuard<Stream>&& guard)
54 {
55 if (!guard.Handle())
56 throw std::runtime_error("handle must not be null");
57
58 return std::make_unique<Stream>(std::move(guard));
59 }
60
61 explicit Stream(HandleGuard<Stream>&& guard) noexcept
62 : handle_(std::move(guard))
63 {
64
65 }
66
67 Stream(const Stream& other) = delete;
68 Stream& operator=(const Stream& other) = delete;
69 Stream(Stream&& other) = delete;
70 Stream& operator=(Stream&& other) = delete;
71
72 ~Stream() = default;
73
74 void* Handle() const noexcept
75 {
76 return handle_.Handle();
77 }
78
80
89 void PushImage(const Image& image)
90 {
91 CVB_CALL_CAPI_CHECKED(CVRTPStreamPushImage(Handle(),image.Handle()));
92 }
93
94 private:
95
96 HandleGuard<Stream> handle_;
97 };
98
99 }
100
101 CVB_END_INLINE_NS
102}
Represents one acquisition stream of a device.
Definition: decl_stream.hpp:38
The Common Vision Blox image.
Definition: decl_image.hpp:45
void * Handle() const noexcept
Classic API image handle.
Definition: decl_image.hpp:226
A RTP stream to send images.
Definition: stream.hpp:32
void PushImage(const Image &image)
Push an image over the network.
Definition: stream.hpp:89
static std::unique_ptr< Stream > Create(const StreamConfig &streamConfig)
Creates a stream with a given configuration.
Definition: stream.hpp:45
Root namespace for the Image Manager interface.
Definition: c_barcode.h:15