MillicastSDK 2.5.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};
115
121struct ViewerCredentials {
122 bool is_valid;
125 std::string stream_name;
127 std::optional<std::string> token;
128 std::string account_id;
129 std::string
130 api_url;
131};
132
138class MILLICAST_API Viewer : public virtual Client {
139 public:
140 using Option = ViewerOption;
141 using Credentials = ViewerCredentials;
147 struct StreamStopped {
148 std::string description;
149 };
150
160 virtual Promise<void> subscribe(
161 std::optional<ViewerOption>&& options = std::nullopt) = 0;
162
167 virtual Promise<void> unsubscribe() = 0;
168
174 [[nodiscard]] virtual Promise<bool> is_subscribed() const = 0;
175
181 virtual Promise<void> set_credentials(ViewerCredentials&& creds) = 0;
182
187 [[nodiscard]] virtual Promise<ViewerCredentials> get_credentials() const = 0;
188
193 static std::unique_ptr<Viewer> create();
194
198 struct RtsTrackAdded {
199 RtsRemoteTrack& track;
201 };
202
203 struct RtsStatsEvent {
204 const std::shared_ptr<const RtsViewerStats> viewer_stats;
205 };
206
212 virtual EventConnectionPtr add_event_handler(
213 EventHandler<RtsTrackAdded>&& handler) = 0;
214
220 virtual EventConnectionPtr add_event_handler(
221 EventHandler<StreamStopped>&& handler) = 0;
222
231 [[deprecated(
232 "Use the overload with RtsStatsEvent")]] virtual EventConnectionPtr
233 add_event_handler(EventHandler<StatsEvent>&& handler) = 0;
234
243 virtual EventConnectionPtr add_event_handler(
244 EventHandler<RtsStatsEvent>&& handler) = 0;
245
252 virtual EventConnectionPtr add_event_handler(
253 EventHandler<ViewerCount>&& handler) = 0;
254
260 virtual EventConnectionPtr add_event_handler(
261 EventHandler<SignalingError>&& handler) = 0;
262
268 virtual EventConnectionPtr add_event_handler(
269 EventHandler<HttpConnectionError>&& handler) = 0;
270
276 virtual EventConnectionPtr add_event_handler(
277 EventHandler<WebsocketState>&& handler) = 0;
278
285 virtual EventConnectionPtr add_event_handler(
286 EventHandler<PeerConnectionState>&& handler) = 0;
287
295 [[nodiscard]] virtual Promise<std::vector<RtsRemoteAudioTrack*>>
296 audio_tracks() const = 0;
297
305 [[nodiscard]] virtual Promise<std::vector<RtsRemoteVideoTrack*>>
306 video_tracks() const = 0;
307
328 virtual Promise<WebrtcRemoteTrack*> add_webrtc_remote_track(
329 WebrtcRemoteTrack::Kind kind,
330 std::string_view cname) = 0;
331
340 [[nodiscard]] virtual Promise<std::vector<WebrtcRemoteAudioTrack*>>
341 webrtc_audio_tracks() const = 0;
342
351 [[nodiscard]] virtual Promise<std::vector<WebrtcRemoteVideoTrack*>>
352 webrtc_video_tracks() const = 0;
353
416 virtual void enable_seamless_migration(bool enabled = true) = 0;
417};
418
419} // namespace millicast
420
421#endif // __cplusplus
422#endif /* MILLICAST_API_VIEWER_H */
#define MILLICAST_API
Definition exports.h:51