Flyby SDK v0.3.0
Loading...
Searching...
No Matches
stream.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <functional>
11#include <memory>
12
15
16namespace flyby {
17
23 class StreamInterface : public Component {
24 public:
25 friend class ComponentHandler;
26
27 virtual void register_camera(std::shared_ptr<CameraInterface> camera) = 0;
28
29 virtual void start_stream(unsigned int endpoint_idx, std::function<void(std::string)> set_alive_callback) = 0;
30
31 [[nodiscard]] virtual unsigned int get_active_camera_idx() = 0;
32
33 virtual void set_active_camera(unsigned int camera_idx) = 0;
34
35 [[nodiscard]] virtual unsigned int get_endpoint_idx() const = 0;
36
37 [[nodiscard]] virtual const std::vector<std::shared_ptr<const CameraInterface>>& get_cameras_const() const = 0;
38
39 protected:
41
42 private:
43 virtual void set_endpoint_idx(unsigned int endpoint_idx) = 0;
44 virtual void set_active_camera_idx(unsigned int camera_idx) = 0;
45 virtual std::shared_ptr<CameraInterface> get_active_camera() = 0;
46 virtual std::vector<std::shared_ptr<CameraInterface>>& get_cameras() = 0;
47 };
48
55 class Stream : public StreamInterface {
56 public:
60 explicit Stream(const std::string& name);
61
68 Stream(std::string name, unsigned int endpoint_idx, std::string uuid);
69
70 ~Stream() override;
71
75 void register_camera(std::shared_ptr<CameraInterface> camera) final;
76
86 void start_stream(unsigned int endpoint_idx, std::function<void(std::string)> set_alive_callback) override;
87
93 void set_active_camera(unsigned int camera_idx) override;
94
100 [[nodiscard]] unsigned int get_endpoint_idx() const final;
101
107 [[nodiscard]] const std::vector<std::shared_ptr<const CameraInterface>>& get_cameras_const() const final;
108
109 private:
110 void set_endpoint_idx(unsigned int endpoint_idx) final;
111 std::shared_ptr<CameraInterface> get_active_camera() final;
112 unsigned int get_active_camera_idx() final;
113 void set_active_camera_idx(unsigned int camera_idx) final;
114 std::vector<std::shared_ptr<CameraInterface>>& get_cameras() final;
115
116 unsigned int m_endpoint_idx;
117 unsigned int m_active_camera_idx;
118 std::vector<std::shared_ptr<CameraInterface>> m_cameras;
119 };
120
121}
Component()=default
The default constructor.
The base stream class.
Definition stream.h:55
unsigned int get_endpoint_idx() const final
Get the stream endpoint index.
void register_camera(std::shared_ptr< CameraInterface > camera) final
Register a camera that can publish through this stream.
const std::vector< std::shared_ptr< const CameraInterface > > & get_cameras_const() const final
Get the stream cameras.
void start_stream(unsigned int endpoint_idx, std::function< void(std::string)> set_alive_callback) override
Register a camera that can publish through this stream.
Stream(std::string name, unsigned int endpoint_idx, std::string uuid)
Internal stream constructor.
void set_active_camera(unsigned int camera_idx) override
Set the active camera.
Stream(const std::string &name)
Creates a new named stream.