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> |
pbos@webrtc.org | 1e92b0a | 2014-05-15 09:35:06 +0000 | [diff] [blame] | 16 | #include <string> |
pbos@webrtc.org | f577ae9 | 2014-03-19 08:43:57 +0000 | [diff] [blame] | 17 | #include <vector> |
| 18 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "api/array_view.h" |
| 20 | #include "api/optional.h" |
Erik Språng | 566124a | 2018-04-23 12:32:22 +0200 | [diff] [blame] | 21 | // TODO(sprang): Remove this include when all usage includes it directly. |
| 22 | #include "api/video/video_bitrate_allocation.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 23 | #include "rtc_base/checks.h" |
| 24 | #include "rtc_base/deprecation.h" |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 25 | #include "typedefs.h" // NOLINT(build/include) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 27 | #if defined(_MSC_VER) |
| 28 | // Disable "new behavior: elements of array will be default initialized" |
| 29 | // warning. Affects OverUseDetectorOptions. |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 30 | #pragma warning(disable : 4351) |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 31 | #endif |
| 32 | |
Peter Boström | 8b79b07 | 2016-02-26 16:31:37 +0100 | [diff] [blame] | 33 | #define RTP_PAYLOAD_NAME_SIZE 32u |
henrika@webrtc.org | f75901f | 2012-01-16 08:45:42 +0000 | [diff] [blame] | 34 | |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 35 | #if defined(WEBRTC_WIN) || defined(WIN32) |
andrew@webrtc.org | eda189b | 2013-09-09 17:50:10 +0000 | [diff] [blame] | 36 | // Compares two strings without regard to case. |
| 37 | #define STR_CASE_CMP(s1, s2) ::_stricmp(s1, s2) |
| 38 | // Compares characters of two strings without regard to case. |
| 39 | #define STR_NCASE_CMP(s1, s2, n) ::_strnicmp(s1, s2, n) |
| 40 | #else |
| 41 | #define STR_CASE_CMP(s1, s2) ::strcasecmp(s1, s2) |
| 42 | #define STR_NCASE_CMP(s1, s2, n) ::strncasecmp(s1, s2, n) |
| 43 | #endif |
| 44 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | namespace webrtc { |
| 46 | |
pbos | 22993e1 | 2015-10-19 02:39:06 -0700 | [diff] [blame] | 47 | enum FrameType { |
| 48 | kEmptyFrame = 0, |
| 49 | kAudioFrameSpeech = 1, |
| 50 | kAudioFrameCN = 2, |
| 51 | kVideoFrameKey = 3, |
| 52 | kVideoFrameDelta = 4, |
sprang@webrtc.org | 71f055f | 2013-12-04 15:09:27 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 55 | // Statistics for an RTCP channel |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 56 | struct RtcpStatistics { |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 57 | RtcpStatistics() |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 58 | : fraction_lost(0), |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 59 | packets_lost(0), |
| 60 | extended_highest_sequence_number(0), |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 61 | jitter(0) {} |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 62 | |
| 63 | uint8_t fraction_lost; |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 64 | union { |
Harald Alvestrand | c7c4191 | 2017-12-08 09:59:34 +0100 | [diff] [blame] | 65 | int32_t packets_lost; // Defined as a 24 bit signed integer in RTCP |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 66 | RTC_DEPRECATED uint32_t cumulative_lost; |
| 67 | }; |
| 68 | union { |
| 69 | uint32_t extended_highest_sequence_number; |
| 70 | RTC_DEPRECATED uint32_t extended_max_sequence_number; |
| 71 | }; |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 72 | uint32_t jitter; |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 73 | }; |
| 74 | |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 75 | class RtcpStatisticsCallback { |
| 76 | public: |
| 77 | virtual ~RtcpStatisticsCallback() {} |
| 78 | |
| 79 | virtual void StatisticsUpdated(const RtcpStatistics& statistics, |
| 80 | uint32_t ssrc) = 0; |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 81 | virtual void CNameChanged(const char* cname, uint32_t ssrc) = 0; |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 82 | }; |
| 83 | |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 84 | // Statistics for RTCP packet types. |
| 85 | struct RtcpPacketTypeCounter { |
| 86 | RtcpPacketTypeCounter() |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 87 | : first_packet_time_ms(-1), |
| 88 | nack_packets(0), |
| 89 | fir_packets(0), |
| 90 | pli_packets(0), |
| 91 | nack_requests(0), |
| 92 | unique_nack_requests(0) {} |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 93 | |
| 94 | void Add(const RtcpPacketTypeCounter& other) { |
| 95 | nack_packets += other.nack_packets; |
| 96 | fir_packets += other.fir_packets; |
| 97 | pli_packets += other.pli_packets; |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 98 | nack_requests += other.nack_requests; |
| 99 | unique_nack_requests += other.unique_nack_requests; |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 100 | if (other.first_packet_time_ms != -1 && |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 101 | (other.first_packet_time_ms < first_packet_time_ms || |
| 102 | first_packet_time_ms == -1)) { |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 103 | // Use oldest time. |
| 104 | first_packet_time_ms = other.first_packet_time_ms; |
| 105 | } |
| 106 | } |
| 107 | |
sprang | 07fb9be | 2016-02-24 07:55:00 -0800 | [diff] [blame] | 108 | void Subtract(const RtcpPacketTypeCounter& other) { |
| 109 | nack_packets -= other.nack_packets; |
| 110 | fir_packets -= other.fir_packets; |
| 111 | pli_packets -= other.pli_packets; |
| 112 | nack_requests -= other.nack_requests; |
| 113 | unique_nack_requests -= other.unique_nack_requests; |
| 114 | if (other.first_packet_time_ms != -1 && |
| 115 | (other.first_packet_time_ms > first_packet_time_ms || |
| 116 | first_packet_time_ms == -1)) { |
| 117 | // Use youngest time. |
| 118 | first_packet_time_ms = other.first_packet_time_ms; |
| 119 | } |
| 120 | } |
| 121 | |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 122 | int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const { |
| 123 | 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] | 124 | } |
| 125 | |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 126 | int UniqueNackRequestsInPercent() const { |
| 127 | if (nack_requests == 0) { |
| 128 | return 0; |
| 129 | } |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 130 | return static_cast<int>((unique_nack_requests * 100.0f / nack_requests) + |
| 131 | 0.5f); |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 132 | } |
| 133 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 134 | int64_t first_packet_time_ms; // Time when first packet is sent/received. |
| 135 | uint32_t nack_packets; // Number of RTCP NACK packets. |
| 136 | uint32_t fir_packets; // Number of RTCP FIR packets. |
| 137 | uint32_t pli_packets; // Number of RTCP PLI packets. |
| 138 | uint32_t nack_requests; // Number of NACKed RTP packets. |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 139 | uint32_t unique_nack_requests; // Number of unique NACKed RTP packets. |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 140 | }; |
| 141 | |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 142 | class RtcpPacketTypeCounterObserver { |
| 143 | public: |
| 144 | virtual ~RtcpPacketTypeCounterObserver() {} |
| 145 | virtual void RtcpPacketTypesCounterUpdated( |
| 146 | uint32_t ssrc, |
| 147 | const RtcpPacketTypeCounter& packet_counter) = 0; |
| 148 | }; |
| 149 | |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 150 | // Callback, used to notify an observer whenever new rates have been estimated. |
| 151 | class BitrateStatisticsObserver { |
| 152 | public: |
| 153 | virtual ~BitrateStatisticsObserver() {} |
| 154 | |
sprang | cd349d9 | 2016-07-13 09:11:28 -0700 | [diff] [blame] | 155 | virtual void Notify(uint32_t total_bitrate_bps, |
| 156 | uint32_t retransmit_bitrate_bps, |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame] | 157 | uint32_t ssrc) = 0; |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 158 | }; |
| 159 | |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 160 | struct FrameCounts { |
| 161 | FrameCounts() : key_frames(0), delta_frames(0) {} |
| 162 | int key_frames; |
| 163 | int delta_frames; |
| 164 | }; |
| 165 | |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 166 | // 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] | 167 | class FrameCountObserver { |
| 168 | public: |
sprang@webrtc.org | 72964bd | 2013-11-21 09:09:54 +0000 | [diff] [blame] | 169 | virtual ~FrameCountObserver() {} |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 170 | virtual void FrameCountUpdated(const FrameCounts& frame_counts, |
| 171 | uint32_t ssrc) = 0; |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 172 | }; |
| 173 | |
stefan@webrtc.org | 168f23f | 2014-07-11 13:44:02 +0000 | [diff] [blame] | 174 | // Callback, used to notify an observer whenever the send-side delay is updated. |
| 175 | class SendSideDelayObserver { |
| 176 | public: |
| 177 | virtual ~SendSideDelayObserver() {} |
| 178 | virtual void SendSideDelayUpdated(int avg_delay_ms, |
| 179 | int max_delay_ms, |
| 180 | uint32_t ssrc) = 0; |
| 181 | }; |
| 182 | |
asapersson | 35151f3 | 2016-05-02 23:44:01 -0700 | [diff] [blame] | 183 | // Callback, used to notify an observer whenever a packet is sent to the |
| 184 | // transport. |
| 185 | // TODO(asapersson): This class will remove the need for SendSideDelayObserver. |
| 186 | // Remove SendSideDelayObserver once possible. |
| 187 | class SendPacketObserver { |
| 188 | public: |
| 189 | virtual ~SendPacketObserver() {} |
| 190 | virtual void OnSendPacket(uint16_t packet_id, |
| 191 | int64_t capture_time_ms, |
| 192 | uint32_t ssrc) = 0; |
| 193 | }; |
| 194 | |
michaelt | 4da3044 | 2016-11-17 01:38:43 -0800 | [diff] [blame] | 195 | // Callback, used to notify an observer when the overhead per packet |
| 196 | // has changed. |
| 197 | class OverheadObserver { |
| 198 | public: |
| 199 | virtual ~OverheadObserver() = default; |
| 200 | virtual void OnOverheadChanged(size_t overhead_bytes_per_packet) = 0; |
| 201 | }; |
| 202 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 203 | // ================================================================== |
| 204 | // Voice specific types |
| 205 | // ================================================================== |
| 206 | |
| 207 | // Each codec supported can be described by this structure. |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 208 | struct CodecInst { |
| 209 | int pltype; |
| 210 | char plname[RTP_PAYLOAD_NAME_SIZE]; |
| 211 | int plfreq; |
| 212 | int pacsize; |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 213 | size_t channels; |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 214 | int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file! |
| 215 | |
| 216 | bool operator==(const CodecInst& other) const { |
| 217 | return pltype == other.pltype && |
| 218 | (STR_CASE_CMP(plname, other.plname) == 0) && |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 219 | plfreq == other.plfreq && pacsize == other.pacsize && |
| 220 | channels == other.channels && rate == other.rate; |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 221 | } |
| 222 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 223 | bool operator!=(const CodecInst& other) const { return !(*this == other); } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 224 | }; |
| 225 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 226 | // RTP |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 227 | enum { kRtpCsrcSize = 15 }; // RFC 3550 page 13 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 228 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 229 | // NETEQ statistics. |
| 230 | struct NetworkStatistics { |
| 231 | // current jitter buffer size in ms |
| 232 | uint16_t currentBufferSize; |
| 233 | // preferred (optimal) buffer size in ms |
| 234 | uint16_t preferredBufferSize; |
| 235 | // adding extra delay due to "peaky jitter" |
| 236 | bool jitterPeaksFound; |
Gustaf Ullberg | b0a0207 | 2017-10-02 12:00:34 +0200 | [diff] [blame] | 237 | // Stats below correspond to similarly-named fields in the WebRTC stats spec. |
| 238 | // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats |
Steve Anton | 2dbc69f | 2017-08-24 17:15:13 -0700 | [diff] [blame] | 239 | uint64_t totalSamplesReceived; |
Steve Anton | 2dbc69f | 2017-08-24 17:15:13 -0700 | [diff] [blame] | 240 | uint64_t concealedSamples; |
Gustaf Ullberg | 9a2e906 | 2017-09-18 09:28:20 +0200 | [diff] [blame] | 241 | uint64_t concealmentEvents; |
Gustaf Ullberg | b0a0207 | 2017-10-02 12:00:34 +0200 | [diff] [blame] | 242 | uint64_t jitterBufferDelayMs; |
| 243 | // Stats below DO NOT correspond directly to anything in the WebRTC stats |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 244 | // Loss rate (network + late); fraction between 0 and 1, scaled to Q14. |
| 245 | uint16_t currentPacketLossRate; |
| 246 | // Late loss rate; fraction between 0 and 1, scaled to Q14. |
minyue-webrtc | 0c3ca75 | 2017-08-23 15:59:38 +0200 | [diff] [blame] | 247 | union { |
| 248 | RTC_DEPRECATED uint16_t currentDiscardRate; |
| 249 | }; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 250 | // fraction (of original stream) of synthesized audio inserted through |
| 251 | // expansion (in Q14) |
| 252 | uint16_t currentExpandRate; |
| 253 | // fraction (of original stream) of synthesized speech inserted through |
| 254 | // expansion (in Q14) |
| 255 | uint16_t currentSpeechExpandRate; |
| 256 | // fraction of synthesized speech inserted through pre-emptive expansion |
| 257 | // (in Q14) |
| 258 | uint16_t currentPreemptiveRate; |
| 259 | // fraction of data removed through acceleration (in Q14) |
| 260 | uint16_t currentAccelerateRate; |
| 261 | // fraction of data coming from secondary decoding (in Q14) |
| 262 | uint16_t currentSecondaryDecodedRate; |
minyue-webrtc | 0e320ec | 2017-08-28 13:51:27 +0200 | [diff] [blame] | 263 | // Fraction of secondary data, including FEC and RED, that is discarded (in |
| 264 | // Q14). Discarding of secondary data can be caused by the reception of the |
| 265 | // primary data, obsoleting the secondary data. It can also be caused by early |
| 266 | // or late arrival of secondary data. |
minyue-webrtc | 0c3ca75 | 2017-08-23 15:59:38 +0200 | [diff] [blame] | 267 | uint16_t currentSecondaryDiscardedRate; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 268 | // clock-drift in parts-per-million (negative or positive) |
| 269 | int32_t clockDriftPPM; |
| 270 | // average packet waiting time in the jitter buffer (ms) |
| 271 | int meanWaitingTimeMs; |
| 272 | // median packet waiting time in the jitter buffer (ms) |
| 273 | int medianWaitingTimeMs; |
| 274 | // min packet waiting time in the jitter buffer (ms) |
| 275 | int minWaitingTimeMs; |
| 276 | // max packet waiting time in the jitter buffer (ms) |
| 277 | int maxWaitingTimeMs; |
| 278 | // added samples in off mode due to packet loss |
| 279 | size_t addedSamples; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 280 | }; |
| 281 | |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 282 | // Statistics for calls to AudioCodingModule::PlayoutData10Ms(). |
| 283 | struct AudioDecodingCallStats { |
| 284 | AudioDecodingCallStats() |
| 285 | : calls_to_silence_generator(0), |
| 286 | calls_to_neteq(0), |
| 287 | decoded_normal(0), |
| 288 | decoded_plc(0), |
| 289 | decoded_cng(0), |
henrik.lundin | 6348978 | 2016-09-20 01:47:12 -0700 | [diff] [blame] | 290 | decoded_plc_cng(0), |
| 291 | decoded_muted_output(0) {} |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 292 | |
| 293 | int calls_to_silence_generator; // Number of calls where silence generated, |
| 294 | // and NetEq was disengaged from decoding. |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 295 | int calls_to_neteq; // Number of calls to NetEq. |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 296 | int decoded_normal; // Number of calls where audio RTP packet decoded. |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 297 | int decoded_plc; // Number of calls resulted in PLC. |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 298 | int decoded_cng; // Number of calls where comfort noise generated due to DTX. |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 299 | 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] | 300 | 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] | 301 | }; |
| 302 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 303 | // ================================================================== |
| 304 | // Video specific types |
| 305 | // ================================================================== |
| 306 | |
nisse | eb44b39 | 2017-04-28 07:18:05 -0700 | [diff] [blame] | 307 | // TODO(nisse): Delete, and switch to fourcc values everywhere? |
| 308 | // Supported video types. |
| 309 | enum class VideoType { |
| 310 | kUnknown, |
| 311 | kI420, |
| 312 | kIYUV, |
| 313 | kRGB24, |
| 314 | kABGR, |
| 315 | kARGB, |
| 316 | kARGB4444, |
| 317 | kRGB565, |
| 318 | kARGB1555, |
| 319 | kYUY2, |
| 320 | kYV12, |
| 321 | kUYVY, |
| 322 | kMJPEG, |
| 323 | kNV21, |
| 324 | kNV12, |
| 325 | kBGRA, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 326 | }; |
| 327 | |
magjed | e69a1a9 | 2016-11-25 10:06:31 -0800 | [diff] [blame] | 328 | // TODO(magjed): Move this and other H264 related classes out to their own file. |
| 329 | namespace H264 { |
| 330 | |
| 331 | enum Profile { |
| 332 | kProfileConstrainedBaseline, |
| 333 | kProfileBaseline, |
| 334 | kProfileMain, |
| 335 | kProfileConstrainedHigh, |
| 336 | kProfileHigh, |
| 337 | }; |
| 338 | |
| 339 | } // namespace H264 |
| 340 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 341 | // Video codec types |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 342 | enum VideoCodecType { |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 343 | // There are various memset(..., 0, ...) calls in the code that rely on |
| 344 | // kVideoCodecUnknown being zero. |
| 345 | kVideoCodecUnknown = 0, |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 346 | kVideoCodecVP8, |
| 347 | kVideoCodecVP9, |
| 348 | kVideoCodecH264, |
| 349 | kVideoCodecI420, |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 350 | kVideoCodecGeneric, |
Emircan Uysaler | d7ae3c3 | 2018-01-25 13:01:09 -0800 | [diff] [blame] | 351 | kVideoCodecMultiplex, |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 352 | |
| 353 | // TODO(nisse): Deprecated aliases, for code expecting RtpVideoCodecTypes. |
| 354 | kRtpVideoNone = kVideoCodecUnknown, |
| 355 | kRtpVideoGeneric = kVideoCodecGeneric, |
| 356 | kRtpVideoVp8 = kVideoCodecVP8, |
| 357 | kRtpVideoVp9 = kVideoCodecVP9, |
| 358 | kRtpVideoH264 = kVideoCodecH264, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 359 | }; |
| 360 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 361 | // Translates from name of codec to codec type and vice versa. |
kthelgason | 1cdddc9 | 2017-08-24 03:52:48 -0700 | [diff] [blame] | 362 | const char* CodecTypeToPayloadString(VideoCodecType type); |
| 363 | VideoCodecType PayloadStringToCodecType(const std::string& name); |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 364 | |
Sergey Silkin | 13e7434 | 2018-03-02 12:28:00 +0100 | [diff] [blame] | 365 | struct SpatialLayer { |
Niels Möller | def1ef5 | 2018-03-19 13:48:44 +0100 | [diff] [blame] | 366 | bool operator==(const SpatialLayer& other) const; |
| 367 | bool operator!=(const SpatialLayer& other) const { return !(*this == other); } |
| 368 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 369 | unsigned short width; |
| 370 | unsigned short height; |
| 371 | unsigned char numberOfTemporalLayers; |
| 372 | unsigned int maxBitrate; // kilobits/sec. |
| 373 | unsigned int targetBitrate; // kilobits/sec. |
| 374 | unsigned int minBitrate; // kilobits/sec. |
| 375 | unsigned int qpMax; // minimum quality |
Seth Hampson | f6464c9 | 2018-01-17 13:55:14 -0800 | [diff] [blame] | 376 | bool active; // encoded and sent. |
pwestin@webrtc.org | 1da1ce0 | 2011-10-13 15:19:55 +0000 | [diff] [blame] | 377 | }; |
| 378 | |
Sergey Silkin | 13e7434 | 2018-03-02 12:28:00 +0100 | [diff] [blame] | 379 | // Simulcast is when the same stream is encoded multiple times with different |
| 380 | // settings such as resolution. |
| 381 | typedef SpatialLayer SimulcastStream; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 382 | |
Erik Språng | 566124a | 2018-04-23 12:32:22 +0200 | [diff] [blame] | 383 | // TODO(sprang): Remove this when downstream projects have been updated. |
| 384 | using BitrateAllocation = VideoBitrateAllocation; |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 385 | |
stefan | 64c0a0a | 2015-11-27 01:02:31 -0800 | [diff] [blame] | 386 | // Bandwidth over-use detector options. These are used to drive |
| 387 | // experimentation with bandwidth estimation parameters. |
| 388 | // See modules/remote_bitrate_estimator/overuse_detector.h |
terelius | 84f83f8 | 2016-12-27 10:43:01 -0800 | [diff] [blame] | 389 | // TODO(terelius): This is only used in overuse_estimator.cc, and only in the |
| 390 | // default constructed state. Can we move the relevant variables into that |
| 391 | // class and delete this? See also disabled warning at line 27 |
stefan | 64c0a0a | 2015-11-27 01:02:31 -0800 | [diff] [blame] | 392 | struct OverUseDetectorOptions { |
| 393 | OverUseDetectorOptions() |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 394 | : initial_slope(8.0 / 512.0), |
stefan | 64c0a0a | 2015-11-27 01:02:31 -0800 | [diff] [blame] | 395 | initial_offset(0), |
| 396 | initial_e(), |
| 397 | initial_process_noise(), |
| 398 | initial_avg_noise(0.0), |
| 399 | initial_var_noise(50) { |
| 400 | initial_e[0][0] = 100; |
| 401 | initial_e[1][1] = 1e-1; |
| 402 | initial_e[0][1] = initial_e[1][0] = 0; |
| 403 | initial_process_noise[0] = 1e-13; |
stefan | 1069cac | 2016-03-10 05:13:21 -0800 | [diff] [blame] | 404 | initial_process_noise[1] = 1e-3; |
stefan | 64c0a0a | 2015-11-27 01:02:31 -0800 | [diff] [blame] | 405 | } |
| 406 | double initial_slope; |
| 407 | double initial_offset; |
| 408 | double initial_e[2][2]; |
| 409 | double initial_process_noise[2]; |
| 410 | double initial_avg_noise; |
| 411 | double initial_var_noise; |
| 412 | }; |
| 413 | |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 414 | // This structure will have the information about when packet is actually |
| 415 | // received by socket. |
| 416 | struct PacketTime { |
henrike@webrtc.org | 82d3cb6 | 2014-04-29 17:50:47 +0000 | [diff] [blame] | 417 | PacketTime() : timestamp(-1), not_before(-1) {} |
| 418 | PacketTime(int64_t timestamp, int64_t not_before) |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 419 | : timestamp(timestamp), not_before(not_before) {} |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 420 | |
henrike@webrtc.org | 82d3cb6 | 2014-04-29 17:50:47 +0000 | [diff] [blame] | 421 | int64_t timestamp; // Receive time after socket delivers the data. |
| 422 | int64_t not_before; // Earliest possible time the data could have arrived, |
| 423 | // indicating the potential error in the |timestamp| |
| 424 | // value,in case the system is busy. |
| 425 | // For example, the time of the last select() call. |
| 426 | // If unknown, this value will be set to zero. |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 427 | }; |
| 428 | |
isheriff | 6b4b5f3 | 2016-06-08 00:24:21 -0700 | [diff] [blame] | 429 | // Minimum and maximum playout delay values from capture to render. |
| 430 | // These are best effort values. |
| 431 | // |
| 432 | // A value < 0 indicates no change from previous valid value. |
| 433 | // |
| 434 | // min = max = 0 indicates that the receiver should try and render |
| 435 | // frame as soon as possible. |
| 436 | // |
| 437 | // min = x, max = y indicates that the receiver is free to adapt |
| 438 | // in the range (x, y) based on network jitter. |
| 439 | // |
| 440 | // Note: Given that this gets embedded in a union, it is up-to the owner to |
| 441 | // initialize these values. |
| 442 | struct PlayoutDelay { |
| 443 | int min_ms; |
| 444 | int max_ms; |
| 445 | }; |
| 446 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 447 | } // namespace webrtc |
andrew@webrtc.org | eda189b | 2013-09-09 17:50:10 +0000 | [diff] [blame] | 448 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 449 | #endif // COMMON_TYPES_H_ |