MillicastSDK 2.0.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
12#include "millicast-sdk/track.h"
13
14namespace millicast {
15
16// Forward declarations ///////////////////////////////////////////////////////
17class VideoTrack;
18class AudioTrack;
19
20// Viewer /////////////////////////////////////////////////////////////////////
21
22struct ViewerOption : public ClientOption {
29 struct {
30 std::optional<std::string>
33 std::optional<uint8_t>
37 std::vector<std::string>
41
49 int min;
50 int max;
51 };
52
56 std::optional<ForcePlayoutDelay> force_playout_delay;
57
61 std::optional<unsigned int> maximum_bitrate;
62
64 false};
69 0;
85 bool force_smooth{false};
86
94 std::optional<unsigned int> bwe_monitor_duration_us;
95
100 std::optional<unsigned int> upwards_layer_wait_time_ms;
101
110 std::optional<double> bwe_rate_change_percentage;
111};
112
119 bool is_valid;
122 std::string stream_name;
124 std::optional<std::string> token;
125 std::string account_id;
126 std::string
128};
129
135class MILLICAST_API Viewer : public virtual Client {
136 public:
145 std::string description;
146 };
147
158 std::optional<ViewerOption>&& options = std::nullopt) = 0;
159
165
171 [[nodiscard]] virtual Promise<bool> is_subscribed() const = 0;
172
179
184 [[nodiscard]] virtual Promise<ViewerCredentials> get_credentials() const = 0;
185
190 static std::unique_ptr<Viewer> create();
191
198 };
199
206 EventHandler<RtsTrackAdded>&& handler) = 0;
207
214 EventHandler<StreamStopped>&& handler) = 0;
215
223 EventHandler<StatsEvent>&& handler) = 0;
224
232 EventHandler<ViewerCount>&& handler) = 0;
233
240 EventHandler<SignalingError>&& handler) = 0;
241
249
256 EventHandler<WebsocketState>&& handler) = 0;
257
266
274 [[nodiscard]] virtual Promise<std::vector<RtsRemoteAudioTrack*>>
275 audio_tracks() const = 0;
276
284 [[nodiscard]] virtual Promise<std::vector<RtsRemoteVideoTrack*>>
285 video_tracks() const = 0;
286
309 std::string_view cname) = 0;
310
321
332
395 virtual void enable_seamless_migration(bool enabled = true) = 0;
396};
397
398} // namespace millicast
399
400#endif /* MILLICAST_API_VIEWER_H */
The Client base class.
Definition client.h:142
Definition promise.h:45
Definition track.h:298
The Viewer class. Its purpose is to receive media by subscribing to a millicast stream....
Definition viewer.h:135
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 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:183
#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:195
RtsRemoteTrack & track
Definition viewer.h:196
The Stream Stopped event is emitted when the viewer has requested to disconnect from the media server...
Definition viewer.h:144
std::string description
Definition viewer.h:145
The ViewerCredentials struct represent the credentials need to be able to connect and subscribe to a ...
Definition viewer.h:118
bool is_valid
Definition viewer.h:119
std::string stream_name
Definition viewer.h:122
std::string api_url
Definition viewer.h:127
std::string account_id
Definition viewer.h:125
std::optional< std::string > token
Definition viewer.h:124
Structure describing playout delay to be enforced on the client. https://webrtc.googlesource....
Definition viewer.h:48
Definition viewer.h:22
bool force_smooth
Definition viewer.h:85
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:100
std::optional< uint8_t > multiplexed_audio_track
Definition viewer.h:34
int jitter_minimum_delay_ms
Definition viewer.h:68
std::vector< std::string > excluded_source_id
Definition viewer.h:38
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:94
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:61
std::optional< std::string > pinned_source_id
Definition viewer.h:31
std::optional< double > bwe_rate_change_percentage
Definition viewer.h:110
std::optional< ForcePlayoutDelay > force_playout_delay
The playout delay to enforce on the client side.
Definition viewer.h:56
bool disable_audio
Definition viewer.h:63