media_channel.h 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  1. /*
  2. * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef MEDIA_BASE_MEDIA_CHANNEL_H_
  11. #define MEDIA_BASE_MEDIA_CHANNEL_H_
  12. #include <map>
  13. #include <memory>
  14. #include <string>
  15. #include <utility>
  16. #include <vector>
  17. #include "absl/types/optional.h"
  18. #include "api/audio_codecs/audio_encoder.h"
  19. #include "api/audio_options.h"
  20. #include "api/crypto/frame_decryptor_interface.h"
  21. #include "api/crypto/frame_encryptor_interface.h"
  22. #include "api/frame_transformer_interface.h"
  23. #include "api/media_stream_interface.h"
  24. #include "api/rtc_error.h"
  25. #include "api/rtp_parameters.h"
  26. #include "api/transport/media/media_transport_config.h"
  27. #include "api/transport/rtp/rtp_source.h"
  28. #include "api/video/video_content_type.h"
  29. #include "api/video/video_sink_interface.h"
  30. #include "api/video/video_source_interface.h"
  31. #include "api/video/video_timing.h"
  32. #include "api/video_codecs/video_encoder_config.h"
  33. #include "call/video_receive_stream.h"
  34. #include "common_video/include/quality_limitation_reason.h"
  35. #include "media/base/codec.h"
  36. #include "media/base/delayable.h"
  37. #include "media/base/media_config.h"
  38. #include "media/base/media_constants.h"
  39. #include "media/base/stream_params.h"
  40. #include "modules/audio_processing/include/audio_processing_statistics.h"
  41. #include "modules/rtp_rtcp/include/report_block_data.h"
  42. #include "rtc_base/async_packet_socket.h"
  43. #include "rtc_base/buffer.h"
  44. #include "rtc_base/callback.h"
  45. #include "rtc_base/copy_on_write_buffer.h"
  46. #include "rtc_base/critical_section.h"
  47. #include "rtc_base/dscp.h"
  48. #include "rtc_base/logging.h"
  49. #include "rtc_base/network_route.h"
  50. #include "rtc_base/socket.h"
  51. #include "rtc_base/string_encode.h"
  52. #include "rtc_base/strings/string_builder.h"
  53. #include "rtc_base/third_party/sigslot/sigslot.h"
  54. namespace rtc {
  55. class Timing;
  56. }
  57. namespace webrtc {
  58. class AudioSinkInterface;
  59. class VideoFrame;
  60. } // namespace webrtc
  61. namespace cricket {
  62. class AudioSource;
  63. class VideoCapturer;
  64. struct RtpHeader;
  65. struct VideoFormat;
  66. const int kScreencastDefaultFps = 5;
  67. template <class T>
  68. static std::string ToStringIfSet(const char* key,
  69. const absl::optional<T>& val) {
  70. std::string str;
  71. if (val) {
  72. str = key;
  73. str += ": ";
  74. str += val ? rtc::ToString(*val) : "";
  75. str += ", ";
  76. }
  77. return str;
  78. }
  79. template <class T>
  80. static std::string VectorToString(const std::vector<T>& vals) {
  81. rtc::StringBuilder ost; // no-presubmit-check TODO(webrtc:8982)
  82. ost << "[";
  83. for (size_t i = 0; i < vals.size(); ++i) {
  84. if (i > 0) {
  85. ost << ", ";
  86. }
  87. ost << vals[i].ToString();
  88. }
  89. ost << "]";
  90. return ost.Release();
  91. }
  92. // Options that can be applied to a VideoMediaChannel or a VideoMediaEngine.
  93. // Used to be flags, but that makes it hard to selectively apply options.
  94. // We are moving all of the setting of options to structs like this,
  95. // but some things currently still use flags.
  96. struct VideoOptions {
  97. VideoOptions();
  98. ~VideoOptions();
  99. void SetAll(const VideoOptions& change) {
  100. SetFrom(&video_noise_reduction, change.video_noise_reduction);
  101. SetFrom(&screencast_min_bitrate_kbps, change.screencast_min_bitrate_kbps);
  102. SetFrom(&is_screencast, change.is_screencast);
  103. }
  104. bool operator==(const VideoOptions& o) const {
  105. return video_noise_reduction == o.video_noise_reduction &&
  106. screencast_min_bitrate_kbps == o.screencast_min_bitrate_kbps &&
  107. is_screencast == o.is_screencast;
  108. }
  109. bool operator!=(const VideoOptions& o) const { return !(*this == o); }
  110. std::string ToString() const {
  111. rtc::StringBuilder ost;
  112. ost << "VideoOptions {";
  113. ost << ToStringIfSet("noise reduction", video_noise_reduction);
  114. ost << ToStringIfSet("screencast min bitrate kbps",
  115. screencast_min_bitrate_kbps);
  116. ost << ToStringIfSet("is_screencast ", is_screencast);
  117. ost << "}";
  118. return ost.Release();
  119. }
  120. // Enable denoising? This flag comes from the getUserMedia
  121. // constraint 'googNoiseReduction', and WebRtcVideoEngine passes it
  122. // on to the codec options. Disabled by default.
  123. absl::optional<bool> video_noise_reduction;
  124. // Force screencast to use a minimum bitrate. This flag comes from
  125. // the PeerConnection constraint 'googScreencastMinBitrate'. It is
  126. // copied to the encoder config by WebRtcVideoChannel.
  127. absl::optional<int> screencast_min_bitrate_kbps;
  128. // Set by screencast sources. Implies selection of encoding settings
  129. // suitable for screencast. Most likely not the right way to do
  130. // things, e.g., screencast of a text document and screencast of a
  131. // youtube video have different needs.
  132. absl::optional<bool> is_screencast;
  133. webrtc::VideoTrackInterface::ContentHint content_hint;
  134. private:
  135. template <typename T>
  136. static void SetFrom(absl::optional<T>* s, const absl::optional<T>& o) {
  137. if (o) {
  138. *s = o;
  139. }
  140. }
  141. };
  142. // TODO(isheriff): Remove this once client usage is fixed to use RtpExtension.
  143. struct RtpHeaderExtension {
  144. RtpHeaderExtension() : id(0) {}
  145. RtpHeaderExtension(const std::string& uri, int id) : uri(uri), id(id) {}
  146. std::string ToString() const {
  147. rtc::StringBuilder ost;
  148. ost << "{";
  149. ost << "uri: " << uri;
  150. ost << ", id: " << id;
  151. ost << "}";
  152. return ost.Release();
  153. }
  154. std::string uri;
  155. int id;
  156. };
  157. class MediaChannel : public sigslot::has_slots<> {
  158. public:
  159. class NetworkInterface {
  160. public:
  161. enum SocketType { ST_RTP, ST_RTCP };
  162. virtual bool SendPacket(rtc::CopyOnWriteBuffer* packet,
  163. const rtc::PacketOptions& options) = 0;
  164. virtual bool SendRtcp(rtc::CopyOnWriteBuffer* packet,
  165. const rtc::PacketOptions& options) = 0;
  166. virtual int SetOption(SocketType type,
  167. rtc::Socket::Option opt,
  168. int option) = 0;
  169. virtual ~NetworkInterface() {}
  170. };
  171. explicit MediaChannel(const MediaConfig& config);
  172. MediaChannel();
  173. ~MediaChannel() override;
  174. virtual cricket::MediaType media_type() const = 0;
  175. // Sets the abstract interface class for sending RTP/RTCP data and
  176. // interface for media transport (experimental). If media transport is
  177. // provided, it should be used instead of RTP/RTCP.
  178. // TODO(sukhanov): Currently media transport can co-exist with RTP/RTCP, but
  179. // in the future we will refactor code to send all frames with media
  180. // transport.
  181. virtual void SetInterface(
  182. NetworkInterface* iface,
  183. const webrtc::MediaTransportConfig& media_transport_config)
  184. RTC_LOCKS_EXCLUDED(network_interface_crit_);
  185. // Called when a RTP packet is received.
  186. virtual void OnPacketReceived(rtc::CopyOnWriteBuffer packet,
  187. int64_t packet_time_us) = 0;
  188. // Called when the socket's ability to send has changed.
  189. virtual void OnReadyToSend(bool ready) = 0;
  190. // Called when the network route used for sending packets changed.
  191. virtual void OnNetworkRouteChanged(
  192. const std::string& transport_name,
  193. const rtc::NetworkRoute& network_route) = 0;
  194. // Creates a new outgoing media stream with SSRCs and CNAME as described
  195. // by sp.
  196. virtual bool AddSendStream(const StreamParams& sp) = 0;
  197. // Removes an outgoing media stream.
  198. // SSRC must be the first SSRC of the media stream if the stream uses
  199. // multiple SSRCs. In the case of an ssrc of 0, the possibly cached
  200. // StreamParams is removed.
  201. virtual bool RemoveSendStream(uint32_t ssrc) = 0;
  202. // Creates a new incoming media stream with SSRCs, CNAME as described
  203. // by sp. In the case of a sp without SSRCs, the unsignaled sp is cached
  204. // to be used later for unsignaled streams received.
  205. virtual bool AddRecvStream(const StreamParams& sp) = 0;
  206. // Removes an incoming media stream.
  207. // ssrc must be the first SSRC of the media stream if the stream uses
  208. // multiple SSRCs.
  209. virtual bool RemoveRecvStream(uint32_t ssrc) = 0;
  210. // Resets any cached StreamParams for an unsignaled RecvStream.
  211. virtual void ResetUnsignaledRecvStream() = 0;
  212. // Returns the absoulte sendtime extension id value from media channel.
  213. virtual int GetRtpSendTimeExtnId() const;
  214. // Set the frame encryptor to use on all outgoing frames. This is optional.
  215. // This pointers lifetime is managed by the set of RtpSender it is attached
  216. // to.
  217. // TODO(benwright) make pure virtual once internal supports it.
  218. virtual void SetFrameEncryptor(
  219. uint32_t ssrc,
  220. rtc::scoped_refptr<webrtc::FrameEncryptorInterface> frame_encryptor);
  221. // Set the frame decryptor to use on all incoming frames. This is optional.
  222. // This pointers lifetimes is managed by the set of RtpReceivers it is
  223. // attached to.
  224. // TODO(benwright) make pure virtual once internal supports it.
  225. virtual void SetFrameDecryptor(
  226. uint32_t ssrc,
  227. rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor);
  228. // Enable network condition based codec switching.
  229. virtual void SetVideoCodecSwitchingEnabled(bool enabled);
  230. // Base method to send packet using NetworkInterface.
  231. bool SendPacket(rtc::CopyOnWriteBuffer* packet,
  232. const rtc::PacketOptions& options) {
  233. return DoSendPacket(packet, false, options);
  234. }
  235. bool SendRtcp(rtc::CopyOnWriteBuffer* packet,
  236. const rtc::PacketOptions& options) {
  237. return DoSendPacket(packet, true, options);
  238. }
  239. int SetOption(NetworkInterface::SocketType type,
  240. rtc::Socket::Option opt,
  241. int option) RTC_LOCKS_EXCLUDED(network_interface_crit_) {
  242. rtc::CritScope cs(&network_interface_crit_);
  243. return SetOptionLocked(type, opt, option);
  244. }
  245. const webrtc::MediaTransportConfig& media_transport_config() const {
  246. return media_transport_config_;
  247. }
  248. // Corresponds to the SDP attribute extmap-allow-mixed, see RFC8285.
  249. // Set to true if it's allowed to mix one- and two-byte RTP header extensions
  250. // in the same stream. The setter and getter must only be called from
  251. // worker_thread.
  252. void SetExtmapAllowMixed(bool extmap_allow_mixed) {
  253. extmap_allow_mixed_ = extmap_allow_mixed;
  254. }
  255. bool ExtmapAllowMixed() const { return extmap_allow_mixed_; }
  256. virtual webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const = 0;
  257. virtual webrtc::RTCError SetRtpSendParameters(
  258. uint32_t ssrc,
  259. const webrtc::RtpParameters& parameters) = 0;
  260. virtual void SetEncoderToPacketizerFrameTransformer(
  261. uint32_t ssrc,
  262. rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer);
  263. virtual void SetDepacketizerToDecoderFrameTransformer(
  264. uint32_t ssrc,
  265. rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer);
  266. protected:
  267. int SetOptionLocked(NetworkInterface::SocketType type,
  268. rtc::Socket::Option opt,
  269. int option)
  270. RTC_EXCLUSIVE_LOCKS_REQUIRED(network_interface_crit_) {
  271. if (!network_interface_)
  272. return -1;
  273. return network_interface_->SetOption(type, opt, option);
  274. }
  275. bool DscpEnabled() const { return enable_dscp_; }
  276. // This is the DSCP value used for both RTP and RTCP channels if DSCP is
  277. // enabled. It can be changed at any time via |SetPreferredDscp|.
  278. rtc::DiffServCodePoint PreferredDscp() const
  279. RTC_LOCKS_EXCLUDED(network_interface_crit_) {
  280. rtc::CritScope cs(&network_interface_crit_);
  281. return preferred_dscp_;
  282. }
  283. int SetPreferredDscp(rtc::DiffServCodePoint preferred_dscp)
  284. RTC_LOCKS_EXCLUDED(network_interface_crit_) {
  285. rtc::CritScope cs(&network_interface_crit_);
  286. if (preferred_dscp == preferred_dscp_) {
  287. return 0;
  288. }
  289. preferred_dscp_ = preferred_dscp;
  290. return UpdateDscp();
  291. }
  292. private:
  293. // Apply the preferred DSCP setting to the underlying network interface RTP
  294. // and RTCP channels. If DSCP is disabled, then apply the default DSCP value.
  295. int UpdateDscp() RTC_EXCLUSIVE_LOCKS_REQUIRED(network_interface_crit_) {
  296. rtc::DiffServCodePoint value =
  297. enable_dscp_ ? preferred_dscp_ : rtc::DSCP_DEFAULT;
  298. int ret =
  299. SetOptionLocked(NetworkInterface::ST_RTP, rtc::Socket::OPT_DSCP, value);
  300. if (ret == 0) {
  301. ret = SetOptionLocked(NetworkInterface::ST_RTCP, rtc::Socket::OPT_DSCP,
  302. value);
  303. }
  304. return ret;
  305. }
  306. bool DoSendPacket(rtc::CopyOnWriteBuffer* packet,
  307. bool rtcp,
  308. const rtc::PacketOptions& options)
  309. RTC_LOCKS_EXCLUDED(network_interface_crit_) {
  310. rtc::CritScope cs(&network_interface_crit_);
  311. if (!network_interface_)
  312. return false;
  313. return (!rtcp) ? network_interface_->SendPacket(packet, options)
  314. : network_interface_->SendRtcp(packet, options);
  315. }
  316. const bool enable_dscp_;
  317. // |network_interface_| can be accessed from the worker_thread and
  318. // from any MediaEngine threads. This critical section is to protect accessing
  319. // of network_interface_ object.
  320. rtc::CriticalSection network_interface_crit_;
  321. NetworkInterface* network_interface_ RTC_GUARDED_BY(network_interface_crit_) =
  322. nullptr;
  323. rtc::DiffServCodePoint preferred_dscp_
  324. RTC_GUARDED_BY(network_interface_crit_) = rtc::DSCP_DEFAULT;
  325. webrtc::MediaTransportConfig media_transport_config_;
  326. bool extmap_allow_mixed_ = false;
  327. };
  328. // The stats information is structured as follows:
  329. // Media are represented by either MediaSenderInfo or MediaReceiverInfo.
  330. // Media contains a vector of SSRC infos that are exclusively used by this
  331. // media. (SSRCs shared between media streams can't be represented.)
  332. // Information about an SSRC.
  333. // This data may be locally recorded, or received in an RTCP SR or RR.
  334. struct SsrcSenderInfo {
  335. uint32_t ssrc = 0;
  336. double timestamp = 0.0; // NTP timestamp, represented as seconds since epoch.
  337. };
  338. struct SsrcReceiverInfo {
  339. uint32_t ssrc = 0;
  340. double timestamp = 0.0;
  341. };
  342. struct MediaSenderInfo {
  343. MediaSenderInfo();
  344. ~MediaSenderInfo();
  345. void add_ssrc(const SsrcSenderInfo& stat) { local_stats.push_back(stat); }
  346. // Temporary utility function for call sites that only provide SSRC.
  347. // As more info is added into SsrcSenderInfo, this function should go away.
  348. void add_ssrc(uint32_t ssrc) {
  349. SsrcSenderInfo stat;
  350. stat.ssrc = ssrc;
  351. add_ssrc(stat);
  352. }
  353. // Utility accessor for clients that are only interested in ssrc numbers.
  354. std::vector<uint32_t> ssrcs() const {
  355. std::vector<uint32_t> retval;
  356. for (std::vector<SsrcSenderInfo>::const_iterator it = local_stats.begin();
  357. it != local_stats.end(); ++it) {
  358. retval.push_back(it->ssrc);
  359. }
  360. return retval;
  361. }
  362. // Returns true if the media has been connected.
  363. bool connected() const { return local_stats.size() > 0; }
  364. // Utility accessor for clients that make the assumption only one ssrc
  365. // exists per media.
  366. // This will eventually go away.
  367. // Call sites that compare this to zero should use connected() instead.
  368. // https://bugs.webrtc.org/8694
  369. uint32_t ssrc() const {
  370. if (connected()) {
  371. return local_stats[0].ssrc;
  372. } else {
  373. return 0;
  374. }
  375. }
  376. // https://w3c.github.io/webrtc-stats/#dom-rtcsentrtpstreamstats-bytessent
  377. int64_t payload_bytes_sent = 0;
  378. // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-headerbytessent
  379. int64_t header_and_padding_bytes_sent = 0;
  380. // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedbytessent
  381. uint64_t retransmitted_bytes_sent = 0;
  382. int packets_sent = 0;
  383. // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedpacketssent
  384. uint64_t retransmitted_packets_sent = 0;
  385. int packets_lost = 0;
  386. float fraction_lost = 0.0f;
  387. int64_t rtt_ms = 0;
  388. std::string codec_name;
  389. absl::optional<int> codec_payload_type;
  390. std::vector<SsrcSenderInfo> local_stats;
  391. std::vector<SsrcReceiverInfo> remote_stats;
  392. // A snapshot of the most recent Report Block with additional data of interest
  393. // to statistics. Used to implement RTCRemoteInboundRtpStreamStats. Within
  394. // this list, the ReportBlockData::RTCPReportBlock::source_ssrc(), which is
  395. // the SSRC of the corresponding outbound RTP stream, is unique.
  396. std::vector<webrtc::ReportBlockData> report_block_datas;
  397. };
  398. struct MediaReceiverInfo {
  399. MediaReceiverInfo();
  400. ~MediaReceiverInfo();
  401. void add_ssrc(const SsrcReceiverInfo& stat) { local_stats.push_back(stat); }
  402. // Temporary utility function for call sites that only provide SSRC.
  403. // As more info is added into SsrcSenderInfo, this function should go away.
  404. void add_ssrc(uint32_t ssrc) {
  405. SsrcReceiverInfo stat;
  406. stat.ssrc = ssrc;
  407. add_ssrc(stat);
  408. }
  409. std::vector<uint32_t> ssrcs() const {
  410. std::vector<uint32_t> retval;
  411. for (std::vector<SsrcReceiverInfo>::const_iterator it = local_stats.begin();
  412. it != local_stats.end(); ++it) {
  413. retval.push_back(it->ssrc);
  414. }
  415. return retval;
  416. }
  417. // Returns true if the media has been connected.
  418. bool connected() const { return local_stats.size() > 0; }
  419. // Utility accessor for clients that make the assumption only one ssrc
  420. // exists per media.
  421. // This will eventually go away.
  422. // Call sites that compare this to zero should use connected();
  423. // https://bugs.webrtc.org/8694
  424. uint32_t ssrc() const {
  425. if (connected()) {
  426. return local_stats[0].ssrc;
  427. } else {
  428. return 0;
  429. }
  430. }
  431. // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-bytesreceived
  432. int64_t payload_bytes_rcvd = 0;
  433. // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-headerbytesreceived
  434. int64_t header_and_padding_bytes_rcvd = 0;
  435. int packets_rcvd = 0;
  436. int packets_lost = 0;
  437. // The timestamp at which the last packet was received, i.e. the time of the
  438. // local clock when it was received - not the RTP timestamp of that packet.
  439. // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-lastpacketreceivedtimestamp
  440. absl::optional<int64_t> last_packet_received_timestamp_ms;
  441. // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-estimatedplayouttimestamp
  442. absl::optional<int64_t> estimated_playout_ntp_timestamp_ms;
  443. std::string codec_name;
  444. absl::optional<int> codec_payload_type;
  445. std::vector<SsrcReceiverInfo> local_stats;
  446. std::vector<SsrcSenderInfo> remote_stats;
  447. };
  448. struct VoiceSenderInfo : public MediaSenderInfo {
  449. VoiceSenderInfo();
  450. ~VoiceSenderInfo();
  451. int jitter_ms = 0;
  452. // Current audio level, expressed linearly [0,32767].
  453. int audio_level = 0;
  454. // See description of "totalAudioEnergy" in the WebRTC stats spec:
  455. // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy
  456. double total_input_energy = 0.0;
  457. double total_input_duration = 0.0;
  458. bool typing_noise_detected = false;
  459. webrtc::ANAStats ana_statistics;
  460. webrtc::AudioProcessingStats apm_statistics;
  461. };
  462. struct VoiceReceiverInfo : public MediaReceiverInfo {
  463. VoiceReceiverInfo();
  464. ~VoiceReceiverInfo();
  465. int jitter_ms = 0;
  466. int jitter_buffer_ms = 0;
  467. int jitter_buffer_preferred_ms = 0;
  468. int delay_estimate_ms = 0;
  469. int audio_level = 0;
  470. // Stats below correspond to similarly-named fields in the WebRTC stats spec.
  471. // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats
  472. double total_output_energy = 0.0;
  473. uint64_t total_samples_received = 0;
  474. double total_output_duration = 0.0;
  475. uint64_t concealed_samples = 0;
  476. uint64_t silent_concealed_samples = 0;
  477. uint64_t concealment_events = 0;
  478. double jitter_buffer_delay_seconds = 0.0;
  479. uint64_t jitter_buffer_emitted_count = 0;
  480. double jitter_buffer_target_delay_seconds = 0.0;
  481. uint64_t inserted_samples_for_deceleration = 0;
  482. uint64_t removed_samples_for_acceleration = 0;
  483. uint64_t fec_packets_received = 0;
  484. uint64_t fec_packets_discarded = 0;
  485. // Stats below DO NOT correspond directly to anything in the WebRTC stats
  486. // fraction of synthesized audio inserted through expansion.
  487. float expand_rate = 0.0f;
  488. // fraction of synthesized speech inserted through expansion.
  489. float speech_expand_rate = 0.0f;
  490. // fraction of data out of secondary decoding, including FEC and RED.
  491. float secondary_decoded_rate = 0.0f;
  492. // Fraction of secondary data, including FEC and RED, that is discarded.
  493. // Discarding of secondary data can be caused by the reception of the primary
  494. // data, obsoleting the secondary data. It can also be caused by early
  495. // or late arrival of secondary data. This metric is the percentage of
  496. // discarded secondary data since last query of receiver info.
  497. float secondary_discarded_rate = 0.0f;
  498. // Fraction of data removed through time compression.
  499. float accelerate_rate = 0.0f;
  500. // Fraction of data inserted through time stretching.
  501. float preemptive_expand_rate = 0.0f;
  502. int decoding_calls_to_silence_generator = 0;
  503. int decoding_calls_to_neteq = 0;
  504. int decoding_normal = 0;
  505. // TODO(alexnarest): Consider decoding_neteq_plc for consistency
  506. int decoding_plc = 0;
  507. int decoding_codec_plc = 0;
  508. int decoding_cng = 0;
  509. int decoding_plc_cng = 0;
  510. int decoding_muted_output = 0;
  511. // Estimated capture start time in NTP time in ms.
  512. int64_t capture_start_ntp_time_ms = -1;
  513. // Count of the number of buffer flushes.
  514. uint64_t jitter_buffer_flushes = 0;
  515. // Number of samples expanded due to delayed packets.
  516. uint64_t delayed_packet_outage_samples = 0;
  517. // Arrival delay of received audio packets.
  518. double relative_packet_arrival_delay_seconds = 0.0;
  519. // Count and total duration of audio interruptions (loss-concealement periods
  520. // longer than 150 ms).
  521. int32_t interruption_count = 0;
  522. int32_t total_interruption_duration_ms = 0;
  523. };
  524. struct VideoSenderInfo : public MediaSenderInfo {
  525. VideoSenderInfo();
  526. ~VideoSenderInfo();
  527. std::vector<SsrcGroup> ssrc_groups;
  528. std::string encoder_implementation_name;
  529. int firs_rcvd = 0;
  530. int plis_rcvd = 0;
  531. int nacks_rcvd = 0;
  532. int send_frame_width = 0;
  533. int send_frame_height = 0;
  534. int framerate_input = 0;
  535. int framerate_sent = 0;
  536. int aggregated_framerate_sent = 0;
  537. int nominal_bitrate = 0;
  538. int adapt_reason = 0;
  539. int adapt_changes = 0;
  540. // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationreason
  541. webrtc::QualityLimitationReason quality_limitation_reason =
  542. webrtc::QualityLimitationReason::kNone;
  543. // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationdurations
  544. std::map<webrtc::QualityLimitationReason, int64_t>
  545. quality_limitation_durations_ms;
  546. // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationresolutionchanges
  547. uint32_t quality_limitation_resolution_changes = 0;
  548. int avg_encode_ms = 0;
  549. int encode_usage_percent = 0;
  550. uint32_t frames_encoded = 0;
  551. uint32_t key_frames_encoded = 0;
  552. // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalencodetime
  553. uint64_t total_encode_time_ms = 0;
  554. // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalencodedbytestarget
  555. uint64_t total_encoded_bytes_target = 0;
  556. uint64_t total_packet_send_delay_ms = 0;
  557. bool has_entered_low_resolution = false;
  558. absl::optional<uint64_t> qp_sum;
  559. webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED;
  560. uint32_t frames_sent = 0;
  561. // https://w3c.github.io/webrtc-stats/#dom-rtcvideosenderstats-hugeframessent
  562. uint32_t huge_frames_sent = 0;
  563. uint32_t aggregated_huge_frames_sent = 0;
  564. absl::optional<std::string> rid;
  565. };
  566. struct VideoReceiverInfo : public MediaReceiverInfo {
  567. VideoReceiverInfo();
  568. ~VideoReceiverInfo();
  569. std::vector<SsrcGroup> ssrc_groups;
  570. std::string decoder_implementation_name;
  571. int packets_concealed = 0;
  572. int firs_sent = 0;
  573. int plis_sent = 0;
  574. int nacks_sent = 0;
  575. int frame_width = 0;
  576. int frame_height = 0;
  577. int framerate_rcvd = 0;
  578. int framerate_decoded = 0;
  579. int framerate_output = 0;
  580. // Framerate as sent to the renderer.
  581. int framerate_render_input = 0;
  582. // Framerate that the renderer reports.
  583. int framerate_render_output = 0;
  584. uint32_t frames_received = 0;
  585. uint32_t frames_dropped = 0;
  586. uint32_t frames_decoded = 0;
  587. uint32_t key_frames_decoded = 0;
  588. uint32_t frames_rendered = 0;
  589. absl::optional<uint64_t> qp_sum;
  590. // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totaldecodetime
  591. uint64_t total_decode_time_ms = 0;
  592. double total_inter_frame_delay = 0;
  593. double total_squared_inter_frame_delay = 0;
  594. int64_t interframe_delay_max_ms = -1;
  595. uint32_t freeze_count = 0;
  596. uint32_t pause_count = 0;
  597. uint32_t total_freezes_duration_ms = 0;
  598. uint32_t total_pauses_duration_ms = 0;
  599. uint32_t total_frames_duration_ms = 0;
  600. double sum_squared_frame_durations = 0.0;
  601. webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED;
  602. // All stats below are gathered per-VideoReceiver, but some will be correlated
  603. // across MediaStreamTracks. NOTE(hta): when sinking stats into per-SSRC
  604. // structures, reflect this in the new layout.
  605. // Current frame decode latency.
  606. int decode_ms = 0;
  607. // Maximum observed frame decode latency.
  608. int max_decode_ms = 0;
  609. // Jitter (network-related) latency.
  610. int jitter_buffer_ms = 0;
  611. // Jitter (network-related) latency (cumulative).
  612. // https://w3c.github.io/webrtc-stats/#dom-rtcvideoreceiverstats-jitterbufferdelay
  613. double jitter_buffer_delay_seconds = 0;
  614. // Number of observations for cumulative jitter latency.
  615. // https://w3c.github.io/webrtc-stats/#dom-rtcvideoreceiverstats-jitterbufferemittedcount
  616. uint64_t jitter_buffer_emitted_count = 0;
  617. // Requested minimum playout latency.
  618. int min_playout_delay_ms = 0;
  619. // Requested latency to account for rendering delay.
  620. int render_delay_ms = 0;
  621. // Target overall delay: network+decode+render, accounting for
  622. // min_playout_delay_ms.
  623. int target_delay_ms = 0;
  624. // Current overall delay, possibly ramping towards target_delay_ms.
  625. int current_delay_ms = 0;
  626. // Estimated capture start time in NTP time in ms.
  627. int64_t capture_start_ntp_time_ms = -1;
  628. // First frame received to first frame decoded latency.
  629. int64_t first_frame_received_to_decoded_ms = -1;
  630. // Timing frame info: all important timestamps for a full lifetime of a
  631. // single 'timing frame'.
  632. absl::optional<webrtc::TimingFrameInfo> timing_frame_info;
  633. };
  634. struct DataSenderInfo : public MediaSenderInfo {
  635. uint32_t ssrc = 0;
  636. };
  637. struct DataReceiverInfo : public MediaReceiverInfo {
  638. uint32_t ssrc = 0;
  639. };
  640. struct BandwidthEstimationInfo {
  641. int available_send_bandwidth = 0;
  642. int available_recv_bandwidth = 0;
  643. int target_enc_bitrate = 0;
  644. int actual_enc_bitrate = 0;
  645. int retransmit_bitrate = 0;
  646. int transmit_bitrate = 0;
  647. int64_t bucket_delay = 0;
  648. };
  649. // Maps from payload type to |RtpCodecParameters|.
  650. typedef std::map<int, webrtc::RtpCodecParameters> RtpCodecParametersMap;
  651. struct VoiceMediaInfo {
  652. VoiceMediaInfo();
  653. ~VoiceMediaInfo();
  654. void Clear() {
  655. senders.clear();
  656. receivers.clear();
  657. send_codecs.clear();
  658. receive_codecs.clear();
  659. }
  660. std::vector<VoiceSenderInfo> senders;
  661. std::vector<VoiceReceiverInfo> receivers;
  662. RtpCodecParametersMap send_codecs;
  663. RtpCodecParametersMap receive_codecs;
  664. int32_t device_underrun_count = 0;
  665. };
  666. struct VideoMediaInfo {
  667. VideoMediaInfo();
  668. ~VideoMediaInfo();
  669. void Clear() {
  670. senders.clear();
  671. aggregated_senders.clear();
  672. receivers.clear();
  673. send_codecs.clear();
  674. receive_codecs.clear();
  675. }
  676. // Each sender info represents one "outbound-rtp" stream.In non - simulcast,
  677. // this means one info per RtpSender but if simulcast is used this means
  678. // one info per simulcast layer.
  679. std::vector<VideoSenderInfo> senders;
  680. // Used for legacy getStats() API's "ssrc" stats and modern getStats() API's
  681. // "track" stats. If simulcast is used, instead of having one sender info per
  682. // simulcast layer, the metrics of all layers of an RtpSender are aggregated
  683. // into a single sender info per RtpSender.
  684. std::vector<VideoSenderInfo> aggregated_senders;
  685. std::vector<VideoReceiverInfo> receivers;
  686. RtpCodecParametersMap send_codecs;
  687. RtpCodecParametersMap receive_codecs;
  688. };
  689. struct DataMediaInfo {
  690. DataMediaInfo();
  691. ~DataMediaInfo();
  692. void Clear() {
  693. senders.clear();
  694. receivers.clear();
  695. }
  696. std::vector<DataSenderInfo> senders;
  697. std::vector<DataReceiverInfo> receivers;
  698. };
  699. struct RtcpParameters {
  700. bool reduced_size = false;
  701. bool remote_estimate = false;
  702. };
  703. template <class Codec>
  704. struct RtpParameters {
  705. virtual ~RtpParameters() = default;
  706. std::vector<Codec> codecs;
  707. std::vector<webrtc::RtpExtension> extensions;
  708. // For a send stream this is true if we've neogtiated a send direction,
  709. // for a receive stream this is true if we've negotiated a receive direction.
  710. bool is_stream_active = true;
  711. // TODO(pthatcher): Add streams.
  712. RtcpParameters rtcp;
  713. std::string ToString() const {
  714. rtc::StringBuilder ost;
  715. ost << "{";
  716. const char* separator = "";
  717. for (const auto& entry : ToStringMap()) {
  718. ost << separator << entry.first << ": " << entry.second;
  719. separator = ", ";
  720. }
  721. ost << "}";
  722. return ost.Release();
  723. }
  724. protected:
  725. virtual std::map<std::string, std::string> ToStringMap() const {
  726. return {{"codecs", VectorToString(codecs)},
  727. {"extensions", VectorToString(extensions)}};
  728. }
  729. };
  730. // TODO(deadbeef): Rename to RtpSenderParameters, since they're intended to
  731. // encapsulate all the parameters needed for an RtpSender.
  732. template <class Codec>
  733. struct RtpSendParameters : RtpParameters<Codec> {
  734. int max_bandwidth_bps = -1;
  735. // This is the value to be sent in the MID RTP header extension (if the header
  736. // extension in included in the list of extensions).
  737. std::string mid;
  738. bool extmap_allow_mixed = false;
  739. protected:
  740. std::map<std::string, std::string> ToStringMap() const override {
  741. auto params = RtpParameters<Codec>::ToStringMap();
  742. params["max_bandwidth_bps"] = rtc::ToString(max_bandwidth_bps);
  743. params["mid"] = (mid.empty() ? "<not set>" : mid);
  744. params["extmap-allow-mixed"] = extmap_allow_mixed ? "true" : "false";
  745. return params;
  746. }
  747. };
  748. struct AudioSendParameters : RtpSendParameters<AudioCodec> {
  749. AudioSendParameters();
  750. ~AudioSendParameters() override;
  751. AudioOptions options;
  752. protected:
  753. std::map<std::string, std::string> ToStringMap() const override;
  754. };
  755. struct AudioRecvParameters : RtpParameters<AudioCodec> {};
  756. class VoiceMediaChannel : public MediaChannel, public Delayable {
  757. public:
  758. VoiceMediaChannel() {}
  759. explicit VoiceMediaChannel(const MediaConfig& config)
  760. : MediaChannel(config) {}
  761. ~VoiceMediaChannel() override {}
  762. cricket::MediaType media_type() const override;
  763. virtual bool SetSendParameters(const AudioSendParameters& params) = 0;
  764. virtual bool SetRecvParameters(const AudioRecvParameters& params) = 0;
  765. // Get the receive parameters for the incoming stream identified by |ssrc|.
  766. virtual webrtc::RtpParameters GetRtpReceiveParameters(
  767. uint32_t ssrc) const = 0;
  768. // Retrieve the receive parameters for the default receive
  769. // stream, which is used when SSRCs are not signaled.
  770. virtual webrtc::RtpParameters GetDefaultRtpReceiveParameters() const = 0;
  771. // Starts or stops playout of received audio.
  772. virtual void SetPlayout(bool playout) = 0;
  773. // Starts or stops sending (and potentially capture) of local audio.
  774. virtual void SetSend(bool send) = 0;
  775. // Configure stream for sending.
  776. virtual bool SetAudioSend(uint32_t ssrc,
  777. bool enable,
  778. const AudioOptions* options,
  779. AudioSource* source) = 0;
  780. // Set speaker output volume of the specified ssrc.
  781. virtual bool SetOutputVolume(uint32_t ssrc, double volume) = 0;
  782. // Set speaker output volume for future unsignaled streams.
  783. virtual bool SetDefaultOutputVolume(double volume) = 0;
  784. // Returns if the telephone-event has been negotiated.
  785. virtual bool CanInsertDtmf() = 0;
  786. // Send a DTMF |event|. The DTMF out-of-band signal will be used.
  787. // The |ssrc| should be either 0 or a valid send stream ssrc.
  788. // The valid value for the |event| are 0 to 15 which corresponding to
  789. // DTMF event 0-9, *, #, A-D.
  790. virtual bool InsertDtmf(uint32_t ssrc, int event, int duration) = 0;
  791. // Gets quality stats for the channel.
  792. virtual bool GetStats(VoiceMediaInfo* info) = 0;
  793. virtual void SetRawAudioSink(
  794. uint32_t ssrc,
  795. std::unique_ptr<webrtc::AudioSinkInterface> sink) = 0;
  796. virtual void SetDefaultRawAudioSink(
  797. std::unique_ptr<webrtc::AudioSinkInterface> sink) = 0;
  798. virtual std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const = 0;
  799. };
  800. // TODO(deadbeef): Rename to VideoSenderParameters, since they're intended to
  801. // encapsulate all the parameters needed for a video RtpSender.
  802. struct VideoSendParameters : RtpSendParameters<VideoCodec> {
  803. VideoSendParameters();
  804. ~VideoSendParameters() override;
  805. // Use conference mode? This flag comes from the remote
  806. // description's SDP line 'a=x-google-flag:conference', copied over
  807. // by VideoChannel::SetRemoteContent_w, and ultimately used by
  808. // conference mode screencast logic in
  809. // WebRtcVideoChannel::WebRtcVideoSendStream::CreateVideoEncoderConfig.
  810. // The special screencast behaviour is disabled by default.
  811. bool conference_mode = false;
  812. protected:
  813. std::map<std::string, std::string> ToStringMap() const override;
  814. };
  815. // TODO(deadbeef): Rename to VideoReceiverParameters, since they're intended to
  816. // encapsulate all the parameters needed for a video RtpReceiver.
  817. struct VideoRecvParameters : RtpParameters<VideoCodec> {};
  818. class VideoMediaChannel : public MediaChannel, public Delayable {
  819. public:
  820. VideoMediaChannel() {}
  821. explicit VideoMediaChannel(const MediaConfig& config)
  822. : MediaChannel(config) {}
  823. ~VideoMediaChannel() override {}
  824. cricket::MediaType media_type() const override;
  825. virtual bool SetSendParameters(const VideoSendParameters& params) = 0;
  826. virtual bool SetRecvParameters(const VideoRecvParameters& params) = 0;
  827. // Get the receive parameters for the incoming stream identified by |ssrc|.
  828. virtual webrtc::RtpParameters GetRtpReceiveParameters(
  829. uint32_t ssrc) const = 0;
  830. // Retrieve the receive parameters for the default receive
  831. // stream, which is used when SSRCs are not signaled.
  832. virtual webrtc::RtpParameters GetDefaultRtpReceiveParameters() const = 0;
  833. // Gets the currently set codecs/payload types to be used for outgoing media.
  834. virtual bool GetSendCodec(VideoCodec* send_codec) = 0;
  835. // Starts or stops transmission (and potentially capture) of local video.
  836. virtual bool SetSend(bool send) = 0;
  837. // Configure stream for sending and register a source.
  838. // The |ssrc| must correspond to a registered send stream.
  839. virtual bool SetVideoSend(
  840. uint32_t ssrc,
  841. const VideoOptions* options,
  842. rtc::VideoSourceInterface<webrtc::VideoFrame>* source) = 0;
  843. // Sets the sink object to be used for the specified stream.
  844. virtual bool SetSink(uint32_t ssrc,
  845. rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) = 0;
  846. // The sink is used for the 'default' stream.
  847. virtual void SetDefaultSink(
  848. rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) = 0;
  849. // This fills the "bitrate parts" (rtx, video bitrate) of the
  850. // BandwidthEstimationInfo, since that part that isn't possible to get
  851. // through webrtc::Call::GetStats, as they are statistics of the send
  852. // streams.
  853. // TODO(holmer): We should change this so that either BWE graphs doesn't
  854. // need access to bitrates of the streams, or change the (RTC)StatsCollector
  855. // so that it's getting the send stream stats separately by calling
  856. // GetStats(), and merges with BandwidthEstimationInfo by itself.
  857. virtual void FillBitrateInfo(BandwidthEstimationInfo* bwe_info) = 0;
  858. // Gets quality stats for the channel.
  859. virtual bool GetStats(VideoMediaInfo* info) = 0;
  860. // Set recordable encoded frame callback for |ssrc|
  861. virtual void SetRecordableEncodedFrameCallback(
  862. uint32_t ssrc,
  863. std::function<void(const webrtc::RecordableEncodedFrame&)> callback) = 0;
  864. // Clear recordable encoded frame callback for |ssrc|
  865. virtual void ClearRecordableEncodedFrameCallback(uint32_t ssrc) = 0;
  866. // Cause generation of a keyframe for |ssrc|
  867. virtual void GenerateKeyFrame(uint32_t ssrc) = 0;
  868. virtual std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const = 0;
  869. };
  870. enum DataMessageType {
  871. // Chrome-Internal use only. See SctpDataMediaChannel for the actual PPID
  872. // values.
  873. DMT_NONE = 0,
  874. DMT_CONTROL = 1,
  875. DMT_BINARY = 2,
  876. DMT_TEXT = 3,
  877. };
  878. // Info about data received in DataMediaChannel. For use in
  879. // DataMediaChannel::SignalDataReceived and in all of the signals that
  880. // signal fires, on up the chain.
  881. struct ReceiveDataParams {
  882. // The in-packet stream indentifier.
  883. // RTP data channels use SSRCs, SCTP data channels use SIDs.
  884. union {
  885. uint32_t ssrc;
  886. int sid = 0;
  887. };
  888. // The type of message (binary, text, or control).
  889. DataMessageType type = DMT_TEXT;
  890. // A per-stream value incremented per packet in the stream.
  891. int seq_num = 0;
  892. // A per-stream value monotonically increasing with time.
  893. int timestamp = 0;
  894. };
  895. struct SendDataParams {
  896. // The in-packet stream indentifier.
  897. // RTP data channels use SSRCs, SCTP data channels use SIDs.
  898. union {
  899. uint32_t ssrc;
  900. int sid = 0;
  901. };
  902. // The type of message (binary, text, or control).
  903. DataMessageType type = DMT_TEXT;
  904. // TODO(pthatcher): Make |ordered| and |reliable| true by default?
  905. // For SCTP, whether to send messages flagged as ordered or not.
  906. // If false, messages can be received out of order.
  907. bool ordered = false;
  908. // For SCTP, whether the messages are sent reliably or not.
  909. // If false, messages may be lost.
  910. bool reliable = false;
  911. // For SCTP, if reliable == false, provide partial reliability by
  912. // resending up to this many times. Either count or millis
  913. // is supported, not both at the same time.
  914. int max_rtx_count = 0;
  915. // For SCTP, if reliable == false, provide partial reliability by
  916. // resending for up to this many milliseconds. Either count or millis
  917. // is supported, not both at the same time.
  918. int max_rtx_ms = 0;
  919. };
  920. enum SendDataResult { SDR_SUCCESS, SDR_ERROR, SDR_BLOCK };
  921. struct DataSendParameters : RtpSendParameters<DataCodec> {};
  922. struct DataRecvParameters : RtpParameters<DataCodec> {};
  923. class DataMediaChannel : public MediaChannel {
  924. public:
  925. DataMediaChannel();
  926. explicit DataMediaChannel(const MediaConfig& config);
  927. ~DataMediaChannel() override;
  928. cricket::MediaType media_type() const override;
  929. virtual bool SetSendParameters(const DataSendParameters& params) = 0;
  930. virtual bool SetRecvParameters(const DataRecvParameters& params) = 0;
  931. // RtpParameter methods are not supported for Data channel.
  932. webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override;
  933. webrtc::RTCError SetRtpSendParameters(
  934. uint32_t ssrc,
  935. const webrtc::RtpParameters& parameters) override;
  936. // TODO(pthatcher): Implement this.
  937. virtual bool GetStats(DataMediaInfo* info);
  938. virtual bool SetSend(bool send) = 0;
  939. virtual bool SetReceive(bool receive) = 0;
  940. void OnNetworkRouteChanged(const std::string& transport_name,
  941. const rtc::NetworkRoute& network_route) override {}
  942. virtual bool SendData(const SendDataParams& params,
  943. const rtc::CopyOnWriteBuffer& payload,
  944. SendDataResult* result = NULL) = 0;
  945. // Signals when data is received (params, data, len)
  946. sigslot::signal3<const ReceiveDataParams&, const char*, size_t>
  947. SignalDataReceived;
  948. // Signal when the media channel is ready to send the stream. Arguments are:
  949. // writable(bool)
  950. sigslot::signal1<bool> SignalReadyToSend;
  951. };
  952. } // namespace cricket
  953. #endif // MEDIA_BASE_MEDIA_CHANNEL_H_