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