andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [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 | 81c4d24 | 2013-09-09 17:50:10 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_COMMON_TYPES_H_ |
| 12 | #define WEBRTC_COMMON_TYPES_H_ |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 13 | |
pbos@webrtc.org | f39df52 | 2014-03-19 08:43:57 +0000 | [diff] [blame] | 14 | #include <stddef.h> |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 15 | #include <string.h> |
pbos@webrtc.org | f39df52 | 2014-03-19 08:43:57 +0000 | [diff] [blame] | 16 | #include <vector> |
| 17 | |
andrew@webrtc.org | 81c4d24 | 2013-09-09 17:50:10 +0000 | [diff] [blame] | 18 | #include "webrtc/typedefs.h" |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 19 | |
| 20 | #if defined(_MSC_VER) |
| 21 | // Disable "new behavior: elements of array will be default initialized" |
| 22 | // warning. Affects OverUseDetectorOptions. |
| 23 | #pragma warning(disable:4351) |
| 24 | #endif |
| 25 | |
| 26 | #ifdef WEBRTC_EXPORT |
| 27 | #define WEBRTC_DLLEXPORT _declspec(dllexport) |
| 28 | #elif WEBRTC_DLL |
| 29 | #define WEBRTC_DLLEXPORT _declspec(dllimport) |
| 30 | #else |
| 31 | #define WEBRTC_DLLEXPORT |
| 32 | #endif |
| 33 | |
| 34 | #ifndef NULL |
| 35 | #define NULL 0 |
| 36 | #endif |
| 37 | |
| 38 | #define RTP_PAYLOAD_NAME_SIZE 32 |
| 39 | |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 40 | #if defined(WEBRTC_WIN) || defined(WIN32) |
andrew@webrtc.org | 81c4d24 | 2013-09-09 17:50:10 +0000 | [diff] [blame] | 41 | // Compares two strings without regard to case. |
| 42 | #define STR_CASE_CMP(s1, s2) ::_stricmp(s1, s2) |
| 43 | // Compares characters of two strings without regard to case. |
| 44 | #define STR_NCASE_CMP(s1, s2, n) ::_strnicmp(s1, s2, n) |
| 45 | #else |
| 46 | #define STR_CASE_CMP(s1, s2) ::strcasecmp(s1, s2) |
| 47 | #define STR_NCASE_CMP(s1, s2, n) ::strncasecmp(s1, s2, n) |
| 48 | #endif |
| 49 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 50 | namespace webrtc { |
| 51 | |
andresp@webrtc.org | 1e8424f | 2013-05-14 08:02:25 +0000 | [diff] [blame] | 52 | class Config; |
| 53 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 54 | class InStream |
| 55 | { |
| 56 | public: |
| 57 | virtual int Read(void *buf,int len) = 0; |
| 58 | virtual int Rewind() {return -1;} |
| 59 | virtual ~InStream() {} |
| 60 | protected: |
| 61 | InStream() {} |
| 62 | }; |
| 63 | |
| 64 | class OutStream |
| 65 | { |
| 66 | public: |
| 67 | virtual bool Write(const void *buf,int len) = 0; |
| 68 | virtual int Rewind() {return -1;} |
| 69 | virtual ~OutStream() {} |
| 70 | protected: |
| 71 | OutStream() {} |
| 72 | }; |
| 73 | |
| 74 | enum TraceModule |
| 75 | { |
pbos@webrtc.org | 39139dc | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 76 | kTraceUndefined = 0, |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 77 | // not a module, triggered from the engine code |
pbos@webrtc.org | 39139dc | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 78 | kTraceVoice = 0x0001, |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 79 | // not a module, triggered from the engine code |
pbos@webrtc.org | 39139dc | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 80 | kTraceVideo = 0x0002, |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 81 | // not a module, triggered from the utility code |
pbos@webrtc.org | 39139dc | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 82 | kTraceUtility = 0x0003, |
| 83 | kTraceRtpRtcp = 0x0004, |
| 84 | kTraceTransport = 0x0005, |
| 85 | kTraceSrtp = 0x0006, |
| 86 | kTraceAudioCoding = 0x0007, |
| 87 | kTraceAudioMixerServer = 0x0008, |
| 88 | kTraceAudioMixerClient = 0x0009, |
| 89 | kTraceFile = 0x000a, |
| 90 | kTraceAudioProcessing = 0x000b, |
| 91 | kTraceVideoCoding = 0x0010, |
| 92 | kTraceVideoMixer = 0x0011, |
| 93 | kTraceAudioDevice = 0x0012, |
| 94 | kTraceVideoRenderer = 0x0014, |
| 95 | kTraceVideoCapture = 0x0015, |
pbos@webrtc.org | 39139dc | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 96 | kTraceRemoteBitrateEstimator = 0x0017, |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | enum TraceLevel |
| 100 | { |
| 101 | kTraceNone = 0x0000, // no trace |
| 102 | kTraceStateInfo = 0x0001, |
| 103 | kTraceWarning = 0x0002, |
| 104 | kTraceError = 0x0004, |
| 105 | kTraceCritical = 0x0008, |
| 106 | kTraceApiCall = 0x0010, |
| 107 | kTraceDefault = 0x00ff, |
| 108 | |
| 109 | kTraceModuleCall = 0x0020, |
| 110 | kTraceMemory = 0x0100, // memory info |
| 111 | kTraceTimer = 0x0200, // timing info |
| 112 | kTraceStream = 0x0400, // "continuous" stream of data |
| 113 | |
| 114 | // used for debug purposes |
| 115 | kTraceDebug = 0x0800, // debug |
| 116 | kTraceInfo = 0x1000, // debug info |
| 117 | |
andrew@webrtc.org | 10e0b28 | 2012-11-20 07:34:45 +0000 | [diff] [blame] | 118 | // Non-verbose level used by LS_INFO of logging.h. Do not use directly. |
| 119 | kTraceTerseInfo = 0x2000, |
| 120 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 121 | kTraceAll = 0xffff |
| 122 | }; |
| 123 | |
| 124 | // External Trace API |
andrew@webrtc.org | 4c8c307 | 2012-11-15 05:33:25 +0000 | [diff] [blame] | 125 | class TraceCallback { |
| 126 | public: |
| 127 | virtual void Print(TraceLevel level, const char* message, int length) = 0; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 128 | |
andrew@webrtc.org | 4c8c307 | 2012-11-15 05:33:25 +0000 | [diff] [blame] | 129 | protected: |
| 130 | virtual ~TraceCallback() {} |
| 131 | TraceCallback() {} |
| 132 | }; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 133 | |
| 134 | enum FileFormats |
| 135 | { |
| 136 | kFileFormatWavFile = 1, |
| 137 | kFileFormatCompressedFile = 2, |
| 138 | kFileFormatAviFile = 3, |
| 139 | kFileFormatPreencodedFile = 4, |
| 140 | kFileFormatPcm16kHzFile = 7, |
| 141 | kFileFormatPcm8kHzFile = 8, |
| 142 | kFileFormatPcm32kHzFile = 9 |
| 143 | }; |
| 144 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 145 | enum ProcessingTypes |
| 146 | { |
| 147 | kPlaybackPerChannel = 0, |
| 148 | kPlaybackAllChannelsMixed, |
| 149 | kRecordingPerChannel, |
| 150 | kRecordingAllChannelsMixed, |
| 151 | kRecordingPreprocessing |
| 152 | }; |
| 153 | |
sprang@webrtc.org | 9435a17 | 2013-12-04 15:09:27 +0000 | [diff] [blame] | 154 | enum FrameType |
| 155 | { |
| 156 | kFrameEmpty = 0, |
| 157 | kAudioFrameSpeech = 1, |
| 158 | kAudioFrameCN = 2, |
| 159 | kVideoFrameKey = 3, // independent frame |
| 160 | kVideoFrameDelta = 4, // depends on the previus frame |
| 161 | }; |
| 162 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 163 | // External transport callback interface |
| 164 | class Transport |
| 165 | { |
| 166 | public: |
| 167 | virtual int SendPacket(int channel, const void *data, int len) = 0; |
| 168 | virtual int SendRTCPPacket(int channel, const void *data, int len) = 0; |
| 169 | |
| 170 | protected: |
| 171 | virtual ~Transport() {} |
| 172 | Transport() {} |
| 173 | }; |
| 174 | |
sprang@webrtc.org | 13a4d31 | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 175 | // Statistics for an RTCP channel |
sprang@webrtc.org | 4043e7e | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 176 | struct RtcpStatistics { |
sprang@webrtc.org | 4043e7e | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 177 | RtcpStatistics() |
| 178 | : fraction_lost(0), |
| 179 | cumulative_lost(0), |
| 180 | extended_max_sequence_number(0), |
sprang@webrtc.org | 8911937 | 2013-12-05 09:48:44 +0000 | [diff] [blame] | 181 | jitter(0) {} |
sprang@webrtc.org | 4043e7e | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 182 | |
| 183 | uint8_t fraction_lost; |
| 184 | uint32_t cumulative_lost; |
| 185 | uint32_t extended_max_sequence_number; |
| 186 | uint32_t jitter; |
sprang@webrtc.org | 4043e7e | 2013-10-28 09:21:07 +0000 | [diff] [blame] | 187 | }; |
| 188 | |
sprang@webrtc.org | 13a4d31 | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 189 | // Callback, called whenever a new rtcp report block is transmitted. |
| 190 | class RtcpStatisticsCallback { |
| 191 | public: |
| 192 | virtual ~RtcpStatisticsCallback() {} |
| 193 | |
| 194 | virtual void StatisticsUpdated(const RtcpStatistics& statistics, |
| 195 | uint32_t ssrc) = 0; |
| 196 | }; |
| 197 | |
asapersson@webrtc.org | 2fa9f7e | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 198 | // Statistics for RTCP packet types. |
| 199 | struct RtcpPacketTypeCounter { |
| 200 | RtcpPacketTypeCounter() |
| 201 | : nack_packets(0), |
| 202 | fir_packets(0), |
| 203 | pli_packets(0) {} |
| 204 | |
| 205 | void Add(const RtcpPacketTypeCounter& other) { |
| 206 | nack_packets += other.nack_packets; |
| 207 | fir_packets += other.fir_packets; |
| 208 | pli_packets += other.pli_packets; |
| 209 | } |
| 210 | |
| 211 | uint32_t nack_packets; |
| 212 | uint32_t fir_packets; |
| 213 | uint32_t pli_packets; |
| 214 | }; |
| 215 | |
sprang@webrtc.org | 13a4d31 | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 216 | // Data usage statistics for a (rtp) stream |
| 217 | struct StreamDataCounters { |
sprang@webrtc.org | 13a4d31 | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 218 | StreamDataCounters() |
| 219 | : bytes(0), |
sprang@webrtc.org | cf5c552 | 2013-12-05 14:29:02 +0000 | [diff] [blame] | 220 | header_bytes(0), |
sprang@webrtc.org | 13a4d31 | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 221 | padding_bytes(0), |
| 222 | packets(0), |
| 223 | retransmitted_packets(0), |
| 224 | fec_packets(0) {} |
| 225 | |
sprang@webrtc.org | cf5c552 | 2013-12-05 14:29:02 +0000 | [diff] [blame] | 226 | uint32_t bytes; // Payload bytes, excluding RTP headers and padding. |
| 227 | uint32_t header_bytes; // Number of bytes used by RTP headers. |
| 228 | uint32_t padding_bytes; // Number of padding bytes. |
| 229 | uint32_t packets; // Number of packets. |
| 230 | uint32_t retransmitted_packets; // Number of retransmitted packets. |
| 231 | uint32_t fec_packets; // Number of redundancy packets. |
sprang@webrtc.org | 13a4d31 | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 232 | }; |
| 233 | |
| 234 | // Callback, called whenever byte/packet counts have been updated. |
| 235 | class StreamDataCountersCallback { |
| 236 | public: |
| 237 | virtual ~StreamDataCountersCallback() {} |
| 238 | |
| 239 | virtual void DataCountersUpdated(const StreamDataCounters& counters, |
| 240 | uint32_t ssrc) = 0; |
| 241 | }; |
| 242 | |
| 243 | // Rate statistics for a stream |
| 244 | struct BitrateStatistics { |
sprang@webrtc.org | 0e4512b | 2013-12-13 09:46:59 +0000 | [diff] [blame] | 245 | BitrateStatistics() : bitrate_bps(0), packet_rate(0), timestamp_ms(0) {} |
sprang@webrtc.org | 13a4d31 | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 246 | |
sprang@webrtc.org | 0e4512b | 2013-12-13 09:46:59 +0000 | [diff] [blame] | 247 | uint32_t bitrate_bps; // Bitrate in bits per second. |
| 248 | uint32_t packet_rate; // Packet rate in packets per second. |
| 249 | uint64_t timestamp_ms; // Ntp timestamp in ms at time of rate estimation. |
sprang@webrtc.org | 13a4d31 | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 250 | }; |
| 251 | |
| 252 | // Callback, used to notify an observer whenever new rates have been estimated. |
| 253 | class BitrateStatisticsObserver { |
| 254 | public: |
| 255 | virtual ~BitrateStatisticsObserver() {} |
| 256 | |
| 257 | virtual void Notify(const BitrateStatistics& stats, uint32_t ssrc) = 0; |
| 258 | }; |
| 259 | |
| 260 | // Callback, used to notify an observer whenever frame counts have been updated |
| 261 | class FrameCountObserver { |
| 262 | public: |
sprang@webrtc.org | e92aec9 | 2013-11-21 09:09:54 +0000 | [diff] [blame] | 263 | virtual ~FrameCountObserver() {} |
sprang@webrtc.org | 9435a17 | 2013-12-04 15:09:27 +0000 | [diff] [blame] | 264 | virtual void FrameCountUpdated(FrameType frame_type, |
| 265 | uint32_t frame_count, |
| 266 | const unsigned int ssrc) = 0; |
sprang@webrtc.org | 13a4d31 | 2013-11-20 16:47:07 +0000 | [diff] [blame] | 267 | }; |
| 268 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 269 | // ================================================================== |
| 270 | // Voice specific types |
| 271 | // ================================================================== |
| 272 | |
| 273 | // Each codec supported can be described by this structure. |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 274 | struct CodecInst { |
| 275 | int pltype; |
| 276 | char plname[RTP_PAYLOAD_NAME_SIZE]; |
| 277 | int plfreq; |
| 278 | int pacsize; |
| 279 | int channels; |
| 280 | int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file! |
| 281 | |
| 282 | bool operator==(const CodecInst& other) const { |
| 283 | return pltype == other.pltype && |
| 284 | (STR_CASE_CMP(plname, other.plname) == 0) && |
| 285 | plfreq == other.plfreq && |
| 286 | pacsize == other.pacsize && |
| 287 | channels == other.channels && |
| 288 | rate == other.rate; |
| 289 | } |
| 290 | |
| 291 | bool operator!=(const CodecInst& other) const { |
| 292 | return !(*this == other); |
| 293 | } |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 294 | }; |
| 295 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 296 | // RTP |
| 297 | enum {kRtpCsrcSize = 15}; // RFC 3550 page 13 |
| 298 | |
| 299 | enum RTPDirections |
| 300 | { |
| 301 | kRtpIncoming = 0, |
| 302 | kRtpOutgoing |
| 303 | }; |
| 304 | |
| 305 | enum PayloadFrequencies |
| 306 | { |
| 307 | kFreq8000Hz = 8000, |
| 308 | kFreq16000Hz = 16000, |
| 309 | kFreq32000Hz = 32000 |
| 310 | }; |
| 311 | |
| 312 | enum VadModes // degree of bandwidth reduction |
| 313 | { |
| 314 | kVadConventional = 0, // lowest reduction |
| 315 | kVadAggressiveLow, |
| 316 | kVadAggressiveMid, |
| 317 | kVadAggressiveHigh // highest reduction |
| 318 | }; |
| 319 | |
| 320 | struct NetworkStatistics // NETEQ statistics |
| 321 | { |
| 322 | // current jitter buffer size in ms |
pbos@webrtc.org | c22830f | 2013-05-03 12:02:11 +0000 | [diff] [blame] | 323 | uint16_t currentBufferSize; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 324 | // preferred (optimal) buffer size in ms |
pbos@webrtc.org | c22830f | 2013-05-03 12:02:11 +0000 | [diff] [blame] | 325 | uint16_t preferredBufferSize; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 326 | // adding extra delay due to "peaky jitter" |
| 327 | bool jitterPeaksFound; |
| 328 | // loss rate (network + late) in percent (in Q14) |
pbos@webrtc.org | c22830f | 2013-05-03 12:02:11 +0000 | [diff] [blame] | 329 | uint16_t currentPacketLossRate; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 330 | // late loss rate in percent (in Q14) |
pbos@webrtc.org | c22830f | 2013-05-03 12:02:11 +0000 | [diff] [blame] | 331 | uint16_t currentDiscardRate; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 332 | // fraction (of original stream) of synthesized speech inserted through |
| 333 | // expansion (in Q14) |
pbos@webrtc.org | c22830f | 2013-05-03 12:02:11 +0000 | [diff] [blame] | 334 | uint16_t currentExpandRate; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 335 | // fraction of synthesized speech inserted through pre-emptive expansion |
| 336 | // (in Q14) |
pbos@webrtc.org | c22830f | 2013-05-03 12:02:11 +0000 | [diff] [blame] | 337 | uint16_t currentPreemptiveRate; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 338 | // fraction of data removed through acceleration (in Q14) |
pbos@webrtc.org | c22830f | 2013-05-03 12:02:11 +0000 | [diff] [blame] | 339 | uint16_t currentAccelerateRate; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 340 | // clock-drift in parts-per-million (negative or positive) |
| 341 | int32_t clockDriftPPM; |
| 342 | // average packet waiting time in the jitter buffer (ms) |
| 343 | int meanWaitingTimeMs; |
| 344 | // median packet waiting time in the jitter buffer (ms) |
| 345 | int medianWaitingTimeMs; |
| 346 | // min packet waiting time in the jitter buffer (ms) |
| 347 | int minWaitingTimeMs; |
| 348 | // max packet waiting time in the jitter buffer (ms) |
| 349 | int maxWaitingTimeMs; |
roosa@google.com | d0a9608 | 2012-12-14 00:06:18 +0000 | [diff] [blame] | 350 | // added samples in off mode due to packet loss |
| 351 | int addedSamples; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 352 | }; |
| 353 | |
wu@webrtc.org | 7f0519e | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 354 | // Statistics for calls to AudioCodingModule::PlayoutData10Ms(). |
| 355 | struct AudioDecodingCallStats { |
| 356 | AudioDecodingCallStats() |
| 357 | : calls_to_silence_generator(0), |
| 358 | calls_to_neteq(0), |
| 359 | decoded_normal(0), |
| 360 | decoded_plc(0), |
| 361 | decoded_cng(0), |
| 362 | decoded_plc_cng(0) {} |
| 363 | |
| 364 | int calls_to_silence_generator; // Number of calls where silence generated, |
| 365 | // and NetEq was disengaged from decoding. |
| 366 | int calls_to_neteq; // Number of calls to NetEq. |
| 367 | int decoded_normal; // Number of calls where audio RTP packet decoded. |
| 368 | int decoded_plc; // Number of calls resulted in PLC. |
| 369 | int decoded_cng; // Number of calls where comfort noise generated due to DTX. |
| 370 | int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG. |
| 371 | }; |
| 372 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 373 | typedef struct |
| 374 | { |
| 375 | int min; // minumum |
| 376 | int max; // maximum |
| 377 | int average; // average |
| 378 | } StatVal; |
| 379 | |
| 380 | typedef struct // All levels are reported in dBm0 |
| 381 | { |
| 382 | StatVal speech_rx; // long-term speech levels on receiving side |
| 383 | StatVal speech_tx; // long-term speech levels on transmitting side |
| 384 | StatVal noise_rx; // long-term noise/silence levels on receiving side |
| 385 | StatVal noise_tx; // long-term noise/silence levels on transmitting side |
| 386 | } LevelStatistics; |
| 387 | |
| 388 | typedef struct // All levels are reported in dB |
| 389 | { |
| 390 | StatVal erl; // Echo Return Loss |
| 391 | StatVal erle; // Echo Return Loss Enhancement |
| 392 | StatVal rerl; // RERL = ERL + ERLE |
| 393 | // Echo suppression inside EC at the point just before its NLP |
| 394 | StatVal a_nlp; |
| 395 | } EchoStatistics; |
| 396 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 397 | enum NsModes // type of Noise Suppression |
| 398 | { |
| 399 | kNsUnchanged = 0, // previously set mode |
| 400 | kNsDefault, // platform default |
| 401 | kNsConference, // conferencing default |
| 402 | kNsLowSuppression, // lowest suppression |
| 403 | kNsModerateSuppression, |
| 404 | kNsHighSuppression, |
| 405 | kNsVeryHighSuppression, // highest suppression |
| 406 | }; |
| 407 | |
| 408 | enum AgcModes // type of Automatic Gain Control |
| 409 | { |
| 410 | kAgcUnchanged = 0, // previously set mode |
| 411 | kAgcDefault, // platform default |
| 412 | // adaptive mode for use when analog volume control exists (e.g. for |
| 413 | // PC softphone) |
| 414 | kAgcAdaptiveAnalog, |
| 415 | // scaling takes place in the digital domain (e.g. for conference servers |
| 416 | // and embedded devices) |
| 417 | kAgcAdaptiveDigital, |
| 418 | // can be used on embedded devices where the capture signal level |
| 419 | // is predictable |
| 420 | kAgcFixedDigital |
| 421 | }; |
| 422 | |
| 423 | // EC modes |
| 424 | enum EcModes // type of Echo Control |
| 425 | { |
| 426 | kEcUnchanged = 0, // previously set mode |
| 427 | kEcDefault, // platform default |
| 428 | kEcConference, // conferencing default (aggressive AEC) |
| 429 | kEcAec, // Acoustic Echo Cancellation |
| 430 | kEcAecm, // AEC mobile |
| 431 | }; |
| 432 | |
| 433 | // AECM modes |
| 434 | enum AecmModes // mode of AECM |
| 435 | { |
| 436 | kAecmQuietEarpieceOrHeadset = 0, |
| 437 | // Quiet earpiece or headset use |
| 438 | kAecmEarpiece, // most earpiece use |
| 439 | kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use |
| 440 | kAecmSpeakerphone, // most speakerphone use (default) |
| 441 | kAecmLoudSpeakerphone // Loud speakerphone |
| 442 | }; |
| 443 | |
| 444 | // AGC configuration |
| 445 | typedef struct |
| 446 | { |
| 447 | unsigned short targetLeveldBOv; |
| 448 | unsigned short digitalCompressionGaindB; |
| 449 | bool limiterEnable; |
| 450 | } AgcConfig; // AGC configuration parameters |
| 451 | |
| 452 | enum StereoChannel |
| 453 | { |
| 454 | kStereoLeft = 0, |
| 455 | kStereoRight, |
| 456 | kStereoBoth |
| 457 | }; |
| 458 | |
| 459 | // Audio device layers |
| 460 | enum AudioLayers |
| 461 | { |
| 462 | kAudioPlatformDefault = 0, |
| 463 | kAudioWindowsWave = 1, |
| 464 | kAudioWindowsCore = 2, |
| 465 | kAudioLinuxAlsa = 3, |
| 466 | kAudioLinuxPulse = 4 |
| 467 | }; |
| 468 | |
henrika@webrtc.org | 514abde | 2014-04-17 10:45:01 +0000 | [diff] [blame] | 469 | // TODO(henrika): to be removed. |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 470 | enum NetEqModes // NetEQ playout configurations |
| 471 | { |
| 472 | // Optimized trade-off between low delay and jitter robustness for two-way |
| 473 | // communication. |
| 474 | kNetEqDefault = 0, |
| 475 | // Improved jitter robustness at the cost of increased delay. Can be |
| 476 | // used in one-way communication. |
| 477 | kNetEqStreaming = 1, |
| 478 | // Optimzed for decodability of fax signals rather than for perceived audio |
| 479 | // quality. |
| 480 | kNetEqFax = 2, |
roosa@google.com | e68106f | 2012-12-12 21:59:14 +0000 | [diff] [blame] | 481 | // Minimal buffer management. Inserts zeros for lost packets and during |
| 482 | // buffer increases. |
| 483 | kNetEqOff = 3, |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 484 | }; |
| 485 | |
henrika@webrtc.org | 514abde | 2014-04-17 10:45:01 +0000 | [diff] [blame] | 486 | // TODO(henrika): to be removed. |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 487 | enum OnHoldModes // On Hold direction |
| 488 | { |
| 489 | kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state. |
| 490 | kHoldSendOnly, // Put only sending in on-hold state. |
| 491 | kHoldPlayOnly // Put only playing in on-hold state. |
| 492 | }; |
| 493 | |
henrika@webrtc.org | 514abde | 2014-04-17 10:45:01 +0000 | [diff] [blame] | 494 | // TODO(henrika): to be removed. |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 495 | enum AmrMode |
| 496 | { |
| 497 | kRfc3267BwEfficient = 0, |
| 498 | kRfc3267OctetAligned = 1, |
| 499 | kRfc3267FileStorage = 2, |
| 500 | }; |
| 501 | |
| 502 | // ================================================================== |
| 503 | // Video specific types |
| 504 | // ================================================================== |
| 505 | |
| 506 | // Raw video types |
| 507 | enum RawVideoType |
| 508 | { |
| 509 | kVideoI420 = 0, |
| 510 | kVideoYV12 = 1, |
| 511 | kVideoYUY2 = 2, |
| 512 | kVideoUYVY = 3, |
| 513 | kVideoIYUV = 4, |
| 514 | kVideoARGB = 5, |
| 515 | kVideoRGB24 = 6, |
| 516 | kVideoRGB565 = 7, |
| 517 | kVideoARGB4444 = 8, |
| 518 | kVideoARGB1555 = 9, |
| 519 | kVideoMJPEG = 10, |
| 520 | kVideoNV12 = 11, |
| 521 | kVideoNV21 = 12, |
| 522 | kVideoBGRA = 13, |
| 523 | kVideoUnknown = 99 |
| 524 | }; |
| 525 | |
| 526 | // Video codec |
| 527 | enum { kConfigParameterSize = 128}; |
| 528 | enum { kPayloadNameSize = 32}; |
| 529 | enum { kMaxSimulcastStreams = 4}; |
| 530 | enum { kMaxTemporalStreams = 4}; |
| 531 | |
| 532 | enum VideoCodecComplexity |
| 533 | { |
| 534 | kComplexityNormal = 0, |
| 535 | kComplexityHigh = 1, |
| 536 | kComplexityHigher = 2, |
| 537 | kComplexityMax = 3 |
| 538 | }; |
| 539 | |
| 540 | enum VideoCodecProfile |
| 541 | { |
| 542 | kProfileBase = 0x00, |
| 543 | kProfileMain = 0x01 |
| 544 | }; |
| 545 | |
| 546 | enum VP8ResilienceMode { |
| 547 | kResilienceOff, // The stream produced by the encoder requires a |
| 548 | // recovery frame (typically a key frame) to be |
| 549 | // decodable after a packet loss. |
| 550 | kResilientStream, // A stream produced by the encoder is resilient to |
| 551 | // packet losses, but packets within a frame subsequent |
| 552 | // to a loss can't be decoded. |
| 553 | kResilientFrames // Same as kResilientStream but with added resilience |
| 554 | // within a frame. |
| 555 | }; |
| 556 | |
| 557 | // VP8 specific |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 558 | struct VideoCodecVP8 { |
| 559 | bool pictureLossIndicationOn; |
| 560 | bool feedbackModeOn; |
| 561 | VideoCodecComplexity complexity; |
| 562 | VP8ResilienceMode resilience; |
| 563 | unsigned char numberOfTemporalLayers; |
| 564 | bool denoisingOn; |
| 565 | bool errorConcealmentOn; |
| 566 | bool automaticResizeOn; |
| 567 | bool frameDroppingOn; |
| 568 | int keyFrameInterval; |
| 569 | |
| 570 | bool operator==(const VideoCodecVP8& other) const { |
| 571 | return pictureLossIndicationOn == other.pictureLossIndicationOn && |
| 572 | feedbackModeOn == other.feedbackModeOn && |
| 573 | complexity == other.complexity && |
| 574 | resilience == other.resilience && |
| 575 | numberOfTemporalLayers == other.numberOfTemporalLayers && |
| 576 | denoisingOn == other.denoisingOn && |
| 577 | errorConcealmentOn == other.errorConcealmentOn && |
| 578 | automaticResizeOn == other.automaticResizeOn && |
| 579 | frameDroppingOn == other.frameDroppingOn && |
| 580 | keyFrameInterval == other.keyFrameInterval; |
| 581 | } |
| 582 | |
| 583 | bool operator!=(const VideoCodecVP8& other) const { |
| 584 | return !(*this == other); |
| 585 | } |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 586 | }; |
| 587 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 588 | // Video codec types |
| 589 | enum VideoCodecType |
| 590 | { |
| 591 | kVideoCodecVP8, |
| 592 | kVideoCodecI420, |
| 593 | kVideoCodecRED, |
| 594 | kVideoCodecULPFEC, |
pbos@webrtc.org | a2e9124 | 2013-03-18 16:39:03 +0000 | [diff] [blame] | 595 | kVideoCodecGeneric, |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 596 | kVideoCodecUnknown |
| 597 | }; |
| 598 | |
| 599 | union VideoCodecUnion |
| 600 | { |
| 601 | VideoCodecVP8 VP8; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 602 | }; |
| 603 | |
| 604 | |
| 605 | // Simulcast is when the same stream is encoded multiple times with different |
| 606 | // settings such as resolution. |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 607 | struct SimulcastStream { |
| 608 | unsigned short width; |
| 609 | unsigned short height; |
| 610 | unsigned char numberOfTemporalLayers; |
| 611 | unsigned int maxBitrate; // kilobits/sec. |
| 612 | unsigned int targetBitrate; // kilobits/sec. |
| 613 | unsigned int minBitrate; // kilobits/sec. |
| 614 | unsigned int qpMax; // minimum quality |
| 615 | |
| 616 | bool operator==(const SimulcastStream& other) const { |
| 617 | return width == other.width && |
| 618 | height == other.height && |
| 619 | numberOfTemporalLayers == other.numberOfTemporalLayers && |
| 620 | maxBitrate == other.maxBitrate && |
| 621 | targetBitrate == other.targetBitrate && |
| 622 | minBitrate == other.minBitrate && |
| 623 | qpMax == other.qpMax; |
| 624 | } |
| 625 | |
| 626 | bool operator!=(const SimulcastStream& other) const { |
| 627 | return !(*this == other); |
| 628 | } |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 629 | }; |
| 630 | |
stefan@webrtc.org | 85e2e0e | 2013-02-18 14:40:18 +0000 | [diff] [blame] | 631 | enum VideoCodecMode { |
| 632 | kRealtimeVideo, |
| 633 | kScreensharing |
| 634 | }; |
| 635 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 636 | // Common video codec properties |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 637 | struct VideoCodec { |
| 638 | VideoCodecType codecType; |
| 639 | char plName[kPayloadNameSize]; |
| 640 | unsigned char plType; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 641 | |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 642 | unsigned short width; |
| 643 | unsigned short height; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 644 | |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 645 | unsigned int startBitrate; // kilobits/sec. |
| 646 | unsigned int maxBitrate; // kilobits/sec. |
| 647 | unsigned int minBitrate; // kilobits/sec. |
pbos@webrtc.org | 5ca38d1 | 2014-03-24 12:36:52 +0000 | [diff] [blame] | 648 | unsigned int targetBitrate; // kilobits/sec. |
| 649 | |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 650 | unsigned char maxFramerate; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 651 | |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 652 | VideoCodecUnion codecSpecific; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 653 | |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 654 | unsigned int qpMax; |
| 655 | unsigned char numberOfSimulcastStreams; |
| 656 | SimulcastStream simulcastStream[kMaxSimulcastStreams]; |
stefan@webrtc.org | 85e2e0e | 2013-02-18 14:40:18 +0000 | [diff] [blame] | 657 | |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 658 | VideoCodecMode mode; |
andresp@webrtc.org | 1e8424f | 2013-05-14 08:02:25 +0000 | [diff] [blame] | 659 | |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 660 | // When using an external encoder/decoder this allows to pass |
| 661 | // extra options without requiring webrtc to be aware of them. |
| 662 | Config* extra_options; |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 663 | |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 664 | bool operator==(const VideoCodec& other) const { |
| 665 | bool ret = codecType == other.codecType && |
| 666 | (STR_CASE_CMP(plName, other.plName) == 0) && |
| 667 | plType == other.plType && |
| 668 | width == other.width && |
| 669 | height == other.height && |
| 670 | startBitrate == other.startBitrate && |
| 671 | maxBitrate == other.maxBitrate && |
| 672 | minBitrate == other.minBitrate && |
pbos@webrtc.org | 5ca38d1 | 2014-03-24 12:36:52 +0000 | [diff] [blame] | 673 | targetBitrate == other.targetBitrate && |
mallinath@webrtc.org | 40fee00 | 2014-03-21 00:41:28 +0000 | [diff] [blame] | 674 | maxFramerate == other.maxFramerate && |
| 675 | qpMax == other.qpMax && |
| 676 | numberOfSimulcastStreams == other.numberOfSimulcastStreams && |
| 677 | mode == other.mode; |
| 678 | if (ret && codecType == kVideoCodecVP8) { |
| 679 | ret &= (codecSpecific.VP8 == other.codecSpecific.VP8); |
| 680 | } |
| 681 | |
| 682 | for (unsigned char i = 0; i < other.numberOfSimulcastStreams && ret; ++i) { |
| 683 | ret &= (simulcastStream[i] == other.simulcastStream[i]); |
| 684 | } |
| 685 | return ret; |
| 686 | } |
| 687 | |
| 688 | bool operator!=(const VideoCodec& other) const { |
| 689 | return !(*this == other); |
| 690 | } |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 691 | }; |
| 692 | |
| 693 | // Bandwidth over-use detector options. These are used to drive |
| 694 | // experimentation with bandwidth estimation parameters. |
| 695 | // See modules/remote_bitrate_estimator/overuse_detector.h |
| 696 | struct OverUseDetectorOptions { |
| 697 | OverUseDetectorOptions() |
| 698 | : initial_slope(8.0/512.0), |
| 699 | initial_offset(0), |
| 700 | initial_e(), |
| 701 | initial_process_noise(), |
| 702 | initial_avg_noise(0.0), |
| 703 | initial_var_noise(50), |
| 704 | initial_threshold(25.0) { |
| 705 | initial_e[0][0] = 100; |
| 706 | initial_e[1][1] = 1e-1; |
| 707 | initial_e[0][1] = initial_e[1][0] = 0; |
| 708 | initial_process_noise[0] = 1e-10; |
| 709 | initial_process_noise[1] = 1e-2; |
| 710 | } |
| 711 | double initial_slope; |
| 712 | double initial_offset; |
| 713 | double initial_e[2][2]; |
| 714 | double initial_process_noise[2]; |
| 715 | double initial_avg_noise; |
| 716 | double initial_var_noise; |
| 717 | double initial_threshold; |
| 718 | }; |
andrew@webrtc.org | 81c4d24 | 2013-09-09 17:50:10 +0000 | [diff] [blame] | 719 | |
wu@webrtc.org | 3a4fc4b | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 720 | // This structure will have the information about when packet is actually |
| 721 | // received by socket. |
| 722 | struct PacketTime { |
| 723 | PacketTime() : timestamp(-1), max_error_us(-1) {} |
| 724 | PacketTime(int64_t timestamp, int64_t max_error_us) |
| 725 | : timestamp(timestamp), max_error_us(max_error_us) { |
| 726 | } |
| 727 | |
| 728 | int64_t timestamp; // Receive time after socket delivers the data. |
| 729 | int64_t max_error_us; // Earliest possible time the data could have arrived, |
| 730 | // indicating the potential error in the |timestamp| |
| 731 | // value,in case the system is busy. |
| 732 | // For example, the time of the last select() call. |
| 733 | // If unknown, this value will be set to zero. |
| 734 | }; |
| 735 | |
solenberg@webrtc.org | 5f804f8 | 2014-03-24 10:38:25 +0000 | [diff] [blame] | 736 | struct RTPHeaderExtension { |
| 737 | RTPHeaderExtension() |
| 738 | : hasTransmissionTimeOffset(false), |
| 739 | transmissionTimeOffset(0), |
| 740 | hasAbsoluteSendTime(false), |
| 741 | absoluteSendTime(0), |
| 742 | hasAudioLevel(false), |
| 743 | audioLevel(0) {} |
| 744 | |
| 745 | bool hasTransmissionTimeOffset; |
| 746 | int32_t transmissionTimeOffset; |
| 747 | bool hasAbsoluteSendTime; |
| 748 | uint32_t absoluteSendTime; |
| 749 | |
| 750 | // Audio Level includes both level in dBov and voiced/unvoiced bit. See: |
| 751 | // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/ |
| 752 | bool hasAudioLevel; |
| 753 | uint8_t audioLevel; |
| 754 | }; |
| 755 | |
| 756 | struct RTPHeader { |
| 757 | RTPHeader() |
| 758 | : markerBit(false), |
| 759 | payloadType(0), |
| 760 | sequenceNumber(0), |
| 761 | timestamp(0), |
| 762 | ssrc(0), |
| 763 | numCSRCs(0), |
| 764 | paddingLength(0), |
| 765 | headerLength(0), |
| 766 | payload_type_frequency(0), |
| 767 | extension() { |
| 768 | memset(&arrOfCSRCs, 0, sizeof(arrOfCSRCs)); |
| 769 | } |
| 770 | |
| 771 | bool markerBit; |
| 772 | uint8_t payloadType; |
| 773 | uint16_t sequenceNumber; |
| 774 | uint32_t timestamp; |
| 775 | uint32_t ssrc; |
| 776 | uint8_t numCSRCs; |
| 777 | uint32_t arrOfCSRCs[kRtpCsrcSize]; |
| 778 | uint8_t paddingLength; |
| 779 | uint16_t headerLength; |
| 780 | int payload_type_frequency; |
| 781 | RTPHeaderExtension extension; |
| 782 | }; |
| 783 | |
pbos@webrtc.org | f39df52 | 2014-03-19 08:43:57 +0000 | [diff] [blame] | 784 | struct VideoStream { |
| 785 | VideoStream() |
| 786 | : width(0), |
| 787 | height(0), |
| 788 | max_framerate(-1), |
| 789 | min_bitrate_bps(-1), |
| 790 | target_bitrate_bps(-1), |
| 791 | max_bitrate_bps(-1), |
| 792 | max_qp(-1) {} |
| 793 | |
| 794 | size_t width; |
| 795 | size_t height; |
| 796 | int max_framerate; |
| 797 | |
| 798 | int min_bitrate_bps; |
| 799 | int target_bitrate_bps; |
| 800 | int max_bitrate_bps; |
| 801 | |
| 802 | int max_qp; |
| 803 | |
| 804 | // Bitrate thresholds for enabling additional temporal layers. |
| 805 | std::vector<int> temporal_layers; |
| 806 | }; |
| 807 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 808 | } // namespace webrtc |
andrew@webrtc.org | 81c4d24 | 2013-09-09 17:50:10 +0000 | [diff] [blame] | 809 | |
| 810 | #endif // WEBRTC_COMMON_TYPES_H_ |