MillicastSDK 2.6.0
Loading...
Searching...
No Matches
viewer.h
Go to the documentation of this file.
1#ifndef MILLICAST_API_VIEWER_H
2#define MILLICAST_API_VIEWER_H
3
11#ifdef __cplusplus
12
13#include "client.h"
14#include "rts_stats.h"
15#include "track.h"
16
17namespace millicast {
18
19// Forward declarations ///////////////////////////////////////////////////////
20class VideoTrack;
21class AudioTrack;
22
23// Viewer /////////////////////////////////////////////////////////////////////
24
25struct ViewerOption : public ClientOption {
32 struct {
33 std::optional<std::string>
34 pinned_source_id;
36 std::optional<uint8_t>
37 multiplexed_audio_track;
40 std::vector<std::string>
41 excluded_source_id;
43 } multisource;
44
51 struct ForcePlayoutDelay {
52 int min;
53 int max;
54 };
55
59 std::optional<ForcePlayoutDelay> force_playout_delay;
60
64 std::optional<unsigned int> maximum_bitrate;
65
66 bool disable_audio{
67 false};
71 int jitter_minimum_delay_ms =
72 0;
88 bool force_smooth{false};
89
97 std::optional<unsigned int> bwe_monitor_duration_us;
98
103 std::optional<unsigned int> upwards_layer_wait_time_ms;
104
113 std::optional<double> bwe_rate_change_percentage;
114
118 enum class AbrStrategy {
119 DEFAULT,
120 QUALITY,
121 PERFORMANCE,
122 BANDWIDTH,
123 };
124
129 AbrStrategy abr_strategy{AbrStrategy::DEFAULT};
130};
131
137struct ViewerCredentials {
138 bool is_valid;
141 std::string stream_name;
143 std::optional<std::string> token;
144 std::string account_id;
145 std::string
146 api_url;
147};
148
154class MILLICAST_API Viewer : public virtual Client {
155 public:
156 using Option = ViewerOption;
157 using Credentials = ViewerCredentials;
163 struct StreamStopped {
164 std::string description;
165 };
166
176 virtual Promise<void> subscribe(
177 std::optional<ViewerOption>&& options = std::nullopt) = 0;
178
183 virtual Promise<void> unsubscribe() = 0;
184
190 [[nodiscard]] virtual Promise<bool> is_subscribed() const = 0;
191
197 virtual Promise<void> set_credentials(ViewerCredentials&& creds) = 0;
198
203 [[nodiscard]] virtual Promise<ViewerCredentials> get_credentials() const = 0;
204
209 static std::unique_ptr<Viewer> create();
210
214 struct RtsTrackAdded {
215 RtsRemoteTrack& track;
217 };
218
219 struct RtsStatsEvent {
220 const std::shared_ptr<const RtsViewerStats> viewer_stats;
221 };
222
228 virtual EventConnectionPtr add_event_handler(
229 EventHandler<RtsTrackAdded>&& handler) = 0;
230
236 virtual EventConnectionPtr add_event_handler(
237 EventHandler<StreamStopped>&& handler) = 0;
238
247 [[deprecated(
248 "Use the overload with RtsStatsEvent")]] virtual EventConnectionPtr
249 add_event_handler(EventHandler<StatsEvent>&& handler) = 0;
250
259 virtual EventConnectionPtr add_event_handler(
260 EventHandler<RtsStatsEvent>&& handler) = 0;
261
268 virtual EventConnectionPtr add_event_handler(
269 EventHandler<ViewerCount>&& handler) = 0;
270
276 virtual EventConnectionPtr add_event_handler(
277 EventHandler<SignalingError>&& handler) = 0;
278
284 virtual EventConnectionPtr add_event_handler(
285 EventHandler<HttpConnectionError>&& handler) = 0;
286
292 virtual EventConnectionPtr add_event_handler(
293 EventHandler<WebsocketState>&& handler) = 0;
294
301 virtual EventConnectionPtr add_event_handler(
302 EventHandler<PeerConnectionState>&& handler) = 0;
303
311 [[nodiscard]] virtual Promise<std::vector<RtsRemoteAudioTrack*>>
312 audio_tracks() const = 0;
313
321 [[nodiscard]] virtual Promise<std::vector<RtsRemoteVideoTrack*>>
322 video_tracks() const = 0;
323
344 virtual Promise<WebrtcRemoteTrack*> add_webrtc_remote_track(
345 WebrtcRemoteTrack::Kind kind,
346 std::string_view cname) = 0;
347
356 [[nodiscard]] virtual Promise<std::vector<WebrtcRemoteAudioTrack*>>
357 webrtc_audio_tracks() const = 0;
358
367 [[nodiscard]] virtual Promise<std::vector<WebrtcRemoteVideoTrack*>>
368 webrtc_video_tracks() const = 0;
369
432 virtual void enable_seamless_migration(bool enabled = true) = 0;
433};
434
435} // namespace millicast
436
437#endif // __cplusplus
438#endif /* MILLICAST_API_VIEWER_H */
#define MILLICAST_API
Definition exports.h:51