kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_H_ |
| 12 | #define MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_H_ |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 13 | |
kwiberg | 84be511 | 2016-04-27 01:19:58 -0700 | [diff] [blame] | 14 | #include <memory> |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 15 | #include <string> |
Fredrik Solenberg | f693bfa | 2018-12-11 12:22:10 +0100 | [diff] [blame] | 16 | #include <utility> |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 17 | #include <vector> |
| 18 | |
Danil Chapovalov | b602123 | 2018-06-19 13:26:36 +0200 | [diff] [blame] | 19 | #include "absl/types/optional.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "api/audio_codecs/audio_decoder_factory.h" |
| 21 | #include "api/audio_codecs/audio_encoder.h" |
Artem Titov | 741daaf | 2019-03-21 14:37:36 +0100 | [diff] [blame] | 22 | #include "api/function_view.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 23 | #include "modules/audio_coding/include/audio_coding_module_typedefs.h" |
| 24 | #include "modules/audio_coding/neteq/include/neteq.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 25 | #include "system_wrappers/include/clock.h" |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 26 | |
| 27 | namespace webrtc { |
| 28 | |
| 29 | // forward declarations |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 30 | class AudioDecoder; |
| 31 | class AudioEncoder; |
| 32 | class AudioFrame; |
Niels Möller | afb5dbb | 2019-02-15 15:21:47 +0100 | [diff] [blame] | 33 | struct RTPHeader; |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 34 | |
| 35 | #define WEBRTC_10MS_PCM_AUDIO 960 // 16 bits super wideband 48 kHz |
| 36 | |
| 37 | // Callback class used for sending data ready to be packetized |
| 38 | class AudioPacketizationCallback { |
| 39 | public: |
| 40 | virtual ~AudioPacketizationCallback() {} |
| 41 | |
Niels Möller | 87e2d78 | 2019-03-07 10:18:23 +0100 | [diff] [blame] | 42 | virtual int32_t SendData(AudioFrameType frame_type, |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 43 | uint8_t payload_type, |
| 44 | uint32_t timestamp, |
| 45 | const uint8_t* payload_data, |
Niels Möller | 4babc68 | 2019-04-26 15:46:12 +0200 | [diff] [blame] | 46 | size_t payload_len_bytes) = 0; |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | // Callback class used for reporting VAD decision |
| 50 | class ACMVADCallback { |
| 51 | public: |
| 52 | virtual ~ACMVADCallback() {} |
| 53 | |
Niels Möller | 87e2d78 | 2019-03-07 10:18:23 +0100 | [diff] [blame] | 54 | virtual int32_t InFrameType(AudioFrameType frame_type) = 0; |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | class AudioCodingModule { |
| 58 | protected: |
| 59 | AudioCodingModule() {} |
| 60 | |
| 61 | public: |
| 62 | struct Config { |
Karl Wiberg | 5817d3d | 2018-04-06 10:06:42 +0200 | [diff] [blame] | 63 | explicit Config( |
| 64 | rtc::scoped_refptr<AudioDecoderFactory> decoder_factory = nullptr); |
kwiberg | 36a4388 | 2016-08-29 05:33:32 -0700 | [diff] [blame] | 65 | Config(const Config&); |
| 66 | ~Config(); |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 67 | |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 68 | NetEq::Config neteq_config; |
| 69 | Clock* clock; |
ossu | e352578 | 2016-05-25 07:37:43 -0700 | [diff] [blame] | 70 | rtc::scoped_refptr<AudioDecoderFactory> decoder_factory; |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 71 | }; |
| 72 | |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 73 | static AudioCodingModule* Create(const Config& config); |
| 74 | virtual ~AudioCodingModule() = default; |
| 75 | |
| 76 | /////////////////////////////////////////////////////////////////////////// |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 77 | // Sender |
| 78 | // |
| 79 | |
kwiberg | 4cdbd57 | 2016-03-30 03:10:05 -0700 | [diff] [blame] | 80 | // |modifier| is called exactly once with one argument: a pointer to the |
| 81 | // unique_ptr that holds the current encoder (which is null if there is no |
| 82 | // current encoder). For the duration of the call, |modifier| has exclusive |
| 83 | // access to the unique_ptr; it may call the encoder, steal the encoder and |
| 84 | // replace it with another encoder or with nullptr, etc. |
| 85 | virtual void ModifyEncoder( |
kwiberg | 24c7c12 | 2016-09-28 11:57:10 -0700 | [diff] [blame] | 86 | rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) = 0; |
kwiberg | 4cdbd57 | 2016-03-30 03:10:05 -0700 | [diff] [blame] | 87 | |
| 88 | // Utility method for simply replacing the existing encoder with a new one. |
| 89 | void SetEncoder(std::unique_ptr<AudioEncoder> new_encoder) { |
| 90 | ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 91 | *encoder = std::move(new_encoder); |
| 92 | }); |
| 93 | } |
| 94 | |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 95 | /////////////////////////////////////////////////////////////////////////// |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 96 | // Sets the bitrate to the specified value in bits/sec. If the value is not |
| 97 | // supported by the codec, it will choose another appropriate value. |
minyue | 7e30432 | 2016-10-12 05:00:55 -0700 | [diff] [blame] | 98 | // |
| 99 | // This is only used in test code that rely on old ACM APIs. |
| 100 | // TODO(minyue): Remove it when possible. |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 101 | virtual void SetBitRate(int bitrate_bps) = 0; |
| 102 | |
| 103 | // int32_t RegisterTransportCallback() |
| 104 | // Register a transport callback which will be called to deliver |
| 105 | // the encoded buffers whenever Process() is called and a |
| 106 | // bit-stream is ready. |
| 107 | // |
| 108 | // Input: |
| 109 | // -transport : pointer to the callback class |
| 110 | // transport->SendData() is called whenever |
| 111 | // Process() is called and bit-stream is ready |
| 112 | // to deliver. |
| 113 | // |
| 114 | // Return value: |
| 115 | // -1 if the transport callback could not be registered |
| 116 | // 0 if registration is successful. |
| 117 | // |
| 118 | virtual int32_t RegisterTransportCallback( |
| 119 | AudioPacketizationCallback* transport) = 0; |
| 120 | |
| 121 | /////////////////////////////////////////////////////////////////////////// |
| 122 | // int32_t Add10MsData() |
| 123 | // Add 10MS of raw (PCM) audio data and encode it. If the sampling |
| 124 | // frequency of the audio does not match the sampling frequency of the |
| 125 | // current encoder ACM will resample the audio. If an encoded packet was |
| 126 | // produced, it will be delivered via the callback object registered using |
| 127 | // RegisterTransportCallback, and the return value from this function will |
| 128 | // be the number of bytes encoded. |
| 129 | // |
| 130 | // Input: |
| 131 | // -audio_frame : the input audio frame, containing raw audio |
Fredrik Solenberg | bbf21a3 | 2018-04-12 22:44:09 +0200 | [diff] [blame] | 132 | // sampling frequency etc. |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 133 | // |
| 134 | // Return value: |
| 135 | // >= 0 number of bytes encoded. |
| 136 | // -1 some error occurred. |
| 137 | // |
| 138 | virtual int32_t Add10MsData(const AudioFrame& audio_frame) = 0; |
| 139 | |
| 140 | /////////////////////////////////////////////////////////////////////////// |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 141 | // int SetPacketLossRate() |
| 142 | // Sets expected packet loss rate for encoding. Some encoders provide packet |
| 143 | // loss gnostic encoding to make stream less sensitive to packet losses, |
| 144 | // through e.g., FEC. No effects on codecs that do not provide such encoding. |
| 145 | // |
| 146 | // Input: |
| 147 | // -packet_loss_rate : expected packet loss rate (0 -- 100 inclusive). |
| 148 | // |
| 149 | // Return value |
| 150 | // -1 if failed to set packet loss rate, |
| 151 | // 0 if succeeded. |
| 152 | // |
minyue | 7e30432 | 2016-10-12 05:00:55 -0700 | [diff] [blame] | 153 | // This is only used in test code that rely on old ACM APIs. |
| 154 | // TODO(minyue): Remove it when possible. |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 155 | virtual int SetPacketLossRate(int packet_loss_rate) = 0; |
| 156 | |
| 157 | /////////////////////////////////////////////////////////////////////////// |
| 158 | // (VAD) Voice Activity Detection |
| 159 | // |
| 160 | |
| 161 | /////////////////////////////////////////////////////////////////////////// |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 162 | // int32_t RegisterVADCallback() |
| 163 | // Call this method to register a callback function which is called |
| 164 | // any time that ACM encounters an empty frame. That is a frame which is |
| 165 | // recognized inactive. Depending on the codec WebRtc VAD or internal codec |
| 166 | // VAD is employed to identify a frame as active/inactive. |
| 167 | // |
| 168 | // Input: |
| 169 | // -vad_callback : pointer to a callback function. |
| 170 | // |
| 171 | // Return value: |
| 172 | // -1 if failed to register the callback function. |
| 173 | // 0 if the callback function is registered successfully. |
| 174 | // |
| 175 | virtual int32_t RegisterVADCallback(ACMVADCallback* vad_callback) = 0; |
| 176 | |
| 177 | /////////////////////////////////////////////////////////////////////////// |
| 178 | // Receiver |
| 179 | // |
| 180 | |
| 181 | /////////////////////////////////////////////////////////////////////////// |
| 182 | // int32_t InitializeReceiver() |
| 183 | // Any decoder-related state of ACM will be initialized to the |
| 184 | // same state when ACM is created. This will not interrupt or |
| 185 | // effect encoding functionality of ACM. ACM would lose all the |
| 186 | // decoding-related settings by calling this function. |
| 187 | // For instance, all registered codecs are deleted and have to be |
| 188 | // registered again. |
| 189 | // |
| 190 | // Return value: |
| 191 | // -1 if failed to initialize, |
| 192 | // 0 if succeeded. |
| 193 | // |
| 194 | virtual int32_t InitializeReceiver() = 0; |
| 195 | |
| 196 | /////////////////////////////////////////////////////////////////////////// |
| 197 | // int32_t ReceiveFrequency() |
| 198 | // Get sampling frequency of the last received payload. |
| 199 | // |
| 200 | // Return value: |
| 201 | // non-negative the sampling frequency in Hertz. |
| 202 | // -1 if an error has occurred. |
| 203 | // |
| 204 | virtual int32_t ReceiveFrequency() const = 0; |
| 205 | |
| 206 | /////////////////////////////////////////////////////////////////////////// |
| 207 | // int32_t PlayoutFrequency() |
| 208 | // Get sampling frequency of audio played out. |
| 209 | // |
| 210 | // Return value: |
| 211 | // the sampling frequency in Hertz. |
| 212 | // |
| 213 | virtual int32_t PlayoutFrequency() const = 0; |
| 214 | |
kwiberg | 1c07c70 | 2017-03-27 07:15:49 -0700 | [diff] [blame] | 215 | // Replace any existing decoders with the given payload type -> decoder map. |
| 216 | virtual void SetReceiveCodecs( |
| 217 | const std::map<int, SdpAudioFormat>& codecs) = 0; |
| 218 | |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 219 | /////////////////////////////////////////////////////////////////////////// |
Fredrik Solenberg | f693bfa | 2018-12-11 12:22:10 +0100 | [diff] [blame] | 220 | // absl::optional<std::pair<int, SdpAudioFormat>> ReceiveCodec() |
| 221 | // Get the codec info associated with last received payload. |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 222 | // |
| 223 | // Return value: |
Fredrik Solenberg | f693bfa | 2018-12-11 12:22:10 +0100 | [diff] [blame] | 224 | // A payload type and SdpAudioFormat describing the format associated with |
| 225 | // the last received payload. |
ossu | e280cde | 2016-10-12 11:04:10 -0700 | [diff] [blame] | 226 | // An empty Optional if no payload has yet been received. |
| 227 | // |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame^] | 228 | virtual absl::optional<std::pair<int, SdpAudioFormat>> ReceiveCodec() |
| 229 | const = 0; |
ossu | e280cde | 2016-10-12 11:04:10 -0700 | [diff] [blame] | 230 | |
| 231 | /////////////////////////////////////////////////////////////////////////// |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 232 | // int32_t IncomingPacket() |
| 233 | // Call this function to insert a parsed RTP packet into ACM. |
| 234 | // |
| 235 | // Inputs: |
| 236 | // -incoming_payload : received payload. |
| 237 | // -payload_len_bytes : the length of payload in bytes. |
| 238 | // -rtp_info : the relevant information retrieved from RTP |
| 239 | // header. |
| 240 | // |
| 241 | // Return value: |
| 242 | // -1 if failed to push in the payload |
| 243 | // 0 if payload is successfully pushed in. |
| 244 | // |
| 245 | virtual int32_t IncomingPacket(const uint8_t* incoming_payload, |
| 246 | const size_t payload_len_bytes, |
Niels Möller | afb5dbb | 2019-02-15 15:21:47 +0100 | [diff] [blame] | 247 | const RTPHeader& rtp_header) = 0; |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 248 | |
| 249 | /////////////////////////////////////////////////////////////////////////// |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 250 | // int SetMinimumPlayoutDelay() |
| 251 | // Set a minimum for the playout delay, used for lip-sync. NetEq maintains |
| 252 | // such a delay unless channel condition yields to a higher delay. |
| 253 | // |
| 254 | // Input: |
| 255 | // -time_ms : minimum delay in milliseconds. |
| 256 | // |
| 257 | // Return value: |
| 258 | // -1 if failed to set the delay, |
| 259 | // 0 if the minimum delay is set. |
| 260 | // |
| 261 | virtual int SetMinimumPlayoutDelay(int time_ms) = 0; |
| 262 | |
| 263 | /////////////////////////////////////////////////////////////////////////// |
| 264 | // int SetMaximumPlayoutDelay() |
| 265 | // Set a maximum for the playout delay |
| 266 | // |
| 267 | // Input: |
| 268 | // -time_ms : maximum delay in milliseconds. |
| 269 | // |
| 270 | // Return value: |
| 271 | // -1 if failed to set the delay, |
| 272 | // 0 if the maximum delay is set. |
| 273 | // |
| 274 | virtual int SetMaximumPlayoutDelay(int time_ms) = 0; |
| 275 | |
Ruslan Burakov | 3b50f9f | 2019-02-06 09:45:56 +0100 | [diff] [blame] | 276 | // Sets a base minimum for the playout delay. Base minimum delay sets lower |
| 277 | // bound minimum delay value which is set via SetMinimumPlayoutDelay. |
| 278 | // |
| 279 | // Returns true if value was successfully set, false overwise. |
| 280 | virtual bool SetBaseMinimumPlayoutDelayMs(int delay_ms) = 0; |
| 281 | |
| 282 | // Returns current value of base minimum delay in milliseconds. |
| 283 | virtual int GetBaseMinimumPlayoutDelayMs() const = 0; |
| 284 | |
henrik.lundin | 9a410dd | 2016-04-06 01:39:22 -0700 | [diff] [blame] | 285 | /////////////////////////////////////////////////////////////////////////// |
| 286 | // int32_t PlayoutTimestamp() |
| 287 | // The send timestamp of an RTP packet is associated with the decoded |
| 288 | // audio of the packet in question. This function returns the timestamp of |
| 289 | // the latest audio obtained by calling PlayoutData10ms(), or empty if no |
| 290 | // valid timestamp is available. |
| 291 | // |
Danil Chapovalov | b602123 | 2018-06-19 13:26:36 +0200 | [diff] [blame] | 292 | virtual absl::optional<uint32_t> PlayoutTimestamp() = 0; |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 293 | |
| 294 | /////////////////////////////////////////////////////////////////////////// |
henrik.lundin | b3f1c5d | 2016-08-22 15:39:53 -0700 | [diff] [blame] | 295 | // int FilteredCurrentDelayMs() |
| 296 | // Returns the current total delay from NetEq (packet buffer and sync buffer) |
| 297 | // in ms, with smoothing applied to even out short-time fluctuations due to |
| 298 | // jitter. The packet buffer part of the delay is not updated during DTX/CNG |
| 299 | // periods. |
| 300 | // |
| 301 | virtual int FilteredCurrentDelayMs() const = 0; |
| 302 | |
| 303 | /////////////////////////////////////////////////////////////////////////// |
Henrik Lundin | abbff89 | 2017-11-29 09:14:04 +0100 | [diff] [blame] | 304 | // int FilteredCurrentDelayMs() |
| 305 | // Returns the current target delay for NetEq in ms. |
| 306 | // |
| 307 | virtual int TargetDelayMs() const = 0; |
| 308 | |
| 309 | /////////////////////////////////////////////////////////////////////////// |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 310 | // int32_t PlayoutData10Ms( |
| 311 | // Get 10 milliseconds of raw audio data for playout, at the given sampling |
| 312 | // frequency. ACM will perform a resampling if required. |
| 313 | // |
| 314 | // Input: |
| 315 | // -desired_freq_hz : the desired sampling frequency, in Hertz, of the |
| 316 | // output audio. If set to -1, the function returns |
| 317 | // the audio at the current sampling frequency. |
| 318 | // |
| 319 | // Output: |
| 320 | // -audio_frame : output audio frame which contains raw audio data |
Fredrik Solenberg | bbf21a3 | 2018-04-12 22:44:09 +0200 | [diff] [blame] | 321 | // and other relevant parameters. |
henrik.lundin | 834a6ea | 2016-05-13 03:45:24 -0700 | [diff] [blame] | 322 | // -muted : if true, the sample data in audio_frame is not |
| 323 | // populated, and must be interpreted as all zero. |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 324 | // |
| 325 | // Return value: |
| 326 | // -1 if the function fails, |
| 327 | // 0 if the function succeeds. |
| 328 | // |
| 329 | virtual int32_t PlayoutData10Ms(int32_t desired_freq_hz, |
henrik.lundin | 834a6ea | 2016-05-13 03:45:24 -0700 | [diff] [blame] | 330 | AudioFrame* audio_frame, |
| 331 | bool* muted) = 0; |
| 332 | |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 333 | /////////////////////////////////////////////////////////////////////////// |
| 334 | // Codec specific |
| 335 | // |
| 336 | |
| 337 | /////////////////////////////////////////////////////////////////////////// |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 338 | // int SetOpusMaxPlaybackRate() |
| 339 | // If current send codec is Opus, informs it about maximum playback rate the |
| 340 | // receiver will render. Opus can use this information to optimize the bit |
| 341 | // rate and increase the computation efficiency. |
| 342 | // |
| 343 | // Input: |
| 344 | // -frequency_hz : maximum playback rate in Hz. |
| 345 | // |
| 346 | // Return value: |
| 347 | // -1 if current send codec is not Opus or |
| 348 | // error occurred in setting the maximum playback rate, |
| 349 | // 0 if maximum bandwidth is set successfully. |
| 350 | // |
| 351 | virtual int SetOpusMaxPlaybackRate(int frequency_hz) = 0; |
| 352 | |
| 353 | /////////////////////////////////////////////////////////////////////////// |
| 354 | // EnableOpusDtx() |
| 355 | // Enable the DTX, if current send codec is Opus. |
| 356 | // |
| 357 | // Return value: |
| 358 | // -1 if current send codec is not Opus or error occurred in enabling the |
| 359 | // Opus DTX. |
| 360 | // 0 if Opus DTX is enabled successfully. |
| 361 | // |
| 362 | virtual int EnableOpusDtx() = 0; |
| 363 | |
| 364 | /////////////////////////////////////////////////////////////////////////// |
| 365 | // int DisableOpusDtx() |
| 366 | // If current send codec is Opus, disables its internal DTX. |
| 367 | // |
| 368 | // Return value: |
| 369 | // -1 if current send codec is not Opus or error occurred in disabling DTX. |
| 370 | // 0 if Opus DTX is disabled successfully. |
| 371 | // |
| 372 | virtual int DisableOpusDtx() = 0; |
| 373 | |
| 374 | /////////////////////////////////////////////////////////////////////////// |
| 375 | // statistics |
| 376 | // |
| 377 | |
| 378 | /////////////////////////////////////////////////////////////////////////// |
| 379 | // int32_t GetNetworkStatistics() |
| 380 | // Get network statistics. Note that the internal statistics of NetEq are |
| 381 | // reset by this call. |
| 382 | // |
| 383 | // Input: |
| 384 | // -network_statistics : a structure that contains network statistics. |
| 385 | // |
| 386 | // Return value: |
| 387 | // -1 if failed to set the network statistics, |
| 388 | // 0 if statistics are set successfully. |
| 389 | // |
| 390 | virtual int32_t GetNetworkStatistics( |
| 391 | NetworkStatistics* network_statistics) = 0; |
| 392 | |
| 393 | // |
| 394 | // Enable NACK and set the maximum size of the NACK list. If NACK is already |
| 395 | // enable then the maximum NACK list size is modified accordingly. |
| 396 | // |
| 397 | // If the sequence number of last received packet is N, the sequence numbers |
| 398 | // of NACK list are in the range of [N - |max_nack_list_size|, N). |
| 399 | // |
| 400 | // |max_nack_list_size| should be positive (none zero) and less than or |
| 401 | // equal to |Nack::kNackListSizeLimit|. Otherwise, No change is applied and -1 |
| 402 | // is returned. 0 is returned at success. |
| 403 | // |
| 404 | virtual int EnableNack(size_t max_nack_list_size) = 0; |
| 405 | |
| 406 | // Disable NACK. |
| 407 | virtual void DisableNack() = 0; |
| 408 | |
| 409 | // |
| 410 | // Get a list of packets to be retransmitted. |round_trip_time_ms| is an |
| 411 | // estimate of the round-trip-time (in milliseconds). Missing packets which |
| 412 | // will be playout in a shorter time than the round-trip-time (with respect |
| 413 | // to the time this API is called) will not be included in the list. |
| 414 | // |
| 415 | // Negative |round_trip_time_ms| results is an error message and empty list |
| 416 | // is returned. |
| 417 | // |
| 418 | virtual std::vector<uint16_t> GetNackList( |
| 419 | int64_t round_trip_time_ms) const = 0; |
| 420 | |
| 421 | virtual void GetDecodingCallStatistics( |
| 422 | AudioDecodingCallStats* call_stats) const = 0; |
ivoc | e1198e0 | 2017-09-08 08:13:19 -0700 | [diff] [blame] | 423 | |
| 424 | virtual ANAStats GetANAStats() const = 0; |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 425 | }; |
| 426 | |
| 427 | } // namespace webrtc |
| 428 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 429 | #endif // MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_H_ |