1#ifndef MILLICAST_API_VIEWER_H
2#define MILLICAST_API_VIEWER_H
25struct ViewerOption :
public ClientOption {
33 std::optional<std::string>
36 std::optional<uint8_t>
37 multiplexed_audio_track;
40 std::vector<std::string>
51 struct ForcePlayoutDelay {
59 std::optional<ForcePlayoutDelay> force_playout_delay;
64 std::optional<unsigned int> maximum_bitrate;
71 int jitter_minimum_delay_ms =
88 bool force_smooth{
false};
97 std::optional<unsigned int> bwe_monitor_duration_us;
103 std::optional<unsigned int> upwards_layer_wait_time_ms;
113 std::optional<double> bwe_rate_change_percentage;
118 enum class AbrStrategy {
129 AbrStrategy abr_strategy{AbrStrategy::DEFAULT};
138 std::optional<std::vector<std::string>> events;
146struct ViewerCredentials {
150 std::string stream_name;
152 std::optional<std::string> token;
153 std::string account_id;
165 using Option = ViewerOption;
166 using Credentials = ViewerCredentials;
172 struct StreamStopped {
173 std::string description;
185 virtual Promise<void> subscribe(
186 std::optional<ViewerOption>&& options = std::nullopt) = 0;
192 virtual Promise<void> unsubscribe() = 0;
199 [[nodiscard]]
virtual Promise<bool> is_subscribed()
const = 0;
206 virtual Promise<void> set_credentials(ViewerCredentials&& creds) = 0;
212 [[nodiscard]]
virtual Promise<ViewerCredentials> get_credentials()
const = 0;
218 static std::unique_ptr<Viewer> create();
223 struct RtsTrackAdded {
224 RtsRemoteTrack& track;
228 struct RtsStatsEvent {
229 const std::shared_ptr<const RtsViewerStats> viewer_stats;
237 virtual EventConnectionPtr add_event_handler(
238 EventHandler<RtsTrackAdded>&& handler) = 0;
245 virtual EventConnectionPtr add_event_handler(
246 EventHandler<StreamStopped>&& handler) = 0;
257 "Use the overload with RtsStatsEvent")]]
virtual EventConnectionPtr
258 add_event_handler(EventHandler<StatsEvent>&& handler) = 0;
268 virtual EventConnectionPtr add_event_handler(
269 EventHandler<RtsStatsEvent>&& handler) = 0;
277 virtual EventConnectionPtr add_event_handler(
278 EventHandler<ViewerCount>&& handler) = 0;
285 virtual EventConnectionPtr add_event_handler(
286 EventHandler<SignalingError>&& handler) = 0;
293 virtual EventConnectionPtr add_event_handler(
294 EventHandler<HttpConnectionError>&& handler) = 0;
301 virtual EventConnectionPtr add_event_handler(
302 EventHandler<WebsocketState>&& handler) = 0;
310 virtual EventConnectionPtr add_event_handler(
311 EventHandler<PeerConnectionState>&& handler) = 0;
320 [[nodiscard]]
virtual Promise<std::vector<RtsRemoteAudioTrack*>>
321 audio_tracks()
const = 0;
330 [[nodiscard]]
virtual Promise<std::vector<RtsRemoteVideoTrack*>>
331 video_tracks()
const = 0;
353 virtual Promise<WebrtcRemoteTrack*> add_webrtc_remote_track(
354 WebrtcRemoteTrack::Kind kind,
355 std::string_view cname) = 0;
365 [[nodiscard]]
virtual Promise<std::vector<WebrtcRemoteAudioTrack*>>
366 webrtc_audio_tracks()
const = 0;
376 [[nodiscard]]
virtual Promise<std::vector<WebrtcRemoteVideoTrack*>>
377 webrtc_video_tracks()
const = 0;
441 virtual void enable_seamless_migration(
bool enabled =
true) = 0;
#define MILLICAST_API
Definition exports.h:51