niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
phoglund@webrtc.org | 8bfee84 | 2012-02-17 09:32:48 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef COMMON_TYPES_H_ |
| 12 | #define COMMON_TYPES_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
pbos@webrtc.org | f577ae9 | 2014-03-19 08:43:57 +0000 | [diff] [blame] | 14 | #include <stddef.h> |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 15 | #include <string.h> |
kwiberg | 5bf4e08 | 2016-12-19 06:04:04 -0800 | [diff] [blame] | 16 | #include <ostream> |
pbos@webrtc.org | 1e92b0a | 2014-05-15 09:35:06 +0000 | [diff] [blame] | 17 | #include <string> |
pbos@webrtc.org | f577ae9 | 2014-03-19 08:43:57 +0000 | [diff] [blame] | 18 | #include <vector> |
| 19 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "api/array_view.h" |
| 21 | #include "api/optional.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 22 | #include "rtc_base/checks.h" |
| 23 | #include "rtc_base/deprecation.h" |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 24 | #include "typedefs.h" // NOLINT(build/include) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 26 | #if defined(_MSC_VER) |
| 27 | // Disable "new behavior: elements of array will be default initialized" |
| 28 | // warning. Affects OverUseDetectorOptions. |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 29 | #pragma warning(disable : 4351) |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 30 | #endif |
| 31 | |
kwiberg | 77eab70 | 2016-09-28 17:42:01 -0700 | [diff] [blame] | 32 | #if defined(WEBRTC_EXPORT) |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 33 | #define WEBRTC_DLLEXPORT _declspec(dllexport) |
kwiberg | 77eab70 | 2016-09-28 17:42:01 -0700 | [diff] [blame] | 34 | #elif defined(WEBRTC_DLL) |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 35 | #define WEBRTC_DLLEXPORT _declspec(dllimport) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | #else |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 37 | #define WEBRTC_DLLEXPORT |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | #endif |
| 39 | |
| 40 | #ifndef NULL |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 41 | #define NULL 0 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | #endif |
| 43 | |
Peter Boström | 8b79b07 | 2016-02-26 16:31:37 +0100 | [diff] [blame] | 44 | #define RTP_PAYLOAD_NAME_SIZE 32u |
henrika@webrtc.org | f75901f | 2012-01-16 08:45:42 +0000 | [diff] [blame] | 45 | |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 46 | #if defined(WEBRTC_WIN) || defined(WIN32) |
andrew@webrtc.org | eda189b | 2013-09-09 17:50:10 +0000 | [diff] [blame] | 47 | // Compares two strings without regard to case. |
| 48 | #define STR_CASE_CMP(s1, s2) ::_stricmp(s1, s2) |
| 49 | // Compares characters of two strings without regard to case. |
| 50 | #define STR_NCASE_CMP(s1, s2, n) ::_strnicmp(s1, s2, n) |
| 51 | #else |
| 52 | #define STR_CASE_CMP(s1, s2) ::strcasecmp(s1, s2) |
| 53 | #define STR_NCASE_CMP(s1, s2, n) ::strncasecmp(s1, s2, n) |
| 54 | #endif |
| 55 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | namespace webrtc { |
| 57 | |
tommi | a6219cc | 2016-06-15 10:30:14 -0700 | [diff] [blame] | 58 | class RewindableStream { |
| 59 | public: |
| 60 | virtual ~RewindableStream() {} |
| 61 | virtual int Rewind() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
tommi | a6219cc | 2016-06-15 10:30:14 -0700 | [diff] [blame] | 64 | class InStream : public RewindableStream { |
| 65 | public: |
| 66 | // Reads |len| bytes from file to |buf|. Returns the number of bytes read |
| 67 | // or -1 on error. |
| 68 | virtual int Read(void* buf, size_t len) = 0; |
| 69 | }; |
| 70 | |
| 71 | class OutStream : public RewindableStream { |
| 72 | public: |
| 73 | // Writes |len| bytes from |buf| to file. The actual writing may happen |
| 74 | // some time later. Call Flush() to force a write. |
| 75 | virtual bool Write(const void* buf, size_t len) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
Niels Möller | 4f6b6c2 | 2017-12-01 11:17:32 +0100 | [diff] [blame] | 78 | // For the deprecated MediaFile module. |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 79 | enum FileFormats { |
| 80 | kFileFormatWavFile = 1, |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 81 | kFileFormatPcm16kHzFile = 7, |
| 82 | kFileFormatPcm8kHzFile = 8, |
Minyue Li | 85a3b6b | 2017-09-01 14:36:33 +0200 | [diff] [blame] | 83 | kFileFormatPcm32kHzFile = 9, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
pbos | 22993e1 | 2015-10-19 02:39:06 -0700 | [diff] [blame] | 86 | enum FrameType { |
| 87 | kEmptyFrame = 0, |
| 88 | kAudioFrameSpeech = 1, |
| 89 | kAudioFrameCN = 2, |
| 90 | kVideoFrameKey = 3, |
| 91 | kVideoFrameDelta = 4, |
sprang@webrtc.org | 71f055f | 2013-12-04 15:09:27 +0000 | [diff] [blame] | 92 | }; |
| 93 | |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 94 | // Statistics for an RTCP channel |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 95 | struct RtcpStatistics { |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 96 | RtcpStatistics() |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 97 | : fraction_lost(0), |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 98 | packets_lost(0), |
| 99 | extended_highest_sequence_number(0), |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 100 | jitter(0) {} |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 101 | |
| 102 | uint8_t fraction_lost; |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 103 | union { |
Harald Alvestrand | c7c4191 | 2017-12-08 09:59:34 +0100 | [diff] [blame] | 104 | int32_t packets_lost; // Defined as a 24 bit signed integer in RTCP |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 105 | RTC_DEPRECATED uint32_t cumulative_lost; |
| 106 | }; |
| 107 | union { |
| 108 | uint32_t extended_highest_sequence_number; |
| 109 | RTC_DEPRECATED uint32_t extended_max_sequence_number; |
| 110 | }; |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 111 | uint32_t jitter; |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 112 | }; |
| 113 | |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 114 | class RtcpStatisticsCallback { |
| 115 | public: |
| 116 | virtual ~RtcpStatisticsCallback() {} |
| 117 | |
| 118 | virtual void StatisticsUpdated(const RtcpStatistics& statistics, |
| 119 | uint32_t ssrc) = 0; |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 120 | virtual void CNameChanged(const char* cname, uint32_t ssrc) = 0; |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 121 | }; |
| 122 | |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 123 | // Statistics for RTCP packet types. |
| 124 | struct RtcpPacketTypeCounter { |
| 125 | RtcpPacketTypeCounter() |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 126 | : first_packet_time_ms(-1), |
| 127 | nack_packets(0), |
| 128 | fir_packets(0), |
| 129 | pli_packets(0), |
| 130 | nack_requests(0), |
| 131 | unique_nack_requests(0) {} |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 132 | |
| 133 | void Add(const RtcpPacketTypeCounter& other) { |
| 134 | nack_packets += other.nack_packets; |
| 135 | fir_packets += other.fir_packets; |
| 136 | pli_packets += other.pli_packets; |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 137 | nack_requests += other.nack_requests; |
| 138 | unique_nack_requests += other.unique_nack_requests; |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 139 | if (other.first_packet_time_ms != -1 && |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 140 | (other.first_packet_time_ms < first_packet_time_ms || |
| 141 | first_packet_time_ms == -1)) { |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 142 | // Use oldest time. |
| 143 | first_packet_time_ms = other.first_packet_time_ms; |
| 144 | } |
| 145 | } |
| 146 | |
sprang | 07fb9be | 2016-02-24 07:55:00 -0800 | [diff] [blame] | 147 | void Subtract(const RtcpPacketTypeCounter& other) { |
| 148 | nack_packets -= other.nack_packets; |
| 149 | fir_packets -= other.fir_packets; |
| 150 | pli_packets -= other.pli_packets; |
| 151 | nack_requests -= other.nack_requests; |
| 152 | unique_nack_requests -= other.unique_nack_requests; |
| 153 | if (other.first_packet_time_ms != -1 && |
| 154 | (other.first_packet_time_ms > first_packet_time_ms || |
| 155 | first_packet_time_ms == -1)) { |
| 156 | // Use youngest time. |
| 157 | first_packet_time_ms = other.first_packet_time_ms; |
| 158 | } |
| 159 | } |
| 160 | |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 161 | int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const { |
| 162 | return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms); |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 163 | } |
| 164 | |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 165 | int UniqueNackRequestsInPercent() const { |
| 166 | if (nack_requests == 0) { |
| 167 | return 0; |
| 168 | } |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 169 | return static_cast<int>((unique_nack_requests * 100.0f / nack_requests) + |
| 170 | 0.5f); |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 171 | } |
| 172 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 173 | int64_t first_packet_time_ms; // Time when first packet is sent/received. |
| 174 | uint32_t nack_packets; // Number of RTCP NACK packets. |
| 175 | uint32_t fir_packets; // Number of RTCP FIR packets. |
| 176 | uint32_t pli_packets; // Number of RTCP PLI packets. |
| 177 | uint32_t nack_requests; // Number of NACKed RTP packets. |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 178 | uint32_t unique_nack_requests; // Number of unique NACKed RTP packets. |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 179 | }; |
| 180 | |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 181 | class RtcpPacketTypeCounterObserver { |
| 182 | public: |
| 183 | virtual ~RtcpPacketTypeCounterObserver() {} |
| 184 | virtual void RtcpPacketTypesCounterUpdated( |
| 185 | uint32_t ssrc, |
| 186 | const RtcpPacketTypeCounter& packet_counter) = 0; |
| 187 | }; |
| 188 | |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 189 | // Rate statistics for a stream. |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 190 | struct BitrateStatistics { |
sprang | cd349d9 | 2016-07-13 09:11:28 -0700 | [diff] [blame] | 191 | BitrateStatistics() : bitrate_bps(0), packet_rate(0) {} |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 192 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 193 | uint32_t bitrate_bps; // Bitrate in bits per second. |
| 194 | uint32_t packet_rate; // Packet rate in packets per second. |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 195 | }; |
| 196 | |
| 197 | // Callback, used to notify an observer whenever new rates have been estimated. |
| 198 | class BitrateStatisticsObserver { |
| 199 | public: |
| 200 | virtual ~BitrateStatisticsObserver() {} |
| 201 | |
sprang | cd349d9 | 2016-07-13 09:11:28 -0700 | [diff] [blame] | 202 | virtual void Notify(uint32_t total_bitrate_bps, |
| 203 | uint32_t retransmit_bitrate_bps, |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame] | 204 | uint32_t ssrc) = 0; |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 205 | }; |
| 206 | |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 207 | struct FrameCounts { |
| 208 | FrameCounts() : key_frames(0), delta_frames(0) {} |
| 209 | int key_frames; |
| 210 | int delta_frames; |
| 211 | }; |
| 212 | |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 213 | // Callback, used to notify an observer whenever frame counts have been updated. |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 214 | class FrameCountObserver { |
| 215 | public: |
sprang@webrtc.org | 72964bd | 2013-11-21 09:09:54 +0000 | [diff] [blame] | 216 | virtual ~FrameCountObserver() {} |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 217 | virtual void FrameCountUpdated(const FrameCounts& frame_counts, |
| 218 | uint32_t ssrc) = 0; |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 219 | }; |
| 220 | |
stefan@webrtc.org | 168f23f | 2014-07-11 13:44:02 +0000 | [diff] [blame] | 221 | // Callback, used to notify an observer whenever the send-side delay is updated. |
| 222 | class SendSideDelayObserver { |
| 223 | public: |
| 224 | virtual ~SendSideDelayObserver() {} |
| 225 | virtual void SendSideDelayUpdated(int avg_delay_ms, |
| 226 | int max_delay_ms, |
| 227 | uint32_t ssrc) = 0; |
| 228 | }; |
| 229 | |
asapersson | 35151f3 | 2016-05-02 23:44:01 -0700 | [diff] [blame] | 230 | // Callback, used to notify an observer whenever a packet is sent to the |
| 231 | // transport. |
| 232 | // TODO(asapersson): This class will remove the need for SendSideDelayObserver. |
| 233 | // Remove SendSideDelayObserver once possible. |
| 234 | class SendPacketObserver { |
| 235 | public: |
| 236 | virtual ~SendPacketObserver() {} |
| 237 | virtual void OnSendPacket(uint16_t packet_id, |
| 238 | int64_t capture_time_ms, |
| 239 | uint32_t ssrc) = 0; |
| 240 | }; |
| 241 | |
michaelt | 4da3044 | 2016-11-17 01:38:43 -0800 | [diff] [blame] | 242 | // Callback, used to notify an observer when the overhead per packet |
| 243 | // has changed. |
| 244 | class OverheadObserver { |
| 245 | public: |
| 246 | virtual ~OverheadObserver() = default; |
| 247 | virtual void OnOverheadChanged(size_t overhead_bytes_per_packet) = 0; |
| 248 | }; |
| 249 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 250 | // ================================================================== |
| 251 | // Voice specific types |
| 252 | // ================================================================== |
| 253 | |
| 254 | // Each codec supported can be described by this structure. |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 255 | struct CodecInst { |
| 256 | int pltype; |
| 257 | char plname[RTP_PAYLOAD_NAME_SIZE]; |
| 258 | int plfreq; |
| 259 | int pacsize; |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 260 | size_t channels; |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 261 | int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file! |
| 262 | |
| 263 | bool operator==(const CodecInst& other) const { |
| 264 | return pltype == other.pltype && |
| 265 | (STR_CASE_CMP(plname, other.plname) == 0) && |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 266 | plfreq == other.plfreq && pacsize == other.pacsize && |
| 267 | channels == other.channels && rate == other.rate; |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 268 | } |
| 269 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 270 | bool operator!=(const CodecInst& other) const { return !(*this == other); } |
kwiberg | 5bf4e08 | 2016-12-19 06:04:04 -0800 | [diff] [blame] | 271 | |
| 272 | friend std::ostream& operator<<(std::ostream& os, const CodecInst& ci) { |
| 273 | os << "{pltype: " << ci.pltype; |
| 274 | os << ", plname: " << ci.plname; |
| 275 | os << ", plfreq: " << ci.plfreq; |
| 276 | os << ", pacsize: " << ci.pacsize; |
| 277 | os << ", channels: " << ci.channels; |
| 278 | os << ", rate: " << ci.rate << "}"; |
| 279 | return os; |
| 280 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 281 | }; |
| 282 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 283 | // RTP |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 284 | enum { kRtpCsrcSize = 15 }; // RFC 3550 page 13 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 285 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 286 | enum PayloadFrequencies { |
| 287 | kFreq8000Hz = 8000, |
| 288 | kFreq16000Hz = 16000, |
| 289 | kFreq32000Hz = 32000 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 290 | }; |
| 291 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 292 | // Degree of bandwidth reduction. |
| 293 | enum VadModes { |
| 294 | kVadConventional = 0, // lowest reduction |
| 295 | kVadAggressiveLow, |
| 296 | kVadAggressiveMid, |
| 297 | kVadAggressiveHigh // highest reduction |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 298 | }; |
| 299 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 300 | // NETEQ statistics. |
| 301 | struct NetworkStatistics { |
| 302 | // current jitter buffer size in ms |
| 303 | uint16_t currentBufferSize; |
| 304 | // preferred (optimal) buffer size in ms |
| 305 | uint16_t preferredBufferSize; |
| 306 | // adding extra delay due to "peaky jitter" |
| 307 | bool jitterPeaksFound; |
Gustaf Ullberg | b0a0207 | 2017-10-02 12:00:34 +0200 | [diff] [blame] | 308 | // Stats below correspond to similarly-named fields in the WebRTC stats spec. |
| 309 | // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats |
Steve Anton | 2dbc69f | 2017-08-24 17:15:13 -0700 | [diff] [blame] | 310 | uint64_t totalSamplesReceived; |
Steve Anton | 2dbc69f | 2017-08-24 17:15:13 -0700 | [diff] [blame] | 311 | uint64_t concealedSamples; |
Gustaf Ullberg | 9a2e906 | 2017-09-18 09:28:20 +0200 | [diff] [blame] | 312 | uint64_t concealmentEvents; |
Gustaf Ullberg | b0a0207 | 2017-10-02 12:00:34 +0200 | [diff] [blame] | 313 | uint64_t jitterBufferDelayMs; |
| 314 | // Stats below DO NOT correspond directly to anything in the WebRTC stats |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 315 | // Loss rate (network + late); fraction between 0 and 1, scaled to Q14. |
| 316 | uint16_t currentPacketLossRate; |
| 317 | // Late loss rate; fraction between 0 and 1, scaled to Q14. |
minyue-webrtc | 0c3ca75 | 2017-08-23 15:59:38 +0200 | [diff] [blame] | 318 | union { |
| 319 | RTC_DEPRECATED uint16_t currentDiscardRate; |
| 320 | }; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 321 | // fraction (of original stream) of synthesized audio inserted through |
| 322 | // expansion (in Q14) |
| 323 | uint16_t currentExpandRate; |
| 324 | // fraction (of original stream) of synthesized speech inserted through |
| 325 | // expansion (in Q14) |
| 326 | uint16_t currentSpeechExpandRate; |
| 327 | // fraction of synthesized speech inserted through pre-emptive expansion |
| 328 | // (in Q14) |
| 329 | uint16_t currentPreemptiveRate; |
| 330 | // fraction of data removed through acceleration (in Q14) |
| 331 | uint16_t currentAccelerateRate; |
| 332 | // fraction of data coming from secondary decoding (in Q14) |
| 333 | uint16_t currentSecondaryDecodedRate; |
minyue-webrtc | 0e320ec | 2017-08-28 13:51:27 +0200 | [diff] [blame] | 334 | // Fraction of secondary data, including FEC and RED, that is discarded (in |
| 335 | // Q14). Discarding of secondary data can be caused by the reception of the |
| 336 | // primary data, obsoleting the secondary data. It can also be caused by early |
| 337 | // or late arrival of secondary data. |
minyue-webrtc | 0c3ca75 | 2017-08-23 15:59:38 +0200 | [diff] [blame] | 338 | uint16_t currentSecondaryDiscardedRate; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 339 | // clock-drift in parts-per-million (negative or positive) |
| 340 | int32_t clockDriftPPM; |
| 341 | // average packet waiting time in the jitter buffer (ms) |
| 342 | int meanWaitingTimeMs; |
| 343 | // median packet waiting time in the jitter buffer (ms) |
| 344 | int medianWaitingTimeMs; |
| 345 | // min packet waiting time in the jitter buffer (ms) |
| 346 | int minWaitingTimeMs; |
| 347 | // max packet waiting time in the jitter buffer (ms) |
| 348 | int maxWaitingTimeMs; |
| 349 | // added samples in off mode due to packet loss |
| 350 | size_t addedSamples; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 351 | }; |
| 352 | |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 353 | // Statistics for calls to AudioCodingModule::PlayoutData10Ms(). |
| 354 | struct AudioDecodingCallStats { |
| 355 | AudioDecodingCallStats() |
| 356 | : calls_to_silence_generator(0), |
| 357 | calls_to_neteq(0), |
| 358 | decoded_normal(0), |
| 359 | decoded_plc(0), |
| 360 | decoded_cng(0), |
henrik.lundin | 6348978 | 2016-09-20 01:47:12 -0700 | [diff] [blame] | 361 | decoded_plc_cng(0), |
| 362 | decoded_muted_output(0) {} |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 363 | |
| 364 | int calls_to_silence_generator; // Number of calls where silence generated, |
| 365 | // and NetEq was disengaged from decoding. |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 366 | int calls_to_neteq; // Number of calls to NetEq. |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 367 | int decoded_normal; // Number of calls where audio RTP packet decoded. |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 368 | int decoded_plc; // Number of calls resulted in PLC. |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 369 | int decoded_cng; // Number of calls where comfort noise generated due to DTX. |
| 370 | int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG. |
henrik.lundin | 6348978 | 2016-09-20 01:47:12 -0700 | [diff] [blame] | 371 | int decoded_muted_output; // Number of calls returning a muted state output. |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 372 | }; |
| 373 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 374 | // ================================================================== |
| 375 | // Video specific types |
| 376 | // ================================================================== |
| 377 | |
nisse | eb44b39 | 2017-04-28 07:18:05 -0700 | [diff] [blame] | 378 | // TODO(nisse): Delete, and switch to fourcc values everywhere? |
| 379 | // Supported video types. |
| 380 | enum class VideoType { |
| 381 | kUnknown, |
| 382 | kI420, |
| 383 | kIYUV, |
| 384 | kRGB24, |
| 385 | kABGR, |
| 386 | kARGB, |
| 387 | kARGB4444, |
| 388 | kRGB565, |
| 389 | kARGB1555, |
| 390 | kYUY2, |
| 391 | kYV12, |
| 392 | kUYVY, |
| 393 | kMJPEG, |
| 394 | kNV21, |
| 395 | kNV12, |
| 396 | kBGRA, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 397 | }; |
| 398 | |
| 399 | // Video codec |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 400 | enum { kMaxSimulcastStreams = 4 }; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 401 | enum { kMaxSpatialLayers = 5 }; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 402 | enum { kMaxTemporalStreams = 4 }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 403 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 404 | enum VideoCodecComplexity { |
| 405 | kComplexityNormal = 0, |
| 406 | kComplexityHigh = 1, |
| 407 | kComplexityHigher = 2, |
| 408 | kComplexityMax = 3 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 409 | }; |
| 410 | |
stefan@webrtc.org | efd0a48 | 2011-12-29 10:12:35 +0000 | [diff] [blame] | 411 | enum VP8ResilienceMode { |
| 412 | kResilienceOff, // The stream produced by the encoder requires a |
| 413 | // recovery frame (typically a key frame) to be |
| 414 | // decodable after a packet loss. |
| 415 | kResilientStream, // A stream produced by the encoder is resilient to |
| 416 | // packet losses, but packets within a frame subsequent |
| 417 | // to a loss can't be decoded. |
| 418 | kResilientFrames // Same as kResilientStream but with added resilience |
| 419 | // within a frame. |
| 420 | }; |
| 421 | |
Peter Boström | 7b971e7 | 2016-01-19 16:26:16 +0100 | [diff] [blame] | 422 | class TemporalLayersFactory; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 423 | // VP8 specific |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 424 | struct VideoCodecVP8 { |
Niels Möller | def1ef5 | 2018-03-19 13:48:44 +0100 | [diff] [blame] | 425 | bool operator==(const VideoCodecVP8& other) const; |
| 426 | bool operator!=(const VideoCodecVP8& other) const { |
| 427 | return !(*this == other); |
| 428 | } |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 429 | VideoCodecComplexity complexity; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 430 | VP8ResilienceMode resilience; |
| 431 | unsigned char numberOfTemporalLayers; |
| 432 | bool denoisingOn; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 433 | bool automaticResizeOn; |
| 434 | bool frameDroppingOn; |
| 435 | int keyFrameInterval; |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 436 | TemporalLayersFactory* tl_factory; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 437 | }; |
| 438 | |
asapersson | a9455ab | 2015-07-31 06:10:09 -0700 | [diff] [blame] | 439 | // VP9 specific. |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 440 | struct VideoCodecVP9 { |
Niels Möller | def1ef5 | 2018-03-19 13:48:44 +0100 | [diff] [blame] | 441 | bool operator==(const VideoCodecVP9& other) const; |
| 442 | bool operator!=(const VideoCodecVP9& other) const { |
| 443 | return !(*this == other); |
| 444 | } |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 445 | VideoCodecComplexity complexity; |
asapersson | 15dcb38 | 2017-06-08 02:55:08 -0700 | [diff] [blame] | 446 | bool resilienceOn; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 447 | unsigned char numberOfTemporalLayers; |
| 448 | bool denoisingOn; |
| 449 | bool frameDroppingOn; |
| 450 | int keyFrameInterval; |
| 451 | bool adaptiveQpMode; |
| 452 | bool automaticResizeOn; |
| 453 | unsigned char numberOfSpatialLayers; |
| 454 | bool flexibleMode; |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 455 | }; |
| 456 | |
magjed | e69a1a9 | 2016-11-25 10:06:31 -0800 | [diff] [blame] | 457 | // TODO(magjed): Move this and other H264 related classes out to their own file. |
| 458 | namespace H264 { |
| 459 | |
| 460 | enum Profile { |
| 461 | kProfileConstrainedBaseline, |
| 462 | kProfileBaseline, |
| 463 | kProfileMain, |
| 464 | kProfileConstrainedHigh, |
| 465 | kProfileHigh, |
| 466 | }; |
| 467 | |
| 468 | } // namespace H264 |
| 469 | |
stefan@webrtc.org | b9f5453 | 2014-07-04 12:42:07 +0000 | [diff] [blame] | 470 | // H264 specific. |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 471 | struct VideoCodecH264 { |
Niels Möller | def1ef5 | 2018-03-19 13:48:44 +0100 | [diff] [blame] | 472 | bool operator==(const VideoCodecH264& other) const; |
| 473 | bool operator!=(const VideoCodecH264& other) const { |
| 474 | return !(*this == other); |
| 475 | } |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 476 | bool frameDroppingOn; |
| 477 | int keyFrameInterval; |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 478 | // These are NULL/0 if not externally negotiated. |
| 479 | const uint8_t* spsData; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 480 | size_t spsLen; |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 481 | const uint8_t* ppsData; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 482 | size_t ppsLen; |
magjed | e69a1a9 | 2016-11-25 10:06:31 -0800 | [diff] [blame] | 483 | H264::Profile profile; |
stefan@webrtc.org | b9f5453 | 2014-07-04 12:42:07 +0000 | [diff] [blame] | 484 | }; |
| 485 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 486 | // Video codec types |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 487 | enum VideoCodecType { |
| 488 | kVideoCodecVP8, |
| 489 | kVideoCodecVP9, |
| 490 | kVideoCodecH264, |
| 491 | kVideoCodecI420, |
| 492 | kVideoCodecRED, |
| 493 | kVideoCodecULPFEC, |
brandtr | 87d7d77 | 2016-11-07 03:03:41 -0800 | [diff] [blame] | 494 | kVideoCodecFlexfec, |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 495 | kVideoCodecGeneric, |
Emircan Uysaler | d7ae3c3 | 2018-01-25 13:01:09 -0800 | [diff] [blame] | 496 | kVideoCodecMultiplex, |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 497 | kVideoCodecUnknown |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 498 | }; |
| 499 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 500 | // Translates from name of codec to codec type and vice versa. |
kthelgason | 1cdddc9 | 2017-08-24 03:52:48 -0700 | [diff] [blame] | 501 | const char* CodecTypeToPayloadString(VideoCodecType type); |
| 502 | VideoCodecType PayloadStringToCodecType(const std::string& name); |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 503 | |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 504 | union VideoCodecUnion { |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 505 | VideoCodecVP8 VP8; |
| 506 | VideoCodecVP9 VP9; |
| 507 | VideoCodecH264 H264; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 508 | }; |
| 509 | |
Sergey Silkin | 13e7434 | 2018-03-02 12:28:00 +0100 | [diff] [blame] | 510 | struct SpatialLayer { |
Niels Möller | def1ef5 | 2018-03-19 13:48:44 +0100 | [diff] [blame] | 511 | bool operator==(const SpatialLayer& other) const; |
| 512 | bool operator!=(const SpatialLayer& other) const { return !(*this == other); } |
| 513 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 514 | unsigned short width; |
| 515 | unsigned short height; |
| 516 | unsigned char numberOfTemporalLayers; |
| 517 | unsigned int maxBitrate; // kilobits/sec. |
| 518 | unsigned int targetBitrate; // kilobits/sec. |
| 519 | unsigned int minBitrate; // kilobits/sec. |
| 520 | unsigned int qpMax; // minimum quality |
Seth Hampson | f6464c9 | 2018-01-17 13:55:14 -0800 | [diff] [blame] | 521 | bool active; // encoded and sent. |
pwestin@webrtc.org | 1da1ce0 | 2011-10-13 15:19:55 +0000 | [diff] [blame] | 522 | }; |
| 523 | |
Sergey Silkin | 13e7434 | 2018-03-02 12:28:00 +0100 | [diff] [blame] | 524 | // Simulcast is when the same stream is encoded multiple times with different |
| 525 | // settings such as resolution. |
| 526 | typedef SpatialLayer SimulcastStream; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 527 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 528 | enum VideoCodecMode { kRealtimeVideo, kScreensharing }; |
stefan@webrtc.org | eb91792 | 2013-02-18 14:40:18 +0000 | [diff] [blame] | 529 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 530 | // Common video codec properties |
hta | 257dc39 | 2016-10-25 09:05:06 -0700 | [diff] [blame] | 531 | class VideoCodec { |
| 532 | public: |
| 533 | VideoCodec(); |
| 534 | |
| 535 | // Public variables. TODO(hta): Make them private with accessors. |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 536 | VideoCodecType codecType; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 537 | unsigned char plType; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 538 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 539 | unsigned short width; |
| 540 | unsigned short height; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 541 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 542 | unsigned int startBitrate; // kilobits/sec. |
| 543 | unsigned int maxBitrate; // kilobits/sec. |
| 544 | unsigned int minBitrate; // kilobits/sec. |
| 545 | unsigned int targetBitrate; // kilobits/sec. |
pbos@webrtc.org | 3c412b2 | 2014-03-24 12:36:52 +0000 | [diff] [blame] | 546 | |
Stefan Holmer | 144475b | 2017-03-10 15:08:26 +0100 | [diff] [blame] | 547 | uint32_t maxFramerate; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 548 | |
Seth Hampson | f6464c9 | 2018-01-17 13:55:14 -0800 | [diff] [blame] | 549 | // This enables/disables encoding and sending when there aren't multiple |
| 550 | // simulcast streams,by allocating 0 bitrate if inactive. |
| 551 | bool active; |
| 552 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 553 | unsigned int qpMax; |
| 554 | unsigned char numberOfSimulcastStreams; |
| 555 | SimulcastStream simulcastStream[kMaxSimulcastStreams]; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 556 | SpatialLayer spatialLayers[kMaxSpatialLayers]; |
stefan@webrtc.org | eb91792 | 2013-02-18 14:40:18 +0000 | [diff] [blame] | 557 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 558 | VideoCodecMode mode; |
| 559 | bool expect_encode_from_texture; |
andresp@webrtc.org | 185bae4 | 2013-05-14 08:02:25 +0000 | [diff] [blame] | 560 | |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 561 | // Timing frames configuration. There is delay of delay_ms between two |
| 562 | // consequent timing frames, excluding outliers. Frame is always made a |
| 563 | // timing frame if it's at least outlier_ratio in percent of "ideal" average |
| 564 | // frame given bitrate and framerate, i.e. if it's bigger than |
| 565 | // |outlier_ratio / 100.0 * bitrate_bps / fps| in bits. This way, timing |
| 566 | // frames will not be sent too often usually. Yet large frames will always |
| 567 | // have timing information for debug purposes because they are more likely to |
| 568 | // cause extra delays. |
| 569 | struct TimingFrameTriggerThresholds { |
| 570 | int64_t delay_ms; |
| 571 | uint16_t outlier_ratio_percent; |
| 572 | } timing_frame_thresholds; |
| 573 | |
Peter Boström | 7b971e7 | 2016-01-19 16:26:16 +0100 | [diff] [blame] | 574 | bool operator==(const VideoCodec& other) const = delete; |
| 575 | bool operator!=(const VideoCodec& other) const = delete; |
hta | 257dc39 | 2016-10-25 09:05:06 -0700 | [diff] [blame] | 576 | |
| 577 | // Accessors for codec specific information. |
| 578 | // There is a const version of each that returns a reference, |
| 579 | // and a non-const version that returns a pointer, in order |
| 580 | // to allow modification of the parameters. |
| 581 | VideoCodecVP8* VP8(); |
| 582 | const VideoCodecVP8& VP8() const; |
| 583 | VideoCodecVP9* VP9(); |
| 584 | const VideoCodecVP9& VP9() const; |
| 585 | VideoCodecH264* H264(); |
| 586 | const VideoCodecH264& H264() const; |
| 587 | |
hta | 527d347 | 2016-11-16 23:23:04 -0800 | [diff] [blame] | 588 | private: |
hta | 257dc39 | 2016-10-25 09:05:06 -0700 | [diff] [blame] | 589 | // TODO(hta): Consider replacing the union with a pointer type. |
| 590 | // This will allow removing the VideoCodec* types from this file. |
hta | 527d347 | 2016-11-16 23:23:04 -0800 | [diff] [blame] | 591 | VideoCodecUnion codec_specific_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 592 | }; |
astor@webrtc.org | bd7aeba | 2012-06-26 10:47:04 +0000 | [diff] [blame] | 593 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 594 | class BitrateAllocation { |
| 595 | public: |
| 596 | static const uint32_t kMaxBitrateBps; |
| 597 | BitrateAllocation(); |
| 598 | |
| 599 | bool SetBitrate(size_t spatial_index, |
| 600 | size_t temporal_index, |
| 601 | uint32_t bitrate_bps); |
| 602 | |
erikvarga@webrtc.org | 01f2ec3 | 2017-11-15 14:58:23 +0100 | [diff] [blame] | 603 | bool HasBitrate(size_t spatial_index, size_t temporal_index) const; |
| 604 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 605 | uint32_t GetBitrate(size_t spatial_index, size_t temporal_index) const; |
| 606 | |
erikvarga@webrtc.org | 01f2ec3 | 2017-11-15 14:58:23 +0100 | [diff] [blame] | 607 | // Whether the specific spatial layers has the bitrate set in any of its |
| 608 | // temporal layers. |
| 609 | bool IsSpatialLayerUsed(size_t spatial_index) const; |
| 610 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 611 | // Get the sum of all the temporal layer for a specific spatial layer. |
| 612 | uint32_t GetSpatialLayerSum(size_t spatial_index) const; |
| 613 | |
Sergey Silkin | 8668496 | 2018-03-28 19:32:37 +0200 | [diff] [blame] | 614 | // Sum of bitrates of temporal layers, from layer 0 to |temporal_index| |
| 615 | // inclusive, of specified spatial layer |spatial_index|. Bitrates of lower |
| 616 | // spatial layers are not included. |
| 617 | uint32_t GetTemporalLayerSum(size_t spatial_index, |
| 618 | size_t temporal_index) const; |
| 619 | |
Erik Språng | bb60a3a | 2018-03-19 18:25:10 +0100 | [diff] [blame] | 620 | // Returns a vector of the temporal layer bitrates for the specific spatial |
| 621 | // layer. Length of the returned vector is cropped to the highest temporal |
| 622 | // layer with a defined bitrate. |
| 623 | std::vector<uint32_t> GetTemporalLayerAllocation(size_t spatial_index) const; |
| 624 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 625 | uint32_t get_sum_bps() const { return sum_; } // Sum of all bitrates. |
| 626 | uint32_t get_sum_kbps() const { return (sum_ + 500) / 1000; } |
| 627 | |
| 628 | inline bool operator==(const BitrateAllocation& other) const { |
| 629 | return memcmp(bitrates_, other.bitrates_, sizeof(bitrates_)) == 0; |
| 630 | } |
| 631 | inline bool operator!=(const BitrateAllocation& other) const { |
| 632 | return !(*this == other); |
| 633 | } |
| 634 | |
sprang | d0fc37a | 2017-06-22 05:40:25 -0700 | [diff] [blame] | 635 | // Expensive, please use only in tests. |
| 636 | std::string ToString() const; |
sprang | d0fc37a | 2017-06-22 05:40:25 -0700 | [diff] [blame] | 637 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 638 | private: |
| 639 | uint32_t sum_; |
| 640 | uint32_t bitrates_[kMaxSpatialLayers][kMaxTemporalStreams]; |
erikvarga@webrtc.org | 01f2ec3 | 2017-11-15 14:58:23 +0100 | [diff] [blame] | 641 | bool has_bitrate_[kMaxSpatialLayers][kMaxTemporalStreams]; |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 642 | }; |
| 643 | |
stefan | 64c0a0a | 2015-11-27 01:02:31 -0800 | [diff] [blame] | 644 | // Bandwidth over-use detector options. These are used to drive |
| 645 | // experimentation with bandwidth estimation parameters. |
| 646 | // See modules/remote_bitrate_estimator/overuse_detector.h |
terelius | 84f83f8 | 2016-12-27 10:43:01 -0800 | [diff] [blame] | 647 | // TODO(terelius): This is only used in overuse_estimator.cc, and only in the |
| 648 | // default constructed state. Can we move the relevant variables into that |
| 649 | // class and delete this? See also disabled warning at line 27 |
stefan | 64c0a0a | 2015-11-27 01:02:31 -0800 | [diff] [blame] | 650 | struct OverUseDetectorOptions { |
| 651 | OverUseDetectorOptions() |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 652 | : initial_slope(8.0 / 512.0), |
stefan | 64c0a0a | 2015-11-27 01:02:31 -0800 | [diff] [blame] | 653 | initial_offset(0), |
| 654 | initial_e(), |
| 655 | initial_process_noise(), |
| 656 | initial_avg_noise(0.0), |
| 657 | initial_var_noise(50) { |
| 658 | initial_e[0][0] = 100; |
| 659 | initial_e[1][1] = 1e-1; |
| 660 | initial_e[0][1] = initial_e[1][0] = 0; |
| 661 | initial_process_noise[0] = 1e-13; |
stefan | 1069cac | 2016-03-10 05:13:21 -0800 | [diff] [blame] | 662 | initial_process_noise[1] = 1e-3; |
stefan | 64c0a0a | 2015-11-27 01:02:31 -0800 | [diff] [blame] | 663 | } |
| 664 | double initial_slope; |
| 665 | double initial_offset; |
| 666 | double initial_e[2][2]; |
| 667 | double initial_process_noise[2]; |
| 668 | double initial_avg_noise; |
| 669 | double initial_var_noise; |
| 670 | }; |
| 671 | |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 672 | // This structure will have the information about when packet is actually |
| 673 | // received by socket. |
| 674 | struct PacketTime { |
henrike@webrtc.org | 82d3cb6 | 2014-04-29 17:50:47 +0000 | [diff] [blame] | 675 | PacketTime() : timestamp(-1), not_before(-1) {} |
| 676 | PacketTime(int64_t timestamp, int64_t not_before) |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 677 | : timestamp(timestamp), not_before(not_before) {} |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 678 | |
henrike@webrtc.org | 82d3cb6 | 2014-04-29 17:50:47 +0000 | [diff] [blame] | 679 | int64_t timestamp; // Receive time after socket delivers the data. |
| 680 | int64_t not_before; // Earliest possible time the data could have arrived, |
| 681 | // indicating the potential error in the |timestamp| |
| 682 | // value,in case the system is busy. |
| 683 | // For example, the time of the last select() call. |
| 684 | // If unknown, this value will be set to zero. |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 685 | }; |
| 686 | |
isheriff | 6b4b5f3 | 2016-06-08 00:24:21 -0700 | [diff] [blame] | 687 | // Minimum and maximum playout delay values from capture to render. |
| 688 | // These are best effort values. |
| 689 | // |
| 690 | // A value < 0 indicates no change from previous valid value. |
| 691 | // |
| 692 | // min = max = 0 indicates that the receiver should try and render |
| 693 | // frame as soon as possible. |
| 694 | // |
| 695 | // min = x, max = y indicates that the receiver is free to adapt |
| 696 | // in the range (x, y) based on network jitter. |
| 697 | // |
| 698 | // Note: Given that this gets embedded in a union, it is up-to the owner to |
| 699 | // initialize these values. |
| 700 | struct PlayoutDelay { |
| 701 | int min_ms; |
| 702 | int max_ms; |
| 703 | }; |
| 704 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 705 | } // namespace webrtc |
andrew@webrtc.org | eda189b | 2013-09-09 17:50:10 +0000 | [diff] [blame] | 706 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 707 | #endif // COMMON_TYPES_H_ |