henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
| 3 | * Copyright 2004 Google Inc. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #ifndef TALK_MEDIA_BASE_MEDIACHANNEL_H_ |
| 29 | #define TALK_MEDIA_BASE_MEDIACHANNEL_H_ |
| 30 | |
| 31 | #include <string> |
| 32 | #include <vector> |
| 33 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 34 | #include "webrtc/base/basictypes.h" |
| 35 | #include "webrtc/base/buffer.h" |
| 36 | #include "webrtc/base/dscp.h" |
| 37 | #include "webrtc/base/logging.h" |
| 38 | #include "webrtc/base/sigslot.h" |
| 39 | #include "webrtc/base/socket.h" |
| 40 | #include "webrtc/base/window.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 41 | #include "talk/media/base/codec.h" |
| 42 | #include "talk/media/base/constants.h" |
| 43 | #include "talk/media/base/streamparams.h" |
| 44 | // TODO(juberti): re-evaluate this include |
| 45 | #include "talk/session/media/audiomonitor.h" |
| 46 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 47 | namespace rtc { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 48 | class Buffer; |
| 49 | class RateLimiter; |
| 50 | class Timing; |
| 51 | } |
| 52 | |
| 53 | namespace cricket { |
| 54 | |
| 55 | class AudioRenderer; |
| 56 | struct RtpHeader; |
| 57 | class ScreencastId; |
| 58 | struct VideoFormat; |
| 59 | class VideoCapturer; |
| 60 | class VideoRenderer; |
| 61 | |
| 62 | const int kMinRtpHeaderExtensionId = 1; |
| 63 | const int kMaxRtpHeaderExtensionId = 255; |
| 64 | const int kScreencastDefaultFps = 5; |
wu@webrtc.org | cfe5e9c | 2014-03-27 17:03:58 +0000 | [diff] [blame] | 65 | const int kHighStartBitrate = 1500; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 66 | |
| 67 | // Used in AudioOptions and VideoOptions to signify "unset" values. |
| 68 | template <class T> |
| 69 | class Settable { |
| 70 | public: |
| 71 | Settable() : set_(false), val_() {} |
| 72 | explicit Settable(T val) : set_(true), val_(val) {} |
| 73 | |
| 74 | bool IsSet() const { |
| 75 | return set_; |
| 76 | } |
| 77 | |
| 78 | bool Get(T* out) const { |
| 79 | *out = val_; |
| 80 | return set_; |
| 81 | } |
| 82 | |
| 83 | T GetWithDefaultIfUnset(const T& default_value) const { |
| 84 | return set_ ? val_ : default_value; |
| 85 | } |
| 86 | |
| 87 | virtual void Set(T val) { |
| 88 | set_ = true; |
| 89 | val_ = val; |
| 90 | } |
| 91 | |
| 92 | void Clear() { |
| 93 | Set(T()); |
| 94 | set_ = false; |
| 95 | } |
| 96 | |
| 97 | void SetFrom(const Settable<T>& o) { |
| 98 | // Set this value based on the value of o, iff o is set. If this value is |
| 99 | // set and o is unset, the current value will be unchanged. |
| 100 | T val; |
| 101 | if (o.Get(&val)) { |
| 102 | Set(val); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | std::string ToString() const { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 107 | return set_ ? rtc::ToString(val_) : ""; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | bool operator==(const Settable<T>& o) const { |
| 111 | // Equal if both are unset with any value or both set with the same value. |
| 112 | return (set_ == o.set_) && (!set_ || (val_ == o.val_)); |
| 113 | } |
| 114 | |
| 115 | bool operator!=(const Settable<T>& o) const { |
| 116 | return !operator==(o); |
| 117 | } |
| 118 | |
| 119 | protected: |
| 120 | void InitializeValue(const T &val) { |
| 121 | val_ = val; |
| 122 | } |
| 123 | |
| 124 | private: |
| 125 | bool set_; |
| 126 | T val_; |
| 127 | }; |
| 128 | |
| 129 | class SettablePercent : public Settable<float> { |
| 130 | public: |
| 131 | virtual void Set(float val) { |
| 132 | if (val < 0) { |
| 133 | val = 0; |
| 134 | } |
| 135 | if (val > 1.0) { |
| 136 | val = 1.0; |
| 137 | } |
| 138 | Settable<float>::Set(val); |
| 139 | } |
| 140 | }; |
| 141 | |
| 142 | template <class T> |
| 143 | static std::string ToStringIfSet(const char* key, const Settable<T>& val) { |
| 144 | std::string str; |
| 145 | if (val.IsSet()) { |
| 146 | str = key; |
| 147 | str += ": "; |
| 148 | str += val.ToString(); |
| 149 | str += ", "; |
| 150 | } |
| 151 | return str; |
| 152 | } |
| 153 | |
| 154 | // Options that can be applied to a VoiceMediaChannel or a VoiceMediaEngine. |
| 155 | // Used to be flags, but that makes it hard to selectively apply options. |
| 156 | // We are moving all of the setting of options to structs like this, |
| 157 | // but some things currently still use flags. |
| 158 | struct AudioOptions { |
| 159 | void SetAll(const AudioOptions& change) { |
| 160 | echo_cancellation.SetFrom(change.echo_cancellation); |
| 161 | auto_gain_control.SetFrom(change.auto_gain_control); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 162 | rx_auto_gain_control.SetFrom(change.rx_auto_gain_control); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 163 | noise_suppression.SetFrom(change.noise_suppression); |
| 164 | highpass_filter.SetFrom(change.highpass_filter); |
| 165 | stereo_swapping.SetFrom(change.stereo_swapping); |
| 166 | typing_detection.SetFrom(change.typing_detection); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 167 | aecm_generate_comfort_noise.SetFrom(change.aecm_generate_comfort_noise); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 168 | conference_mode.SetFrom(change.conference_mode); |
| 169 | adjust_agc_delta.SetFrom(change.adjust_agc_delta); |
| 170 | experimental_agc.SetFrom(change.experimental_agc); |
| 171 | experimental_aec.SetFrom(change.experimental_aec); |
sergeyu@chromium.org | 9cf037b | 2014-02-07 19:03:26 +0000 | [diff] [blame] | 172 | experimental_ns.SetFrom(change.experimental_ns); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 173 | aec_dump.SetFrom(change.aec_dump); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 174 | tx_agc_target_dbov.SetFrom(change.tx_agc_target_dbov); |
| 175 | tx_agc_digital_compression_gain.SetFrom( |
| 176 | change.tx_agc_digital_compression_gain); |
| 177 | tx_agc_limiter.SetFrom(change.tx_agc_limiter); |
| 178 | rx_agc_target_dbov.SetFrom(change.rx_agc_target_dbov); |
| 179 | rx_agc_digital_compression_gain.SetFrom( |
| 180 | change.rx_agc_digital_compression_gain); |
| 181 | rx_agc_limiter.SetFrom(change.rx_agc_limiter); |
| 182 | recording_sample_rate.SetFrom(change.recording_sample_rate); |
| 183 | playout_sample_rate.SetFrom(change.playout_sample_rate); |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 184 | dscp.SetFrom(change.dscp); |
buildbot@webrtc.org | d27d9ae | 2014-06-19 01:56:46 +0000 | [diff] [blame] | 185 | opus_fec.SetFrom(change.opus_fec); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | bool operator==(const AudioOptions& o) const { |
| 189 | return echo_cancellation == o.echo_cancellation && |
| 190 | auto_gain_control == o.auto_gain_control && |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 191 | rx_auto_gain_control == o.rx_auto_gain_control && |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 192 | noise_suppression == o.noise_suppression && |
| 193 | highpass_filter == o.highpass_filter && |
| 194 | stereo_swapping == o.stereo_swapping && |
| 195 | typing_detection == o.typing_detection && |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 196 | aecm_generate_comfort_noise == o.aecm_generate_comfort_noise && |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 197 | conference_mode == o.conference_mode && |
| 198 | experimental_agc == o.experimental_agc && |
| 199 | experimental_aec == o.experimental_aec && |
sergeyu@chromium.org | 9cf037b | 2014-02-07 19:03:26 +0000 | [diff] [blame] | 200 | experimental_ns == o.experimental_ns && |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 201 | adjust_agc_delta == o.adjust_agc_delta && |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 202 | aec_dump == o.aec_dump && |
| 203 | tx_agc_target_dbov == o.tx_agc_target_dbov && |
| 204 | tx_agc_digital_compression_gain == o.tx_agc_digital_compression_gain && |
| 205 | tx_agc_limiter == o.tx_agc_limiter && |
| 206 | rx_agc_target_dbov == o.rx_agc_target_dbov && |
| 207 | rx_agc_digital_compression_gain == o.rx_agc_digital_compression_gain && |
| 208 | rx_agc_limiter == o.rx_agc_limiter && |
| 209 | recording_sample_rate == o.recording_sample_rate && |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 210 | playout_sample_rate == o.playout_sample_rate && |
buildbot@webrtc.org | d27d9ae | 2014-06-19 01:56:46 +0000 | [diff] [blame] | 211 | dscp == o.dscp && |
| 212 | opus_fec == o.opus_fec; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | std::string ToString() const { |
| 216 | std::ostringstream ost; |
| 217 | ost << "AudioOptions {"; |
| 218 | ost << ToStringIfSet("aec", echo_cancellation); |
| 219 | ost << ToStringIfSet("agc", auto_gain_control); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 220 | ost << ToStringIfSet("rx_agc", rx_auto_gain_control); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 221 | ost << ToStringIfSet("ns", noise_suppression); |
| 222 | ost << ToStringIfSet("hf", highpass_filter); |
| 223 | ost << ToStringIfSet("swap", stereo_swapping); |
| 224 | ost << ToStringIfSet("typing", typing_detection); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 225 | ost << ToStringIfSet("comfort_noise", aecm_generate_comfort_noise); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 226 | ost << ToStringIfSet("conference", conference_mode); |
| 227 | ost << ToStringIfSet("agc_delta", adjust_agc_delta); |
| 228 | ost << ToStringIfSet("experimental_agc", experimental_agc); |
| 229 | ost << ToStringIfSet("experimental_aec", experimental_aec); |
sergeyu@chromium.org | 9cf037b | 2014-02-07 19:03:26 +0000 | [diff] [blame] | 230 | ost << ToStringIfSet("experimental_ns", experimental_ns); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 231 | ost << ToStringIfSet("aec_dump", aec_dump); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 232 | ost << ToStringIfSet("tx_agc_target_dbov", tx_agc_target_dbov); |
| 233 | ost << ToStringIfSet("tx_agc_digital_compression_gain", |
| 234 | tx_agc_digital_compression_gain); |
| 235 | ost << ToStringIfSet("tx_agc_limiter", tx_agc_limiter); |
| 236 | ost << ToStringIfSet("rx_agc_target_dbov", rx_agc_target_dbov); |
| 237 | ost << ToStringIfSet("rx_agc_digital_compression_gain", |
| 238 | rx_agc_digital_compression_gain); |
| 239 | ost << ToStringIfSet("rx_agc_limiter", rx_agc_limiter); |
| 240 | ost << ToStringIfSet("recording_sample_rate", recording_sample_rate); |
| 241 | ost << ToStringIfSet("playout_sample_rate", playout_sample_rate); |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 242 | ost << ToStringIfSet("dscp", dscp); |
buildbot@webrtc.org | d27d9ae | 2014-06-19 01:56:46 +0000 | [diff] [blame] | 243 | ost << ToStringIfSet("opus_fec", opus_fec); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 244 | ost << "}"; |
| 245 | return ost.str(); |
| 246 | } |
| 247 | |
| 248 | // Audio processing that attempts to filter away the output signal from |
| 249 | // later inbound pickup. |
| 250 | Settable<bool> echo_cancellation; |
| 251 | // Audio processing to adjust the sensitivity of the local mic dynamically. |
| 252 | Settable<bool> auto_gain_control; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 253 | // Audio processing to apply gain to the remote audio. |
| 254 | Settable<bool> rx_auto_gain_control; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 255 | // Audio processing to filter out background noise. |
| 256 | Settable<bool> noise_suppression; |
| 257 | // Audio processing to remove background noise of lower frequencies. |
| 258 | Settable<bool> highpass_filter; |
| 259 | // Audio processing to swap the left and right channels. |
| 260 | Settable<bool> stereo_swapping; |
| 261 | // Audio processing to detect typing. |
| 262 | Settable<bool> typing_detection; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 263 | Settable<bool> aecm_generate_comfort_noise; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 264 | Settable<bool> conference_mode; |
| 265 | Settable<int> adjust_agc_delta; |
| 266 | Settable<bool> experimental_agc; |
| 267 | Settable<bool> experimental_aec; |
sergeyu@chromium.org | 9cf037b | 2014-02-07 19:03:26 +0000 | [diff] [blame] | 268 | Settable<bool> experimental_ns; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 269 | Settable<bool> aec_dump; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 270 | // Note that tx_agc_* only applies to non-experimental AGC. |
| 271 | Settable<uint16> tx_agc_target_dbov; |
| 272 | Settable<uint16> tx_agc_digital_compression_gain; |
| 273 | Settable<bool> tx_agc_limiter; |
| 274 | Settable<uint16> rx_agc_target_dbov; |
| 275 | Settable<uint16> rx_agc_digital_compression_gain; |
| 276 | Settable<bool> rx_agc_limiter; |
| 277 | Settable<uint32> recording_sample_rate; |
| 278 | Settable<uint32> playout_sample_rate; |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 279 | // Set DSCP value for packet sent from audio channel. |
| 280 | Settable<bool> dscp; |
buildbot@webrtc.org | d27d9ae | 2014-06-19 01:56:46 +0000 | [diff] [blame] | 281 | // Set Opus FEC |
| 282 | Settable<bool> opus_fec; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 283 | }; |
| 284 | |
| 285 | // Options that can be applied to a VideoMediaChannel or a VideoMediaEngine. |
| 286 | // Used to be flags, but that makes it hard to selectively apply options. |
| 287 | // We are moving all of the setting of options to structs like this, |
| 288 | // but some things currently still use flags. |
| 289 | struct VideoOptions { |
henrike@webrtc.org | f45a550 | 2014-03-13 18:51:34 +0000 | [diff] [blame] | 290 | enum HighestBitrate { |
| 291 | NORMAL, |
| 292 | HIGH, |
| 293 | VERY_HIGH |
| 294 | }; |
| 295 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 296 | VideoOptions() { |
| 297 | process_adaptation_threshhold.Set(kProcessCpuThreshold); |
| 298 | system_low_adaptation_threshhold.Set(kLowSystemCpuThreshold); |
| 299 | system_high_adaptation_threshhold.Set(kHighSystemCpuThreshold); |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 300 | unsignalled_recv_stream_limit.Set(kNumDefaultUnsignalledVideoRecvStreams); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | void SetAll(const VideoOptions& change) { |
| 304 | adapt_input_to_encoder.SetFrom(change.adapt_input_to_encoder); |
| 305 | adapt_input_to_cpu_usage.SetFrom(change.adapt_input_to_cpu_usage); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 306 | adapt_cpu_with_smoothing.SetFrom(change.adapt_cpu_with_smoothing); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 307 | adapt_view_switch.SetFrom(change.adapt_view_switch); |
wu@webrtc.org | cadf904 | 2013-08-30 21:24:16 +0000 | [diff] [blame] | 308 | video_adapt_third.SetFrom(change.video_adapt_third); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 309 | video_noise_reduction.SetFrom(change.video_noise_reduction); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 310 | video_one_layer_screencast.SetFrom(change.video_one_layer_screencast); |
| 311 | video_high_bitrate.SetFrom(change.video_high_bitrate); |
wu@webrtc.org | 1e6cb2c | 2014-03-24 17:01:50 +0000 | [diff] [blame] | 312 | video_start_bitrate.SetFrom(change.video_start_bitrate); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 313 | video_temporal_layer_screencast.SetFrom( |
| 314 | change.video_temporal_layer_screencast); |
| 315 | video_leaky_bucket.SetFrom(change.video_leaky_bucket); |
henrike@webrtc.org | f45a550 | 2014-03-13 18:51:34 +0000 | [diff] [blame] | 316 | video_highest_bitrate.SetFrom(change.video_highest_bitrate); |
wu@webrtc.org | cadf904 | 2013-08-30 21:24:16 +0000 | [diff] [blame] | 317 | cpu_overuse_detection.SetFrom(change.cpu_overuse_detection); |
henrike@webrtc.org | e9793ab | 2014-03-18 14:36:23 +0000 | [diff] [blame] | 318 | cpu_underuse_threshold.SetFrom(change.cpu_underuse_threshold); |
| 319 | cpu_overuse_threshold.SetFrom(change.cpu_overuse_threshold); |
buildbot@webrtc.org | 27626a6 | 2014-06-16 13:39:40 +0000 | [diff] [blame] | 320 | cpu_underuse_encode_rsd_threshold.SetFrom( |
| 321 | change.cpu_underuse_encode_rsd_threshold); |
| 322 | cpu_overuse_encode_rsd_threshold.SetFrom( |
| 323 | change.cpu_overuse_encode_rsd_threshold); |
henrike@webrtc.org | b0ecc1c | 2014-03-26 22:44:28 +0000 | [diff] [blame] | 324 | cpu_overuse_encode_usage.SetFrom(change.cpu_overuse_encode_usage); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 325 | conference_mode.SetFrom(change.conference_mode); |
| 326 | process_adaptation_threshhold.SetFrom(change.process_adaptation_threshhold); |
| 327 | system_low_adaptation_threshhold.SetFrom( |
| 328 | change.system_low_adaptation_threshhold); |
| 329 | system_high_adaptation_threshhold.SetFrom( |
| 330 | change.system_high_adaptation_threshhold); |
| 331 | buffered_mode_latency.SetFrom(change.buffered_mode_latency); |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 332 | dscp.SetFrom(change.dscp); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 333 | suspend_below_min_bitrate.SetFrom(change.suspend_below_min_bitrate); |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 334 | unsignalled_recv_stream_limit.SetFrom(change.unsignalled_recv_stream_limit); |
henrike@webrtc.org | 10bd88e | 2014-03-11 21:07:25 +0000 | [diff] [blame] | 335 | use_simulcast_adapter.SetFrom(change.use_simulcast_adapter); |
henrike@webrtc.org | dce3feb | 2014-03-26 01:17:30 +0000 | [diff] [blame] | 336 | screencast_min_bitrate.SetFrom(change.screencast_min_bitrate); |
| 337 | use_improved_wifi_bandwidth_estimator.SetFrom( |
| 338 | change.use_improved_wifi_bandwidth_estimator); |
buildbot@webrtc.org | 44a317a | 2014-06-17 07:49:15 +0000 | [diff] [blame] | 339 | use_payload_padding.SetFrom(change.use_payload_padding); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | bool operator==(const VideoOptions& o) const { |
| 343 | return adapt_input_to_encoder == o.adapt_input_to_encoder && |
| 344 | adapt_input_to_cpu_usage == o.adapt_input_to_cpu_usage && |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 345 | adapt_cpu_with_smoothing == o.adapt_cpu_with_smoothing && |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 346 | adapt_view_switch == o.adapt_view_switch && |
wu@webrtc.org | cadf904 | 2013-08-30 21:24:16 +0000 | [diff] [blame] | 347 | video_adapt_third == o.video_adapt_third && |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 348 | video_noise_reduction == o.video_noise_reduction && |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 349 | video_one_layer_screencast == o.video_one_layer_screencast && |
| 350 | video_high_bitrate == o.video_high_bitrate && |
wu@webrtc.org | 1e6cb2c | 2014-03-24 17:01:50 +0000 | [diff] [blame] | 351 | video_start_bitrate == o.video_start_bitrate && |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 352 | video_temporal_layer_screencast == o.video_temporal_layer_screencast && |
| 353 | video_leaky_bucket == o.video_leaky_bucket && |
henrike@webrtc.org | f45a550 | 2014-03-13 18:51:34 +0000 | [diff] [blame] | 354 | video_highest_bitrate == o.video_highest_bitrate && |
wu@webrtc.org | cadf904 | 2013-08-30 21:24:16 +0000 | [diff] [blame] | 355 | cpu_overuse_detection == o.cpu_overuse_detection && |
henrike@webrtc.org | e9793ab | 2014-03-18 14:36:23 +0000 | [diff] [blame] | 356 | cpu_underuse_threshold == o.cpu_underuse_threshold && |
| 357 | cpu_overuse_threshold == o.cpu_overuse_threshold && |
buildbot@webrtc.org | 27626a6 | 2014-06-16 13:39:40 +0000 | [diff] [blame] | 358 | cpu_underuse_encode_rsd_threshold == |
| 359 | o.cpu_underuse_encode_rsd_threshold && |
| 360 | cpu_overuse_encode_rsd_threshold == |
| 361 | o.cpu_overuse_encode_rsd_threshold && |
henrike@webrtc.org | b0ecc1c | 2014-03-26 22:44:28 +0000 | [diff] [blame] | 362 | cpu_overuse_encode_usage == o.cpu_overuse_encode_usage && |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 363 | conference_mode == o.conference_mode && |
| 364 | process_adaptation_threshhold == o.process_adaptation_threshhold && |
| 365 | system_low_adaptation_threshhold == |
| 366 | o.system_low_adaptation_threshhold && |
| 367 | system_high_adaptation_threshhold == |
| 368 | o.system_high_adaptation_threshhold && |
wu@webrtc.org | cecfd18 | 2013-10-30 05:18:12 +0000 | [diff] [blame] | 369 | buffered_mode_latency == o.buffered_mode_latency && |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 370 | dscp == o.dscp && |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 371 | suspend_below_min_bitrate == o.suspend_below_min_bitrate && |
henrike@webrtc.org | 10bd88e | 2014-03-11 21:07:25 +0000 | [diff] [blame] | 372 | unsignalled_recv_stream_limit == o.unsignalled_recv_stream_limit && |
henrike@webrtc.org | dce3feb | 2014-03-26 01:17:30 +0000 | [diff] [blame] | 373 | use_simulcast_adapter == o.use_simulcast_adapter && |
henrike@webrtc.org | 5fb7428 | 2014-03-26 02:00:10 +0000 | [diff] [blame] | 374 | screencast_min_bitrate == o.screencast_min_bitrate && |
henrike@webrtc.org | dce3feb | 2014-03-26 01:17:30 +0000 | [diff] [blame] | 375 | use_improved_wifi_bandwidth_estimator == |
buildbot@webrtc.org | 44a317a | 2014-06-17 07:49:15 +0000 | [diff] [blame] | 376 | o.use_improved_wifi_bandwidth_estimator && |
| 377 | use_payload_padding == o.use_payload_padding; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | std::string ToString() const { |
| 381 | std::ostringstream ost; |
| 382 | ost << "VideoOptions {"; |
| 383 | ost << ToStringIfSet("encoder adaption", adapt_input_to_encoder); |
| 384 | ost << ToStringIfSet("cpu adaption", adapt_input_to_cpu_usage); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 385 | ost << ToStringIfSet("cpu adaptation smoothing", adapt_cpu_with_smoothing); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 386 | ost << ToStringIfSet("adapt view switch", adapt_view_switch); |
wu@webrtc.org | cadf904 | 2013-08-30 21:24:16 +0000 | [diff] [blame] | 387 | ost << ToStringIfSet("video adapt third", video_adapt_third); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 388 | ost << ToStringIfSet("noise reduction", video_noise_reduction); |
wu@webrtc.org | cadf904 | 2013-08-30 21:24:16 +0000 | [diff] [blame] | 389 | ost << ToStringIfSet("1 layer screencast", video_one_layer_screencast); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 390 | ost << ToStringIfSet("high bitrate", video_high_bitrate); |
wu@webrtc.org | 1e6cb2c | 2014-03-24 17:01:50 +0000 | [diff] [blame] | 391 | ost << ToStringIfSet("start bitrate", video_start_bitrate); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 392 | ost << ToStringIfSet("video temporal layer screencast", |
| 393 | video_temporal_layer_screencast); |
| 394 | ost << ToStringIfSet("leaky bucket", video_leaky_bucket); |
henrike@webrtc.org | f45a550 | 2014-03-13 18:51:34 +0000 | [diff] [blame] | 395 | ost << ToStringIfSet("highest video bitrate", video_highest_bitrate); |
wu@webrtc.org | cadf904 | 2013-08-30 21:24:16 +0000 | [diff] [blame] | 396 | ost << ToStringIfSet("cpu overuse detection", cpu_overuse_detection); |
henrike@webrtc.org | e9793ab | 2014-03-18 14:36:23 +0000 | [diff] [blame] | 397 | ost << ToStringIfSet("cpu underuse threshold", cpu_underuse_threshold); |
| 398 | ost << ToStringIfSet("cpu overuse threshold", cpu_overuse_threshold); |
buildbot@webrtc.org | 27626a6 | 2014-06-16 13:39:40 +0000 | [diff] [blame] | 399 | ost << ToStringIfSet("cpu underuse encode rsd threshold", |
| 400 | cpu_underuse_encode_rsd_threshold); |
| 401 | ost << ToStringIfSet("cpu overuse encode rsd threshold", |
| 402 | cpu_overuse_encode_rsd_threshold); |
henrike@webrtc.org | b0ecc1c | 2014-03-26 22:44:28 +0000 | [diff] [blame] | 403 | ost << ToStringIfSet("cpu overuse encode usage", |
| 404 | cpu_overuse_encode_usage); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 405 | ost << ToStringIfSet("conference mode", conference_mode); |
| 406 | ost << ToStringIfSet("process", process_adaptation_threshhold); |
| 407 | ost << ToStringIfSet("low", system_low_adaptation_threshhold); |
| 408 | ost << ToStringIfSet("high", system_high_adaptation_threshhold); |
| 409 | ost << ToStringIfSet("buffered mode latency", buffered_mode_latency); |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 410 | ost << ToStringIfSet("dscp", dscp); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 411 | ost << ToStringIfSet("suspend below min bitrate", |
| 412 | suspend_below_min_bitrate); |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 413 | ost << ToStringIfSet("num channels for early receive", |
| 414 | unsignalled_recv_stream_limit); |
henrike@webrtc.org | 10bd88e | 2014-03-11 21:07:25 +0000 | [diff] [blame] | 415 | ost << ToStringIfSet("use simulcast adapter", use_simulcast_adapter); |
henrike@webrtc.org | dce3feb | 2014-03-26 01:17:30 +0000 | [diff] [blame] | 416 | ost << ToStringIfSet("screencast min bitrate", screencast_min_bitrate); |
| 417 | ost << ToStringIfSet("improved wifi bwe", |
| 418 | use_improved_wifi_bandwidth_estimator); |
buildbot@webrtc.org | 44a317a | 2014-06-17 07:49:15 +0000 | [diff] [blame] | 419 | ost << ToStringIfSet("payload padding", use_payload_padding); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 420 | ost << "}"; |
| 421 | return ost.str(); |
| 422 | } |
| 423 | |
| 424 | // Encoder adaption, which is the gd callback in LMI, and TBA in WebRTC. |
| 425 | Settable<bool> adapt_input_to_encoder; |
| 426 | // Enable CPU adaptation? |
| 427 | Settable<bool> adapt_input_to_cpu_usage; |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 428 | // Enable CPU adaptation smoothing? |
| 429 | Settable<bool> adapt_cpu_with_smoothing; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 430 | // Enable Adapt View Switch? |
| 431 | Settable<bool> adapt_view_switch; |
wu@webrtc.org | cadf904 | 2013-08-30 21:24:16 +0000 | [diff] [blame] | 432 | // Enable video adapt third? |
| 433 | Settable<bool> video_adapt_third; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 434 | // Enable denoising? |
| 435 | Settable<bool> video_noise_reduction; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 436 | // Experimental: Enable one layer screencast? |
| 437 | Settable<bool> video_one_layer_screencast; |
| 438 | // Experimental: Enable WebRtc higher bitrate? |
| 439 | Settable<bool> video_high_bitrate; |
wu@webrtc.org | 1e6cb2c | 2014-03-24 17:01:50 +0000 | [diff] [blame] | 440 | // Experimental: Enable WebRtc higher start bitrate? |
| 441 | Settable<int> video_start_bitrate; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 442 | // Experimental: Enable WebRTC layered screencast. |
| 443 | Settable<bool> video_temporal_layer_screencast; |
| 444 | // Enable WebRTC leaky bucket when sending media packets. |
| 445 | Settable<bool> video_leaky_bucket; |
henrike@webrtc.org | f45a550 | 2014-03-13 18:51:34 +0000 | [diff] [blame] | 446 | // Set highest bitrate mode for video. |
wu@webrtc.org | cfe5e9c | 2014-03-27 17:03:58 +0000 | [diff] [blame] | 447 | Settable<HighestBitrate> video_highest_bitrate; |
wu@webrtc.org | cadf904 | 2013-08-30 21:24:16 +0000 | [diff] [blame] | 448 | // Enable WebRTC Cpu Overuse Detection, which is a new version of the CPU |
| 449 | // adaptation algorithm. So this option will override the |
| 450 | // |adapt_input_to_cpu_usage|. |
| 451 | Settable<bool> cpu_overuse_detection; |
buildbot@webrtc.org | 27626a6 | 2014-06-16 13:39:40 +0000 | [diff] [blame] | 452 | // Low threshold (t1) for cpu overuse adaptation. (Adapt up) |
| 453 | // Metric: encode usage (m1). m1 < t1 => underuse. |
henrike@webrtc.org | e9793ab | 2014-03-18 14:36:23 +0000 | [diff] [blame] | 454 | Settable<int> cpu_underuse_threshold; |
buildbot@webrtc.org | 27626a6 | 2014-06-16 13:39:40 +0000 | [diff] [blame] | 455 | // High threshold (t1) for cpu overuse adaptation. (Adapt down) |
| 456 | // Metric: encode usage (m1). m1 > t1 => overuse. |
henrike@webrtc.org | e9793ab | 2014-03-18 14:36:23 +0000 | [diff] [blame] | 457 | Settable<int> cpu_overuse_threshold; |
buildbot@webrtc.org | 27626a6 | 2014-06-16 13:39:40 +0000 | [diff] [blame] | 458 | // Low threshold (t2) for cpu overuse adaptation. (Adapt up) |
| 459 | // Metric: relative standard deviation of encode time (m2). |
| 460 | // Optional threshold. If set, (m1 < t1 && m2 < t2) => underuse. |
| 461 | // Note: t2 will have no effect if t1 is not set. |
| 462 | Settable<int> cpu_underuse_encode_rsd_threshold; |
| 463 | // High threshold (t2) for cpu overuse adaptation. (Adapt down) |
| 464 | // Metric: relative standard deviation of encode time (m2). |
| 465 | // Optional threshold. If set, (m1 > t1 || m2 > t2) => overuse. |
| 466 | // Note: t2 will have no effect if t1 is not set. |
| 467 | Settable<int> cpu_overuse_encode_rsd_threshold; |
henrike@webrtc.org | b0ecc1c | 2014-03-26 22:44:28 +0000 | [diff] [blame] | 468 | // Use encode usage for cpu detection. |
| 469 | Settable<bool> cpu_overuse_encode_usage; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 470 | // Use conference mode? |
| 471 | Settable<bool> conference_mode; |
| 472 | // Threshhold for process cpu adaptation. (Process limit) |
| 473 | SettablePercent process_adaptation_threshhold; |
| 474 | // Low threshhold for cpu adaptation. (Adapt up) |
| 475 | SettablePercent system_low_adaptation_threshhold; |
| 476 | // High threshhold for cpu adaptation. (Adapt down) |
| 477 | SettablePercent system_high_adaptation_threshhold; |
| 478 | // Specify buffered mode latency in milliseconds. |
| 479 | Settable<int> buffered_mode_latency; |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 480 | // Set DSCP value for packet sent from video channel. |
| 481 | Settable<bool> dscp; |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 482 | // Enable WebRTC suspension of video. No video frames will be sent when the |
| 483 | // bitrate is below the configured minimum bitrate. |
| 484 | Settable<bool> suspend_below_min_bitrate; |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 485 | // Limit on the number of early receive channels that can be created. |
| 486 | Settable<int> unsignalled_recv_stream_limit; |
henrike@webrtc.org | 10bd88e | 2014-03-11 21:07:25 +0000 | [diff] [blame] | 487 | // Enable use of simulcast adapter. |
| 488 | Settable<bool> use_simulcast_adapter; |
henrike@webrtc.org | dce3feb | 2014-03-26 01:17:30 +0000 | [diff] [blame] | 489 | // Force screencast to use a minimum bitrate |
| 490 | Settable<int> screencast_min_bitrate; |
| 491 | // Enable improved bandwidth estiamtor on wifi. |
| 492 | Settable<bool> use_improved_wifi_bandwidth_estimator; |
buildbot@webrtc.org | 44a317a | 2014-06-17 07:49:15 +0000 | [diff] [blame] | 493 | // Enable payload padding. |
| 494 | Settable<bool> use_payload_padding; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 495 | }; |
| 496 | |
| 497 | // A class for playing out soundclips. |
| 498 | class SoundclipMedia { |
| 499 | public: |
| 500 | enum SoundclipFlags { |
| 501 | SF_LOOP = 1, |
| 502 | }; |
| 503 | |
| 504 | virtual ~SoundclipMedia() {} |
| 505 | |
| 506 | // Plays a sound out to the speakers with the given audio stream. The stream |
| 507 | // must be 16-bit little-endian 16 kHz PCM. If a stream is already playing |
| 508 | // on this SoundclipMedia, it is stopped. If clip is NULL, nothing is played. |
| 509 | // Returns whether it was successful. |
| 510 | virtual bool PlaySound(const char *clip, int len, int flags) = 0; |
| 511 | }; |
| 512 | |
| 513 | struct RtpHeaderExtension { |
| 514 | RtpHeaderExtension() : id(0) {} |
| 515 | RtpHeaderExtension(const std::string& u, int i) : uri(u), id(i) {} |
| 516 | std::string uri; |
| 517 | int id; |
| 518 | // TODO(juberti): SendRecv direction; |
| 519 | |
| 520 | bool operator==(const RtpHeaderExtension& ext) const { |
| 521 | // id is a reserved word in objective-c. Therefore the id attribute has to |
| 522 | // be a fully qualified name in order to compile on IOS. |
| 523 | return this->id == ext.id && |
| 524 | uri == ext.uri; |
| 525 | } |
| 526 | }; |
| 527 | |
| 528 | // Returns the named header extension if found among all extensions, NULL |
| 529 | // otherwise. |
| 530 | inline const RtpHeaderExtension* FindHeaderExtension( |
| 531 | const std::vector<RtpHeaderExtension>& extensions, |
| 532 | const std::string& name) { |
| 533 | for (std::vector<RtpHeaderExtension>::const_iterator it = extensions.begin(); |
| 534 | it != extensions.end(); ++it) { |
| 535 | if (it->uri == name) |
| 536 | return &(*it); |
| 537 | } |
| 538 | return NULL; |
| 539 | } |
| 540 | |
| 541 | enum MediaChannelOptions { |
| 542 | // Tune the stream for conference mode. |
| 543 | OPT_CONFERENCE = 0x0001 |
| 544 | }; |
| 545 | |
| 546 | enum VoiceMediaChannelOptions { |
| 547 | // Tune the audio stream for vcs with different target levels. |
| 548 | OPT_AGC_MINUS_10DB = 0x80000000 |
| 549 | }; |
| 550 | |
| 551 | // DTMF flags to control if a DTMF tone should be played and/or sent. |
| 552 | enum DtmfFlags { |
| 553 | DF_PLAY = 0x01, |
| 554 | DF_SEND = 0x02, |
| 555 | }; |
| 556 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 557 | class MediaChannel : public sigslot::has_slots<> { |
| 558 | public: |
| 559 | class NetworkInterface { |
| 560 | public: |
| 561 | enum SocketType { ST_RTP, ST_RTCP }; |
mallinath@webrtc.org | 1112c30 | 2013-09-23 20:34:45 +0000 | [diff] [blame] | 562 | virtual bool SendPacket( |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 563 | rtc::Buffer* packet, |
| 564 | rtc::DiffServCodePoint dscp = rtc::DSCP_NO_CHANGE) = 0; |
mallinath@webrtc.org | 1112c30 | 2013-09-23 20:34:45 +0000 | [diff] [blame] | 565 | virtual bool SendRtcp( |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 566 | rtc::Buffer* packet, |
| 567 | rtc::DiffServCodePoint dscp = rtc::DSCP_NO_CHANGE) = 0; |
| 568 | virtual int SetOption(SocketType type, rtc::Socket::Option opt, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 569 | int option) = 0; |
| 570 | virtual ~NetworkInterface() {} |
| 571 | }; |
| 572 | |
| 573 | MediaChannel() : network_interface_(NULL) {} |
| 574 | virtual ~MediaChannel() {} |
| 575 | |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 576 | // Sets the abstract interface class for sending RTP/RTCP data. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 577 | virtual void SetInterface(NetworkInterface *iface) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 578 | rtc::CritScope cs(&network_interface_crit_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 579 | network_interface_ = iface; |
| 580 | } |
| 581 | |
| 582 | // Called when a RTP packet is received. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 583 | virtual void OnPacketReceived(rtc::Buffer* packet, |
| 584 | const rtc::PacketTime& packet_time) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 585 | // Called when a RTCP packet is received. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 586 | virtual void OnRtcpReceived(rtc::Buffer* packet, |
| 587 | const rtc::PacketTime& packet_time) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 588 | // Called when the socket's ability to send has changed. |
| 589 | virtual void OnReadyToSend(bool ready) = 0; |
| 590 | // Creates a new outgoing media stream with SSRCs and CNAME as described |
| 591 | // by sp. |
| 592 | virtual bool AddSendStream(const StreamParams& sp) = 0; |
| 593 | // Removes an outgoing media stream. |
| 594 | // ssrc must be the first SSRC of the media stream if the stream uses |
| 595 | // multiple SSRCs. |
| 596 | virtual bool RemoveSendStream(uint32 ssrc) = 0; |
| 597 | // Creates a new incoming media stream with SSRCs and CNAME as described |
| 598 | // by sp. |
| 599 | virtual bool AddRecvStream(const StreamParams& sp) = 0; |
| 600 | // Removes an incoming media stream. |
| 601 | // ssrc must be the first SSRC of the media stream if the stream uses |
| 602 | // multiple SSRCs. |
| 603 | virtual bool RemoveRecvStream(uint32 ssrc) = 0; |
| 604 | |
| 605 | // Mutes the channel. |
| 606 | virtual bool MuteStream(uint32 ssrc, bool on) = 0; |
| 607 | |
| 608 | // Sets the RTP extension headers and IDs to use when sending RTP. |
| 609 | virtual bool SetRecvRtpHeaderExtensions( |
| 610 | const std::vector<RtpHeaderExtension>& extensions) = 0; |
| 611 | virtual bool SetSendRtpHeaderExtensions( |
| 612 | const std::vector<RtpHeaderExtension>& extensions) = 0; |
mallinath@webrtc.org | 92fdfeb | 2014-02-17 18:49:41 +0000 | [diff] [blame] | 613 | // Returns the absoulte sendtime extension id value from media channel. |
| 614 | virtual int GetRtpSendTimeExtnId() const { |
| 615 | return -1; |
| 616 | } |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 617 | // Sets the initial bandwidth to use when sending starts. |
| 618 | virtual bool SetStartSendBandwidth(int bps) = 0; |
| 619 | // Sets the maximum allowed bandwidth to use when sending data. |
| 620 | virtual bool SetMaxSendBandwidth(int bps) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 621 | |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 622 | // Base method to send packet using NetworkInterface. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 623 | bool SendPacket(rtc::Buffer* packet) { |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 624 | return DoSendPacket(packet, false); |
| 625 | } |
| 626 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 627 | bool SendRtcp(rtc::Buffer* packet) { |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 628 | return DoSendPacket(packet, true); |
| 629 | } |
| 630 | |
| 631 | int SetOption(NetworkInterface::SocketType type, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 632 | rtc::Socket::Option opt, |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 633 | int option) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 634 | rtc::CritScope cs(&network_interface_crit_); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 635 | if (!network_interface_) |
| 636 | return -1; |
| 637 | |
| 638 | return network_interface_->SetOption(type, opt, option); |
| 639 | } |
| 640 | |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 641 | protected: |
| 642 | // This method sets DSCP |value| on both RTP and RTCP channels. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 643 | int SetDscp(rtc::DiffServCodePoint value) { |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 644 | int ret; |
| 645 | ret = SetOption(NetworkInterface::ST_RTP, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 646 | rtc::Socket::OPT_DSCP, |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 647 | value); |
| 648 | if (ret == 0) { |
| 649 | ret = SetOption(NetworkInterface::ST_RTCP, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 650 | rtc::Socket::OPT_DSCP, |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 651 | value); |
| 652 | } |
| 653 | return ret; |
| 654 | } |
| 655 | |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 656 | private: |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 657 | bool DoSendPacket(rtc::Buffer* packet, bool rtcp) { |
| 658 | rtc::CritScope cs(&network_interface_crit_); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 659 | if (!network_interface_) |
| 660 | return false; |
| 661 | |
| 662 | return (!rtcp) ? network_interface_->SendPacket(packet) : |
| 663 | network_interface_->SendRtcp(packet); |
| 664 | } |
| 665 | |
| 666 | // |network_interface_| can be accessed from the worker_thread and |
| 667 | // from any MediaEngine threads. This critical section is to protect accessing |
| 668 | // of network_interface_ object. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 669 | rtc::CriticalSection network_interface_crit_; |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 670 | NetworkInterface* network_interface_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 671 | }; |
| 672 | |
| 673 | enum SendFlags { |
| 674 | SEND_NOTHING, |
| 675 | SEND_RINGBACKTONE, |
| 676 | SEND_MICROPHONE |
| 677 | }; |
| 678 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 679 | // The stats information is structured as follows: |
| 680 | // Media are represented by either MediaSenderInfo or MediaReceiverInfo. |
| 681 | // Media contains a vector of SSRC infos that are exclusively used by this |
| 682 | // media. (SSRCs shared between media streams can't be represented.) |
| 683 | |
| 684 | // Information about an SSRC. |
| 685 | // This data may be locally recorded, or received in an RTCP SR or RR. |
| 686 | struct SsrcSenderInfo { |
| 687 | SsrcSenderInfo() |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 688 | : ssrc(0), |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 689 | timestamp(0) { |
| 690 | } |
| 691 | uint32 ssrc; |
| 692 | double timestamp; // NTP timestamp, represented as seconds since epoch. |
| 693 | }; |
| 694 | |
| 695 | struct SsrcReceiverInfo { |
| 696 | SsrcReceiverInfo() |
| 697 | : ssrc(0), |
| 698 | timestamp(0) { |
| 699 | } |
| 700 | uint32 ssrc; |
| 701 | double timestamp; |
| 702 | }; |
| 703 | |
| 704 | struct MediaSenderInfo { |
| 705 | MediaSenderInfo() |
| 706 | : bytes_sent(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 707 | packets_sent(0), |
| 708 | packets_lost(0), |
| 709 | fraction_lost(0.0), |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 710 | rtt_ms(0) { |
| 711 | } |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 712 | void add_ssrc(const SsrcSenderInfo& stat) { |
| 713 | local_stats.push_back(stat); |
| 714 | } |
| 715 | // Temporary utility function for call sites that only provide SSRC. |
| 716 | // As more info is added into SsrcSenderInfo, this function should go away. |
| 717 | void add_ssrc(uint32 ssrc) { |
| 718 | SsrcSenderInfo stat; |
| 719 | stat.ssrc = ssrc; |
| 720 | add_ssrc(stat); |
| 721 | } |
| 722 | // Utility accessor for clients that are only interested in ssrc numbers. |
| 723 | std::vector<uint32> ssrcs() const { |
| 724 | std::vector<uint32> retval; |
| 725 | for (std::vector<SsrcSenderInfo>::const_iterator it = local_stats.begin(); |
| 726 | it != local_stats.end(); ++it) { |
| 727 | retval.push_back(it->ssrc); |
| 728 | } |
| 729 | return retval; |
| 730 | } |
| 731 | // Utility accessor for clients that make the assumption only one ssrc |
| 732 | // exists per media. |
| 733 | // This will eventually go away. |
| 734 | uint32 ssrc() const { |
| 735 | if (local_stats.size() > 0) { |
| 736 | return local_stats[0].ssrc; |
| 737 | } else { |
| 738 | return 0; |
| 739 | } |
| 740 | } |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 741 | int64 bytes_sent; |
| 742 | int packets_sent; |
| 743 | int packets_lost; |
| 744 | float fraction_lost; |
| 745 | int rtt_ms; |
| 746 | std::string codec_name; |
| 747 | std::vector<SsrcSenderInfo> local_stats; |
| 748 | std::vector<SsrcReceiverInfo> remote_stats; |
| 749 | }; |
| 750 | |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 751 | template<class T> |
| 752 | struct VariableInfo { |
| 753 | VariableInfo() |
| 754 | : min_val(), |
| 755 | mean(0.0), |
| 756 | max_val(), |
| 757 | variance(0.0) { |
| 758 | } |
| 759 | T min_val; |
| 760 | double mean; |
| 761 | T max_val; |
| 762 | double variance; |
| 763 | }; |
| 764 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 765 | struct MediaReceiverInfo { |
| 766 | MediaReceiverInfo() |
| 767 | : bytes_rcvd(0), |
| 768 | packets_rcvd(0), |
| 769 | packets_lost(0), |
| 770 | fraction_lost(0.0) { |
| 771 | } |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 772 | void add_ssrc(const SsrcReceiverInfo& stat) { |
| 773 | local_stats.push_back(stat); |
| 774 | } |
| 775 | // Temporary utility function for call sites that only provide SSRC. |
| 776 | // As more info is added into SsrcSenderInfo, this function should go away. |
| 777 | void add_ssrc(uint32 ssrc) { |
| 778 | SsrcReceiverInfo stat; |
| 779 | stat.ssrc = ssrc; |
| 780 | add_ssrc(stat); |
| 781 | } |
| 782 | std::vector<uint32> ssrcs() const { |
| 783 | std::vector<uint32> retval; |
| 784 | for (std::vector<SsrcReceiverInfo>::const_iterator it = local_stats.begin(); |
| 785 | it != local_stats.end(); ++it) { |
| 786 | retval.push_back(it->ssrc); |
| 787 | } |
| 788 | return retval; |
| 789 | } |
| 790 | // Utility accessor for clients that make the assumption only one ssrc |
| 791 | // exists per media. |
| 792 | // This will eventually go away. |
| 793 | uint32 ssrc() const { |
| 794 | if (local_stats.size() > 0) { |
| 795 | return local_stats[0].ssrc; |
| 796 | } else { |
| 797 | return 0; |
| 798 | } |
| 799 | } |
| 800 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 801 | int64 bytes_rcvd; |
| 802 | int packets_rcvd; |
| 803 | int packets_lost; |
| 804 | float fraction_lost; |
buildbot@webrtc.org | 7e71b77 | 2014-06-13 01:14:01 +0000 | [diff] [blame] | 805 | std::string codec_name; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 806 | std::vector<SsrcReceiverInfo> local_stats; |
| 807 | std::vector<SsrcSenderInfo> remote_stats; |
| 808 | }; |
| 809 | |
| 810 | struct VoiceSenderInfo : public MediaSenderInfo { |
| 811 | VoiceSenderInfo() |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 812 | : ext_seqnum(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 813 | jitter_ms(0), |
| 814 | audio_level(0), |
| 815 | aec_quality_min(0.0), |
| 816 | echo_delay_median_ms(0), |
| 817 | echo_delay_std_ms(0), |
| 818 | echo_return_loss(0), |
wu@webrtc.org | 967bfff | 2013-09-19 05:49:50 +0000 | [diff] [blame] | 819 | echo_return_loss_enhancement(0), |
| 820 | typing_noise_detected(false) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 821 | } |
| 822 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 823 | int ext_seqnum; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 824 | int jitter_ms; |
| 825 | int audio_level; |
| 826 | float aec_quality_min; |
| 827 | int echo_delay_median_ms; |
| 828 | int echo_delay_std_ms; |
| 829 | int echo_return_loss; |
| 830 | int echo_return_loss_enhancement; |
wu@webrtc.org | 967bfff | 2013-09-19 05:49:50 +0000 | [diff] [blame] | 831 | bool typing_noise_detected; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 832 | }; |
| 833 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 834 | struct VoiceReceiverInfo : public MediaReceiverInfo { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 835 | VoiceReceiverInfo() |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 836 | : ext_seqnum(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 837 | jitter_ms(0), |
| 838 | jitter_buffer_ms(0), |
| 839 | jitter_buffer_preferred_ms(0), |
| 840 | delay_estimate_ms(0), |
| 841 | audio_level(0), |
henrike@webrtc.org | b8c254a | 2014-02-14 23:38:45 +0000 | [diff] [blame] | 842 | expand_rate(0), |
| 843 | decoding_calls_to_silence_generator(0), |
| 844 | decoding_calls_to_neteq(0), |
| 845 | decoding_normal(0), |
| 846 | decoding_plc(0), |
| 847 | decoding_cng(0), |
buildbot@webrtc.org | b525a9d | 2014-06-03 09:42:15 +0000 | [diff] [blame] | 848 | decoding_plc_cng(0), |
| 849 | capture_start_ntp_time_ms(-1) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 850 | } |
| 851 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 852 | int ext_seqnum; |
| 853 | int jitter_ms; |
| 854 | int jitter_buffer_ms; |
| 855 | int jitter_buffer_preferred_ms; |
| 856 | int delay_estimate_ms; |
| 857 | int audio_level; |
| 858 | // fraction of synthesized speech inserted through pre-emptive expansion |
| 859 | float expand_rate; |
henrike@webrtc.org | b8c254a | 2014-02-14 23:38:45 +0000 | [diff] [blame] | 860 | int decoding_calls_to_silence_generator; |
| 861 | int decoding_calls_to_neteq; |
| 862 | int decoding_normal; |
| 863 | int decoding_plc; |
| 864 | int decoding_cng; |
| 865 | int decoding_plc_cng; |
buildbot@webrtc.org | b525a9d | 2014-06-03 09:42:15 +0000 | [diff] [blame] | 866 | // Estimated capture start time in NTP time in ms. |
| 867 | int64 capture_start_ntp_time_ms; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 868 | }; |
| 869 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 870 | struct VideoSenderInfo : public MediaSenderInfo { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 871 | VideoSenderInfo() |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 872 | : packets_cached(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 873 | firs_rcvd(0), |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 874 | plis_rcvd(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 875 | nacks_rcvd(0), |
wu@webrtc.org | 987f2c9 | 2014-03-28 16:22:19 +0000 | [diff] [blame] | 876 | input_frame_width(0), |
| 877 | input_frame_height(0), |
| 878 | send_frame_width(0), |
| 879 | send_frame_height(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 880 | framerate_input(0), |
| 881 | framerate_sent(0), |
| 882 | nominal_bitrate(0), |
| 883 | preferred_bitrate(0), |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 884 | adapt_reason(0), |
buildbot@webrtc.org | 71dffb7 | 2014-06-24 07:24:49 +0000 | [diff] [blame] | 885 | adapt_changes(0), |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 886 | capture_jitter_ms(0), |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 887 | avg_encode_ms(0), |
| 888 | encode_usage_percent(0), |
buildbot@webrtc.org | c800c1c | 2014-06-13 07:56:17 +0000 | [diff] [blame] | 889 | encode_rsd(0), |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 890 | capture_queue_delay_ms_per_s(0) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 891 | } |
| 892 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 893 | std::vector<SsrcGroup> ssrc_groups; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 894 | int packets_cached; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 895 | int firs_rcvd; |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 896 | int plis_rcvd; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 897 | int nacks_rcvd; |
wu@webrtc.org | 987f2c9 | 2014-03-28 16:22:19 +0000 | [diff] [blame] | 898 | int input_frame_width; |
| 899 | int input_frame_height; |
| 900 | int send_frame_width; |
| 901 | int send_frame_height; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 902 | int framerate_input; |
| 903 | int framerate_sent; |
| 904 | int nominal_bitrate; |
| 905 | int preferred_bitrate; |
| 906 | int adapt_reason; |
buildbot@webrtc.org | 71dffb7 | 2014-06-24 07:24:49 +0000 | [diff] [blame] | 907 | int adapt_changes; |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 908 | int capture_jitter_ms; |
| 909 | int avg_encode_ms; |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 910 | int encode_usage_percent; |
buildbot@webrtc.org | c800c1c | 2014-06-13 07:56:17 +0000 | [diff] [blame] | 911 | int encode_rsd; |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 912 | int capture_queue_delay_ms_per_s; |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 913 | VariableInfo<int> adapt_frame_drops; |
| 914 | VariableInfo<int> effects_frame_drops; |
| 915 | VariableInfo<double> capturer_frame_time; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 916 | }; |
| 917 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 918 | struct VideoReceiverInfo : public MediaReceiverInfo { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 919 | VideoReceiverInfo() |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 920 | : packets_concealed(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 921 | firs_sent(0), |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 922 | plis_sent(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 923 | nacks_sent(0), |
| 924 | frame_width(0), |
| 925 | frame_height(0), |
| 926 | framerate_rcvd(0), |
| 927 | framerate_decoded(0), |
| 928 | framerate_output(0), |
| 929 | framerate_render_input(0), |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 930 | framerate_render_output(0), |
| 931 | decode_ms(0), |
| 932 | max_decode_ms(0), |
| 933 | jitter_buffer_ms(0), |
| 934 | min_playout_delay_ms(0), |
| 935 | render_delay_ms(0), |
| 936 | target_delay_ms(0), |
buildbot@webrtc.org | 0581f0b | 2014-05-06 21:36:31 +0000 | [diff] [blame] | 937 | current_delay_ms(0), |
buildbot@webrtc.org | b525a9d | 2014-06-03 09:42:15 +0000 | [diff] [blame] | 938 | capture_start_ntp_time_ms(-1) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 939 | } |
| 940 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 941 | std::vector<SsrcGroup> ssrc_groups; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 942 | int packets_concealed; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 943 | int firs_sent; |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 944 | int plis_sent; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 945 | int nacks_sent; |
| 946 | int frame_width; |
| 947 | int frame_height; |
| 948 | int framerate_rcvd; |
| 949 | int framerate_decoded; |
| 950 | int framerate_output; |
| 951 | // Framerate as sent to the renderer. |
| 952 | int framerate_render_input; |
| 953 | // Framerate that the renderer reports. |
| 954 | int framerate_render_output; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 955 | |
| 956 | // All stats below are gathered per-VideoReceiver, but some will be correlated |
| 957 | // across MediaStreamTracks. NOTE(hta): when sinking stats into per-SSRC |
| 958 | // structures, reflect this in the new layout. |
| 959 | |
| 960 | // Current frame decode latency. |
| 961 | int decode_ms; |
| 962 | // Maximum observed frame decode latency. |
| 963 | int max_decode_ms; |
| 964 | // Jitter (network-related) latency. |
| 965 | int jitter_buffer_ms; |
| 966 | // Requested minimum playout latency. |
| 967 | int min_playout_delay_ms; |
| 968 | // Requested latency to account for rendering delay. |
| 969 | int render_delay_ms; |
| 970 | // Target overall delay: network+decode+render, accounting for |
| 971 | // min_playout_delay_ms. |
| 972 | int target_delay_ms; |
| 973 | // Current overall delay, possibly ramping towards target_delay_ms. |
| 974 | int current_delay_ms; |
buildbot@webrtc.org | 0581f0b | 2014-05-06 21:36:31 +0000 | [diff] [blame] | 975 | |
| 976 | // Estimated capture start time in NTP time in ms. |
| 977 | int64 capture_start_ntp_time_ms; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 978 | }; |
| 979 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 980 | struct DataSenderInfo : public MediaSenderInfo { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 981 | DataSenderInfo() |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 982 | : ssrc(0) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 983 | } |
| 984 | |
| 985 | uint32 ssrc; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 986 | }; |
| 987 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 988 | struct DataReceiverInfo : public MediaReceiverInfo { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 989 | DataReceiverInfo() |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 990 | : ssrc(0) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 991 | } |
| 992 | |
| 993 | uint32 ssrc; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 994 | }; |
| 995 | |
| 996 | struct BandwidthEstimationInfo { |
| 997 | BandwidthEstimationInfo() |
| 998 | : available_send_bandwidth(0), |
| 999 | available_recv_bandwidth(0), |
| 1000 | target_enc_bitrate(0), |
| 1001 | actual_enc_bitrate(0), |
| 1002 | retransmit_bitrate(0), |
| 1003 | transmit_bitrate(0), |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1004 | bucket_delay(0), |
| 1005 | total_received_propagation_delta_ms(0) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1006 | } |
| 1007 | |
| 1008 | int available_send_bandwidth; |
| 1009 | int available_recv_bandwidth; |
| 1010 | int target_enc_bitrate; |
| 1011 | int actual_enc_bitrate; |
| 1012 | int retransmit_bitrate; |
| 1013 | int transmit_bitrate; |
| 1014 | int bucket_delay; |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1015 | // The following stats are only valid when |
| 1016 | // StatsOptions::include_received_propagation_stats is true. |
| 1017 | int total_received_propagation_delta_ms; |
| 1018 | std::vector<int> recent_received_propagation_delta_ms; |
| 1019 | std::vector<int64> recent_received_packet_group_arrival_time_ms; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1020 | }; |
| 1021 | |
| 1022 | struct VoiceMediaInfo { |
| 1023 | void Clear() { |
| 1024 | senders.clear(); |
| 1025 | receivers.clear(); |
| 1026 | } |
| 1027 | std::vector<VoiceSenderInfo> senders; |
| 1028 | std::vector<VoiceReceiverInfo> receivers; |
| 1029 | }; |
| 1030 | |
| 1031 | struct VideoMediaInfo { |
| 1032 | void Clear() { |
| 1033 | senders.clear(); |
| 1034 | receivers.clear(); |
| 1035 | bw_estimations.clear(); |
| 1036 | } |
| 1037 | std::vector<VideoSenderInfo> senders; |
| 1038 | std::vector<VideoReceiverInfo> receivers; |
| 1039 | std::vector<BandwidthEstimationInfo> bw_estimations; |
| 1040 | }; |
| 1041 | |
| 1042 | struct DataMediaInfo { |
| 1043 | void Clear() { |
| 1044 | senders.clear(); |
| 1045 | receivers.clear(); |
| 1046 | } |
| 1047 | std::vector<DataSenderInfo> senders; |
| 1048 | std::vector<DataReceiverInfo> receivers; |
| 1049 | }; |
| 1050 | |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1051 | struct StatsOptions { |
| 1052 | StatsOptions() : include_received_propagation_stats(false) {} |
| 1053 | |
| 1054 | bool include_received_propagation_stats; |
| 1055 | }; |
| 1056 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1057 | class VoiceMediaChannel : public MediaChannel { |
| 1058 | public: |
| 1059 | enum Error { |
| 1060 | ERROR_NONE = 0, // No error. |
| 1061 | ERROR_OTHER, // Other errors. |
| 1062 | ERROR_REC_DEVICE_OPEN_FAILED = 100, // Could not open mic. |
| 1063 | ERROR_REC_DEVICE_MUTED, // Mic was muted by OS. |
| 1064 | ERROR_REC_DEVICE_SILENT, // No background noise picked up. |
| 1065 | ERROR_REC_DEVICE_SATURATION, // Mic input is clipping. |
| 1066 | ERROR_REC_DEVICE_REMOVED, // Mic was removed while active. |
| 1067 | ERROR_REC_RUNTIME_ERROR, // Processing is encountering errors. |
| 1068 | ERROR_REC_SRTP_ERROR, // Generic SRTP failure. |
| 1069 | ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 1070 | ERROR_REC_TYPING_NOISE_DETECTED, // Typing noise is detected. |
| 1071 | ERROR_PLAY_DEVICE_OPEN_FAILED = 200, // Could not open playout. |
| 1072 | ERROR_PLAY_DEVICE_MUTED, // Playout muted by OS. |
| 1073 | ERROR_PLAY_DEVICE_REMOVED, // Playout removed while active. |
| 1074 | ERROR_PLAY_RUNTIME_ERROR, // Errors in voice processing. |
| 1075 | ERROR_PLAY_SRTP_ERROR, // Generic SRTP failure. |
| 1076 | ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 1077 | ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. |
| 1078 | }; |
| 1079 | |
| 1080 | VoiceMediaChannel() {} |
| 1081 | virtual ~VoiceMediaChannel() {} |
| 1082 | // Sets the codecs/payload types to be used for incoming media. |
| 1083 | virtual bool SetRecvCodecs(const std::vector<AudioCodec>& codecs) = 0; |
| 1084 | // Sets the codecs/payload types to be used for outgoing media. |
| 1085 | virtual bool SetSendCodecs(const std::vector<AudioCodec>& codecs) = 0; |
| 1086 | // Starts or stops playout of received audio. |
| 1087 | virtual bool SetPlayout(bool playout) = 0; |
| 1088 | // Starts or stops sending (and potentially capture) of local audio. |
| 1089 | virtual bool SetSend(SendFlags flag) = 0; |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 1090 | // Sets the renderer object to be used for the specified remote audio stream. |
| 1091 | virtual bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) = 0; |
| 1092 | // Sets the renderer object to be used for the specified local audio stream. |
| 1093 | virtual bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1094 | // Gets current energy levels for all incoming streams. |
| 1095 | virtual bool GetActiveStreams(AudioInfo::StreamList* actives) = 0; |
| 1096 | // Get the current energy level of the stream sent to the speaker. |
| 1097 | virtual int GetOutputLevel() = 0; |
| 1098 | // Get the time in milliseconds since last recorded keystroke, or negative. |
| 1099 | virtual int GetTimeSinceLastTyping() = 0; |
| 1100 | // Temporarily exposed field for tuning typing detect options. |
| 1101 | virtual void SetTypingDetectionParameters(int time_window, |
| 1102 | int cost_per_typing, int reporting_threshold, int penalty_decay, |
| 1103 | int type_event_delay) = 0; |
| 1104 | // Set left and right scale for speaker output volume of the specified ssrc. |
| 1105 | virtual bool SetOutputScaling(uint32 ssrc, double left, double right) = 0; |
| 1106 | // Get left and right scale for speaker output volume of the specified ssrc. |
| 1107 | virtual bool GetOutputScaling(uint32 ssrc, double* left, double* right) = 0; |
| 1108 | // Specifies a ringback tone to be played during call setup. |
| 1109 | virtual bool SetRingbackTone(const char *buf, int len) = 0; |
| 1110 | // Plays or stops the aforementioned ringback tone |
| 1111 | virtual bool PlayRingbackTone(uint32 ssrc, bool play, bool loop) = 0; |
| 1112 | // Returns if the telephone-event has been negotiated. |
| 1113 | virtual bool CanInsertDtmf() { return false; } |
| 1114 | // Send and/or play a DTMF |event| according to the |flags|. |
| 1115 | // The DTMF out-of-band signal will be used on sending. |
| 1116 | // The |ssrc| should be either 0 or a valid send stream ssrc. |
henrike@webrtc.org | 9de257d | 2013-07-17 14:42:53 +0000 | [diff] [blame] | 1117 | // The valid value for the |event| are 0 to 15 which corresponding to |
| 1118 | // DTMF event 0-9, *, #, A-D. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1119 | virtual bool InsertDtmf(uint32 ssrc, int event, int duration, int flags) = 0; |
| 1120 | // Gets quality stats for the channel. |
| 1121 | virtual bool GetStats(VoiceMediaInfo* info) = 0; |
| 1122 | // Gets last reported error for this media channel. |
| 1123 | virtual void GetLastMediaError(uint32* ssrc, |
| 1124 | VoiceMediaChannel::Error* error) { |
| 1125 | ASSERT(error != NULL); |
| 1126 | *error = ERROR_NONE; |
| 1127 | } |
| 1128 | // Sets the media options to use. |
| 1129 | virtual bool SetOptions(const AudioOptions& options) = 0; |
| 1130 | virtual bool GetOptions(AudioOptions* options) const = 0; |
| 1131 | |
| 1132 | // Signal errors from MediaChannel. Arguments are: |
| 1133 | // ssrc(uint32), and error(VoiceMediaChannel::Error). |
| 1134 | sigslot::signal2<uint32, VoiceMediaChannel::Error> SignalMediaError; |
| 1135 | }; |
| 1136 | |
| 1137 | class VideoMediaChannel : public MediaChannel { |
| 1138 | public: |
| 1139 | enum Error { |
| 1140 | ERROR_NONE = 0, // No error. |
| 1141 | ERROR_OTHER, // Other errors. |
| 1142 | ERROR_REC_DEVICE_OPEN_FAILED = 100, // Could not open camera. |
| 1143 | ERROR_REC_DEVICE_NO_DEVICE, // No camera. |
| 1144 | ERROR_REC_DEVICE_IN_USE, // Device is in already use. |
| 1145 | ERROR_REC_DEVICE_REMOVED, // Device is removed. |
| 1146 | ERROR_REC_SRTP_ERROR, // Generic sender SRTP failure. |
| 1147 | ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 1148 | ERROR_REC_CPU_MAX_CANT_DOWNGRADE, // Can't downgrade capture anymore. |
| 1149 | ERROR_PLAY_SRTP_ERROR = 200, // Generic receiver SRTP failure. |
| 1150 | ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 1151 | ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. |
| 1152 | }; |
| 1153 | |
| 1154 | VideoMediaChannel() : renderer_(NULL) {} |
| 1155 | virtual ~VideoMediaChannel() {} |
| 1156 | // Sets the codecs/payload types to be used for incoming media. |
| 1157 | virtual bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) = 0; |
| 1158 | // Sets the codecs/payload types to be used for outgoing media. |
| 1159 | virtual bool SetSendCodecs(const std::vector<VideoCodec>& codecs) = 0; |
| 1160 | // Gets the currently set codecs/payload types to be used for outgoing media. |
| 1161 | virtual bool GetSendCodec(VideoCodec* send_codec) = 0; |
| 1162 | // Sets the format of a specified outgoing stream. |
| 1163 | virtual bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) = 0; |
| 1164 | // Starts or stops playout of received video. |
| 1165 | virtual bool SetRender(bool render) = 0; |
| 1166 | // Starts or stops transmission (and potentially capture) of local video. |
| 1167 | virtual bool SetSend(bool send) = 0; |
| 1168 | // Sets the renderer object to be used for the specified stream. |
| 1169 | // If SSRC is 0, the renderer is used for the 'default' stream. |
| 1170 | virtual bool SetRenderer(uint32 ssrc, VideoRenderer* renderer) = 0; |
| 1171 | // If |ssrc| is 0, replace the default capturer (engine capturer) with |
| 1172 | // |capturer|. If |ssrc| is non zero create a new stream with |ssrc| as SSRC. |
| 1173 | virtual bool SetCapturer(uint32 ssrc, VideoCapturer* capturer) = 0; |
| 1174 | // Gets quality stats for the channel. |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1175 | virtual bool GetStats(const StatsOptions& options, VideoMediaInfo* info) = 0; |
| 1176 | // This is needed for MediaMonitor to use the same template for voice, video |
| 1177 | // and data MediaChannels. |
| 1178 | bool GetStats(VideoMediaInfo* info) { |
| 1179 | return GetStats(StatsOptions(), info); |
| 1180 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1181 | |
| 1182 | // Send an intra frame to the receivers. |
| 1183 | virtual bool SendIntraFrame() = 0; |
| 1184 | // Reuqest each of the remote senders to send an intra frame. |
| 1185 | virtual bool RequestIntraFrame() = 0; |
| 1186 | // Sets the media options to use. |
| 1187 | virtual bool SetOptions(const VideoOptions& options) = 0; |
| 1188 | virtual bool GetOptions(VideoOptions* options) const = 0; |
| 1189 | virtual void UpdateAspectRatio(int ratio_w, int ratio_h) = 0; |
| 1190 | |
| 1191 | // Signal errors from MediaChannel. Arguments are: |
| 1192 | // ssrc(uint32), and error(VideoMediaChannel::Error). |
| 1193 | sigslot::signal2<uint32, Error> SignalMediaError; |
| 1194 | |
| 1195 | protected: |
| 1196 | VideoRenderer *renderer_; |
| 1197 | }; |
| 1198 | |
| 1199 | enum DataMessageType { |
mallinath@webrtc.org | 1112c30 | 2013-09-23 20:34:45 +0000 | [diff] [blame] | 1200 | // Chrome-Internal use only. See SctpDataMediaChannel for the actual PPID |
| 1201 | // values. |
| 1202 | DMT_NONE = 0, |
| 1203 | DMT_CONTROL = 1, |
| 1204 | DMT_BINARY = 2, |
| 1205 | DMT_TEXT = 3, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1206 | }; |
| 1207 | |
| 1208 | // Info about data received in DataMediaChannel. For use in |
| 1209 | // DataMediaChannel::SignalDataReceived and in all of the signals that |
| 1210 | // signal fires, on up the chain. |
| 1211 | struct ReceiveDataParams { |
| 1212 | // The in-packet stream indentifier. |
| 1213 | // For SCTP, this is really SID, not SSRC. |
| 1214 | uint32 ssrc; |
| 1215 | // The type of message (binary, text, or control). |
| 1216 | DataMessageType type; |
| 1217 | // A per-stream value incremented per packet in the stream. |
| 1218 | int seq_num; |
| 1219 | // A per-stream value monotonically increasing with time. |
| 1220 | int timestamp; |
| 1221 | |
| 1222 | ReceiveDataParams() : |
| 1223 | ssrc(0), |
| 1224 | type(DMT_TEXT), |
| 1225 | seq_num(0), |
| 1226 | timestamp(0) { |
| 1227 | } |
| 1228 | }; |
| 1229 | |
| 1230 | struct SendDataParams { |
| 1231 | // The in-packet stream indentifier. |
| 1232 | // For SCTP, this is really SID, not SSRC. |
| 1233 | uint32 ssrc; |
| 1234 | // The type of message (binary, text, or control). |
| 1235 | DataMessageType type; |
| 1236 | |
| 1237 | // For SCTP, whether to send messages flagged as ordered or not. |
| 1238 | // If false, messages can be received out of order. |
| 1239 | bool ordered; |
| 1240 | // For SCTP, whether the messages are sent reliably or not. |
| 1241 | // If false, messages may be lost. |
| 1242 | bool reliable; |
| 1243 | // For SCTP, if reliable == false, provide partial reliability by |
| 1244 | // resending up to this many times. Either count or millis |
| 1245 | // is supported, not both at the same time. |
| 1246 | int max_rtx_count; |
| 1247 | // For SCTP, if reliable == false, provide partial reliability by |
| 1248 | // resending for up to this many milliseconds. Either count or millis |
| 1249 | // is supported, not both at the same time. |
| 1250 | int max_rtx_ms; |
| 1251 | |
| 1252 | SendDataParams() : |
| 1253 | ssrc(0), |
| 1254 | type(DMT_TEXT), |
| 1255 | // TODO(pthatcher): Make these true by default? |
| 1256 | ordered(false), |
| 1257 | reliable(false), |
| 1258 | max_rtx_count(0), |
| 1259 | max_rtx_ms(0) { |
| 1260 | } |
| 1261 | }; |
| 1262 | |
| 1263 | enum SendDataResult { SDR_SUCCESS, SDR_ERROR, SDR_BLOCK }; |
| 1264 | |
| 1265 | class DataMediaChannel : public MediaChannel { |
| 1266 | public: |
| 1267 | enum Error { |
| 1268 | ERROR_NONE = 0, // No error. |
| 1269 | ERROR_OTHER, // Other errors. |
| 1270 | ERROR_SEND_SRTP_ERROR = 200, // Generic SRTP failure. |
| 1271 | ERROR_SEND_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 1272 | ERROR_RECV_SRTP_ERROR, // Generic SRTP failure. |
| 1273 | ERROR_RECV_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 1274 | ERROR_RECV_SRTP_REPLAY, // Packet replay detected. |
| 1275 | }; |
| 1276 | |
| 1277 | virtual ~DataMediaChannel() {} |
| 1278 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1279 | virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs) = 0; |
| 1280 | virtual bool SetRecvCodecs(const std::vector<DataCodec>& codecs) = 0; |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 1281 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1282 | virtual bool MuteStream(uint32 ssrc, bool on) { return false; } |
| 1283 | // TODO(pthatcher): Implement this. |
| 1284 | virtual bool GetStats(DataMediaInfo* info) { return true; } |
| 1285 | |
| 1286 | virtual bool SetSend(bool send) = 0; |
| 1287 | virtual bool SetReceive(bool receive) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1288 | |
| 1289 | virtual bool SendData( |
| 1290 | const SendDataParams& params, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame^] | 1291 | const rtc::Buffer& payload, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1292 | SendDataResult* result = NULL) = 0; |
| 1293 | // Signals when data is received (params, data, len) |
| 1294 | sigslot::signal3<const ReceiveDataParams&, |
| 1295 | const char*, |
| 1296 | size_t> SignalDataReceived; |
| 1297 | // Signal errors from MediaChannel. Arguments are: |
| 1298 | // ssrc(uint32), and error(DataMediaChannel::Error). |
| 1299 | sigslot::signal2<uint32, DataMediaChannel::Error> SignalMediaError; |
wu@webrtc.org | d64719d | 2013-08-01 00:00:07 +0000 | [diff] [blame] | 1300 | // Signal when the media channel is ready to send the stream. Arguments are: |
| 1301 | // writable(bool) |
| 1302 | sigslot::signal1<bool> SignalReadyToSend; |
buildbot@webrtc.org | 1d66be2 | 2014-05-29 22:54:24 +0000 | [diff] [blame] | 1303 | // Signal for notifying that the remote side has closed the DataChannel. |
| 1304 | sigslot::signal1<uint32> SignalStreamClosedRemotely; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1305 | }; |
| 1306 | |
| 1307 | } // namespace cricket |
| 1308 | |
| 1309 | #endif // TALK_MEDIA_BASE_MEDIACHANNEL_H_ |