henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 15:54:43 | [diff] [blame] | 2 | * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 15:54:43 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | // This file contains interfaces for MediaStream, MediaTrack and MediaSource. |
| 12 | // These interfaces are used for implementing MediaStream and MediaTrack as |
| 13 | // defined in http://dev.w3.org/2011/webrtc/editor/webrtc.html#stream-api. These |
| 14 | // interfaces must be used only with PeerConnection. PeerConnectionManager |
| 15 | // interface provides the factory methods to create MediaStream and MediaTracks. |
| 16 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 17 | #ifndef API_MEDIA_STREAM_INTERFACE_H_ |
| 18 | #define API_MEDIA_STREAM_INTERFACE_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 19 | |
pbos | 9baddf2 | 2017-01-02 14:44:41 | [diff] [blame] | 20 | #include <stddef.h> |
| 21 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 22 | #include <string> |
| 23 | #include <vector> |
| 24 | |
Danil Chapovalov | 0bc58cf | 2018-06-21 11:32:56 | [diff] [blame] | 25 | #include "absl/types/optional.h" |
Piotr (Peter) Slatala | 95ca6e1 | 2018-11-13 15:57:07 | [diff] [blame] | 26 | #include "api/audio_options.h" |
Mirko Bonadei | d970807 | 2019-01-25 19:26:48 | [diff] [blame] | 27 | #include "api/scoped_refptr.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 28 | #include "api/video/video_frame.h" |
Niels Möller | c6ce9c5 | 2018-05-11 09:15:30 | [diff] [blame] | 29 | #include "api/video/video_sink_interface.h" |
Niels Möller | 0327c2d | 2018-05-21 12:09:31 | [diff] [blame] | 30 | #include "api/video/video_source_interface.h" |
Ivo Creusen | 56d46090 | 2017-11-24 16:29:59 | [diff] [blame] | 31 | #include "modules/audio_processing/include/audio_processing_statistics.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 32 | #include "rtc_base/ref_count.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 33 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 34 | namespace webrtc { |
| 35 | |
| 36 | // Generic observer interface. |
| 37 | class ObserverInterface { |
| 38 | public: |
| 39 | virtual void OnChanged() = 0; |
| 40 | |
| 41 | protected: |
| 42 | virtual ~ObserverInterface() {} |
| 43 | }; |
| 44 | |
| 45 | class NotifierInterface { |
| 46 | public: |
| 47 | virtual void RegisterObserver(ObserverInterface* observer) = 0; |
| 48 | virtual void UnregisterObserver(ObserverInterface* observer) = 0; |
| 49 | |
| 50 | virtual ~NotifierInterface() {} |
| 51 | }; |
| 52 | |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 53 | // Base class for sources. A MediaStreamTrack has an underlying source that |
| 54 | // provides media. A source can be shared by multiple tracks. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 | [diff] [blame] | 55 | class MediaSourceInterface : public rtc::RefCountInterface, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 56 | public NotifierInterface { |
| 57 | public: |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 58 | enum SourceState { kInitializing, kLive, kEnded, kMuted }; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 59 | |
| 60 | virtual SourceState state() const = 0; |
| 61 | |
tommi | 6eca7e3 | 2015-12-15 12:27:11 | [diff] [blame] | 62 | virtual bool remote() const = 0; |
| 63 | |
Ruslan Burakov | 493a650 | 2019-02-27 14:32:48 | [diff] [blame] | 64 | // Sets the minimum latency of the remote source until audio playout. Actual |
| 65 | // observered latency may differ depending on the source. |latency| is in the |
| 66 | // range of [0.0, 10.0] seconds. |
| 67 | // TODO(kuddai) make pure virtual once not only remote tracks support latency. |
| 68 | virtual void SetLatency(double latency) {} |
| 69 | virtual double GetLatency() const; |
| 70 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 71 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 08:38:31 | [diff] [blame] | 72 | ~MediaSourceInterface() override = default; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 73 | }; |
| 74 | |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 75 | // C++ version of MediaStreamTrack. |
| 76 | // See: https://www.w3.org/TR/mediacapture-streams/#mediastreamtrack |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 | [diff] [blame] | 77 | class MediaStreamTrackInterface : public rtc::RefCountInterface, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 78 | public NotifierInterface { |
| 79 | public: |
| 80 | enum TrackState { |
perkj | c8f952d | 2016-03-23 07:33:56 | [diff] [blame] | 81 | kLive, |
| 82 | kEnded, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 83 | }; |
| 84 | |
deadbeef | fac0655 | 2015-11-25 19:26:01 | [diff] [blame] | 85 | static const char kAudioKind[]; |
| 86 | static const char kVideoKind[]; |
| 87 | |
nisse | fcc640f | 2016-04-01 08:10:42 | [diff] [blame] | 88 | // The kind() method must return kAudioKind only if the object is a |
| 89 | // subclass of AudioTrackInterface, and kVideoKind only if the |
| 90 | // object is a subclass of VideoTrackInterface. It is typically used |
| 91 | // to protect a static_cast<> to the corresponding subclass. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 92 | virtual std::string kind() const = 0; |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 93 | |
| 94 | // Track identifier. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 95 | virtual std::string id() const = 0; |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 96 | |
| 97 | // A disabled track will produce silence (if audio) or black frames (if |
| 98 | // video). Can be disabled and re-enabled. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 99 | virtual bool enabled() const = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 100 | virtual bool set_enabled(bool enable) = 0; |
fischman@webrtc.org | 32001ef | 2013-08-12 23:26:21 | [diff] [blame] | 101 | |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 102 | // Live or ended. A track will never be live again after becoming ended. |
| 103 | virtual TrackState state() const = 0; |
| 104 | |
fischman@webrtc.org | 32001ef | 2013-08-12 23:26:21 | [diff] [blame] | 105 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 08:38:31 | [diff] [blame] | 106 | ~MediaStreamTrackInterface() override = default; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 107 | }; |
| 108 | |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 109 | // VideoTrackSourceInterface is a reference counted source used for |
| 110 | // VideoTracks. The same source can be used by multiple VideoTracks. |
perkj | 773be36 | 2017-08-01 06:22:01 | [diff] [blame] | 111 | // VideoTrackSourceInterface is designed to be invoked on the signaling thread |
| 112 | // except for rtc::VideoSourceInterface<VideoFrame> methods that will be invoked |
| 113 | // on the worker thread via a VideoTrack. A custom implementation of a source |
| 114 | // can inherit AdaptedVideoTrackSource instead of directly implementing this |
| 115 | // interface. |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 116 | class VideoTrackSourceInterface : public MediaSourceInterface, |
| 117 | public rtc::VideoSourceInterface<VideoFrame> { |
perkj | a3ede6c | 2016-03-08 00:27:48 | [diff] [blame] | 118 | public: |
nisse | fcc640f | 2016-04-01 08:10:42 | [diff] [blame] | 119 | struct Stats { |
| 120 | // Original size of captured frame, before video adaptation. |
| 121 | int input_width; |
| 122 | int input_height; |
| 123 | }; |
perkj | a3ede6c | 2016-03-08 00:27:48 | [diff] [blame] | 124 | |
perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 125 | // Indicates that parameters suitable for screencasts should be automatically |
| 126 | // applied to RtpSenders. |
| 127 | // TODO(perkj): Remove these once all known applications have moved to |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 128 | // explicitly setting suitable parameters for screencasts and don't need this |
perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 129 | // implicit behavior. |
| 130 | virtual bool is_screencast() const = 0; |
| 131 | |
Per | c0d31e9 | 2016-03-31 15:23:39 | [diff] [blame] | 132 | // Indicates that the encoder should denoise video before encoding it. |
| 133 | // If it is not set, the default configuration is used which is different |
| 134 | // depending on video codec. |
perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 135 | // TODO(perkj): Remove this once denoising is done by the source, and not by |
| 136 | // the encoder. |
Danil Chapovalov | 0bc58cf | 2018-06-21 11:32:56 | [diff] [blame] | 137 | virtual absl::optional<bool> needs_denoising() const = 0; |
perkj | a3ede6c | 2016-03-08 00:27:48 | [diff] [blame] | 138 | |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 139 | // Returns false if no stats are available, e.g, for a remote source, or a |
| 140 | // source which has not seen its first frame yet. |
| 141 | // |
| 142 | // Implementation should avoid blocking. |
nisse | fcc640f | 2016-04-01 08:10:42 | [diff] [blame] | 143 | virtual bool GetStats(Stats* stats) = 0; |
| 144 | |
perkj | a3ede6c | 2016-03-08 00:27:48 | [diff] [blame] | 145 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 08:38:31 | [diff] [blame] | 146 | ~VideoTrackSourceInterface() override = default; |
perkj | a3ede6c | 2016-03-08 00:27:48 | [diff] [blame] | 147 | }; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 148 | |
perkj | 773be36 | 2017-08-01 06:22:01 | [diff] [blame] | 149 | // VideoTrackInterface is designed to be invoked on the signaling thread except |
| 150 | // for rtc::VideoSourceInterface<VideoFrame> methods that must be invoked |
| 151 | // on the worker thread. |
| 152 | // PeerConnectionFactory::CreateVideoTrack can be used for creating a VideoTrack |
| 153 | // that ensures thread safety and that all methods are called on the right |
| 154 | // thread. |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 155 | class VideoTrackInterface : public MediaStreamTrackInterface, |
| 156 | public rtc::VideoSourceInterface<VideoFrame> { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 157 | public: |
pbos | 5214a0a | 2016-12-16 23:39:11 | [diff] [blame] | 158 | // Video track content hint, used to override the source is_screencast |
| 159 | // property. |
Harald Alvestrand | c19ab07 | 2018-06-18 06:53:10 | [diff] [blame] | 160 | // See https://crbug.com/653531 and https://w3c.github.io/mst-content-hint. |
| 161 | enum class ContentHint { kNone, kFluid, kDetailed, kText }; |
pbos | 5214a0a | 2016-12-16 23:39:11 | [diff] [blame] | 162 | |
mbonadei | 539d104 | 2017-07-10 09:40:49 | [diff] [blame] | 163 | // Register a video sink for this track. Used to connect the track to the |
| 164 | // underlying video engine. |
| 165 | void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, |
| 166 | const rtc::VideoSinkWants& wants) override {} |
| 167 | void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override {} |
| 168 | |
perkj | a3ede6c | 2016-03-08 00:27:48 | [diff] [blame] | 169 | virtual VideoTrackSourceInterface* GetSource() const = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 170 | |
Danil Chapovalov | 2a5ce2b | 2018-02-07 08:38:31 | [diff] [blame] | 171 | virtual ContentHint content_hint() const; |
pbos | 5214a0a | 2016-12-16 23:39:11 | [diff] [blame] | 172 | virtual void set_content_hint(ContentHint hint) {} |
| 173 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 174 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 08:38:31 | [diff] [blame] | 175 | ~VideoTrackInterface() override = default; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 176 | }; |
| 177 | |
tommi | 6eca7e3 | 2015-12-15 12:27:11 | [diff] [blame] | 178 | // Interface for receiving audio data from a AudioTrack. |
| 179 | class AudioTrackSinkInterface { |
| 180 | public: |
| 181 | virtual void OnData(const void* audio_data, |
| 182 | int bits_per_sample, |
| 183 | int sample_rate, |
Peter Kasting | 6955870 | 2016-01-13 00:26:35 | [diff] [blame] | 184 | size_t number_of_channels, |
tommi | 6eca7e3 | 2015-12-15 12:27:11 | [diff] [blame] | 185 | size_t number_of_frames) = 0; |
| 186 | |
| 187 | protected: |
| 188 | virtual ~AudioTrackSinkInterface() {} |
| 189 | }; |
| 190 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 191 | // AudioSourceInterface is a reference counted source used for AudioTracks. |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 192 | // The same source can be used by multiple AudioTracks. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 193 | class AudioSourceInterface : public MediaSourceInterface { |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 | [diff] [blame] | 194 | public: |
| 195 | class AudioObserver { |
| 196 | public: |
| 197 | virtual void OnSetVolume(double volume) = 0; |
| 198 | |
| 199 | protected: |
| 200 | virtual ~AudioObserver() {} |
| 201 | }; |
| 202 | |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 203 | // TODO(deadbeef): Makes all the interfaces pure virtual after they're |
| 204 | // implemented in chromium. |
| 205 | |
| 206 | // Sets the volume of the source. |volume| is in the range of [0, 10]. |
Tommi | f888bb5 | 2015-12-12 00:37:01 | [diff] [blame] | 207 | // TODO(tommi): This method should be on the track and ideally volume should |
| 208 | // be applied in the track in a way that does not affect clones of the track. |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 | [diff] [blame] | 209 | virtual void SetVolume(double volume) {} |
| 210 | |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 211 | // Registers/unregisters observers to the audio source. |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 | [diff] [blame] | 212 | virtual void RegisterAudioObserver(AudioObserver* observer) {} |
| 213 | virtual void UnregisterAudioObserver(AudioObserver* observer) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 214 | |
tommi | 6eca7e3 | 2015-12-15 12:27:11 | [diff] [blame] | 215 | // TODO(tommi): Make pure virtual. |
| 216 | virtual void AddSink(AudioTrackSinkInterface* sink) {} |
| 217 | virtual void RemoveSink(AudioTrackSinkInterface* sink) {} |
Piotr (Peter) Slatala | 95ca6e1 | 2018-11-13 15:57:07 | [diff] [blame] | 218 | |
| 219 | // Returns options for the AudioSource. |
| 220 | // (for some of the settings this approach is broken, e.g. setting |
| 221 | // audio network adaptation on the source is the wrong layer of abstraction). |
| 222 | virtual const cricket::AudioOptions options() const; |
mallinath@webrtc.org | 67ee6b9 | 2014-02-03 16:57:16 | [diff] [blame] | 223 | }; |
| 224 | |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 | [diff] [blame] | 225 | // Interface of the audio processor used by the audio track to collect |
| 226 | // statistics. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 | [diff] [blame] | 227 | class AudioProcessorInterface : public rtc::RefCountInterface { |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 | [diff] [blame] | 228 | public: |
Ivo Creusen | ae026096 | 2017-11-20 12:07:16 | [diff] [blame] | 229 | struct AudioProcessorStatistics { |
| 230 | bool typing_noise_detected = false; |
Ivo Creusen | 56d46090 | 2017-11-24 16:29:59 | [diff] [blame] | 231 | AudioProcessingStats apm_statistics; |
Ivo Creusen | ae026096 | 2017-11-20 12:07:16 | [diff] [blame] | 232 | }; |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 | [diff] [blame] | 233 | |
Ivo Creusen | ae026096 | 2017-11-20 12:07:16 | [diff] [blame] | 234 | // Get audio processor statistics. The |has_remote_tracks| argument should be |
| 235 | // set if there are active remote tracks (this would usually be true during |
| 236 | // a call). If there are no remote tracks some of the stats will not be set by |
| 237 | // the AudioProcessor, because they only make sense if there is at least one |
| 238 | // remote track. |
Sam Zackrisson | 2812763 | 2018-11-01 10:37:15 | [diff] [blame] | 239 | virtual AudioProcessorStatistics GetStats(bool has_remote_tracks) = 0; |
Ivo Creusen | ae026096 | 2017-11-20 12:07:16 | [diff] [blame] | 240 | |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 | [diff] [blame] | 241 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 08:38:31 | [diff] [blame] | 242 | ~AudioProcessorInterface() override = default; |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 | [diff] [blame] | 243 | }; |
| 244 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 245 | class AudioTrackInterface : public MediaStreamTrackInterface { |
| 246 | public: |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 247 | // TODO(deadbeef): Figure out if the following interface should be const or |
| 248 | // not. |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 249 | virtual AudioSourceInterface* GetSource() const = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 250 | |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 | [diff] [blame] | 251 | // Add/Remove a sink that will receive the audio data from the track. |
| 252 | virtual void AddSink(AudioTrackSinkInterface* sink) = 0; |
| 253 | virtual void RemoveSink(AudioTrackSinkInterface* sink) = 0; |
mallinath@webrtc.org | 67ee6b9 | 2014-02-03 16:57:16 | [diff] [blame] | 254 | |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 | [diff] [blame] | 255 | // Get the signal level from the audio track. |
| 256 | // Return true on success, otherwise false. |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 257 | // TODO(deadbeef): Change the interface to int GetSignalLevel() and pure |
| 258 | // virtual after it's implemented in chromium. |
Danil Chapovalov | 2a5ce2b | 2018-02-07 08:38:31 | [diff] [blame] | 259 | virtual bool GetSignalLevel(int* level); |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 | [diff] [blame] | 260 | |
deadbeef | 8d60a94 | 2017-02-27 22:47:33 | [diff] [blame] | 261 | // Get the audio processor used by the audio track. Return null if the track |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 | [diff] [blame] | 262 | // does not have any processor. |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 263 | // TODO(deadbeef): Make the interface pure virtual. |
Danil Chapovalov | 2a5ce2b | 2018-02-07 08:38:31 | [diff] [blame] | 264 | virtual rtc::scoped_refptr<AudioProcessorInterface> GetAudioProcessor(); |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 | [diff] [blame] | 265 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 266 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 08:38:31 | [diff] [blame] | 267 | ~AudioTrackInterface() override = default; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 268 | }; |
| 269 | |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 270 | typedef std::vector<rtc::scoped_refptr<AudioTrackInterface> > AudioTrackVector; |
| 271 | typedef std::vector<rtc::scoped_refptr<VideoTrackInterface> > VideoTrackVector; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 272 | |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 273 | // C++ version of https://www.w3.org/TR/mediacapture-streams/#mediastream. |
| 274 | // |
| 275 | // A major difference is that remote audio/video tracks (received by a |
| 276 | // PeerConnection/RtpReceiver) are not synchronized simply by adding them to |
| 277 | // the same stream; a session description with the correct "a=msid" attributes |
| 278 | // must be pushed down. |
| 279 | // |
| 280 | // Thus, this interface acts as simply a container for tracks. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 | [diff] [blame] | 281 | class MediaStreamInterface : public rtc::RefCountInterface, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 282 | public NotifierInterface { |
| 283 | public: |
Seth Hampson | 13b8bad | 2018-03-13 23:05:28 | [diff] [blame] | 284 | virtual std::string id() const = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 285 | |
| 286 | virtual AudioTrackVector GetAudioTracks() = 0; |
| 287 | virtual VideoTrackVector GetVideoTracks() = 0; |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 288 | virtual rtc::scoped_refptr<AudioTrackInterface> FindAudioTrack( |
| 289 | const std::string& track_id) = 0; |
| 290 | virtual rtc::scoped_refptr<VideoTrackInterface> FindVideoTrack( |
| 291 | const std::string& track_id) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 292 | |
| 293 | virtual bool AddTrack(AudioTrackInterface* track) = 0; |
| 294 | virtual bool AddTrack(VideoTrackInterface* track) = 0; |
| 295 | virtual bool RemoveTrack(AudioTrackInterface* track) = 0; |
| 296 | virtual bool RemoveTrack(VideoTrackInterface* track) = 0; |
| 297 | |
| 298 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 08:38:31 | [diff] [blame] | 299 | ~MediaStreamInterface() override = default; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 300 | }; |
| 301 | |
| 302 | } // namespace webrtc |
| 303 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 304 | #endif // API_MEDIA_STREAM_INTERFACE_H_ |