henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 2 | * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef MEDIA_BASE_MEDIA_CHANNEL_H_ |
| 12 | #define MEDIA_BASE_MEDIA_CHANNEL_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 | |
Steve Anton | e78bcb9 | 2017-10-31 09:53:08 -0700 | [diff] [blame] | 14 | #include <map> |
kwiberg | 686a8ef | 2016-02-26 03:00:35 -0800 | [diff] [blame] | 15 | #include <memory> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 16 | #include <string> |
Patrik Höglund | aba85d1 | 2017-11-28 15:46:08 +0100 | [diff] [blame] | 17 | #include <utility> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 18 | #include <vector> |
| 19 | |
Danil Chapovalov | 00c7183 | 2018-06-15 15:58:38 +0200 | [diff] [blame] | 20 | #include "absl/types/optional.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 21 | #include "api/audio_codecs/audio_encoder.h" |
Niels Möller | a6fe261 | 2018-01-19 11:28:54 +0100 | [diff] [blame] | 22 | #include "api/audio_options.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 23 | #include "api/crypto/frame_decryptor_interface.h" |
| 24 | #include "api/crypto/frame_encryptor_interface.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 25 | #include "api/rtc_error.h" |
| 26 | #include "api/rtp_parameters.h" |
Niels Möller | 65f17ca | 2019-09-12 13:59:36 +0200 | [diff] [blame^] | 27 | #include "api/transport/media/media_transport_config.h" |
Niels Möller | a837030 | 2019-09-02 15:16:49 +0200 | [diff] [blame] | 28 | #include "api/transport/rtp/rtp_source.h" |
Patrik Höglund | 3e11343 | 2017-12-15 14:40:10 +0100 | [diff] [blame] | 29 | #include "api/video/video_content_type.h" |
Niels Möller | c6ce9c5 | 2018-05-11 11:15:30 +0200 | [diff] [blame] | 30 | #include "api/video/video_sink_interface.h" |
Niels Möller | 0327c2d | 2018-05-21 14:09:31 +0200 | [diff] [blame] | 31 | #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öm | ce33b6a | 2019-05-28 17:42:38 +0200 | [diff] [blame] | 34 | #include "common_video/include/quality_limitation_reason.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 35 | #include "media/base/codec.h" |
Ruslan Burakov | 493a650 | 2019-02-27 15:32:48 +0100 | [diff] [blame] | 36 | #include "media/base/delayable.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 37 | #include "media/base/media_config.h" |
| 38 | #include "media/base/media_constants.h" |
| 39 | #include "media/base/stream_params.h" |
Ivo Creusen | 56d4609 | 2017-11-24 17:29:59 +0100 | [diff] [blame] | 40 | #include "modules/audio_processing/include/audio_processing_statistics.h" |
Henrik Boström | 87e3f9d | 2019-05-27 10:44:24 +0200 | [diff] [blame] | 41 | #include "modules/rtp_rtcp/include/report_block_data.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 42 | #include "rtc_base/async_packet_socket.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 43 | #include "rtc_base/buffer.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 44 | #include "rtc_base/copy_on_write_buffer.h" |
Niels Möller | a837030 | 2019-09-02 15:16:49 +0200 | [diff] [blame] | 45 | #include "rtc_base/critical_section.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 46 | #include "rtc_base/dscp.h" |
| 47 | #include "rtc_base/logging.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 48 | #include "rtc_base/network_route.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 49 | #include "rtc_base/socket.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 50 | #include "rtc_base/string_encode.h" |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 51 | #include "rtc_base/strings/string_builder.h" |
Artem Titov | e41c433 | 2018-07-25 15:04:28 +0200 | [diff] [blame] | 52 | #include "rtc_base/third_party/sigslot/sigslot.h" |
Patrik Höglund | aba85d1 | 2017-11-28 15:46:08 +0100 | [diff] [blame] | 53 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 54 | namespace rtc { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 55 | class Timing; |
| 56 | } |
| 57 | |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 58 | namespace webrtc { |
| 59 | class AudioSinkInterface; |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 60 | class VideoFrame; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 61 | } // namespace webrtc |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 62 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 63 | namespace cricket { |
| 64 | |
Taylor Brandstetter | 1a018dc | 2016-03-08 12:37:39 -0800 | [diff] [blame] | 65 | class AudioSource; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 66 | class VideoCapturer; |
tommi | 1d5c19d | 2015-12-13 22:54:29 -0800 | [diff] [blame] | 67 | struct RtpHeader; |
| 68 | struct VideoFormat; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 69 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 70 | const int kScreencastDefaultFps = 5; |
| 71 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 72 | template <class T> |
Danil Chapovalov | 00c7183 | 2018-06-15 15:58:38 +0200 | [diff] [blame] | 73 | static std::string ToStringIfSet(const char* key, |
| 74 | const absl::optional<T>& val) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 75 | std::string str; |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 76 | if (val) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 77 | str = key; |
| 78 | str += ": "; |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 79 | str += val ? rtc::ToString(*val) : ""; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 80 | str += ", "; |
| 81 | } |
| 82 | return str; |
| 83 | } |
| 84 | |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 85 | template <class T> |
| 86 | static std::string VectorToString(const std::vector<T>& vals) { |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 87 | rtc::StringBuilder ost; // no-presubmit-check TODO(webrtc:8982) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 88 | ost << "["; |
| 89 | for (size_t i = 0; i < vals.size(); ++i) { |
| 90 | if (i > 0) { |
| 91 | ost << ", "; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 92 | } |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 93 | ost << vals[i].ToString(); |
| 94 | } |
| 95 | ost << "]"; |
Jonas Olsson | 84df1c7 | 2018-09-14 16:59:32 +0200 | [diff] [blame] | 96 | return ost.Release(); |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 97 | } |
| 98 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 99 | // 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. |
| 103 | struct VideoOptions { |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 104 | VideoOptions(); |
| 105 | ~VideoOptions(); |
| 106 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 107 | void SetAll(const VideoOptions& change) { |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 108 | SetFrom(&video_noise_reduction, change.video_noise_reduction); |
nisse | b163c3f | 2016-01-29 01:14:38 -0800 | [diff] [blame] | 109 | SetFrom(&screencast_min_bitrate_kbps, change.screencast_min_bitrate_kbps); |
Niels Möller | 60653ba | 2016-03-02 11:41:36 +0100 | [diff] [blame] | 110 | SetFrom(&is_screencast, change.is_screencast); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | bool operator==(const VideoOptions& o) const { |
nisse | b163c3f | 2016-01-29 01:14:38 -0800 | [diff] [blame] | 114 | return video_noise_reduction == o.video_noise_reduction && |
Niels Möller | 60653ba | 2016-03-02 11:41:36 +0100 | [diff] [blame] | 115 | screencast_min_bitrate_kbps == o.screencast_min_bitrate_kbps && |
| 116 | is_screencast == o.is_screencast; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 117 | } |
deadbeef | 119760a | 2016-04-04 11:43:27 -0700 | [diff] [blame] | 118 | bool operator!=(const VideoOptions& o) const { return !(*this == o); } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 119 | |
| 120 | std::string ToString() const { |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 121 | rtc::StringBuilder ost; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 122 | ost << "VideoOptions {"; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 123 | ost << ToStringIfSet("noise reduction", video_noise_reduction); |
nisse | b163c3f | 2016-01-29 01:14:38 -0800 | [diff] [blame] | 124 | ost << ToStringIfSet("screencast min bitrate kbps", |
| 125 | screencast_min_bitrate_kbps); |
Niels Möller | 60653ba | 2016-03-02 11:41:36 +0100 | [diff] [blame] | 126 | ost << ToStringIfSet("is_screencast ", is_screencast); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 127 | ost << "}"; |
Jonas Olsson | 84df1c7 | 2018-09-14 16:59:32 +0200 | [diff] [blame] | 128 | return ost.Release(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 129 | } |
| 130 | |
nisse | b163c3f | 2016-01-29 01:14:38 -0800 | [diff] [blame] | 131 | // Enable denoising? This flag comes from the getUserMedia |
eladalon | f184138 | 2017-06-12 01:16:46 -0700 | [diff] [blame] | 132 | // constraint 'googNoiseReduction', and WebRtcVideoEngine passes it |
nisse | b163c3f | 2016-01-29 01:14:38 -0800 | [diff] [blame] | 133 | // on to the codec options. Disabled by default. |
Danil Chapovalov | 00c7183 | 2018-06-15 15:58:38 +0200 | [diff] [blame] | 134 | absl::optional<bool> video_noise_reduction; |
nisse | b163c3f | 2016-01-29 01:14:38 -0800 | [diff] [blame] | 135 | // Force screencast to use a minimum bitrate. This flag comes from |
| 136 | // the PeerConnection constraint 'googScreencastMinBitrate'. It is |
eladalon | f184138 | 2017-06-12 01:16:46 -0700 | [diff] [blame] | 137 | // copied to the encoder config by WebRtcVideoChannel. |
Danil Chapovalov | 00c7183 | 2018-06-15 15:58:38 +0200 | [diff] [blame] | 138 | absl::optional<int> screencast_min_bitrate_kbps; |
Niels Möller | 60653ba | 2016-03-02 11:41:36 +0100 | [diff] [blame] | 139 | // 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 Chapovalov | 00c7183 | 2018-06-15 15:58:38 +0200 | [diff] [blame] | 143 | absl::optional<bool> is_screencast; |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 144 | |
| 145 | private: |
| 146 | template <typename T> |
Danil Chapovalov | 00c7183 | 2018-06-15 15:58:38 +0200 | [diff] [blame] | 147 | static void SetFrom(absl::optional<T>* s, const absl::optional<T>& o) { |
kwiberg | 102c6a6 | 2015-10-30 02:47:38 -0700 | [diff] [blame] | 148 | if (o) { |
| 149 | *s = o; |
| 150 | } |
| 151 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 152 | }; |
| 153 | |
isheriff | a1c548b | 2016-05-31 16:12:24 -0700 | [diff] [blame] | 154 | // TODO(isheriff): Remove this once client usage is fixed to use RtpExtension. |
| 155 | struct RtpHeaderExtension { |
| 156 | RtpHeaderExtension() : id(0) {} |
| 157 | RtpHeaderExtension(const std::string& uri, int id) : uri(uri), id(id) {} |
| 158 | |
| 159 | std::string ToString() const { |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 160 | rtc::StringBuilder ost; |
isheriff | a1c548b | 2016-05-31 16:12:24 -0700 | [diff] [blame] | 161 | ost << "{"; |
| 162 | ost << "uri: " << uri; |
| 163 | ost << ", id: " << id; |
| 164 | ost << "}"; |
Jonas Olsson | 84df1c7 | 2018-09-14 16:59:32 +0200 | [diff] [blame] | 165 | return ost.Release(); |
isheriff | a1c548b | 2016-05-31 16:12:24 -0700 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | std::string uri; |
| 169 | int id; |
| 170 | }; |
| 171 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 172 | class MediaChannel : public sigslot::has_slots<> { |
| 173 | public: |
| 174 | class NetworkInterface { |
| 175 | public: |
| 176 | enum SocketType { ST_RTP, ST_RTCP }; |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 177 | virtual bool SendPacket(rtc::CopyOnWriteBuffer* packet, |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 178 | const rtc::PacketOptions& options) = 0; |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 179 | virtual bool SendRtcp(rtc::CopyOnWriteBuffer* packet, |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 180 | const rtc::PacketOptions& options) = 0; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 181 | virtual int SetOption(SocketType type, |
| 182 | rtc::Socket::Option opt, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 183 | int option) = 0; |
| 184 | virtual ~NetworkInterface() {} |
| 185 | }; |
| 186 | |
Benjamin Wright | 84583f6 | 2018-10-04 14:22:34 -0700 | [diff] [blame] | 187 | explicit MediaChannel(const MediaConfig& config); |
| 188 | MediaChannel(); |
| 189 | ~MediaChannel() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 190 | |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 191 | virtual cricket::MediaType media_type() const = 0; |
| 192 | |
Anton Sukhanov | 98a462c | 2018-10-17 13:15:42 -0700 | [diff] [blame] | 193 | // 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 Sukhanov | 4f08faa | 2019-05-21 11:12:57 -0700 | [diff] [blame] | 199 | virtual void SetInterface( |
| 200 | NetworkInterface* iface, |
| 201 | const webrtc::MediaTransportConfig& media_transport_config); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 202 | // Called when a RTP packet is received. |
Amit Hilbuch | e7a5f7b | 2019-03-12 11:10:27 -0700 | [diff] [blame] | 203 | virtual void OnPacketReceived(rtc::CopyOnWriteBuffer packet, |
Niels Möller | e693381 | 2018-11-05 13:01:41 +0100 | [diff] [blame] | 204 | int64_t packet_time_us) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 205 | // Called when a RTCP packet is received. |
Amit Hilbuch | e7a5f7b | 2019-03-12 11:10:27 -0700 | [diff] [blame] | 206 | virtual void OnRtcpReceived(rtc::CopyOnWriteBuffer packet, |
Niels Möller | e693381 | 2018-11-05 13:01:41 +0100 | [diff] [blame] | 207 | int64_t packet_time_us) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 208 | // Called when the socket's ability to send has changed. |
| 209 | virtual void OnReadyToSend(bool ready) = 0; |
Honghai Zhang | cc411c0 | 2016-03-29 17:27:21 -0700 | [diff] [blame] | 210 | // Called when the network route used for sending packets changed. |
Honghai Zhang | 0e533ef | 2016-04-19 15:41:36 -0700 | [diff] [blame] | 211 | virtual void OnNetworkRouteChanged( |
| 212 | const std::string& transport_name, |
| 213 | const rtc::NetworkRoute& network_route) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 214 | // 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 Hampson | 5897a6e | 2018-04-03 11:16:33 -0700 | [diff] [blame] | 218 | // 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öm | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 221 | virtual bool RemoveSendStream(uint32_t ssrc) = 0; |
Seth Hampson | 5897a6e | 2018-04-03 11:16:33 -0700 | [diff] [blame] | 222 | // 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.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 225 | 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öm | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 229 | virtual bool RemoveRecvStream(uint32_t ssrc) = 0; |
mallinath@webrtc.org | 92fdfeb | 2014-02-17 18:49:41 +0000 | [diff] [blame] | 230 | // Returns the absoulte sendtime extension id value from media channel. |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 231 | virtual int GetRtpSendTimeExtnId() const; |
Benjamin Wright | bfd412e | 2018-09-10 14:06:02 -0700 | [diff] [blame] | 232 | // 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 Wright | 84583f6 | 2018-10-04 14:22:34 -0700 | [diff] [blame] | 235 | // TODO(benwright) make pure virtual once internal supports it. |
Benjamin Wright | bfd412e | 2018-09-10 14:06:02 -0700 | [diff] [blame] | 236 | virtual void SetFrameEncryptor( |
Benjamin Wright | 84583f6 | 2018-10-04 14:22:34 -0700 | [diff] [blame] | 237 | uint32_t ssrc, |
| 238 | rtc::scoped_refptr<webrtc::FrameEncryptorInterface> frame_encryptor); |
Benjamin Wright | bfd412e | 2018-09-10 14:06:02 -0700 | [diff] [blame] | 239 | // 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 Wright | 84583f6 | 2018-10-04 14:22:34 -0700 | [diff] [blame] | 242 | // TODO(benwright) make pure virtual once internal supports it. |
Benjamin Wright | bfd412e | 2018-09-10 14:06:02 -0700 | [diff] [blame] | 243 | virtual void SetFrameDecryptor( |
Benjamin Wright | 84583f6 | 2018-10-04 14:22:34 -0700 | [diff] [blame] | 244 | uint32_t ssrc, |
| 245 | rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 246 | |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 247 | // Base method to send packet using NetworkInterface. |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 248 | bool SendPacket(rtc::CopyOnWriteBuffer* packet, |
| 249 | const rtc::PacketOptions& options) { |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 250 | return DoSendPacket(packet, false, options); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 251 | } |
| 252 | |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 253 | bool SendRtcp(rtc::CopyOnWriteBuffer* packet, |
| 254 | const rtc::PacketOptions& options) { |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 255 | return DoSendPacket(packet, true, options); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | int SetOption(NetworkInterface::SocketType type, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 259 | rtc::Socket::Option opt, |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 260 | int option) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 261 | rtc::CritScope cs(&network_interface_crit_); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 262 | if (!network_interface_) |
| 263 | return -1; |
| 264 | |
| 265 | return network_interface_->SetOption(type, opt, option); |
| 266 | } |
| 267 | |
Anton Sukhanov | 4f08faa | 2019-05-21 11:12:57 -0700 | [diff] [blame] | 268 | const webrtc::MediaTransportConfig& media_transport_config() const { |
| 269 | return media_transport_config_; |
| 270 | } |
| 271 | |
Anton Sukhanov | 98a462c | 2018-10-17 13:15:42 -0700 | [diff] [blame] | 272 | webrtc::MediaTransportInterface* media_transport() { |
Anton Sukhanov | 4f08faa | 2019-05-21 11:12:57 -0700 | [diff] [blame] | 273 | return media_transport_config_.media_transport; |
Anton Sukhanov | 98a462c | 2018-10-17 13:15:42 -0700 | [diff] [blame] | 274 | } |
| 275 | |
Johannes Kron | 9190b82 | 2018-10-29 11:22:05 +0100 | [diff] [blame] | 276 | // 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 Hilbuch | ea7ef2a | 2019-02-19 15:20:21 -0800 | [diff] [blame] | 285 | 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 Haloun | 6ca9836 | 2018-09-17 17:06:08 -0700 | [diff] [blame] | 290 | protected: |
Tim Haloun | 6ca9836 | 2018-09-17 17:06:08 -0700 | [diff] [blame] | 291 | bool DscpEnabled() const { return enable_dscp_; } |
| 292 | |
Steve Anton | e25f595 | 2019-03-08 15:09:16 -0800 | [diff] [blame] | 293 | // 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 Haloun | 648d28a | 2018-10-18 16:52:22 -0700 | [diff] [blame] | 313 | rtc::DiffServCodePoint value = |
Steve Anton | e25f595 | 2019-03-08 15:09:16 -0800 | [diff] [blame] | 314 | enable_dscp_ ? preferred_dscp_ : rtc::DSCP_DEFAULT; |
| 315 | int ret = SetOption(NetworkInterface::ST_RTP, rtc::Socket::OPT_DSCP, value); |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 316 | if (ret == 0) { |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 317 | ret = SetOption(NetworkInterface::ST_RTCP, rtc::Socket::OPT_DSCP, value); |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 318 | } |
| 319 | return ret; |
| 320 | } |
| 321 | |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 322 | bool DoSendPacket(rtc::CopyOnWriteBuffer* packet, |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 323 | bool rtcp, |
| 324 | const rtc::PacketOptions& options) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 325 | rtc::CritScope cs(&network_interface_crit_); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 326 | if (!network_interface_) |
| 327 | return false; |
| 328 | |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 329 | return (!rtcp) ? network_interface_->SendPacket(packet, options) |
| 330 | : network_interface_->SendRtcp(packet, options); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 331 | } |
| 332 | |
nisse | 51542be | 2016-02-12 02:27:06 -0800 | [diff] [blame] | 333 | const bool enable_dscp_; |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 334 | // |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.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 337 | rtc::CriticalSection network_interface_crit_; |
Steve Anton | e25f595 | 2019-03-08 15:09:16 -0800 | [diff] [blame] | 338 | 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 Sukhanov | 4f08faa | 2019-05-21 11:12:57 -0700 | [diff] [blame] | 342 | webrtc::MediaTransportConfig media_transport_config_; |
Johannes Kron | 9190b82 | 2018-10-29 11:22:05 +0100 | [diff] [blame] | 343 | bool extmap_allow_mixed_ = false; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 344 | }; |
| 345 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 346 | // 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. |
| 353 | struct SsrcSenderInfo { |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 354 | uint32_t ssrc = 0; |
| 355 | double timestamp = 0.0; // NTP timestamp, represented as seconds since epoch. |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 356 | }; |
| 357 | |
| 358 | struct SsrcReceiverInfo { |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 359 | uint32_t ssrc = 0; |
| 360 | double timestamp = 0.0; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 361 | }; |
| 362 | |
| 363 | struct MediaSenderInfo { |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 364 | MediaSenderInfo(); |
| 365 | ~MediaSenderInfo(); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 366 | void add_ssrc(const SsrcSenderInfo& stat) { local_stats.push_back(stat); } |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 367 | // 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öm | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 369 | void add_ssrc(uint32_t ssrc) { |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 370 | 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öm | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 375 | std::vector<uint32_t> ssrcs() const { |
| 376 | std::vector<uint32_t> retval; |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 377 | 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 Alvestrand | b8e1201 | 2018-01-23 15:28:16 +0100 | [diff] [blame] | 383 | // Returns true if the media has been connected. |
| 384 | bool connected() const { return local_stats.size() > 0; } |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 385 | // Utility accessor for clients that make the assumption only one ssrc |
| 386 | // exists per media. |
| 387 | // This will eventually go away. |
Harald Alvestrand | b8e1201 | 2018-01-23 15:28:16 +0100 | [diff] [blame] | 388 | // Call sites that compare this to zero should use connected() instead. |
| 389 | // https://bugs.webrtc.org/8694 |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 390 | uint32_t ssrc() const { |
Harald Alvestrand | b8e1201 | 2018-01-23 15:28:16 +0100 | [diff] [blame] | 391 | if (connected()) { |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 392 | return local_stats[0].ssrc; |
| 393 | } else { |
| 394 | return 0; |
| 395 | } |
| 396 | } |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 397 | int64_t bytes_sent = 0; |
Henrik Boström | cf96e0f | 2019-04-17 13:51:53 +0200 | [diff] [blame] | 398 | // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedbytessent |
| 399 | uint64_t retransmitted_bytes_sent = 0; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 400 | int packets_sent = 0; |
Henrik Boström | cf96e0f | 2019-04-17 13:51:53 +0200 | [diff] [blame] | 401 | // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedpacketssent |
| 402 | uint64_t retransmitted_packets_sent = 0; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 403 | int packets_lost = 0; |
| 404 | float fraction_lost = 0.0f; |
| 405 | int64_t rtt_ms = 0; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 406 | std::string codec_name; |
Danil Chapovalov | 00c7183 | 2018-06-15 15:58:38 +0200 | [diff] [blame] | 407 | absl::optional<int> codec_payload_type; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 408 | std::vector<SsrcSenderInfo> local_stats; |
| 409 | std::vector<SsrcReceiverInfo> remote_stats; |
Henrik Boström | 87e3f9d | 2019-05-27 10:44:24 +0200 | [diff] [blame] | 410 | // 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.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 415 | }; |
| 416 | |
| 417 | struct MediaReceiverInfo { |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 418 | MediaReceiverInfo(); |
| 419 | ~MediaReceiverInfo(); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 420 | void add_ssrc(const SsrcReceiverInfo& stat) { local_stats.push_back(stat); } |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 421 | // 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öm | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 423 | void add_ssrc(uint32_t ssrc) { |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 424 | SsrcReceiverInfo stat; |
| 425 | stat.ssrc = ssrc; |
| 426 | add_ssrc(stat); |
| 427 | } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 428 | std::vector<uint32_t> ssrcs() const { |
| 429 | std::vector<uint32_t> retval; |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 430 | 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 Alvestrand | b8e1201 | 2018-01-23 15:28:16 +0100 | [diff] [blame] | 436 | // Returns true if the media has been connected. |
| 437 | bool connected() const { return local_stats.size() > 0; } |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 438 | // Utility accessor for clients that make the assumption only one ssrc |
| 439 | // exists per media. |
| 440 | // This will eventually go away. |
Harald Alvestrand | b8e1201 | 2018-01-23 15:28:16 +0100 | [diff] [blame] | 441 | // Call sites that compare this to zero should use connected(); |
| 442 | // https://bugs.webrtc.org/8694 |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 443 | uint32_t ssrc() const { |
Harald Alvestrand | b8e1201 | 2018-01-23 15:28:16 +0100 | [diff] [blame] | 444 | if (connected()) { |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 445 | return local_stats[0].ssrc; |
| 446 | } else { |
| 447 | return 0; |
| 448 | } |
| 449 | } |
| 450 | |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 451 | int64_t bytes_rcvd = 0; |
| 452 | int packets_rcvd = 0; |
| 453 | int packets_lost = 0; |
Niels Möller | 3472b9a | 2019-06-24 12:18:03 +0200 | [diff] [blame] | 454 | // TODO(bugs.webrtc.org/10679): Unused, delete as soon as downstream code is |
| 455 | // updated. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 456 | float fraction_lost = 0.0f; |
Henrik Boström | 01738c6 | 2019-04-15 17:32:00 +0200 | [diff] [blame] | 457 | // 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.org | 7e71b77 | 2014-06-13 01:14:01 +0000 | [diff] [blame] | 461 | std::string codec_name; |
Danil Chapovalov | 00c7183 | 2018-06-15 15:58:38 +0200 | [diff] [blame] | 462 | absl::optional<int> codec_payload_type; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 463 | std::vector<SsrcReceiverInfo> local_stats; |
| 464 | std::vector<SsrcSenderInfo> remote_stats; |
| 465 | }; |
| 466 | |
| 467 | struct VoiceSenderInfo : public MediaSenderInfo { |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 468 | VoiceSenderInfo(); |
| 469 | ~VoiceSenderInfo(); |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 470 | int jitter_ms = 0; |
Henrik Boström | d2c336f | 2019-07-03 17:11:10 +0200 | [diff] [blame] | 471 | // Current audio level, expressed linearly [0,32767]. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 472 | int audio_level = 0; |
zstein | e76bd3a | 2017-07-14 12:17:49 -0700 | [diff] [blame] | 473 | // See description of "totalAudioEnergy" in the WebRTC stats spec: |
| 474 | // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 475 | double total_input_energy = 0.0; |
| 476 | double total_input_duration = 0.0; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 477 | bool typing_noise_detected = false; |
ivoc | e1198e0 | 2017-09-08 08:13:19 -0700 | [diff] [blame] | 478 | webrtc::ANAStats ana_statistics; |
Ivo Creusen | 56d4609 | 2017-11-24 17:29:59 +0100 | [diff] [blame] | 479 | webrtc::AudioProcessingStats apm_statistics; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 480 | }; |
| 481 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 482 | struct VoiceReceiverInfo : public MediaReceiverInfo { |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 483 | VoiceReceiverInfo(); |
| 484 | ~VoiceReceiverInfo(); |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 485 | 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 Ullberg | 9a2e906 | 2017-09-18 09:28:20 +0200 | [diff] [blame] | 490 | // Stats below correspond to similarly-named fields in the WebRTC stats spec. |
| 491 | // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 492 | 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 Creusen | 8d8ffdb | 2019-04-30 09:45:21 +0200 | [diff] [blame] | 496 | uint64_t silent_concealed_samples = 0; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 497 | uint64_t concealment_events = 0; |
Chen Xing | 0acffb5 | 2019-01-15 15:46:29 +0100 | [diff] [blame] | 498 | double jitter_buffer_delay_seconds = 0.0; |
| 499 | uint64_t jitter_buffer_emitted_count = 0; |
Ivo Creusen | 8d8ffdb | 2019-04-30 09:45:21 +0200 | [diff] [blame] | 500 | 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 Ullberg | 9a2e906 | 2017-09-18 09:28:20 +0200 | [diff] [blame] | 504 | // Stats below DO NOT correspond directly to anything in the WebRTC stats |
minyue@webrtc.org | c0bd7be | 2015-02-18 15:24:13 +0000 | [diff] [blame] | 505 | // fraction of synthesized audio inserted through expansion. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 506 | float expand_rate = 0.0f; |
minyue@webrtc.org | c0bd7be | 2015-02-18 15:24:13 +0000 | [diff] [blame] | 507 | // fraction of synthesized speech inserted through expansion. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 508 | float speech_expand_rate = 0.0f; |
minyue@webrtc.org | c0bd7be | 2015-02-18 15:24:13 +0000 | [diff] [blame] | 509 | // fraction of data out of secondary decoding, including FEC and RED. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 510 | float secondary_decoded_rate = 0.0f; |
minyue-webrtc | 0e320ec | 2017-08-28 13:51:27 +0200 | [diff] [blame] | 511 | // 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 Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 516 | float secondary_discarded_rate = 0.0f; |
Henrik Lundin | 8e6fd46 | 2015-06-02 09:24:52 +0200 | [diff] [blame] | 517 | // Fraction of data removed through time compression. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 518 | float accelerate_rate = 0.0f; |
Henrik Lundin | 8e6fd46 | 2015-06-02 09:24:52 +0200 | [diff] [blame] | 519 | // Fraction of data inserted through time stretching. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 520 | 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 Narest | 5b5d97c | 2019-08-07 18:15:08 +0200 | [diff] [blame] | 524 | // TODO(alexnarest): Consider decoding_neteq_plc for consistency |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 525 | int decoding_plc = 0; |
Alex Narest | 5b5d97c | 2019-08-07 18:15:08 +0200 | [diff] [blame] | 526 | int decoding_codec_plc = 0; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 527 | int decoding_cng = 0; |
| 528 | int decoding_plc_cng = 0; |
| 529 | int decoding_muted_output = 0; |
buildbot@webrtc.org | b525a9d | 2014-06-03 09:42:15 +0000 | [diff] [blame] | 530 | // Estimated capture start time in NTP time in ms. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 531 | int64_t capture_start_ntp_time_ms = -1; |
Ruslan Burakov | 8af8896 | 2018-11-22 17:21:10 +0100 | [diff] [blame] | 532 | // Count of the number of buffer flushes. |
| 533 | uint64_t jitter_buffer_flushes = 0; |
Jakob Ivarsson | 352ce5c | 2018-11-27 12:52:16 +0100 | [diff] [blame] | 534 | // Number of samples expanded due to delayed packets. |
| 535 | uint64_t delayed_packet_outage_samples = 0; |
Jakob Ivarsson | 232b3fd | 2019-03-06 09:18:40 +0100 | [diff] [blame] | 536 | // Arrival delay of received audio packets. |
| 537 | double relative_packet_arrival_delay_seconds = 0.0; |
Henrik Lundin | 44125fa | 2019-04-29 17:00:46 +0200 | [diff] [blame] | 538 | // 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.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 542 | }; |
| 543 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 544 | struct VideoSenderInfo : public MediaSenderInfo { |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 545 | VideoSenderInfo(); |
| 546 | ~VideoSenderInfo(); |
pbos@webrtc.org | 1ed6224 | 2015-02-19 13:57:03 +0000 | [diff] [blame] | 547 | std::vector<SsrcGroup> ssrc_groups; |
Peter Boström | b7d9a97 | 2015-12-18 16:01:11 +0100 | [diff] [blame] | 548 | std::string encoder_implementation_name; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 549 | 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 Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 557 | int adapt_reason = 0; |
| 558 | int adapt_changes = 0; |
Henrik Boström | ce33b6a | 2019-05-28 17:42:38 +0200 | [diff] [blame] | 559 | // 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; |
Evan Shrubsole | cc62b16 | 2019-09-09 11:26:45 +0200 | [diff] [blame] | 565 | // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationresolutionchanges |
| 566 | uint32_t quality_limitation_resolution_changes = 0; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 567 | int avg_encode_ms = 0; |
| 568 | int encode_usage_percent = 0; |
| 569 | uint32_t frames_encoded = 0; |
Rasmus Brandt | 2efae77 | 2019-06-27 14:29:34 +0200 | [diff] [blame] | 570 | uint32_t key_frames_encoded = 0; |
Henrik Boström | f71362f | 2019-04-08 16:14:23 +0200 | [diff] [blame] | 571 | // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalencodetime |
| 572 | uint64_t total_encode_time_ms = 0; |
Henrik Boström | 23aff9b | 2019-05-20 15:15:38 +0200 | [diff] [blame] | 573 | // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalencodedbytestarget |
| 574 | uint64_t total_encoded_bytes_target = 0; |
Henrik Boström | 9fe1834 | 2019-05-16 18:38:20 +0200 | [diff] [blame] | 575 | uint64_t total_packet_send_delay_ms = 0; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 576 | bool has_entered_low_resolution = false; |
Danil Chapovalov | 00c7183 | 2018-06-15 15:58:38 +0200 | [diff] [blame] | 577 | absl::optional<uint64_t> qp_sum; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 578 | webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED; |
Ilya Nikolaevskiy | 70473fc | 2018-02-28 16:35:03 +0100 | [diff] [blame] | 579 | // https://w3c.github.io/webrtc-stats/#dom-rtcvideosenderstats-hugeframessent |
| 580 | uint32_t huge_frames_sent = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 581 | }; |
| 582 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 583 | struct VideoReceiverInfo : public MediaReceiverInfo { |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 584 | VideoReceiverInfo(); |
| 585 | ~VideoReceiverInfo(); |
pbos@webrtc.org | 1ed6224 | 2015-02-19 13:57:03 +0000 | [diff] [blame] | 586 | std::vector<SsrcGroup> ssrc_groups; |
Peter Boström | b7d9a97 | 2015-12-18 16:01:11 +0100 | [diff] [blame] | 587 | std::string decoder_implementation_name; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 588 | int packets_concealed = 0; |
| 589 | int firs_sent = 0; |
| 590 | int plis_sent = 0; |
| 591 | int nacks_sent = 0; |
| 592 | int frame_width = 0; |
| 593 | int frame_height = 0; |
| 594 | int framerate_rcvd = 0; |
| 595 | int framerate_decoded = 0; |
| 596 | int framerate_output = 0; |
pbos@webrtc.org | 1ed6224 | 2015-02-19 13:57:03 +0000 | [diff] [blame] | 597 | // Framerate as sent to the renderer. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 598 | int framerate_render_input = 0; |
pbos@webrtc.org | 1ed6224 | 2015-02-19 13:57:03 +0000 | [diff] [blame] | 599 | // Framerate that the renderer reports. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 600 | int framerate_render_output = 0; |
| 601 | uint32_t frames_received = 0; |
Johannes Kron | 0c141c5 | 2019-08-26 15:04:43 +0200 | [diff] [blame] | 602 | uint32_t frames_dropped = 0; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 603 | uint32_t frames_decoded = 0; |
Rasmus Brandt | 2efae77 | 2019-06-27 14:29:34 +0200 | [diff] [blame] | 604 | uint32_t key_frames_decoded = 0; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 605 | uint32_t frames_rendered = 0; |
Danil Chapovalov | 00c7183 | 2018-06-15 15:58:38 +0200 | [diff] [blame] | 606 | absl::optional<uint64_t> qp_sum; |
Johannes Kron | bfd343b | 2019-07-01 10:07:50 +0200 | [diff] [blame] | 607 | // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totaldecodetime |
| 608 | uint64_t total_decode_time_ms = 0; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 609 | int64_t interframe_delay_max_ms = -1; |
Sergey Silkin | 0237106 | 2019-01-31 16:45:42 +0100 | [diff] [blame] | 610 | uint32_t freeze_count = 0; |
| 611 | uint32_t pause_count = 0; |
| 612 | uint32_t total_freezes_duration_ms = 0; |
| 613 | uint32_t total_pauses_duration_ms = 0; |
| 614 | uint32_t total_frames_duration_ms = 0; |
| 615 | double sum_squared_frame_durations = 0.0; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 616 | |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 617 | webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED; |
ilnik | 2e1b40b | 2017-09-04 07:57:17 -0700 | [diff] [blame] | 618 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 619 | // All stats below are gathered per-VideoReceiver, but some will be correlated |
| 620 | // across MediaStreamTracks. NOTE(hta): when sinking stats into per-SSRC |
| 621 | // structures, reflect this in the new layout. |
| 622 | |
| 623 | // Current frame decode latency. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 624 | int decode_ms = 0; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 625 | // Maximum observed frame decode latency. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 626 | int max_decode_ms = 0; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 627 | // Jitter (network-related) latency. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 628 | int jitter_buffer_ms = 0; |
Guido Urdaneta | 6737841 | 2019-05-28 17:38:08 +0200 | [diff] [blame] | 629 | // Jitter (network-related) latency (cumulative). |
| 630 | // https://w3c.github.io/webrtc-stats/#dom-rtcvideoreceiverstats-jitterbufferdelay |
| 631 | double jitter_buffer_delay_seconds = 0; |
| 632 | // Number of observations for cumulative jitter latency. |
| 633 | // https://w3c.github.io/webrtc-stats/#dom-rtcvideoreceiverstats-jitterbufferemittedcount |
| 634 | uint64_t jitter_buffer_emitted_count = 0; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 635 | // Requested minimum playout latency. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 636 | int min_playout_delay_ms = 0; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 637 | // Requested latency to account for rendering delay. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 638 | int render_delay_ms = 0; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 639 | // Target overall delay: network+decode+render, accounting for |
| 640 | // min_playout_delay_ms. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 641 | int target_delay_ms = 0; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 642 | // Current overall delay, possibly ramping towards target_delay_ms. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 643 | int current_delay_ms = 0; |
buildbot@webrtc.org | 0581f0b | 2014-05-06 21:36:31 +0000 | [diff] [blame] | 644 | |
| 645 | // Estimated capture start time in NTP time in ms. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 646 | int64_t capture_start_ntp_time_ms = -1; |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 647 | |
Benjamin Wright | 514f084 | 2018-12-10 09:55:17 -0800 | [diff] [blame] | 648 | // First frame received to first frame decoded latency. |
| 649 | int64_t first_frame_received_to_decoded_ms = -1; |
| 650 | |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 651 | // Timing frame info: all important timestamps for a full lifetime of a |
| 652 | // single 'timing frame'. |
Danil Chapovalov | 00c7183 | 2018-06-15 15:58:38 +0200 | [diff] [blame] | 653 | absl::optional<webrtc::TimingFrameInfo> timing_frame_info; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 654 | }; |
| 655 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 656 | struct DataSenderInfo : public MediaSenderInfo { |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 657 | uint32_t ssrc = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 658 | }; |
| 659 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 660 | struct DataReceiverInfo : public MediaReceiverInfo { |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 661 | uint32_t ssrc = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 662 | }; |
| 663 | |
| 664 | struct BandwidthEstimationInfo { |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 665 | int available_send_bandwidth = 0; |
| 666 | int available_recv_bandwidth = 0; |
| 667 | int target_enc_bitrate = 0; |
| 668 | int actual_enc_bitrate = 0; |
| 669 | int retransmit_bitrate = 0; |
| 670 | int transmit_bitrate = 0; |
| 671 | int64_t bucket_delay = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 672 | }; |
| 673 | |
hbos | a65704b | 2016-11-14 02:28:16 -0800 | [diff] [blame] | 674 | // Maps from payload type to |RtpCodecParameters|. |
| 675 | typedef std::map<int, webrtc::RtpCodecParameters> RtpCodecParametersMap; |
| 676 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 677 | struct VoiceMediaInfo { |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 678 | VoiceMediaInfo(); |
| 679 | ~VoiceMediaInfo(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 680 | void Clear() { |
| 681 | senders.clear(); |
| 682 | receivers.clear(); |
hbos | 1acfbd2 | 2016-11-17 23:43:29 -0800 | [diff] [blame] | 683 | send_codecs.clear(); |
| 684 | receive_codecs.clear(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 685 | } |
| 686 | std::vector<VoiceSenderInfo> senders; |
| 687 | std::vector<VoiceReceiverInfo> receivers; |
hbos | 1acfbd2 | 2016-11-17 23:43:29 -0800 | [diff] [blame] | 688 | RtpCodecParametersMap send_codecs; |
| 689 | RtpCodecParametersMap receive_codecs; |
Alex Narest | bbeb109 | 2019-08-16 11:49:04 +0200 | [diff] [blame] | 690 | int32_t device_underrun_count = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 691 | }; |
| 692 | |
| 693 | struct VideoMediaInfo { |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 694 | VideoMediaInfo(); |
| 695 | ~VideoMediaInfo(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 696 | void Clear() { |
| 697 | senders.clear(); |
| 698 | receivers.clear(); |
charujain | d72098a | 2017-06-01 08:54:47 -0700 | [diff] [blame] | 699 | bw_estimations.clear(); |
hbos | a65704b | 2016-11-14 02:28:16 -0800 | [diff] [blame] | 700 | send_codecs.clear(); |
| 701 | receive_codecs.clear(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 702 | } |
| 703 | std::vector<VideoSenderInfo> senders; |
| 704 | std::vector<VideoReceiverInfo> receivers; |
stefan | f79ade1 | 2017-06-02 06:44:03 -0700 | [diff] [blame] | 705 | // Deprecated. |
| 706 | // TODO(holmer): Remove once upstream projects no longer use this. |
charujain | d72098a | 2017-06-01 08:54:47 -0700 | [diff] [blame] | 707 | std::vector<BandwidthEstimationInfo> bw_estimations; |
hbos | a65704b | 2016-11-14 02:28:16 -0800 | [diff] [blame] | 708 | RtpCodecParametersMap send_codecs; |
| 709 | RtpCodecParametersMap receive_codecs; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 710 | }; |
| 711 | |
| 712 | struct DataMediaInfo { |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 713 | DataMediaInfo(); |
| 714 | ~DataMediaInfo(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 715 | void Clear() { |
| 716 | senders.clear(); |
| 717 | receivers.clear(); |
| 718 | } |
| 719 | std::vector<DataSenderInfo> senders; |
| 720 | std::vector<DataReceiverInfo> receivers; |
| 721 | }; |
| 722 | |
deadbeef | 1387149 | 2015-12-09 12:37:51 -0800 | [diff] [blame] | 723 | struct RtcpParameters { |
| 724 | bool reduced_size = false; |
Sebastian Jansson | e1795f4 | 2019-07-24 11:38:03 +0200 | [diff] [blame] | 725 | bool remote_estimate = false; |
deadbeef | 1387149 | 2015-12-09 12:37:51 -0800 | [diff] [blame] | 726 | }; |
| 727 | |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 728 | template <class Codec> |
| 729 | struct RtpParameters { |
Steve Anton | 003930a | 2018-03-29 12:37:21 -0700 | [diff] [blame] | 730 | virtual ~RtpParameters() = default; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 731 | |
| 732 | std::vector<Codec> codecs; |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 733 | std::vector<webrtc::RtpExtension> extensions; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 734 | // TODO(pthatcher): Add streams. |
deadbeef | 1387149 | 2015-12-09 12:37:51 -0800 | [diff] [blame] | 735 | RtcpParameters rtcp; |
Steve Anton | 003930a | 2018-03-29 12:37:21 -0700 | [diff] [blame] | 736 | |
| 737 | std::string ToString() const { |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 738 | rtc::StringBuilder ost; |
Steve Anton | 003930a | 2018-03-29 12:37:21 -0700 | [diff] [blame] | 739 | ost << "{"; |
| 740 | const char* separator = ""; |
| 741 | for (const auto& entry : ToStringMap()) { |
| 742 | ost << separator << entry.first << ": " << entry.second; |
| 743 | separator = ", "; |
| 744 | } |
| 745 | ost << "}"; |
Jonas Olsson | 84df1c7 | 2018-09-14 16:59:32 +0200 | [diff] [blame] | 746 | return ost.Release(); |
Steve Anton | 003930a | 2018-03-29 12:37:21 -0700 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | protected: |
| 750 | virtual std::map<std::string, std::string> ToStringMap() const { |
| 751 | return {{"codecs", VectorToString(codecs)}, |
| 752 | {"extensions", VectorToString(extensions)}}; |
| 753 | } |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 754 | }; |
| 755 | |
Taylor Brandstetter | 5f0b83b | 2016-03-18 15:02:07 -0700 | [diff] [blame] | 756 | // TODO(deadbeef): Rename to RtpSenderParameters, since they're intended to |
| 757 | // encapsulate all the parameters needed for an RtpSender. |
nisse | 0510331 | 2016-03-16 02:22:50 -0700 | [diff] [blame] | 758 | template <class Codec> |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 759 | struct RtpSendParameters : RtpParameters<Codec> { |
nisse | 0510331 | 2016-03-16 02:22:50 -0700 | [diff] [blame] | 760 | int max_bandwidth_bps = -1; |
Steve Anton | bb50ce5 | 2018-03-26 10:24:32 -0700 | [diff] [blame] | 761 | // This is the value to be sent in the MID RTP header extension (if the header |
| 762 | // extension in included in the list of extensions). |
| 763 | std::string mid; |
Johannes Kron | 9190b82 | 2018-10-29 11:22:05 +0100 | [diff] [blame] | 764 | bool extmap_allow_mixed = false; |
Steve Anton | 003930a | 2018-03-29 12:37:21 -0700 | [diff] [blame] | 765 | |
| 766 | protected: |
| 767 | std::map<std::string, std::string> ToStringMap() const override { |
| 768 | auto params = RtpParameters<Codec>::ToStringMap(); |
| 769 | params["max_bandwidth_bps"] = rtc::ToString(max_bandwidth_bps); |
| 770 | params["mid"] = (mid.empty() ? "<not set>" : mid); |
Johannes Kron | 9190b82 | 2018-10-29 11:22:05 +0100 | [diff] [blame] | 771 | params["extmap-allow-mixed"] = extmap_allow_mixed ? "true" : "false"; |
Steve Anton | 003930a | 2018-03-29 12:37:21 -0700 | [diff] [blame] | 772 | return params; |
| 773 | } |
nisse | 0510331 | 2016-03-16 02:22:50 -0700 | [diff] [blame] | 774 | }; |
| 775 | |
| 776 | struct AudioSendParameters : RtpSendParameters<AudioCodec> { |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 777 | AudioSendParameters(); |
| 778 | ~AudioSendParameters() override; |
nisse | 0510331 | 2016-03-16 02:22:50 -0700 | [diff] [blame] | 779 | AudioOptions options; |
Steve Anton | 003930a | 2018-03-29 12:37:21 -0700 | [diff] [blame] | 780 | |
| 781 | protected: |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 782 | std::map<std::string, std::string> ToStringMap() const override; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 783 | }; |
| 784 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 785 | struct AudioRecvParameters : RtpParameters<AudioCodec> {}; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 786 | |
Ruslan Burakov | 493a650 | 2019-02-27 15:32:48 +0100 | [diff] [blame] | 787 | class VoiceMediaChannel : public MediaChannel, public Delayable { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 788 | public: |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 789 | VoiceMediaChannel() {} |
terelius | 54f9171 | 2016-06-01 11:18:56 -0700 | [diff] [blame] | 790 | explicit VoiceMediaChannel(const MediaConfig& config) |
| 791 | : MediaChannel(config) {} |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 792 | ~VoiceMediaChannel() override {} |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 793 | |
| 794 | cricket::MediaType media_type() const override; |
Fredrik Solenberg | b071a19 | 2015-09-17 16:42:56 +0200 | [diff] [blame] | 795 | virtual bool SetSendParameters(const AudioSendParameters& params) = 0; |
| 796 | virtual bool SetRecvParameters(const AudioRecvParameters& params) = 0; |
deadbeef | 3bc1510 | 2017-04-20 19:25:07 -0700 | [diff] [blame] | 797 | // Get the receive parameters for the incoming stream identified by |ssrc|. |
| 798 | // If |ssrc| is 0, retrieve the receive parameters for the default receive |
| 799 | // stream, which is used when SSRCs are not signaled. Note that calling with |
| 800 | // an |ssrc| of 0 will return encoding parameters with an unset |ssrc| |
| 801 | // member. |
Taylor Brandstetter | db0cd9e | 2016-05-16 11:40:30 -0700 | [diff] [blame] | 802 | virtual webrtc::RtpParameters GetRtpReceiveParameters( |
| 803 | uint32_t ssrc) const = 0; |
| 804 | virtual bool SetRtpReceiveParameters( |
| 805 | uint32_t ssrc, |
| 806 | const webrtc::RtpParameters& parameters) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 807 | // Starts or stops playout of received audio. |
aleloi | 84ef615 | 2016-08-04 05:28:21 -0700 | [diff] [blame] | 808 | virtual void SetPlayout(bool playout) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 809 | // Starts or stops sending (and potentially capture) of local audio. |
Taylor Brandstetter | 1a018dc | 2016-03-08 12:37:39 -0800 | [diff] [blame] | 810 | virtual void SetSend(bool send) = 0; |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 811 | // Configure stream for sending. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 812 | virtual bool SetAudioSend(uint32_t ssrc, |
| 813 | bool enable, |
solenberg | dfc8f4f | 2015-10-01 02:31:10 -0700 | [diff] [blame] | 814 | const AudioOptions* options, |
Taylor Brandstetter | 1a018dc | 2016-03-08 12:37:39 -0800 | [diff] [blame] | 815 | AudioSource* source) = 0; |
solenberg | 4bac9c5 | 2015-10-09 02:32:53 -0700 | [diff] [blame] | 816 | // Set speaker output volume of the specified ssrc. |
| 817 | virtual bool SetOutputVolume(uint32_t ssrc, double volume) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 818 | // Returns if the telephone-event has been negotiated. |
solenberg | 1d63dd0 | 2015-12-02 12:35:09 -0800 | [diff] [blame] | 819 | virtual bool CanInsertDtmf() = 0; |
| 820 | // Send a DTMF |event|. The DTMF out-of-band signal will be used. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 821 | // The |ssrc| should be either 0 or a valid send stream ssrc. |
henrike@webrtc.org | 9de257d | 2013-07-17 14:42:53 +0000 | [diff] [blame] | 822 | // The valid value for the |event| are 0 to 15 which corresponding to |
| 823 | // DTMF event 0-9, *, #, A-D. |
solenberg | 1d63dd0 | 2015-12-02 12:35:09 -0800 | [diff] [blame] | 824 | virtual bool InsertDtmf(uint32_t ssrc, int event, int duration) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 825 | // Gets quality stats for the channel. |
| 826 | virtual bool GetStats(VoiceMediaInfo* info) = 0; |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 827 | |
| 828 | virtual void SetRawAudioSink( |
| 829 | uint32_t ssrc, |
kwiberg | 686a8ef | 2016-02-26 03:00:35 -0800 | [diff] [blame] | 830 | std::unique_ptr<webrtc::AudioSinkInterface> sink) = 0; |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 831 | |
| 832 | virtual std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 833 | }; |
| 834 | |
Taylor Brandstetter | 5f0b83b | 2016-03-18 15:02:07 -0700 | [diff] [blame] | 835 | // TODO(deadbeef): Rename to VideoSenderParameters, since they're intended to |
| 836 | // encapsulate all the parameters needed for a video RtpSender. |
nisse | 0510331 | 2016-03-16 02:22:50 -0700 | [diff] [blame] | 837 | struct VideoSendParameters : RtpSendParameters<VideoCodec> { |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 838 | VideoSendParameters(); |
| 839 | ~VideoSendParameters() override; |
nisse | 4b4dc86 | 2016-02-17 05:25:36 -0800 | [diff] [blame] | 840 | // Use conference mode? This flag comes from the remote |
| 841 | // description's SDP line 'a=x-google-flag:conference', copied over |
| 842 | // by VideoChannel::SetRemoteContent_w, and ultimately used by |
| 843 | // conference mode screencast logic in |
eladalon | f184138 | 2017-06-12 01:16:46 -0700 | [diff] [blame] | 844 | // WebRtcVideoChannel::WebRtcVideoSendStream::CreateVideoEncoderConfig. |
nisse | 4b4dc86 | 2016-02-17 05:25:36 -0800 | [diff] [blame] | 845 | // The special screencast behaviour is disabled by default. |
| 846 | bool conference_mode = false; |
Steve Anton | 003930a | 2018-03-29 12:37:21 -0700 | [diff] [blame] | 847 | |
| 848 | protected: |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 849 | std::map<std::string, std::string> ToStringMap() const override; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 850 | }; |
| 851 | |
Taylor Brandstetter | 5f0b83b | 2016-03-18 15:02:07 -0700 | [diff] [blame] | 852 | // TODO(deadbeef): Rename to VideoReceiverParameters, since they're intended to |
| 853 | // encapsulate all the parameters needed for a video RtpReceiver. |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 854 | struct VideoRecvParameters : RtpParameters<VideoCodec> {}; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 855 | |
Ruslan Burakov | 493a650 | 2019-02-27 15:32:48 +0100 | [diff] [blame] | 856 | class VideoMediaChannel : public MediaChannel, public Delayable { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 857 | public: |
nisse | 08582ff | 2016-02-04 01:24:52 -0800 | [diff] [blame] | 858 | VideoMediaChannel() {} |
terelius | 54f9171 | 2016-06-01 11:18:56 -0700 | [diff] [blame] | 859 | explicit VideoMediaChannel(const MediaConfig& config) |
| 860 | : MediaChannel(config) {} |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 861 | ~VideoMediaChannel() override {} |
Fredrik Solenberg | b071a19 | 2015-09-17 16:42:56 +0200 | [diff] [blame] | 862 | |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 863 | cricket::MediaType media_type() const override; |
Fredrik Solenberg | b071a19 | 2015-09-17 16:42:56 +0200 | [diff] [blame] | 864 | virtual bool SetSendParameters(const VideoSendParameters& params) = 0; |
| 865 | virtual bool SetRecvParameters(const VideoRecvParameters& params) = 0; |
deadbeef | 3bc1510 | 2017-04-20 19:25:07 -0700 | [diff] [blame] | 866 | // Get the receive parameters for the incoming stream identified by |ssrc|. |
| 867 | // If |ssrc| is 0, retrieve the receive parameters for the default receive |
| 868 | // stream, which is used when SSRCs are not signaled. Note that calling with |
| 869 | // an |ssrc| of 0 will return encoding parameters with an unset |ssrc| |
| 870 | // member. |
Taylor Brandstetter | db0cd9e | 2016-05-16 11:40:30 -0700 | [diff] [blame] | 871 | virtual webrtc::RtpParameters GetRtpReceiveParameters( |
| 872 | uint32_t ssrc) const = 0; |
| 873 | virtual bool SetRtpReceiveParameters( |
| 874 | uint32_t ssrc, |
| 875 | const webrtc::RtpParameters& parameters) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 876 | // Gets the currently set codecs/payload types to be used for outgoing media. |
| 877 | virtual bool GetSendCodec(VideoCodec* send_codec) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 878 | // Starts or stops transmission (and potentially capture) of local video. |
| 879 | virtual bool SetSend(bool send) = 0; |
deadbeef | 5a4a75a | 2016-06-02 16:23:38 -0700 | [diff] [blame] | 880 | // Configure stream for sending and register a source. |
| 881 | // The |ssrc| must correspond to a registered send stream. |
| 882 | virtual bool SetVideoSend( |
| 883 | uint32_t ssrc, |
deadbeef | 5a4a75a | 2016-06-02 16:23:38 -0700 | [diff] [blame] | 884 | const VideoOptions* options, |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 885 | rtc::VideoSourceInterface<webrtc::VideoFrame>* source) = 0; |
nisse | 08582ff | 2016-02-04 01:24:52 -0800 | [diff] [blame] | 886 | // Sets the sink object to be used for the specified stream. |
deadbeef | 3bc1510 | 2017-04-20 19:25:07 -0700 | [diff] [blame] | 887 | // If SSRC is 0, the sink is used for the 'default' stream. |
nisse | 08582ff | 2016-02-04 01:24:52 -0800 | [diff] [blame] | 888 | virtual bool SetSink(uint32_t ssrc, |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 889 | rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) = 0; |
stefan | f79ade1 | 2017-06-02 06:44:03 -0700 | [diff] [blame] | 890 | // This fills the "bitrate parts" (rtx, video bitrate) of the |
| 891 | // BandwidthEstimationInfo, since that part that isn't possible to get |
| 892 | // through webrtc::Call::GetStats, as they are statistics of the send |
| 893 | // streams. |
| 894 | // TODO(holmer): We should change this so that either BWE graphs doesn't |
| 895 | // need access to bitrates of the streams, or change the (RTC)StatsCollector |
| 896 | // so that it's getting the send stream stats separately by calling |
| 897 | // GetStats(), and merges with BandwidthEstimationInfo by itself. |
| 898 | virtual void FillBitrateInfo(BandwidthEstimationInfo* bwe_info) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 899 | // Gets quality stats for the channel. |
pbos@webrtc.org | 058b1f1 | 2015-03-04 08:54:32 +0000 | [diff] [blame] | 900 | virtual bool GetStats(VideoMediaInfo* info) = 0; |
Jonas Oreland | 49ac595 | 2018-09-26 16:04:32 +0200 | [diff] [blame] | 901 | |
| 902 | virtual std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 903 | }; |
| 904 | |
| 905 | enum DataMessageType { |
mallinath@webrtc.org | 1112c30 | 2013-09-23 20:34:45 +0000 | [diff] [blame] | 906 | // Chrome-Internal use only. See SctpDataMediaChannel for the actual PPID |
| 907 | // values. |
| 908 | DMT_NONE = 0, |
| 909 | DMT_CONTROL = 1, |
| 910 | DMT_BINARY = 2, |
| 911 | DMT_TEXT = 3, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 912 | }; |
| 913 | |
| 914 | // Info about data received in DataMediaChannel. For use in |
| 915 | // DataMediaChannel::SignalDataReceived and in all of the signals that |
| 916 | // signal fires, on up the chain. |
| 917 | struct ReceiveDataParams { |
| 918 | // The in-packet stream indentifier. |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 919 | // RTP data channels use SSRCs, SCTP data channels use SIDs. |
| 920 | union { |
| 921 | uint32_t ssrc; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 922 | int sid = 0; |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 923 | }; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 924 | // The type of message (binary, text, or control). |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 925 | DataMessageType type = DMT_TEXT; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 926 | // A per-stream value incremented per packet in the stream. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 927 | int seq_num = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 928 | // A per-stream value monotonically increasing with time. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 929 | int timestamp = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 930 | }; |
| 931 | |
| 932 | struct SendDataParams { |
| 933 | // The in-packet stream indentifier. |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 934 | // RTP data channels use SSRCs, SCTP data channels use SIDs. |
| 935 | union { |
| 936 | uint32_t ssrc; |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 937 | int sid = 0; |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 938 | }; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 939 | // The type of message (binary, text, or control). |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 940 | DataMessageType type = DMT_TEXT; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 941 | |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 942 | // TODO(pthatcher): Make |ordered| and |reliable| true by default? |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 943 | // For SCTP, whether to send messages flagged as ordered or not. |
| 944 | // If false, messages can be received out of order. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 945 | bool ordered = false; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 946 | // For SCTP, whether the messages are sent reliably or not. |
| 947 | // If false, messages may be lost. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 948 | bool reliable = false; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 949 | // For SCTP, if reliable == false, provide partial reliability by |
| 950 | // resending up to this many times. Either count or millis |
| 951 | // is supported, not both at the same time. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 952 | int max_rtx_count = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 953 | // For SCTP, if reliable == false, provide partial reliability by |
| 954 | // resending for up to this many milliseconds. Either count or millis |
| 955 | // is supported, not both at the same time. |
Steve Anton | 002f921 | 2018-01-09 16:38:15 -0800 | [diff] [blame] | 956 | int max_rtx_ms = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 957 | }; |
| 958 | |
| 959 | enum SendDataResult { SDR_SUCCESS, SDR_ERROR, SDR_BLOCK }; |
| 960 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 961 | struct DataSendParameters : RtpSendParameters<DataCodec> {}; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 962 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 963 | struct DataRecvParameters : RtpParameters<DataCodec> {}; |
Peter Thatcher | c2ee2c8 | 2015-08-07 16:05:34 -0700 | [diff] [blame] | 964 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 965 | class DataMediaChannel : public MediaChannel { |
| 966 | public: |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 967 | DataMediaChannel(); |
| 968 | explicit DataMediaChannel(const MediaConfig& config); |
| 969 | ~DataMediaChannel() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 970 | |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 971 | cricket::MediaType media_type() const override; |
Fredrik Solenberg | b071a19 | 2015-09-17 16:42:56 +0200 | [diff] [blame] | 972 | virtual bool SetSendParameters(const DataSendParameters& params) = 0; |
| 973 | virtual bool SetRecvParameters(const DataRecvParameters& params) = 0; |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 974 | |
Amit Hilbuch | ea7ef2a | 2019-02-19 15:20:21 -0800 | [diff] [blame] | 975 | // RtpParameter methods are not supported for Data channel. |
| 976 | webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override; |
| 977 | webrtc::RTCError SetRtpSendParameters( |
| 978 | uint32_t ssrc, |
| 979 | const webrtc::RtpParameters& parameters) override; |
| 980 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 981 | // TODO(pthatcher): Implement this. |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 982 | virtual bool GetStats(DataMediaInfo* info); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 983 | |
| 984 | virtual bool SetSend(bool send) = 0; |
| 985 | virtual bool SetReceive(bool receive) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 986 | |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 987 | void OnNetworkRouteChanged(const std::string& transport_name, |
| 988 | const rtc::NetworkRoute& network_route) override {} |
Honghai Zhang | cc411c0 | 2016-03-29 17:27:21 -0700 | [diff] [blame] | 989 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 990 | virtual bool SendData(const SendDataParams& params, |
| 991 | const rtc::CopyOnWriteBuffer& payload, |
| 992 | SendDataResult* result = NULL) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 993 | // Signals when data is received (params, data, len) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 994 | sigslot::signal3<const ReceiveDataParams&, const char*, size_t> |
| 995 | SignalDataReceived; |
wu@webrtc.org | d64719d | 2013-08-01 00:00:07 +0000 | [diff] [blame] | 996 | // Signal when the media channel is ready to send the stream. Arguments are: |
| 997 | // writable(bool) |
| 998 | sigslot::signal1<bool> SignalReadyToSend; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 999 | }; |
| 1000 | |
| 1001 | } // namespace cricket |
| 1002 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 1003 | #endif // MEDIA_BASE_MEDIA_CHANNEL_H_ |