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