MillicastSDK 2.7.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
10
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};
70
71 int jitter_minimum_delay_ms =
72 0;
76
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
138 std::optional<std::vector<std::string>> events;
139};
140
146struct ViewerCredentials {
147 bool is_valid;
149
150 std::string stream_name;
152 std::optional<std::string> token;
153 std::string account_id;
154 std::string
155 api_url;
156};
157
163class MILLICAST_API Viewer : public virtual Client {
164 public:
165 using Option = ViewerOption;
166 using Credentials = ViewerCredentials;
172 struct StreamStopped {
173 std::string description;
174 };
175
185 virtual Promise<void> subscribe(
186 std::optional<ViewerOption>&& options = std::nullopt) = 0;
187
192 virtual Promise<void> unsubscribe() = 0;
193
199 [[nodiscard]] virtual Promise<bool> is_subscribed() const = 0;
200
206 virtual Promise<void> set_credentials(ViewerCredentials&& creds) = 0;
207
212 [[nodiscard]] virtual Promise<ViewerCredentials> get_credentials() const = 0;
213
218 static std::unique_ptr<Viewer> create();
219
223 struct RtsTrackAdded {
224 RtsRemoteTrack& track;
226 };
227
228 struct RtsStatsEvent {
229 const std::shared_ptr<const RtsViewerStats> viewer_stats;
230 };
231
237 virtual EventConnectionPtr add_event_handler(
238 EventHandler<RtsTrackAdded>&& handler) = 0;
239
245 virtual EventConnectionPtr add_event_handler(
246 EventHandler<StreamStopped>&& handler) = 0;
247
256 [[deprecated(
257 "Use the overload with RtsStatsEvent")]] virtual EventConnectionPtr
258 add_event_handler(EventHandler<StatsEvent>&& handler) = 0;
259
268 virtual EventConnectionPtr add_event_handler(
269 EventHandler<RtsStatsEvent>&& handler) = 0;
270
277 virtual EventConnectionPtr add_event_handler(
278 EventHandler<ViewerCount>&& handler) = 0;
279
285 virtual EventConnectionPtr add_event_handler(
286 EventHandler<SignalingError>&& handler) = 0;
287
293 virtual EventConnectionPtr add_event_handler(
294 EventHandler<HttpConnectionError>&& handler) = 0;
295
301 virtual EventConnectionPtr add_event_handler(
302 EventHandler<WebsocketState>&& handler) = 0;
303
310 virtual EventConnectionPtr add_event_handler(
311 EventHandler<PeerConnectionState>&& handler) = 0;
312
320 [[nodiscard]] virtual Promise<std::vector<RtsRemoteAudioTrack*>>
321 audio_tracks() const = 0;
322
330 [[nodiscard]] virtual Promise<std::vector<RtsRemoteVideoTrack*>>
331 video_tracks() const = 0;
332
353 virtual Promise<WebrtcRemoteTrack*> add_webrtc_remote_track(
354 WebrtcRemoteTrack::Kind kind,
355 std::string_view cname) = 0;
356
365 [[nodiscard]] virtual Promise<std::vector<WebrtcRemoteAudioTrack*>>
366 webrtc_audio_tracks() const = 0;
367
376 [[nodiscard]] virtual Promise<std::vector<WebrtcRemoteVideoTrack*>>
377 webrtc_video_tracks() const = 0;
378
441 virtual void enable_seamless_migration(bool enabled = true) = 0;
442};
443
444} // namespace millicast
445
446#endif // __cplusplus
447#endif /* MILLICAST_API_VIEWER_H */
#define MILLICAST_API
Definition exports.h:51