MillicastSDK 2.0.0
Loading...
Searching...
No Matches
track.h
Go to the documentation of this file.
1#ifndef MILLICAST_API_TRACK_H
2#define MILLICAST_API_TRACK_H
3
15
16#include <optional>
17#include <string>
18#include <vector>
19
20namespace millicast {
21
22// Forward declarations ///////////////////////////////////////////////////////
23class VideoRenderer;
24class AudioRenderer;
25
26// Track //////////////////////////////////////////////////////////////////////
27
33 public:
34 Track() = default;
35 virtual ~Track() = default;
36
42 [[nodiscard]] virtual const std::string& id() const = 0;
43
49 [[nodiscard]] virtual const std::string& kind() const = 0;
50
56 [[nodiscard]] virtual bool is_enabled() const = 0;
57
65 virtual void enable(bool e) = 0;
66};
67
68// VideoTrack /////////////////////////////////////////////////////////////////
69
75 public:
80 enum class ContentHint { NONE, FLUID, DETAILED, TEXT };
81
82 VideoTrack() = default;
83 ~VideoTrack() override = default;
84
92 virtual void add_renderer(VideoRenderer* renderer) = 0;
93
99 virtual void remove_renderer(VideoRenderer* renderer) = 0;
100
106 virtual void set_content_hint(ContentHint hint) noexcept = 0;
107
112 [[nodiscard]] virtual ContentHint content_hint() const noexcept = 0;
113};
114
115// AudioTrack /////////////////////////////////////////////////////////////////
116
122 public:
123 AudioTrack() = default;
124 ~AudioTrack() override = default;
125
133 virtual void add_renderer(AudioRenderer* renderer) = 0;
134
140 virtual void remove_renderer(AudioRenderer* renderer) = 0;
141
147 virtual void set_volume(double volume) = 0;
148};
149
150#ifndef MC_DISABLE_COPY_AND_ASSIGN
151#define MC_DISABLE_COPY_AND_ASSIGN(Klass) \
152 Klass(Klass&&) = delete; \
153 Klass(const Klass&) = delete; \
154 Klass& operator=(Klass&&) = delete; \
155 Klass& operator=(const Klass&) = delete
156#endif // !defined(MC_DISABLE_COPY_AND_ASSIGN)
157
158class RtsRemoteTrack;
159class RtsRemoteVideoTrack;
160class RtsRemoteAudioTrack;
161class WebrtcRemoteAudioTrack;
162class WebrtcRemoteVideoTrack;
163
176 public:
177 WebrtcRemoteTrack() = default;
179
183 enum Kind {
185 VIDEO
186 };
187
197 struct Disabled {};
198
214 struct MidUpdated {
215 std::optional<std::string> mid;
216 };
217
222 [[nodiscard]] virtual Kind kind() const = 0;
223
231
244 virtual std::optional<std::string> get_current_mid() const = 0;
245
246 virtual const std::string& get_cname() const = 0;
247
254
261
268 EventHandler<Disabled>&& handler) = 0;
269
276 EventHandler<MidUpdated>&& handler) = 0;
277
284 EventHandler<FrameMetadata>&& handler) = 0;
285};
286
299 public:
300 RtsRemoteTrack() = default;
302
321 struct Active {};
322
340 struct Inactive {};
341
347
355 struct Layers {
357 struct Resolution {
358 int width;
359 int height;
360 };
361
366 struct Layer {
367 std::string encoding_id;
368 int bitrate = 0;
369 std::optional<int>
370 target_bitrate{};
371 std::optional<int> target_fps{};
372 std::optional<int>
373 target_height{};
374 std::optional<int> target_width{};
375 std::optional<int> temporal_layer_id;
376 std::optional<int> spatial_layer_id;
378 std::optional<Resolution> layer_resolution;
381 std::optional<int> max_temporal_layer_id;
384 std::optional<int> max_spatial_layer_id;
385 };
386
387 std::vector<Layer> active;
388 std::vector<std::string> inactive;
389 };
390
392
399 EventHandler<Active>&& handler) = 0;
400
407 EventHandler<Inactive>&& handler) = 0;
408
415 EventHandler<Layers>&& handler) = 0;
416
423 EventHandler<MidUpdated>&& handler) = 0;
424
431 EventHandler<FrameMetadata>&& handler) = 0;
432
442 [[nodiscard]] virtual const std::optional<std::string>& source_id() const = 0;
443
448 [[nodiscard]] virtual Kind kind() const = 0;
449
457 [[nodiscard]] virtual bool is_active() const = 0;
458
471 virtual std::optional<std::string> get_current_mid() const = 0;
472
481 virtual Promise<void> disable() = 0;
482
489
496};
497
502 public:
508 struct Layer {
509 std::optional<std::string> encodingId;
510 std::optional<int> spatialLayerId;
511 std::optional<int> temporalLayerId;
512 std::optional<int> maxSpatialLayerId;
513 std::optional<int> maxTemporalLayerId;
514
515 operator bool() const noexcept {
516 return encodingId || spatialLayerId || temporalLayerId ||
517 maxSpatialLayerId || maxTemporalLayerId;
518 }
519 };
520
530
550 virtual Promise<void> enable(const std::shared_ptr<VideoRenderer>& renderer,
551 const Layer& layer = {},
552 bool promote = false) = 0;
553};
554
559 public:
562
568 virtual Promise<void> enable() = 0;
569
580 virtual Promise<void> set_volume(double volume) = 0;
581};
582
587 public:
590
600
625 const RtsRemoteVideoTrack::Layer& layer = {},
626 bool promote = false) = 0;
627
637 const std::shared_ptr<VideoRenderer>& renderer) = 0;
638
645 virtual Promise<void> remove_renderer(const VideoRenderer* renderer) = 0;
646
657};
658
663 public:
666
683
694 virtual Promise<void> set_volume(double volume) = 0;
695
706};
707
708} // namespace millicast
709
710#endif /* TRACK_H */
The AudioRenderer class is responsible for rendering audio in a specific way in your application.
Definition renderer.h:70
The AudioTrack class.
Definition track.h:121
virtual void set_volume(double volume)=0
Set the track's volume.
~AudioTrack() override=default
virtual void add_renderer(AudioRenderer *renderer)=0
Add an audio renderer to render this track. Several renderers can be added to the track....
virtual void remove_renderer(AudioRenderer *renderer)=0
Remove a renderer from the renderer list.
Definition promise.h:45
Definition track.h:558
MC_DISABLE_COPY_AND_ASSIGN(RtsRemoteAudioTrack)
virtual Promise< void > set_volume(double volume)=0
virtual Promise< void > enable()=0
Definition track.h:298
virtual Promise< void > disable()=0
virtual EventConnectionPtr add_event_handler(EventHandler< Inactive > &&handler)=0
virtual Kind kind() const =0
virtual EventConnectionPtr add_event_handler(EventHandler< Active > &&handler)=0
virtual const std::optional< std::string > & source_id() const =0
MC_DISABLE_COPY_AND_ASSIGN(RtsRemoteTrack)
virtual EventConnectionPtr add_event_handler(EventHandler< FrameMetadata > &&handler)=0
virtual EventConnectionPtr add_event_handler(EventHandler< Layers > &&handler)=0
virtual EventConnectionPtr add_event_handler(EventHandler< MidUpdated > &&handler)=0
virtual RtsRemoteVideoTrack * as_video()=0
virtual bool is_active() const =0
virtual std::optional< std::string > get_current_mid() const =0
virtual RtsRemoteAudioTrack * as_audio()=0
Definition track.h:501
virtual millicast::Promise< void > enable_frame_metadata(bool enabled)=0
MC_DISABLE_COPY_AND_ASSIGN(RtsRemoteVideoTrack)
virtual Promise< void > enable(const std::shared_ptr< VideoRenderer > &renderer, const Layer &layer={}, bool promote=false)=0
The Track class represent a media sources.
Definition track.h:32
virtual const std::string & kind() const =0
Get the track's kind.
virtual const std::string & id() const =0
Get the track's id.
virtual void enable(bool e)=0
enable or disable the track. A disabled track will produce silence (if audio) or black frames (if vid...
virtual ~Track()=default
virtual bool is_enabled() const =0
Tell whether the track is enabled or not.
The VideoRenderer class Inherits this class to receive video frames and render them in your applicati...
Definition renderer.h:46
The VideoTrack class.
Definition track.h:74
~VideoTrack() override=default
virtual void remove_renderer(VideoRenderer *renderer)=0
Remove a renderer from the renderer list.
virtual ContentHint content_hint() const noexcept=0
Get the current content hint for this track.
ContentHint
Video track content hint, used to override the source is_screencast property.
Definition track.h:80
virtual void set_content_hint(ContentHint hint) noexcept=0
Set the content hint for this track.
virtual void add_renderer(VideoRenderer *renderer)=0
Add a VideoRenderer to render this video track. Several renderers can be added to the track....
Definition track.h:662
MC_DISABLE_COPY_AND_ASSIGN(WebrtcRemoteAudioTrack)
virtual Promise< void > set_volume(double volume)=0
virtual Promise< RtsRemoteAudioTrack * > current_projection()=0
virtual Promise< void > project(RtsRemoteAudioTrack &rts_track)=0
Definition track.h:175
Kind
Definition track.h:183
@ AUDIO
audio
Definition track.h:184
virtual EventConnectionPtr add_event_handler(EventHandler< MidUpdated > &&handler)=0
virtual EventConnectionPtr add_event_handler(EventHandler< Disabled > &&handler)=0
MC_DISABLE_COPY_AND_ASSIGN(WebrtcRemoteTrack)
virtual WebrtcRemoteAudioTrack * as_audio()=0
virtual Promise< void > unproject()=0
virtual WebrtcRemoteVideoTrack * as_video()=0
virtual std::optional< std::string > get_current_mid() const =0
virtual EventConnectionPtr add_event_handler(EventHandler< FrameMetadata > &&handler)=0
virtual const std::string & get_cname() const =0
virtual Kind kind() const =0
Definition track.h:586
virtual Promise< void > project(RtsRemoteVideoTrack &rts_track, const RtsRemoteVideoTrack::Layer &layer={}, bool promote=false)=0
virtual Promise< void > add_renderer(const std::shared_ptr< VideoRenderer > &renderer)=0
virtual Promise< void > remove_renderer(const VideoRenderer *renderer)=0
virtual Promise< RtsRemoteVideoTrack * > current_projection()=0
virtual millicast::Promise< void > enable_frame_metadata(bool enabled)=0
MC_DISABLE_COPY_AND_ASSIGN(WebrtcRemoteVideoTrack)
#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
Definition track.h:321
The layer data is used to select a simulcast/svc layer. by sending a command to the server using the ...
Definition track.h:366
std::optional< int > temporal_layer_id
Definition track.h:375
std::string encoding_id
Definition track.h:367
std::optional< Resolution > layer_resolution
The resolution of the frame for simulcast / SVC layer.
Definition track.h:378
std::optional< int > max_spatial_layer_id
Definition track.h:384
std::optional< int > max_temporal_layer_id
Definition track.h:381
std::optional< int > spatial_layer_id
Definition track.h:376
Represents resolution of a video frame.
Definition track.h:357
Definition track.h:355
std::vector< Layer > active
Definition track.h:387
std::vector< std::string > inactive
Definition track.h:388
std::optional< int > maxTemporalLayerId
Definition track.h:513
std::optional< int > temporalLayerId
Definition track.h:511
std::optional< std::string > encodingId
Definition track.h:509
std::optional< int > maxSpatialLayerId
Definition track.h:512
std::optional< int > spatialLayerId
Definition track.h:510
std::optional< std::string > mid
Definition track.h:215