xref: /aosp_15_r20/external/webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2011 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 MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_TYPEDEFS_H_
12 #define MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_TYPEDEFS_H_
13 
14 #include <map>
15 
16 namespace webrtc {
17 
18 ///////////////////////////////////////////////////////////////////////////
19 // enum ACMVADMode
20 // An enumerator for aggressiveness of VAD
21 // -VADNormal                : least aggressive mode.
22 // -VADLowBitrate            : more aggressive than "VADNormal" to save on
23 //                             bit-rate.
24 // -VADAggr                  : an aggressive mode.
25 // -VADVeryAggr              : the most agressive mode.
26 //
27 enum ACMVADMode {
28   VADNormal = 0,
29   VADLowBitrate = 1,
30   VADAggr = 2,
31   VADVeryAggr = 3
32 };
33 
34 enum class AudioFrameType {
35   kEmptyFrame = 0,
36   kAudioFrameSpeech = 1,
37   kAudioFrameCN = 2,
38 };
39 
40 ///////////////////////////////////////////////////////////////////////////
41 //
42 // Enumeration of Opus mode for intended application.
43 //
44 // kVoip              : optimized for voice signals.
45 // kAudio             : optimized for non-voice signals like music.
46 //
47 enum OpusApplicationMode {
48   kVoip = 0,
49   kAudio = 1,
50 };
51 
52 // Statistics for calls to AudioCodingModule::PlayoutData10Ms().
53 struct AudioDecodingCallStats {
AudioDecodingCallStatsAudioDecodingCallStats54   AudioDecodingCallStats()
55       : calls_to_silence_generator(0),
56         calls_to_neteq(0),
57         decoded_normal(0),
58         decoded_neteq_plc(0),
59         decoded_codec_plc(0),
60         decoded_cng(0),
61         decoded_plc_cng(0),
62         decoded_muted_output(0) {}
63 
64   int calls_to_silence_generator;  // Number of calls where silence generated,
65                                    // and NetEq was disengaged from decoding.
66   int calls_to_neteq;              // Number of calls to NetEq.
67   int decoded_normal;  // Number of calls where audio RTP packet decoded.
68   int decoded_neteq_plc;  // Number of calls resulted in NetEq PLC.
69   int decoded_codec_plc;  // Number of calls resulted in codec PLC.
70   int decoded_cng;  // Number of calls where comfort noise generated due to DTX.
71   int decoded_plc_cng;       // Number of calls resulted where PLC faded to CNG.
72   int decoded_muted_output;  // Number of calls returning a muted state output.
73 };
74 
75 // NETEQ statistics.
76 struct NetworkStatistics {
77   // current jitter buffer size in ms
78   uint16_t currentBufferSize;
79   // preferred (optimal) buffer size in ms
80   uint16_t preferredBufferSize;
81   // adding extra delay due to "peaky jitter"
82   bool jitterPeaksFound;
83   // Stats below correspond to similarly-named fields in the WebRTC stats spec.
84   // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats
85   uint64_t totalSamplesReceived;
86   uint64_t concealedSamples;
87   uint64_t silentConcealedSamples;
88   uint64_t concealmentEvents;
89   uint64_t jitterBufferDelayMs;
90   uint64_t jitterBufferTargetDelayMs;
91   uint64_t jitterBufferMinimumDelayMs;
92   uint64_t jitterBufferEmittedCount;
93   uint64_t insertedSamplesForDeceleration;
94   uint64_t removedSamplesForAcceleration;
95   uint64_t fecPacketsReceived;
96   uint64_t fecPacketsDiscarded;
97   // Stats below correspond to similarly-named fields in the WebRTC stats spec.
98   // https://w3c.github.io/webrtc-stats/#dom-rtcreceivedrtpstreamstats
99   uint64_t packetsDiscarded;
100   // Stats below DO NOT correspond directly to anything in the WebRTC stats
101   // fraction (of original stream) of synthesized audio inserted through
102   // expansion (in Q14)
103   uint16_t currentExpandRate;
104   // fraction (of original stream) of synthesized speech inserted through
105   // expansion (in Q14)
106   uint16_t currentSpeechExpandRate;
107   // fraction of synthesized speech inserted through pre-emptive expansion
108   // (in Q14)
109   uint16_t currentPreemptiveRate;
110   // fraction of data removed through acceleration (in Q14)
111   uint16_t currentAccelerateRate;
112   // fraction of data coming from secondary decoding (in Q14)
113   uint16_t currentSecondaryDecodedRate;
114   // Fraction of secondary data, including FEC and RED, that is discarded (in
115   // Q14). Discarding of secondary data can be caused by the reception of the
116   // primary data, obsoleting the secondary data. It can also be caused by early
117   // or late arrival of secondary data.
118   uint16_t currentSecondaryDiscardedRate;
119   // average packet waiting time in the jitter buffer (ms)
120   int meanWaitingTimeMs;
121   // max packet waiting time in the jitter buffer (ms)
122   int maxWaitingTimeMs;
123   // count of the number of buffer flushes
124   uint64_t packetBufferFlushes;
125   // number of samples expanded due to delayed packets
126   uint64_t delayedPacketOutageSamples;
127   // arrival delay of incoming packets
128   uint64_t relativePacketArrivalDelayMs;
129   // number of audio interruptions
130   int32_t interruptionCount;
131   // total duration of audio interruptions
132   int32_t totalInterruptionDurationMs;
133 };
134 
135 }  // namespace webrtc
136 
137 #endif  // MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_TYPEDEFS_H_
138