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