Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / common_types.h
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
11 #ifndef WEBRTC_COMMON_TYPES_H_
12 #define WEBRTC_COMMON_TYPES_H_
13
14 #include <stddef.h>
15 #include <string.h>
16 #include <vector>
17
18 #include "webrtc/typedefs.h"
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
40 #if defined(WEBRTC_WIN) || defined(WIN32)
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
50 namespace webrtc {
51
52 class Config;
53
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 {
76     kTraceUndefined              = 0,
77     // not a module, triggered from the engine code
78     kTraceVoice                  = 0x0001,
79     // not a module, triggered from the engine code
80     kTraceVideo                  = 0x0002,
81     // not a module, triggered from the utility code
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,
96     kTraceRemoteBitrateEstimator = 0x0017,
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
118     // Non-verbose level used by LS_INFO of logging.h. Do not use directly.
119     kTraceTerseInfo          = 0x2000,
120
121     kTraceAll                = 0xffff
122 };
123
124 // External Trace API
125 class TraceCallback {
126  public:
127   virtual void Print(TraceLevel level, const char* message, int length) = 0;
128
129  protected:
130   virtual ~TraceCallback() {}
131   TraceCallback() {}
132 };
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
145 enum ProcessingTypes
146 {
147     kPlaybackPerChannel = 0,
148     kPlaybackAllChannelsMixed,
149     kRecordingPerChannel,
150     kRecordingAllChannelsMixed,
151     kRecordingPreprocessing
152 };
153
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
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
175 // Statistics for an RTCP channel
176 struct RtcpStatistics {
177   RtcpStatistics()
178     : fraction_lost(0),
179       cumulative_lost(0),
180       extended_max_sequence_number(0),
181       jitter(0) {}
182
183   uint8_t fraction_lost;
184   uint32_t cumulative_lost;
185   uint32_t extended_max_sequence_number;
186   uint32_t jitter;
187 };
188
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
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
216 // Data usage statistics for a (rtp) stream
217 struct StreamDataCounters {
218   StreamDataCounters()
219    : bytes(0),
220      header_bytes(0),
221      padding_bytes(0),
222      packets(0),
223      retransmitted_packets(0),
224      fec_packets(0) {}
225
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.
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 {
245   BitrateStatistics() : bitrate_bps(0), packet_rate(0), timestamp_ms(0) {}
246
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.
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:
263   virtual ~FrameCountObserver() {}
264   virtual void FrameCountUpdated(FrameType frame_type,
265                                  uint32_t frame_count,
266                                  const unsigned int ssrc) = 0;
267 };
268
269 // ==================================================================
270 // Voice specific types
271 // ==================================================================
272
273 // Each codec supported can be described by this structure.
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   }
294 };
295
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
323     uint16_t currentBufferSize;
324     // preferred (optimal) buffer size in ms
325     uint16_t preferredBufferSize;
326     // adding extra delay due to "peaky jitter"
327     bool jitterPeaksFound;
328     // loss rate (network + late) in percent (in Q14)
329     uint16_t currentPacketLossRate;
330     // late loss rate in percent (in Q14)
331     uint16_t currentDiscardRate;
332     // fraction (of original stream) of synthesized speech inserted through
333     // expansion (in Q14)
334     uint16_t currentExpandRate;
335     // fraction of synthesized speech inserted through pre-emptive expansion
336     // (in Q14)
337     uint16_t currentPreemptiveRate;
338     // fraction of data removed through acceleration (in Q14)
339     uint16_t currentAccelerateRate;
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;
350     // added samples in off mode due to packet loss
351     int addedSamples;
352 };
353
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
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
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
469 // TODO(henrika): to be removed.
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,
481     // Minimal buffer management. Inserts zeros for lost packets and during
482     // buffer increases.
483     kNetEqOff = 3,
484 };
485
486 // TODO(henrika): to be removed.
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
494 // TODO(henrika): to be removed.
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
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   }
586 };
587
588 // Video codec types
589 enum VideoCodecType
590 {
591     kVideoCodecVP8,
592     kVideoCodecI420,
593     kVideoCodecRED,
594     kVideoCodecULPFEC,
595     kVideoCodecGeneric,
596     kVideoCodecUnknown
597 };
598
599 union VideoCodecUnion
600 {
601     VideoCodecVP8       VP8;
602 };
603
604
605 // Simulcast is when the same stream is encoded multiple times with different
606 // settings such as resolution.
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   }
629 };
630
631 enum VideoCodecMode {
632   kRealtimeVideo,
633   kScreensharing
634 };
635
636 // Common video codec properties
637 struct VideoCodec {
638   VideoCodecType      codecType;
639   char                plName[kPayloadNameSize];
640   unsigned char       plType;
641
642   unsigned short      width;
643   unsigned short      height;
644
645   unsigned int        startBitrate;  // kilobits/sec.
646   unsigned int        maxBitrate;  // kilobits/sec.
647   unsigned int        minBitrate;  // kilobits/sec.
648   unsigned int        targetBitrate;  // kilobits/sec.
649
650   unsigned char       maxFramerate;
651
652   VideoCodecUnion     codecSpecific;
653
654   unsigned int        qpMax;
655   unsigned char       numberOfSimulcastStreams;
656   SimulcastStream     simulcastStream[kMaxSimulcastStreams];
657
658   VideoCodecMode      mode;
659
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;
663
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 &&
673                targetBitrate == other.targetBitrate &&
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   }
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 };
719
720 // This structure will have the information about when packet is actually
721 // received by socket.
722 struct PacketTime {
723   PacketTime() : timestamp(-1), not_before(-1) {}
724   PacketTime(int64_t timestamp, int64_t not_before)
725       : timestamp(timestamp), not_before(not_before) {
726   }
727
728   int64_t timestamp;   // Receive time after socket delivers the data.
729   int64_t not_before;  // 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
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
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
808 }  // namespace webrtc
809
810 #endif  // WEBRTC_COMMON_TYPES_H_