MillicastSDK 2.2.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
13#include "millicast-sdk/track.h"
14
15namespace millicast {
16
17// Forward declarations ///////////////////////////////////////////////////////
18class VideoTrack;
19class AudioTrack;
20
21// Viewer /////////////////////////////////////////////////////////////////////
22
23struct ViewerOption : public ClientOption {
30 struct {
31 std::optional<std::string>
34 std::optional<uint8_t>
38 std::vector<std::string>
42
50 int min;
51 int max;
52 };
53
57 std::optional<ForcePlayoutDelay> force_playout_delay;
58
62 std::optional<unsigned int> maximum_bitrate;
63
65 false};
70 0;
86 bool force_smooth{false};
87
95 std::optional<unsigned int> bwe_monitor_duration_us;
96
101 std::optional<unsigned int> upwards_layer_wait_time_ms;
102
111 std::optional<double> bwe_rate_change_percentage;
112};
113
120 bool is_valid;
123 std::string stream_name;
125 std::optional<std::string> token;
126 std::string account_id;
127 std::string
129};
130
136class MILLICAST_API Viewer : public virtual Client {
137 public:
146 std::string description;
147 };
148
159 std::optional<ViewerOption>&& options = std::nullopt) = 0;
160
166
172 [[nodiscard]] virtual Promise<bool> is_subscribed() const = 0;
173
180
185 [[nodiscard]] virtual Promise<ViewerCredentials> get_credentials() const = 0;
186
191 static std::unique_ptr<Viewer> create();
192
200
202 const std::shared_ptr<const RtsViewerStats> viewer_stats;
203 };
204
211 EventHandler<RtsTrackAdded>&& handler) = 0;
212
219 EventHandler<StreamStopped>&& handler) = 0;
220
229 [[deprecated(
230 "Use the overload with RtsStatsEvent")]] virtual EventConnectionPtr
232
242 EventHandler<RtsStatsEvent>&& handler) = 0;
243
251 EventHandler<ViewerCount>&& handler) = 0;
252
259 EventHandler<SignalingError>&& handler) = 0;
260
268
275 EventHandler<WebsocketState>&& handler) = 0;
276
285
293 [[nodiscard]] virtual Promise<std::vector<RtsRemoteAudioTrack*>>
294 audio_tracks() const = 0;
295
303 [[nodiscard]] virtual Promise<std::vector<RtsRemoteVideoTrack*>>
304 video_tracks() const = 0;
305
328 std::string_view cname) = 0;
329
340
351
414 virtual void enable_seamless_migration(bool enabled = true) = 0;
415};
416
417} // namespace millicast
418
419#endif /* MILLICAST_API_VIEWER_H */
The Client base class.
Definition client.h:142
Definition promise.h:45
Definition track.h:299
The Viewer class. Its purpose is to receive media by subscribing to a millicast stream....
Definition viewer.h:136
virtual Promise< std::vector< WebrtcRemoteAudioTrack * > > webrtc_audio_tracks() const =0
virtual EventConnectionPtr add_event_handler(EventHandler< RtsTrackAdded > &&handler)=0
Attach the event handler for discovery of new RTS tracks.
virtual Promise< WebrtcRemoteTrack * > add_webrtc_remote_track(WebrtcRemoteTrack::Kind kind, std::string_view cname)=0
virtual EventConnectionPtr add_event_handler(EventHandler< WebsocketState > &&handler)=0
Attach the event handler for the WebsocketState change event.
virtual void enable_seamless_migration(bool enabled=true)=0
virtual EventConnectionPtr add_event_handler(EventHandler< PeerConnectionState > &&handler)=0
Attach the event handler for the PeerConnectionState change event.
virtual Promise< bool > is_subscribed() const =0
Tell if the viewer is subscribed.
virtual Promise< std::vector< WebrtcRemoteVideoTrack * > > webrtc_video_tracks() const =0
virtual EventConnectionPtr add_event_handler(EventHandler< ViewerCount > &&handler)=0
Attach the event handler for the ViewerCount event emitted when the viewer count has changed.
virtual Promise< ViewerCredentials > get_credentials() const =0
Get the current viewer credentials.
virtual EventConnectionPtr add_event_handler(EventHandler< RtsStatsEvent > &&handler)=0
Attach the event handler for the RTS stats event containing the collated information about the curren...
virtual Promise< std::vector< RtsRemoteVideoTrack * > > video_tracks() const =0
virtual Promise< std::vector< RtsRemoteAudioTrack * > > audio_tracks() const =0
virtual Promise< void > unsubscribe()=0
Stop receiving media from Millicast.
virtual EventConnectionPtr add_event_handler(EventHandler< StreamStopped > &&handler)=0
Attach the event handler for the StreamStopped event.
virtual EventConnectionPtr add_event_handler(EventHandler< HttpConnectionError > &&handler)=0
Attach the event handler for the HttpConnectionError event.
static std::unique_ptr< Viewer > create()
Create a new viewer.
virtual Promise< void > subscribe(std::optional< ViewerOption > &&options=std::nullopt)=0
Subscribe to a Millicast stream. You must be connected first in order to subscribe to a stream.
virtual Promise< void > set_credentials(ViewerCredentials &&creds)=0
Set the viewer credentials.
virtual EventConnectionPtr add_event_handler(EventHandler< SignalingError > &&handler)=0
Attach the event handler for the SignalingError event.
virtual EventConnectionPtr add_event_handler(EventHandler< StatsEvent > &&handler)=0
Attach the event handler for the StatsEvent containing the StatsReport..
Kind
Definition track.h:184
#define MILLICAST_API
Definition exports.h:51
Definition capabilities.h:15
std::function< void(const EventTypes &...)> EventHandler
Definition event_handling.h:10
std::unique_ptr< EventConnection > EventConnectionPtr
Definition event_handling.h:31
The ClientOption struct allows to setup the millicast connection.
Definition client.h:84
Definition viewer.h:201
const std::shared_ptr< const RtsViewerStats > viewer_stats
Definition viewer.h:202
Definition viewer.h:196
RtsRemoteTrack & track
Definition viewer.h:197
The Stream Stopped event is emitted when the viewer has requested to disconnect from the media server...
Definition viewer.h:145
std::string description
Definition viewer.h:146
The ViewerCredentials struct represent the credentials need to be able to connect and subscribe to a ...
Definition viewer.h:119
bool is_valid
Definition viewer.h:120
std::string stream_name
Definition viewer.h:123
std::string api_url
Definition viewer.h:128
std::string account_id
Definition viewer.h:126
std::optional< std::string > token
Definition viewer.h:125
Structure describing playout delay to be enforced on the client. https://webrtc.googlesource....
Definition viewer.h:49
Definition viewer.h:23
bool force_smooth
Definition viewer.h:86
std::optional< unsigned int > upwards_layer_wait_time_ms
Duration the Transponder will wait before switching back to a higher layer in msec....
Definition viewer.h:101
std::optional< uint8_t > multiplexed_audio_track
Definition viewer.h:35
int jitter_minimum_delay_ms
Definition viewer.h:69
std::vector< std::string > excluded_source_id
Definition viewer.h:39
std::optional< unsigned int > bwe_monitor_duration_us
overrides the duration of time over which bandwidth-estimate-calculations occur in usec By default th...
Definition viewer.h:95
struct millicast::ViewerOption::@2 multisource
The structure describing viewership of multisource events. This is valid for events where multiple pu...
std::optional< unsigned int > maximum_bitrate
Set the maximum bitrate in KBps that can be used by the viewer.
Definition viewer.h:62
std::optional< std::string > pinned_source_id
Definition viewer.h:32
std::optional< double > bwe_rate_change_percentage
Definition viewer.h:111
std::optional< ForcePlayoutDelay > force_playout_delay
The playout delay to enforce on the client side.
Definition viewer.h:57
bool disable_audio
Definition viewer.h:64