blob: 0f502d343849e584fc32ec7823b0a7d53a9c76c4 [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
Steve Anton10542f22019-01-11 09:11:00 -080011#ifndef MEDIA_BASE_MEDIA_CHANNEL_H_
12#define MEDIA_BASE_MEDIA_CHANNEL_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
Danil Chapovalov00c71832018-06-15 15:58:38 +020020#include "absl/types/optional.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "api/audio_codecs/audio_encoder.h"
Niels Möllera6fe2612018-01-19 11:28:54 +010022#include "api/audio_options.h"
Steve Anton10542f22019-01-11 09:11:00 -080023#include "api/crypto/frame_decryptor_interface.h"
24#include "api/crypto/frame_encryptor_interface.h"
Anton Sukhanov4f08faa2019-05-21 11:12:57 -070025#include "api/media_transport_config.h"
Steve Anton10542f22019-01-11 09:11:00 -080026#include "api/rtc_error.h"
27#include "api/rtp_parameters.h"
Niels Möllera8370302019-09-02 15:16:49 +020028#include "api/transport/rtp/rtp_source.h"
Patrik Höglund3e113432017-12-15 14:40:10 +010029#include "api/video/video_content_type.h"
Niels Möllerc6ce9c52018-05-11 11:15:30 +020030#include "api/video/video_sink_interface.h"
Niels Möller0327c2d2018-05-21 14:09:31 +020031#include "api/video/video_source_interface.h"
32#include "api/video/video_timing.h"
33#include "api/video_codecs/video_encoder_config.h"
Henrik Boströmce33b6a2019-05-28 17:42:38 +020034#include "common_video/include/quality_limitation_reason.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020035#include "media/base/codec.h"
Ruslan Burakov493a6502019-02-27 15:32:48 +010036#include "media/base/delayable.h"
Steve Anton10542f22019-01-11 09:11:00 -080037#include "media/base/media_config.h"
38#include "media/base/media_constants.h"
39#include "media/base/stream_params.h"
Ivo Creusen56d46092017-11-24 17:29:59 +010040#include "modules/audio_processing/include/audio_processing_statistics.h"
Henrik Boström87e3f9d2019-05-27 10:44:24 +020041#include "modules/rtp_rtcp/include/report_block_data.h"
Steve Anton10542f22019-01-11 09:11:00 -080042#include "rtc_base/async_packet_socket.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020043#include "rtc_base/buffer.h"
Steve Anton10542f22019-01-11 09:11:00 -080044#include "rtc_base/copy_on_write_buffer.h"
Niels Möllera8370302019-09-02 15:16:49 +020045#include "rtc_base/critical_section.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020046#include "rtc_base/dscp.h"
47#include "rtc_base/logging.h"
Steve Anton10542f22019-01-11 09:11:00 -080048#include "rtc_base/network_route.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020049#include "rtc_base/socket.h"
Steve Anton10542f22019-01-11 09:11:00 -080050#include "rtc_base/string_encode.h"
Jonas Olsson366a50c2018-09-06 13:41:30 +020051#include "rtc_base/strings/string_builder.h"
Artem Titove41c4332018-07-25 15:04:28 +020052#include "rtc_base/third_party/sigslot/sigslot.h"
Patrik Höglundaba85d12017-11-28 15:46:08 +010053
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000054namespace rtc {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000055class Timing;
56}
57
Tommif888bb52015-12-12 01:37:01 +010058namespace webrtc {
59class AudioSinkInterface;
nisseacd935b2016-11-11 03:55:13 -080060class VideoFrame;
Yves Gerey665174f2018-06-19 15:03:05 +020061} // namespace webrtc
Tommif888bb52015-12-12 01:37:01 +010062
henrike@webrtc.org28e20752013-07-10 00:45:36 +000063namespace cricket {
64
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -080065class AudioSource;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000066class VideoCapturer;
tommi1d5c19d2015-12-13 22:54:29 -080067struct RtpHeader;
68struct VideoFormat;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000069
henrike@webrtc.org28e20752013-07-10 00:45:36 +000070const int kScreencastDefaultFps = 5;
71
henrike@webrtc.org28e20752013-07-10 00:45:36 +000072template <class T>
Danil Chapovalov00c71832018-06-15 15:58:38 +020073static std::string ToStringIfSet(const char* key,
74 const absl::optional<T>& val) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000075 std::string str;
kwiberg102c6a62015-10-30 02:47:38 -070076 if (val) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000077 str = key;
78 str += ": ";
kwiberg102c6a62015-10-30 02:47:38 -070079 str += val ? rtc::ToString(*val) : "";
henrike@webrtc.org28e20752013-07-10 00:45:36 +000080 str += ", ";
81 }
82 return str;
83}
84
Peter Thatcherc2ee2c82015-08-07 16:05:34 -070085template <class T>
86static std::string VectorToString(const std::vector<T>& vals) {
Jonas Olsson366a50c2018-09-06 13:41:30 +020087 rtc::StringBuilder ost; // no-presubmit-check TODO(webrtc:8982)
Yves Gerey665174f2018-06-19 15:03:05 +020088 ost << "[";
89 for (size_t i = 0; i < vals.size(); ++i) {
90 if (i > 0) {
91 ost << ", ";
Peter Thatcherc2ee2c82015-08-07 16:05:34 -070092 }
Yves Gerey665174f2018-06-19 15:03:05 +020093 ost << vals[i].ToString();
94 }
95 ost << "]";
Jonas Olsson84df1c72018-09-14 16:59:32 +020096 return ost.Release();
Peter Thatcherc2ee2c82015-08-07 16:05:34 -070097}
98
henrike@webrtc.org28e20752013-07-10 00:45:36 +000099// Options that can be applied to a VideoMediaChannel or a VideoMediaEngine.
100// Used to be flags, but that makes it hard to selectively apply options.
101// We are moving all of the setting of options to structs like this,
102// but some things currently still use flags.
103struct VideoOptions {
Paulina Hensman11b34f42018-04-09 14:24:52 +0200104 VideoOptions();
105 ~VideoOptions();
106
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000107 void SetAll(const VideoOptions& change) {
kwiberg102c6a62015-10-30 02:47:38 -0700108 SetFrom(&video_noise_reduction, change.video_noise_reduction);
nisseb163c3f2016-01-29 01:14:38 -0800109 SetFrom(&screencast_min_bitrate_kbps, change.screencast_min_bitrate_kbps);
Niels Möller60653ba2016-03-02 11:41:36 +0100110 SetFrom(&is_screencast, change.is_screencast);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000111 }
112
113 bool operator==(const VideoOptions& o) const {
nisseb163c3f2016-01-29 01:14:38 -0800114 return video_noise_reduction == o.video_noise_reduction &&
Niels Möller60653ba2016-03-02 11:41:36 +0100115 screencast_min_bitrate_kbps == o.screencast_min_bitrate_kbps &&
116 is_screencast == o.is_screencast;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000117 }
deadbeef119760a2016-04-04 11:43:27 -0700118 bool operator!=(const VideoOptions& o) const { return !(*this == o); }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000119
120 std::string ToString() const {
Jonas Olsson366a50c2018-09-06 13:41:30 +0200121 rtc::StringBuilder ost;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000122 ost << "VideoOptions {";
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000123 ost << ToStringIfSet("noise reduction", video_noise_reduction);
nisseb163c3f2016-01-29 01:14:38 -0800124 ost << ToStringIfSet("screencast min bitrate kbps",
125 screencast_min_bitrate_kbps);
Niels Möller60653ba2016-03-02 11:41:36 +0100126 ost << ToStringIfSet("is_screencast ", is_screencast);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000127 ost << "}";
Jonas Olsson84df1c72018-09-14 16:59:32 +0200128 return ost.Release();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000129 }
130
nisseb163c3f2016-01-29 01:14:38 -0800131 // Enable denoising? This flag comes from the getUserMedia
eladalonf1841382017-06-12 01:16:46 -0700132 // constraint 'googNoiseReduction', and WebRtcVideoEngine passes it
nisseb163c3f2016-01-29 01:14:38 -0800133 // on to the codec options. Disabled by default.
Danil Chapovalov00c71832018-06-15 15:58:38 +0200134 absl::optional<bool> video_noise_reduction;
nisseb163c3f2016-01-29 01:14:38 -0800135 // Force screencast to use a minimum bitrate. This flag comes from
136 // the PeerConnection constraint 'googScreencastMinBitrate'. It is
eladalonf1841382017-06-12 01:16:46 -0700137 // copied to the encoder config by WebRtcVideoChannel.
Danil Chapovalov00c71832018-06-15 15:58:38 +0200138 absl::optional<int> screencast_min_bitrate_kbps;
Niels Möller60653ba2016-03-02 11:41:36 +0100139 // Set by screencast sources. Implies selection of encoding settings
140 // suitable for screencast. Most likely not the right way to do
141 // things, e.g., screencast of a text document and screencast of a
142 // youtube video have different needs.
Danil Chapovalov00c71832018-06-15 15:58:38 +0200143 absl::optional<bool> is_screencast;
kwiberg102c6a62015-10-30 02:47:38 -0700144
145 private:
146 template <typename T>
Danil Chapovalov00c71832018-06-15 15:58:38 +0200147 static void SetFrom(absl::optional<T>* s, const absl::optional<T>& o) {
kwiberg102c6a62015-10-30 02:47:38 -0700148 if (o) {
149 *s = o;
150 }
151 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000152};
153
isheriffa1c548b2016-05-31 16:12:24 -0700154// TODO(isheriff): Remove this once client usage is fixed to use RtpExtension.
155struct RtpHeaderExtension {
156 RtpHeaderExtension() : id(0) {}
157 RtpHeaderExtension(const std::string& uri, int id) : uri(uri), id(id) {}
158
159 std::string ToString() const {
Jonas Olsson366a50c2018-09-06 13:41:30 +0200160 rtc::StringBuilder ost;
isheriffa1c548b2016-05-31 16:12:24 -0700161 ost << "{";
162 ost << "uri: " << uri;
163 ost << ", id: " << id;
164 ost << "}";
Jonas Olsson84df1c72018-09-14 16:59:32 +0200165 return ost.Release();
isheriffa1c548b2016-05-31 16:12:24 -0700166 }
167
168 std::string uri;
169 int id;
170};
171
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000172class MediaChannel : public sigslot::has_slots<> {
173 public:
174 class NetworkInterface {
175 public:
176 enum SocketType { ST_RTP, ST_RTCP };
jbaucheec21bd2016-03-20 06:15:43 -0700177 virtual bool SendPacket(rtc::CopyOnWriteBuffer* packet,
stefanc1aeaf02015-10-15 07:26:07 -0700178 const rtc::PacketOptions& options) = 0;
jbaucheec21bd2016-03-20 06:15:43 -0700179 virtual bool SendRtcp(rtc::CopyOnWriteBuffer* packet,
stefanc1aeaf02015-10-15 07:26:07 -0700180 const rtc::PacketOptions& options) = 0;
Yves Gerey665174f2018-06-19 15:03:05 +0200181 virtual int SetOption(SocketType type,
182 rtc::Socket::Option opt,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000183 int option) = 0;
184 virtual ~NetworkInterface() {}
185 };
186
Benjamin Wright84583f62018-10-04 14:22:34 -0700187 explicit MediaChannel(const MediaConfig& config);
188 MediaChannel();
189 ~MediaChannel() override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000190
Amit Hilbuchdd9390c2018-11-13 16:26:05 -0800191 virtual cricket::MediaType media_type() const = 0;
192
Anton Sukhanov98a462c2018-10-17 13:15:42 -0700193 // Sets the abstract interface class for sending RTP/RTCP data and
194 // interface for media transport (experimental). If media transport is
195 // provided, it should be used instead of RTP/RTCP.
196 // TODO(sukhanov): Currently media transport can co-exist with RTP/RTCP, but
197 // in the future we will refactor code to send all frames with media
198 // transport.
Anton Sukhanov4f08faa2019-05-21 11:12:57 -0700199 virtual void SetInterface(
200 NetworkInterface* iface,
201 const webrtc::MediaTransportConfig& media_transport_config);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000202 // Called when a RTP packet is received.
Amit Hilbuche7a5f7b2019-03-12 11:10:27 -0700203 virtual void OnPacketReceived(rtc::CopyOnWriteBuffer packet,
Niels Möllere6933812018-11-05 13:01:41 +0100204 int64_t packet_time_us) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000205 // Called when a RTCP packet is received.
Amit Hilbuche7a5f7b2019-03-12 11:10:27 -0700206 virtual void OnRtcpReceived(rtc::CopyOnWriteBuffer packet,
Niels Möllere6933812018-11-05 13:01:41 +0100207 int64_t packet_time_us) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000208 // Called when the socket's ability to send has changed.
209 virtual void OnReadyToSend(bool ready) = 0;
Honghai Zhangcc411c02016-03-29 17:27:21 -0700210 // Called when the network route used for sending packets changed.
Honghai Zhang0e533ef2016-04-19 15:41:36 -0700211 virtual void OnNetworkRouteChanged(
212 const std::string& transport_name,
213 const rtc::NetworkRoute& network_route) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000214 // Creates a new outgoing media stream with SSRCs and CNAME as described
215 // by sp.
216 virtual bool AddSendStream(const StreamParams& sp) = 0;
217 // Removes an outgoing media stream.
Seth Hampson5897a6e2018-04-03 11:16:33 -0700218 // SSRC must be the first SSRC of the media stream if the stream uses
219 // multiple SSRCs. In the case of an ssrc of 0, the possibly cached
220 // StreamParams is removed.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200221 virtual bool RemoveSendStream(uint32_t ssrc) = 0;
Seth Hampson5897a6e2018-04-03 11:16:33 -0700222 // Creates a new incoming media stream with SSRCs, CNAME as described
223 // by sp. In the case of a sp without SSRCs, the unsignaled sp is cached
224 // to be used later for unsignaled streams received.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000225 virtual bool AddRecvStream(const StreamParams& sp) = 0;
226 // Removes an incoming media stream.
227 // ssrc must be the first SSRC of the media stream if the stream uses
228 // multiple SSRCs.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200229 virtual bool RemoveRecvStream(uint32_t ssrc) = 0;
mallinath@webrtc.org92fdfeb2014-02-17 18:49:41 +0000230 // Returns the absoulte sendtime extension id value from media channel.
Paulina Hensman11b34f42018-04-09 14:24:52 +0200231 virtual int GetRtpSendTimeExtnId() const;
Benjamin Wrightbfd412e2018-09-10 14:06:02 -0700232 // Set the frame encryptor to use on all outgoing frames. This is optional.
233 // This pointers lifetime is managed by the set of RtpSender it is attached
234 // to.
Benjamin Wright84583f62018-10-04 14:22:34 -0700235 // TODO(benwright) make pure virtual once internal supports it.
Benjamin Wrightbfd412e2018-09-10 14:06:02 -0700236 virtual void SetFrameEncryptor(
Benjamin Wright84583f62018-10-04 14:22:34 -0700237 uint32_t ssrc,
238 rtc::scoped_refptr<webrtc::FrameEncryptorInterface> frame_encryptor);
Benjamin Wrightbfd412e2018-09-10 14:06:02 -0700239 // Set the frame decryptor to use on all incoming frames. This is optional.
240 // This pointers lifetimes is managed by the set of RtpReceivers it is
241 // attached to.
Benjamin Wright84583f62018-10-04 14:22:34 -0700242 // TODO(benwright) make pure virtual once internal supports it.
Benjamin Wrightbfd412e2018-09-10 14:06:02 -0700243 virtual void SetFrameDecryptor(
Benjamin Wright84583f62018-10-04 14:22:34 -0700244 uint32_t ssrc,
245 rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000246
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000247 // Base method to send packet using NetworkInterface.
jbaucheec21bd2016-03-20 06:15:43 -0700248 bool SendPacket(rtc::CopyOnWriteBuffer* packet,
249 const rtc::PacketOptions& options) {
stefanc1aeaf02015-10-15 07:26:07 -0700250 return DoSendPacket(packet, false, options);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000251 }
252
jbaucheec21bd2016-03-20 06:15:43 -0700253 bool SendRtcp(rtc::CopyOnWriteBuffer* packet,
254 const rtc::PacketOptions& options) {
stefanc1aeaf02015-10-15 07:26:07 -0700255 return DoSendPacket(packet, true, options);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000256 }
257
258 int SetOption(NetworkInterface::SocketType type,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000259 rtc::Socket::Option opt,
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000260 int option) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000261 rtc::CritScope cs(&network_interface_crit_);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000262 if (!network_interface_)
263 return -1;
264
265 return network_interface_->SetOption(type, opt, option);
266 }
267
Anton Sukhanov4f08faa2019-05-21 11:12:57 -0700268 const webrtc::MediaTransportConfig& media_transport_config() const {
269 return media_transport_config_;
270 }
271
Anton Sukhanov98a462c2018-10-17 13:15:42 -0700272 webrtc::MediaTransportInterface* media_transport() {
Anton Sukhanov4f08faa2019-05-21 11:12:57 -0700273 return media_transport_config_.media_transport;
Anton Sukhanov98a462c2018-10-17 13:15:42 -0700274 }
275
Johannes Kron9190b822018-10-29 11:22:05 +0100276 // Corresponds to the SDP attribute extmap-allow-mixed, see RFC8285.
277 // Set to true if it's allowed to mix one- and two-byte RTP header extensions
278 // in the same stream. The setter and getter must only be called from
279 // worker_thread.
280 void SetExtmapAllowMixed(bool extmap_allow_mixed) {
281 extmap_allow_mixed_ = extmap_allow_mixed;
282 }
283 bool ExtmapAllowMixed() const { return extmap_allow_mixed_; }
284
Amit Hilbuchea7ef2a2019-02-19 15:20:21 -0800285 virtual webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const = 0;
286 virtual webrtc::RTCError SetRtpSendParameters(
287 uint32_t ssrc,
288 const webrtc::RtpParameters& parameters) = 0;
289
Tim Haloun6ca98362018-09-17 17:06:08 -0700290 protected:
Tim Haloun6ca98362018-09-17 17:06:08 -0700291 bool DscpEnabled() const { return enable_dscp_; }
292
Steve Antone25f5952019-03-08 15:09:16 -0800293 // This is the DSCP value used for both RTP and RTCP channels if DSCP is
294 // enabled. It can be changed at any time via |SetPreferredDscp|.
295 rtc::DiffServCodePoint PreferredDscp() const {
296 rtc::CritScope cs(&network_interface_crit_);
297 return preferred_dscp_;
298 }
299
300 int SetPreferredDscp(rtc::DiffServCodePoint preferred_dscp) {
301 rtc::CritScope cs(&network_interface_crit_);
302 if (preferred_dscp == preferred_dscp_) {
303 return 0;
304 }
305 preferred_dscp_ = preferred_dscp;
306 return UpdateDscp();
307 }
308
309 private:
310 // Apply the preferred DSCP setting to the underlying network interface RTP
311 // and RTCP channels. If DSCP is disabled, then apply the default DSCP value.
312 int UpdateDscp() RTC_EXCLUSIVE_LOCKS_REQUIRED(network_interface_crit_) {
Tim Haloun648d28a2018-10-18 16:52:22 -0700313 rtc::DiffServCodePoint value =
Steve Antone25f5952019-03-08 15:09:16 -0800314 enable_dscp_ ? preferred_dscp_ : rtc::DSCP_DEFAULT;
315 int ret = SetOption(NetworkInterface::ST_RTP, rtc::Socket::OPT_DSCP, value);
wu@webrtc.orgde305012013-10-31 15:40:38 +0000316 if (ret == 0) {
Yves Gerey665174f2018-06-19 15:03:05 +0200317 ret = SetOption(NetworkInterface::ST_RTCP, rtc::Socket::OPT_DSCP, value);
wu@webrtc.orgde305012013-10-31 15:40:38 +0000318 }
319 return ret;
320 }
321
jbaucheec21bd2016-03-20 06:15:43 -0700322 bool DoSendPacket(rtc::CopyOnWriteBuffer* packet,
stefanc1aeaf02015-10-15 07:26:07 -0700323 bool rtcp,
324 const rtc::PacketOptions& options) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000325 rtc::CritScope cs(&network_interface_crit_);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000326 if (!network_interface_)
327 return false;
328
stefanc1aeaf02015-10-15 07:26:07 -0700329 return (!rtcp) ? network_interface_->SendPacket(packet, options)
330 : network_interface_->SendRtcp(packet, options);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000331 }
332
nisse51542be2016-02-12 02:27:06 -0800333 const bool enable_dscp_;
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000334 // |network_interface_| can be accessed from the worker_thread and
335 // from any MediaEngine threads. This critical section is to protect accessing
336 // of network_interface_ object.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000337 rtc::CriticalSection network_interface_crit_;
Steve Antone25f5952019-03-08 15:09:16 -0800338 NetworkInterface* network_interface_ RTC_GUARDED_BY(network_interface_crit_) =
339 nullptr;
340 rtc::DiffServCodePoint preferred_dscp_
341 RTC_GUARDED_BY(network_interface_crit_) = rtc::DSCP_DEFAULT;
Anton Sukhanov4f08faa2019-05-21 11:12:57 -0700342 webrtc::MediaTransportConfig media_transport_config_;
Johannes Kron9190b822018-10-29 11:22:05 +0100343 bool extmap_allow_mixed_ = false;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000344};
345
wu@webrtc.org97077a32013-10-25 21:18:33 +0000346// The stats information is structured as follows:
347// Media are represented by either MediaSenderInfo or MediaReceiverInfo.
348// Media contains a vector of SSRC infos that are exclusively used by this
349// media. (SSRCs shared between media streams can't be represented.)
350
351// Information about an SSRC.
352// This data may be locally recorded, or received in an RTCP SR or RR.
353struct SsrcSenderInfo {
Steve Anton002f9212018-01-09 16:38:15 -0800354 uint32_t ssrc = 0;
355 double timestamp = 0.0; // NTP timestamp, represented as seconds since epoch.
wu@webrtc.org97077a32013-10-25 21:18:33 +0000356};
357
358struct SsrcReceiverInfo {
Steve Anton002f9212018-01-09 16:38:15 -0800359 uint32_t ssrc = 0;
360 double timestamp = 0.0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000361};
362
363struct MediaSenderInfo {
Paulina Hensman11b34f42018-04-09 14:24:52 +0200364 MediaSenderInfo();
365 ~MediaSenderInfo();
Yves Gerey665174f2018-06-19 15:03:05 +0200366 void add_ssrc(const SsrcSenderInfo& stat) { local_stats.push_back(stat); }
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000367 // Temporary utility function for call sites that only provide SSRC.
368 // As more info is added into SsrcSenderInfo, this function should go away.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200369 void add_ssrc(uint32_t ssrc) {
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000370 SsrcSenderInfo stat;
371 stat.ssrc = ssrc;
372 add_ssrc(stat);
373 }
374 // Utility accessor for clients that are only interested in ssrc numbers.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200375 std::vector<uint32_t> ssrcs() const {
376 std::vector<uint32_t> retval;
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000377 for (std::vector<SsrcSenderInfo>::const_iterator it = local_stats.begin();
378 it != local_stats.end(); ++it) {
379 retval.push_back(it->ssrc);
380 }
381 return retval;
382 }
Harald Alvestrandb8e12012018-01-23 15:28:16 +0100383 // Returns true if the media has been connected.
384 bool connected() const { return local_stats.size() > 0; }
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000385 // Utility accessor for clients that make the assumption only one ssrc
386 // exists per media.
387 // This will eventually go away.
Harald Alvestrandb8e12012018-01-23 15:28:16 +0100388 // Call sites that compare this to zero should use connected() instead.
389 // https://bugs.webrtc.org/8694
Peter Boström0c4e06b2015-10-07 12:23:21 +0200390 uint32_t ssrc() const {
Harald Alvestrandb8e12012018-01-23 15:28:16 +0100391 if (connected()) {
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000392 return local_stats[0].ssrc;
393 } else {
394 return 0;
395 }
396 }
Steve Anton002f9212018-01-09 16:38:15 -0800397 int64_t bytes_sent = 0;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200398 // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedbytessent
399 uint64_t retransmitted_bytes_sent = 0;
Steve Anton002f9212018-01-09 16:38:15 -0800400 int packets_sent = 0;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200401 // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedpacketssent
402 uint64_t retransmitted_packets_sent = 0;
Steve Anton002f9212018-01-09 16:38:15 -0800403 int packets_lost = 0;
404 float fraction_lost = 0.0f;
405 int64_t rtt_ms = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000406 std::string codec_name;
Danil Chapovalov00c71832018-06-15 15:58:38 +0200407 absl::optional<int> codec_payload_type;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000408 std::vector<SsrcSenderInfo> local_stats;
409 std::vector<SsrcReceiverInfo> remote_stats;
Henrik Boström87e3f9d2019-05-27 10:44:24 +0200410 // A snapshot of the most recent Report Block with additional data of interest
411 // to statistics. Used to implement RTCRemoteInboundRtpStreamStats. Within
412 // this list, the ReportBlockData::RTCPReportBlock::source_ssrc(), which is
413 // the SSRC of the corresponding outbound RTP stream, is unique.
414 std::vector<webrtc::ReportBlockData> report_block_datas;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000415};
416
417struct MediaReceiverInfo {
Paulina Hensman11b34f42018-04-09 14:24:52 +0200418 MediaReceiverInfo();
419 ~MediaReceiverInfo();
Yves Gerey665174f2018-06-19 15:03:05 +0200420 void add_ssrc(const SsrcReceiverInfo& stat) { local_stats.push_back(stat); }
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000421 // Temporary utility function for call sites that only provide SSRC.
422 // As more info is added into SsrcSenderInfo, this function should go away.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200423 void add_ssrc(uint32_t ssrc) {
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000424 SsrcReceiverInfo stat;
425 stat.ssrc = ssrc;
426 add_ssrc(stat);
427 }
Peter Boström0c4e06b2015-10-07 12:23:21 +0200428 std::vector<uint32_t> ssrcs() const {
429 std::vector<uint32_t> retval;
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000430 for (std::vector<SsrcReceiverInfo>::const_iterator it = local_stats.begin();
431 it != local_stats.end(); ++it) {
432 retval.push_back(it->ssrc);
433 }
434 return retval;
435 }
Harald Alvestrandb8e12012018-01-23 15:28:16 +0100436 // Returns true if the media has been connected.
437 bool connected() const { return local_stats.size() > 0; }
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000438 // Utility accessor for clients that make the assumption only one ssrc
439 // exists per media.
440 // This will eventually go away.
Harald Alvestrandb8e12012018-01-23 15:28:16 +0100441 // Call sites that compare this to zero should use connected();
442 // https://bugs.webrtc.org/8694
Peter Boström0c4e06b2015-10-07 12:23:21 +0200443 uint32_t ssrc() const {
Harald Alvestrandb8e12012018-01-23 15:28:16 +0100444 if (connected()) {
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000445 return local_stats[0].ssrc;
446 } else {
447 return 0;
448 }
449 }
450
Steve Anton002f9212018-01-09 16:38:15 -0800451 int64_t bytes_rcvd = 0;
452 int packets_rcvd = 0;
453 int packets_lost = 0;
Niels Möller3472b9a2019-06-24 12:18:03 +0200454 // TODO(bugs.webrtc.org/10679): Unused, delete as soon as downstream code is
455 // updated.
Steve Anton002f9212018-01-09 16:38:15 -0800456 float fraction_lost = 0.0f;
Henrik Boström01738c62019-04-15 17:32:00 +0200457 // The timestamp at which the last packet was received, i.e. the time of the
458 // local clock when it was received - not the RTP timestamp of that packet.
459 // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-lastpacketreceivedtimestamp
460 absl::optional<int64_t> last_packet_received_timestamp_ms;
buildbot@webrtc.org7e71b772014-06-13 01:14:01 +0000461 std::string codec_name;
Danil Chapovalov00c71832018-06-15 15:58:38 +0200462 absl::optional<int> codec_payload_type;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000463 std::vector<SsrcReceiverInfo> local_stats;
464 std::vector<SsrcSenderInfo> remote_stats;
465};
466
467struct VoiceSenderInfo : public MediaSenderInfo {
Paulina Hensman11b34f42018-04-09 14:24:52 +0200468 VoiceSenderInfo();
469 ~VoiceSenderInfo();
Steve Anton002f9212018-01-09 16:38:15 -0800470 int jitter_ms = 0;
Henrik Boströmd2c336f2019-07-03 17:11:10 +0200471 // Current audio level, expressed linearly [0,32767].
Steve Anton002f9212018-01-09 16:38:15 -0800472 int audio_level = 0;
zsteine76bd3a2017-07-14 12:17:49 -0700473 // See description of "totalAudioEnergy" in the WebRTC stats spec:
474 // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy
Steve Anton002f9212018-01-09 16:38:15 -0800475 double total_input_energy = 0.0;
476 double total_input_duration = 0.0;
Steve Anton002f9212018-01-09 16:38:15 -0800477 bool typing_noise_detected = false;
ivoce1198e02017-09-08 08:13:19 -0700478 webrtc::ANAStats ana_statistics;
Ivo Creusen56d46092017-11-24 17:29:59 +0100479 webrtc::AudioProcessingStats apm_statistics;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000480};
481
wu@webrtc.org97077a32013-10-25 21:18:33 +0000482struct VoiceReceiverInfo : public MediaReceiverInfo {
Paulina Hensman11b34f42018-04-09 14:24:52 +0200483 VoiceReceiverInfo();
484 ~VoiceReceiverInfo();
Steve Anton002f9212018-01-09 16:38:15 -0800485 int jitter_ms = 0;
486 int jitter_buffer_ms = 0;
487 int jitter_buffer_preferred_ms = 0;
488 int delay_estimate_ms = 0;
489 int audio_level = 0;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200490 // Stats below correspond to similarly-named fields in the WebRTC stats spec.
491 // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats
Steve Anton002f9212018-01-09 16:38:15 -0800492 double total_output_energy = 0.0;
493 uint64_t total_samples_received = 0;
494 double total_output_duration = 0.0;
495 uint64_t concealed_samples = 0;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200496 uint64_t silent_concealed_samples = 0;
Steve Anton002f9212018-01-09 16:38:15 -0800497 uint64_t concealment_events = 0;
Chen Xing0acffb52019-01-15 15:46:29 +0100498 double jitter_buffer_delay_seconds = 0.0;
499 uint64_t jitter_buffer_emitted_count = 0;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200500 uint64_t inserted_samples_for_deceleration = 0;
501 uint64_t removed_samples_for_acceleration = 0;
502 uint64_t fec_packets_received = 0;
503 uint64_t fec_packets_discarded = 0;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200504 // Stats below DO NOT correspond directly to anything in the WebRTC stats
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13 +0000505 // fraction of synthesized audio inserted through expansion.
Steve Anton002f9212018-01-09 16:38:15 -0800506 float expand_rate = 0.0f;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13 +0000507 // fraction of synthesized speech inserted through expansion.
Steve Anton002f9212018-01-09 16:38:15 -0800508 float speech_expand_rate = 0.0f;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13 +0000509 // fraction of data out of secondary decoding, including FEC and RED.
Steve Anton002f9212018-01-09 16:38:15 -0800510 float secondary_decoded_rate = 0.0f;
minyue-webrtc0e320ec2017-08-28 13:51:27 +0200511 // Fraction of secondary data, including FEC and RED, that is discarded.
512 // Discarding of secondary data can be caused by the reception of the primary
513 // data, obsoleting the secondary data. It can also be caused by early
514 // or late arrival of secondary data. This metric is the percentage of
515 // discarded secondary data since last query of receiver info.
Steve Anton002f9212018-01-09 16:38:15 -0800516 float secondary_discarded_rate = 0.0f;
Henrik Lundin8e6fd462015-06-02 09:24:52 +0200517 // Fraction of data removed through time compression.
Steve Anton002f9212018-01-09 16:38:15 -0800518 float accelerate_rate = 0.0f;
Henrik Lundin8e6fd462015-06-02 09:24:52 +0200519 // Fraction of data inserted through time stretching.
Steve Anton002f9212018-01-09 16:38:15 -0800520 float preemptive_expand_rate = 0.0f;
521 int decoding_calls_to_silence_generator = 0;
522 int decoding_calls_to_neteq = 0;
523 int decoding_normal = 0;
Alex Narest5b5d97c2019-08-07 18:15:08 +0200524 // TODO(alexnarest): Consider decoding_neteq_plc for consistency
Steve Anton002f9212018-01-09 16:38:15 -0800525 int decoding_plc = 0;
Alex Narest5b5d97c2019-08-07 18:15:08 +0200526 int decoding_codec_plc = 0;
Steve Anton002f9212018-01-09 16:38:15 -0800527 int decoding_cng = 0;
528 int decoding_plc_cng = 0;
529 int decoding_muted_output = 0;
buildbot@webrtc.orgb525a9d2014-06-03 09:42:15 +0000530 // Estimated capture start time in NTP time in ms.
Steve Anton002f9212018-01-09 16:38:15 -0800531 int64_t capture_start_ntp_time_ms = -1;
Ruslan Burakov8af88962018-11-22 17:21:10 +0100532 // Count of the number of buffer flushes.
533 uint64_t jitter_buffer_flushes = 0;
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100534 // Number of samples expanded due to delayed packets.
535 uint64_t delayed_packet_outage_samples = 0;
Jakob Ivarsson232b3fd2019-03-06 09:18:40 +0100536 // Arrival delay of received audio packets.
537 double relative_packet_arrival_delay_seconds = 0.0;
Henrik Lundin44125fa2019-04-29 17:00:46 +0200538 // Count and total duration of audio interruptions (loss-concealement periods
539 // longer than 150 ms).
540 int32_t interruption_count = 0;
541 int32_t total_interruption_duration_ms = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000542};
543
wu@webrtc.org97077a32013-10-25 21:18:33 +0000544struct VideoSenderInfo : public MediaSenderInfo {
Paulina Hensman11b34f42018-04-09 14:24:52 +0200545 VideoSenderInfo();
546 ~VideoSenderInfo();
pbos@webrtc.org1ed62242015-02-19 13:57:03 +0000547 std::vector<SsrcGroup> ssrc_groups;
Peter Boströmb7d9a972015-12-18 16:01:11 +0100548 std::string encoder_implementation_name;
Steve Anton002f9212018-01-09 16:38:15 -0800549 int firs_rcvd = 0;
550 int plis_rcvd = 0;
551 int nacks_rcvd = 0;
552 int send_frame_width = 0;
553 int send_frame_height = 0;
554 int framerate_input = 0;
555 int framerate_sent = 0;
556 int nominal_bitrate = 0;
Steve Anton002f9212018-01-09 16:38:15 -0800557 int adapt_reason = 0;
558 int adapt_changes = 0;
Henrik Boströmce33b6a2019-05-28 17:42:38 +0200559 // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationreason
560 webrtc::QualityLimitationReason quality_limitation_reason =
561 webrtc::QualityLimitationReason::kNone;
562 // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationdurations
563 std::map<webrtc::QualityLimitationReason, int64_t>
564 quality_limitation_durations_ms;
Steve Anton002f9212018-01-09 16:38:15 -0800565 int avg_encode_ms = 0;
566 int encode_usage_percent = 0;
567 uint32_t frames_encoded = 0;
Rasmus Brandt2efae772019-06-27 14:29:34 +0200568 uint32_t key_frames_encoded = 0;
Henrik Boströmf71362f2019-04-08 16:14:23 +0200569 // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalencodetime
570 uint64_t total_encode_time_ms = 0;
Henrik Boström23aff9b2019-05-20 15:15:38 +0200571 // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalencodedbytestarget
572 uint64_t total_encoded_bytes_target = 0;
Henrik Boström9fe18342019-05-16 18:38:20 +0200573 uint64_t total_packet_send_delay_ms = 0;
Steve Anton002f9212018-01-09 16:38:15 -0800574 bool has_entered_low_resolution = false;
Danil Chapovalov00c71832018-06-15 15:58:38 +0200575 absl::optional<uint64_t> qp_sum;
Steve Anton002f9212018-01-09 16:38:15 -0800576 webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED;
Ilya Nikolaevskiy70473fc2018-02-28 16:35:03 +0100577 // https://w3c.github.io/webrtc-stats/#dom-rtcvideosenderstats-hugeframessent
578 uint32_t huge_frames_sent = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000579};
580
wu@webrtc.org97077a32013-10-25 21:18:33 +0000581struct VideoReceiverInfo : public MediaReceiverInfo {
Paulina Hensman11b34f42018-04-09 14:24:52 +0200582 VideoReceiverInfo();
583 ~VideoReceiverInfo();
pbos@webrtc.org1ed62242015-02-19 13:57:03 +0000584 std::vector<SsrcGroup> ssrc_groups;
Peter Boströmb7d9a972015-12-18 16:01:11 +0100585 std::string decoder_implementation_name;
Steve Anton002f9212018-01-09 16:38:15 -0800586 int packets_concealed = 0;
587 int firs_sent = 0;
588 int plis_sent = 0;
589 int nacks_sent = 0;
590 int frame_width = 0;
591 int frame_height = 0;
592 int framerate_rcvd = 0;
593 int framerate_decoded = 0;
594 int framerate_output = 0;
pbos@webrtc.org1ed62242015-02-19 13:57:03 +0000595 // Framerate as sent to the renderer.
Steve Anton002f9212018-01-09 16:38:15 -0800596 int framerate_render_input = 0;
pbos@webrtc.org1ed62242015-02-19 13:57:03 +0000597 // Framerate that the renderer reports.
Steve Anton002f9212018-01-09 16:38:15 -0800598 int framerate_render_output = 0;
599 uint32_t frames_received = 0;
Johannes Kron0c141c52019-08-26 15:04:43 +0200600 uint32_t frames_dropped = 0;
Steve Anton002f9212018-01-09 16:38:15 -0800601 uint32_t frames_decoded = 0;
Rasmus Brandt2efae772019-06-27 14:29:34 +0200602 uint32_t key_frames_decoded = 0;
Steve Anton002f9212018-01-09 16:38:15 -0800603 uint32_t frames_rendered = 0;
Danil Chapovalov00c71832018-06-15 15:58:38 +0200604 absl::optional<uint64_t> qp_sum;
Johannes Kronbfd343b2019-07-01 10:07:50 +0200605 // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totaldecodetime
606 uint64_t total_decode_time_ms = 0;
Steve Anton002f9212018-01-09 16:38:15 -0800607 int64_t interframe_delay_max_ms = -1;
Sergey Silkin02371062019-01-31 16:45:42 +0100608 uint32_t freeze_count = 0;
609 uint32_t pause_count = 0;
610 uint32_t total_freezes_duration_ms = 0;
611 uint32_t total_pauses_duration_ms = 0;
612 uint32_t total_frames_duration_ms = 0;
613 double sum_squared_frame_durations = 0.0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000614
Steve Anton002f9212018-01-09 16:38:15 -0800615 webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED;
ilnik2e1b40b2017-09-04 07:57:17 -0700616
wu@webrtc.org97077a32013-10-25 21:18:33 +0000617 // All stats below are gathered per-VideoReceiver, but some will be correlated
618 // across MediaStreamTracks. NOTE(hta): when sinking stats into per-SSRC
619 // structures, reflect this in the new layout.
620
621 // Current frame decode latency.
Steve Anton002f9212018-01-09 16:38:15 -0800622 int decode_ms = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000623 // Maximum observed frame decode latency.
Steve Anton002f9212018-01-09 16:38:15 -0800624 int max_decode_ms = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000625 // Jitter (network-related) latency.
Steve Anton002f9212018-01-09 16:38:15 -0800626 int jitter_buffer_ms = 0;
Guido Urdaneta67378412019-05-28 17:38:08 +0200627 // Jitter (network-related) latency (cumulative).
628 // https://w3c.github.io/webrtc-stats/#dom-rtcvideoreceiverstats-jitterbufferdelay
629 double jitter_buffer_delay_seconds = 0;
630 // Number of observations for cumulative jitter latency.
631 // https://w3c.github.io/webrtc-stats/#dom-rtcvideoreceiverstats-jitterbufferemittedcount
632 uint64_t jitter_buffer_emitted_count = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000633 // Requested minimum playout latency.
Steve Anton002f9212018-01-09 16:38:15 -0800634 int min_playout_delay_ms = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000635 // Requested latency to account for rendering delay.
Steve Anton002f9212018-01-09 16:38:15 -0800636 int render_delay_ms = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000637 // Target overall delay: network+decode+render, accounting for
638 // min_playout_delay_ms.
Steve Anton002f9212018-01-09 16:38:15 -0800639 int target_delay_ms = 0;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000640 // Current overall delay, possibly ramping towards target_delay_ms.
Steve Anton002f9212018-01-09 16:38:15 -0800641 int current_delay_ms = 0;
buildbot@webrtc.org0581f0b2014-05-06 21:36:31 +0000642
643 // Estimated capture start time in NTP time in ms.
Steve Anton002f9212018-01-09 16:38:15 -0800644 int64_t capture_start_ntp_time_ms = -1;
ilnik2edc6842017-07-06 03:06:50 -0700645
Benjamin Wright514f0842018-12-10 09:55:17 -0800646 // First frame received to first frame decoded latency.
647 int64_t first_frame_received_to_decoded_ms = -1;
648
ilnik2edc6842017-07-06 03:06:50 -0700649 // Timing frame info: all important timestamps for a full lifetime of a
650 // single 'timing frame'.
Danil Chapovalov00c71832018-06-15 15:58:38 +0200651 absl::optional<webrtc::TimingFrameInfo> timing_frame_info;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000652};
653
wu@webrtc.org97077a32013-10-25 21:18:33 +0000654struct DataSenderInfo : public MediaSenderInfo {
Steve Anton002f9212018-01-09 16:38:15 -0800655 uint32_t ssrc = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000656};
657
wu@webrtc.org97077a32013-10-25 21:18:33 +0000658struct DataReceiverInfo : public MediaReceiverInfo {
Steve Anton002f9212018-01-09 16:38:15 -0800659 uint32_t ssrc = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000660};
661
662struct BandwidthEstimationInfo {
Steve Anton002f9212018-01-09 16:38:15 -0800663 int available_send_bandwidth = 0;
664 int available_recv_bandwidth = 0;
665 int target_enc_bitrate = 0;
666 int actual_enc_bitrate = 0;
667 int retransmit_bitrate = 0;
668 int transmit_bitrate = 0;
669 int64_t bucket_delay = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000670};
671
hbosa65704b2016-11-14 02:28:16 -0800672// Maps from payload type to |RtpCodecParameters|.
673typedef std::map<int, webrtc::RtpCodecParameters> RtpCodecParametersMap;
674
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000675struct VoiceMediaInfo {
Paulina Hensman11b34f42018-04-09 14:24:52 +0200676 VoiceMediaInfo();
677 ~VoiceMediaInfo();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000678 void Clear() {
679 senders.clear();
680 receivers.clear();
hbos1acfbd22016-11-17 23:43:29 -0800681 send_codecs.clear();
682 receive_codecs.clear();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000683 }
684 std::vector<VoiceSenderInfo> senders;
685 std::vector<VoiceReceiverInfo> receivers;
hbos1acfbd22016-11-17 23:43:29 -0800686 RtpCodecParametersMap send_codecs;
687 RtpCodecParametersMap receive_codecs;
Alex Narestbbeb1092019-08-16 11:49:04 +0200688 int32_t device_underrun_count = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000689};
690
691struct VideoMediaInfo {
Paulina Hensman11b34f42018-04-09 14:24:52 +0200692 VideoMediaInfo();
693 ~VideoMediaInfo();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000694 void Clear() {
695 senders.clear();
696 receivers.clear();
charujaind72098a2017-06-01 08:54:47 -0700697 bw_estimations.clear();
hbosa65704b2016-11-14 02:28:16 -0800698 send_codecs.clear();
699 receive_codecs.clear();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000700 }
701 std::vector<VideoSenderInfo> senders;
702 std::vector<VideoReceiverInfo> receivers;
stefanf79ade12017-06-02 06:44:03 -0700703 // Deprecated.
704 // TODO(holmer): Remove once upstream projects no longer use this.
charujaind72098a2017-06-01 08:54:47 -0700705 std::vector<BandwidthEstimationInfo> bw_estimations;
hbosa65704b2016-11-14 02:28:16 -0800706 RtpCodecParametersMap send_codecs;
707 RtpCodecParametersMap receive_codecs;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000708};
709
710struct DataMediaInfo {
Paulina Hensman11b34f42018-04-09 14:24:52 +0200711 DataMediaInfo();
712 ~DataMediaInfo();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000713 void Clear() {
714 senders.clear();
715 receivers.clear();
716 }
717 std::vector<DataSenderInfo> senders;
718 std::vector<DataReceiverInfo> receivers;
719};
720
deadbeef13871492015-12-09 12:37:51 -0800721struct RtcpParameters {
722 bool reduced_size = false;
Sebastian Janssone1795f42019-07-24 11:38:03 +0200723 bool remote_estimate = false;
deadbeef13871492015-12-09 12:37:51 -0800724};
725
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700726template <class Codec>
727struct RtpParameters {
Steve Anton003930a2018-03-29 12:37:21 -0700728 virtual ~RtpParameters() = default;
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700729
730 std::vector<Codec> codecs;
isheriff6f8d6862016-05-26 11:24:55 -0700731 std::vector<webrtc::RtpExtension> extensions;
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700732 // TODO(pthatcher): Add streams.
deadbeef13871492015-12-09 12:37:51 -0800733 RtcpParameters rtcp;
Steve Anton003930a2018-03-29 12:37:21 -0700734
735 std::string ToString() const {
Jonas Olsson366a50c2018-09-06 13:41:30 +0200736 rtc::StringBuilder ost;
Steve Anton003930a2018-03-29 12:37:21 -0700737 ost << "{";
738 const char* separator = "";
739 for (const auto& entry : ToStringMap()) {
740 ost << separator << entry.first << ": " << entry.second;
741 separator = ", ";
742 }
743 ost << "}";
Jonas Olsson84df1c72018-09-14 16:59:32 +0200744 return ost.Release();
Steve Anton003930a2018-03-29 12:37:21 -0700745 }
746
747 protected:
748 virtual std::map<std::string, std::string> ToStringMap() const {
749 return {{"codecs", VectorToString(codecs)},
750 {"extensions", VectorToString(extensions)}};
751 }
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700752};
753
Taylor Brandstetter5f0b83b2016-03-18 15:02:07 -0700754// TODO(deadbeef): Rename to RtpSenderParameters, since they're intended to
755// encapsulate all the parameters needed for an RtpSender.
nisse05103312016-03-16 02:22:50 -0700756template <class Codec>
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700757struct RtpSendParameters : RtpParameters<Codec> {
nisse05103312016-03-16 02:22:50 -0700758 int max_bandwidth_bps = -1;
Steve Antonbb50ce52018-03-26 10:24:32 -0700759 // This is the value to be sent in the MID RTP header extension (if the header
760 // extension in included in the list of extensions).
761 std::string mid;
Johannes Kron9190b822018-10-29 11:22:05 +0100762 bool extmap_allow_mixed = false;
Steve Anton003930a2018-03-29 12:37:21 -0700763
764 protected:
765 std::map<std::string, std::string> ToStringMap() const override {
766 auto params = RtpParameters<Codec>::ToStringMap();
767 params["max_bandwidth_bps"] = rtc::ToString(max_bandwidth_bps);
768 params["mid"] = (mid.empty() ? "<not set>" : mid);
Johannes Kron9190b822018-10-29 11:22:05 +0100769 params["extmap-allow-mixed"] = extmap_allow_mixed ? "true" : "false";
Steve Anton003930a2018-03-29 12:37:21 -0700770 return params;
771 }
nisse05103312016-03-16 02:22:50 -0700772};
773
774struct AudioSendParameters : RtpSendParameters<AudioCodec> {
Paulina Hensman11b34f42018-04-09 14:24:52 +0200775 AudioSendParameters();
776 ~AudioSendParameters() override;
nisse05103312016-03-16 02:22:50 -0700777 AudioOptions options;
Steve Anton003930a2018-03-29 12:37:21 -0700778
779 protected:
Paulina Hensman11b34f42018-04-09 14:24:52 +0200780 std::map<std::string, std::string> ToStringMap() const override;
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700781};
782
Yves Gerey665174f2018-06-19 15:03:05 +0200783struct AudioRecvParameters : RtpParameters<AudioCodec> {};
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700784
Ruslan Burakov493a6502019-02-27 15:32:48 +0100785class VoiceMediaChannel : public MediaChannel, public Delayable {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000786 public:
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000787 VoiceMediaChannel() {}
terelius54f91712016-06-01 11:18:56 -0700788 explicit VoiceMediaChannel(const MediaConfig& config)
789 : MediaChannel(config) {}
Paulina Hensman11b34f42018-04-09 14:24:52 +0200790 ~VoiceMediaChannel() override {}
Amit Hilbuchdd9390c2018-11-13 16:26:05 -0800791
792 cricket::MediaType media_type() const override;
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200793 virtual bool SetSendParameters(const AudioSendParameters& params) = 0;
794 virtual bool SetRecvParameters(const AudioRecvParameters& params) = 0;
deadbeef3bc15102017-04-20 19:25:07 -0700795 // Get the receive parameters for the incoming stream identified by |ssrc|.
796 // If |ssrc| is 0, retrieve the receive parameters for the default receive
797 // stream, which is used when SSRCs are not signaled. Note that calling with
798 // an |ssrc| of 0 will return encoding parameters with an unset |ssrc|
799 // member.
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700800 virtual webrtc::RtpParameters GetRtpReceiveParameters(
801 uint32_t ssrc) const = 0;
802 virtual bool SetRtpReceiveParameters(
803 uint32_t ssrc,
804 const webrtc::RtpParameters& parameters) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000805 // Starts or stops playout of received audio.
aleloi84ef6152016-08-04 05:28:21 -0700806 virtual void SetPlayout(bool playout) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000807 // Starts or stops sending (and potentially capture) of local audio.
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -0800808 virtual void SetSend(bool send) = 0;
solenberg1dd98f32015-09-10 01:57:14 -0700809 // Configure stream for sending.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200810 virtual bool SetAudioSend(uint32_t ssrc,
811 bool enable,
solenbergdfc8f4f2015-10-01 02:31:10 -0700812 const AudioOptions* options,
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -0800813 AudioSource* source) = 0;
solenberg4bac9c52015-10-09 02:32:53 -0700814 // Set speaker output volume of the specified ssrc.
815 virtual bool SetOutputVolume(uint32_t ssrc, double volume) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000816 // Returns if the telephone-event has been negotiated.
solenberg1d63dd02015-12-02 12:35:09 -0800817 virtual bool CanInsertDtmf() = 0;
818 // Send a DTMF |event|. The DTMF out-of-band signal will be used.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000819 // The |ssrc| should be either 0 or a valid send stream ssrc.
henrike@webrtc.org9de257d2013-07-17 14:42:53 +0000820 // The valid value for the |event| are 0 to 15 which corresponding to
821 // DTMF event 0-9, *, #, A-D.
solenberg1d63dd02015-12-02 12:35:09 -0800822 virtual bool InsertDtmf(uint32_t ssrc, int event, int duration) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000823 // Gets quality stats for the channel.
824 virtual bool GetStats(VoiceMediaInfo* info) = 0;
Tommif888bb52015-12-12 01:37:01 +0100825
826 virtual void SetRawAudioSink(
827 uint32_t ssrc,
kwiberg686a8ef2016-02-26 03:00:35 -0800828 std::unique_ptr<webrtc::AudioSinkInterface> sink) = 0;
zhihuang38ede132017-06-15 12:52:32 -0700829
830 virtual std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000831};
832
Taylor Brandstetter5f0b83b2016-03-18 15:02:07 -0700833// TODO(deadbeef): Rename to VideoSenderParameters, since they're intended to
834// encapsulate all the parameters needed for a video RtpSender.
nisse05103312016-03-16 02:22:50 -0700835struct VideoSendParameters : RtpSendParameters<VideoCodec> {
Paulina Hensman11b34f42018-04-09 14:24:52 +0200836 VideoSendParameters();
837 ~VideoSendParameters() override;
nisse4b4dc862016-02-17 05:25:36 -0800838 // Use conference mode? This flag comes from the remote
839 // description's SDP line 'a=x-google-flag:conference', copied over
840 // by VideoChannel::SetRemoteContent_w, and ultimately used by
841 // conference mode screencast logic in
eladalonf1841382017-06-12 01:16:46 -0700842 // WebRtcVideoChannel::WebRtcVideoSendStream::CreateVideoEncoderConfig.
nisse4b4dc862016-02-17 05:25:36 -0800843 // The special screencast behaviour is disabled by default.
844 bool conference_mode = false;
Steve Anton003930a2018-03-29 12:37:21 -0700845
846 protected:
Paulina Hensman11b34f42018-04-09 14:24:52 +0200847 std::map<std::string, std::string> ToStringMap() const override;
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700848};
849
Taylor Brandstetter5f0b83b2016-03-18 15:02:07 -0700850// TODO(deadbeef): Rename to VideoReceiverParameters, since they're intended to
851// encapsulate all the parameters needed for a video RtpReceiver.
Yves Gerey665174f2018-06-19 15:03:05 +0200852struct VideoRecvParameters : RtpParameters<VideoCodec> {};
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700853
Ruslan Burakov493a6502019-02-27 15:32:48 +0100854class VideoMediaChannel : public MediaChannel, public Delayable {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000855 public:
nisse08582ff2016-02-04 01:24:52 -0800856 VideoMediaChannel() {}
terelius54f91712016-06-01 11:18:56 -0700857 explicit VideoMediaChannel(const MediaConfig& config)
858 : MediaChannel(config) {}
Paulina Hensman11b34f42018-04-09 14:24:52 +0200859 ~VideoMediaChannel() override {}
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200860
Amit Hilbuchdd9390c2018-11-13 16:26:05 -0800861 cricket::MediaType media_type() const override;
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200862 virtual bool SetSendParameters(const VideoSendParameters& params) = 0;
863 virtual bool SetRecvParameters(const VideoRecvParameters& params) = 0;
deadbeef3bc15102017-04-20 19:25:07 -0700864 // Get the receive parameters for the incoming stream identified by |ssrc|.
865 // If |ssrc| is 0, retrieve the receive parameters for the default receive
866 // stream, which is used when SSRCs are not signaled. Note that calling with
867 // an |ssrc| of 0 will return encoding parameters with an unset |ssrc|
868 // member.
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700869 virtual webrtc::RtpParameters GetRtpReceiveParameters(
870 uint32_t ssrc) const = 0;
871 virtual bool SetRtpReceiveParameters(
872 uint32_t ssrc,
873 const webrtc::RtpParameters& parameters) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000874 // Gets the currently set codecs/payload types to be used for outgoing media.
875 virtual bool GetSendCodec(VideoCodec* send_codec) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000876 // Starts or stops transmission (and potentially capture) of local video.
877 virtual bool SetSend(bool send) = 0;
deadbeef5a4a75a2016-06-02 16:23:38 -0700878 // Configure stream for sending and register a source.
879 // The |ssrc| must correspond to a registered send stream.
880 virtual bool SetVideoSend(
881 uint32_t ssrc,
deadbeef5a4a75a2016-06-02 16:23:38 -0700882 const VideoOptions* options,
nisseacd935b2016-11-11 03:55:13 -0800883 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) = 0;
nisse08582ff2016-02-04 01:24:52 -0800884 // Sets the sink object to be used for the specified stream.
deadbeef3bc15102017-04-20 19:25:07 -0700885 // If SSRC is 0, the sink is used for the 'default' stream.
nisse08582ff2016-02-04 01:24:52 -0800886 virtual bool SetSink(uint32_t ssrc,
nisseacd935b2016-11-11 03:55:13 -0800887 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) = 0;
stefanf79ade12017-06-02 06:44:03 -0700888 // This fills the "bitrate parts" (rtx, video bitrate) of the
889 // BandwidthEstimationInfo, since that part that isn't possible to get
890 // through webrtc::Call::GetStats, as they are statistics of the send
891 // streams.
892 // TODO(holmer): We should change this so that either BWE graphs doesn't
893 // need access to bitrates of the streams, or change the (RTC)StatsCollector
894 // so that it's getting the send stream stats separately by calling
895 // GetStats(), and merges with BandwidthEstimationInfo by itself.
896 virtual void FillBitrateInfo(BandwidthEstimationInfo* bwe_info) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000897 // Gets quality stats for the channel.
pbos@webrtc.org058b1f12015-03-04 08:54:32 +0000898 virtual bool GetStats(VideoMediaInfo* info) = 0;
Jonas Oreland49ac5952018-09-26 16:04:32 +0200899
900 virtual std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000901};
902
903enum DataMessageType {
mallinath@webrtc.org1112c302013-09-23 20:34:45 +0000904 // Chrome-Internal use only. See SctpDataMediaChannel for the actual PPID
905 // values.
906 DMT_NONE = 0,
907 DMT_CONTROL = 1,
908 DMT_BINARY = 2,
909 DMT_TEXT = 3,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000910};
911
912// Info about data received in DataMediaChannel. For use in
913// DataMediaChannel::SignalDataReceived and in all of the signals that
914// signal fires, on up the chain.
915struct ReceiveDataParams {
916 // The in-packet stream indentifier.
deadbeef953c2ce2017-01-09 14:53:41 -0800917 // RTP data channels use SSRCs, SCTP data channels use SIDs.
918 union {
919 uint32_t ssrc;
Steve Anton002f9212018-01-09 16:38:15 -0800920 int sid = 0;
deadbeef953c2ce2017-01-09 14:53:41 -0800921 };
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000922 // The type of message (binary, text, or control).
Steve Anton002f9212018-01-09 16:38:15 -0800923 DataMessageType type = DMT_TEXT;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000924 // A per-stream value incremented per packet in the stream.
Steve Anton002f9212018-01-09 16:38:15 -0800925 int seq_num = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000926 // A per-stream value monotonically increasing with time.
Steve Anton002f9212018-01-09 16:38:15 -0800927 int timestamp = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000928};
929
930struct SendDataParams {
931 // The in-packet stream indentifier.
deadbeef953c2ce2017-01-09 14:53:41 -0800932 // RTP data channels use SSRCs, SCTP data channels use SIDs.
933 union {
934 uint32_t ssrc;
Steve Anton002f9212018-01-09 16:38:15 -0800935 int sid = 0;
deadbeef953c2ce2017-01-09 14:53:41 -0800936 };
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000937 // The type of message (binary, text, or control).
Steve Anton002f9212018-01-09 16:38:15 -0800938 DataMessageType type = DMT_TEXT;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000939
Steve Anton002f9212018-01-09 16:38:15 -0800940 // TODO(pthatcher): Make |ordered| and |reliable| true by default?
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000941 // For SCTP, whether to send messages flagged as ordered or not.
942 // If false, messages can be received out of order.
Steve Anton002f9212018-01-09 16:38:15 -0800943 bool ordered = false;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000944 // For SCTP, whether the messages are sent reliably or not.
945 // If false, messages may be lost.
Steve Anton002f9212018-01-09 16:38:15 -0800946 bool reliable = false;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000947 // For SCTP, if reliable == false, provide partial reliability by
948 // resending up to this many times. Either count or millis
949 // is supported, not both at the same time.
Steve Anton002f9212018-01-09 16:38:15 -0800950 int max_rtx_count = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000951 // For SCTP, if reliable == false, provide partial reliability by
952 // resending for up to this many milliseconds. Either count or millis
953 // is supported, not both at the same time.
Steve Anton002f9212018-01-09 16:38:15 -0800954 int max_rtx_ms = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000955};
956
957enum SendDataResult { SDR_SUCCESS, SDR_ERROR, SDR_BLOCK };
958
Yves Gerey665174f2018-06-19 15:03:05 +0200959struct DataSendParameters : RtpSendParameters<DataCodec> {};
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700960
Yves Gerey665174f2018-06-19 15:03:05 +0200961struct DataRecvParameters : RtpParameters<DataCodec> {};
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700962
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000963class DataMediaChannel : public MediaChannel {
964 public:
Paulina Hensman11b34f42018-04-09 14:24:52 +0200965 DataMediaChannel();
966 explicit DataMediaChannel(const MediaConfig& config);
967 ~DataMediaChannel() override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000968
Amit Hilbuchdd9390c2018-11-13 16:26:05 -0800969 cricket::MediaType media_type() const override;
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200970 virtual bool SetSendParameters(const DataSendParameters& params) = 0;
971 virtual bool SetRecvParameters(const DataRecvParameters& params) = 0;
wu@webrtc.orga9890802013-12-13 00:21:03 +0000972
Amit Hilbuchea7ef2a2019-02-19 15:20:21 -0800973 // RtpParameter methods are not supported for Data channel.
974 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override;
975 webrtc::RTCError SetRtpSendParameters(
976 uint32_t ssrc,
977 const webrtc::RtpParameters& parameters) override;
978
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000979 // TODO(pthatcher): Implement this.
Paulina Hensman11b34f42018-04-09 14:24:52 +0200980 virtual bool GetStats(DataMediaInfo* info);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000981
982 virtual bool SetSend(bool send) = 0;
983 virtual bool SetReceive(bool receive) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000984
Paulina Hensman11b34f42018-04-09 14:24:52 +0200985 void OnNetworkRouteChanged(const std::string& transport_name,
986 const rtc::NetworkRoute& network_route) override {}
Honghai Zhangcc411c02016-03-29 17:27:21 -0700987
Yves Gerey665174f2018-06-19 15:03:05 +0200988 virtual bool SendData(const SendDataParams& params,
989 const rtc::CopyOnWriteBuffer& payload,
990 SendDataResult* result = NULL) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000991 // Signals when data is received (params, data, len)
Yves Gerey665174f2018-06-19 15:03:05 +0200992 sigslot::signal3<const ReceiveDataParams&, const char*, size_t>
993 SignalDataReceived;
wu@webrtc.orgd64719d2013-08-01 00:00:07 +0000994 // Signal when the media channel is ready to send the stream. Arguments are:
995 // writable(bool)
996 sigslot::signal1<bool> SignalReadyToSend;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000997};
998
999} // namespace cricket
1000
Steve Anton10542f22019-01-11 09:11:00 -08001001#endif // MEDIA_BASE_MEDIA_CHANNEL_H_