henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [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 +0000 | [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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #ifndef API_MEDIASTREAMINTERFACE_H_ |
| 18 | #define API_MEDIASTREAMINTERFACE_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 19 | |
pbos | 9baddf2 | 2017-01-02 06:44:41 -0800 | [diff] [blame] | 20 | #include <stddef.h> |
| 21 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 22 | #include <string> |
| 23 | #include <vector> |
| 24 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 25 | #include "api/optional.h" |
| 26 | #include "api/video/video_frame.h" |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 27 | // TODO(zhihuang): Remove unrelated headers once downstream applications stop |
| 28 | // relying on them; they were previously transitively included by |
| 29 | // mediachannel.h, which is no longer a dependency of this file. |
Niels Möller | c6ce9c5 | 2018-05-11 11:15:30 +0200 | [diff] [blame^] | 30 | #include "api/video/video_sink_interface.h" |
Patrik Höglund | 9e19403 | 2018-01-04 15:58:20 +0100 | [diff] [blame] | 31 | #include "api/videosourceinterface.h" |
Ivo Creusen | 56d4609 | 2017-11-24 17:29:59 +0100 | [diff] [blame] | 32 | #include "modules/audio_processing/include/audio_processing_statistics.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 33 | #include "rtc_base/ratetracker.h" |
| 34 | #include "rtc_base/refcount.h" |
| 35 | #include "rtc_base/scoped_ref_ptr.h" |
| 36 | #include "rtc_base/thread.h" |
| 37 | #include "rtc_base/timeutils.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 38 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 39 | namespace webrtc { |
| 40 | |
| 41 | // Generic observer interface. |
| 42 | class ObserverInterface { |
| 43 | public: |
| 44 | virtual void OnChanged() = 0; |
| 45 | |
| 46 | protected: |
| 47 | virtual ~ObserverInterface() {} |
| 48 | }; |
| 49 | |
| 50 | class NotifierInterface { |
| 51 | public: |
| 52 | virtual void RegisterObserver(ObserverInterface* observer) = 0; |
| 53 | virtual void UnregisterObserver(ObserverInterface* observer) = 0; |
| 54 | |
| 55 | virtual ~NotifierInterface() {} |
| 56 | }; |
| 57 | |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 58 | // Base class for sources. A MediaStreamTrack has an underlying source that |
| 59 | // provides media. A source can be shared by multiple tracks. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 60 | class MediaSourceInterface : public rtc::RefCountInterface, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 61 | public NotifierInterface { |
| 62 | public: |
| 63 | enum SourceState { |
| 64 | kInitializing, |
| 65 | kLive, |
| 66 | kEnded, |
| 67 | kMuted |
| 68 | }; |
| 69 | |
| 70 | virtual SourceState state() const = 0; |
| 71 | |
tommi | 6eca7e3 | 2015-12-15 04:27:11 -0800 | [diff] [blame] | 72 | virtual bool remote() const = 0; |
| 73 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 74 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 09:38:31 +0100 | [diff] [blame] | 75 | ~MediaSourceInterface() override = default; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 78 | // C++ version of MediaStreamTrack. |
| 79 | // See: https://www.w3.org/TR/mediacapture-streams/#mediastreamtrack |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 80 | class MediaStreamTrackInterface : public rtc::RefCountInterface, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 81 | public NotifierInterface { |
| 82 | public: |
| 83 | enum TrackState { |
perkj | c8f952d | 2016-03-23 00:33:56 -0700 | [diff] [blame] | 84 | kLive, |
| 85 | kEnded, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 88 | static const char kAudioKind[]; |
| 89 | static const char kVideoKind[]; |
| 90 | |
nisse | fcc640f | 2016-04-01 01:10:42 -0700 | [diff] [blame] | 91 | // The kind() method must return kAudioKind only if the object is a |
| 92 | // subclass of AudioTrackInterface, and kVideoKind only if the |
| 93 | // object is a subclass of VideoTrackInterface. It is typically used |
| 94 | // to protect a static_cast<> to the corresponding subclass. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 95 | virtual std::string kind() const = 0; |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 96 | |
| 97 | // Track identifier. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 98 | virtual std::string id() const = 0; |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 99 | |
| 100 | // A disabled track will produce silence (if audio) or black frames (if |
| 101 | // video). Can be disabled and re-enabled. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 102 | virtual bool enabled() const = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 103 | virtual bool set_enabled(bool enable) = 0; |
fischman@webrtc.org | 32001ef | 2013-08-12 23:26:21 +0000 | [diff] [blame] | 104 | |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 105 | // Live or ended. A track will never be live again after becoming ended. |
| 106 | virtual TrackState state() const = 0; |
| 107 | |
fischman@webrtc.org | 32001ef | 2013-08-12 23:26:21 +0000 | [diff] [blame] | 108 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 09:38:31 +0100 | [diff] [blame] | 109 | ~MediaStreamTrackInterface() override = default; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 110 | }; |
| 111 | |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 112 | // VideoTrackSourceInterface is a reference counted source used for |
| 113 | // VideoTracks. The same source can be used by multiple VideoTracks. |
perkj | 773be36 | 2017-07-31 23:22:01 -0700 | [diff] [blame] | 114 | // VideoTrackSourceInterface is designed to be invoked on the signaling thread |
| 115 | // except for rtc::VideoSourceInterface<VideoFrame> methods that will be invoked |
| 116 | // on the worker thread via a VideoTrack. A custom implementation of a source |
| 117 | // can inherit AdaptedVideoTrackSource instead of directly implementing this |
| 118 | // interface. |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 119 | class VideoTrackSourceInterface |
| 120 | : public MediaSourceInterface, |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 121 | public rtc::VideoSourceInterface<VideoFrame> { |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 122 | public: |
nisse | fcc640f | 2016-04-01 01:10:42 -0700 | [diff] [blame] | 123 | struct Stats { |
| 124 | // Original size of captured frame, before video adaptation. |
| 125 | int input_width; |
| 126 | int input_height; |
| 127 | }; |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 128 | |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 129 | // Indicates that parameters suitable for screencasts should be automatically |
| 130 | // applied to RtpSenders. |
| 131 | // TODO(perkj): Remove these once all known applications have moved to |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 132 | // explicitly setting suitable parameters for screencasts and don't need this |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 133 | // implicit behavior. |
| 134 | virtual bool is_screencast() const = 0; |
| 135 | |
Per | c0d31e9 | 2016-03-31 17:23:39 +0200 | [diff] [blame] | 136 | // Indicates that the encoder should denoise video before encoding it. |
| 137 | // If it is not set, the default configuration is used which is different |
| 138 | // depending on video codec. |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 139 | // TODO(perkj): Remove this once denoising is done by the source, and not by |
| 140 | // the encoder. |
Per | c0d31e9 | 2016-03-31 17:23:39 +0200 | [diff] [blame] | 141 | virtual rtc::Optional<bool> needs_denoising() const = 0; |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 142 | |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 143 | // Returns false if no stats are available, e.g, for a remote source, or a |
| 144 | // source which has not seen its first frame yet. |
| 145 | // |
| 146 | // Implementation should avoid blocking. |
nisse | fcc640f | 2016-04-01 01:10:42 -0700 | [diff] [blame] | 147 | virtual bool GetStats(Stats* stats) = 0; |
| 148 | |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 149 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 09:38:31 +0100 | [diff] [blame] | 150 | ~VideoTrackSourceInterface() override = default; |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 151 | }; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 152 | |
perkj | 773be36 | 2017-07-31 23:22:01 -0700 | [diff] [blame] | 153 | // VideoTrackInterface is designed to be invoked on the signaling thread except |
| 154 | // for rtc::VideoSourceInterface<VideoFrame> methods that must be invoked |
| 155 | // on the worker thread. |
| 156 | // PeerConnectionFactory::CreateVideoTrack can be used for creating a VideoTrack |
| 157 | // that ensures thread safety and that all methods are called on the right |
| 158 | // thread. |
nisse | db25d2e | 2016-02-26 01:24:58 -0800 | [diff] [blame] | 159 | class VideoTrackInterface |
| 160 | : public MediaStreamTrackInterface, |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 161 | public rtc::VideoSourceInterface<VideoFrame> { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 162 | public: |
pbos | 5214a0a | 2016-12-16 15:39:11 -0800 | [diff] [blame] | 163 | // Video track content hint, used to override the source is_screencast |
| 164 | // property. |
| 165 | // See https://crbug.com/653531 and https://github.com/WICG/mst-content-hint. |
| 166 | enum class ContentHint { kNone, kFluid, kDetailed }; |
| 167 | |
mbonadei | 539d104 | 2017-07-10 02:40:49 -0700 | [diff] [blame] | 168 | // Register a video sink for this track. Used to connect the track to the |
| 169 | // underlying video engine. |
| 170 | void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, |
| 171 | const rtc::VideoSinkWants& wants) override {} |
| 172 | void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override {} |
| 173 | |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 174 | virtual VideoTrackSourceInterface* GetSource() const = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 175 | |
Danil Chapovalov | 2a5ce2b | 2018-02-07 09:38:31 +0100 | [diff] [blame] | 176 | virtual ContentHint content_hint() const; |
pbos | 5214a0a | 2016-12-16 15:39:11 -0800 | [diff] [blame] | 177 | virtual void set_content_hint(ContentHint hint) {} |
| 178 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 179 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 09:38:31 +0100 | [diff] [blame] | 180 | ~VideoTrackInterface() override = default; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 181 | }; |
| 182 | |
tommi | 6eca7e3 | 2015-12-15 04:27:11 -0800 | [diff] [blame] | 183 | // Interface for receiving audio data from a AudioTrack. |
| 184 | class AudioTrackSinkInterface { |
| 185 | public: |
| 186 | virtual void OnData(const void* audio_data, |
| 187 | int bits_per_sample, |
| 188 | int sample_rate, |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 189 | size_t number_of_channels, |
tommi | 6eca7e3 | 2015-12-15 04:27:11 -0800 | [diff] [blame] | 190 | size_t number_of_frames) = 0; |
| 191 | |
| 192 | protected: |
| 193 | virtual ~AudioTrackSinkInterface() {} |
| 194 | }; |
| 195 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 196 | // AudioSourceInterface is a reference counted source used for AudioTracks. |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 197 | // The same source can be used by multiple AudioTracks. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 198 | class AudioSourceInterface : public MediaSourceInterface { |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 199 | public: |
| 200 | class AudioObserver { |
| 201 | public: |
| 202 | virtual void OnSetVolume(double volume) = 0; |
| 203 | |
| 204 | protected: |
| 205 | virtual ~AudioObserver() {} |
| 206 | }; |
| 207 | |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 208 | // TODO(deadbeef): Makes all the interfaces pure virtual after they're |
| 209 | // implemented in chromium. |
| 210 | |
| 211 | // Sets the volume of the source. |volume| is in the range of [0, 10]. |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 212 | // TODO(tommi): This method should be on the track and ideally volume should |
| 213 | // 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 +0000 | [diff] [blame] | 214 | virtual void SetVolume(double volume) {} |
| 215 | |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 216 | // Registers/unregisters observers to the audio source. |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 217 | virtual void RegisterAudioObserver(AudioObserver* observer) {} |
| 218 | virtual void UnregisterAudioObserver(AudioObserver* observer) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 219 | |
tommi | 6eca7e3 | 2015-12-15 04:27:11 -0800 | [diff] [blame] | 220 | // TODO(tommi): Make pure virtual. |
| 221 | virtual void AddSink(AudioTrackSinkInterface* sink) {} |
| 222 | virtual void RemoveSink(AudioTrackSinkInterface* sink) {} |
mallinath@webrtc.org | 67ee6b9 | 2014-02-03 16:57:16 +0000 | [diff] [blame] | 223 | }; |
| 224 | |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [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 +0000 | [diff] [blame] | 227 | class AudioProcessorInterface : public rtc::RefCountInterface { |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 228 | public: |
Ivo Creusen | ae02609 | 2017-11-20 13:07:16 +0100 | [diff] [blame] | 229 | // Deprecated, use AudioProcessorStatistics instead. |
| 230 | // TODO(ivoc): Remove this when all implementations have switched to the new |
| 231 | // GetStats function. See b/67926135. |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 232 | struct AudioProcessorStats { |
ivoc | 4e477a1 | 2017-01-15 08:29:46 -0800 | [diff] [blame] | 233 | AudioProcessorStats() |
| 234 | : typing_noise_detected(false), |
| 235 | echo_return_loss(0), |
| 236 | echo_return_loss_enhancement(0), |
| 237 | echo_delay_median_ms(0), |
| 238 | echo_delay_std_ms(0), |
ivoc | 4e477a1 | 2017-01-15 08:29:46 -0800 | [diff] [blame] | 239 | residual_echo_likelihood(0.0f), |
| 240 | residual_echo_likelihood_recent_max(0.0f), |
| 241 | aec_divergent_filter_fraction(0.0) {} |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 242 | ~AudioProcessorStats() {} |
| 243 | |
| 244 | bool typing_noise_detected; |
| 245 | int echo_return_loss; |
| 246 | int echo_return_loss_enhancement; |
| 247 | int echo_delay_median_ms; |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 248 | int echo_delay_std_ms; |
ivoc | 8c63a82 | 2016-10-21 04:10:03 -0700 | [diff] [blame] | 249 | float residual_echo_likelihood; |
ivoc | 4e477a1 | 2017-01-15 08:29:46 -0800 | [diff] [blame] | 250 | float residual_echo_likelihood_recent_max; |
Minyue | 2a8a78c | 2016-04-07 16:48:15 +0200 | [diff] [blame] | 251 | float aec_divergent_filter_fraction; |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 252 | }; |
Ivo Creusen | ae02609 | 2017-11-20 13:07:16 +0100 | [diff] [blame] | 253 | // This struct maintains the optionality of the stats, and will replace the |
| 254 | // regular stats struct when all users have been updated. |
| 255 | struct AudioProcessorStatistics { |
| 256 | bool typing_noise_detected = false; |
Ivo Creusen | 56d4609 | 2017-11-24 17:29:59 +0100 | [diff] [blame] | 257 | AudioProcessingStats apm_statistics; |
Ivo Creusen | ae02609 | 2017-11-20 13:07:16 +0100 | [diff] [blame] | 258 | }; |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 259 | |
| 260 | // Get audio processor statistics. |
Ivo Creusen | 21eb9fc | 2017-12-12 10:45:51 +0100 | [diff] [blame] | 261 | virtual void GetStats(AudioProcessorStats* stats); |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 262 | |
Ivo Creusen | ae02609 | 2017-11-20 13:07:16 +0100 | [diff] [blame] | 263 | // Get audio processor statistics. The |has_remote_tracks| argument should be |
| 264 | // set if there are active remote tracks (this would usually be true during |
| 265 | // a call). If there are no remote tracks some of the stats will not be set by |
| 266 | // the AudioProcessor, because they only make sense if there is at least one |
| 267 | // remote track. |
| 268 | // TODO(ivoc): Make pure virtual when all implementions are updated. |
| 269 | virtual AudioProcessorStatistics GetStats(bool has_remote_tracks); |
| 270 | |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 271 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 09:38:31 +0100 | [diff] [blame] | 272 | ~AudioProcessorInterface() override = default; |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 273 | }; |
| 274 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 275 | class AudioTrackInterface : public MediaStreamTrackInterface { |
| 276 | public: |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 277 | // TODO(deadbeef): Figure out if the following interface should be const or |
| 278 | // not. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 279 | virtual AudioSourceInterface* GetSource() const = 0; |
| 280 | |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 281 | // Add/Remove a sink that will receive the audio data from the track. |
| 282 | virtual void AddSink(AudioTrackSinkInterface* sink) = 0; |
| 283 | virtual void RemoveSink(AudioTrackSinkInterface* sink) = 0; |
mallinath@webrtc.org | 67ee6b9 | 2014-02-03 16:57:16 +0000 | [diff] [blame] | 284 | |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 285 | // Get the signal level from the audio track. |
| 286 | // Return true on success, otherwise false. |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 287 | // TODO(deadbeef): Change the interface to int GetSignalLevel() and pure |
| 288 | // virtual after it's implemented in chromium. |
Danil Chapovalov | 2a5ce2b | 2018-02-07 09:38:31 +0100 | [diff] [blame] | 289 | virtual bool GetSignalLevel(int* level); |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 290 | |
deadbeef | 8d60a94 | 2017-02-27 14:47:33 -0800 | [diff] [blame] | 291 | // Get the audio processor used by the audio track. Return null if the track |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 292 | // does not have any processor. |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 293 | // TODO(deadbeef): Make the interface pure virtual. |
Danil Chapovalov | 2a5ce2b | 2018-02-07 09:38:31 +0100 | [diff] [blame] | 294 | virtual rtc::scoped_refptr<AudioProcessorInterface> GetAudioProcessor(); |
henrike@webrtc.org | 40b3b68 | 2014-03-03 18:30:11 +0000 | [diff] [blame] | 295 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 296 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 09:38:31 +0100 | [diff] [blame] | 297 | ~AudioTrackInterface() override = default; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 298 | }; |
| 299 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 300 | typedef std::vector<rtc::scoped_refptr<AudioTrackInterface> > |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 301 | AudioTrackVector; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 302 | typedef std::vector<rtc::scoped_refptr<VideoTrackInterface> > |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 303 | VideoTrackVector; |
| 304 | |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 305 | // C++ version of https://www.w3.org/TR/mediacapture-streams/#mediastream. |
| 306 | // |
| 307 | // A major difference is that remote audio/video tracks (received by a |
| 308 | // PeerConnection/RtpReceiver) are not synchronized simply by adding them to |
| 309 | // the same stream; a session description with the correct "a=msid" attributes |
| 310 | // must be pushed down. |
| 311 | // |
| 312 | // Thus, this interface acts as simply a container for tracks. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 313 | class MediaStreamInterface : public rtc::RefCountInterface, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 314 | public NotifierInterface { |
| 315 | public: |
Seth Hampson | 13b8bad | 2018-03-13 16:05:28 -0700 | [diff] [blame] | 316 | virtual std::string id() const = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 317 | |
| 318 | virtual AudioTrackVector GetAudioTracks() = 0; |
| 319 | virtual VideoTrackVector GetVideoTracks() = 0; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 320 | virtual rtc::scoped_refptr<AudioTrackInterface> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 321 | FindAudioTrack(const std::string& track_id) = 0; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 322 | virtual rtc::scoped_refptr<VideoTrackInterface> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 323 | FindVideoTrack(const std::string& track_id) = 0; |
| 324 | |
| 325 | virtual bool AddTrack(AudioTrackInterface* track) = 0; |
| 326 | virtual bool AddTrack(VideoTrackInterface* track) = 0; |
| 327 | virtual bool RemoveTrack(AudioTrackInterface* track) = 0; |
| 328 | virtual bool RemoveTrack(VideoTrackInterface* track) = 0; |
| 329 | |
| 330 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 09:38:31 +0100 | [diff] [blame] | 331 | ~MediaStreamInterface() override = default; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 332 | }; |
| 333 | |
| 334 | } // namespace webrtc |
| 335 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 336 | #endif // API_MEDIASTREAMINTERFACE_H_ |