blob: f4753ec4c18fdbf9354c47704422a82f029329c9 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellander1afca732016-02-07 20:46:45 -08002 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellander1afca732016-02-07 20:46:45 -08004 * 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.org28e20752013-07-10 00:45:36 +00009 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MEDIA_BASE_MEDIACHANNEL_H_
12#define MEDIA_BASE_MEDIACHANNEL_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000013
Steve Antone78bcb92017-10-31 09:53:08 -070014#include <map>
kwiberg686a8ef2016-02-26 03:00:35 -080015#include <memory>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000016#include <string>
Patrik Höglundaba85d12017-11-28 15:46:08 +010017#include <utility>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000018#include <vector>
19
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "api/audio_codecs/audio_encoder.h"
21#include "api/optional.h"
22#include "api/rtpparameters.h"
23#include "api/rtpreceiverinterface.h"
Patrik Höglund3e113432017-12-15 14:40:10 +010024#include "api/video/video_content_type.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020025#include "api/video/video_timing.h"
Patrik Höglundbe214a22018-01-04 12:14:35 +010026#include "api/videosinkinterface.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020027#include "call/video_config.h"
28#include "media/base/codec.h"
29#include "media/base/mediaconstants.h"
30#include "media/base/streamparams.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020031#include "media/base/videosourceinterface.h"
Ivo Creusen56d46092017-11-24 17:29:59 +010032#include "modules/audio_processing/include/audio_processing_statistics.h"
Patrik Höglundaba85d12017-11-28 15:46:08 +010033#include "rtc_base/asyncpacketsocket.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020034#include "rtc_base/basictypes.h"
35#include "rtc_base/buffer.h"
36#include "rtc_base/copyonwritebuffer.h"
37#include "rtc_base/dscp.h"
38#include "rtc_base/logging.h"
39#include "rtc_base/networkroute.h"
40#include "rtc_base/sigslot.h"
41#include "rtc_base/socket.h"
Niels Möller9a44f962017-12-08 15:57:38 +010042#include "rtc_base/stringencode.h"
Patrik Höglundaba85d12017-11-28 15:46:08 +010043
henrike@webrtc.org28e20752013-07-10 00:45:36 +000044
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000045namespace rtc {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000046class RateLimiter;
47class Timing;
48}
49
Tommif888bb52015-12-12 01:37:01 +010050namespace webrtc {
51class AudioSinkInterface;
nisseacd935b2016-11-11 03:55:13 -080052class VideoFrame;
Tommif888bb52015-12-12 01:37:01 +010053}
54
henrike@webrtc.org28e20752013-07-10 00:45:36 +000055namespace cricket {
56
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -080057class AudioSource;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000058class VideoCapturer;
tommi1d5c19d2015-12-13 22:54:29 -080059struct RtpHeader;
60struct VideoFormat;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000061
henrike@webrtc.org28e20752013-07-10 00:45:36 +000062const int kScreencastDefaultFps = 5;
63
henrike@webrtc.org28e20752013-07-10 00:45:36 +000064template <class T>
Karl Wibergbe579832015-11-10 22:34:18 +010065static std::string ToStringIfSet(const char* key, const rtc::Optional<T>& val) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000066 std::string str;
kwiberg102c6a62015-10-30 02:47:38 -070067 if (val) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000068 str = key;
69 str += ": ";
kwiberg102c6a62015-10-30 02:47:38 -070070 str += val ? rtc::ToString(*val) : "";
henrike@webrtc.org28e20752013-07-10 00:45:36 +000071 str += ", ";
72 }
73 return str;
74}
75
Peter Thatcherc2ee2c82015-08-07 16:05:34 -070076template <class T>
77static std::string VectorToString(const std::vector<T>& vals) {
78 std::ostringstream ost;
79 ost << "[";
80 for (size_t i = 0; i < vals.size(); ++i) {
81 if (i > 0) {
82 ost << ", ";
83 }
84 ost << vals[i].ToString();
85 }
86 ost << "]";
87 return ost.str();
88}
89
nisse528b7932017-05-08 03:21:43 -070090// Construction-time settings, passed on when creating
nisse51542be2016-02-12 02:27:06 -080091// MediaChannels.
92struct MediaConfig {
93 // Set DSCP value on packets. This flag comes from the
94 // PeerConnection constraint 'googDscp'.
95 bool enable_dscp = false;
96
nisse0db023a2016-03-01 04:29:59 -080097 // Video-specific config.
98 struct Video {
99 // Enable WebRTC CPU Overuse Detection. This flag comes from the
perkj803d97f2016-11-01 11:45:46 -0700100 // PeerConnection constraint 'googCpuOveruseDetection'.
nisse0db023a2016-03-01 04:29:59 -0800101 bool enable_cpu_overuse_detection = true;
nisse51542be2016-02-12 02:27:06 -0800102
nisse0db023a2016-03-01 04:29:59 -0800103 // Enable WebRTC suspension of video. No video frames will be sent
104 // when the bitrate is below the configured minimum bitrate. This
105 // flag comes from the PeerConnection constraint
eladalonf1841382017-06-12 01:16:46 -0700106 // 'googSuspendBelowMinBitrate', and WebRtcVideoChannel copies it
nisse0db023a2016-03-01 04:29:59 -0800107 // to VideoSendStream::Config::suspend_below_min_bitrate.
108 bool suspend_below_min_bitrate = false;
nisse51542be2016-02-12 02:27:06 -0800109
nisse0db023a2016-03-01 04:29:59 -0800110 // Set to true if the renderer has an algorithm of frame selection.
111 // If the value is true, then WebRTC will hand over a frame as soon as
112 // possible without delay, and rendering smoothness is completely the duty
113 // of the renderer;
114 // If the value is false, then WebRTC is responsible to delay frame release
115 // in order to increase rendering smoothness.
116 //
117 // This flag comes from PeerConnection's RtcConfiguration, but is
118 // currently only set by the command line flag
119 // 'disable-rtc-smoothness-algorithm'.
eladalonf1841382017-06-12 01:16:46 -0700120 // WebRtcVideoChannel::AddRecvStream copies it to the created
nisse0db023a2016-03-01 04:29:59 -0800121 // WebRtcVideoReceiveStream, where it is returned by the
122 // SmoothsRenderedFrames method. This method is used by the
123 // VideoReceiveStream, where the value is passed on to the
124 // IncomingVideoStream constructor.
125 bool disable_prerenderer_smoothing = false;
sergeyu80ed35e2016-11-28 13:11:13 -0800126
127 // Enables periodic bandwidth probing in application-limited region.
128 bool periodic_alr_bandwidth_probing = false;
nisse0db023a2016-03-01 04:29:59 -0800129 } video;
deadbeef293e9262017-01-11 12:28:30 -0800130
131 bool operator==(const MediaConfig& o) const {
132 return enable_dscp == o.enable_dscp &&
133 video.enable_cpu_overuse_detection ==
134 o.video.enable_cpu_overuse_detection &&
135 video.suspend_below_min_bitrate ==
136 o.video.suspend_below_min_bitrate &&
137 video.disable_prerenderer_smoothing ==
138 o.video.disable_prerenderer_smoothing &&
139 video.periodic_alr_bandwidth_probing ==
140 o.video.periodic_alr_bandwidth_probing;
141 }
142
143 bool operator!=(const MediaConfig& o) const { return !(*this == o); }
nisse51542be2016-02-12 02:27:06 -0800144};
145
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000146// Options that can be applied to a VoiceMediaChannel or a VoiceMediaEngine.
147// Used to be flags, but that makes it hard to selectively apply options.
148// We are moving all of the setting of options to structs like this,
149// but some things currently still use flags.
150struct AudioOptions {
151 void SetAll(const AudioOptions& change) {
kwiberg102c6a62015-10-30 02:47:38 -0700152 SetFrom(&echo_cancellation, change.echo_cancellation);
Jonathan Yu76220482017-12-21 04:18:07 -0800153#if defined(WEBRTC_IOS)
154 SetFrom(&ios_force_software_aec_HACK, change.ios_force_software_aec_HACK);
155#endif
kwiberg102c6a62015-10-30 02:47:38 -0700156 SetFrom(&auto_gain_control, change.auto_gain_control);
157 SetFrom(&noise_suppression, change.noise_suppression);
158 SetFrom(&highpass_filter, change.highpass_filter);
159 SetFrom(&stereo_swapping, change.stereo_swapping);
160 SetFrom(&audio_jitter_buffer_max_packets,
161 change.audio_jitter_buffer_max_packets);
162 SetFrom(&audio_jitter_buffer_fast_accelerate,
163 change.audio_jitter_buffer_fast_accelerate);
164 SetFrom(&typing_detection, change.typing_detection);
165 SetFrom(&aecm_generate_comfort_noise, change.aecm_generate_comfort_noise);
kwiberg102c6a62015-10-30 02:47:38 -0700166 SetFrom(&experimental_agc, change.experimental_agc);
167 SetFrom(&extended_filter_aec, change.extended_filter_aec);
168 SetFrom(&delay_agnostic_aec, change.delay_agnostic_aec);
169 SetFrom(&experimental_ns, change.experimental_ns);
Alejandro Luebsc9b0c262016-05-16 15:32:38 -0700170 SetFrom(&intelligibility_enhancer, change.intelligibility_enhancer);
peaha3333bf2016-06-30 00:02:34 -0700171 SetFrom(&level_control, change.level_control);
ivocb829d9f2016-11-15 02:34:47 -0800172 SetFrom(&residual_echo_detector, change.residual_echo_detector);
kwiberg102c6a62015-10-30 02:47:38 -0700173 SetFrom(&tx_agc_target_dbov, change.tx_agc_target_dbov);
174 SetFrom(&tx_agc_digital_compression_gain,
175 change.tx_agc_digital_compression_gain);
176 SetFrom(&tx_agc_limiter, change.tx_agc_limiter);
kwiberg102c6a62015-10-30 02:47:38 -0700177 SetFrom(&combined_audio_video_bwe, change.combined_audio_video_bwe);
minyue6b825df2016-10-31 04:08:32 -0700178 SetFrom(&audio_network_adaptor, change.audio_network_adaptor);
179 SetFrom(&audio_network_adaptor_config, change.audio_network_adaptor_config);
aleloie33c5d92016-10-20 01:53:27 -0700180 SetFrom(&level_control_initial_peak_level_dbfs,
181 change.level_control_initial_peak_level_dbfs);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000182 }
183
184 bool operator==(const AudioOptions& o) const {
185 return echo_cancellation == o.echo_cancellation &&
Jonathan Yu76220482017-12-21 04:18:07 -0800186#if defined(WEBRTC_IOS)
187 ios_force_software_aec_HACK == o.ios_force_software_aec_HACK &&
188#endif
peaha3333bf2016-06-30 00:02:34 -0700189 auto_gain_control == o.auto_gain_control &&
190 noise_suppression == o.noise_suppression &&
191 highpass_filter == o.highpass_filter &&
192 stereo_swapping == o.stereo_swapping &&
193 audio_jitter_buffer_max_packets ==
194 o.audio_jitter_buffer_max_packets &&
195 audio_jitter_buffer_fast_accelerate ==
196 o.audio_jitter_buffer_fast_accelerate &&
197 typing_detection == o.typing_detection &&
198 aecm_generate_comfort_noise == o.aecm_generate_comfort_noise &&
199 experimental_agc == o.experimental_agc &&
200 extended_filter_aec == o.extended_filter_aec &&
201 delay_agnostic_aec == o.delay_agnostic_aec &&
202 experimental_ns == o.experimental_ns &&
203 intelligibility_enhancer == o.intelligibility_enhancer &&
204 level_control == o.level_control &&
ivocb829d9f2016-11-15 02:34:47 -0800205 residual_echo_detector == o.residual_echo_detector &&
peaha3333bf2016-06-30 00:02:34 -0700206 tx_agc_target_dbov == o.tx_agc_target_dbov &&
207 tx_agc_digital_compression_gain ==
208 o.tx_agc_digital_compression_gain &&
209 tx_agc_limiter == o.tx_agc_limiter &&
aleloie33c5d92016-10-20 01:53:27 -0700210 combined_audio_video_bwe == o.combined_audio_video_bwe &&
minyue6b825df2016-10-31 04:08:32 -0700211 audio_network_adaptor == o.audio_network_adaptor &&
212 audio_network_adaptor_config == o.audio_network_adaptor_config &&
aleloie33c5d92016-10-20 01:53:27 -0700213 level_control_initial_peak_level_dbfs ==
214 o.level_control_initial_peak_level_dbfs;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000215 }
deadbeef119760a2016-04-04 11:43:27 -0700216 bool operator!=(const AudioOptions& o) const { return !(*this == o); }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000217
218 std::string ToString() const {
219 std::ostringstream ost;
220 ost << "AudioOptions {";
221 ost << ToStringIfSet("aec", echo_cancellation);
Jonathan Yu76220482017-12-21 04:18:07 -0800222#if defined(WEBRTC_IOS)
223 ost << ToStringIfSet("ios_force_software_aec_HACK",
224 ios_force_software_aec_HACK);
225#endif
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000226 ost << ToStringIfSet("agc", auto_gain_control);
227 ost << ToStringIfSet("ns", noise_suppression);
228 ost << ToStringIfSet("hf", highpass_filter);
229 ost << ToStringIfSet("swap", stereo_swapping);
Henrik Lundin64dad832015-05-11 12:44:23 +0200230 ost << ToStringIfSet("audio_jitter_buffer_max_packets",
231 audio_jitter_buffer_max_packets);
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200232 ost << ToStringIfSet("audio_jitter_buffer_fast_accelerate",
233 audio_jitter_buffer_fast_accelerate);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000234 ost << ToStringIfSet("typing", typing_detection);
wu@webrtc.org97077a32013-10-25 21:18:33 +0000235 ost << ToStringIfSet("comfort_noise", aecm_generate_comfort_noise);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000236 ost << ToStringIfSet("experimental_agc", experimental_agc);
Henrik Lundin441f6342015-06-09 16:03:13 +0200237 ost << ToStringIfSet("extended_filter_aec", extended_filter_aec);
Bjorn Volckerbf395c12015-03-25 22:45:56 +0100238 ost << ToStringIfSet("delay_agnostic_aec", delay_agnostic_aec);
sergeyu@chromium.org9cf037b2014-02-07 19:03:26 +0000239 ost << ToStringIfSet("experimental_ns", experimental_ns);
Alejandro Luebsc9b0c262016-05-16 15:32:38 -0700240 ost << ToStringIfSet("intelligibility_enhancer", intelligibility_enhancer);
peaha3333bf2016-06-30 00:02:34 -0700241 ost << ToStringIfSet("level_control", level_control);
aleloie33c5d92016-10-20 01:53:27 -0700242 ost << ToStringIfSet("level_control_initial_peak_level_dbfs",
243 level_control_initial_peak_level_dbfs);
ivocb829d9f2016-11-15 02:34:47 -0800244 ost << ToStringIfSet("residual_echo_detector", residual_echo_detector);
wu@webrtc.org97077a32013-10-25 21:18:33 +0000245 ost << ToStringIfSet("tx_agc_target_dbov", tx_agc_target_dbov);
246 ost << ToStringIfSet("tx_agc_digital_compression_gain",
247 tx_agc_digital_compression_gain);
248 ost << ToStringIfSet("tx_agc_limiter", tx_agc_limiter);
buildbot@webrtc.orgb4c7b092014-08-25 12:11:58 +0000249 ost << ToStringIfSet("combined_audio_video_bwe", combined_audio_video_bwe);
minyue6b825df2016-10-31 04:08:32 -0700250 ost << ToStringIfSet("audio_network_adaptor", audio_network_adaptor);
251 // The adaptor config is a serialized proto buffer and therefore not human
252 // readable. So we comment out the following line.
253 // ost << ToStringIfSet("audio_network_adaptor_config",
254 // audio_network_adaptor_config);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000255 ost << "}";
256 return ost.str();
257 }
258
259 // Audio processing that attempts to filter away the output signal from
260 // later inbound pickup.
Karl Wibergbe579832015-11-10 22:34:18 +0100261 rtc::Optional<bool> echo_cancellation;
Jonathan Yu76220482017-12-21 04:18:07 -0800262#if defined(WEBRTC_IOS)
263 // Forces software echo cancellation on iOS. This is a temporary workaround
264 // (until Apple fixes the bug) for a device with non-functioning AEC. May
265 // improve performance on that particular device, but will cause unpredictable
266 // behavior in all other cases. See http://bugs.webrtc.org/8682.
267 rtc::Optional<bool> ios_force_software_aec_HACK;
268#endif
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000269 // Audio processing to adjust the sensitivity of the local mic dynamically.
Karl Wibergbe579832015-11-10 22:34:18 +0100270 rtc::Optional<bool> auto_gain_control;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000271 // Audio processing to filter out background noise.
Karl Wibergbe579832015-11-10 22:34:18 +0100272 rtc::Optional<bool> noise_suppression;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000273 // Audio processing to remove background noise of lower frequencies.
Karl Wibergbe579832015-11-10 22:34:18 +0100274 rtc::Optional<bool> highpass_filter;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000275 // Audio processing to swap the left and right channels.
Karl Wibergbe579832015-11-10 22:34:18 +0100276 rtc::Optional<bool> stereo_swapping;
Henrik Lundin64dad832015-05-11 12:44:23 +0200277 // Audio receiver jitter buffer (NetEq) max capacity in number of packets.
Karl Wibergbe579832015-11-10 22:34:18 +0100278 rtc::Optional<int> audio_jitter_buffer_max_packets;
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200279 // Audio receiver jitter buffer (NetEq) fast accelerate mode.
Karl Wibergbe579832015-11-10 22:34:18 +0100280 rtc::Optional<bool> audio_jitter_buffer_fast_accelerate;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000281 // Audio processing to detect typing.
Karl Wibergbe579832015-11-10 22:34:18 +0100282 rtc::Optional<bool> typing_detection;
283 rtc::Optional<bool> aecm_generate_comfort_noise;
Karl Wibergbe579832015-11-10 22:34:18 +0100284 rtc::Optional<bool> experimental_agc;
285 rtc::Optional<bool> extended_filter_aec;
286 rtc::Optional<bool> delay_agnostic_aec;
287 rtc::Optional<bool> experimental_ns;
Alejandro Luebsc9b0c262016-05-16 15:32:38 -0700288 rtc::Optional<bool> intelligibility_enhancer;
peaha3333bf2016-06-30 00:02:34 -0700289 rtc::Optional<bool> level_control;
aleloie33c5d92016-10-20 01:53:27 -0700290 // Specifies an optional initialization value for the level controller.
291 rtc::Optional<float> level_control_initial_peak_level_dbfs;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000292 // Note that tx_agc_* only applies to non-experimental AGC.
ivocb829d9f2016-11-15 02:34:47 -0800293 rtc::Optional<bool> residual_echo_detector;
Karl Wibergbe579832015-11-10 22:34:18 +0100294 rtc::Optional<uint16_t> tx_agc_target_dbov;
295 rtc::Optional<uint16_t> tx_agc_digital_compression_gain;
296 rtc::Optional<bool> tx_agc_limiter;
buildbot@webrtc.orgb4c7b092014-08-25 12:11:58 +0000297 // Enable combined audio+bandwidth BWE.
nisse51542be2016-02-12 02:27:06 -0800298 // TODO(pthatcher): This flag is set from the
299 // "googCombinedAudioVideoBwe", but not used anywhere. So delete it,
300 // and check if any other AudioOptions members are unused.
Karl Wibergbe579832015-11-10 22:34:18 +0100301 rtc::Optional<bool> combined_audio_video_bwe;
minyue6b825df2016-10-31 04:08:32 -0700302 // Enable audio network adaptor.
303 rtc::Optional<bool> audio_network_adaptor;
304 // Config string for audio network adaptor.
305 rtc::Optional<std::string> audio_network_adaptor_config;
kwiberg102c6a62015-10-30 02:47:38 -0700306
307 private:
308 template <typename T>
Karl Wibergbe579832015-11-10 22:34:18 +0100309 static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) {
kwiberg102c6a62015-10-30 02:47:38 -0700310 if (o) {
311 *s = o;
312 }
313 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000314};
315
316// Options that can be applied to a VideoMediaChannel or a VideoMediaEngine.
317// Used to be flags, but that makes it hard to selectively apply options.
318// We are moving all of the setting of options to structs like this,
319// but some things currently still use flags.
320struct VideoOptions {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000321 void SetAll(const VideoOptions& change) {
kwiberg102c6a62015-10-30 02:47:38 -0700322 SetFrom(&video_noise_reduction, change.video_noise_reduction);
nisseb163c3f2016-01-29 01:14:38 -0800323 SetFrom(&screencast_min_bitrate_kbps, change.screencast_min_bitrate_kbps);
Niels Möller60653ba2016-03-02 11:41:36 +0100324 SetFrom(&is_screencast, change.is_screencast);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000325 }
326
327 bool operator==(const VideoOptions& o) const {
nisseb163c3f2016-01-29 01:14:38 -0800328 return video_noise_reduction == o.video_noise_reduction &&
Niels Möller60653ba2016-03-02 11:41:36 +0100329 screencast_min_bitrate_kbps == o.screencast_min_bitrate_kbps &&
330 is_screencast == o.is_screencast;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000331 }
deadbeef119760a2016-04-04 11:43:27 -0700332 bool operator!=(const VideoOptions& o) const { return !(*this == o); }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000333
334 std::string ToString() const {
335 std::ostringstream ost;
336 ost << "VideoOptions {";
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000337 ost << ToStringIfSet("noise reduction", video_noise_reduction);
nisseb163c3f2016-01-29 01:14:38 -0800338 ost << ToStringIfSet("screencast min bitrate kbps",
339 screencast_min_bitrate_kbps);
Niels Möller60653ba2016-03-02 11:41:36 +0100340 ost << ToStringIfSet("is_screencast ", is_screencast);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000341 ost << "}";
342 return ost.str();
343 }
344
nisseb163c3f2016-01-29 01:14:38 -0800345 // Enable denoising? This flag comes from the getUserMedia
eladalonf1841382017-06-12 01:16:46 -0700346 // constraint 'googNoiseReduction', and WebRtcVideoEngine passes it
nisseb163c3f2016-01-29 01:14:38 -0800347 // on to the codec options. Disabled by default.
Karl Wibergbe579832015-11-10 22:34:18 +0100348 rtc::Optional<bool> video_noise_reduction;
nisseb163c3f2016-01-29 01:14:38 -0800349 // Force screencast to use a minimum bitrate. This flag comes from
350 // the PeerConnection constraint 'googScreencastMinBitrate'. It is
eladalonf1841382017-06-12 01:16:46 -0700351 // copied to the encoder config by WebRtcVideoChannel.
nisseb163c3f2016-01-29 01:14:38 -0800352 rtc::Optional<int> screencast_min_bitrate_kbps;
Niels Möller60653ba2016-03-02 11:41:36 +0100353 // Set by screencast sources. Implies selection of encoding settings
354 // suitable for screencast. Most likely not the right way to do
355 // things, e.g., screencast of a text document and screencast of a
356 // youtube video have different needs.
357 rtc::Optional<bool> is_screencast;
kwiberg102c6a62015-10-30 02:47:38 -0700358
359 private:
360 template <typename T>
Karl Wibergbe579832015-11-10 22:34:18 +0100361 static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) {
kwiberg102c6a62015-10-30 02:47:38 -0700362 if (o) {
363 *s = o;
364 }
365 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000366};
367
isheriffa1c548b2016-05-31 16:12:24 -0700368// TODO(isheriff): Remove this once client usage is fixed to use RtpExtension.
369struct RtpHeaderExtension {
370 RtpHeaderExtension() : id(0) {}
371 RtpHeaderExtension(const std::string& uri, int id) : uri(uri), id(id) {}
372
373 std::string ToString() const {
374 std::ostringstream ost;
375 ost << "{";
376 ost << "uri: " << uri;
377 ost << ", id: " << id;
378 ost << "}";
379 return ost.str();
380 }
381
382 std::string uri;
383 int id;
384};
385
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000386class MediaChannel : public sigslot::has_slots<> {
387 public:
388 class NetworkInterface {
389 public:
390 enum SocketType { ST_RTP, ST_RTCP };
jbaucheec21bd2016-03-20 06:15:43 -0700391 virtual bool SendPacket(rtc::CopyOnWriteBuffer* packet,
stefanc1aeaf02015-10-15 07:26:07 -0700392 const rtc::PacketOptions& options) = 0;
jbaucheec21bd2016-03-20 06:15:43 -0700393 virtual bool SendRtcp(rtc::CopyOnWriteBuffer* packet,
stefanc1aeaf02015-10-15 07:26:07 -0700394 const rtc::PacketOptions& options) = 0;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000395 virtual int SetOption(SocketType type, rtc::Socket::Option opt,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000396 int option) = 0;
397 virtual ~NetworkInterface() {}
398 };
399
terelius54f91712016-06-01 11:18:56 -0700400 explicit MediaChannel(const MediaConfig& config)
nisse51542be2016-02-12 02:27:06 -0800401 : enable_dscp_(config.enable_dscp), network_interface_(NULL) {}
402 MediaChannel() : enable_dscp_(false), network_interface_(NULL) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000403 virtual ~MediaChannel() {}
404
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000405 // Sets the abstract interface class for sending RTP/RTCP data.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000406 virtual void SetInterface(NetworkInterface *iface) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000407 rtc::CritScope cs(&network_interface_crit_);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000408 network_interface_ = iface;
nisse51542be2016-02-12 02:27:06 -0800409 SetDscp(enable_dscp_ ? PreferredDscp() : rtc::DSCP_DEFAULT);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000410 }
nisse51542be2016-02-12 02:27:06 -0800411 virtual rtc::DiffServCodePoint PreferredDscp() const {
412 return rtc::DSCP_DEFAULT;
413 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000414 // Called when a RTP packet is received.
jbaucheec21bd2016-03-20 06:15:43 -0700415 virtual void OnPacketReceived(rtc::CopyOnWriteBuffer* packet,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000416 const rtc::PacketTime& packet_time) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000417 // Called when a RTCP packet is received.
jbaucheec21bd2016-03-20 06:15:43 -0700418 virtual void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000419 const rtc::PacketTime& packet_time) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000420 // Called when the socket's ability to send has changed.
421 virtual void OnReadyToSend(bool ready) = 0;
Honghai Zhangcc411c02016-03-29 17:27:21 -0700422 // Called when the network route used for sending packets changed.
Honghai Zhang0e533ef2016-04-19 15:41:36 -0700423 virtual void OnNetworkRouteChanged(
424 const std::string& transport_name,
425 const rtc::NetworkRoute& network_route) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000426 // Creates a new outgoing media stream with SSRCs and CNAME as described
427 // by sp.
428 virtual bool AddSendStream(const StreamParams& sp) = 0;
429 // Removes an outgoing media stream.
430 // ssrc must be the first SSRC of the media stream if the stream uses
431 // multiple SSRCs.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200432 virtual bool RemoveSendStream(uint32_t ssrc) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000433 // Creates a new incoming media stream with SSRCs and CNAME as described
434 // by sp.
435 virtual bool AddRecvStream(const StreamParams& sp) = 0;
436 // Removes an incoming media stream.
437 // ssrc must be the first SSRC of the media stream if the stream uses
438 // multiple SSRCs.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200439 virtual bool RemoveRecvStream(uint32_t ssrc) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000440
mallinath@webrtc.org92fdfeb2014-02-17 18:49:41 +0000441 // Returns the absoulte sendtime extension id value from media channel.
442 virtual int GetRtpSendTimeExtnId() const {
443 return -1;
444 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000445
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000446 // Base method to send packet using NetworkInterface.
jbaucheec21bd2016-03-20 06:15:43 -0700447 bool SendPacket(rtc::CopyOnWriteBuffer* packet,
448 const rtc::PacketOptions& options) {
stefanc1aeaf02015-10-15 07:26:07 -0700449 return DoSendPacket(packet, false, options);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000450 }
451
jbaucheec21bd2016-03-20 06:15:43 -0700452 bool SendRtcp(rtc::CopyOnWriteBuffer* packet,
453 const rtc::PacketOptions& options) {
stefanc1aeaf02015-10-15 07:26:07 -0700454 return DoSendPacket(packet, true, options);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000455 }
456
457 int SetOption(NetworkInterface::SocketType type,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000458 rtc::Socket::Option opt,
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000459 int option) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000460 rtc::CritScope cs(&network_interface_crit_);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000461 if (!network_interface_)
462 return -1;
463
464 return network_interface_->SetOption(type, opt, option);
465 }
466
nisse51542be2016-02-12 02:27:06 -0800467 private:
wu@webrtc.orgde305012013-10-31 15:40:38 +0000468 // This method sets DSCP |value| on both RTP and RTCP channels.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000469 int SetDscp(rtc::DiffServCodePoint value) {
wu@webrtc.orgde305012013-10-31 15:40:38 +0000470 int ret;
471 ret = SetOption(NetworkInterface::ST_RTP,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000472 rtc::Socket::OPT_DSCP,
wu@webrtc.orgde305012013-10-31 15:40:38 +0000473 value);
474 if (ret == 0) {
475 ret = SetOption(NetworkInterface::ST_RTCP,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000476 rtc::Socket::OPT_DSCP,
wu@webrtc.orgde305012013-10-31 15:40:38 +0000477 value);
478 }
479 return ret;
480 }
481
jbaucheec21bd2016-03-20 06:15:43 -0700482 bool DoSendPacket(rtc::CopyOnWriteBuffer* packet,
stefanc1aeaf02015-10-15 07:26:07 -0700483 bool rtcp,
484 const rtc::PacketOptions& options) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000485 rtc::CritScope cs(&network_interface_crit_);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000486 if (!network_interface_)
487 return false;
488
stefanc1aeaf02015-10-15 07:26:07 -0700489 return (!rtcp) ? network_interface_->SendPacket(packet, options)
490 : network_interface_->SendRtcp(packet, options);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000491 }
492
nisse51542be2016-02-12 02:27:06 -0800493 const bool enable_dscp_;
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000494 // |network_interface_| can be accessed from the worker_thread and
495 // from any MediaEngine threads. This critical section is to protect accessing
496 // of network_interface_ object.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000497 rtc::CriticalSection network_interface_crit_;
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000498 NetworkInterface* network_interface_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000499};
500
wu@webrtc.org97077a32013-10-25 21:18:33 +0000501// The stats information is structured as follows:
502// Media are represented by either MediaSenderInfo or MediaReceiverInfo.
503// Media contains a vector of SSRC infos that are exclusively used by this
504// media. (SSRCs shared between media streams can't be represented.)
505
506// Information about an SSRC.
507// This data may be locally recorded, or received in an RTCP SR or RR.
508struct SsrcSenderInfo {
Steve Anton002f9212018-01-09 16:38:15 -0800509 uint32_t ssrc = 0;
510 double timestamp = 0.0; // NTP timestamp, represented as seconds since epoch.
wu@webrtc.org97077a32013-10-25 21:18:33 +0000511};
512
513struct SsrcReceiverInfo {
Steve Anton002f9212018-01-09 16:38:15 -0800514 uint32_t ssrc = 0;
515 double timestamp = 0.0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000516};
517
518struct MediaSenderInfo {
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000519 void add_ssrc(const SsrcSenderInfo& stat) {
520 local_stats.push_back(stat);
521 }
522 // Temporary utility function for call sites that only provide SSRC.
523 // As more info is added into SsrcSenderInfo, this function should go away.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200524 void add_ssrc(uint32_t ssrc) {
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000525 SsrcSenderInfo stat;
526 stat.ssrc = ssrc;
527 add_ssrc(stat);
528 }
529 // Utility accessor for clients that are only interested in ssrc numbers.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200530 std::vector<uint32_t> ssrcs() const {
531 std::vector<uint32_t> retval;
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000532 for (std::vector<SsrcSenderInfo>::const_iterator it = local_stats.begin();
533 it != local_stats.end(); ++it) {
534 retval.push_back(it->ssrc);
535 }
536 return retval;
537 }
538 // Utility accessor for clients that make the assumption only one ssrc
539 // exists per media.
540 // This will eventually go away.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200541 uint32_t ssrc() const {
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000542 if (local_stats.size() > 0) {
543 return local_stats[0].ssrc;
544 } else {
545 return 0;
546 }
547 }
Steve Anton002f9212018-01-09 16:38:15 -0800548 int64_t bytes_sent = 0;
549 int packets_sent = 0;
550 int packets_lost = 0;
551 float fraction_lost = 0.0f;
552 int64_t rtt_ms = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000553 std::string codec_name;
hbos1acfbd22016-11-17 23:43:29 -0800554 rtc::Optional<int> codec_payload_type;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000555 std::vector<SsrcSenderInfo> local_stats;
556 std::vector<SsrcReceiverInfo> remote_stats;
557};
558
559struct MediaReceiverInfo {
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000560 void add_ssrc(const SsrcReceiverInfo& stat) {
561 local_stats.push_back(stat);
562 }
563 // Temporary utility function for call sites that only provide SSRC.
564 // As more info is added into SsrcSenderInfo, this function should go away.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200565 void add_ssrc(uint32_t ssrc) {
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000566 SsrcReceiverInfo stat;
567 stat.ssrc = ssrc;
568 add_ssrc(stat);
569 }
Peter Boström0c4e06b2015-10-07 12:23:21 +0200570 std::vector<uint32_t> ssrcs() const {
571 std::vector<uint32_t> retval;
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000572 for (std::vector<SsrcReceiverInfo>::const_iterator it = local_stats.begin();
573 it != local_stats.end(); ++it) {
574 retval.push_back(it->ssrc);
575 }
576 return retval;
577 }
578 // Utility accessor for clients that make the assumption only one ssrc
579 // exists per media.
580 // This will eventually go away.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200581 uint32_t ssrc() const {
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000582 if (local_stats.size() > 0) {
583 return local_stats[0].ssrc;
584 } else {
585 return 0;
586 }
587 }
588
Steve Anton002f9212018-01-09 16:38:15 -0800589 int64_t bytes_rcvd = 0;
590 int packets_rcvd = 0;
591 int packets_lost = 0;
592 float fraction_lost = 0.0f;
buildbot@webrtc.org7e71b772014-06-13 01:14:01 +0000593 std::string codec_name;
hbos1acfbd22016-11-17 23:43:29 -0800594 rtc::Optional<int> codec_payload_type;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000595 std::vector<SsrcReceiverInfo> local_stats;
596 std::vector<SsrcSenderInfo> remote_stats;
597};
598
599struct VoiceSenderInfo : public MediaSenderInfo {
Steve Anton002f9212018-01-09 16:38:15 -0800600 int ext_seqnum = 0;
601 int jitter_ms = 0;
602 int audio_level = 0;
zsteine76bd3a2017-07-14 12:17:49 -0700603 // See description of "totalAudioEnergy" in the WebRTC stats spec:
604 // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy
Steve Anton002f9212018-01-09 16:38:15 -0800605 double total_input_energy = 0.0;
606 double total_input_duration = 0.0;
Ivo Creusen56d46092017-11-24 17:29:59 +0100607 // TODO(bugs.webrtc.org/8572): Remove APM stats from this struct, since they
608 // are no longer needed now that we have apm_statistics.
Steve Anton002f9212018-01-09 16:38:15 -0800609 int echo_delay_median_ms = 0;
610 int echo_delay_std_ms = 0;
611 int echo_return_loss = 0;
612 int echo_return_loss_enhancement = 0;
613 float residual_echo_likelihood = 0.0f;
614 float residual_echo_likelihood_recent_max = 0.0f;
615 bool typing_noise_detected = false;
ivoce1198e02017-09-08 08:13:19 -0700616 webrtc::ANAStats ana_statistics;
Ivo Creusen56d46092017-11-24 17:29:59 +0100617 webrtc::AudioProcessingStats apm_statistics;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000618};
619
wu@webrtc.org97077a32013-10-25 21:18:33 +0000620struct VoiceReceiverInfo : public MediaReceiverInfo {
Steve Anton002f9212018-01-09 16:38:15 -0800621 int ext_seqnum = 0;
622 int jitter_ms = 0;
623 int jitter_buffer_ms = 0;
624 int jitter_buffer_preferred_ms = 0;
625 int delay_estimate_ms = 0;
626 int audio_level = 0;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200627 // Stats below correspond to similarly-named fields in the WebRTC stats spec.
628 // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats
Steve Anton002f9212018-01-09 16:38:15 -0800629 double total_output_energy = 0.0;
630 uint64_t total_samples_received = 0;
631 double total_output_duration = 0.0;
632 uint64_t concealed_samples = 0;
633 uint64_t concealment_events = 0;
634 double jitter_buffer_delay_seconds = 0;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200635 // Stats below DO NOT correspond directly to anything in the WebRTC stats
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13 +0000636 // fraction of synthesized audio inserted through expansion.
Steve Anton002f9212018-01-09 16:38:15 -0800637 float expand_rate = 0.0f;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13 +0000638 // fraction of synthesized speech inserted through expansion.
Steve Anton002f9212018-01-09 16:38:15 -0800639 float speech_expand_rate = 0.0f;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13 +0000640 // fraction of data out of secondary decoding, including FEC and RED.
Steve Anton002f9212018-01-09 16:38:15 -0800641 float secondary_decoded_rate = 0.0f;
minyue-webrtc0e320ec2017-08-28 13:51:27 +0200642 // Fraction of secondary data, including FEC and RED, that is discarded.
643 // Discarding of secondary data can be caused by the reception of the primary
644 // data, obsoleting the secondary data. It can also be caused by early
645 // or late arrival of secondary data. This metric is the percentage of
646 // discarded secondary data since last query of receiver info.
Steve Anton002f9212018-01-09 16:38:15 -0800647 float secondary_discarded_rate = 0.0f;
Henrik Lundin8e6fd462015-06-02 09:24:52 +0200648 // Fraction of data removed through time compression.
Steve Anton002f9212018-01-09 16:38:15 -0800649 float accelerate_rate = 0.0f;
Henrik Lundin8e6fd462015-06-02 09:24:52 +0200650 // Fraction of data inserted through time stretching.
Steve Anton002f9212018-01-09 16:38:15 -0800651 float preemptive_expand_rate = 0.0f;
652 int decoding_calls_to_silence_generator = 0;
653 int decoding_calls_to_neteq = 0;
654 int decoding_normal = 0;
655 int decoding_plc = 0;
656 int decoding_cng = 0;
657 int decoding_plc_cng = 0;
658 int decoding_muted_output = 0;
buildbot@webrtc.orgb525a9d2014-06-03 09:42:15 +0000659 // Estimated capture start time in NTP time in ms.
Steve Anton002f9212018-01-09 16:38:15 -0800660 int64_t capture_start_ntp_time_ms = -1;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000661};
662
wu@webrtc.org97077a32013-10-25 21:18:33 +0000663struct VideoSenderInfo : public MediaSenderInfo {
pbos@webrtc.org1ed62242015-02-19 13:57:03 +0000664 std::vector<SsrcGroup> ssrc_groups;
hbosa65704b2016-11-14 02:28:16 -0800665 // TODO(hbos): Move this to |VideoMediaInfo::send_codecs|?
Peter Boströmb7d9a972015-12-18 16:01:11 +0100666 std::string encoder_implementation_name;
Steve Anton002f9212018-01-09 16:38:15 -0800667 int packets_cached = 0;
668 int firs_rcvd = 0;
669 int plis_rcvd = 0;
670 int nacks_rcvd = 0;
671 int send_frame_width = 0;
672 int send_frame_height = 0;
673 int framerate_input = 0;
674 int framerate_sent = 0;
675 int nominal_bitrate = 0;
676 int preferred_bitrate = 0;
677 int adapt_reason = 0;
678 int adapt_changes = 0;
679 int avg_encode_ms = 0;
680 int encode_usage_percent = 0;
681 uint32_t frames_encoded = 0;
682 bool has_entered_low_resolution = false;
sakal87da4042016-10-31 06:53:47 -0700683 rtc::Optional<uint64_t> qp_sum;
Steve Anton002f9212018-01-09 16:38:15 -0800684 webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000685};
686
wu@webrtc.org97077a32013-10-25 21:18:33 +0000687struct VideoReceiverInfo : public MediaReceiverInfo {
pbos@webrtc.org1ed62242015-02-19 13:57:03 +0000688 std::vector<SsrcGroup> ssrc_groups;
hbosa65704b2016-11-14 02:28:16 -0800689 // TODO(hbos): Move this to |VideoMediaInfo::receive_codecs|?
Peter Boströmb7d9a972015-12-18 16:01:11 +0100690 std::string decoder_implementation_name;
Steve Anton002f9212018-01-09 16:38:15 -0800691 int packets_concealed = 0;
692 int firs_sent = 0;
693 int plis_sent = 0;
694 int nacks_sent = 0;
695 int frame_width = 0;
696 int frame_height = 0;
697 int framerate_rcvd = 0;
698 int framerate_decoded = 0;
699 int framerate_output = 0;
pbos@webrtc.org1ed62242015-02-19 13:57:03 +0000700 // Framerate as sent to the renderer.
Steve Anton002f9212018-01-09 16:38:15 -0800701 int framerate_render_input = 0;
pbos@webrtc.org1ed62242015-02-19 13:57:03 +0000702 // Framerate that the renderer reports.
Steve Anton002f9212018-01-09 16:38:15 -0800703 int framerate_render_output = 0;
704 uint32_t frames_received = 0;
705 uint32_t frames_decoded = 0;
706 uint32_t frames_rendered = 0;
sakalcc452e12017-02-09 04:53:45 -0800707 rtc::Optional<uint64_t> qp_sum;
Steve Anton002f9212018-01-09 16:38:15 -0800708 int64_t interframe_delay_max_ms = -1;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000709
Steve Anton002f9212018-01-09 16:38:15 -0800710 webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED;
ilnik2e1b40b2017-09-04 07:57:17 -0700711
wu@webrtc.org97077a32013-10-25 21:18:33 +0000712 // All stats below are gathered per-VideoReceiver, but some will be correlated
713 // across MediaStreamTracks. NOTE(hta): when sinking stats into per-SSRC
714 // structures, reflect this in the new layout.
715
716 // Current frame decode latency.
Steve Anton002f9212018-01-09 16:38:15 -0800717 int decode_ms = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000718 // Maximum observed frame decode latency.
Steve Anton002f9212018-01-09 16:38:15 -0800719 int max_decode_ms = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000720 // Jitter (network-related) latency.
Steve Anton002f9212018-01-09 16:38:15 -0800721 int jitter_buffer_ms = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000722 // Requested minimum playout latency.
Steve Anton002f9212018-01-09 16:38:15 -0800723 int min_playout_delay_ms = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000724 // Requested latency to account for rendering delay.
Steve Anton002f9212018-01-09 16:38:15 -0800725 int render_delay_ms = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000726 // Target overall delay: network+decode+render, accounting for
727 // min_playout_delay_ms.
Steve Anton002f9212018-01-09 16:38:15 -0800728 int target_delay_ms = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000729 // Current overall delay, possibly ramping towards target_delay_ms.
Steve Anton002f9212018-01-09 16:38:15 -0800730 int current_delay_ms = 0;
buildbot@webrtc.org0581f0b2014-05-06 21:36:31 +0000731
732 // Estimated capture start time in NTP time in ms.
Steve Anton002f9212018-01-09 16:38:15 -0800733 int64_t capture_start_ntp_time_ms = -1;
ilnik2edc6842017-07-06 03:06:50 -0700734
735 // Timing frame info: all important timestamps for a full lifetime of a
736 // single 'timing frame'.
737 rtc::Optional<webrtc::TimingFrameInfo> timing_frame_info;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000738};
739
wu@webrtc.org97077a32013-10-25 21:18:33 +0000740struct DataSenderInfo : public MediaSenderInfo {
Steve Anton002f9212018-01-09 16:38:15 -0800741 uint32_t ssrc = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000742};
743
wu@webrtc.org97077a32013-10-25 21:18:33 +0000744struct DataReceiverInfo : public MediaReceiverInfo {
Steve Anton002f9212018-01-09 16:38:15 -0800745 uint32_t ssrc = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000746};
747
748struct BandwidthEstimationInfo {
Steve Anton002f9212018-01-09 16:38:15 -0800749 int available_send_bandwidth = 0;
750 int available_recv_bandwidth = 0;
751 int target_enc_bitrate = 0;
752 int actual_enc_bitrate = 0;
753 int retransmit_bitrate = 0;
754 int transmit_bitrate = 0;
755 int64_t bucket_delay = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000756};
757
hbosa65704b2016-11-14 02:28:16 -0800758// Maps from payload type to |RtpCodecParameters|.
759typedef std::map<int, webrtc::RtpCodecParameters> RtpCodecParametersMap;
760
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000761struct VoiceMediaInfo {
762 void Clear() {
763 senders.clear();
764 receivers.clear();
hbos1acfbd22016-11-17 23:43:29 -0800765 send_codecs.clear();
766 receive_codecs.clear();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000767 }
768 std::vector<VoiceSenderInfo> senders;
769 std::vector<VoiceReceiverInfo> receivers;
hbos1acfbd22016-11-17 23:43:29 -0800770 RtpCodecParametersMap send_codecs;
771 RtpCodecParametersMap receive_codecs;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000772};
773
774struct VideoMediaInfo {
775 void Clear() {
776 senders.clear();
777 receivers.clear();
charujaind72098a2017-06-01 08:54:47 -0700778 bw_estimations.clear();
hbosa65704b2016-11-14 02:28:16 -0800779 send_codecs.clear();
780 receive_codecs.clear();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000781 }
782 std::vector<VideoSenderInfo> senders;
783 std::vector<VideoReceiverInfo> receivers;
stefanf79ade12017-06-02 06:44:03 -0700784 // Deprecated.
785 // TODO(holmer): Remove once upstream projects no longer use this.
charujaind72098a2017-06-01 08:54:47 -0700786 std::vector<BandwidthEstimationInfo> bw_estimations;
hbosa65704b2016-11-14 02:28:16 -0800787 RtpCodecParametersMap send_codecs;
788 RtpCodecParametersMap receive_codecs;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000789};
790
791struct DataMediaInfo {
792 void Clear() {
793 senders.clear();
794 receivers.clear();
795 }
796 std::vector<DataSenderInfo> senders;
797 std::vector<DataReceiverInfo> receivers;
798};
799
deadbeef13871492015-12-09 12:37:51 -0800800struct RtcpParameters {
801 bool reduced_size = false;
802};
803
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700804template <class Codec>
805struct RtpParameters {
solenberg7e4e01a2015-12-02 08:05:01 -0800806 virtual std::string ToString() const {
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700807 std::ostringstream ost;
808 ost << "{";
809 ost << "codecs: " << VectorToString(codecs) << ", ";
810 ost << "extensions: " << VectorToString(extensions);
811 ost << "}";
812 return ost.str();
813 }
814
815 std::vector<Codec> codecs;
isheriff6f8d6862016-05-26 11:24:55 -0700816 std::vector<webrtc::RtpExtension> extensions;
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700817 // TODO(pthatcher): Add streams.
deadbeef13871492015-12-09 12:37:51 -0800818 RtcpParameters rtcp;
Henrik Kjellander3fe372d2016-05-12 08:10:52 +0200819 virtual ~RtpParameters() = default;
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700820};
821
Taylor Brandstetter5f0b83b2016-03-18 15:02:07 -0700822// TODO(deadbeef): Rename to RtpSenderParameters, since they're intended to
823// encapsulate all the parameters needed for an RtpSender.
nisse05103312016-03-16 02:22:50 -0700824template <class Codec>
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700825struct RtpSendParameters : RtpParameters<Codec> {
solenberg7e4e01a2015-12-02 08:05:01 -0800826 std::string ToString() const override {
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700827 std::ostringstream ost;
828 ost << "{";
829 ost << "codecs: " << VectorToString(this->codecs) << ", ";
830 ost << "extensions: " << VectorToString(this->extensions) << ", ";
pbos378dc772016-01-28 15:58:41 -0800831 ost << "max_bandwidth_bps: " << max_bandwidth_bps << ", ";
nisse05103312016-03-16 02:22:50 -0700832 ost << "}";
833 return ost.str();
834 }
835
836 int max_bandwidth_bps = -1;
837};
838
839struct AudioSendParameters : RtpSendParameters<AudioCodec> {
840 std::string ToString() const override {
841 std::ostringstream ost;
842 ost << "{";
843 ost << "codecs: " << VectorToString(this->codecs) << ", ";
844 ost << "extensions: " << VectorToString(this->extensions) << ", ";
845 ost << "max_bandwidth_bps: " << max_bandwidth_bps << ", ";
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700846 ost << "options: " << options.ToString();
847 ost << "}";
848 return ost.str();
849 }
850
nisse05103312016-03-16 02:22:50 -0700851 AudioOptions options;
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700852};
853
854struct AudioRecvParameters : RtpParameters<AudioCodec> {
855};
856
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000857class VoiceMediaChannel : public MediaChannel {
858 public:
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000859 VoiceMediaChannel() {}
terelius54f91712016-06-01 11:18:56 -0700860 explicit VoiceMediaChannel(const MediaConfig& config)
861 : MediaChannel(config) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000862 virtual ~VoiceMediaChannel() {}
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200863 virtual bool SetSendParameters(const AudioSendParameters& params) = 0;
864 virtual bool SetRecvParameters(const AudioRecvParameters& params) = 0;
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700865 virtual webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const = 0;
866 virtual bool SetRtpSendParameters(
867 uint32_t ssrc,
868 const webrtc::RtpParameters& parameters) = 0;
deadbeef3bc15102017-04-20 19:25:07 -0700869 // Get the receive parameters for the incoming stream identified by |ssrc|.
870 // If |ssrc| is 0, retrieve the receive parameters for the default receive
871 // stream, which is used when SSRCs are not signaled. Note that calling with
872 // an |ssrc| of 0 will return encoding parameters with an unset |ssrc|
873 // member.
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700874 virtual webrtc::RtpParameters GetRtpReceiveParameters(
875 uint32_t ssrc) const = 0;
876 virtual bool SetRtpReceiveParameters(
877 uint32_t ssrc,
878 const webrtc::RtpParameters& parameters) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000879 // Starts or stops playout of received audio.
aleloi84ef6152016-08-04 05:28:21 -0700880 virtual void SetPlayout(bool playout) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000881 // Starts or stops sending (and potentially capture) of local audio.
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -0800882 virtual void SetSend(bool send) = 0;
solenberg1dd98f32015-09-10 01:57:14 -0700883 // Configure stream for sending.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200884 virtual bool SetAudioSend(uint32_t ssrc,
885 bool enable,
solenbergdfc8f4f2015-10-01 02:31:10 -0700886 const AudioOptions* options,
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -0800887 AudioSource* source) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000888 // Gets current energy levels for all incoming streams.
Patrik Höglundaba85d12017-11-28 15:46:08 +0100889 typedef std::vector<std::pair<uint32_t, int>> StreamList;
890 virtual bool GetActiveStreams(StreamList* actives) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000891 // Get the current energy level of the stream sent to the speaker.
892 virtual int GetOutputLevel() = 0;
solenberg4bac9c52015-10-09 02:32:53 -0700893 // Set speaker output volume of the specified ssrc.
894 virtual bool SetOutputVolume(uint32_t ssrc, double volume) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000895 // Returns if the telephone-event has been negotiated.
solenberg1d63dd02015-12-02 12:35:09 -0800896 virtual bool CanInsertDtmf() = 0;
897 // Send a DTMF |event|. The DTMF out-of-band signal will be used.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000898 // The |ssrc| should be either 0 or a valid send stream ssrc.
henrike@webrtc.org9de257d2013-07-17 14:42:53 +0000899 // The valid value for the |event| are 0 to 15 which corresponding to
900 // DTMF event 0-9, *, #, A-D.
solenberg1d63dd02015-12-02 12:35:09 -0800901 virtual bool InsertDtmf(uint32_t ssrc, int event, int duration) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000902 // Gets quality stats for the channel.
903 virtual bool GetStats(VoiceMediaInfo* info) = 0;
Tommif888bb52015-12-12 01:37:01 +0100904
905 virtual void SetRawAudioSink(
906 uint32_t ssrc,
kwiberg686a8ef2016-02-26 03:00:35 -0800907 std::unique_ptr<webrtc::AudioSinkInterface> sink) = 0;
zhihuang38ede132017-06-15 12:52:32 -0700908
909 virtual std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000910};
911
Taylor Brandstetter5f0b83b2016-03-18 15:02:07 -0700912// TODO(deadbeef): Rename to VideoSenderParameters, since they're intended to
913// encapsulate all the parameters needed for a video RtpSender.
nisse05103312016-03-16 02:22:50 -0700914struct VideoSendParameters : RtpSendParameters<VideoCodec> {
nisse4b4dc862016-02-17 05:25:36 -0800915 // Use conference mode? This flag comes from the remote
916 // description's SDP line 'a=x-google-flag:conference', copied over
917 // by VideoChannel::SetRemoteContent_w, and ultimately used by
918 // conference mode screencast logic in
eladalonf1841382017-06-12 01:16:46 -0700919 // WebRtcVideoChannel::WebRtcVideoSendStream::CreateVideoEncoderConfig.
nisse4b4dc862016-02-17 05:25:36 -0800920 // The special screencast behaviour is disabled by default.
921 bool conference_mode = false;
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700922};
923
Taylor Brandstetter5f0b83b2016-03-18 15:02:07 -0700924// TODO(deadbeef): Rename to VideoReceiverParameters, since they're intended to
925// encapsulate all the parameters needed for a video RtpReceiver.
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700926struct VideoRecvParameters : RtpParameters<VideoCodec> {
927};
928
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000929class VideoMediaChannel : public MediaChannel {
930 public:
nisse08582ff2016-02-04 01:24:52 -0800931 VideoMediaChannel() {}
terelius54f91712016-06-01 11:18:56 -0700932 explicit VideoMediaChannel(const MediaConfig& config)
933 : MediaChannel(config) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000934 virtual ~VideoMediaChannel() {}
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200935
936 virtual bool SetSendParameters(const VideoSendParameters& params) = 0;
937 virtual bool SetRecvParameters(const VideoRecvParameters& params) = 0;
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700938 virtual webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const = 0;
939 virtual bool SetRtpSendParameters(
940 uint32_t ssrc,
941 const webrtc::RtpParameters& parameters) = 0;
deadbeef3bc15102017-04-20 19:25:07 -0700942 // Get the receive parameters for the incoming stream identified by |ssrc|.
943 // If |ssrc| is 0, retrieve the receive parameters for the default receive
944 // stream, which is used when SSRCs are not signaled. Note that calling with
945 // an |ssrc| of 0 will return encoding parameters with an unset |ssrc|
946 // member.
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700947 virtual webrtc::RtpParameters GetRtpReceiveParameters(
948 uint32_t ssrc) const = 0;
949 virtual bool SetRtpReceiveParameters(
950 uint32_t ssrc,
951 const webrtc::RtpParameters& parameters) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000952 // Gets the currently set codecs/payload types to be used for outgoing media.
953 virtual bool GetSendCodec(VideoCodec* send_codec) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000954 // Starts or stops transmission (and potentially capture) of local video.
955 virtual bool SetSend(bool send) = 0;
deadbeef5a4a75a2016-06-02 16:23:38 -0700956 // Configure stream for sending and register a source.
957 // The |ssrc| must correspond to a registered send stream.
958 virtual bool SetVideoSend(
959 uint32_t ssrc,
960 bool enable,
961 const VideoOptions* options,
nisseacd935b2016-11-11 03:55:13 -0800962 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) = 0;
nisse08582ff2016-02-04 01:24:52 -0800963 // Sets the sink object to be used for the specified stream.
deadbeef3bc15102017-04-20 19:25:07 -0700964 // If SSRC is 0, the sink is used for the 'default' stream.
nisse08582ff2016-02-04 01:24:52 -0800965 virtual bool SetSink(uint32_t ssrc,
nisseacd935b2016-11-11 03:55:13 -0800966 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) = 0;
stefanf79ade12017-06-02 06:44:03 -0700967 // This fills the "bitrate parts" (rtx, video bitrate) of the
968 // BandwidthEstimationInfo, since that part that isn't possible to get
969 // through webrtc::Call::GetStats, as they are statistics of the send
970 // streams.
971 // TODO(holmer): We should change this so that either BWE graphs doesn't
972 // need access to bitrates of the streams, or change the (RTC)StatsCollector
973 // so that it's getting the send stream stats separately by calling
974 // GetStats(), and merges with BandwidthEstimationInfo by itself.
975 virtual void FillBitrateInfo(BandwidthEstimationInfo* bwe_info) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000976 // Gets quality stats for the channel.
pbos@webrtc.org058b1f12015-03-04 08:54:32 +0000977 virtual bool GetStats(VideoMediaInfo* info) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000978};
979
980enum DataMessageType {
mallinath@webrtc.org1112c302013-09-23 20:34:45 +0000981 // Chrome-Internal use only. See SctpDataMediaChannel for the actual PPID
982 // values.
983 DMT_NONE = 0,
984 DMT_CONTROL = 1,
985 DMT_BINARY = 2,
986 DMT_TEXT = 3,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000987};
988
989// Info about data received in DataMediaChannel. For use in
990// DataMediaChannel::SignalDataReceived and in all of the signals that
991// signal fires, on up the chain.
992struct ReceiveDataParams {
993 // The in-packet stream indentifier.
deadbeef953c2ce2017-01-09 14:53:41 -0800994 // RTP data channels use SSRCs, SCTP data channels use SIDs.
995 union {
996 uint32_t ssrc;
Steve Anton002f9212018-01-09 16:38:15 -0800997 int sid = 0;
deadbeef953c2ce2017-01-09 14:53:41 -0800998 };
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000999 // The type of message (binary, text, or control).
Steve Anton002f9212018-01-09 16:38:15 -08001000 DataMessageType type = DMT_TEXT;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001001 // A per-stream value incremented per packet in the stream.
Steve Anton002f9212018-01-09 16:38:15 -08001002 int seq_num = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001003 // A per-stream value monotonically increasing with time.
Steve Anton002f9212018-01-09 16:38:15 -08001004 int timestamp = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001005};
1006
1007struct SendDataParams {
1008 // The in-packet stream indentifier.
deadbeef953c2ce2017-01-09 14:53:41 -08001009 // RTP data channels use SSRCs, SCTP data channels use SIDs.
1010 union {
1011 uint32_t ssrc;
Steve Anton002f9212018-01-09 16:38:15 -08001012 int sid = 0;
deadbeef953c2ce2017-01-09 14:53:41 -08001013 };
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001014 // The type of message (binary, text, or control).
Steve Anton002f9212018-01-09 16:38:15 -08001015 DataMessageType type = DMT_TEXT;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001016
Steve Anton002f9212018-01-09 16:38:15 -08001017 // TODO(pthatcher): Make |ordered| and |reliable| true by default?
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001018 // For SCTP, whether to send messages flagged as ordered or not.
1019 // If false, messages can be received out of order.
Steve Anton002f9212018-01-09 16:38:15 -08001020 bool ordered = false;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001021 // For SCTP, whether the messages are sent reliably or not.
1022 // If false, messages may be lost.
Steve Anton002f9212018-01-09 16:38:15 -08001023 bool reliable = false;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001024 // For SCTP, if reliable == false, provide partial reliability by
1025 // resending up to this many times. Either count or millis
1026 // is supported, not both at the same time.
Steve Anton002f9212018-01-09 16:38:15 -08001027 int max_rtx_count = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001028 // For SCTP, if reliable == false, provide partial reliability by
1029 // resending for up to this many milliseconds. Either count or millis
1030 // is supported, not both at the same time.
Steve Anton002f9212018-01-09 16:38:15 -08001031 int max_rtx_ms = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001032};
1033
1034enum SendDataResult { SDR_SUCCESS, SDR_ERROR, SDR_BLOCK };
1035
nisse05103312016-03-16 02:22:50 -07001036struct DataSendParameters : RtpSendParameters<DataCodec> {
solenberg7e4e01a2015-12-02 08:05:01 -08001037 std::string ToString() const {
Peter Thatcherc2ee2c82015-08-07 16:05:34 -07001038 std::ostringstream ost;
1039 // Options and extensions aren't used.
1040 ost << "{";
1041 ost << "codecs: " << VectorToString(codecs) << ", ";
pbos378dc772016-01-28 15:58:41 -08001042 ost << "max_bandwidth_bps: " << max_bandwidth_bps;
Peter Thatcherc2ee2c82015-08-07 16:05:34 -07001043 ost << "}";
1044 return ost.str();
1045 }
1046};
1047
1048struct DataRecvParameters : RtpParameters<DataCodec> {
1049};
1050
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001051class DataMediaChannel : public MediaChannel {
1052 public:
zhihuangebbe4f22016-12-06 10:45:42 -08001053 DataMediaChannel() {}
Steve Antone78bcb92017-10-31 09:53:08 -07001054 explicit DataMediaChannel(const MediaConfig& config) : MediaChannel(config) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001055 virtual ~DataMediaChannel() {}
1056
Fredrik Solenbergb071a192015-09-17 16:42:56 +02001057 virtual bool SetSendParameters(const DataSendParameters& params) = 0;
1058 virtual bool SetRecvParameters(const DataRecvParameters& params) = 0;
wu@webrtc.orga9890802013-12-13 00:21:03 +00001059
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001060 // TODO(pthatcher): Implement this.
1061 virtual bool GetStats(DataMediaInfo* info) { return true; }
1062
1063 virtual bool SetSend(bool send) = 0;
1064 virtual bool SetReceive(bool receive) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001065
Honghai Zhangcc411c02016-03-29 17:27:21 -07001066 virtual void OnNetworkRouteChanged(const std::string& transport_name,
Honghai Zhang0e533ef2016-04-19 15:41:36 -07001067 const rtc::NetworkRoute& network_route) {}
Honghai Zhangcc411c02016-03-29 17:27:21 -07001068
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001069 virtual bool SendData(
1070 const SendDataParams& params,
jbaucheec21bd2016-03-20 06:15:43 -07001071 const rtc::CopyOnWriteBuffer& payload,
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001072 SendDataResult* result = NULL) = 0;
1073 // Signals when data is received (params, data, len)
1074 sigslot::signal3<const ReceiveDataParams&,
1075 const char*,
1076 size_t> SignalDataReceived;
wu@webrtc.orgd64719d2013-08-01 00:00:07 +00001077 // Signal when the media channel is ready to send the stream. Arguments are:
1078 // writable(bool)
1079 sigslot::signal1<bool> SignalReadyToSend;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001080};
1081
1082} // namespace cricket
1083
Mirko Bonadei92ea95e2017-09-15 06:47:31 +02001084#endif // MEDIA_BASE_MEDIACHANNEL_H_