13f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org/* 23f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 33f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org * 43f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org * Use of this source code is governed by a BSD-style license 53f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org * that can be found in the LICENSE file in the root of the source 63f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org * tree. An additional intellectual property rights grant can be found 73f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org * in the file PATENTS. All contributing project authors may 83f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org * be found in the AUTHORS file in the root of the source tree. 93f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org */ 103f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 11ed0b4fb2f28fa291e726fc1cf6852611f2176392turaj@webrtc.org#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_AUDIO_CODING_MODULE_IMPL_H_ 12ed0b4fb2f28fa291e726fc1cf6852611f2176392turaj@webrtc.org#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_AUDIO_CODING_MODULE_IMPL_H_ 133f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 143f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org#include <vector> 153f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 16d54aa969545bd9c5ccc0077dd6645e742bf11418pbos@webrtc.org#include "webrtc/base/thread_annotations.h" 173f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org#include "webrtc/common_types.h" 183f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org#include "webrtc/engine_configurations.h" 19ed0b4fb2f28fa291e726fc1cf6852611f2176392turaj@webrtc.org#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" 20ed0b4fb2f28fa291e726fc1cf6852611f2176392turaj@webrtc.org#include "webrtc/modules/audio_coding/main/acm2/acm_receiver.h" 21ed0b4fb2f28fa291e726fc1cf6852611f2176392turaj@webrtc.org#include "webrtc/modules/audio_coding/main/acm2/acm_resampler.h" 223f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org#include "webrtc/system_wrappers/interface/scoped_ptr.h" 233f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 243f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.orgnamespace webrtc { 253f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 263f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.orgclass CriticalSectionWrapper; 273f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 280a1c75a50d10621f70d5921c5b8b9c0eb144bb42turaj@webrtc.orgnamespace acm2 { 290a1c75a50d10621f70d5921c5b8b9c0eb144bb42turaj@webrtc.org 300a1c75a50d10621f70d5921c5b8b9c0eb144bb42turaj@webrtc.orgclass ACMDTMFDetection; 310a1c75a50d10621f70d5921c5b8b9c0eb144bb42turaj@webrtc.orgclass ACMGenericCodec; 320a1c75a50d10621f70d5921c5b8b9c0eb144bb42turaj@webrtc.org 333f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.orgclass AudioCodingModuleImpl : public AudioCodingModule { 343f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org public: 35f9cbb15535000ad8af4a9c55a24f135c2cc59e6chenrik.lundin@webrtc.org explicit AudioCodingModuleImpl(const AudioCodingModule::Config& config); 363f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org ~AudioCodingModuleImpl(); 373f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 383f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Change the unique identifier of this object. 396b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int32_t ChangeUniqueId(const int32_t id) OVERRIDE; 403f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 413f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Returns the number of milliseconds until the module want a worker thread 423f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // to call Process. 436b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int32_t TimeUntilNextProcess() OVERRIDE; 443f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 453f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Process any pending tasks such as timeouts. 466b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int32_t Process() OVERRIDE; 473f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 483f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org ///////////////////////////////////////// 493f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Sender 503f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // 513f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 523f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Initialize send codec. 536b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int InitializeSender() OVERRIDE; 543f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 553f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Reset send codec. 566b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int ResetEncoder() OVERRIDE; 573f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 583f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Can be called multiple times for Codec, CNG, RED. 596b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int RegisterSendCodec(const CodecInst& send_codec) OVERRIDE; 603f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 613f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Register Secondary codec for dual-streaming. Dual-streaming is activated 623f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // right after the secondary codec is registered. 636b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int RegisterSecondarySendCodec(const CodecInst& send_codec) OVERRIDE; 643f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 653f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Unregister the secondary codec. Dual-streaming is deactivated right after 663f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // deregistering secondary codec. 676b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual void UnregisterSecondarySendCodec() OVERRIDE; 683f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 693f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Get the secondary codec. 706b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SecondarySendCodec(CodecInst* secondary_codec) const OVERRIDE; 713f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 723f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Get current send codec. 736b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SendCodec(CodecInst* current_codec) const OVERRIDE; 743f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 753f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Get current send frequency. 766b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SendFrequency() const OVERRIDE; 773f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 783f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Get encode bit-rate. 793f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Adaptive rate codecs return their current encode target rate, while other 803f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // codecs return there long-term average or their fixed rate. 816b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SendBitrate() const OVERRIDE; 823f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 833f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Set available bandwidth, inform the encoder about the 843f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // estimated bandwidth received from the remote party. 856b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SetReceivedEstimatedBandwidth(int bw) OVERRIDE; 863f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 873f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Register a transport callback which will be 883f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // called to deliver the encoded buffers. 896b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int RegisterTransportCallback( 906b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org AudioPacketizationCallback* transport) OVERRIDE; 913f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 923f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Add 10 ms of raw (PCM) audio data to the encoder. 936b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int Add10MsData(const AudioFrame& audio_frame) OVERRIDE; 943f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 953f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org ///////////////////////////////////////// 9691c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org // (RED) Redundant Coding 973f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // 983f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 9991c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org // Configure RED status i.e. on/off. 1006b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SetREDStatus(bool enable_red) OVERRIDE; 10191c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org 10291c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org // Get RED status. 1036b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual bool REDStatus() const OVERRIDE; 10491c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org 10591c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org ///////////////////////////////////////// 10691c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org // (FEC) Forward Error Correction (codec internal) 10791c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org // 10891c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org 10991c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org // Configure FEC status i.e. on/off. 1106b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SetCodecFEC(bool enabled_codec_fec) OVERRIDE; 1113f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1123f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Get FEC status. 1136b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual bool CodecFEC() const OVERRIDE; 11491c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org 11591c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org // Set target packet loss rate 1166b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SetPacketLossRate(int loss_rate) OVERRIDE; 1173f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1183f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org ///////////////////////////////////////// 1193f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // (VAD) Voice Activity Detection 1203f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // and 1213f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // (CNG) Comfort Noise Generation 1223f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // 1233f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1246b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SetVAD(bool enable_dtx = true, 1256b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org bool enable_vad = false, 1266b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org ACMVADMode mode = VADNormal) OVERRIDE; 1273f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1286b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int VAD(bool* dtx_enabled, 1296b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org bool* vad_enabled, 1306b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org ACMVADMode* mode) const OVERRIDE; 1313f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1326b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int RegisterVADCallback(ACMVADCallback* vad_callback) OVERRIDE; 1333f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1343f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org ///////////////////////////////////////// 1353f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Receiver 1363f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // 1373f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1383f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Initialize receiver, resets codec database etc. 1396b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int InitializeReceiver() OVERRIDE; 1403f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1413f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Reset the decoder state. 1426b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int ResetDecoder() OVERRIDE; 1433f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1443f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Get current receive frequency. 1456b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int ReceiveFrequency() const OVERRIDE; 1463f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1473f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Get current playout frequency. 1486b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int PlayoutFrequency() const OVERRIDE; 1493f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1503f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Register possible receive codecs, can be called multiple times, 1513f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // for codecs, CNG, DTMF, RED. 1526b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int RegisterReceiveCodec(const CodecInst& receive_codec) OVERRIDE; 1533f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1543f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Get current received codec. 1556b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int ReceiveCodec(CodecInst* current_codec) const OVERRIDE; 1563f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1573f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Incoming packet from network parsed and ready for decode. 1586b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int IncomingPacket(const uint8_t* incoming_payload, 1596b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org int payload_length, 1606b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org const WebRtcRTPHeader& rtp_info) OVERRIDE; 1613f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1623f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Incoming payloads, without rtp-info, the rtp-info will be created in ACM. 1633f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // One usage for this API is when pre-encoded files are pushed in ACM. 1646b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int IncomingPayload(const uint8_t* incoming_payload, 1656b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org int payload_length, 1666b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org uint8_t payload_type, 1676b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org uint32_t timestamp) OVERRIDE; 1683f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1693f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Minimum playout delay. 1706b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SetMinimumPlayoutDelay(int time_ms) OVERRIDE; 1713f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1723f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Maximum playout delay. 1736b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SetMaximumPlayoutDelay(int time_ms) OVERRIDE; 1743f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1753f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Smallest latency NetEq will maintain. 1766b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int LeastRequiredDelayMs() const OVERRIDE; 1773f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1783f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Impose an initial delay on playout. ACM plays silence until |delay_ms| 1793f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // audio is accumulated in NetEq buffer, then starts decoding payloads. 1806b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SetInitialPlayoutDelay(int delay_ms) OVERRIDE; 1813f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1823f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // TODO(turajs): DTMF playout is always activated in NetEq these APIs should 1833f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // be removed, as well as all VoE related APIs and methods. 1843f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // 1853f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Configure Dtmf playout status i.e on/off playout the incoming outband Dtmf 1863f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // tone. 1876b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SetDtmfPlayoutStatus(bool enable) OVERRIDE { return 0; } 1883f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1893f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Get Dtmf playout status. 1906b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual bool DtmfPlayoutStatus() const OVERRIDE { return true; } 1913f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1923f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Estimate the Bandwidth based on the incoming stream, needed 1933f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // for one way audio where the RTCP send the BW estimate. 1943f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // This is also done in the RTP module . 1956b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int DecoderEstimatedBandwidth() const OVERRIDE; 1963f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 1973f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Set playout mode voice, fax. 1986b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SetPlayoutMode(AudioPlayoutMode mode) OVERRIDE; 1993f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2003f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Get playout mode voice, fax. 2016b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual AudioPlayoutMode PlayoutMode() const OVERRIDE; 2023f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2033f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Get playout timestamp. 2046b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int PlayoutTimestamp(uint32_t* timestamp) OVERRIDE; 2053f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2063f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Get 10 milliseconds of raw audio data to play out, and 2073f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // automatic resample to the requested frequency if > 0. 2086b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int PlayoutData10Ms(int desired_freq_hz, 2096b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org AudioFrame* audio_frame) OVERRIDE; 2103f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2113f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org ///////////////////////////////////////// 2123f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Statistics 2133f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // 2143f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2156b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int NetworkStatistics(ACMNetworkStatistics* statistics) OVERRIDE; 2163f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2173f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // GET RED payload for iSAC. The method id called when 'this' ACM is 2183f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // the default ACM. 219a2c69185be1737c73534fa8e3f149ae1173e18e8henrik.lundin@webrtc.org // TODO(henrik.lundin) Not used. Remove? 2203f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org int REDPayloadISAC(int isac_rate, 2213f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org int isac_bw_estimate, 2223f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org uint8_t* payload, 2233f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org int16_t* length_bytes); 2243f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2256b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int ReplaceInternalDTXWithWebRtc(bool use_webrtc_dtx) OVERRIDE; 2263f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2276b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int IsInternalDTXReplacedWithWebRtc(bool* uses_webrtc_dtx) OVERRIDE; 2283f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2296b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SetISACMaxRate(int max_bit_per_sec) OVERRIDE; 2303f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2316b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SetISACMaxPayloadSize(int max_size_bytes) OVERRIDE; 2323f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2336b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int ConfigISACBandwidthEstimator( 2346b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org int frame_size_ms, 2356b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org int rate_bit_per_sec, 2366b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org bool enforce_frame_size = false) OVERRIDE; 2373f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 238b0aac71bfeb5b06083a9664434d936e091f54d91minyue@webrtc.org // If current send codec is Opus, informs it about the maximum playback rate 239b0aac71bfeb5b06083a9664434d936e091f54d91minyue@webrtc.org // the receiver will render. 2406b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int SetOpusMaxPlaybackRate(int frequency_hz) OVERRIDE; 2411bfd54032a8e60b993fb3b32c15ba9c55184c86bminyue@webrtc.org 2426b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int UnregisterReceiveCodec(uint8_t payload_type) OVERRIDE; 2433f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2446b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual int EnableNack(size_t max_nack_list_size) OVERRIDE; 2453f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2466b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual void DisableNack() OVERRIDE; 2473f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2486b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual std::vector<uint16_t> GetNackList( 2496b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org int round_trip_time_ms) const OVERRIDE; 2503f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2516b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org virtual void GetDecodingCallStatistics( 2526b0dab1b84bb8b6cccd9cffa15067099c1fcfa51henrik.lundin@webrtc.org AudioDecodingCallStats* stats) const OVERRIDE; 25379d6dafd3dac32e505bc1a2ccc83ef3ceb6c5ad3wu@webrtc.org 2543f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org private: 2553f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org int UnregisterReceiveCodecSafe(int payload_type); 2563f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2573f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org ACMGenericCodec* CreateCodec(const CodecInst& codec); 2583f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 25981000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org int InitializeReceiverSafe() EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 2603f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 261a2c69185be1737c73534fa8e3f149ae1173e18e8henrik.lundin@webrtc.org bool HaveValidEncoder(const char* caller_name) const 262a2c69185be1737c73534fa8e3f149ae1173e18e8henrik.lundin@webrtc.org EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 2633f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2643f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Set VAD/DTX status. This function does not acquire a lock, and it is 2653f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // created to be called only from inside a critical section. 26681000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org int SetVADSafe(bool enable_dtx, bool enable_vad, ACMVADMode mode) 26781000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 2683f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2693f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Process buffered audio when dual-streaming is not enabled (When RED is 2703f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // enabled still this function is used.) 2713f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org int ProcessSingleStream(); 2723f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2733f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Process buffered audio when dual-streaming is enabled, i.e. secondary send 2743f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // codec is registered. 2753f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org int ProcessDualStream(); 2763f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2773f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Preprocessing of input audio, including resampling and down-mixing if 2783f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // required, before pushing audio into encoder's buffer. 2793f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // 2803f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // in_frame: input audio-frame 2813f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // ptr_out: pointer to output audio_frame. If no preprocessing is required 2823f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // |ptr_out| will be pointing to |in_frame|, otherwise pointing to 2833f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // |preprocess_frame_|. 2843f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // 2853f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Return value: 2863f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // -1: if encountering an error. 2873f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // 0: otherwise. 2883f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org int PreprocessToAddData(const AudioFrame& in_frame, 28981000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org const AudioFrame** ptr_out) 29081000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 2913f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 2923f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Change required states after starting to receive the codec corresponding 2933f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // to |index|. 2943f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org int UpdateUponReceivingCodec(int index); 2953f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 29681000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org int EncodeFragmentation(int fragmentation_index, 29781000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org int payload_type, 2983f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org uint32_t current_timestamp, 2993f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org ACMGenericCodec* encoder, 30081000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org uint8_t* stream) 30181000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 3023f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 30381000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org void ResetFragmentation(int vector_size) 30481000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 3053f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 3063f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Get a pointer to AudioDecoder of the given codec. For some codecs, e.g. 3073f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // iSAC, encoding and decoding have to be performed on a shared 3083f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // codec-instance. By calling this method, we get the codec-instance that ACM 3093f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // owns, then pass that to NetEq. This way, we perform both encoding and 3103f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // decoding on the same codec-instance. Furthermore, ACM would have control 3113f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // over decoder functionality if required. If |codec| does not share an 3123f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // instance between encoder and decoder, the |*decoder| is set NULL. 3133f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // The field ACMCodecDB::CodecSettings.owns_decoder indicates that if a 3143f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // codec owns the decoder-instance. For such codecs |*decoder| should be a 3153f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // valid pointer, otherwise it will be NULL. 3163f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org int GetAudioDecoder(const CodecInst& codec, int codec_id, 317a2c69185be1737c73534fa8e3f149ae1173e18e8henrik.lundin@webrtc.org int mirror_id, AudioDecoder** decoder) 318a2c69185be1737c73534fa8e3f149ae1173e18e8henrik.lundin@webrtc.org EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 3193f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 32081000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org CriticalSectionWrapper* acm_crit_sect_; 32181000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org int id_; // TODO(henrik.lundin) Make const. 32281000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org uint32_t expected_codec_ts_ GUARDED_BY(acm_crit_sect_); 32381000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org uint32_t expected_in_ts_ GUARDED_BY(acm_crit_sect_); 32481000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org CodecInst send_codec_inst_ GUARDED_BY(acm_crit_sect_); 32581000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org 32681000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org uint8_t cng_nb_pltype_ GUARDED_BY(acm_crit_sect_); 32781000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org uint8_t cng_wb_pltype_ GUARDED_BY(acm_crit_sect_); 32881000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org uint8_t cng_swb_pltype_ GUARDED_BY(acm_crit_sect_); 32981000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org uint8_t cng_fb_pltype_ GUARDED_BY(acm_crit_sect_); 33081000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org 33181000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org uint8_t red_pltype_ GUARDED_BY(acm_crit_sect_); 33281000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org bool vad_enabled_ GUARDED_BY(acm_crit_sect_); 33381000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org bool dtx_enabled_ GUARDED_BY(acm_crit_sect_); 33481000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org ACMVADMode vad_mode_ GUARDED_BY(acm_crit_sect_); 335a2c69185be1737c73534fa8e3f149ae1173e18e8henrik.lundin@webrtc.org ACMGenericCodec* codecs_[ACMCodecDB::kMaxNumCodecs] 336a2c69185be1737c73534fa8e3f149ae1173e18e8henrik.lundin@webrtc.org GUARDED_BY(acm_crit_sect_); 337a2c69185be1737c73534fa8e3f149ae1173e18e8henrik.lundin@webrtc.org int mirror_codec_idx_[ACMCodecDB::kMaxNumCodecs] GUARDED_BY(acm_crit_sect_); 33881000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org bool stereo_send_ GUARDED_BY(acm_crit_sect_); 339a2c69185be1737c73534fa8e3f149ae1173e18e8henrik.lundin@webrtc.org int current_send_codec_idx_ GUARDED_BY(acm_crit_sect_); 340a2c69185be1737c73534fa8e3f149ae1173e18e8henrik.lundin@webrtc.org bool send_codec_registered_ GUARDED_BY(acm_crit_sect_); 34181000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org ACMResampler resampler_ GUARDED_BY(acm_crit_sect_); 342a2c69185be1737c73534fa8e3f149ae1173e18e8henrik.lundin@webrtc.org AcmReceiver receiver_; // AcmReceiver has it's own internal lock. 3433f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 34491c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org // RED. 34581000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org bool is_first_red_ GUARDED_BY(acm_crit_sect_); 34681000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org bool red_enabled_ GUARDED_BY(acm_crit_sect_); 3473f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 3483f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // TODO(turajs): |red_buffer_| is allocated in constructor, why having them 3493f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // as pointers and not an array. If concerned about the memory, then make a 3503f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // set-up function to allocate them only when they are going to be used, i.e. 35191c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org // RED or Dual-streaming is enabled. 35281000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org uint8_t* red_buffer_ GUARDED_BY(acm_crit_sect_); 3533f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 3543f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // TODO(turajs): we actually don't need |fragmentation_| as a member variable. 3553f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // It is sufficient to keep the length & payload type of previous payload in 3563f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // member variables. 35781000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org RTPFragmentationHeader fragmentation_ GUARDED_BY(acm_crit_sect_); 35881000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org uint32_t last_red_timestamp_ GUARDED_BY(acm_crit_sect_); 35991c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org 36091c0a2592faf1e68f658c98e5faa1acef7124d1aminyue@webrtc.org // Codec internal FEC 361a2c69185be1737c73534fa8e3f149ae1173e18e8henrik.lundin@webrtc.org bool codec_fec_enabled_ GUARDED_BY(acm_crit_sect_); 3623f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 3633f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // This is to keep track of CN instances where we can send DTMFs. 36481000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org uint8_t previous_pltype_ GUARDED_BY(acm_crit_sect_); 3653f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 3663f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // Used when payloads are pushed into ACM without any RTP info 3673f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // One example is when pre-encoded bit-stream is pushed from 3683f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // a file. 3693f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // IMPORTANT: this variable is only used in IncomingPayload(), therefore, 3703f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // no lock acquired when interacting with this variable. If it is going to 3713f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org // be used in other methods, locks need to be taken. 3723f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org WebRtcRTPHeader* aux_rtp_header_; 3733f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 37481000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org bool receiver_initialized_ GUARDED_BY(acm_crit_sect_); 3753f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 37681000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org AudioFrame preprocess_frame_ GUARDED_BY(acm_crit_sect_); 37781000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org CodecInst secondary_send_codec_inst_ GUARDED_BY(acm_crit_sect_); 37881000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org scoped_ptr<ACMGenericCodec> secondary_encoder_ GUARDED_BY(acm_crit_sect_); 37981000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org uint32_t codec_timestamp_ GUARDED_BY(acm_crit_sect_); 38081000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org bool first_10ms_data_ GUARDED_BY(acm_crit_sect_); 3813f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 38281000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org CriticalSectionWrapper* callback_crit_sect_; 38381000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org AudioPacketizationCallback* packetization_callback_ 38481000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org GUARDED_BY(callback_crit_sect_); 38581000de553d80d173cf9b0e72fa3b739b4457770henrik.lundin@webrtc.org ACMVADCallback* vad_callback_ GUARDED_BY(callback_crit_sect_); 3863f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org}; 3873f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 3880a1c75a50d10621f70d5921c5b8b9c0eb144bb42turaj@webrtc.org} // namespace acm2 3890a1c75a50d10621f70d5921c5b8b9c0eb144bb42turaj@webrtc.org 39085e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.orgclass AudioCodingImpl : public AudioCoding { 39185e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org public: 39285e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org AudioCodingImpl(const Config& config) { 393dabeef3e9cb462203287384ac873f46b0d8cb694andresp@webrtc.org AudioCodingModule::Config config_old = config.ToOldConfig(); 39485e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org acm_old_.reset(new acm2::AudioCodingModuleImpl(config_old)); 39585e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org acm_old_->RegisterTransportCallback(config.transport); 39685e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org acm_old_->RegisterVADCallback(config.vad_callback); 39785e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org acm_old_->SetDtmfPlayoutStatus(config.play_dtmf); 39885e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org if (config.initial_playout_delay_ms > 0) { 39985e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org acm_old_->SetInitialPlayoutDelay(config.initial_playout_delay_ms); 40085e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org } 40185e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org playout_frequency_hz_ = config.playout_frequency_hz; 40285e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org } 40385e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 40485e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual ~AudioCodingImpl() OVERRIDE {}; 40585e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 40685e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual bool RegisterSendCodec(AudioEncoder* send_codec) OVERRIDE; 40785e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 40885e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual bool RegisterSendCodec(int encoder_type, 40985e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org uint8_t payload_type, 41085e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org int frame_size_samples = 0) OVERRIDE; 41185e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 41285e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual const AudioEncoder* GetSenderInfo() const OVERRIDE; 41385e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 414dabeef3e9cb462203287384ac873f46b0d8cb694andresp@webrtc.org virtual const CodecInst* GetSenderCodecInst() OVERRIDE; 415dabeef3e9cb462203287384ac873f46b0d8cb694andresp@webrtc.org 41685e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual int Add10MsAudio(const AudioFrame& audio_frame) OVERRIDE; 41785e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 41885e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual const ReceiverInfo* GetReceiverInfo() const OVERRIDE; 41985e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 42085e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual bool RegisterReceiveCodec(AudioDecoder* receive_codec) OVERRIDE; 42185e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 42285e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual bool RegisterReceiveCodec(int decoder_type, 42385e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org uint8_t payload_type) OVERRIDE; 42485e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 42585e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual bool InsertPacket(const uint8_t* incoming_payload, 42685e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org int32_t payload_len_bytes, 42785e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org const WebRtcRTPHeader& rtp_info) OVERRIDE; 42885e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 42985e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual bool InsertPayload(const uint8_t* incoming_payload, 43085e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org int32_t payload_len_byte, 43185e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org uint8_t payload_type, 43285e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org uint32_t timestamp) OVERRIDE; 43385e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 43485e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual bool SetMinimumPlayoutDelay(int time_ms) OVERRIDE; 43585e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 43685e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual bool SetMaximumPlayoutDelay(int time_ms) OVERRIDE; 43785e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 43885e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual int LeastRequiredDelayMs() const OVERRIDE; 43985e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 44085e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual bool PlayoutTimestamp(uint32_t* timestamp) OVERRIDE; 44185e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 44285e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual bool Get10MsAudio(AudioFrame* audio_frame) OVERRIDE; 44385e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 44485e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual bool NetworkStatistics( 44585e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org ACMNetworkStatistics* network_statistics) OVERRIDE; 44685e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 44785e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual bool EnableNack(size_t max_nack_list_size) OVERRIDE; 44885e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 44985e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual void DisableNack() OVERRIDE; 45085e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 451dabeef3e9cb462203287384ac873f46b0d8cb694andresp@webrtc.org virtual bool SetVad(bool enable_dtx, 452dabeef3e9cb462203287384ac873f46b0d8cb694andresp@webrtc.org bool enable_vad, 453dabeef3e9cb462203287384ac873f46b0d8cb694andresp@webrtc.org ACMVADMode vad_mode) OVERRIDE; 454dabeef3e9cb462203287384ac873f46b0d8cb694andresp@webrtc.org 45585e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual std::vector<uint16_t> GetNackList( 45685e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org int round_trip_time_ms) const OVERRIDE; 45785e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 45885e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org virtual void GetDecodingCallStatistics( 45985e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org AudioDecodingCallStats* call_stats) const OVERRIDE; 46085e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 46185e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org private: 46285e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org // Temporary method to be used during redesign phase. 46385e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org // Maps |codec_type| (a value from the anonymous enum in acm2::ACMCodecDB) to 46485e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org // |codec_name|, |sample_rate_hz|, and |channels|. 46585e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org // TODO(henrik.lundin) Remove this when no longer needed. 46685e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org static bool MapCodecTypeToParameters(int codec_type, 46785e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org std::string* codec_name, 46885e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org int* sample_rate_hz, 46985e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org int* channels); 47085e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 471f349bd7f617b13c8e7fe0270ef39757350fa7acaandresp@webrtc.org int playout_frequency_hz_; 472dabeef3e9cb462203287384ac873f46b0d8cb694andresp@webrtc.org // TODO(henrik.lundin): All members below this line are temporary and should 473dabeef3e9cb462203287384ac873f46b0d8cb694andresp@webrtc.org // be removed after refactoring is completed. 474dabeef3e9cb462203287384ac873f46b0d8cb694andresp@webrtc.org scoped_ptr<acm2::AudioCodingModuleImpl> acm_old_; 475dabeef3e9cb462203287384ac873f46b0d8cb694andresp@webrtc.org CodecInst current_send_codec_; 47685e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org}; 47785e6dae81428a1c646276bf1148937e986d4f5d7henrik.lundin@webrtc.org 4783f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org} // namespace webrtc 4793f39c00d9875d7e09062725757b789f4da375ef9turaj@webrtc.org 480ed0b4fb2f28fa291e726fc1cf6852611f2176392turaj@webrtc.org#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_AUDIO_CODING_MODULE_IMPL_H_ 481