henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 2 | * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | 1afca73 | 2016-02-07 20:46:45 -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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MEDIA_BASE_MEDIACHANNEL_H_ |
| 12 | #define MEDIA_BASE_MEDIACHANNEL_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 | |
Steve Anton | e78bcb9 | 2017-10-31 09:53:08 -0700 | [diff] [blame] | 14 | #include <map> |
kwiberg | 686a8ef | 2016-02-26 03:00:35 -0800 | [diff] [blame] | 15 | #include <memory> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 16 | #include <string> |
Patrik Höglund | aba85d1 | 2017-11-28 15:46:08 +0100 | [diff] [blame^] | 17 | #include <utility> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 18 | #include <vector> |
| 19 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "api/audio_codecs/audio_encoder.h" |
| 21 | #include "api/optional.h" |
| 22 | #include "api/rtpparameters.h" |
| 23 | #include "api/rtpreceiverinterface.h" |
| 24 | #include "api/video/video_timing.h" |
| 25 | #include "call/video_config.h" |
| 26 | #include "media/base/codec.h" |
| 27 | #include "media/base/mediaconstants.h" |
| 28 | #include "media/base/streamparams.h" |
| 29 | #include "media/base/videosinkinterface.h" |
| 30 | #include "media/base/videosourceinterface.h" |
Ivo Creusen | 56d4609 | 2017-11-24 17:29:59 +0100 | [diff] [blame] | 31 | #include "modules/audio_processing/include/audio_processing_statistics.h" |
Patrik Höglund | aba85d1 | 2017-11-28 15:46:08 +0100 | [diff] [blame^] | 32 | #include "rtc_base/asyncpacketsocket.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 33 | #include "rtc_base/basictypes.h" |
| 34 | #include "rtc_base/buffer.h" |
| 35 | #include "rtc_base/copyonwritebuffer.h" |
| 36 | #include "rtc_base/dscp.h" |
| 37 | #include "rtc_base/logging.h" |
| 38 | #include "rtc_base/networkroute.h" |
| 39 | #include "rtc_base/sigslot.h" |
| 40 | #include "rtc_base/socket.h" |
| 41 | #include "rtc_base/window.h" |
Patrik Höglund | aba85d1 | 2017-11-28 15:46:08 +0100 | [diff] [blame^] | 42 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 43 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 44 | namespace rtc { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 45 | class RateLimiter; |
| 46 | class Timing; |
| 47 | } |
| 48 | |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 49 | namespace webrtc { |
| 50 | class AudioSinkInterface; |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 51 | class VideoFrame; |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 52 | } |
| 53 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 54 | namespace cricket { |
| 55 | |
Taylor Brandstetter | 1a018dc | 2016-03-08 12:37:39 -0800 | [diff] [blame] | 56 | class AudioSource; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 57 | class VideoCapturer; |
tommi | 1d5c19d | 2015-12-13 22:54:29 -0800 | [diff] [blame] | 58 | struct RtpHeader; |
| 59 | struct VideoFormat; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 60 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 61 | const int kScreencastDefaultFps = 5; |
| 62 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 63 | template <class T> |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 64 | static std::string ToStringIfSet(const char* key, const rtc::Optional<T>& val) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 65 | std::string str; |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 66 | if (val) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 67 | str = key; |
| 68 | str += ": "; |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 69 | str += val ? rtc::ToString(*val) : ""; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 70 | str += ", "; |
| 71 | } |
| 72 | return str; |
| 73 | } |
| 74 | |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 75 | template <class T> |
| 76 | static std::string VectorToString(const std::vector<T>& vals) { |
| 77 | std::ostringstream ost; |
| 78 | ost << "["; |
| 79 | for (size_t i = 0; i < vals.size(); ++i) { |
| 80 | if (i > 0) { |
| 81 | ost << ", "; |
| 82 | } |
| 83 | ost << vals[i].ToString(); |
| 84 | } |
| 85 | ost << "]"; |
| 86 | return ost.str(); |
| 87 | } |
| 88 | |
nisse | 528b793 | 2017-05-08 03:21:43 -0700 | [diff] [blame] | 89 | // Construction-time settings, passed on when creating |
nisse | 51542be | 2016-02-12 02:27:06 -0800 | [diff] [blame] | 90 | // MediaChannels. |
| 91 | struct MediaConfig { |
| 92 | // Set DSCP value on packets. This flag comes from the |
| 93 | // PeerConnection constraint 'googDscp'. |
| 94 | bool enable_dscp = false; |
| 95 | |
nisse | 0db023a | 2016-03-01 04:29:59 -0800 | [diff] [blame] | 96 | // Video-specific config. |
| 97 | struct Video { |
| 98 | // Enable WebRTC CPU Overuse Detection. This flag comes from the |
perkj | 803d97f | 2016-11-01 11:45:46 -0700 | [diff] [blame] | 99 | // PeerConnection constraint 'googCpuOveruseDetection'. |
nisse | 0db023a | 2016-03-01 04:29:59 -0800 | [diff] [blame] | 100 | bool enable_cpu_overuse_detection = true; |
nisse | 51542be | 2016-02-12 02:27:06 -0800 | [diff] [blame] | 101 | |
nisse | 0db023a | 2016-03-01 04:29:59 -0800 | [diff] [blame] | 102 | // Enable WebRTC suspension of video. No video frames will be sent |
| 103 | // when the bitrate is below the configured minimum bitrate. This |
| 104 | // flag comes from the PeerConnection constraint |
eladalon | f184138 | 2017-06-12 01:16:46 -0700 | [diff] [blame] | 105 | // 'googSuspendBelowMinBitrate', and WebRtcVideoChannel copies it |
nisse | 0db023a | 2016-03-01 04:29:59 -0800 | [diff] [blame] | 106 | // to VideoSendStream::Config::suspend_below_min_bitrate. |
| 107 | bool suspend_below_min_bitrate = false; |
nisse | 51542be | 2016-02-12 02:27:06 -0800 | [diff] [blame] | 108 | |
nisse | 0db023a | 2016-03-01 04:29:59 -0800 | [diff] [blame] | 109 | // Set to true if the renderer has an algorithm of frame selection. |
| 110 | // If the value is true, then WebRTC will hand over a frame as soon as |
| 111 | // possible without delay, and rendering smoothness is completely the duty |
| 112 | // of the renderer; |
| 113 | // If the value is false, then WebRTC is responsible to delay frame release |
| 114 | // in order to increase rendering smoothness. |
| 115 | // |
| 116 | // This flag comes from PeerConnection's RtcConfiguration, but is |
| 117 | // currently only set by the command line flag |
| 118 | // 'disable-rtc-smoothness-algorithm'. |
eladalon | f184138 | 2017-06-12 01:16:46 -0700 | [diff] [blame] | 119 | // WebRtcVideoChannel::AddRecvStream copies it to the created |
nisse | 0db023a | 2016-03-01 04:29:59 -0800 | [diff] [blame] | 120 | // WebRtcVideoReceiveStream, where it is returned by the |
| 121 | // SmoothsRenderedFrames method. This method is used by the |
| 122 | // VideoReceiveStream, where the value is passed on to the |
| 123 | // IncomingVideoStream constructor. |
| 124 | bool disable_prerenderer_smoothing = false; |
sergeyu | 80ed35e | 2016-11-28 13:11:13 -0800 | [diff] [blame] | 125 | |
| 126 | // Enables periodic bandwidth probing in application-limited region. |
| 127 | bool periodic_alr_bandwidth_probing = false; |
nisse | 0db023a | 2016-03-01 04:29:59 -0800 | [diff] [blame] | 128 | } video; |
deadbeef | 293e926 | 2017-01-11 12:28:30 -0800 | [diff] [blame] | 129 | |
| 130 | bool operator==(const MediaConfig& o) const { |
| 131 | return enable_dscp == o.enable_dscp && |
| 132 | video.enable_cpu_overuse_detection == |
| 133 | o.video.enable_cpu_overuse_detection && |
| 134 | video.suspend_below_min_bitrate == |
| 135 | o.video.suspend_below_min_bitrate && |
| 136 | video.disable_prerenderer_smoothing == |
| 137 | o.video.disable_prerenderer_smoothing && |
| 138 | video.periodic_alr_bandwidth_probing == |
| 139 | o.video.periodic_alr_bandwidth_probing; |
| 140 | } |
| 141 | |
| 142 | bool operator!=(const MediaConfig& o) const { return !(*this == o); } |
nisse | 51542be | 2016-02-12 02:27:06 -0800 | [diff] [blame] | 143 | }; |
| 144 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 145 | // Options that can be applied to a VoiceMediaChannel or a VoiceMediaEngine. |
| 146 | // Used to be flags, but that makes it hard to selectively apply options. |
| 147 | // We are moving all of the setting of options to structs like this, |
| 148 | // but some things currently still use flags. |
| 149 | struct AudioOptions { |
| 150 | void SetAll(const AudioOptions& change) { |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 151 | SetFrom(&echo_cancellation, change.echo_cancellation); |
| 152 | SetFrom(&auto_gain_control, change.auto_gain_control); |
| 153 | SetFrom(&noise_suppression, change.noise_suppression); |
| 154 | SetFrom(&highpass_filter, change.highpass_filter); |
| 155 | SetFrom(&stereo_swapping, change.stereo_swapping); |
| 156 | SetFrom(&audio_jitter_buffer_max_packets, |
| 157 | change.audio_jitter_buffer_max_packets); |
| 158 | SetFrom(&audio_jitter_buffer_fast_accelerate, |
| 159 | change.audio_jitter_buffer_fast_accelerate); |
| 160 | SetFrom(&typing_detection, change.typing_detection); |
| 161 | SetFrom(&aecm_generate_comfort_noise, change.aecm_generate_comfort_noise); |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 162 | SetFrom(&adjust_agc_delta, change.adjust_agc_delta); |
| 163 | SetFrom(&experimental_agc, change.experimental_agc); |
| 164 | SetFrom(&extended_filter_aec, change.extended_filter_aec); |
| 165 | SetFrom(&delay_agnostic_aec, change.delay_agnostic_aec); |
| 166 | SetFrom(&experimental_ns, change.experimental_ns); |
Alejandro Luebs | c9b0c26 | 2016-05-16 15:32:38 -0700 | [diff] [blame] | 167 | SetFrom(&intelligibility_enhancer, change.intelligibility_enhancer); |
peah | a3333bf | 2016-06-30 00:02:34 -0700 | [diff] [blame] | 168 | SetFrom(&level_control, change.level_control); |
ivoc | b829d9f | 2016-11-15 02:34:47 -0800 | [diff] [blame] | 169 | SetFrom(&residual_echo_detector, change.residual_echo_detector); |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 170 | SetFrom(&tx_agc_target_dbov, change.tx_agc_target_dbov); |
| 171 | SetFrom(&tx_agc_digital_compression_gain, |
| 172 | change.tx_agc_digital_compression_gain); |
| 173 | SetFrom(&tx_agc_limiter, change.tx_agc_limiter); |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 174 | SetFrom(&combined_audio_video_bwe, change.combined_audio_video_bwe); |
minyue | 6b825df | 2016-10-31 04:08:32 -0700 | [diff] [blame] | 175 | SetFrom(&audio_network_adaptor, change.audio_network_adaptor); |
| 176 | SetFrom(&audio_network_adaptor_config, change.audio_network_adaptor_config); |
aleloi | e33c5d9 | 2016-10-20 01:53:27 -0700 | [diff] [blame] | 177 | SetFrom(&level_control_initial_peak_level_dbfs, |
| 178 | change.level_control_initial_peak_level_dbfs); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | bool operator==(const AudioOptions& o) const { |
| 182 | return echo_cancellation == o.echo_cancellation && |
peah | a3333bf | 2016-06-30 00:02:34 -0700 | [diff] [blame] | 183 | auto_gain_control == o.auto_gain_control && |
| 184 | noise_suppression == o.noise_suppression && |
| 185 | highpass_filter == o.highpass_filter && |
| 186 | stereo_swapping == o.stereo_swapping && |
| 187 | audio_jitter_buffer_max_packets == |
| 188 | o.audio_jitter_buffer_max_packets && |
| 189 | audio_jitter_buffer_fast_accelerate == |
| 190 | o.audio_jitter_buffer_fast_accelerate && |
| 191 | typing_detection == o.typing_detection && |
| 192 | aecm_generate_comfort_noise == o.aecm_generate_comfort_noise && |
| 193 | experimental_agc == o.experimental_agc && |
| 194 | extended_filter_aec == o.extended_filter_aec && |
| 195 | delay_agnostic_aec == o.delay_agnostic_aec && |
| 196 | experimental_ns == o.experimental_ns && |
| 197 | intelligibility_enhancer == o.intelligibility_enhancer && |
| 198 | level_control == o.level_control && |
ivoc | b829d9f | 2016-11-15 02:34:47 -0800 | [diff] [blame] | 199 | residual_echo_detector == o.residual_echo_detector && |
peah | a3333bf | 2016-06-30 00:02:34 -0700 | [diff] [blame] | 200 | adjust_agc_delta == o.adjust_agc_delta && |
| 201 | tx_agc_target_dbov == o.tx_agc_target_dbov && |
| 202 | tx_agc_digital_compression_gain == |
| 203 | o.tx_agc_digital_compression_gain && |
| 204 | tx_agc_limiter == o.tx_agc_limiter && |
aleloi | e33c5d9 | 2016-10-20 01:53:27 -0700 | [diff] [blame] | 205 | combined_audio_video_bwe == o.combined_audio_video_bwe && |
minyue | 6b825df | 2016-10-31 04:08:32 -0700 | [diff] [blame] | 206 | audio_network_adaptor == o.audio_network_adaptor && |
| 207 | audio_network_adaptor_config == o.audio_network_adaptor_config && |
aleloi | e33c5d9 | 2016-10-20 01:53:27 -0700 | [diff] [blame] | 208 | level_control_initial_peak_level_dbfs == |
| 209 | o.level_control_initial_peak_level_dbfs; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 210 | } |
deadbeef | 119760a | 2016-04-04 11:43:27 -0700 | [diff] [blame] | 211 | bool operator!=(const AudioOptions& o) const { return !(*this == o); } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 212 | |
| 213 | std::string ToString() const { |
| 214 | std::ostringstream ost; |
| 215 | ost << "AudioOptions {"; |
| 216 | ost << ToStringIfSet("aec", echo_cancellation); |
| 217 | ost << ToStringIfSet("agc", auto_gain_control); |
| 218 | ost << ToStringIfSet("ns", noise_suppression); |
| 219 | ost << ToStringIfSet("hf", highpass_filter); |
| 220 | ost << ToStringIfSet("swap", stereo_swapping); |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 221 | ost << ToStringIfSet("audio_jitter_buffer_max_packets", |
| 222 | audio_jitter_buffer_max_packets); |
Henrik Lundin | 5263b3c | 2015-06-01 10:29:41 +0200 | [diff] [blame] | 223 | ost << ToStringIfSet("audio_jitter_buffer_fast_accelerate", |
| 224 | audio_jitter_buffer_fast_accelerate); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 225 | ost << ToStringIfSet("typing", typing_detection); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 226 | ost << ToStringIfSet("comfort_noise", aecm_generate_comfort_noise); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 227 | ost << ToStringIfSet("agc_delta", adjust_agc_delta); |
| 228 | ost << ToStringIfSet("experimental_agc", experimental_agc); |
Henrik Lundin | 441f634 | 2015-06-09 16:03:13 +0200 | [diff] [blame] | 229 | ost << ToStringIfSet("extended_filter_aec", extended_filter_aec); |
Bjorn Volcker | bf395c1 | 2015-03-25 22:45:56 +0100 | [diff] [blame] | 230 | ost << ToStringIfSet("delay_agnostic_aec", delay_agnostic_aec); |
sergeyu@chromium.org | 9cf037b | 2014-02-07 19:03:26 +0000 | [diff] [blame] | 231 | ost << ToStringIfSet("experimental_ns", experimental_ns); |
Alejandro Luebs | c9b0c26 | 2016-05-16 15:32:38 -0700 | [diff] [blame] | 232 | ost << ToStringIfSet("intelligibility_enhancer", intelligibility_enhancer); |
peah | a3333bf | 2016-06-30 00:02:34 -0700 | [diff] [blame] | 233 | ost << ToStringIfSet("level_control", level_control); |
aleloi | e33c5d9 | 2016-10-20 01:53:27 -0700 | [diff] [blame] | 234 | ost << ToStringIfSet("level_control_initial_peak_level_dbfs", |
| 235 | level_control_initial_peak_level_dbfs); |
ivoc | b829d9f | 2016-11-15 02:34:47 -0800 | [diff] [blame] | 236 | ost << ToStringIfSet("residual_echo_detector", residual_echo_detector); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 237 | ost << ToStringIfSet("tx_agc_target_dbov", tx_agc_target_dbov); |
| 238 | ost << ToStringIfSet("tx_agc_digital_compression_gain", |
| 239 | tx_agc_digital_compression_gain); |
| 240 | ost << ToStringIfSet("tx_agc_limiter", tx_agc_limiter); |
buildbot@webrtc.org | b4c7b09 | 2014-08-25 12:11:58 +0000 | [diff] [blame] | 241 | ost << ToStringIfSet("combined_audio_video_bwe", combined_audio_video_bwe); |
minyue | 6b825df | 2016-10-31 04:08:32 -0700 | [diff] [blame] | 242 | ost << ToStringIfSet("audio_network_adaptor", audio_network_adaptor); |
| 243 | // The adaptor config is a serialized proto buffer and therefore not human |
| 244 | // readable. So we comment out the following line. |
| 245 | // ost << ToStringIfSet("audio_network_adaptor_config", |
| 246 | // audio_network_adaptor_config); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 247 | ost << "}"; |
| 248 | return ost.str(); |
| 249 | } |
| 250 | |
| 251 | // Audio processing that attempts to filter away the output signal from |
| 252 | // later inbound pickup. |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 253 | rtc::Optional<bool> echo_cancellation; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 254 | // Audio processing to adjust the sensitivity of the local mic dynamically. |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 255 | rtc::Optional<bool> auto_gain_control; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 256 | // Audio processing to filter out background noise. |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 257 | rtc::Optional<bool> noise_suppression; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 258 | // Audio processing to remove background noise of lower frequencies. |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 259 | rtc::Optional<bool> highpass_filter; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 260 | // Audio processing to swap the left and right channels. |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 261 | rtc::Optional<bool> stereo_swapping; |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 262 | // Audio receiver jitter buffer (NetEq) max capacity in number of packets. |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 263 | rtc::Optional<int> audio_jitter_buffer_max_packets; |
Henrik Lundin | 5263b3c | 2015-06-01 10:29:41 +0200 | [diff] [blame] | 264 | // Audio receiver jitter buffer (NetEq) fast accelerate mode. |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 265 | rtc::Optional<bool> audio_jitter_buffer_fast_accelerate; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 266 | // Audio processing to detect typing. |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 267 | rtc::Optional<bool> typing_detection; |
| 268 | rtc::Optional<bool> aecm_generate_comfort_noise; |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 269 | rtc::Optional<int> adjust_agc_delta; |
| 270 | rtc::Optional<bool> experimental_agc; |
| 271 | rtc::Optional<bool> extended_filter_aec; |
| 272 | rtc::Optional<bool> delay_agnostic_aec; |
| 273 | rtc::Optional<bool> experimental_ns; |
Alejandro Luebs | c9b0c26 | 2016-05-16 15:32:38 -0700 | [diff] [blame] | 274 | rtc::Optional<bool> intelligibility_enhancer; |
peah | a3333bf | 2016-06-30 00:02:34 -0700 | [diff] [blame] | 275 | rtc::Optional<bool> level_control; |
aleloi | e33c5d9 | 2016-10-20 01:53:27 -0700 | [diff] [blame] | 276 | // Specifies an optional initialization value for the level controller. |
| 277 | rtc::Optional<float> level_control_initial_peak_level_dbfs; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 278 | // Note that tx_agc_* only applies to non-experimental AGC. |
ivoc | b829d9f | 2016-11-15 02:34:47 -0800 | [diff] [blame] | 279 | rtc::Optional<bool> residual_echo_detector; |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 280 | rtc::Optional<uint16_t> tx_agc_target_dbov; |
| 281 | rtc::Optional<uint16_t> tx_agc_digital_compression_gain; |
| 282 | rtc::Optional<bool> tx_agc_limiter; |
buildbot@webrtc.org | b4c7b09 | 2014-08-25 12:11:58 +0000 | [diff] [blame] | 283 | // Enable combined audio+bandwidth BWE. |
nisse | 51542be | 2016-02-12 02:27:06 -0800 | [diff] [blame] | 284 | // TODO(pthatcher): This flag is set from the |
| 285 | // "googCombinedAudioVideoBwe", but not used anywhere. So delete it, |
| 286 | // and check if any other AudioOptions members are unused. |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 287 | rtc::Optional<bool> combined_audio_video_bwe; |
minyue | 6b825df | 2016-10-31 04:08:32 -0700 | [diff] [blame] | 288 | // Enable audio network adaptor. |
| 289 | rtc::Optional<bool> audio_network_adaptor; |
| 290 | // Config string for audio network adaptor. |
| 291 | rtc::Optional<std::string> audio_network_adaptor_config; |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 292 | |
| 293 | private: |
| 294 | template <typename T> |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 295 | static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) { |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 296 | if (o) { |
| 297 | *s = o; |
| 298 | } |
| 299 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 300 | }; |
| 301 | |
| 302 | // Options that can be applied to a VideoMediaChannel or a VideoMediaEngine. |
| 303 | // Used to be flags, but that makes it hard to selectively apply options. |
| 304 | // We are moving all of the setting of options to structs like this, |
| 305 | // but some things currently still use flags. |
| 306 | struct VideoOptions { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 307 | void SetAll(const VideoOptions& change) { |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 308 | SetFrom(&video_noise_reduction, change.video_noise_reduction); |
nisse | b163c3f | 2016-01-29 01:14:38 -0800 | [diff] [blame] | 309 | SetFrom(&screencast_min_bitrate_kbps, change.screencast_min_bitrate_kbps); |
Niels Möller | 60653ba | 2016-03-02 11:41:36 +0100 | [diff] [blame] | 310 | SetFrom(&is_screencast, change.is_screencast); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | bool operator==(const VideoOptions& o) const { |
nisse | b163c3f | 2016-01-29 01:14:38 -0800 | [diff] [blame] | 314 | return video_noise_reduction == o.video_noise_reduction && |
Niels Möller | 60653ba | 2016-03-02 11:41:36 +0100 | [diff] [blame] | 315 | screencast_min_bitrate_kbps == o.screencast_min_bitrate_kbps && |
| 316 | is_screencast == o.is_screencast; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 317 | } |
deadbeef | 119760a | 2016-04-04 11:43:27 -0700 | [diff] [blame] | 318 | bool operator!=(const VideoOptions& o) const { return !(*this == o); } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 319 | |
| 320 | std::string ToString() const { |
| 321 | std::ostringstream ost; |
| 322 | ost << "VideoOptions {"; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 323 | ost << ToStringIfSet("noise reduction", video_noise_reduction); |
nisse | b163c3f | 2016-01-29 01:14:38 -0800 | [diff] [blame] | 324 | ost << ToStringIfSet("screencast min bitrate kbps", |
| 325 | screencast_min_bitrate_kbps); |
Niels Möller | 60653ba | 2016-03-02 11:41:36 +0100 | [diff] [blame] | 326 | ost << ToStringIfSet("is_screencast ", is_screencast); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 327 | ost << "}"; |
| 328 | return ost.str(); |
| 329 | } |
| 330 | |
nisse | b163c3f | 2016-01-29 01:14:38 -0800 | [diff] [blame] | 331 | // Enable denoising? This flag comes from the getUserMedia |
eladalon | f184138 | 2017-06-12 01:16:46 -0700 | [diff] [blame] | 332 | // constraint 'googNoiseReduction', and WebRtcVideoEngine passes it |
nisse | b163c3f | 2016-01-29 01:14:38 -0800 | [diff] [blame] | 333 | // on to the codec options. Disabled by default. |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 334 | rtc::Optional<bool> video_noise_reduction; |
nisse | b163c3f | 2016-01-29 01:14:38 -0800 | [diff] [blame] | 335 | // Force screencast to use a minimum bitrate. This flag comes from |
| 336 | // the PeerConnection constraint 'googScreencastMinBitrate'. It is |
eladalon | f184138 | 2017-06-12 01:16:46 -0700 | [diff] [blame] | 337 | // copied to the encoder config by WebRtcVideoChannel. |
nisse | b163c3f | 2016-01-29 01:14:38 -0800 | [diff] [blame] | 338 | rtc::Optional<int> screencast_min_bitrate_kbps; |
Niels Möller | 60653ba | 2016-03-02 11:41:36 +0100 | [diff] [blame] | 339 | // Set by screencast sources. Implies selection of encoding settings |
| 340 | // suitable for screencast. Most likely not the right way to do |
| 341 | // things, e.g., screencast of a text document and screencast of a |
| 342 | // youtube video have different needs. |
| 343 | rtc::Optional<bool> is_screencast; |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 344 | |
| 345 | private: |
| 346 | template <typename T> |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 347 | static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) { |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 348 | if (o) { |
| 349 | *s = o; |
| 350 | } |
| 351 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 352 | }; |
| 353 | |
isheriff | a1c548b | 2016-05-31 16:12:24 -0700 | [diff] [blame] | 354 | // TODO(isheriff): Remove this once client usage is fixed to use RtpExtension. |
| 355 | struct RtpHeaderExtension { |
| 356 | RtpHeaderExtension() : id(0) {} |
| 357 | RtpHeaderExtension(const std::string& uri, int id) : uri(uri), id(id) {} |
| 358 | |
| 359 | std::string ToString() const { |
| 360 | std::ostringstream ost; |
| 361 | ost << "{"; |
| 362 | ost << "uri: " << uri; |
| 363 | ost << ", id: " << id; |
| 364 | ost << "}"; |
| 365 | return ost.str(); |
| 366 | } |
| 367 | |
| 368 | std::string uri; |
| 369 | int id; |
| 370 | }; |
| 371 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 372 | class MediaChannel : public sigslot::has_slots<> { |
| 373 | public: |
| 374 | class NetworkInterface { |
| 375 | public: |
| 376 | enum SocketType { ST_RTP, ST_RTCP }; |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 377 | virtual bool SendPacket(rtc::CopyOnWriteBuffer* packet, |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 378 | const rtc::PacketOptions& options) = 0; |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 379 | virtual bool SendRtcp(rtc::CopyOnWriteBuffer* packet, |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 380 | const rtc::PacketOptions& options) = 0; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 381 | virtual int SetOption(SocketType type, rtc::Socket::Option opt, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 382 | int option) = 0; |
| 383 | virtual ~NetworkInterface() {} |
| 384 | }; |
| 385 | |
terelius | 54f9171 | 2016-06-01 11:18:56 -0700 | [diff] [blame] | 386 | explicit MediaChannel(const MediaConfig& config) |
nisse | 51542be | 2016-02-12 02:27:06 -0800 | [diff] [blame] | 387 | : enable_dscp_(config.enable_dscp), network_interface_(NULL) {} |
| 388 | MediaChannel() : enable_dscp_(false), network_interface_(NULL) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 389 | virtual ~MediaChannel() {} |
| 390 | |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 391 | // Sets the abstract interface class for sending RTP/RTCP data. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 392 | virtual void SetInterface(NetworkInterface *iface) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 393 | rtc::CritScope cs(&network_interface_crit_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 394 | network_interface_ = iface; |
nisse | 51542be | 2016-02-12 02:27:06 -0800 | [diff] [blame] | 395 | SetDscp(enable_dscp_ ? PreferredDscp() : rtc::DSCP_DEFAULT); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 396 | } |
nisse | 51542be | 2016-02-12 02:27:06 -0800 | [diff] [blame] | 397 | virtual rtc::DiffServCodePoint PreferredDscp() const { |
| 398 | return rtc::DSCP_DEFAULT; |
| 399 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 400 | // Called when a RTP packet is received. |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 401 | virtual void OnPacketReceived(rtc::CopyOnWriteBuffer* packet, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 402 | const rtc::PacketTime& packet_time) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 403 | // Called when a RTCP packet is received. |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 404 | virtual void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 405 | const rtc::PacketTime& packet_time) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 406 | // Called when the socket's ability to send has changed. |
| 407 | virtual void OnReadyToSend(bool ready) = 0; |
Honghai Zhang | cc411c0 | 2016-03-29 17:27:21 -0700 | [diff] [blame] | 408 | // Called when the network route used for sending packets changed. |
Honghai Zhang | 0e533ef | 2016-04-19 15:41:36 -0700 | [diff] [blame] | 409 | virtual void OnNetworkRouteChanged( |
| 410 | const std::string& transport_name, |
| 411 | const rtc::NetworkRoute& network_route) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 412 | // Creates a new outgoing media stream with SSRCs and CNAME as described |
| 413 | // by sp. |
| 414 | virtual bool AddSendStream(const StreamParams& sp) = 0; |
| 415 | // Removes an outgoing media stream. |
| 416 | // ssrc must be the first SSRC of the media stream if the stream uses |
| 417 | // multiple SSRCs. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 418 | virtual bool RemoveSendStream(uint32_t ssrc) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 419 | // Creates a new incoming media stream with SSRCs and CNAME as described |
| 420 | // by sp. |
| 421 | virtual bool AddRecvStream(const StreamParams& sp) = 0; |
| 422 | // Removes an incoming media stream. |
| 423 | // ssrc must be the first SSRC of the media stream if the stream uses |
| 424 | // multiple SSRCs. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 425 | virtual bool RemoveRecvStream(uint32_t ssrc) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 426 | |
mallinath@webrtc.org | 92fdfeb | 2014-02-17 18:49:41 +0000 | [diff] [blame] | 427 | // Returns the absoulte sendtime extension id value from media channel. |
| 428 | virtual int GetRtpSendTimeExtnId() const { |
| 429 | return -1; |
| 430 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 431 | |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 432 | // Base method to send packet using NetworkInterface. |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 433 | bool SendPacket(rtc::CopyOnWriteBuffer* packet, |
| 434 | const rtc::PacketOptions& options) { |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 435 | return DoSendPacket(packet, false, options); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 436 | } |
| 437 | |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 438 | bool SendRtcp(rtc::CopyOnWriteBuffer* packet, |
| 439 | const rtc::PacketOptions& options) { |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 440 | return DoSendPacket(packet, true, options); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | int SetOption(NetworkInterface::SocketType type, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 444 | rtc::Socket::Option opt, |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 445 | int option) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 446 | rtc::CritScope cs(&network_interface_crit_); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 447 | if (!network_interface_) |
| 448 | return -1; |
| 449 | |
| 450 | return network_interface_->SetOption(type, opt, option); |
| 451 | } |
| 452 | |
nisse | 51542be | 2016-02-12 02:27:06 -0800 | [diff] [blame] | 453 | private: |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 454 | // This method sets DSCP |value| on both RTP and RTCP channels. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 455 | int SetDscp(rtc::DiffServCodePoint value) { |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 456 | int ret; |
| 457 | ret = SetOption(NetworkInterface::ST_RTP, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 458 | rtc::Socket::OPT_DSCP, |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 459 | value); |
| 460 | if (ret == 0) { |
| 461 | ret = SetOption(NetworkInterface::ST_RTCP, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 462 | rtc::Socket::OPT_DSCP, |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 463 | value); |
| 464 | } |
| 465 | return ret; |
| 466 | } |
| 467 | |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 468 | bool DoSendPacket(rtc::CopyOnWriteBuffer* packet, |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 469 | bool rtcp, |
| 470 | const rtc::PacketOptions& options) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 471 | rtc::CritScope cs(&network_interface_crit_); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 472 | if (!network_interface_) |
| 473 | return false; |
| 474 | |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 475 | return (!rtcp) ? network_interface_->SendPacket(packet, options) |
| 476 | : network_interface_->SendRtcp(packet, options); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 477 | } |
| 478 | |
nisse | 51542be | 2016-02-12 02:27:06 -0800 | [diff] [blame] | 479 | const bool enable_dscp_; |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 480 | // |network_interface_| can be accessed from the worker_thread and |
| 481 | // from any MediaEngine threads. This critical section is to protect accessing |
| 482 | // of network_interface_ object. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 483 | rtc::CriticalSection network_interface_crit_; |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 484 | NetworkInterface* network_interface_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 485 | }; |
| 486 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 487 | // The stats information is structured as follows: |
| 488 | // Media are represented by either MediaSenderInfo or MediaReceiverInfo. |
| 489 | // Media contains a vector of SSRC infos that are exclusively used by this |
| 490 | // media. (SSRCs shared between media streams can't be represented.) |
| 491 | |
| 492 | // Information about an SSRC. |
| 493 | // This data may be locally recorded, or received in an RTCP SR or RR. |
| 494 | struct SsrcSenderInfo { |
| 495 | SsrcSenderInfo() |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 496 | : ssrc(0), |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 497 | timestamp(0) { |
| 498 | } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 499 | uint32_t ssrc; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 500 | double timestamp; // NTP timestamp, represented as seconds since epoch. |
| 501 | }; |
| 502 | |
| 503 | struct SsrcReceiverInfo { |
| 504 | SsrcReceiverInfo() |
| 505 | : ssrc(0), |
| 506 | timestamp(0) { |
| 507 | } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 508 | uint32_t ssrc; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 509 | double timestamp; |
| 510 | }; |
| 511 | |
| 512 | struct MediaSenderInfo { |
| 513 | MediaSenderInfo() |
| 514 | : bytes_sent(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 515 | packets_sent(0), |
| 516 | packets_lost(0), |
| 517 | fraction_lost(0.0), |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 518 | rtt_ms(0) { |
| 519 | } |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 520 | void add_ssrc(const SsrcSenderInfo& stat) { |
| 521 | local_stats.push_back(stat); |
| 522 | } |
| 523 | // Temporary utility function for call sites that only provide SSRC. |
| 524 | // As more info is added into SsrcSenderInfo, this function should go away. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 525 | void add_ssrc(uint32_t ssrc) { |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 526 | SsrcSenderInfo stat; |
| 527 | stat.ssrc = ssrc; |
| 528 | add_ssrc(stat); |
| 529 | } |
| 530 | // Utility accessor for clients that are only interested in ssrc numbers. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 531 | std::vector<uint32_t> ssrcs() const { |
| 532 | std::vector<uint32_t> retval; |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 533 | for (std::vector<SsrcSenderInfo>::const_iterator it = local_stats.begin(); |
| 534 | it != local_stats.end(); ++it) { |
| 535 | retval.push_back(it->ssrc); |
| 536 | } |
| 537 | return retval; |
| 538 | } |
| 539 | // Utility accessor for clients that make the assumption only one ssrc |
| 540 | // exists per media. |
| 541 | // This will eventually go away. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 542 | uint32_t ssrc() const { |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 543 | if (local_stats.size() > 0) { |
| 544 | return local_stats[0].ssrc; |
| 545 | } else { |
| 546 | return 0; |
| 547 | } |
| 548 | } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 549 | int64_t bytes_sent; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 550 | int packets_sent; |
| 551 | int packets_lost; |
| 552 | float fraction_lost; |
pkasting@chromium.org | 16825b1 | 2015-01-12 21:51:21 +0000 | [diff] [blame] | 553 | int64_t rtt_ms; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 554 | std::string codec_name; |
hbos | 1acfbd2 | 2016-11-17 23:43:29 -0800 | [diff] [blame] | 555 | rtc::Optional<int> codec_payload_type; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 556 | std::vector<SsrcSenderInfo> local_stats; |
| 557 | std::vector<SsrcReceiverInfo> remote_stats; |
| 558 | }; |
| 559 | |
| 560 | struct MediaReceiverInfo { |
| 561 | MediaReceiverInfo() |
| 562 | : bytes_rcvd(0), |
| 563 | packets_rcvd(0), |
| 564 | packets_lost(0), |
| 565 | fraction_lost(0.0) { |
| 566 | } |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 567 | void add_ssrc(const SsrcReceiverInfo& stat) { |
| 568 | local_stats.push_back(stat); |
| 569 | } |
| 570 | // Temporary utility function for call sites that only provide SSRC. |
| 571 | // As more info is added into SsrcSenderInfo, this function should go away. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 572 | void add_ssrc(uint32_t ssrc) { |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 573 | SsrcReceiverInfo stat; |
| 574 | stat.ssrc = ssrc; |
| 575 | add_ssrc(stat); |
| 576 | } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 577 | std::vector<uint32_t> ssrcs() const { |
| 578 | std::vector<uint32_t> retval; |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 579 | for (std::vector<SsrcReceiverInfo>::const_iterator it = local_stats.begin(); |
| 580 | it != local_stats.end(); ++it) { |
| 581 | retval.push_back(it->ssrc); |
| 582 | } |
| 583 | return retval; |
| 584 | } |
| 585 | // Utility accessor for clients that make the assumption only one ssrc |
| 586 | // exists per media. |
| 587 | // This will eventually go away. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 588 | uint32_t ssrc() const { |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 589 | if (local_stats.size() > 0) { |
| 590 | return local_stats[0].ssrc; |
| 591 | } else { |
| 592 | return 0; |
| 593 | } |
| 594 | } |
| 595 | |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 596 | int64_t bytes_rcvd; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 597 | int packets_rcvd; |
| 598 | int packets_lost; |
| 599 | float fraction_lost; |
buildbot@webrtc.org | 7e71b77 | 2014-06-13 01:14:01 +0000 | [diff] [blame] | 600 | std::string codec_name; |
hbos | 1acfbd2 | 2016-11-17 23:43:29 -0800 | [diff] [blame] | 601 | rtc::Optional<int> codec_payload_type; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 602 | std::vector<SsrcReceiverInfo> local_stats; |
| 603 | std::vector<SsrcSenderInfo> remote_stats; |
| 604 | }; |
| 605 | |
| 606 | struct VoiceSenderInfo : public MediaSenderInfo { |
| 607 | VoiceSenderInfo() |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 608 | : ext_seqnum(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 609 | jitter_ms(0), |
| 610 | audio_level(0), |
zstein | e76bd3a | 2017-07-14 12:17:49 -0700 | [diff] [blame] | 611 | total_input_energy(0.0), |
| 612 | total_input_duration(0.0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 613 | aec_quality_min(0.0), |
| 614 | echo_delay_median_ms(0), |
| 615 | echo_delay_std_ms(0), |
| 616 | echo_return_loss(0), |
wu@webrtc.org | 967bfff | 2013-09-19 05:49:50 +0000 | [diff] [blame] | 617 | echo_return_loss_enhancement(0), |
ivoc | 8c63a82 | 2016-10-21 04:10:03 -0700 | [diff] [blame] | 618 | residual_echo_likelihood(0.0f), |
ivoc | 4e477a1 | 2017-01-15 08:29:46 -0800 | [diff] [blame] | 619 | residual_echo_likelihood_recent_max(0.0f), |
| 620 | typing_noise_detected(false) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 621 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 622 | int ext_seqnum; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 623 | int jitter_ms; |
| 624 | int audio_level; |
zstein | e76bd3a | 2017-07-14 12:17:49 -0700 | [diff] [blame] | 625 | // See description of "totalAudioEnergy" in the WebRTC stats spec: |
| 626 | // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy |
| 627 | double total_input_energy; |
| 628 | double total_input_duration; |
Ivo Creusen | 56d4609 | 2017-11-24 17:29:59 +0100 | [diff] [blame] | 629 | // TODO(bugs.webrtc.org/8572): Remove APM stats from this struct, since they |
| 630 | // are no longer needed now that we have apm_statistics. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 631 | float aec_quality_min; |
| 632 | int echo_delay_median_ms; |
| 633 | int echo_delay_std_ms; |
| 634 | int echo_return_loss; |
| 635 | int echo_return_loss_enhancement; |
ivoc | 8c63a82 | 2016-10-21 04:10:03 -0700 | [diff] [blame] | 636 | float residual_echo_likelihood; |
ivoc | 4e477a1 | 2017-01-15 08:29:46 -0800 | [diff] [blame] | 637 | float residual_echo_likelihood_recent_max; |
wu@webrtc.org | 967bfff | 2013-09-19 05:49:50 +0000 | [diff] [blame] | 638 | bool typing_noise_detected; |
ivoc | e1198e0 | 2017-09-08 08:13:19 -0700 | [diff] [blame] | 639 | webrtc::ANAStats ana_statistics; |
Ivo Creusen | 56d4609 | 2017-11-24 17:29:59 +0100 | [diff] [blame] | 640 | webrtc::AudioProcessingStats apm_statistics; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 641 | }; |
| 642 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 643 | struct VoiceReceiverInfo : public MediaReceiverInfo { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 644 | VoiceReceiverInfo() |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 645 | : ext_seqnum(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 646 | jitter_ms(0), |
| 647 | jitter_buffer_ms(0), |
| 648 | jitter_buffer_preferred_ms(0), |
| 649 | delay_estimate_ms(0), |
| 650 | audio_level(0), |
zstein | e76bd3a | 2017-07-14 12:17:49 -0700 | [diff] [blame] | 651 | total_output_energy(0.0), |
Steve Anton | 2dbc69f | 2017-08-24 17:15:13 -0700 | [diff] [blame] | 652 | total_samples_received(0), |
zstein | e76bd3a | 2017-07-14 12:17:49 -0700 | [diff] [blame] | 653 | total_output_duration(0.0), |
Steve Anton | 2dbc69f | 2017-08-24 17:15:13 -0700 | [diff] [blame] | 654 | concealed_samples(0), |
Gustaf Ullberg | 9a2e906 | 2017-09-18 09:28:20 +0200 | [diff] [blame] | 655 | concealment_events(0), |
Gustaf Ullberg | b0a0207 | 2017-10-02 12:00:34 +0200 | [diff] [blame] | 656 | jitter_buffer_delay_seconds(0), |
henrike@webrtc.org | b8c254a | 2014-02-14 23:38:45 +0000 | [diff] [blame] | 657 | expand_rate(0), |
minyue@webrtc.org | c0bd7be | 2015-02-18 15:24:13 +0000 | [diff] [blame] | 658 | speech_expand_rate(0), |
| 659 | secondary_decoded_rate(0), |
minyue-webrtc | 0e320ec | 2017-08-28 13:51:27 +0200 | [diff] [blame] | 660 | secondary_discarded_rate(0), |
Henrik Lundin | 8e6fd46 | 2015-06-02 09:24:52 +0200 | [diff] [blame] | 661 | accelerate_rate(0), |
| 662 | preemptive_expand_rate(0), |
henrike@webrtc.org | b8c254a | 2014-02-14 23:38:45 +0000 | [diff] [blame] | 663 | decoding_calls_to_silence_generator(0), |
| 664 | decoding_calls_to_neteq(0), |
| 665 | decoding_normal(0), |
| 666 | decoding_plc(0), |
| 667 | decoding_cng(0), |
buildbot@webrtc.org | b525a9d | 2014-06-03 09:42:15 +0000 | [diff] [blame] | 668 | decoding_plc_cng(0), |
henrik.lundin | 6348978 | 2016-09-20 01:47:12 -0700 | [diff] [blame] | 669 | decoding_muted_output(0), |
Henrik Lundin | 8e6fd46 | 2015-06-02 09:24:52 +0200 | [diff] [blame] | 670 | capture_start_ntp_time_ms(-1) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 671 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 672 | int ext_seqnum; |
| 673 | int jitter_ms; |
| 674 | int jitter_buffer_ms; |
| 675 | int jitter_buffer_preferred_ms; |
| 676 | int delay_estimate_ms; |
| 677 | int audio_level; |
Gustaf Ullberg | 9a2e906 | 2017-09-18 09:28:20 +0200 | [diff] [blame] | 678 | // Stats below correspond to similarly-named fields in the WebRTC stats spec. |
| 679 | // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats |
zstein | e76bd3a | 2017-07-14 12:17:49 -0700 | [diff] [blame] | 680 | double total_output_energy; |
Steve Anton | 2dbc69f | 2017-08-24 17:15:13 -0700 | [diff] [blame] | 681 | uint64_t total_samples_received; |
zstein | e76bd3a | 2017-07-14 12:17:49 -0700 | [diff] [blame] | 682 | double total_output_duration; |
Steve Anton | 2dbc69f | 2017-08-24 17:15:13 -0700 | [diff] [blame] | 683 | uint64_t concealed_samples; |
Gustaf Ullberg | 9a2e906 | 2017-09-18 09:28:20 +0200 | [diff] [blame] | 684 | uint64_t concealment_events; |
Gustaf Ullberg | b0a0207 | 2017-10-02 12:00:34 +0200 | [diff] [blame] | 685 | double jitter_buffer_delay_seconds; |
Gustaf Ullberg | 9a2e906 | 2017-09-18 09:28:20 +0200 | [diff] [blame] | 686 | // Stats below DO NOT correspond directly to anything in the WebRTC stats |
minyue@webrtc.org | c0bd7be | 2015-02-18 15:24:13 +0000 | [diff] [blame] | 687 | // fraction of synthesized audio inserted through expansion. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 688 | float expand_rate; |
minyue@webrtc.org | c0bd7be | 2015-02-18 15:24:13 +0000 | [diff] [blame] | 689 | // fraction of synthesized speech inserted through expansion. |
| 690 | float speech_expand_rate; |
| 691 | // fraction of data out of secondary decoding, including FEC and RED. |
| 692 | float secondary_decoded_rate; |
minyue-webrtc | 0e320ec | 2017-08-28 13:51:27 +0200 | [diff] [blame] | 693 | // Fraction of secondary data, including FEC and RED, that is discarded. |
| 694 | // Discarding of secondary data can be caused by the reception of the primary |
| 695 | // data, obsoleting the secondary data. It can also be caused by early |
| 696 | // or late arrival of secondary data. This metric is the percentage of |
| 697 | // discarded secondary data since last query of receiver info. |
| 698 | float secondary_discarded_rate; |
Henrik Lundin | 8e6fd46 | 2015-06-02 09:24:52 +0200 | [diff] [blame] | 699 | // Fraction of data removed through time compression. |
| 700 | float accelerate_rate; |
| 701 | // Fraction of data inserted through time stretching. |
| 702 | float preemptive_expand_rate; |
henrike@webrtc.org | b8c254a | 2014-02-14 23:38:45 +0000 | [diff] [blame] | 703 | int decoding_calls_to_silence_generator; |
| 704 | int decoding_calls_to_neteq; |
| 705 | int decoding_normal; |
| 706 | int decoding_plc; |
| 707 | int decoding_cng; |
| 708 | int decoding_plc_cng; |
henrik.lundin | 6348978 | 2016-09-20 01:47:12 -0700 | [diff] [blame] | 709 | int decoding_muted_output; |
buildbot@webrtc.org | b525a9d | 2014-06-03 09:42:15 +0000 | [diff] [blame] | 710 | // Estimated capture start time in NTP time in ms. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 711 | int64_t capture_start_ntp_time_ms; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 712 | }; |
| 713 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 714 | struct VideoSenderInfo : public MediaSenderInfo { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 715 | VideoSenderInfo() |
pbos@webrtc.org | 1ed6224 | 2015-02-19 13:57:03 +0000 | [diff] [blame] | 716 | : packets_cached(0), |
| 717 | firs_rcvd(0), |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 718 | plis_rcvd(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 719 | nacks_rcvd(0), |
wu@webrtc.org | 987f2c9 | 2014-03-28 16:22:19 +0000 | [diff] [blame] | 720 | send_frame_width(0), |
| 721 | send_frame_height(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 722 | framerate_input(0), |
| 723 | framerate_sent(0), |
| 724 | nominal_bitrate(0), |
| 725 | preferred_bitrate(0), |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 726 | adapt_reason(0), |
buildbot@webrtc.org | 71dffb7 | 2014-06-24 07:24:49 +0000 | [diff] [blame] | 727 | adapt_changes(0), |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 728 | avg_encode_ms(0), |
sakal | 43536c3 | 2016-10-24 01:46:43 -0700 | [diff] [blame] | 729 | encode_usage_percent(0), |
ilnik | 50864a8 | 2017-09-06 12:32:35 -0700 | [diff] [blame] | 730 | frames_encoded(0), |
Åsa Persson | c3ed630 | 2017-11-16 14:04:52 +0100 | [diff] [blame] | 731 | has_entered_low_resolution(false), |
ilnik | 50864a8 | 2017-09-06 12:32:35 -0700 | [diff] [blame] | 732 | content_type(webrtc::VideoContentType::UNSPECIFIED) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 733 | |
pbos@webrtc.org | 1ed6224 | 2015-02-19 13:57:03 +0000 | [diff] [blame] | 734 | std::vector<SsrcGroup> ssrc_groups; |
hbos | a65704b | 2016-11-14 02:28:16 -0800 | [diff] [blame] | 735 | // TODO(hbos): Move this to |VideoMediaInfo::send_codecs|? |
Peter Boström | b7d9a97 | 2015-12-18 16:01:11 +0100 | [diff] [blame] | 736 | std::string encoder_implementation_name; |
pbos@webrtc.org | 1ed6224 | 2015-02-19 13:57:03 +0000 | [diff] [blame] | 737 | int packets_cached; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 738 | int firs_rcvd; |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 739 | int plis_rcvd; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 740 | int nacks_rcvd; |
wu@webrtc.org | 987f2c9 | 2014-03-28 16:22:19 +0000 | [diff] [blame] | 741 | int send_frame_width; |
| 742 | int send_frame_height; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 743 | int framerate_input; |
| 744 | int framerate_sent; |
| 745 | int nominal_bitrate; |
| 746 | int preferred_bitrate; |
| 747 | int adapt_reason; |
buildbot@webrtc.org | 71dffb7 | 2014-06-24 07:24:49 +0000 | [diff] [blame] | 748 | int adapt_changes; |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 749 | int avg_encode_ms; |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 750 | int encode_usage_percent; |
sakal | 43536c3 | 2016-10-24 01:46:43 -0700 | [diff] [blame] | 751 | uint32_t frames_encoded; |
Åsa Persson | c3ed630 | 2017-11-16 14:04:52 +0100 | [diff] [blame] | 752 | bool has_entered_low_resolution; |
sakal | 87da404 | 2016-10-31 06:53:47 -0700 | [diff] [blame] | 753 | rtc::Optional<uint64_t> qp_sum; |
ilnik | 50864a8 | 2017-09-06 12:32:35 -0700 | [diff] [blame] | 754 | webrtc::VideoContentType content_type; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 755 | }; |
| 756 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 757 | struct VideoReceiverInfo : public MediaReceiverInfo { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 758 | VideoReceiverInfo() |
pbos@webrtc.org | 1ed6224 | 2015-02-19 13:57:03 +0000 | [diff] [blame] | 759 | : packets_concealed(0), |
| 760 | firs_sent(0), |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 761 | plis_sent(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 762 | nacks_sent(0), |
| 763 | frame_width(0), |
| 764 | frame_height(0), |
| 765 | framerate_rcvd(0), |
| 766 | framerate_decoded(0), |
| 767 | framerate_output(0), |
pbos@webrtc.org | 1ed6224 | 2015-02-19 13:57:03 +0000 | [diff] [blame] | 768 | framerate_render_input(0), |
| 769 | framerate_render_output(0), |
hbos | 42f6d2f | 2017-01-20 03:56:50 -0800 | [diff] [blame] | 770 | frames_received(0), |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 771 | frames_decoded(0), |
hbos | 50cfe1f | 2017-01-23 07:21:55 -0800 | [diff] [blame] | 772 | frames_rendered(0), |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 773 | interframe_delay_max_ms(-1), |
ilnik | 2e1b40b | 2017-09-04 07:57:17 -0700 | [diff] [blame] | 774 | content_type(webrtc::VideoContentType::UNSPECIFIED), |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 775 | decode_ms(0), |
| 776 | max_decode_ms(0), |
| 777 | jitter_buffer_ms(0), |
| 778 | min_playout_delay_ms(0), |
| 779 | render_delay_ms(0), |
| 780 | target_delay_ms(0), |
buildbot@webrtc.org | 0581f0b | 2014-05-06 21:36:31 +0000 | [diff] [blame] | 781 | current_delay_ms(0), |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 782 | capture_start_ntp_time_ms(-1) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 783 | |
pbos@webrtc.org | 1ed6224 | 2015-02-19 13:57:03 +0000 | [diff] [blame] | 784 | std::vector<SsrcGroup> ssrc_groups; |
hbos | a65704b | 2016-11-14 02:28:16 -0800 | [diff] [blame] | 785 | // TODO(hbos): Move this to |VideoMediaInfo::receive_codecs|? |
Peter Boström | b7d9a97 | 2015-12-18 16:01:11 +0100 | [diff] [blame] | 786 | std::string decoder_implementation_name; |
pbos@webrtc.org | 1ed6224 | 2015-02-19 13:57:03 +0000 | [diff] [blame] | 787 | int packets_concealed; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 788 | int firs_sent; |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 789 | int plis_sent; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 790 | int nacks_sent; |
| 791 | int frame_width; |
| 792 | int frame_height; |
| 793 | int framerate_rcvd; |
| 794 | int framerate_decoded; |
| 795 | int framerate_output; |
pbos@webrtc.org | 1ed6224 | 2015-02-19 13:57:03 +0000 | [diff] [blame] | 796 | // Framerate as sent to the renderer. |
| 797 | int framerate_render_input; |
| 798 | // Framerate that the renderer reports. |
| 799 | int framerate_render_output; |
hbos | 42f6d2f | 2017-01-20 03:56:50 -0800 | [diff] [blame] | 800 | uint32_t frames_received; |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 801 | uint32_t frames_decoded; |
hbos | 50cfe1f | 2017-01-23 07:21:55 -0800 | [diff] [blame] | 802 | uint32_t frames_rendered; |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 803 | rtc::Optional<uint64_t> qp_sum; |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 804 | int64_t interframe_delay_max_ms; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 805 | |
ilnik | 2e1b40b | 2017-09-04 07:57:17 -0700 | [diff] [blame] | 806 | webrtc::VideoContentType content_type; |
| 807 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 808 | // All stats below are gathered per-VideoReceiver, but some will be correlated |
| 809 | // across MediaStreamTracks. NOTE(hta): when sinking stats into per-SSRC |
| 810 | // structures, reflect this in the new layout. |
| 811 | |
| 812 | // Current frame decode latency. |
| 813 | int decode_ms; |
| 814 | // Maximum observed frame decode latency. |
| 815 | int max_decode_ms; |
| 816 | // Jitter (network-related) latency. |
| 817 | int jitter_buffer_ms; |
| 818 | // Requested minimum playout latency. |
| 819 | int min_playout_delay_ms; |
| 820 | // Requested latency to account for rendering delay. |
| 821 | int render_delay_ms; |
| 822 | // Target overall delay: network+decode+render, accounting for |
| 823 | // min_playout_delay_ms. |
| 824 | int target_delay_ms; |
| 825 | // Current overall delay, possibly ramping towards target_delay_ms. |
| 826 | int current_delay_ms; |
buildbot@webrtc.org | 0581f0b | 2014-05-06 21:36:31 +0000 | [diff] [blame] | 827 | |
| 828 | // Estimated capture start time in NTP time in ms. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 829 | int64_t capture_start_ntp_time_ms; |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 830 | |
| 831 | // Timing frame info: all important timestamps for a full lifetime of a |
| 832 | // single 'timing frame'. |
| 833 | rtc::Optional<webrtc::TimingFrameInfo> timing_frame_info; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 834 | }; |
| 835 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 836 | struct DataSenderInfo : public MediaSenderInfo { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 837 | DataSenderInfo() |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 838 | : ssrc(0) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 839 | } |
| 840 | |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 841 | uint32_t ssrc; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 842 | }; |
| 843 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 844 | struct DataReceiverInfo : public MediaReceiverInfo { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 845 | DataReceiverInfo() |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 846 | : ssrc(0) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 847 | } |
| 848 | |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 849 | uint32_t ssrc; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 850 | }; |
| 851 | |
| 852 | struct BandwidthEstimationInfo { |
| 853 | BandwidthEstimationInfo() |
| 854 | : available_send_bandwidth(0), |
| 855 | available_recv_bandwidth(0), |
| 856 | target_enc_bitrate(0), |
| 857 | actual_enc_bitrate(0), |
| 858 | retransmit_bitrate(0), |
| 859 | transmit_bitrate(0), |
pbos@webrtc.org | 058b1f1 | 2015-03-04 08:54:32 +0000 | [diff] [blame] | 860 | bucket_delay(0) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 861 | } |
| 862 | |
| 863 | int available_send_bandwidth; |
| 864 | int available_recv_bandwidth; |
| 865 | int target_enc_bitrate; |
| 866 | int actual_enc_bitrate; |
| 867 | int retransmit_bitrate; |
| 868 | int transmit_bitrate; |
pkasting@chromium.org | 16825b1 | 2015-01-12 21:51:21 +0000 | [diff] [blame] | 869 | int64_t bucket_delay; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 870 | }; |
| 871 | |
hbos | a65704b | 2016-11-14 02:28:16 -0800 | [diff] [blame] | 872 | // Maps from payload type to |RtpCodecParameters|. |
| 873 | typedef std::map<int, webrtc::RtpCodecParameters> RtpCodecParametersMap; |
| 874 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 875 | struct VoiceMediaInfo { |
| 876 | void Clear() { |
| 877 | senders.clear(); |
| 878 | receivers.clear(); |
hbos | 1acfbd2 | 2016-11-17 23:43:29 -0800 | [diff] [blame] | 879 | send_codecs.clear(); |
| 880 | receive_codecs.clear(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 881 | } |
| 882 | std::vector<VoiceSenderInfo> senders; |
| 883 | std::vector<VoiceReceiverInfo> receivers; |
hbos | 1acfbd2 | 2016-11-17 23:43:29 -0800 | [diff] [blame] | 884 | RtpCodecParametersMap send_codecs; |
| 885 | RtpCodecParametersMap receive_codecs; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 886 | }; |
| 887 | |
| 888 | struct VideoMediaInfo { |
| 889 | void Clear() { |
| 890 | senders.clear(); |
| 891 | receivers.clear(); |
charujain | d72098a | 2017-06-01 08:54:47 -0700 | [diff] [blame] | 892 | bw_estimations.clear(); |
hbos | a65704b | 2016-11-14 02:28:16 -0800 | [diff] [blame] | 893 | send_codecs.clear(); |
| 894 | receive_codecs.clear(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 895 | } |
| 896 | std::vector<VideoSenderInfo> senders; |
| 897 | std::vector<VideoReceiverInfo> receivers; |
stefan | f79ade1 | 2017-06-02 06:44:03 -0700 | [diff] [blame] | 898 | // Deprecated. |
| 899 | // TODO(holmer): Remove once upstream projects no longer use this. |
charujain | d72098a | 2017-06-01 08:54:47 -0700 | [diff] [blame] | 900 | std::vector<BandwidthEstimationInfo> bw_estimations; |
hbos | a65704b | 2016-11-14 02:28:16 -0800 | [diff] [blame] | 901 | RtpCodecParametersMap send_codecs; |
| 902 | RtpCodecParametersMap receive_codecs; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 903 | }; |
| 904 | |
| 905 | struct DataMediaInfo { |
| 906 | void Clear() { |
| 907 | senders.clear(); |
| 908 | receivers.clear(); |
| 909 | } |
| 910 | std::vector<DataSenderInfo> senders; |
| 911 | std::vector<DataReceiverInfo> receivers; |
| 912 | }; |
| 913 | |
deadbeef | 1387149 | 2015-12-09 12:37:51 -0800 | [diff] [blame] | 914 | struct RtcpParameters { |
| 915 | bool reduced_size = false; |
| 916 | }; |
| 917 | |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 918 | template <class Codec> |
| 919 | struct RtpParameters { |
solenberg | 7e4e01a | 2015-12-02 08:05:01 -0800 | [diff] [blame] | 920 | virtual std::string ToString() const { |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 921 | std::ostringstream ost; |
| 922 | ost << "{"; |
| 923 | ost << "codecs: " << VectorToString(codecs) << ", "; |
| 924 | ost << "extensions: " << VectorToString(extensions); |
| 925 | ost << "}"; |
| 926 | return ost.str(); |
| 927 | } |
| 928 | |
| 929 | std::vector<Codec> codecs; |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 930 | std::vector<webrtc::RtpExtension> extensions; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 931 | // TODO(pthatcher): Add streams. |
deadbeef | 1387149 | 2015-12-09 12:37:51 -0800 | [diff] [blame] | 932 | RtcpParameters rtcp; |
Henrik Kjellander | 3fe372d | 2016-05-12 08:10:52 +0200 | [diff] [blame] | 933 | virtual ~RtpParameters() = default; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 934 | }; |
| 935 | |
Taylor Brandstetter | 5f0b83b | 2016-03-18 15:02:07 -0700 | [diff] [blame] | 936 | // TODO(deadbeef): Rename to RtpSenderParameters, since they're intended to |
| 937 | // encapsulate all the parameters needed for an RtpSender. |
nisse | 0510331 | 2016-03-16 02:22:50 -0700 | [diff] [blame] | 938 | template <class Codec> |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 939 | struct RtpSendParameters : RtpParameters<Codec> { |
solenberg | 7e4e01a | 2015-12-02 08:05:01 -0800 | [diff] [blame] | 940 | std::string ToString() const override { |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 941 | std::ostringstream ost; |
| 942 | ost << "{"; |
| 943 | ost << "codecs: " << VectorToString(this->codecs) << ", "; |
| 944 | ost << "extensions: " << VectorToString(this->extensions) << ", "; |
pbos | 378dc77 | 2016-01-28 15:58:41 -0800 | [diff] [blame] | 945 | ost << "max_bandwidth_bps: " << max_bandwidth_bps << ", "; |
nisse | 0510331 | 2016-03-16 02:22:50 -0700 | [diff] [blame] | 946 | ost << "}"; |
| 947 | return ost.str(); |
| 948 | } |
| 949 | |
| 950 | int max_bandwidth_bps = -1; |
| 951 | }; |
| 952 | |
| 953 | struct AudioSendParameters : RtpSendParameters<AudioCodec> { |
| 954 | std::string ToString() const override { |
| 955 | std::ostringstream ost; |
| 956 | ost << "{"; |
| 957 | ost << "codecs: " << VectorToString(this->codecs) << ", "; |
| 958 | ost << "extensions: " << VectorToString(this->extensions) << ", "; |
| 959 | ost << "max_bandwidth_bps: " << max_bandwidth_bps << ", "; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 960 | ost << "options: " << options.ToString(); |
| 961 | ost << "}"; |
| 962 | return ost.str(); |
| 963 | } |
| 964 | |
nisse | 0510331 | 2016-03-16 02:22:50 -0700 | [diff] [blame] | 965 | AudioOptions options; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 966 | }; |
| 967 | |
| 968 | struct AudioRecvParameters : RtpParameters<AudioCodec> { |
| 969 | }; |
| 970 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 971 | class VoiceMediaChannel : public MediaChannel { |
| 972 | public: |
| 973 | enum Error { |
| 974 | ERROR_NONE = 0, // No error. |
| 975 | ERROR_OTHER, // Other errors. |
| 976 | ERROR_REC_DEVICE_OPEN_FAILED = 100, // Could not open mic. |
| 977 | ERROR_REC_DEVICE_MUTED, // Mic was muted by OS. |
| 978 | ERROR_REC_DEVICE_SILENT, // No background noise picked up. |
| 979 | ERROR_REC_DEVICE_SATURATION, // Mic input is clipping. |
| 980 | ERROR_REC_DEVICE_REMOVED, // Mic was removed while active. |
| 981 | ERROR_REC_RUNTIME_ERROR, // Processing is encountering errors. |
| 982 | ERROR_REC_SRTP_ERROR, // Generic SRTP failure. |
| 983 | ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 984 | ERROR_REC_TYPING_NOISE_DETECTED, // Typing noise is detected. |
| 985 | ERROR_PLAY_DEVICE_OPEN_FAILED = 200, // Could not open playout. |
| 986 | ERROR_PLAY_DEVICE_MUTED, // Playout muted by OS. |
| 987 | ERROR_PLAY_DEVICE_REMOVED, // Playout removed while active. |
| 988 | ERROR_PLAY_RUNTIME_ERROR, // Errors in voice processing. |
| 989 | ERROR_PLAY_SRTP_ERROR, // Generic SRTP failure. |
| 990 | ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 991 | ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. |
| 992 | }; |
| 993 | |
| 994 | VoiceMediaChannel() {} |
terelius | 54f9171 | 2016-06-01 11:18:56 -0700 | [diff] [blame] | 995 | explicit VoiceMediaChannel(const MediaConfig& config) |
| 996 | : MediaChannel(config) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 997 | virtual ~VoiceMediaChannel() {} |
Fredrik Solenberg | b071a19 | 2015-09-17 16:42:56 +0200 | [diff] [blame] | 998 | virtual bool SetSendParameters(const AudioSendParameters& params) = 0; |
| 999 | virtual bool SetRecvParameters(const AudioRecvParameters& params) = 0; |
Taylor Brandstetter | db0cd9e | 2016-05-16 11:40:30 -0700 | [diff] [blame] | 1000 | virtual webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const = 0; |
| 1001 | virtual bool SetRtpSendParameters( |
| 1002 | uint32_t ssrc, |
| 1003 | const webrtc::RtpParameters& parameters) = 0; |
deadbeef | 3bc1510 | 2017-04-20 19:25:07 -0700 | [diff] [blame] | 1004 | // Get the receive parameters for the incoming stream identified by |ssrc|. |
| 1005 | // If |ssrc| is 0, retrieve the receive parameters for the default receive |
| 1006 | // stream, which is used when SSRCs are not signaled. Note that calling with |
| 1007 | // an |ssrc| of 0 will return encoding parameters with an unset |ssrc| |
| 1008 | // member. |
Taylor Brandstetter | db0cd9e | 2016-05-16 11:40:30 -0700 | [diff] [blame] | 1009 | virtual webrtc::RtpParameters GetRtpReceiveParameters( |
| 1010 | uint32_t ssrc) const = 0; |
| 1011 | virtual bool SetRtpReceiveParameters( |
| 1012 | uint32_t ssrc, |
| 1013 | const webrtc::RtpParameters& parameters) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1014 | // Starts or stops playout of received audio. |
aleloi | 84ef615 | 2016-08-04 05:28:21 -0700 | [diff] [blame] | 1015 | virtual void SetPlayout(bool playout) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1016 | // Starts or stops sending (and potentially capture) of local audio. |
Taylor Brandstetter | 1a018dc | 2016-03-08 12:37:39 -0800 | [diff] [blame] | 1017 | virtual void SetSend(bool send) = 0; |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 1018 | // Configure stream for sending. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 1019 | virtual bool SetAudioSend(uint32_t ssrc, |
| 1020 | bool enable, |
solenberg | dfc8f4f | 2015-10-01 02:31:10 -0700 | [diff] [blame] | 1021 | const AudioOptions* options, |
Taylor Brandstetter | 1a018dc | 2016-03-08 12:37:39 -0800 | [diff] [blame] | 1022 | AudioSource* source) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1023 | // Gets current energy levels for all incoming streams. |
Patrik Höglund | aba85d1 | 2017-11-28 15:46:08 +0100 | [diff] [blame^] | 1024 | typedef std::vector<std::pair<uint32_t, int>> StreamList; |
| 1025 | virtual bool GetActiveStreams(StreamList* actives) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1026 | // Get the current energy level of the stream sent to the speaker. |
| 1027 | virtual int GetOutputLevel() = 0; |
solenberg | 4bac9c5 | 2015-10-09 02:32:53 -0700 | [diff] [blame] | 1028 | // Set speaker output volume of the specified ssrc. |
| 1029 | virtual bool SetOutputVolume(uint32_t ssrc, double volume) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1030 | // Returns if the telephone-event has been negotiated. |
solenberg | 1d63dd0 | 2015-12-02 12:35:09 -0800 | [diff] [blame] | 1031 | virtual bool CanInsertDtmf() = 0; |
| 1032 | // Send a DTMF |event|. The DTMF out-of-band signal will be used. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1033 | // 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] | 1034 | // The valid value for the |event| are 0 to 15 which corresponding to |
| 1035 | // DTMF event 0-9, *, #, A-D. |
solenberg | 1d63dd0 | 2015-12-02 12:35:09 -0800 | [diff] [blame] | 1036 | virtual bool InsertDtmf(uint32_t ssrc, int event, int duration) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1037 | // Gets quality stats for the channel. |
| 1038 | virtual bool GetStats(VoiceMediaInfo* info) = 0; |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 1039 | |
| 1040 | virtual void SetRawAudioSink( |
| 1041 | uint32_t ssrc, |
kwiberg | 686a8ef | 2016-02-26 03:00:35 -0800 | [diff] [blame] | 1042 | std::unique_ptr<webrtc::AudioSinkInterface> sink) = 0; |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 1043 | |
| 1044 | virtual std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1045 | }; |
| 1046 | |
Taylor Brandstetter | 5f0b83b | 2016-03-18 15:02:07 -0700 | [diff] [blame] | 1047 | // TODO(deadbeef): Rename to VideoSenderParameters, since they're intended to |
| 1048 | // encapsulate all the parameters needed for a video RtpSender. |
nisse | 0510331 | 2016-03-16 02:22:50 -0700 | [diff] [blame] | 1049 | struct VideoSendParameters : RtpSendParameters<VideoCodec> { |
nisse | 4b4dc86 | 2016-02-17 05:25:36 -0800 | [diff] [blame] | 1050 | // Use conference mode? This flag comes from the remote |
| 1051 | // description's SDP line 'a=x-google-flag:conference', copied over |
| 1052 | // by VideoChannel::SetRemoteContent_w, and ultimately used by |
| 1053 | // conference mode screencast logic in |
eladalon | f184138 | 2017-06-12 01:16:46 -0700 | [diff] [blame] | 1054 | // WebRtcVideoChannel::WebRtcVideoSendStream::CreateVideoEncoderConfig. |
nisse | 4b4dc86 | 2016-02-17 05:25:36 -0800 | [diff] [blame] | 1055 | // The special screencast behaviour is disabled by default. |
| 1056 | bool conference_mode = false; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 1057 | }; |
| 1058 | |
Taylor Brandstetter | 5f0b83b | 2016-03-18 15:02:07 -0700 | [diff] [blame] | 1059 | // TODO(deadbeef): Rename to VideoReceiverParameters, since they're intended to |
| 1060 | // encapsulate all the parameters needed for a video RtpReceiver. |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 1061 | struct VideoRecvParameters : RtpParameters<VideoCodec> { |
| 1062 | }; |
| 1063 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1064 | class VideoMediaChannel : public MediaChannel { |
| 1065 | public: |
| 1066 | enum Error { |
| 1067 | ERROR_NONE = 0, // No error. |
| 1068 | ERROR_OTHER, // Other errors. |
| 1069 | ERROR_REC_DEVICE_OPEN_FAILED = 100, // Could not open camera. |
| 1070 | ERROR_REC_DEVICE_NO_DEVICE, // No camera. |
| 1071 | ERROR_REC_DEVICE_IN_USE, // Device is in already use. |
| 1072 | ERROR_REC_DEVICE_REMOVED, // Device is removed. |
| 1073 | ERROR_REC_SRTP_ERROR, // Generic sender SRTP failure. |
| 1074 | ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 1075 | ERROR_REC_CPU_MAX_CANT_DOWNGRADE, // Can't downgrade capture anymore. |
| 1076 | ERROR_PLAY_SRTP_ERROR = 200, // Generic receiver SRTP failure. |
| 1077 | ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 1078 | ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. |
| 1079 | }; |
| 1080 | |
nisse | 08582ff | 2016-02-04 01:24:52 -0800 | [diff] [blame] | 1081 | VideoMediaChannel() {} |
terelius | 54f9171 | 2016-06-01 11:18:56 -0700 | [diff] [blame] | 1082 | explicit VideoMediaChannel(const MediaConfig& config) |
| 1083 | : MediaChannel(config) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1084 | virtual ~VideoMediaChannel() {} |
Fredrik Solenberg | b071a19 | 2015-09-17 16:42:56 +0200 | [diff] [blame] | 1085 | |
| 1086 | virtual bool SetSendParameters(const VideoSendParameters& params) = 0; |
| 1087 | virtual bool SetRecvParameters(const VideoRecvParameters& params) = 0; |
Taylor Brandstetter | db0cd9e | 2016-05-16 11:40:30 -0700 | [diff] [blame] | 1088 | virtual webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const = 0; |
| 1089 | virtual bool SetRtpSendParameters( |
| 1090 | uint32_t ssrc, |
| 1091 | const webrtc::RtpParameters& parameters) = 0; |
deadbeef | 3bc1510 | 2017-04-20 19:25:07 -0700 | [diff] [blame] | 1092 | // Get the receive parameters for the incoming stream identified by |ssrc|. |
| 1093 | // If |ssrc| is 0, retrieve the receive parameters for the default receive |
| 1094 | // stream, which is used when SSRCs are not signaled. Note that calling with |
| 1095 | // an |ssrc| of 0 will return encoding parameters with an unset |ssrc| |
| 1096 | // member. |
Taylor Brandstetter | db0cd9e | 2016-05-16 11:40:30 -0700 | [diff] [blame] | 1097 | virtual webrtc::RtpParameters GetRtpReceiveParameters( |
| 1098 | uint32_t ssrc) const = 0; |
| 1099 | virtual bool SetRtpReceiveParameters( |
| 1100 | uint32_t ssrc, |
| 1101 | const webrtc::RtpParameters& parameters) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1102 | // Gets the currently set codecs/payload types to be used for outgoing media. |
| 1103 | virtual bool GetSendCodec(VideoCodec* send_codec) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1104 | // Starts or stops transmission (and potentially capture) of local video. |
| 1105 | virtual bool SetSend(bool send) = 0; |
deadbeef | 5a4a75a | 2016-06-02 16:23:38 -0700 | [diff] [blame] | 1106 | // Configure stream for sending and register a source. |
| 1107 | // The |ssrc| must correspond to a registered send stream. |
| 1108 | virtual bool SetVideoSend( |
| 1109 | uint32_t ssrc, |
| 1110 | bool enable, |
| 1111 | const VideoOptions* options, |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 1112 | rtc::VideoSourceInterface<webrtc::VideoFrame>* source) = 0; |
nisse | 08582ff | 2016-02-04 01:24:52 -0800 | [diff] [blame] | 1113 | // Sets the sink object to be used for the specified stream. |
deadbeef | 3bc1510 | 2017-04-20 19:25:07 -0700 | [diff] [blame] | 1114 | // If SSRC is 0, the sink is used for the 'default' stream. |
nisse | 08582ff | 2016-02-04 01:24:52 -0800 | [diff] [blame] | 1115 | virtual bool SetSink(uint32_t ssrc, |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 1116 | rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) = 0; |
stefan | f79ade1 | 2017-06-02 06:44:03 -0700 | [diff] [blame] | 1117 | // This fills the "bitrate parts" (rtx, video bitrate) of the |
| 1118 | // BandwidthEstimationInfo, since that part that isn't possible to get |
| 1119 | // through webrtc::Call::GetStats, as they are statistics of the send |
| 1120 | // streams. |
| 1121 | // TODO(holmer): We should change this so that either BWE graphs doesn't |
| 1122 | // need access to bitrates of the streams, or change the (RTC)StatsCollector |
| 1123 | // so that it's getting the send stream stats separately by calling |
| 1124 | // GetStats(), and merges with BandwidthEstimationInfo by itself. |
| 1125 | virtual void FillBitrateInfo(BandwidthEstimationInfo* bwe_info) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1126 | // Gets quality stats for the channel. |
pbos@webrtc.org | 058b1f1 | 2015-03-04 08:54:32 +0000 | [diff] [blame] | 1127 | virtual bool GetStats(VideoMediaInfo* info) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1128 | }; |
| 1129 | |
| 1130 | enum DataMessageType { |
mallinath@webrtc.org | 1112c30 | 2013-09-23 20:34:45 +0000 | [diff] [blame] | 1131 | // Chrome-Internal use only. See SctpDataMediaChannel for the actual PPID |
| 1132 | // values. |
| 1133 | DMT_NONE = 0, |
| 1134 | DMT_CONTROL = 1, |
| 1135 | DMT_BINARY = 2, |
| 1136 | DMT_TEXT = 3, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1137 | }; |
| 1138 | |
| 1139 | // Info about data received in DataMediaChannel. For use in |
| 1140 | // DataMediaChannel::SignalDataReceived and in all of the signals that |
| 1141 | // signal fires, on up the chain. |
| 1142 | struct ReceiveDataParams { |
| 1143 | // The in-packet stream indentifier. |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 1144 | // RTP data channels use SSRCs, SCTP data channels use SIDs. |
| 1145 | union { |
| 1146 | uint32_t ssrc; |
| 1147 | int sid; |
| 1148 | }; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1149 | // The type of message (binary, text, or control). |
| 1150 | DataMessageType type; |
| 1151 | // A per-stream value incremented per packet in the stream. |
| 1152 | int seq_num; |
| 1153 | // A per-stream value monotonically increasing with time. |
| 1154 | int timestamp; |
| 1155 | |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 1156 | ReceiveDataParams() : sid(0), type(DMT_TEXT), seq_num(0), timestamp(0) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1157 | }; |
| 1158 | |
| 1159 | struct SendDataParams { |
| 1160 | // The in-packet stream indentifier. |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 1161 | // RTP data channels use SSRCs, SCTP data channels use SIDs. |
| 1162 | union { |
| 1163 | uint32_t ssrc; |
| 1164 | int sid; |
| 1165 | }; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1166 | // The type of message (binary, text, or control). |
| 1167 | DataMessageType type; |
| 1168 | |
| 1169 | // For SCTP, whether to send messages flagged as ordered or not. |
| 1170 | // If false, messages can be received out of order. |
| 1171 | bool ordered; |
| 1172 | // For SCTP, whether the messages are sent reliably or not. |
| 1173 | // If false, messages may be lost. |
| 1174 | bool reliable; |
| 1175 | // For SCTP, if reliable == false, provide partial reliability by |
| 1176 | // resending up to this many times. Either count or millis |
| 1177 | // is supported, not both at the same time. |
| 1178 | int max_rtx_count; |
| 1179 | // For SCTP, if reliable == false, provide partial reliability by |
| 1180 | // resending for up to this many milliseconds. Either count or millis |
| 1181 | // is supported, not both at the same time. |
| 1182 | int max_rtx_ms; |
| 1183 | |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 1184 | SendDataParams() |
| 1185 | : sid(0), |
| 1186 | type(DMT_TEXT), |
| 1187 | // TODO(pthatcher): Make these true by default? |
| 1188 | ordered(false), |
| 1189 | reliable(false), |
| 1190 | max_rtx_count(0), |
| 1191 | max_rtx_ms(0) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1192 | }; |
| 1193 | |
| 1194 | enum SendDataResult { SDR_SUCCESS, SDR_ERROR, SDR_BLOCK }; |
| 1195 | |
nisse | 0510331 | 2016-03-16 02:22:50 -0700 | [diff] [blame] | 1196 | struct DataSendParameters : RtpSendParameters<DataCodec> { |
solenberg | 7e4e01a | 2015-12-02 08:05:01 -0800 | [diff] [blame] | 1197 | std::string ToString() const { |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 1198 | std::ostringstream ost; |
| 1199 | // Options and extensions aren't used. |
| 1200 | ost << "{"; |
| 1201 | ost << "codecs: " << VectorToString(codecs) << ", "; |
pbos | 378dc77 | 2016-01-28 15:58:41 -0800 | [diff] [blame] | 1202 | ost << "max_bandwidth_bps: " << max_bandwidth_bps; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 1203 | ost << "}"; |
| 1204 | return ost.str(); |
| 1205 | } |
| 1206 | }; |
| 1207 | |
| 1208 | struct DataRecvParameters : RtpParameters<DataCodec> { |
| 1209 | }; |
| 1210 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1211 | class DataMediaChannel : public MediaChannel { |
| 1212 | public: |
| 1213 | enum Error { |
| 1214 | ERROR_NONE = 0, // No error. |
| 1215 | ERROR_OTHER, // Other errors. |
| 1216 | ERROR_SEND_SRTP_ERROR = 200, // Generic SRTP failure. |
| 1217 | ERROR_SEND_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 1218 | ERROR_RECV_SRTP_ERROR, // Generic SRTP failure. |
| 1219 | ERROR_RECV_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 1220 | ERROR_RECV_SRTP_REPLAY, // Packet replay detected. |
| 1221 | }; |
| 1222 | |
zhihuang | ebbe4f2 | 2016-12-06 10:45:42 -0800 | [diff] [blame] | 1223 | DataMediaChannel() {} |
Steve Anton | e78bcb9 | 2017-10-31 09:53:08 -0700 | [diff] [blame] | 1224 | explicit DataMediaChannel(const MediaConfig& config) : MediaChannel(config) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1225 | virtual ~DataMediaChannel() {} |
| 1226 | |
Fredrik Solenberg | b071a19 | 2015-09-17 16:42:56 +0200 | [diff] [blame] | 1227 | virtual bool SetSendParameters(const DataSendParameters& params) = 0; |
| 1228 | virtual bool SetRecvParameters(const DataRecvParameters& params) = 0; |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 1229 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1230 | // TODO(pthatcher): Implement this. |
| 1231 | virtual bool GetStats(DataMediaInfo* info) { return true; } |
| 1232 | |
| 1233 | virtual bool SetSend(bool send) = 0; |
| 1234 | virtual bool SetReceive(bool receive) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1235 | |
Honghai Zhang | cc411c0 | 2016-03-29 17:27:21 -0700 | [diff] [blame] | 1236 | virtual void OnNetworkRouteChanged(const std::string& transport_name, |
Honghai Zhang | 0e533ef | 2016-04-19 15:41:36 -0700 | [diff] [blame] | 1237 | const rtc::NetworkRoute& network_route) {} |
Honghai Zhang | cc411c0 | 2016-03-29 17:27:21 -0700 | [diff] [blame] | 1238 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1239 | virtual bool SendData( |
| 1240 | const SendDataParams& params, |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 1241 | const rtc::CopyOnWriteBuffer& payload, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1242 | SendDataResult* result = NULL) = 0; |
| 1243 | // Signals when data is received (params, data, len) |
| 1244 | sigslot::signal3<const ReceiveDataParams&, |
| 1245 | const char*, |
| 1246 | size_t> SignalDataReceived; |
wu@webrtc.org | d64719d | 2013-08-01 00:00:07 +0000 | [diff] [blame] | 1247 | // Signal when the media channel is ready to send the stream. Arguments are: |
| 1248 | // writable(bool) |
| 1249 | sigslot::signal1<bool> SignalReadyToSend; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1250 | }; |
| 1251 | |
| 1252 | } // namespace cricket |
| 1253 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 1254 | #endif // MEDIA_BASE_MEDIACHANNEL_H_ |