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