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