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" |
| 22 | #include "api/video/video_content_type.h" |
| 23 | #include "api/video/video_rotation.h" |
| 24 | #include "api/video/video_timing.h" |
| 25 | #include "rtc_base/checks.h" |
| 26 | #include "rtc_base/deprecation.h" |
| 27 | #include "typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 29 | #if defined(_MSC_VER) |
| 30 | // Disable "new behavior: elements of array will be default initialized" |
| 31 | // warning. Affects OverUseDetectorOptions. |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 32 | #pragma warning(disable : 4351) |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 33 | #endif |
| 34 | |
kwiberg | 77eab70 | 2016-09-28 17:42:01 -0700 | [diff] [blame] | 35 | #if defined(WEBRTC_EXPORT) |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 36 | #define WEBRTC_DLLEXPORT _declspec(dllexport) |
kwiberg | 77eab70 | 2016-09-28 17:42:01 -0700 | [diff] [blame] | 37 | #elif defined(WEBRTC_DLL) |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 38 | #define WEBRTC_DLLEXPORT _declspec(dllimport) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | #else |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 40 | #define WEBRTC_DLLEXPORT |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | #endif |
| 42 | |
| 43 | #ifndef NULL |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 +0000 | [diff] [blame] | 44 | #define NULL 0 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | #endif |
| 46 | |
Peter Boström | 8b79b07 | 2016-02-26 16:31:37 +0100 | [diff] [blame] | 47 | #define RTP_PAYLOAD_NAME_SIZE 32u |
henrika@webrtc.org | f75901f | 2012-01-16 08:45:42 +0000 | [diff] [blame] | 48 | |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 49 | #if defined(WEBRTC_WIN) || defined(WIN32) |
andrew@webrtc.org | eda189b | 2013-09-09 17:50:10 +0000 | [diff] [blame] | 50 | // Compares two strings without regard to case. |
| 51 | #define STR_CASE_CMP(s1, s2) ::_stricmp(s1, s2) |
| 52 | // Compares characters of two strings without regard to case. |
| 53 | #define STR_NCASE_CMP(s1, s2, n) ::_strnicmp(s1, s2, n) |
| 54 | #else |
| 55 | #define STR_CASE_CMP(s1, s2) ::strcasecmp(s1, s2) |
| 56 | #define STR_NCASE_CMP(s1, s2, n) ::strncasecmp(s1, s2, n) |
| 57 | #endif |
| 58 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | namespace webrtc { |
| 60 | |
tommi | a6219cc | 2016-06-15 10:30:14 -0700 | [diff] [blame] | 61 | class RewindableStream { |
| 62 | public: |
| 63 | virtual ~RewindableStream() {} |
| 64 | virtual int Rewind() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
tommi | a6219cc | 2016-06-15 10:30:14 -0700 | [diff] [blame] | 67 | class InStream : public RewindableStream { |
| 68 | public: |
| 69 | // Reads |len| bytes from file to |buf|. Returns the number of bytes read |
| 70 | // or -1 on error. |
| 71 | virtual int Read(void* buf, size_t len) = 0; |
| 72 | }; |
| 73 | |
| 74 | class OutStream : public RewindableStream { |
| 75 | public: |
| 76 | // Writes |len| bytes from |buf| to file. The actual writing may happen |
| 77 | // some time later. Call Flush() to force a write. |
| 78 | virtual bool Write(const void* buf, size_t len) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 79 | }; |
| 80 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 81 | enum TraceModule { |
| 82 | kTraceUndefined = 0, |
| 83 | // not a module, triggered from the engine code |
| 84 | kTraceVoice = 0x0001, |
| 85 | // not a module, triggered from the engine code |
| 86 | kTraceVideo = 0x0002, |
| 87 | // not a module, triggered from the utility code |
| 88 | kTraceUtility = 0x0003, |
| 89 | kTraceRtpRtcp = 0x0004, |
| 90 | kTraceTransport = 0x0005, |
| 91 | kTraceSrtp = 0x0006, |
| 92 | kTraceAudioCoding = 0x0007, |
| 93 | kTraceAudioMixerServer = 0x0008, |
| 94 | kTraceAudioMixerClient = 0x0009, |
| 95 | kTraceFile = 0x000a, |
| 96 | kTraceAudioProcessing = 0x000b, |
| 97 | kTraceVideoCoding = 0x0010, |
| 98 | kTraceVideoMixer = 0x0011, |
| 99 | kTraceAudioDevice = 0x0012, |
| 100 | kTraceVideoRenderer = 0x0014, |
| 101 | kTraceVideoCapture = 0x0015, |
| 102 | kTraceRemoteBitrateEstimator = 0x0017, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 103 | }; |
| 104 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 105 | enum TraceLevel { |
| 106 | kTraceNone = 0x0000, // no trace |
| 107 | kTraceStateInfo = 0x0001, |
| 108 | kTraceWarning = 0x0002, |
| 109 | kTraceError = 0x0004, |
| 110 | kTraceCritical = 0x0008, |
| 111 | kTraceApiCall = 0x0010, |
| 112 | kTraceDefault = 0x00ff, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 113 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 114 | kTraceModuleCall = 0x0020, |
| 115 | kTraceMemory = 0x0100, // memory info |
| 116 | kTraceTimer = 0x0200, // timing info |
| 117 | kTraceStream = 0x0400, // "continuous" stream of data |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 118 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 119 | // used for debug purposes |
| 120 | kTraceDebug = 0x0800, // debug |
| 121 | kTraceInfo = 0x1000, // debug info |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 122 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 123 | // Non-verbose level used by LS_INFO of logging.h. Do not use directly. |
| 124 | kTraceTerseInfo = 0x2000, |
andrew@webrtc.org | 655d8f5 | 2012-11-20 07:34:45 +0000 | [diff] [blame] | 125 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 126 | kTraceAll = 0xffff |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 127 | }; |
| 128 | |
| 129 | // External Trace API |
andrew@webrtc.org | 23ec30b | 2012-11-15 05:33:25 +0000 | [diff] [blame] | 130 | class TraceCallback { |
| 131 | public: |
| 132 | virtual void Print(TraceLevel level, const char* message, int length) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 133 | |
andrew@webrtc.org | 23ec30b | 2012-11-15 05:33:25 +0000 | [diff] [blame] | 134 | protected: |
| 135 | virtual ~TraceCallback() {} |
| 136 | TraceCallback() {} |
| 137 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 138 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 139 | enum FileFormats { |
| 140 | kFileFormatWavFile = 1, |
| 141 | kFileFormatCompressedFile = 2, |
| 142 | kFileFormatPreencodedFile = 4, |
| 143 | kFileFormatPcm16kHzFile = 7, |
| 144 | kFileFormatPcm8kHzFile = 8, |
Minyue Li | 85a3b6b | 2017-09-01 14:36:33 +0200 | [diff] [blame] | 145 | kFileFormatPcm32kHzFile = 9, |
| 146 | kFileFormatPcm48kHzFile = 10 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 147 | }; |
| 148 | |
pbos | 22993e1 | 2015-10-19 02:39:06 -0700 | [diff] [blame] | 149 | enum FrameType { |
| 150 | kEmptyFrame = 0, |
| 151 | kAudioFrameSpeech = 1, |
| 152 | kAudioFrameCN = 2, |
| 153 | kVideoFrameKey = 3, |
| 154 | kVideoFrameDelta = 4, |
sprang@webrtc.org | 71f055f | 2013-12-04 15:09:27 +0000 | [diff] [blame] | 155 | }; |
| 156 | |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 157 | // Statistics for an RTCP channel |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 158 | struct RtcpStatistics { |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 159 | RtcpStatistics() |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 160 | : fraction_lost(0), |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 161 | packets_lost(0), |
| 162 | extended_highest_sequence_number(0), |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 163 | jitter(0) {} |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 164 | |
| 165 | uint8_t fraction_lost; |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 166 | union { |
| 167 | uint32_t packets_lost; |
| 168 | RTC_DEPRECATED uint32_t cumulative_lost; |
| 169 | }; |
| 170 | union { |
| 171 | uint32_t extended_highest_sequence_number; |
| 172 | RTC_DEPRECATED uint32_t extended_max_sequence_number; |
| 173 | }; |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 174 | uint32_t jitter; |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 175 | }; |
| 176 | |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 177 | class RtcpStatisticsCallback { |
| 178 | public: |
| 179 | virtual ~RtcpStatisticsCallback() {} |
| 180 | |
| 181 | virtual void StatisticsUpdated(const RtcpStatistics& statistics, |
| 182 | uint32_t ssrc) = 0; |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 183 | virtual void CNameChanged(const char* cname, uint32_t ssrc) = 0; |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 184 | }; |
| 185 | |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 186 | // Statistics for RTCP packet types. |
| 187 | struct RtcpPacketTypeCounter { |
| 188 | RtcpPacketTypeCounter() |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 189 | : first_packet_time_ms(-1), |
| 190 | nack_packets(0), |
| 191 | fir_packets(0), |
| 192 | pli_packets(0), |
| 193 | nack_requests(0), |
| 194 | unique_nack_requests(0) {} |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 195 | |
| 196 | void Add(const RtcpPacketTypeCounter& other) { |
| 197 | nack_packets += other.nack_packets; |
| 198 | fir_packets += other.fir_packets; |
| 199 | pli_packets += other.pli_packets; |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 200 | nack_requests += other.nack_requests; |
| 201 | unique_nack_requests += other.unique_nack_requests; |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 202 | if (other.first_packet_time_ms != -1 && |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 203 | (other.first_packet_time_ms < first_packet_time_ms || |
| 204 | first_packet_time_ms == -1)) { |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 205 | // Use oldest time. |
| 206 | first_packet_time_ms = other.first_packet_time_ms; |
| 207 | } |
| 208 | } |
| 209 | |
sprang | 07fb9be | 2016-02-24 07:55:00 -0800 | [diff] [blame] | 210 | void Subtract(const RtcpPacketTypeCounter& other) { |
| 211 | nack_packets -= other.nack_packets; |
| 212 | fir_packets -= other.fir_packets; |
| 213 | pli_packets -= other.pli_packets; |
| 214 | nack_requests -= other.nack_requests; |
| 215 | unique_nack_requests -= other.unique_nack_requests; |
| 216 | if (other.first_packet_time_ms != -1 && |
| 217 | (other.first_packet_time_ms > first_packet_time_ms || |
| 218 | first_packet_time_ms == -1)) { |
| 219 | // Use youngest time. |
| 220 | first_packet_time_ms = other.first_packet_time_ms; |
| 221 | } |
| 222 | } |
| 223 | |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 224 | int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const { |
| 225 | 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] | 226 | } |
| 227 | |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 228 | int UniqueNackRequestsInPercent() const { |
| 229 | if (nack_requests == 0) { |
| 230 | return 0; |
| 231 | } |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 232 | return static_cast<int>((unique_nack_requests * 100.0f / nack_requests) + |
| 233 | 0.5f); |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 234 | } |
| 235 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 236 | int64_t first_packet_time_ms; // Time when first packet is sent/received. |
| 237 | uint32_t nack_packets; // Number of RTCP NACK packets. |
| 238 | uint32_t fir_packets; // Number of RTCP FIR packets. |
| 239 | uint32_t pli_packets; // Number of RTCP PLI packets. |
| 240 | uint32_t nack_requests; // Number of NACKed RTP packets. |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 241 | uint32_t unique_nack_requests; // Number of unique NACKed RTP packets. |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 242 | }; |
| 243 | |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 244 | class RtcpPacketTypeCounterObserver { |
| 245 | public: |
| 246 | virtual ~RtcpPacketTypeCounterObserver() {} |
| 247 | virtual void RtcpPacketTypesCounterUpdated( |
| 248 | uint32_t ssrc, |
| 249 | const RtcpPacketTypeCounter& packet_counter) = 0; |
| 250 | }; |
| 251 | |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 252 | // Rate statistics for a stream. |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 253 | struct BitrateStatistics { |
sprang | cd349d9 | 2016-07-13 09:11:28 -0700 | [diff] [blame] | 254 | BitrateStatistics() : bitrate_bps(0), packet_rate(0) {} |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 255 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 256 | uint32_t bitrate_bps; // Bitrate in bits per second. |
| 257 | uint32_t packet_rate; // Packet rate in packets per second. |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 258 | }; |
| 259 | |
| 260 | // Callback, used to notify an observer whenever new rates have been estimated. |
| 261 | class BitrateStatisticsObserver { |
| 262 | public: |
| 263 | virtual ~BitrateStatisticsObserver() {} |
| 264 | |
sprang | cd349d9 | 2016-07-13 09:11:28 -0700 | [diff] [blame] | 265 | virtual void Notify(uint32_t total_bitrate_bps, |
| 266 | uint32_t retransmit_bitrate_bps, |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame] | 267 | uint32_t ssrc) = 0; |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 268 | }; |
| 269 | |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 270 | struct FrameCounts { |
| 271 | FrameCounts() : key_frames(0), delta_frames(0) {} |
| 272 | int key_frames; |
| 273 | int delta_frames; |
| 274 | }; |
| 275 | |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 +0000 | [diff] [blame] | 276 | // 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] | 277 | class FrameCountObserver { |
| 278 | public: |
sprang@webrtc.org | 72964bd | 2013-11-21 09:09:54 +0000 | [diff] [blame] | 279 | virtual ~FrameCountObserver() {} |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 280 | virtual void FrameCountUpdated(const FrameCounts& frame_counts, |
| 281 | uint32_t ssrc) = 0; |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 282 | }; |
| 283 | |
stefan@webrtc.org | 168f23f | 2014-07-11 13:44:02 +0000 | [diff] [blame] | 284 | // Callback, used to notify an observer whenever the send-side delay is updated. |
| 285 | class SendSideDelayObserver { |
| 286 | public: |
| 287 | virtual ~SendSideDelayObserver() {} |
| 288 | virtual void SendSideDelayUpdated(int avg_delay_ms, |
| 289 | int max_delay_ms, |
| 290 | uint32_t ssrc) = 0; |
| 291 | }; |
| 292 | |
asapersson | 35151f3 | 2016-05-02 23:44:01 -0700 | [diff] [blame] | 293 | // Callback, used to notify an observer whenever a packet is sent to the |
| 294 | // transport. |
| 295 | // TODO(asapersson): This class will remove the need for SendSideDelayObserver. |
| 296 | // Remove SendSideDelayObserver once possible. |
| 297 | class SendPacketObserver { |
| 298 | public: |
| 299 | virtual ~SendPacketObserver() {} |
| 300 | virtual void OnSendPacket(uint16_t packet_id, |
| 301 | int64_t capture_time_ms, |
| 302 | uint32_t ssrc) = 0; |
| 303 | }; |
| 304 | |
michaelt | 4da3044 | 2016-11-17 01:38:43 -0800 | [diff] [blame] | 305 | // Callback, used to notify an observer when the overhead per packet |
| 306 | // has changed. |
| 307 | class OverheadObserver { |
| 308 | public: |
| 309 | virtual ~OverheadObserver() = default; |
| 310 | virtual void OnOverheadChanged(size_t overhead_bytes_per_packet) = 0; |
| 311 | }; |
| 312 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 313 | // ================================================================== |
| 314 | // Voice specific types |
| 315 | // ================================================================== |
| 316 | |
| 317 | // Each codec supported can be described by this structure. |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 318 | struct CodecInst { |
| 319 | int pltype; |
| 320 | char plname[RTP_PAYLOAD_NAME_SIZE]; |
| 321 | int plfreq; |
| 322 | int pacsize; |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 323 | size_t channels; |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 324 | int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file! |
| 325 | |
| 326 | bool operator==(const CodecInst& other) const { |
| 327 | return pltype == other.pltype && |
| 328 | (STR_CASE_CMP(plname, other.plname) == 0) && |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 329 | plfreq == other.plfreq && pacsize == other.pacsize && |
| 330 | channels == other.channels && rate == other.rate; |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 331 | } |
| 332 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 333 | bool operator!=(const CodecInst& other) const { return !(*this == other); } |
kwiberg | 5bf4e08 | 2016-12-19 06:04:04 -0800 | [diff] [blame] | 334 | |
| 335 | friend std::ostream& operator<<(std::ostream& os, const CodecInst& ci) { |
| 336 | os << "{pltype: " << ci.pltype; |
| 337 | os << ", plname: " << ci.plname; |
| 338 | os << ", plfreq: " << ci.plfreq; |
| 339 | os << ", pacsize: " << ci.pacsize; |
| 340 | os << ", channels: " << ci.channels; |
| 341 | os << ", rate: " << ci.rate << "}"; |
| 342 | return os; |
| 343 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 344 | }; |
| 345 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 346 | // RTP |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 347 | enum { kRtpCsrcSize = 15 }; // RFC 3550 page 13 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 348 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 349 | enum PayloadFrequencies { |
| 350 | kFreq8000Hz = 8000, |
| 351 | kFreq16000Hz = 16000, |
| 352 | kFreq32000Hz = 32000 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 353 | }; |
| 354 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 355 | // Degree of bandwidth reduction. |
| 356 | enum VadModes { |
| 357 | kVadConventional = 0, // lowest reduction |
| 358 | kVadAggressiveLow, |
| 359 | kVadAggressiveMid, |
| 360 | kVadAggressiveHigh // highest reduction |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 361 | }; |
| 362 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 363 | // NETEQ statistics. |
| 364 | struct NetworkStatistics { |
| 365 | // current jitter buffer size in ms |
| 366 | uint16_t currentBufferSize; |
| 367 | // preferred (optimal) buffer size in ms |
| 368 | uint16_t preferredBufferSize; |
| 369 | // adding extra delay due to "peaky jitter" |
| 370 | bool jitterPeaksFound; |
Steve Anton | 2dbc69f | 2017-08-24 17:15:13 -0700 | [diff] [blame] | 371 | // Total number of audio samples received, including synthesized samples. |
| 372 | // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalsamplesreceived |
| 373 | uint64_t totalSamplesReceived; |
| 374 | // Total number of inbound audio samples that are based on synthesized data to |
| 375 | // conceal packet loss. |
| 376 | // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-concealedsamples |
| 377 | uint64_t concealedSamples; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 378 | // Loss rate (network + late); fraction between 0 and 1, scaled to Q14. |
| 379 | uint16_t currentPacketLossRate; |
| 380 | // Late loss rate; fraction between 0 and 1, scaled to Q14. |
minyue-webrtc | 0c3ca75 | 2017-08-23 15:59:38 +0200 | [diff] [blame] | 381 | union { |
| 382 | RTC_DEPRECATED uint16_t currentDiscardRate; |
| 383 | }; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 384 | // fraction (of original stream) of synthesized audio inserted through |
| 385 | // expansion (in Q14) |
| 386 | uint16_t currentExpandRate; |
| 387 | // fraction (of original stream) of synthesized speech inserted through |
| 388 | // expansion (in Q14) |
| 389 | uint16_t currentSpeechExpandRate; |
| 390 | // fraction of synthesized speech inserted through pre-emptive expansion |
| 391 | // (in Q14) |
| 392 | uint16_t currentPreemptiveRate; |
| 393 | // fraction of data removed through acceleration (in Q14) |
| 394 | uint16_t currentAccelerateRate; |
| 395 | // fraction of data coming from secondary decoding (in Q14) |
| 396 | uint16_t currentSecondaryDecodedRate; |
minyue-webrtc | 0e320ec | 2017-08-28 13:51:27 +0200 | [diff] [blame] | 397 | // Fraction of secondary data, including FEC and RED, that is discarded (in |
| 398 | // Q14). Discarding of secondary data can be caused by the reception of the |
| 399 | // primary data, obsoleting the secondary data. It can also be caused by early |
| 400 | // or late arrival of secondary data. |
minyue-webrtc | 0c3ca75 | 2017-08-23 15:59:38 +0200 | [diff] [blame] | 401 | uint16_t currentSecondaryDiscardedRate; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 402 | // clock-drift in parts-per-million (negative or positive) |
| 403 | int32_t clockDriftPPM; |
| 404 | // average packet waiting time in the jitter buffer (ms) |
| 405 | int meanWaitingTimeMs; |
| 406 | // median packet waiting time in the jitter buffer (ms) |
| 407 | int medianWaitingTimeMs; |
| 408 | // min packet waiting time in the jitter buffer (ms) |
| 409 | int minWaitingTimeMs; |
| 410 | // max packet waiting time in the jitter buffer (ms) |
| 411 | int maxWaitingTimeMs; |
| 412 | // added samples in off mode due to packet loss |
| 413 | size_t addedSamples; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 414 | }; |
| 415 | |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 416 | // Statistics for calls to AudioCodingModule::PlayoutData10Ms(). |
| 417 | struct AudioDecodingCallStats { |
| 418 | AudioDecodingCallStats() |
| 419 | : calls_to_silence_generator(0), |
| 420 | calls_to_neteq(0), |
| 421 | decoded_normal(0), |
| 422 | decoded_plc(0), |
| 423 | decoded_cng(0), |
henrik.lundin | 6348978 | 2016-09-20 01:47:12 -0700 | [diff] [blame] | 424 | decoded_plc_cng(0), |
| 425 | decoded_muted_output(0) {} |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 426 | |
| 427 | int calls_to_silence_generator; // Number of calls where silence generated, |
| 428 | // and NetEq was disengaged from decoding. |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 429 | int calls_to_neteq; // Number of calls to NetEq. |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 430 | int decoded_normal; // Number of calls where audio RTP packet decoded. |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 431 | int decoded_plc; // Number of calls resulted in PLC. |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 432 | int decoded_cng; // Number of calls where comfort noise generated due to DTX. |
| 433 | 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] | 434 | 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] | 435 | }; |
| 436 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 437 | // ================================================================== |
| 438 | // Video specific types |
| 439 | // ================================================================== |
| 440 | |
nisse | eb44b39 | 2017-04-28 07:18:05 -0700 | [diff] [blame] | 441 | // TODO(nisse): Delete, and switch to fourcc values everywhere? |
| 442 | // Supported video types. |
| 443 | enum class VideoType { |
| 444 | kUnknown, |
| 445 | kI420, |
| 446 | kIYUV, |
| 447 | kRGB24, |
| 448 | kABGR, |
| 449 | kARGB, |
| 450 | kARGB4444, |
| 451 | kRGB565, |
| 452 | kARGB1555, |
| 453 | kYUY2, |
| 454 | kYV12, |
| 455 | kUYVY, |
| 456 | kMJPEG, |
| 457 | kNV21, |
| 458 | kNV12, |
| 459 | kBGRA, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 460 | }; |
| 461 | |
| 462 | // Video codec |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 463 | enum { kPayloadNameSize = 32 }; |
| 464 | enum { kMaxSimulcastStreams = 4 }; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 465 | enum { kMaxSpatialLayers = 5 }; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 466 | enum { kMaxTemporalStreams = 4 }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 467 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 468 | enum VideoCodecComplexity { |
| 469 | kComplexityNormal = 0, |
| 470 | kComplexityHigh = 1, |
| 471 | kComplexityHigher = 2, |
| 472 | kComplexityMax = 3 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 473 | }; |
| 474 | |
stefan@webrtc.org | efd0a48 | 2011-12-29 10:12:35 +0000 | [diff] [blame] | 475 | enum VP8ResilienceMode { |
| 476 | kResilienceOff, // The stream produced by the encoder requires a |
| 477 | // recovery frame (typically a key frame) to be |
| 478 | // decodable after a packet loss. |
| 479 | kResilientStream, // A stream produced by the encoder is resilient to |
| 480 | // packet losses, but packets within a frame subsequent |
| 481 | // to a loss can't be decoded. |
| 482 | kResilientFrames // Same as kResilientStream but with added resilience |
| 483 | // within a frame. |
| 484 | }; |
| 485 | |
Peter Boström | 7b971e7 | 2016-01-19 16:26:16 +0100 | [diff] [blame] | 486 | class TemporalLayersFactory; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 487 | // VP8 specific |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 488 | struct VideoCodecVP8 { |
nisse | 3257b16 | 2017-03-21 01:54:13 -0700 | [diff] [blame] | 489 | // TODO(nisse): Unused, delete? |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 490 | bool pictureLossIndicationOn; |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 491 | VideoCodecComplexity complexity; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 492 | VP8ResilienceMode resilience; |
| 493 | unsigned char numberOfTemporalLayers; |
| 494 | bool denoisingOn; |
| 495 | bool errorConcealmentOn; |
| 496 | bool automaticResizeOn; |
| 497 | bool frameDroppingOn; |
| 498 | int keyFrameInterval; |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 499 | TemporalLayersFactory* tl_factory; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 500 | }; |
| 501 | |
asapersson | a9455ab | 2015-07-31 06:10:09 -0700 | [diff] [blame] | 502 | // VP9 specific. |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 503 | struct VideoCodecVP9 { |
| 504 | VideoCodecComplexity complexity; |
asapersson | 15dcb38 | 2017-06-08 02:55:08 -0700 | [diff] [blame] | 505 | bool resilienceOn; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 506 | unsigned char numberOfTemporalLayers; |
| 507 | bool denoisingOn; |
| 508 | bool frameDroppingOn; |
| 509 | int keyFrameInterval; |
| 510 | bool adaptiveQpMode; |
| 511 | bool automaticResizeOn; |
| 512 | unsigned char numberOfSpatialLayers; |
| 513 | bool flexibleMode; |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 514 | }; |
| 515 | |
magjed | e69a1a9 | 2016-11-25 10:06:31 -0800 | [diff] [blame] | 516 | // TODO(magjed): Move this and other H264 related classes out to their own file. |
| 517 | namespace H264 { |
| 518 | |
| 519 | enum Profile { |
| 520 | kProfileConstrainedBaseline, |
| 521 | kProfileBaseline, |
| 522 | kProfileMain, |
| 523 | kProfileConstrainedHigh, |
| 524 | kProfileHigh, |
| 525 | }; |
| 526 | |
| 527 | } // namespace H264 |
| 528 | |
stefan@webrtc.org | b9f5453 | 2014-07-04 12:42:07 +0000 | [diff] [blame] | 529 | // H264 specific. |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 530 | struct VideoCodecH264 { |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 531 | bool frameDroppingOn; |
| 532 | int keyFrameInterval; |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 533 | // These are NULL/0 if not externally negotiated. |
| 534 | const uint8_t* spsData; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 535 | size_t spsLen; |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 536 | const uint8_t* ppsData; |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 537 | size_t ppsLen; |
magjed | e69a1a9 | 2016-11-25 10:06:31 -0800 | [diff] [blame] | 538 | H264::Profile profile; |
stefan@webrtc.org | b9f5453 | 2014-07-04 12:42:07 +0000 | [diff] [blame] | 539 | }; |
| 540 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 541 | // Video codec types |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 542 | enum VideoCodecType { |
| 543 | kVideoCodecVP8, |
| 544 | kVideoCodecVP9, |
| 545 | kVideoCodecH264, |
| 546 | kVideoCodecI420, |
| 547 | kVideoCodecRED, |
| 548 | kVideoCodecULPFEC, |
brandtr | 87d7d77 | 2016-11-07 03:03:41 -0800 | [diff] [blame] | 549 | kVideoCodecFlexfec, |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 550 | kVideoCodecGeneric, |
| 551 | kVideoCodecUnknown |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 552 | }; |
| 553 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 554 | // Translates from name of codec to codec type and vice versa. |
kthelgason | 1cdddc9 | 2017-08-24 03:52:48 -0700 | [diff] [blame] | 555 | const char* CodecTypeToPayloadString(VideoCodecType type); |
| 556 | VideoCodecType PayloadStringToCodecType(const std::string& name); |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 557 | |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 +0000 | [diff] [blame] | 558 | union VideoCodecUnion { |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 559 | VideoCodecVP8 VP8; |
| 560 | VideoCodecVP9 VP9; |
| 561 | VideoCodecH264 H264; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 562 | }; |
| 563 | |
phoglund@webrtc.org | 8bfee84 | 2012-02-17 09:32:48 +0000 | [diff] [blame] | 564 | // Simulcast is when the same stream is encoded multiple times with different |
| 565 | // settings such as resolution. |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 566 | struct SimulcastStream { |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 567 | unsigned short width; |
| 568 | unsigned short height; |
| 569 | unsigned char numberOfTemporalLayers; |
| 570 | unsigned int maxBitrate; // kilobits/sec. |
| 571 | unsigned int targetBitrate; // kilobits/sec. |
| 572 | unsigned int minBitrate; // kilobits/sec. |
| 573 | unsigned int qpMax; // minimum quality |
pwestin@webrtc.org | 1da1ce0 | 2011-10-13 15:19:55 +0000 | [diff] [blame] | 574 | }; |
| 575 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 576 | struct SpatialLayer { |
| 577 | int scaling_factor_num; |
| 578 | int scaling_factor_den; |
| 579 | int target_bitrate_bps; |
| 580 | // TODO(ivica): Add max_quantizer and min_quantizer? |
| 581 | }; |
| 582 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 583 | enum VideoCodecMode { kRealtimeVideo, kScreensharing }; |
stefan@webrtc.org | eb91792 | 2013-02-18 14:40:18 +0000 | [diff] [blame] | 584 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 585 | // Common video codec properties |
hta | 257dc39 | 2016-10-25 09:05:06 -0700 | [diff] [blame] | 586 | class VideoCodec { |
| 587 | public: |
| 588 | VideoCodec(); |
| 589 | |
| 590 | // Public variables. TODO(hta): Make them private with accessors. |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 591 | VideoCodecType codecType; |
| 592 | char plName[kPayloadNameSize]; |
| 593 | unsigned char plType; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 594 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 595 | unsigned short width; |
| 596 | unsigned short height; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 597 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 598 | unsigned int startBitrate; // kilobits/sec. |
| 599 | unsigned int maxBitrate; // kilobits/sec. |
| 600 | unsigned int minBitrate; // kilobits/sec. |
| 601 | unsigned int targetBitrate; // kilobits/sec. |
pbos@webrtc.org | 3c412b2 | 2014-03-24 12:36:52 +0000 | [diff] [blame] | 602 | |
Stefan Holmer | 144475b | 2017-03-10 15:08:26 +0100 | [diff] [blame] | 603 | uint32_t maxFramerate; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 604 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 605 | unsigned int qpMax; |
| 606 | unsigned char numberOfSimulcastStreams; |
| 607 | SimulcastStream simulcastStream[kMaxSimulcastStreams]; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 608 | SpatialLayer spatialLayers[kMaxSpatialLayers]; |
stefan@webrtc.org | eb91792 | 2013-02-18 14:40:18 +0000 | [diff] [blame] | 609 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 610 | VideoCodecMode mode; |
| 611 | bool expect_encode_from_texture; |
andresp@webrtc.org | 185bae4 | 2013-05-14 08:02:25 +0000 | [diff] [blame] | 612 | |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 613 | // Timing frames configuration. There is delay of delay_ms between two |
| 614 | // consequent timing frames, excluding outliers. Frame is always made a |
| 615 | // timing frame if it's at least outlier_ratio in percent of "ideal" average |
| 616 | // frame given bitrate and framerate, i.e. if it's bigger than |
| 617 | // |outlier_ratio / 100.0 * bitrate_bps / fps| in bits. This way, timing |
| 618 | // frames will not be sent too often usually. Yet large frames will always |
| 619 | // have timing information for debug purposes because they are more likely to |
| 620 | // cause extra delays. |
| 621 | struct TimingFrameTriggerThresholds { |
| 622 | int64_t delay_ms; |
| 623 | uint16_t outlier_ratio_percent; |
| 624 | } timing_frame_thresholds; |
| 625 | |
Peter Boström | 7b971e7 | 2016-01-19 16:26:16 +0100 | [diff] [blame] | 626 | bool operator==(const VideoCodec& other) const = delete; |
| 627 | bool operator!=(const VideoCodec& other) const = delete; |
hta | 257dc39 | 2016-10-25 09:05:06 -0700 | [diff] [blame] | 628 | |
| 629 | // Accessors for codec specific information. |
| 630 | // There is a const version of each that returns a reference, |
| 631 | // and a non-const version that returns a pointer, in order |
| 632 | // to allow modification of the parameters. |
| 633 | VideoCodecVP8* VP8(); |
| 634 | const VideoCodecVP8& VP8() const; |
| 635 | VideoCodecVP9* VP9(); |
| 636 | const VideoCodecVP9& VP9() const; |
| 637 | VideoCodecH264* H264(); |
| 638 | const VideoCodecH264& H264() const; |
| 639 | |
hta | 527d347 | 2016-11-16 23:23:04 -0800 | [diff] [blame] | 640 | private: |
hta | 257dc39 | 2016-10-25 09:05:06 -0700 | [diff] [blame] | 641 | // TODO(hta): Consider replacing the union with a pointer type. |
| 642 | // This will allow removing the VideoCodec* types from this file. |
hta | 527d347 | 2016-11-16 23:23:04 -0800 | [diff] [blame] | 643 | VideoCodecUnion codec_specific_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 644 | }; |
astor@webrtc.org | bd7aeba | 2012-06-26 10:47:04 +0000 | [diff] [blame] | 645 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 646 | class BitrateAllocation { |
| 647 | public: |
| 648 | static const uint32_t kMaxBitrateBps; |
| 649 | BitrateAllocation(); |
| 650 | |
| 651 | bool SetBitrate(size_t spatial_index, |
| 652 | size_t temporal_index, |
| 653 | uint32_t bitrate_bps); |
| 654 | |
| 655 | uint32_t GetBitrate(size_t spatial_index, size_t temporal_index) const; |
| 656 | |
| 657 | // Get the sum of all the temporal layer for a specific spatial layer. |
| 658 | uint32_t GetSpatialLayerSum(size_t spatial_index) const; |
| 659 | |
| 660 | uint32_t get_sum_bps() const { return sum_; } // Sum of all bitrates. |
| 661 | uint32_t get_sum_kbps() const { return (sum_ + 500) / 1000; } |
| 662 | |
| 663 | inline bool operator==(const BitrateAllocation& other) const { |
| 664 | return memcmp(bitrates_, other.bitrates_, sizeof(bitrates_)) == 0; |
| 665 | } |
| 666 | inline bool operator!=(const BitrateAllocation& other) const { |
| 667 | return !(*this == other); |
| 668 | } |
| 669 | |
sprang | d0fc37a | 2017-06-22 05:40:25 -0700 | [diff] [blame] | 670 | // Expensive, please use only in tests. |
| 671 | std::string ToString() const; |
| 672 | std::ostream& operator<<(std::ostream& os) const; |
| 673 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 674 | private: |
| 675 | uint32_t sum_; |
| 676 | uint32_t bitrates_[kMaxSpatialLayers][kMaxTemporalStreams]; |
| 677 | }; |
| 678 | |
stefan | 64c0a0a | 2015-11-27 01:02:31 -0800 | [diff] [blame] | 679 | // Bandwidth over-use detector options. These are used to drive |
| 680 | // experimentation with bandwidth estimation parameters. |
| 681 | // See modules/remote_bitrate_estimator/overuse_detector.h |
terelius | 84f83f8 | 2016-12-27 10:43:01 -0800 | [diff] [blame] | 682 | // TODO(terelius): This is only used in overuse_estimator.cc, and only in the |
| 683 | // default constructed state. Can we move the relevant variables into that |
| 684 | // class and delete this? See also disabled warning at line 27 |
stefan | 64c0a0a | 2015-11-27 01:02:31 -0800 | [diff] [blame] | 685 | struct OverUseDetectorOptions { |
| 686 | OverUseDetectorOptions() |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 687 | : initial_slope(8.0 / 512.0), |
stefan | 64c0a0a | 2015-11-27 01:02:31 -0800 | [diff] [blame] | 688 | initial_offset(0), |
| 689 | initial_e(), |
| 690 | initial_process_noise(), |
| 691 | initial_avg_noise(0.0), |
| 692 | initial_var_noise(50) { |
| 693 | initial_e[0][0] = 100; |
| 694 | initial_e[1][1] = 1e-1; |
| 695 | initial_e[0][1] = initial_e[1][0] = 0; |
| 696 | initial_process_noise[0] = 1e-13; |
stefan | 1069cac | 2016-03-10 05:13:21 -0800 | [diff] [blame] | 697 | initial_process_noise[1] = 1e-3; |
stefan | 64c0a0a | 2015-11-27 01:02:31 -0800 | [diff] [blame] | 698 | } |
| 699 | double initial_slope; |
| 700 | double initial_offset; |
| 701 | double initial_e[2][2]; |
| 702 | double initial_process_noise[2]; |
| 703 | double initial_avg_noise; |
| 704 | double initial_var_noise; |
| 705 | }; |
| 706 | |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 707 | // This structure will have the information about when packet is actually |
| 708 | // received by socket. |
| 709 | struct PacketTime { |
henrike@webrtc.org | 82d3cb6 | 2014-04-29 17:50:47 +0000 | [diff] [blame] | 710 | PacketTime() : timestamp(-1), not_before(-1) {} |
| 711 | PacketTime(int64_t timestamp, int64_t not_before) |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 712 | : timestamp(timestamp), not_before(not_before) {} |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 713 | |
henrike@webrtc.org | 82d3cb6 | 2014-04-29 17:50:47 +0000 | [diff] [blame] | 714 | int64_t timestamp; // Receive time after socket delivers the data. |
| 715 | int64_t not_before; // Earliest possible time the data could have arrived, |
| 716 | // indicating the potential error in the |timestamp| |
| 717 | // value,in case the system is busy. |
| 718 | // For example, the time of the last select() call. |
| 719 | // If unknown, this value will be set to zero. |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 720 | }; |
| 721 | |
isheriff | 6b4b5f3 | 2016-06-08 00:24:21 -0700 | [diff] [blame] | 722 | // Minimum and maximum playout delay values from capture to render. |
| 723 | // These are best effort values. |
| 724 | // |
| 725 | // A value < 0 indicates no change from previous valid value. |
| 726 | // |
| 727 | // min = max = 0 indicates that the receiver should try and render |
| 728 | // frame as soon as possible. |
| 729 | // |
| 730 | // min = x, max = y indicates that the receiver is free to adapt |
| 731 | // in the range (x, y) based on network jitter. |
| 732 | // |
| 733 | // Note: Given that this gets embedded in a union, it is up-to the owner to |
| 734 | // initialize these values. |
| 735 | struct PlayoutDelay { |
| 736 | int min_ms; |
| 737 | int max_ms; |
| 738 | }; |
| 739 | |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 740 | // Class to represent the value of RTP header extensions that are |
| 741 | // variable-length strings (e.g., RtpStreamId and RtpMid). |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 742 | // Unlike std::string, it can be copied with memcpy and cleared with memset. |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 743 | // |
| 744 | // Empty value represents unset header extension (use empty() to query). |
| 745 | class StringRtpHeaderExtension { |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 746 | public: |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 747 | // String RTP header extensions are limited to 16 bytes because it is the |
| 748 | // maximum length that can be encoded with one-byte header extensions. |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 749 | static constexpr size_t kMaxSize = 16; |
| 750 | |
eladalon | d0244c2 | 2017-06-08 04:19:13 -0700 | [diff] [blame] | 751 | static bool IsLegalName(rtc::ArrayView<const char> name); |
| 752 | |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 753 | StringRtpHeaderExtension() { value_[0] = 0; } |
| 754 | explicit StringRtpHeaderExtension(rtc::ArrayView<const char> value) { |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 755 | Set(value.data(), value.size()); |
| 756 | } |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 757 | StringRtpHeaderExtension(const StringRtpHeaderExtension&) = default; |
| 758 | StringRtpHeaderExtension& operator=(const StringRtpHeaderExtension&) = |
| 759 | default; |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 760 | |
| 761 | bool empty() const { return value_[0] == 0; } |
| 762 | const char* data() const { return value_; } |
| 763 | size_t size() const { return strnlen(value_, kMaxSize); } |
| 764 | |
| 765 | void Set(rtc::ArrayView<const uint8_t> value) { |
| 766 | Set(reinterpret_cast<const char*>(value.data()), value.size()); |
| 767 | } |
| 768 | void Set(const char* data, size_t size); |
| 769 | |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 770 | friend bool operator==(const StringRtpHeaderExtension& lhs, |
| 771 | const StringRtpHeaderExtension& rhs) { |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 772 | return strncmp(lhs.value_, rhs.value_, kMaxSize) == 0; |
| 773 | } |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 774 | friend bool operator!=(const StringRtpHeaderExtension& lhs, |
| 775 | const StringRtpHeaderExtension& rhs) { |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 776 | return !(lhs == rhs); |
| 777 | } |
| 778 | |
| 779 | private: |
| 780 | char value_[kMaxSize]; |
| 781 | }; |
| 782 | |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 783 | // StreamId represents RtpStreamId which is a string. |
| 784 | typedef StringRtpHeaderExtension StreamId; |
| 785 | |
| 786 | // Mid represents RtpMid which is a string. |
| 787 | typedef StringRtpHeaderExtension Mid; |
| 788 | |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 +0000 | [diff] [blame] | 789 | struct RTPHeaderExtension { |
sprang@webrtc.org | 3093390 | 2015-03-17 14:33:12 +0000 | [diff] [blame] | 790 | RTPHeaderExtension(); |
eladalon | 98b1b7d | 2017-09-11 08:48:26 -0700 | [diff] [blame] | 791 | RTPHeaderExtension(const RTPHeaderExtension& other); |
| 792 | RTPHeaderExtension& operator=(const RTPHeaderExtension& other); |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 +0000 | [diff] [blame] | 793 | |
| 794 | bool hasTransmissionTimeOffset; |
| 795 | int32_t transmissionTimeOffset; |
| 796 | bool hasAbsoluteSendTime; |
| 797 | uint32_t absoluteSendTime; |
sprang@webrtc.org | 3093390 | 2015-03-17 14:33:12 +0000 | [diff] [blame] | 798 | bool hasTransportSequenceNumber; |
| 799 | uint16_t transportSequenceNumber; |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 +0000 | [diff] [blame] | 800 | |
| 801 | // Audio Level includes both level in dBov and voiced/unvoiced bit. See: |
| 802 | // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/ |
| 803 | bool hasAudioLevel; |
Minyue | 4cee419 | 2015-08-10 15:08:36 +0200 | [diff] [blame] | 804 | bool voiceActivity; |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 +0000 | [diff] [blame] | 805 | uint8_t audioLevel; |
guoweis@webrtc.org | 4536289 | 2015-03-04 22:55:15 +0000 | [diff] [blame] | 806 | |
| 807 | // For Coordination of Video Orientation. See |
| 808 | // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ |
| 809 | // ts_126114v120700p.pdf |
| 810 | bool hasVideoRotation; |
magjed | 71eb61c | 2016-09-08 03:24:58 -0700 | [diff] [blame] | 811 | VideoRotation videoRotation; |
isheriff | 6b4b5f3 | 2016-06-08 00:24:21 -0700 | [diff] [blame] | 812 | |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 813 | // TODO(ilnik): Refactor this and one above to be rtc::Optional() and remove |
| 814 | // a corresponding bool flag. |
| 815 | bool hasVideoContentType; |
| 816 | VideoContentType videoContentType; |
| 817 | |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 818 | bool has_video_timing; |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 819 | VideoSendTiming video_timing; |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 820 | |
isheriff | 6b4b5f3 | 2016-06-08 00:24:21 -0700 | [diff] [blame] | 821 | PlayoutDelay playout_delay = {-1, -1}; |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 822 | |
| 823 | // For identification of a stream when ssrc is not signaled. See |
| 824 | // https://tools.ietf.org/html/draft-ietf-avtext-rid-09 |
| 825 | // TODO(danilchap): Update url from draft to release version. |
| 826 | StreamId stream_id; |
| 827 | StreamId repaired_stream_id; |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 828 | |
| 829 | // For identifying the media section used to interpret this RTP packet. See |
| 830 | // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-38 |
| 831 | Mid mid; |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 +0000 | [diff] [blame] | 832 | }; |
| 833 | |
| 834 | struct RTPHeader { |
kwiberg@webrtc.org | ac2d27d | 2015-02-26 13:59:22 +0000 | [diff] [blame] | 835 | RTPHeader(); |
eladalon | 98b1b7d | 2017-09-11 08:48:26 -0700 | [diff] [blame] | 836 | RTPHeader(const RTPHeader& other); |
| 837 | RTPHeader& operator=(const RTPHeader& other); |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 +0000 | [diff] [blame] | 838 | |
| 839 | bool markerBit; |
| 840 | uint8_t payloadType; |
| 841 | uint16_t sequenceNumber; |
| 842 | uint32_t timestamp; |
| 843 | uint32_t ssrc; |
| 844 | uint8_t numCSRCs; |
| 845 | uint32_t arrOfCSRCs[kRtpCsrcSize]; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 846 | size_t paddingLength; |
| 847 | size_t headerLength; |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 +0000 | [diff] [blame] | 848 | int payload_type_frequency; |
| 849 | RTPHeaderExtension extension; |
| 850 | }; |
| 851 | |
asapersson@webrtc.org | 4414939 | 2015-02-04 08:34:47 +0000 | [diff] [blame] | 852 | struct RtpPacketCounter { |
| 853 | RtpPacketCounter() |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 854 | : header_bytes(0), payload_bytes(0), padding_bytes(0), packets(0) {} |
asapersson@webrtc.org | 4414939 | 2015-02-04 08:34:47 +0000 | [diff] [blame] | 855 | |
| 856 | void Add(const RtpPacketCounter& other) { |
| 857 | header_bytes += other.header_bytes; |
| 858 | payload_bytes += other.payload_bytes; |
| 859 | padding_bytes += other.padding_bytes; |
| 860 | packets += other.packets; |
| 861 | } |
| 862 | |
Erik Språng | 22c2b48 | 2016-03-01 09:40:42 +0100 | [diff] [blame] | 863 | void Subtract(const RtpPacketCounter& other) { |
kwiberg | b890c95c | 2016-11-29 05:30:40 -0800 | [diff] [blame] | 864 | RTC_DCHECK_GE(header_bytes, other.header_bytes); |
Erik Språng | 22c2b48 | 2016-03-01 09:40:42 +0100 | [diff] [blame] | 865 | header_bytes -= other.header_bytes; |
kwiberg | b890c95c | 2016-11-29 05:30:40 -0800 | [diff] [blame] | 866 | RTC_DCHECK_GE(payload_bytes, other.payload_bytes); |
Erik Språng | 22c2b48 | 2016-03-01 09:40:42 +0100 | [diff] [blame] | 867 | payload_bytes -= other.payload_bytes; |
kwiberg | b890c95c | 2016-11-29 05:30:40 -0800 | [diff] [blame] | 868 | RTC_DCHECK_GE(padding_bytes, other.padding_bytes); |
Erik Språng | 22c2b48 | 2016-03-01 09:40:42 +0100 | [diff] [blame] | 869 | padding_bytes -= other.padding_bytes; |
kwiberg | b890c95c | 2016-11-29 05:30:40 -0800 | [diff] [blame] | 870 | RTC_DCHECK_GE(packets, other.packets); |
Erik Språng | 22c2b48 | 2016-03-01 09:40:42 +0100 | [diff] [blame] | 871 | packets -= other.packets; |
| 872 | } |
| 873 | |
asapersson@webrtc.org | 4414939 | 2015-02-04 08:34:47 +0000 | [diff] [blame] | 874 | void AddPacket(size_t packet_length, const RTPHeader& header) { |
| 875 | ++packets; |
| 876 | header_bytes += header.headerLength; |
| 877 | padding_bytes += header.paddingLength; |
| 878 | payload_bytes += |
| 879 | packet_length - (header.headerLength + header.paddingLength); |
| 880 | } |
| 881 | |
| 882 | size_t TotalBytes() const { |
| 883 | return header_bytes + payload_bytes + padding_bytes; |
| 884 | } |
| 885 | |
| 886 | size_t header_bytes; // Number of bytes used by RTP headers. |
| 887 | size_t payload_bytes; // Payload bytes, excluding RTP headers and padding. |
| 888 | size_t padding_bytes; // Number of padding bytes. |
| 889 | uint32_t packets; // Number of packets. |
| 890 | }; |
| 891 | |
| 892 | // Data usage statistics for a (rtp) stream. |
| 893 | struct StreamDataCounters { |
kwiberg@webrtc.org | ac2d27d | 2015-02-26 13:59:22 +0000 | [diff] [blame] | 894 | StreamDataCounters(); |
asapersson@webrtc.org | 4414939 | 2015-02-04 08:34:47 +0000 | [diff] [blame] | 895 | |
| 896 | void Add(const StreamDataCounters& other) { |
| 897 | transmitted.Add(other.transmitted); |
| 898 | retransmitted.Add(other.retransmitted); |
| 899 | fec.Add(other.fec); |
| 900 | if (other.first_packet_time_ms != -1 && |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 901 | (other.first_packet_time_ms < first_packet_time_ms || |
| 902 | first_packet_time_ms == -1)) { |
asapersson@webrtc.org | 4414939 | 2015-02-04 08:34:47 +0000 | [diff] [blame] | 903 | // Use oldest time. |
| 904 | first_packet_time_ms = other.first_packet_time_ms; |
| 905 | } |
| 906 | } |
| 907 | |
Erik Språng | 22c2b48 | 2016-03-01 09:40:42 +0100 | [diff] [blame] | 908 | void Subtract(const StreamDataCounters& other) { |
| 909 | transmitted.Subtract(other.transmitted); |
| 910 | retransmitted.Subtract(other.retransmitted); |
| 911 | fec.Subtract(other.fec); |
| 912 | if (other.first_packet_time_ms != -1 && |
| 913 | (other.first_packet_time_ms > first_packet_time_ms || |
| 914 | first_packet_time_ms == -1)) { |
| 915 | // Use youngest time. |
| 916 | first_packet_time_ms = other.first_packet_time_ms; |
| 917 | } |
| 918 | } |
| 919 | |
asapersson@webrtc.org | 4414939 | 2015-02-04 08:34:47 +0000 | [diff] [blame] | 920 | int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const { |
| 921 | return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms); |
| 922 | } |
| 923 | |
| 924 | // Returns the number of bytes corresponding to the actual media payload (i.e. |
| 925 | // RTP headers, padding, retransmissions and fec packets are excluded). |
| 926 | // Note this function does not have meaning for an RTX stream. |
| 927 | size_t MediaPayloadBytes() const { |
| 928 | return transmitted.payload_bytes - retransmitted.payload_bytes - |
| 929 | fec.payload_bytes; |
| 930 | } |
| 931 | |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 932 | int64_t first_packet_time_ms; // Time when first packet is sent/received. |
| 933 | RtpPacketCounter transmitted; // Number of transmitted packets/bytes. |
asapersson@webrtc.org | 4414939 | 2015-02-04 08:34:47 +0000 | [diff] [blame] | 934 | RtpPacketCounter retransmitted; // Number of retransmitted packets/bytes. |
solenberg | 634b86e | 2016-09-01 07:54:53 -0700 | [diff] [blame] | 935 | RtpPacketCounter fec; // Number of redundancy packets/bytes. |
asapersson@webrtc.org | 4414939 | 2015-02-04 08:34:47 +0000 | [diff] [blame] | 936 | }; |
| 937 | |
| 938 | // Callback, called whenever byte/packet counts have been updated. |
| 939 | class StreamDataCountersCallback { |
| 940 | public: |
| 941 | virtual ~StreamDataCountersCallback() {} |
| 942 | |
| 943 | virtual void DataCountersUpdated(const StreamDataCounters& counters, |
| 944 | uint32_t ssrc) = 0; |
| 945 | }; |
pbos | da903ea | 2015-10-02 02:36:56 -0700 | [diff] [blame] | 946 | |
| 947 | // RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size |
| 948 | // RTCP mode is described by RFC 5506. |
| 949 | enum class RtcpMode { kOff, kCompound, kReducedSize }; |
| 950 | |
pbos | 1ba8d39 | 2016-05-01 20:18:34 -0700 | [diff] [blame] | 951 | enum NetworkState { |
| 952 | kNetworkUp, |
| 953 | kNetworkDown, |
| 954 | }; |
| 955 | |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 956 | struct RtpKeepAliveConfig final { |
sprang | 168794c | 2017-07-06 04:38:06 -0700 | [diff] [blame] | 957 | // If no packet has been sent for |timeout_interval_ms|, send a keep-alive |
| 958 | // packet. The keep-alive packet is an empty (no payload) RTP packet with a |
| 959 | // payload type of 20 as long as the other end has not negotiated the use of |
| 960 | // this value. If this value has already been negotiated, then some other |
| 961 | // unused static payload type from table 5 of RFC 3551 shall be used and set |
| 962 | // in |payload_type|. |
| 963 | int64_t timeout_interval_ms = -1; |
| 964 | uint8_t payload_type = 20; |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 965 | |
| 966 | bool operator==(const RtpKeepAliveConfig& o) const { |
| 967 | return timeout_interval_ms == o.timeout_interval_ms && |
| 968 | payload_type == o.payload_type; |
| 969 | } |
| 970 | bool operator!=(const RtpKeepAliveConfig& o) const { return !(*this == o); } |
sprang | 168794c | 2017-07-06 04:38:06 -0700 | [diff] [blame] | 971 | }; |
| 972 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 973 | } // namespace webrtc |
andrew@webrtc.org | eda189b | 2013-09-09 17:50:10 +0000 | [diff] [blame] | 974 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 975 | #endif // COMMON_TYPES_H_ |