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