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