niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 1 | /* |
phoglund@webrtc.org | 8bfee84 | 2012-02-17 09:32:48 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [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 | |
andrew@webrtc.org | eda189b | 2013-09-09 17:50:10 | [diff] [blame] | 11 | #ifndef WEBRTC_COMMON_TYPES_H_ |
| 12 | #define WEBRTC_COMMON_TYPES_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 13 | |
Erik Språng | 22c2b48 | 2016-03-01 08:40:42 | [diff] [blame] | 14 | #include <assert.h> |
pbos@webrtc.org | f577ae9 | 2014-03-19 08:43:57 | [diff] [blame] | 15 | #include <stddef.h> |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 | [diff] [blame] | 16 | #include <string.h> |
pbos@webrtc.org | 1e92b0a | 2014-05-15 09:35:06 | [diff] [blame] | 17 | |
| 18 | #include <string> |
pbos@webrtc.org | f577ae9 | 2014-03-19 08:43:57 | [diff] [blame] | 19 | #include <vector> |
| 20 | |
andrew@webrtc.org | eda189b | 2013-09-09 17:50:10 | [diff] [blame] | 21 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 22 | |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 | [diff] [blame] | 23 | #if defined(_MSC_VER) |
| 24 | // Disable "new behavior: elements of array will be default initialized" |
| 25 | // warning. Affects OverUseDetectorOptions. |
| 26 | #pragma warning(disable:4351) |
| 27 | #endif |
| 28 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 29 | #ifdef WEBRTC_EXPORT |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 | [diff] [blame] | 30 | #define WEBRTC_DLLEXPORT _declspec(dllexport) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 31 | #elif WEBRTC_DLL |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 | [diff] [blame] | 32 | #define WEBRTC_DLLEXPORT _declspec(dllimport) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 33 | #else |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 | [diff] [blame] | 34 | #define WEBRTC_DLLEXPORT |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 35 | #endif |
| 36 | |
| 37 | #ifndef NULL |
andrew@webrtc.org | 88b8b0d | 2012-08-14 00:05:56 | [diff] [blame] | 38 | #define NULL 0 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 39 | #endif |
| 40 | |
Peter Boström | 8b79b07 | 2016-02-26 15:31:37 | [diff] [blame] | 41 | #define RTP_PAYLOAD_NAME_SIZE 32u |
henrika@webrtc.org | f75901f | 2012-01-16 08:45:42 | [diff] [blame] | 42 | |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 | [diff] [blame] | 43 | #if defined(WEBRTC_WIN) || defined(WIN32) |
andrew@webrtc.org | eda189b | 2013-09-09 17:50:10 | [diff] [blame] | 44 | // Compares two strings without regard to case. |
| 45 | #define STR_CASE_CMP(s1, s2) ::_stricmp(s1, s2) |
| 46 | // Compares characters of two strings without regard to case. |
| 47 | #define STR_NCASE_CMP(s1, s2, n) ::_strnicmp(s1, s2, n) |
| 48 | #else |
| 49 | #define STR_CASE_CMP(s1, s2) ::strcasecmp(s1, s2) |
| 50 | #define STR_NCASE_CMP(s1, s2, n) ::strncasecmp(s1, s2, n) |
| 51 | #endif |
| 52 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 53 | namespace webrtc { |
| 54 | |
andresp@webrtc.org | 185bae4 | 2013-05-14 08:02:25 | [diff] [blame] | 55 | class Config; |
| 56 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 57 | class InStream |
| 58 | { |
| 59 | public: |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 | [diff] [blame] | 60 | // Reads |length| bytes from file to |buf|. Returns the number of bytes read |
| 61 | // or -1 on error. |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 | [diff] [blame] | 62 | virtual int Read(void *buf, size_t len) = 0; |
kwiberg@webrtc.org | ac2d27d | 2015-02-26 13:59:22 | [diff] [blame] | 63 | virtual int Rewind(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 64 | virtual ~InStream() {} |
| 65 | protected: |
| 66 | InStream() {} |
| 67 | }; |
| 68 | |
| 69 | class OutStream |
| 70 | { |
| 71 | public: |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 | [diff] [blame] | 72 | // Writes |length| bytes from |buf| to file. The actual writing may happen |
| 73 | // some time later. Call Flush() to force a write. |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 | [diff] [blame] | 74 | virtual bool Write(const void *buf, size_t len) = 0; |
kwiberg@webrtc.org | ac2d27d | 2015-02-26 13:59:22 | [diff] [blame] | 75 | virtual int Rewind(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 76 | virtual ~OutStream() {} |
| 77 | protected: |
| 78 | OutStream() {} |
| 79 | }; |
| 80 | |
| 81 | enum TraceModule |
| 82 | { |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 | [diff] [blame] | 83 | kTraceUndefined = 0, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 84 | // not a module, triggered from the engine code |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 | [diff] [blame] | 85 | kTraceVoice = 0x0001, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 86 | // not a module, triggered from the engine code |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 | [diff] [blame] | 87 | kTraceVideo = 0x0002, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 88 | // not a module, triggered from the utility code |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 | [diff] [blame] | 89 | kTraceUtility = 0x0003, |
| 90 | kTraceRtpRtcp = 0x0004, |
| 91 | kTraceTransport = 0x0005, |
| 92 | kTraceSrtp = 0x0006, |
| 93 | kTraceAudioCoding = 0x0007, |
| 94 | kTraceAudioMixerServer = 0x0008, |
| 95 | kTraceAudioMixerClient = 0x0009, |
| 96 | kTraceFile = 0x000a, |
| 97 | kTraceAudioProcessing = 0x000b, |
| 98 | kTraceVideoCoding = 0x0010, |
| 99 | kTraceVideoMixer = 0x0011, |
| 100 | kTraceAudioDevice = 0x0012, |
| 101 | kTraceVideoRenderer = 0x0014, |
| 102 | kTraceVideoCapture = 0x0015, |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 | [diff] [blame] | 103 | kTraceRemoteBitrateEstimator = 0x0017, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | enum TraceLevel |
| 107 | { |
| 108 | kTraceNone = 0x0000, // no trace |
| 109 | kTraceStateInfo = 0x0001, |
| 110 | kTraceWarning = 0x0002, |
| 111 | kTraceError = 0x0004, |
| 112 | kTraceCritical = 0x0008, |
| 113 | kTraceApiCall = 0x0010, |
| 114 | kTraceDefault = 0x00ff, |
| 115 | |
| 116 | kTraceModuleCall = 0x0020, |
| 117 | kTraceMemory = 0x0100, // memory info |
| 118 | kTraceTimer = 0x0200, // timing info |
| 119 | kTraceStream = 0x0400, // "continuous" stream of data |
| 120 | |
| 121 | // used for debug purposes |
| 122 | kTraceDebug = 0x0800, // debug |
| 123 | kTraceInfo = 0x1000, // debug info |
| 124 | |
andrew@webrtc.org | 655d8f5 | 2012-11-20 07:34:45 | [diff] [blame] | 125 | // Non-verbose level used by LS_INFO of logging.h. Do not use directly. |
| 126 | kTraceTerseInfo = 0x2000, |
| 127 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 128 | kTraceAll = 0xffff |
| 129 | }; |
| 130 | |
| 131 | // External Trace API |
andrew@webrtc.org | 23ec30b | 2012-11-15 05:33:25 | [diff] [blame] | 132 | class TraceCallback { |
| 133 | public: |
| 134 | virtual void Print(TraceLevel level, const char* message, int length) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 135 | |
andrew@webrtc.org | 23ec30b | 2012-11-15 05:33:25 | [diff] [blame] | 136 | protected: |
| 137 | virtual ~TraceCallback() {} |
| 138 | TraceCallback() {} |
| 139 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 140 | |
| 141 | enum FileFormats |
| 142 | { |
| 143 | kFileFormatWavFile = 1, |
| 144 | kFileFormatCompressedFile = 2, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 145 | kFileFormatPreencodedFile = 4, |
| 146 | kFileFormatPcm16kHzFile = 7, |
| 147 | kFileFormatPcm8kHzFile = 8, |
| 148 | kFileFormatPcm32kHzFile = 9 |
| 149 | }; |
| 150 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 151 | enum ProcessingTypes |
| 152 | { |
| 153 | kPlaybackPerChannel = 0, |
| 154 | kPlaybackAllChannelsMixed, |
| 155 | kRecordingPerChannel, |
andrew@webrtc.org | 21ab3ba | 2012-10-19 17:30:56 | [diff] [blame] | 156 | kRecordingAllChannelsMixed, |
| 157 | kRecordingPreprocessing |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 158 | }; |
| 159 | |
pbos | 22993e1 | 2015-10-19 09:39:06 | [diff] [blame] | 160 | enum FrameType { |
| 161 | kEmptyFrame = 0, |
| 162 | kAudioFrameSpeech = 1, |
| 163 | kAudioFrameCN = 2, |
| 164 | kVideoFrameKey = 3, |
| 165 | kVideoFrameDelta = 4, |
sprang@webrtc.org | 71f055f | 2013-12-04 15:09:27 | [diff] [blame] | 166 | }; |
| 167 | |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 | [diff] [blame] | 168 | // Statistics for an RTCP channel |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 | [diff] [blame] | 169 | struct RtcpStatistics { |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 | [diff] [blame] | 170 | RtcpStatistics() |
| 171 | : fraction_lost(0), |
| 172 | cumulative_lost(0), |
| 173 | extended_max_sequence_number(0), |
sprang@webrtc.org | a6ad6e5 | 2013-12-05 09:48:44 | [diff] [blame] | 174 | jitter(0) {} |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 | [diff] [blame] | 175 | |
| 176 | uint8_t fraction_lost; |
| 177 | uint32_t cumulative_lost; |
| 178 | uint32_t extended_max_sequence_number; |
| 179 | uint32_t jitter; |
sprang@webrtc.org | fe5d36b | 2013-10-28 09:21:07 | [diff] [blame] | 180 | }; |
| 181 | |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 | [diff] [blame] | 182 | class RtcpStatisticsCallback { |
| 183 | public: |
| 184 | virtual ~RtcpStatisticsCallback() {} |
| 185 | |
| 186 | virtual void StatisticsUpdated(const RtcpStatistics& statistics, |
| 187 | uint32_t ssrc) = 0; |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 | [diff] [blame] | 188 | virtual void CNameChanged(const char* cname, uint32_t ssrc) = 0; |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 | [diff] [blame] | 189 | }; |
| 190 | |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 | [diff] [blame] | 191 | // Statistics for RTCP packet types. |
| 192 | struct RtcpPacketTypeCounter { |
| 193 | RtcpPacketTypeCounter() |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 | [diff] [blame] | 194 | : first_packet_time_ms(-1), |
| 195 | nack_packets(0), |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 | [diff] [blame] | 196 | fir_packets(0), |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 | [diff] [blame] | 197 | pli_packets(0), |
| 198 | nack_requests(0), |
| 199 | unique_nack_requests(0) {} |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 | [diff] [blame] | 200 | |
| 201 | void Add(const RtcpPacketTypeCounter& other) { |
| 202 | nack_packets += other.nack_packets; |
| 203 | fir_packets += other.fir_packets; |
| 204 | pli_packets += other.pli_packets; |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 | [diff] [blame] | 205 | nack_requests += other.nack_requests; |
| 206 | unique_nack_requests += other.unique_nack_requests; |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 | [diff] [blame] | 207 | if (other.first_packet_time_ms != -1 && |
| 208 | (other.first_packet_time_ms < first_packet_time_ms || |
| 209 | first_packet_time_ms == -1)) { |
| 210 | // Use oldest time. |
| 211 | first_packet_time_ms = other.first_packet_time_ms; |
| 212 | } |
| 213 | } |
| 214 | |
sprang | 07fb9be | 2016-02-24 15:55:00 | [diff] [blame] | 215 | void Subtract(const RtcpPacketTypeCounter& other) { |
| 216 | nack_packets -= other.nack_packets; |
| 217 | fir_packets -= other.fir_packets; |
| 218 | pli_packets -= other.pli_packets; |
| 219 | nack_requests -= other.nack_requests; |
| 220 | unique_nack_requests -= other.unique_nack_requests; |
| 221 | if (other.first_packet_time_ms != -1 && |
| 222 | (other.first_packet_time_ms > first_packet_time_ms || |
| 223 | first_packet_time_ms == -1)) { |
| 224 | // Use youngest time. |
| 225 | first_packet_time_ms = other.first_packet_time_ms; |
| 226 | } |
| 227 | } |
| 228 | |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 | [diff] [blame] | 229 | int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const { |
| 230 | return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms); |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 | [diff] [blame] | 231 | } |
| 232 | |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 | [diff] [blame] | 233 | int UniqueNackRequestsInPercent() const { |
| 234 | if (nack_requests == 0) { |
| 235 | return 0; |
| 236 | } |
| 237 | return static_cast<int>( |
| 238 | (unique_nack_requests * 100.0f / nack_requests) + 0.5f); |
| 239 | } |
| 240 | |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 | [diff] [blame] | 241 | int64_t first_packet_time_ms; // Time when first packet is sent/received. |
| 242 | uint32_t nack_packets; // Number of RTCP NACK packets. |
| 243 | uint32_t fir_packets; // Number of RTCP FIR packets. |
| 244 | uint32_t pli_packets; // Number of RTCP PLI packets. |
| 245 | uint32_t nack_requests; // Number of NACKed RTP packets. |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 | [diff] [blame] | 246 | uint32_t unique_nack_requests; // Number of unique NACKed RTP packets. |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 | [diff] [blame] | 247 | }; |
| 248 | |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 | [diff] [blame] | 249 | class RtcpPacketTypeCounterObserver { |
| 250 | public: |
| 251 | virtual ~RtcpPacketTypeCounterObserver() {} |
| 252 | virtual void RtcpPacketTypesCounterUpdated( |
| 253 | uint32_t ssrc, |
| 254 | const RtcpPacketTypeCounter& packet_counter) = 0; |
| 255 | }; |
| 256 | |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 | [diff] [blame] | 257 | // Rate statistics for a stream. |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 | [diff] [blame] | 258 | struct BitrateStatistics { |
sprang@webrtc.org | 6811b6e | 2013-12-13 09:46:59 | [diff] [blame] | 259 | BitrateStatistics() : bitrate_bps(0), packet_rate(0), timestamp_ms(0) {} |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 | [diff] [blame] | 260 | |
sprang@webrtc.org | 6811b6e | 2013-12-13 09:46:59 | [diff] [blame] | 261 | uint32_t bitrate_bps; // Bitrate in bits per second. |
| 262 | uint32_t packet_rate; // Packet rate in packets per second. |
| 263 | uint64_t timestamp_ms; // Ntp timestamp in ms at time of rate estimation. |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 | [diff] [blame] | 264 | }; |
| 265 | |
| 266 | // Callback, used to notify an observer whenever new rates have been estimated. |
| 267 | class BitrateStatisticsObserver { |
| 268 | public: |
| 269 | virtual ~BitrateStatisticsObserver() {} |
| 270 | |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 | [diff] [blame] | 271 | virtual void Notify(const BitrateStatistics& total_stats, |
| 272 | const BitrateStatistics& retransmit_stats, |
| 273 | uint32_t ssrc) = 0; |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 | [diff] [blame] | 274 | }; |
| 275 | |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 | [diff] [blame] | 276 | struct FrameCounts { |
| 277 | FrameCounts() : key_frames(0), delta_frames(0) {} |
| 278 | int key_frames; |
| 279 | int delta_frames; |
| 280 | }; |
| 281 | |
asapersson@webrtc.org | d08d389 | 2014-12-16 12:03:11 | [diff] [blame] | 282 | // Callback, used to notify an observer whenever frame counts have been updated. |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 | [diff] [blame] | 283 | class FrameCountObserver { |
| 284 | public: |
sprang@webrtc.org | 72964bd | 2013-11-21 09:09:54 | [diff] [blame] | 285 | virtual ~FrameCountObserver() {} |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 | [diff] [blame] | 286 | virtual void FrameCountUpdated(const FrameCounts& frame_counts, |
| 287 | uint32_t ssrc) = 0; |
sprang@webrtc.org | dc50aae | 2013-11-20 16:47:07 | [diff] [blame] | 288 | }; |
| 289 | |
stefan@webrtc.org | 168f23f | 2014-07-11 13:44:02 | [diff] [blame] | 290 | // Callback, used to notify an observer whenever the send-side delay is updated. |
| 291 | class SendSideDelayObserver { |
| 292 | public: |
| 293 | virtual ~SendSideDelayObserver() {} |
| 294 | virtual void SendSideDelayUpdated(int avg_delay_ms, |
| 295 | int max_delay_ms, |
| 296 | uint32_t ssrc) = 0; |
| 297 | }; |
| 298 | |
asapersson | 35151f3 | 2016-05-03 06:44:01 | [diff] [blame] | 299 | // Callback, used to notify an observer whenever a packet is sent to the |
| 300 | // transport. |
| 301 | // TODO(asapersson): This class will remove the need for SendSideDelayObserver. |
| 302 | // Remove SendSideDelayObserver once possible. |
| 303 | class SendPacketObserver { |
| 304 | public: |
| 305 | virtual ~SendPacketObserver() {} |
| 306 | virtual void OnSendPacket(uint16_t packet_id, |
| 307 | int64_t capture_time_ms, |
| 308 | uint32_t ssrc) = 0; |
| 309 | }; |
| 310 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 311 | // ================================================================== |
| 312 | // Voice specific types |
| 313 | // ================================================================== |
| 314 | |
| 315 | // Each codec supported can be described by this structure. |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 | [diff] [blame] | 316 | struct CodecInst { |
| 317 | int pltype; |
| 318 | char plname[RTP_PAYLOAD_NAME_SIZE]; |
| 319 | int plfreq; |
| 320 | int pacsize; |
Peter Kasting | 6955870 | 2016-01-13 00:26:35 | [diff] [blame] | 321 | size_t channels; |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 | [diff] [blame] | 322 | int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file! |
| 323 | |
| 324 | bool operator==(const CodecInst& other) const { |
| 325 | return pltype == other.pltype && |
| 326 | (STR_CASE_CMP(plname, other.plname) == 0) && |
| 327 | plfreq == other.plfreq && |
| 328 | pacsize == other.pacsize && |
| 329 | channels == other.channels && |
| 330 | rate == other.rate; |
| 331 | } |
| 332 | |
| 333 | bool operator!=(const CodecInst& other) const { |
| 334 | return !(*this == other); |
| 335 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 336 | }; |
| 337 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 338 | // RTP |
| 339 | enum {kRtpCsrcSize = 15}; // RFC 3550 page 13 |
| 340 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 341 | enum PayloadFrequencies |
| 342 | { |
| 343 | kFreq8000Hz = 8000, |
| 344 | kFreq16000Hz = 16000, |
| 345 | kFreq32000Hz = 32000 |
| 346 | }; |
| 347 | |
| 348 | enum VadModes // degree of bandwidth reduction |
| 349 | { |
| 350 | kVadConventional = 0, // lowest reduction |
| 351 | kVadAggressiveLow, |
| 352 | kVadAggressiveMid, |
| 353 | kVadAggressiveHigh // highest reduction |
| 354 | }; |
| 355 | |
| 356 | struct NetworkStatistics // NETEQ statistics |
| 357 | { |
| 358 | // current jitter buffer size in ms |
pbos@webrtc.org | 77f6b21 | 2013-05-03 12:02:11 | [diff] [blame] | 359 | uint16_t currentBufferSize; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 360 | // preferred (optimal) buffer size in ms |
pbos@webrtc.org | 77f6b21 | 2013-05-03 12:02:11 | [diff] [blame] | 361 | uint16_t preferredBufferSize; |
henrik.lundin@webrtc.org | d439870 | 2012-01-04 13:09:55 | [diff] [blame] | 362 | // adding extra delay due to "peaky jitter" |
| 363 | bool jitterPeaksFound; |
henrik.lundin@webrtc.org | 8768f16 | 2014-10-09 12:58:45 | [diff] [blame] | 364 | // Loss rate (network + late); fraction between 0 and 1, scaled to Q14. |
pbos@webrtc.org | 77f6b21 | 2013-05-03 12:02:11 | [diff] [blame] | 365 | uint16_t currentPacketLossRate; |
henrik.lundin@webrtc.org | 8768f16 | 2014-10-09 12:58:45 | [diff] [blame] | 366 | // Late loss rate; fraction between 0 and 1, scaled to Q14. |
pbos@webrtc.org | 77f6b21 | 2013-05-03 12:02:11 | [diff] [blame] | 367 | uint16_t currentDiscardRate; |
minyue@webrtc.org | c0bd7be | 2015-02-18 15:24:13 | [diff] [blame] | 368 | // fraction (of original stream) of synthesized audio inserted through |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 369 | // expansion (in Q14) |
pbos@webrtc.org | 77f6b21 | 2013-05-03 12:02:11 | [diff] [blame] | 370 | uint16_t currentExpandRate; |
minyue@webrtc.org | c0bd7be | 2015-02-18 15:24:13 | [diff] [blame] | 371 | // fraction (of original stream) of synthesized speech inserted through |
| 372 | // expansion (in Q14) |
| 373 | uint16_t currentSpeechExpandRate; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 374 | // fraction of synthesized speech inserted through pre-emptive expansion |
| 375 | // (in Q14) |
pbos@webrtc.org | 77f6b21 | 2013-05-03 12:02:11 | [diff] [blame] | 376 | uint16_t currentPreemptiveRate; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 377 | // fraction of data removed through acceleration (in Q14) |
pbos@webrtc.org | 77f6b21 | 2013-05-03 12:02:11 | [diff] [blame] | 378 | uint16_t currentAccelerateRate; |
minyue@webrtc.org | c0bd7be | 2015-02-18 15:24:13 | [diff] [blame] | 379 | // fraction of data coming from secondary decoding (in Q14) |
| 380 | uint16_t currentSecondaryDecodedRate; |
henrik.lundin@webrtc.org | d439870 | 2012-01-04 13:09:55 | [diff] [blame] | 381 | // clock-drift in parts-per-million (negative or positive) |
| 382 | int32_t clockDriftPPM; |
henrik.lundin@webrtc.org | dbba1f9 | 2011-12-20 15:45:05 | [diff] [blame] | 383 | // average packet waiting time in the jitter buffer (ms) |
| 384 | int meanWaitingTimeMs; |
| 385 | // median packet waiting time in the jitter buffer (ms) |
| 386 | int medianWaitingTimeMs; |
henrik.lundin@webrtc.org | 053c799 | 2012-01-12 14:16:44 | [diff] [blame] | 387 | // min packet waiting time in the jitter buffer (ms) |
| 388 | int minWaitingTimeMs; |
henrik.lundin@webrtc.org | dbba1f9 | 2011-12-20 15:45:05 | [diff] [blame] | 389 | // max packet waiting time in the jitter buffer (ms) |
| 390 | int maxWaitingTimeMs; |
roosa@google.com | b8ba4d8 | 2012-12-14 00:06:18 | [diff] [blame] | 391 | // added samples in off mode due to packet loss |
Peter Kasting | dce40cf | 2015-08-24 21:52:23 | [diff] [blame] | 392 | size_t addedSamples; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 393 | }; |
| 394 | |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 | [diff] [blame] | 395 | // Statistics for calls to AudioCodingModule::PlayoutData10Ms(). |
| 396 | struct AudioDecodingCallStats { |
| 397 | AudioDecodingCallStats() |
| 398 | : calls_to_silence_generator(0), |
| 399 | calls_to_neteq(0), |
| 400 | decoded_normal(0), |
| 401 | decoded_plc(0), |
| 402 | decoded_cng(0), |
| 403 | decoded_plc_cng(0) {} |
| 404 | |
| 405 | int calls_to_silence_generator; // Number of calls where silence generated, |
| 406 | // and NetEq was disengaged from decoding. |
| 407 | int calls_to_neteq; // Number of calls to NetEq. |
| 408 | int decoded_normal; // Number of calls where audio RTP packet decoded. |
| 409 | int decoded_plc; // Number of calls resulted in PLC. |
| 410 | int decoded_cng; // Number of calls where comfort noise generated due to DTX. |
| 411 | int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG. |
| 412 | }; |
| 413 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 414 | typedef struct |
| 415 | { |
| 416 | int min; // minumum |
| 417 | int max; // maximum |
| 418 | int average; // average |
| 419 | } StatVal; |
| 420 | |
| 421 | typedef struct // All levels are reported in dBm0 |
| 422 | { |
| 423 | StatVal speech_rx; // long-term speech levels on receiving side |
| 424 | StatVal speech_tx; // long-term speech levels on transmitting side |
| 425 | StatVal noise_rx; // long-term noise/silence levels on receiving side |
| 426 | StatVal noise_tx; // long-term noise/silence levels on transmitting side |
| 427 | } LevelStatistics; |
| 428 | |
| 429 | typedef struct // All levels are reported in dB |
| 430 | { |
| 431 | StatVal erl; // Echo Return Loss |
| 432 | StatVal erle; // Echo Return Loss Enhancement |
| 433 | StatVal rerl; // RERL = ERL + ERLE |
| 434 | // Echo suppression inside EC at the point just before its NLP |
| 435 | StatVal a_nlp; |
| 436 | } EchoStatistics; |
| 437 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 438 | enum NsModes // type of Noise Suppression |
| 439 | { |
| 440 | kNsUnchanged = 0, // previously set mode |
| 441 | kNsDefault, // platform default |
| 442 | kNsConference, // conferencing default |
| 443 | kNsLowSuppression, // lowest suppression |
| 444 | kNsModerateSuppression, |
| 445 | kNsHighSuppression, |
| 446 | kNsVeryHighSuppression, // highest suppression |
| 447 | }; |
| 448 | |
| 449 | enum AgcModes // type of Automatic Gain Control |
| 450 | { |
| 451 | kAgcUnchanged = 0, // previously set mode |
| 452 | kAgcDefault, // platform default |
| 453 | // adaptive mode for use when analog volume control exists (e.g. for |
| 454 | // PC softphone) |
| 455 | kAgcAdaptiveAnalog, |
| 456 | // scaling takes place in the digital domain (e.g. for conference servers |
| 457 | // and embedded devices) |
| 458 | kAgcAdaptiveDigital, |
andrew@webrtc.org | 8012474 | 2012-03-08 17:54:24 | [diff] [blame] | 459 | // can be used on embedded devices where the capture signal level |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 460 | // is predictable |
| 461 | kAgcFixedDigital |
| 462 | }; |
| 463 | |
| 464 | // EC modes |
| 465 | enum EcModes // type of Echo Control |
| 466 | { |
| 467 | kEcUnchanged = 0, // previously set mode |
| 468 | kEcDefault, // platform default |
| 469 | kEcConference, // conferencing default (aggressive AEC) |
| 470 | kEcAec, // Acoustic Echo Cancellation |
| 471 | kEcAecm, // AEC mobile |
| 472 | }; |
| 473 | |
| 474 | // AECM modes |
| 475 | enum AecmModes // mode of AECM |
| 476 | { |
| 477 | kAecmQuietEarpieceOrHeadset = 0, |
| 478 | // Quiet earpiece or headset use |
| 479 | kAecmEarpiece, // most earpiece use |
| 480 | kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use |
| 481 | kAecmSpeakerphone, // most speakerphone use (default) |
| 482 | kAecmLoudSpeakerphone // Loud speakerphone |
| 483 | }; |
| 484 | |
| 485 | // AGC configuration |
| 486 | typedef struct |
| 487 | { |
| 488 | unsigned short targetLeveldBOv; |
| 489 | unsigned short digitalCompressionGaindB; |
| 490 | bool limiterEnable; |
| 491 | } AgcConfig; // AGC configuration parameters |
| 492 | |
| 493 | enum StereoChannel |
| 494 | { |
| 495 | kStereoLeft = 0, |
| 496 | kStereoRight, |
| 497 | kStereoBoth |
| 498 | }; |
| 499 | |
| 500 | // Audio device layers |
| 501 | enum AudioLayers |
| 502 | { |
| 503 | kAudioPlatformDefault = 0, |
| 504 | kAudioWindowsWave = 1, |
| 505 | kAudioWindowsCore = 2, |
| 506 | kAudioLinuxAlsa = 3, |
| 507 | kAudioLinuxPulse = 4 |
| 508 | }; |
| 509 | |
henrika@webrtc.org | 6680348 | 2014-04-17 10:45:01 | [diff] [blame] | 510 | // TODO(henrika): to be removed. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 511 | enum NetEqModes // NetEQ playout configurations |
| 512 | { |
| 513 | // Optimized trade-off between low delay and jitter robustness for two-way |
| 514 | // communication. |
| 515 | kNetEqDefault = 0, |
| 516 | // Improved jitter robustness at the cost of increased delay. Can be |
| 517 | // used in one-way communication. |
| 518 | kNetEqStreaming = 1, |
| 519 | // Optimzed for decodability of fax signals rather than for perceived audio |
| 520 | // quality. |
| 521 | kNetEqFax = 2, |
roosa@google.com | b718619 | 2012-12-12 21:59:14 | [diff] [blame] | 522 | // Minimal buffer management. Inserts zeros for lost packets and during |
| 523 | // buffer increases. |
| 524 | kNetEqOff = 3, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 525 | }; |
| 526 | |
henrika@webrtc.org | 6680348 | 2014-04-17 10:45:01 | [diff] [blame] | 527 | // TODO(henrika): to be removed. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 528 | enum OnHoldModes // On Hold direction |
| 529 | { |
| 530 | kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state. |
| 531 | kHoldSendOnly, // Put only sending in on-hold state. |
| 532 | kHoldPlayOnly // Put only playing in on-hold state. |
| 533 | }; |
| 534 | |
henrika@webrtc.org | 6680348 | 2014-04-17 10:45:01 | [diff] [blame] | 535 | // TODO(henrika): to be removed. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 536 | enum AmrMode |
| 537 | { |
| 538 | kRfc3267BwEfficient = 0, |
| 539 | kRfc3267OctetAligned = 1, |
| 540 | kRfc3267FileStorage = 2, |
| 541 | }; |
| 542 | |
| 543 | // ================================================================== |
| 544 | // Video specific types |
| 545 | // ================================================================== |
| 546 | |
| 547 | // Raw video types |
| 548 | enum RawVideoType |
| 549 | { |
| 550 | kVideoI420 = 0, |
| 551 | kVideoYV12 = 1, |
| 552 | kVideoYUY2 = 2, |
| 553 | kVideoUYVY = 3, |
| 554 | kVideoIYUV = 4, |
| 555 | kVideoARGB = 5, |
| 556 | kVideoRGB24 = 6, |
| 557 | kVideoRGB565 = 7, |
| 558 | kVideoARGB4444 = 8, |
| 559 | kVideoARGB1555 = 9, |
| 560 | kVideoMJPEG = 10, |
| 561 | kVideoNV12 = 11, |
| 562 | kVideoNV21 = 12, |
mikhal@webrtc.org | c00f91d | 2012-01-03 18:49:15 | [diff] [blame] | 563 | kVideoBGRA = 13, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 564 | kVideoUnknown = 99 |
| 565 | }; |
| 566 | |
| 567 | // Video codec |
| 568 | enum { kConfigParameterSize = 128}; |
| 569 | enum { kPayloadNameSize = 32}; |
pwestin@webrtc.org | 1da1ce0 | 2011-10-13 15:19:55 | [diff] [blame] | 570 | enum { kMaxSimulcastStreams = 4}; |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 571 | enum { kMaxSpatialLayers = 5 }; |
pwestin@webrtc.org | db221d2 | 2011-12-02 11:31:08 | [diff] [blame] | 572 | enum { kMaxTemporalStreams = 4}; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 573 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 574 | enum VideoCodecComplexity |
| 575 | { |
| 576 | kComplexityNormal = 0, |
| 577 | kComplexityHigh = 1, |
| 578 | kComplexityHigher = 2, |
| 579 | kComplexityMax = 3 |
| 580 | }; |
| 581 | |
| 582 | enum VideoCodecProfile |
| 583 | { |
| 584 | kProfileBase = 0x00, |
| 585 | kProfileMain = 0x01 |
| 586 | }; |
| 587 | |
stefan@webrtc.org | efd0a48 | 2011-12-29 10:12:35 | [diff] [blame] | 588 | enum VP8ResilienceMode { |
| 589 | kResilienceOff, // The stream produced by the encoder requires a |
| 590 | // recovery frame (typically a key frame) to be |
| 591 | // decodable after a packet loss. |
| 592 | kResilientStream, // A stream produced by the encoder is resilient to |
| 593 | // packet losses, but packets within a frame subsequent |
| 594 | // to a loss can't be decoded. |
| 595 | kResilientFrames // Same as kResilientStream but with added resilience |
| 596 | // within a frame. |
| 597 | }; |
| 598 | |
Peter Boström | 7b971e7 | 2016-01-19 15:26:16 | [diff] [blame] | 599 | class TemporalLayersFactory; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 600 | // VP8 specific |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 | [diff] [blame] | 601 | struct VideoCodecVP8 { |
| 602 | bool pictureLossIndicationOn; |
| 603 | bool feedbackModeOn; |
| 604 | VideoCodecComplexity complexity; |
| 605 | VP8ResilienceMode resilience; |
| 606 | unsigned char numberOfTemporalLayers; |
| 607 | bool denoisingOn; |
| 608 | bool errorConcealmentOn; |
| 609 | bool automaticResizeOn; |
| 610 | bool frameDroppingOn; |
| 611 | int keyFrameInterval; |
Peter Boström | 7b971e7 | 2016-01-19 15:26:16 | [diff] [blame] | 612 | const TemporalLayersFactory* tl_factory; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 613 | }; |
| 614 | |
asapersson | a9455ab | 2015-07-31 13:10:09 | [diff] [blame] | 615 | // VP9 specific. |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 | [diff] [blame] | 616 | struct VideoCodecVP9 { |
| 617 | VideoCodecComplexity complexity; |
| 618 | int resilience; |
| 619 | unsigned char numberOfTemporalLayers; |
| 620 | bool denoisingOn; |
| 621 | bool frameDroppingOn; |
| 622 | int keyFrameInterval; |
| 623 | bool adaptiveQpMode; |
Marco | f350720 | 2015-09-17 19:16:04 | [diff] [blame] | 624 | bool automaticResizeOn; |
asapersson | a9455ab | 2015-07-31 13:10:09 | [diff] [blame] | 625 | unsigned char numberOfSpatialLayers; |
| 626 | bool flexibleMode; |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 | [diff] [blame] | 627 | }; |
| 628 | |
stefan@webrtc.org | b9f5453 | 2014-07-04 12:42:07 | [diff] [blame] | 629 | // H264 specific. |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 | [diff] [blame] | 630 | struct VideoCodecH264 { |
| 631 | VideoCodecProfile profile; |
| 632 | bool frameDroppingOn; |
| 633 | int keyFrameInterval; |
| 634 | // These are NULL/0 if not externally negotiated. |
| 635 | const uint8_t* spsData; |
| 636 | size_t spsLen; |
| 637 | const uint8_t* ppsData; |
| 638 | size_t ppsLen; |
stefan@webrtc.org | b9f5453 | 2014-07-04 12:42:07 | [diff] [blame] | 639 | }; |
| 640 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 641 | // Video codec types |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 | [diff] [blame] | 642 | enum VideoCodecType { |
| 643 | kVideoCodecVP8, |
| 644 | kVideoCodecVP9, |
| 645 | kVideoCodecH264, |
| 646 | kVideoCodecI420, |
| 647 | kVideoCodecRED, |
| 648 | kVideoCodecULPFEC, |
| 649 | kVideoCodecGeneric, |
| 650 | kVideoCodecUnknown |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 651 | }; |
| 652 | |
marpan@webrtc.org | 5b88317 | 2014-11-01 06:10:48 | [diff] [blame] | 653 | union VideoCodecUnion { |
| 654 | VideoCodecVP8 VP8; |
| 655 | VideoCodecVP9 VP9; |
| 656 | VideoCodecH264 H264; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 657 | }; |
| 658 | |
phoglund@webrtc.org | 8bfee84 | 2012-02-17 09:32:48 | [diff] [blame] | 659 | |
| 660 | // Simulcast is when the same stream is encoded multiple times with different |
| 661 | // settings such as resolution. |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 | [diff] [blame] | 662 | struct SimulcastStream { |
| 663 | unsigned short width; |
| 664 | unsigned short height; |
| 665 | unsigned char numberOfTemporalLayers; |
| 666 | unsigned int maxBitrate; // kilobits/sec. |
| 667 | unsigned int targetBitrate; // kilobits/sec. |
| 668 | unsigned int minBitrate; // kilobits/sec. |
| 669 | unsigned int qpMax; // minimum quality |
pwestin@webrtc.org | 1da1ce0 | 2011-10-13 15:19:55 | [diff] [blame] | 670 | }; |
| 671 | |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 672 | struct SpatialLayer { |
| 673 | int scaling_factor_num; |
| 674 | int scaling_factor_den; |
| 675 | int target_bitrate_bps; |
| 676 | // TODO(ivica): Add max_quantizer and min_quantizer? |
| 677 | }; |
| 678 | |
stefan@webrtc.org | eb91792 | 2013-02-18 14:40:18 | [diff] [blame] | 679 | enum VideoCodecMode { |
| 680 | kRealtimeVideo, |
| 681 | kScreensharing |
| 682 | }; |
| 683 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 684 | // Common video codec properties |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 | [diff] [blame] | 685 | struct VideoCodec { |
| 686 | VideoCodecType codecType; |
| 687 | char plName[kPayloadNameSize]; |
| 688 | unsigned char plType; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 689 | |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 | [diff] [blame] | 690 | unsigned short width; |
| 691 | unsigned short height; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 692 | |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 | [diff] [blame] | 693 | unsigned int startBitrate; // kilobits/sec. |
| 694 | unsigned int maxBitrate; // kilobits/sec. |
| 695 | unsigned int minBitrate; // kilobits/sec. |
pbos@webrtc.org | 3c412b2 | 2014-03-24 12:36:52 | [diff] [blame] | 696 | unsigned int targetBitrate; // kilobits/sec. |
| 697 | |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 | [diff] [blame] | 698 | unsigned char maxFramerate; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 699 | |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 | [diff] [blame] | 700 | VideoCodecUnion codecSpecific; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 701 | |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 | [diff] [blame] | 702 | unsigned int qpMax; |
| 703 | unsigned char numberOfSimulcastStreams; |
| 704 | SimulcastStream simulcastStream[kMaxSimulcastStreams]; |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 705 | SpatialLayer spatialLayers[kMaxSpatialLayers]; |
stefan@webrtc.org | eb91792 | 2013-02-18 14:40:18 | [diff] [blame] | 706 | |
mallinath@webrtc.org | 0209e56 | 2014-03-21 00:41:28 | [diff] [blame] | 707 | VideoCodecMode mode; |
andresp@webrtc.org | 185bae4 | 2013-05-14 08:02:25 | [diff] [blame] | 708 | |
Peter Boström | 7b971e7 | 2016-01-19 15:26:16 | [diff] [blame] | 709 | bool operator==(const VideoCodec& other) const = delete; |
| 710 | bool operator!=(const VideoCodec& other) const = delete; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 711 | }; |
astor@webrtc.org | bd7aeba | 2012-06-26 10:47:04 | [diff] [blame] | 712 | |
stefan | 64c0a0a | 2015-11-27 09:02:31 | [diff] [blame] | 713 | // Bandwidth over-use detector options. These are used to drive |
| 714 | // experimentation with bandwidth estimation parameters. |
| 715 | // See modules/remote_bitrate_estimator/overuse_detector.h |
| 716 | struct OverUseDetectorOptions { |
| 717 | OverUseDetectorOptions() |
| 718 | : initial_slope(8.0/512.0), |
| 719 | initial_offset(0), |
| 720 | initial_e(), |
| 721 | initial_process_noise(), |
| 722 | initial_avg_noise(0.0), |
| 723 | initial_var_noise(50) { |
| 724 | initial_e[0][0] = 100; |
| 725 | initial_e[1][1] = 1e-1; |
| 726 | initial_e[0][1] = initial_e[1][0] = 0; |
| 727 | initial_process_noise[0] = 1e-13; |
stefan | 1069cac | 2016-03-10 13:13:21 | [diff] [blame] | 728 | initial_process_noise[1] = 1e-3; |
stefan | 64c0a0a | 2015-11-27 09:02:31 | [diff] [blame] | 729 | } |
| 730 | double initial_slope; |
| 731 | double initial_offset; |
| 732 | double initial_e[2][2]; |
| 733 | double initial_process_noise[2]; |
| 734 | double initial_avg_noise; |
| 735 | double initial_var_noise; |
| 736 | }; |
| 737 | |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 | [diff] [blame] | 738 | // This structure will have the information about when packet is actually |
| 739 | // received by socket. |
| 740 | struct PacketTime { |
henrike@webrtc.org | 82d3cb6 | 2014-04-29 17:50:47 | [diff] [blame] | 741 | PacketTime() : timestamp(-1), not_before(-1) {} |
| 742 | PacketTime(int64_t timestamp, int64_t not_before) |
| 743 | : timestamp(timestamp), not_before(not_before) { |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 | [diff] [blame] | 744 | } |
| 745 | |
henrike@webrtc.org | 82d3cb6 | 2014-04-29 17:50:47 | [diff] [blame] | 746 | int64_t timestamp; // Receive time after socket delivers the data. |
| 747 | int64_t not_before; // Earliest possible time the data could have arrived, |
| 748 | // indicating the potential error in the |timestamp| |
| 749 | // value,in case the system is busy. |
| 750 | // For example, the time of the last select() call. |
| 751 | // If unknown, this value will be set to zero. |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 | [diff] [blame] | 752 | }; |
| 753 | |
isheriff | 6b4b5f3 | 2016-06-08 07:24:21 | [diff] [blame^] | 754 | // Minimum and maximum playout delay values from capture to render. |
| 755 | // These are best effort values. |
| 756 | // |
| 757 | // A value < 0 indicates no change from previous valid value. |
| 758 | // |
| 759 | // min = max = 0 indicates that the receiver should try and render |
| 760 | // frame as soon as possible. |
| 761 | // |
| 762 | // min = x, max = y indicates that the receiver is free to adapt |
| 763 | // in the range (x, y) based on network jitter. |
| 764 | // |
| 765 | // Note: Given that this gets embedded in a union, it is up-to the owner to |
| 766 | // initialize these values. |
| 767 | struct PlayoutDelay { |
| 768 | int min_ms; |
| 769 | int max_ms; |
| 770 | }; |
| 771 | |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 | [diff] [blame] | 772 | struct RTPHeaderExtension { |
sprang@webrtc.org | 3093390 | 2015-03-17 14:33:12 | [diff] [blame] | 773 | RTPHeaderExtension(); |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 | [diff] [blame] | 774 | |
| 775 | bool hasTransmissionTimeOffset; |
| 776 | int32_t transmissionTimeOffset; |
| 777 | bool hasAbsoluteSendTime; |
| 778 | uint32_t absoluteSendTime; |
sprang@webrtc.org | 3093390 | 2015-03-17 14:33:12 | [diff] [blame] | 779 | bool hasTransportSequenceNumber; |
| 780 | uint16_t transportSequenceNumber; |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 | [diff] [blame] | 781 | |
| 782 | // Audio Level includes both level in dBov and voiced/unvoiced bit. See: |
| 783 | // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/ |
| 784 | bool hasAudioLevel; |
Minyue | 4cee419 | 2015-08-10 13:08:36 | [diff] [blame] | 785 | bool voiceActivity; |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 | [diff] [blame] | 786 | uint8_t audioLevel; |
guoweis@webrtc.org | 4536289 | 2015-03-04 22:55:15 | [diff] [blame] | 787 | |
| 788 | // For Coordination of Video Orientation. See |
| 789 | // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ |
| 790 | // ts_126114v120700p.pdf |
| 791 | bool hasVideoRotation; |
| 792 | uint8_t videoRotation; |
isheriff | 6b4b5f3 | 2016-06-08 07:24:21 | [diff] [blame^] | 793 | |
| 794 | PlayoutDelay playout_delay = {-1, -1}; |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 | [diff] [blame] | 795 | }; |
| 796 | |
| 797 | struct RTPHeader { |
kwiberg@webrtc.org | ac2d27d | 2015-02-26 13:59:22 | [diff] [blame] | 798 | RTPHeader(); |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 | [diff] [blame] | 799 | |
| 800 | bool markerBit; |
| 801 | uint8_t payloadType; |
| 802 | uint16_t sequenceNumber; |
| 803 | uint32_t timestamp; |
| 804 | uint32_t ssrc; |
| 805 | uint8_t numCSRCs; |
| 806 | uint32_t arrOfCSRCs[kRtpCsrcSize]; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 | [diff] [blame] | 807 | size_t paddingLength; |
| 808 | size_t headerLength; |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 | [diff] [blame] | 809 | int payload_type_frequency; |
| 810 | RTPHeaderExtension extension; |
| 811 | }; |
| 812 | |
asapersson@webrtc.org | 4414939 | 2015-02-04 08:34:47 | [diff] [blame] | 813 | struct RtpPacketCounter { |
| 814 | RtpPacketCounter() |
| 815 | : header_bytes(0), |
| 816 | payload_bytes(0), |
| 817 | padding_bytes(0), |
| 818 | packets(0) {} |
| 819 | |
| 820 | void Add(const RtpPacketCounter& other) { |
| 821 | header_bytes += other.header_bytes; |
| 822 | payload_bytes += other.payload_bytes; |
| 823 | padding_bytes += other.padding_bytes; |
| 824 | packets += other.packets; |
| 825 | } |
| 826 | |
Erik Språng | 22c2b48 | 2016-03-01 08:40:42 | [diff] [blame] | 827 | void Subtract(const RtpPacketCounter& other) { |
| 828 | assert(header_bytes >= other.header_bytes); |
| 829 | header_bytes -= other.header_bytes; |
| 830 | assert(payload_bytes >= other.payload_bytes); |
| 831 | payload_bytes -= other.payload_bytes; |
| 832 | assert(padding_bytes >= other.padding_bytes); |
| 833 | padding_bytes -= other.padding_bytes; |
| 834 | assert(packets >= other.packets); |
| 835 | packets -= other.packets; |
| 836 | } |
| 837 | |
asapersson@webrtc.org | 4414939 | 2015-02-04 08:34:47 | [diff] [blame] | 838 | void AddPacket(size_t packet_length, const RTPHeader& header) { |
| 839 | ++packets; |
| 840 | header_bytes += header.headerLength; |
| 841 | padding_bytes += header.paddingLength; |
| 842 | payload_bytes += |
| 843 | packet_length - (header.headerLength + header.paddingLength); |
| 844 | } |
| 845 | |
| 846 | size_t TotalBytes() const { |
| 847 | return header_bytes + payload_bytes + padding_bytes; |
| 848 | } |
| 849 | |
| 850 | size_t header_bytes; // Number of bytes used by RTP headers. |
| 851 | size_t payload_bytes; // Payload bytes, excluding RTP headers and padding. |
| 852 | size_t padding_bytes; // Number of padding bytes. |
| 853 | uint32_t packets; // Number of packets. |
| 854 | }; |
| 855 | |
| 856 | // Data usage statistics for a (rtp) stream. |
| 857 | struct StreamDataCounters { |
kwiberg@webrtc.org | ac2d27d | 2015-02-26 13:59:22 | [diff] [blame] | 858 | StreamDataCounters(); |
asapersson@webrtc.org | 4414939 | 2015-02-04 08:34:47 | [diff] [blame] | 859 | |
| 860 | void Add(const StreamDataCounters& other) { |
| 861 | transmitted.Add(other.transmitted); |
| 862 | retransmitted.Add(other.retransmitted); |
| 863 | fec.Add(other.fec); |
| 864 | if (other.first_packet_time_ms != -1 && |
| 865 | (other.first_packet_time_ms < first_packet_time_ms || |
| 866 | first_packet_time_ms == -1)) { |
| 867 | // Use oldest time. |
| 868 | first_packet_time_ms = other.first_packet_time_ms; |
| 869 | } |
| 870 | } |
| 871 | |
Erik Språng | 22c2b48 | 2016-03-01 08:40:42 | [diff] [blame] | 872 | void Subtract(const StreamDataCounters& other) { |
| 873 | transmitted.Subtract(other.transmitted); |
| 874 | retransmitted.Subtract(other.retransmitted); |
| 875 | fec.Subtract(other.fec); |
| 876 | if (other.first_packet_time_ms != -1 && |
| 877 | (other.first_packet_time_ms > first_packet_time_ms || |
| 878 | first_packet_time_ms == -1)) { |
| 879 | // Use youngest time. |
| 880 | first_packet_time_ms = other.first_packet_time_ms; |
| 881 | } |
| 882 | } |
| 883 | |
asapersson@webrtc.org | 4414939 | 2015-02-04 08:34:47 | [diff] [blame] | 884 | int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const { |
| 885 | return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms); |
| 886 | } |
| 887 | |
| 888 | // Returns the number of bytes corresponding to the actual media payload (i.e. |
| 889 | // RTP headers, padding, retransmissions and fec packets are excluded). |
| 890 | // Note this function does not have meaning for an RTX stream. |
| 891 | size_t MediaPayloadBytes() const { |
| 892 | return transmitted.payload_bytes - retransmitted.payload_bytes - |
| 893 | fec.payload_bytes; |
| 894 | } |
| 895 | |
| 896 | int64_t first_packet_time_ms; // Time when first packet is sent/received. |
| 897 | RtpPacketCounter transmitted; // Number of transmitted packets/bytes. |
| 898 | RtpPacketCounter retransmitted; // Number of retransmitted packets/bytes. |
| 899 | RtpPacketCounter fec; // Number of redundancy packets/bytes. |
| 900 | }; |
| 901 | |
| 902 | // Callback, called whenever byte/packet counts have been updated. |
| 903 | class StreamDataCountersCallback { |
| 904 | public: |
| 905 | virtual ~StreamDataCountersCallback() {} |
| 906 | |
| 907 | virtual void DataCountersUpdated(const StreamDataCounters& counters, |
| 908 | uint32_t ssrc) = 0; |
| 909 | }; |
pbos | da903ea | 2015-10-02 09:36:56 | [diff] [blame] | 910 | |
| 911 | // RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size |
| 912 | // RTCP mode is described by RFC 5506. |
| 913 | enum class RtcpMode { kOff, kCompound, kReducedSize }; |
| 914 | |
pbos | 1ba8d39 | 2016-05-02 03:18:34 | [diff] [blame] | 915 | enum NetworkState { |
| 916 | kNetworkUp, |
| 917 | kNetworkDown, |
| 918 | }; |
| 919 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 920 | } // namespace webrtc |
andrew@webrtc.org | eda189b | 2013-09-09 17:50:10 | [diff] [blame] | 921 | |
| 922 | #endif // WEBRTC_COMMON_TYPES_H_ |