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_MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_H_
12#define WEBRTC_MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_H_
13
14#include <string>
15#include <vector>
16
17#include "webrtc/base/optional.h"
18#include "webrtc/common_types.h"
19#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
20#include "webrtc/modules/audio_coding/neteq/include/neteq.h"
21#include "webrtc/modules/include/module.h"
22#include "webrtc/system_wrappers/include/clock.h"
23#include "webrtc/typedefs.h"
24
25namespace webrtc {
26
27// forward declarations
28struct CodecInst;
29struct WebRtcRTPHeader;
30class AudioDecoder;
31class AudioEncoder;
32class AudioFrame;
33class RTPFragmentationHeader;
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
38class AudioPacketizationCallback {
39 public:
40  virtual ~AudioPacketizationCallback() {}
41
42  virtual int32_t SendData(FrameType frame_type,
43                           uint8_t payload_type,
44                           uint32_t timestamp,
45                           const uint8_t* payload_data,
46                           size_t payload_len_bytes,
47                           const RTPFragmentationHeader* fragmentation) = 0;
48};
49
50// Callback class used for reporting VAD decision
51class ACMVADCallback {
52 public:
53  virtual ~ACMVADCallback() {}
54
55  virtual int32_t InFrameType(FrameType frame_type) = 0;
56};
57
58class AudioCodingModule {
59 protected:
60  AudioCodingModule() {}
61
62 public:
63  struct Config {
64    Config() : id(0), neteq_config(), clock(Clock::GetRealTimeClock()) {
65      // Post-decode VAD is disabled by default in NetEq, however, Audio
66      // Conference Mixer relies on VAD decisions and fails without them.
67      neteq_config.enable_post_decode_vad = true;
68    }
69
70    int id;
71    NetEq::Config neteq_config;
72    Clock* clock;
73  };
74
75  ///////////////////////////////////////////////////////////////////////////
76  // Creation and destruction of a ACM.
77  //
78  // The second method is used for testing where a simulated clock can be
79  // injected into ACM. ACM will take the ownership of the object clock and
80  // delete it when destroyed.
81  //
82  static AudioCodingModule* Create(int id);
83  static AudioCodingModule* Create(int id, Clock* clock);
84  static AudioCodingModule* Create(const Config& config);
85  virtual ~AudioCodingModule() = default;
86
87  ///////////////////////////////////////////////////////////////////////////
88  //   Utility functions
89  //
90
91  ///////////////////////////////////////////////////////////////////////////
92  // uint8_t NumberOfCodecs()
93  // Returns number of supported codecs.
94  //
95  // Return value:
96  //   number of supported codecs.
97  ///
98  static int NumberOfCodecs();
99
100  ///////////////////////////////////////////////////////////////////////////
101  // int32_t Codec()
102  // Get supported codec with list number.
103  //
104  // Input:
105  //   -list_id             : list number.
106  //
107  // Output:
108  //   -codec              : a structure where the parameters of the codec,
109  //                         given by list number is written to.
110  //
111  // Return value:
112  //   -1 if the list number (list_id) is invalid.
113  //    0 if succeeded.
114  //
115  static int Codec(int list_id, CodecInst* codec);
116
117  ///////////////////////////////////////////////////////////////////////////
118  // int32_t Codec()
119  // Get supported codec with the given codec name, sampling frequency, and
120  // a given number of channels.
121  //
122  // Input:
123  //   -payload_name       : name of the codec.
124  //   -sampling_freq_hz   : sampling frequency of the codec. Note! for RED
125  //                         a sampling frequency of -1 is a valid input.
126  //   -channels           : number of channels ( 1 - mono, 2 - stereo).
127  //
128  // Output:
129  //   -codec              : a structure where the function returns the
130  //                         default parameters of the codec.
131  //
132  // Return value:
133  //   -1 if no codec matches the given parameters.
134  //    0 if succeeded.
135  //
136  static int Codec(const char* payload_name, CodecInst* codec,
137                   int sampling_freq_hz, size_t channels);
138
139  ///////////////////////////////////////////////////////////////////////////
140  // int32_t Codec()
141  //
142  // Returns the list number of the given codec name, sampling frequency, and
143  // a given number of channels.
144  //
145  // Input:
146  //   -payload_name        : name of the codec.
147  //   -sampling_freq_hz    : sampling frequency of the codec. Note! for RED
148  //                          a sampling frequency of -1 is a valid input.
149  //   -channels            : number of channels ( 1 - mono, 2 - stereo).
150  //
151  // Return value:
152  //   if the codec is found, the index of the codec in the list,
153  //   -1 if the codec is not found.
154  //
155  static int Codec(const char* payload_name, int sampling_freq_hz,
156                   size_t channels);
157
158  ///////////////////////////////////////////////////////////////////////////
159  // bool IsCodecValid()
160  // Checks the validity of the parameters of the given codec.
161  //
162  // Input:
163  //   -codec              : the structure which keeps the parameters of the
164  //                         codec.
165  //
166  // Return value:
167  //   true if the parameters are valid,
168  //   false if any parameter is not valid.
169  //
170  static bool IsCodecValid(const CodecInst& codec);
171
172  ///////////////////////////////////////////////////////////////////////////
173  //   Sender
174  //
175
176  ///////////////////////////////////////////////////////////////////////////
177  // int32_t RegisterSendCodec()
178  // Registers a codec, specified by |send_codec|, as sending codec.
179  // This API can be called multiple of times to register Codec. The last codec
180  // registered overwrites the previous ones.
181  // The API can also be used to change payload type for CNG and RED, which are
182  // registered by default to default payload types.
183  // Note that registering CNG and RED won't overwrite speech codecs.
184  // This API can be called to set/change the send payload-type, frame-size
185  // or encoding rate (if applicable for the codec).
186  //
187  // Note: If a stereo codec is registered as send codec, VAD/DTX will
188  // automatically be turned off, since it is not supported for stereo sending.
189  //
190  // Note: If a secondary encoder is already registered, and the new send-codec
191  // has a sampling rate that does not match the secondary encoder, the
192  // secondary encoder will be unregistered.
193  //
194  // Input:
195  //   -send_codec         : Parameters of the codec to be registered, c.f.
196  //                         common_types.h for the definition of
197  //                         CodecInst.
198  //
199  // Return value:
200  //   -1 if failed to initialize,
201  //    0 if succeeded.
202  //
203  virtual int32_t RegisterSendCodec(const CodecInst& send_codec) = 0;
204
205  // Registers |external_speech_encoder| as encoder. The new encoder will
206  // replace any previously registered speech encoder (internal or external).
207  virtual void RegisterExternalSendCodec(
208      AudioEncoder* external_speech_encoder) = 0;
209
210  ///////////////////////////////////////////////////////////////////////////
211  // int32_t SendCodec()
212  // Get parameters for the codec currently registered as send codec.
213  //
214  // Return value:
215  //   The send codec, or nothing if we don't have one
216  //
217  virtual rtc::Optional<CodecInst> SendCodec() const = 0;
218
219  ///////////////////////////////////////////////////////////////////////////
220  // int32_t SendFrequency()
221  // Get the sampling frequency of the current encoder in Hertz.
222  //
223  // Return value:
224  //   positive; sampling frequency [Hz] of the current encoder.
225  //   -1 if an error has happened.
226  //
227  virtual int32_t SendFrequency() const = 0;
228
229  ///////////////////////////////////////////////////////////////////////////
230  // Sets the bitrate to the specified value in bits/sec. If the value is not
231  // supported by the codec, it will choose another appropriate value.
232  virtual void SetBitRate(int bitrate_bps) = 0;
233
234  // int32_t RegisterTransportCallback()
235  // Register a transport callback which will be called to deliver
236  // the encoded buffers whenever Process() is called and a
237  // bit-stream is ready.
238  //
239  // Input:
240  //   -transport          : pointer to the callback class
241  //                         transport->SendData() is called whenever
242  //                         Process() is called and bit-stream is ready
243  //                         to deliver.
244  //
245  // Return value:
246  //   -1 if the transport callback could not be registered
247  //    0 if registration is successful.
248  //
249  virtual int32_t RegisterTransportCallback(
250      AudioPacketizationCallback* transport) = 0;
251
252  ///////////////////////////////////////////////////////////////////////////
253  // int32_t Add10MsData()
254  // Add 10MS of raw (PCM) audio data and encode it. If the sampling
255  // frequency of the audio does not match the sampling frequency of the
256  // current encoder ACM will resample the audio. If an encoded packet was
257  // produced, it will be delivered via the callback object registered using
258  // RegisterTransportCallback, and the return value from this function will
259  // be the number of bytes encoded.
260  //
261  // Input:
262  //   -audio_frame        : the input audio frame, containing raw audio
263  //                         sampling frequency etc.,
264  //                         c.f. module_common_types.h for definition of
265  //                         AudioFrame.
266  //
267  // Return value:
268  //   >= 0   number of bytes encoded.
269  //     -1   some error occurred.
270  //
271  virtual int32_t Add10MsData(const AudioFrame& audio_frame) = 0;
272
273  ///////////////////////////////////////////////////////////////////////////
274  // (RED) Redundant Coding
275  //
276
277  ///////////////////////////////////////////////////////////////////////////
278  // int32_t SetREDStatus()
279  // configure RED status i.e. on/off.
280  //
281  // RFC 2198 describes a solution which has a single payload type which
282  // signifies a packet with redundancy. That packet then becomes a container,
283  // encapsulating multiple payloads into a single RTP packet.
284  // Such a scheme is flexible, since any amount of redundancy may be
285  // encapsulated within a single packet.  There is, however, a small overhead
286  // since each encapsulated payload must be preceded by a header indicating
287  // the type of data enclosed.
288  //
289  // Input:
290  //   -enable_red         : if true RED is enabled, otherwise RED is
291  //                         disabled.
292  //
293  // Return value:
294  //   -1 if failed to set RED status,
295  //    0 if succeeded.
296  //
297  virtual int32_t SetREDStatus(bool enable_red) = 0;
298
299  ///////////////////////////////////////////////////////////////////////////
300  // bool REDStatus()
301  // Get RED status
302  //
303  // Return value:
304  //   true if RED is enabled,
305  //   false if RED is disabled.
306  //
307  virtual bool REDStatus() const = 0;
308
309  ///////////////////////////////////////////////////////////////////////////
310  // (FEC) Forward Error Correction (codec internal)
311  //
312
313  ///////////////////////////////////////////////////////////////////////////
314  // int32_t SetCodecFEC()
315  // Configures codec internal FEC status i.e. on/off. No effects on codecs that
316  // do not provide internal FEC.
317  //
318  // Input:
319  //   -enable_fec         : if true FEC will be enabled otherwise the FEC is
320  //                         disabled.
321  //
322  // Return value:
323  //   -1 if failed, or the codec does not support FEC
324  //    0 if succeeded.
325  //
326  virtual int SetCodecFEC(bool enable_codec_fec) = 0;
327
328  ///////////////////////////////////////////////////////////////////////////
329  // bool CodecFEC()
330  // Gets status of codec internal FEC.
331  //
332  // Return value:
333  //   true if FEC is enabled,
334  //   false if FEC is disabled.
335  //
336  virtual bool CodecFEC() const = 0;
337
338  ///////////////////////////////////////////////////////////////////////////
339  // int SetPacketLossRate()
340  // Sets expected packet loss rate for encoding. Some encoders provide packet
341  // loss gnostic encoding to make stream less sensitive to packet losses,
342  // through e.g., FEC. No effects on codecs that do not provide such encoding.
343  //
344  // Input:
345  //   -packet_loss_rate   : expected packet loss rate (0 -- 100 inclusive).
346  //
347  // Return value
348  //   -1 if failed to set packet loss rate,
349  //   0 if succeeded.
350  //
351  virtual int SetPacketLossRate(int packet_loss_rate) = 0;
352
353  ///////////////////////////////////////////////////////////////////////////
354  //   (VAD) Voice Activity Detection
355  //
356
357  ///////////////////////////////////////////////////////////////////////////
358  // int32_t SetVAD()
359  // If DTX is enabled & the codec does not have internal DTX/VAD
360  // WebRtc VAD will be automatically enabled and |enable_vad| is ignored.
361  //
362  // If DTX is disabled but VAD is enabled no DTX packets are send,
363  // regardless of whether the codec has internal DTX/VAD or not. In this
364  // case, WebRtc VAD is running to label frames as active/in-active.
365  //
366  // NOTE! VAD/DTX is not supported when sending stereo.
367  //
368  // Inputs:
369  //   -enable_dtx         : if true DTX is enabled,
370  //                         otherwise DTX is disabled.
371  //   -enable_vad         : if true VAD is enabled,
372  //                         otherwise VAD is disabled.
373  //   -vad_mode           : determines the aggressiveness of VAD. A more
374  //                         aggressive mode results in more frames labeled
375  //                         as in-active, c.f. definition of
376  //                         ACMVADMode in audio_coding_module_typedefs.h
377  //                         for valid values.
378  //
379  // Return value:
380  //   -1 if failed to set up VAD/DTX,
381  //    0 if succeeded.
382  //
383  virtual int32_t SetVAD(const bool enable_dtx = true,
384                               const bool enable_vad = false,
385                               const ACMVADMode vad_mode = VADNormal) = 0;
386
387  ///////////////////////////////////////////////////////////////////////////
388  // int32_t VAD()
389  // Get VAD status.
390  //
391  // Outputs:
392  //   -dtx_enabled        : is set to true if DTX is enabled, otherwise
393  //                         is set to false.
394  //   -vad_enabled        : is set to true if VAD is enabled, otherwise
395  //                         is set to false.
396  //   -vad_mode            : is set to the current aggressiveness of VAD.
397  //
398  // Return value:
399  //   -1 if fails to retrieve the setting of DTX/VAD,
400  //    0 if succeeded.
401  //
402  virtual int32_t VAD(bool* dtx_enabled, bool* vad_enabled,
403                            ACMVADMode* vad_mode) const = 0;
404
405  ///////////////////////////////////////////////////////////////////////////
406  // int32_t RegisterVADCallback()
407  // Call this method to register a callback function which is called
408  // any time that ACM encounters an empty frame. That is a frame which is
409  // recognized inactive. Depending on the codec WebRtc VAD or internal codec
410  // VAD is employed to identify a frame as active/inactive.
411  //
412  // Input:
413  //   -vad_callback        : pointer to a callback function.
414  //
415  // Return value:
416  //   -1 if failed to register the callback function.
417  //    0 if the callback function is registered successfully.
418  //
419  virtual int32_t RegisterVADCallback(ACMVADCallback* vad_callback) = 0;
420
421  ///////////////////////////////////////////////////////////////////////////
422  //   Receiver
423  //
424
425  ///////////////////////////////////////////////////////////////////////////
426  // int32_t InitializeReceiver()
427  // Any decoder-related state of ACM will be initialized to the
428  // same state when ACM is created. This will not interrupt or
429  // effect encoding functionality of ACM. ACM would lose all the
430  // decoding-related settings by calling this function.
431  // For instance, all registered codecs are deleted and have to be
432  // registered again.
433  //
434  // Return value:
435  //   -1 if failed to initialize,
436  //    0 if succeeded.
437  //
438  virtual int32_t InitializeReceiver() = 0;
439
440  ///////////////////////////////////////////////////////////////////////////
441  // int32_t ReceiveFrequency()
442  // Get sampling frequency of the last received payload.
443  //
444  // Return value:
445  //   non-negative the sampling frequency in Hertz.
446  //   -1 if an error has occurred.
447  //
448  virtual int32_t ReceiveFrequency() const = 0;
449
450  ///////////////////////////////////////////////////////////////////////////
451  // int32_t PlayoutFrequency()
452  // Get sampling frequency of audio played out.
453  //
454  // Return value:
455  //   the sampling frequency in Hertz.
456  //
457  virtual int32_t PlayoutFrequency() const = 0;
458
459  ///////////////////////////////////////////////////////////////////////////
460  // int32_t RegisterReceiveCodec()
461  // Register possible decoders, can be called multiple times for
462  // codecs, CNG-NB, CNG-WB, CNG-SWB, AVT and RED.
463  //
464  // Input:
465  //   -receive_codec      : parameters of the codec to be registered, c.f.
466  //                         common_types.h for the definition of
467  //                         CodecInst.
468  //
469  // Return value:
470  //   -1 if failed to register the codec
471  //    0 if the codec registered successfully.
472  //
473  virtual int RegisterReceiveCodec(const CodecInst& receive_codec) = 0;
474
475  // Registers an external decoder. The name is only used to provide information
476  // back to the caller about the decoder. Hence, the name is arbitrary, and may
477  // be empty.
478  virtual int RegisterExternalReceiveCodec(int rtp_payload_type,
479                                           AudioDecoder* external_decoder,
480                                           int sample_rate_hz,
481                                           int num_channels,
482                                           const std::string& name) = 0;
483
484  ///////////////////////////////////////////////////////////////////////////
485  // int32_t UnregisterReceiveCodec()
486  // Unregister the codec currently registered with a specific payload type
487  // from the list of possible receive codecs.
488  //
489  // Input:
490  //   -payload_type        : The number representing the payload type to
491  //                         unregister.
492  //
493  // Output:
494  //   -1 if fails to unregister.
495  //    0 if the given codec is successfully unregistered.
496  //
497  virtual int UnregisterReceiveCodec(
498      uint8_t payload_type) = 0;
499
500  ///////////////////////////////////////////////////////////////////////////
501  // int32_t ReceiveCodec()
502  // Get the codec associated with last received payload.
503  //
504  // Output:
505  //   -curr_receive_codec : parameters of the codec associated with the last
506  //                         received payload, c.f. common_types.h for
507  //                         the definition of CodecInst.
508  //
509  // Return value:
510  //   -1 if failed to retrieve the codec,
511  //    0 if the codec is successfully retrieved.
512  //
513  virtual int32_t ReceiveCodec(CodecInst* curr_receive_codec) const = 0;
514
515  ///////////////////////////////////////////////////////////////////////////
516  // int32_t IncomingPacket()
517  // Call this function to insert a parsed RTP packet into ACM.
518  //
519  // Inputs:
520  //   -incoming_payload   : received payload.
521  //   -payload_len_bytes  : the length of payload in bytes.
522  //   -rtp_info           : the relevant information retrieved from RTP
523  //                         header.
524  //
525  // Return value:
526  //   -1 if failed to push in the payload
527  //    0 if payload is successfully pushed in.
528  //
529  virtual int32_t IncomingPacket(const uint8_t* incoming_payload,
530                                 const size_t payload_len_bytes,
531                                 const WebRtcRTPHeader& rtp_info) = 0;
532
533  ///////////////////////////////////////////////////////////////////////////
534  // int32_t IncomingPayload()
535  // Call this API to push incoming payloads when there is no rtp-info.
536  // The rtp-info will be created in ACM. One usage for this API is when
537  // pre-encoded files are pushed in ACM
538  //
539  // Inputs:
540  //   -incoming_payload   : received payload.
541  //   -payload_len_byte   : the length, in bytes, of the received payload.
542  //   -payload_type       : the payload-type. This specifies which codec has
543  //                         to be used to decode the payload.
544  //   -timestamp          : send timestamp of the payload. ACM starts with
545  //                         a random value and increment it by the
546  //                         packet-size, which is given when the codec in
547  //                         question is registered by RegisterReceiveCodec().
548  //                         Therefore, it is essential to have the timestamp
549  //                         if the frame-size differ from the registered
550  //                         value or if the incoming payload contains DTX
551  //                         packets.
552  //
553  // Return value:
554  //   -1 if failed to push in the payload
555  //    0 if payload is successfully pushed in.
556  //
557  virtual int32_t IncomingPayload(const uint8_t* incoming_payload,
558                                  const size_t payload_len_byte,
559                                  const uint8_t payload_type,
560                                  const uint32_t timestamp = 0) = 0;
561
562  ///////////////////////////////////////////////////////////////////////////
563  // int SetMinimumPlayoutDelay()
564  // Set a minimum for the playout delay, used for lip-sync. NetEq maintains
565  // such a delay unless channel condition yields to a higher delay.
566  //
567  // Input:
568  //   -time_ms            : minimum delay in milliseconds.
569  //
570  // Return value:
571  //   -1 if failed to set the delay,
572  //    0 if the minimum delay is set.
573  //
574  virtual int SetMinimumPlayoutDelay(int time_ms) = 0;
575
576  ///////////////////////////////////////////////////////////////////////////
577  // int SetMaximumPlayoutDelay()
578  // Set a maximum for the playout delay
579  //
580  // Input:
581  //   -time_ms            : maximum delay in milliseconds.
582  //
583  // Return value:
584  //   -1 if failed to set the delay,
585  //    0 if the maximum delay is set.
586  //
587  virtual int SetMaximumPlayoutDelay(int time_ms) = 0;
588
589  //
590  // The shortest latency, in milliseconds, required by jitter buffer. This
591  // is computed based on inter-arrival times and playout mode of NetEq. The
592  // actual delay is the maximum of least-required-delay and the minimum-delay
593  // specified by SetMinumumPlayoutDelay() API.
594  //
595  virtual int LeastRequiredDelayMs() const = 0;
596
597  ///////////////////////////////////////////////////////////////////////////
598  // int32_t PlayoutTimestamp()
599  // The send timestamp of an RTP packet is associated with the decoded
600  // audio of the packet in question. This function returns the timestamp of
601  // the latest audio obtained by calling PlayoutData10ms().
602  //
603  // Input:
604  //   -timestamp          : a reference to a uint32_t to receive the
605  //                         timestamp.
606  // Return value:
607  //    0 if the output is a correct timestamp.
608  //   -1 if failed to output the correct timestamp.
609  //
610  // TODO(tlegrand): Change function to return the timestamp.
611  virtual int32_t PlayoutTimestamp(uint32_t* timestamp) = 0;
612
613  ///////////////////////////////////////////////////////////////////////////
614  // int32_t PlayoutData10Ms(
615  // Get 10 milliseconds of raw audio data for playout, at the given sampling
616  // frequency. ACM will perform a resampling if required.
617  //
618  // Input:
619  //   -desired_freq_hz    : the desired sampling frequency, in Hertz, of the
620  //                         output audio. If set to -1, the function returns
621  //                         the audio at the current sampling frequency.
622  //
623  // Output:
624  //   -audio_frame        : output audio frame which contains raw audio data
625  //                         and other relevant parameters, c.f.
626  //                         module_common_types.h for the definition of
627  //                         AudioFrame.
628  //
629  // Return value:
630  //   -1 if the function fails,
631  //    0 if the function succeeds.
632  //
633  virtual int32_t PlayoutData10Ms(int32_t desired_freq_hz,
634                                        AudioFrame* audio_frame) = 0;
635
636  ///////////////////////////////////////////////////////////////////////////
637  //   Codec specific
638  //
639
640  ///////////////////////////////////////////////////////////////////////////
641  // int SetOpusApplication()
642  // Sets the intended application if current send codec is Opus. Opus uses this
643  // to optimize the encoding for applications like VOIP and music. Currently,
644  // two modes are supported: kVoip and kAudio.
645  //
646  // Input:
647  //   - application            : intended application.
648  //
649  // Return value:
650  //   -1 if current send codec is not Opus or error occurred in setting the
651  //      Opus application mode.
652  //    0 if the Opus application mode is successfully set.
653  //
654  virtual int SetOpusApplication(OpusApplicationMode application) = 0;
655
656  ///////////////////////////////////////////////////////////////////////////
657  // int SetOpusMaxPlaybackRate()
658  // If current send codec is Opus, informs it about maximum playback rate the
659  // receiver will render. Opus can use this information to optimize the bit
660  // rate and increase the computation efficiency.
661  //
662  // Input:
663  //   -frequency_hz            : maximum playback rate in Hz.
664  //
665  // Return value:
666  //   -1 if current send codec is not Opus or
667  //      error occurred in setting the maximum playback rate,
668  //    0 if maximum bandwidth is set successfully.
669  //
670  virtual int SetOpusMaxPlaybackRate(int frequency_hz) = 0;
671
672  ///////////////////////////////////////////////////////////////////////////
673  // EnableOpusDtx()
674  // Enable the DTX, if current send codec is Opus.
675  //
676  // Return value:
677  //   -1 if current send codec is not Opus or error occurred in enabling the
678  //      Opus DTX.
679  //    0 if Opus DTX is enabled successfully.
680  //
681  virtual int EnableOpusDtx() = 0;
682
683  ///////////////////////////////////////////////////////////////////////////
684  // int DisableOpusDtx()
685  // If current send codec is Opus, disables its internal DTX.
686  //
687  // Return value:
688  //   -1 if current send codec is not Opus or error occurred in disabling DTX.
689  //    0 if Opus DTX is disabled successfully.
690  //
691  virtual int DisableOpusDtx() = 0;
692
693  ///////////////////////////////////////////////////////////////////////////
694  //   statistics
695  //
696
697  ///////////////////////////////////////////////////////////////////////////
698  // int32_t  GetNetworkStatistics()
699  // Get network statistics. Note that the internal statistics of NetEq are
700  // reset by this call.
701  //
702  // Input:
703  //   -network_statistics : a structure that contains network statistics.
704  //
705  // Return value:
706  //   -1 if failed to set the network statistics,
707  //    0 if statistics are set successfully.
708  //
709  virtual int32_t GetNetworkStatistics(
710      NetworkStatistics* network_statistics) = 0;
711
712  //
713  // Enable NACK and set the maximum size of the NACK list. If NACK is already
714  // enable then the maximum NACK list size is modified accordingly.
715  //
716  // If the sequence number of last received packet is N, the sequence numbers
717  // of NACK list are in the range of [N - |max_nack_list_size|, N).
718  //
719  // |max_nack_list_size| should be positive (none zero) and less than or
720  // equal to |Nack::kNackListSizeLimit|. Otherwise, No change is applied and -1
721  // is returned. 0 is returned at success.
722  //
723  virtual int EnableNack(size_t max_nack_list_size) = 0;
724
725  // Disable NACK.
726  virtual void DisableNack() = 0;
727
728  //
729  // Get a list of packets to be retransmitted. |round_trip_time_ms| is an
730  // estimate of the round-trip-time (in milliseconds). Missing packets which
731  // will be playout in a shorter time than the round-trip-time (with respect
732  // to the time this API is called) will not be included in the list.
733  //
734  // Negative |round_trip_time_ms| results is an error message and empty list
735  // is returned.
736  //
737  virtual std::vector<uint16_t> GetNackList(
738      int64_t round_trip_time_ms) const = 0;
739
740  virtual void GetDecodingCallStatistics(
741      AudioDecodingCallStats* call_stats) const = 0;
742};
743
744}  // namespace webrtc
745
746#endif  // WEBRTC_MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_H_
747