Reformatting ACM. All changes are bit-exact in this CL.

TEST=VoE auto-test, audio_coding_module_test; 

only 15 ms of teststereo_out_1.pcm is not bit-exact with output file of the head revision
Review URL: https://webrtc-codereview.appspot.com/937035

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3287 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
turaj@webrtc.org 2012-12-13 22:46:43 +00:00
parent ddebc17bee
commit c454fab03b
57 changed files with 5276 additions and 5241 deletions

View File

@ -11,18 +11,20 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_H
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_H
#include "audio_coding_module_typedefs.h" #include "webrtc/common_types.h"
#include "module.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
// TODO(turajs): If possible, forward declare and remove the following include. #include "webrtc/modules/interface/module.h"
#include "module_common_types.h" #include "webrtc/typedefs.h"
namespace webrtc { namespace webrtc {
// forward declarations // forward declarations
struct CodecInst; struct CodecInst;
struct WebRtcRTPHeader;
class AudioFrame;
class RTPFragmentationHeader;
#define WEBRTC_10MS_PCM_AUDIO 960 // 16 bits super wideband 48 Khz #define WEBRTC_10MS_PCM_AUDIO 960 // 16 bits super wideband 48 kHz
// Callback class used for sending data ready to be packetized // Callback class used for sending data ready to be packetized
class AudioPacketizationCallback { class AudioPacketizationCallback {
@ -30,8 +32,11 @@ class AudioPacketizationCallback {
virtual ~AudioPacketizationCallback() {} virtual ~AudioPacketizationCallback() {}
virtual WebRtc_Word32 SendData( virtual WebRtc_Word32 SendData(
FrameType frameType, WebRtc_UWord8 payloadType, WebRtc_UWord32 timeStamp, FrameType frame_type,
const WebRtc_UWord8* payloadData, WebRtc_UWord16 payloadSize, WebRtc_UWord8 payload_type,
WebRtc_UWord32 timestamp,
const WebRtc_UWord8* payload_data,
WebRtc_UWord16 payload_len_bytes,
const RTPFragmentationHeader* fragmentation) = 0; const RTPFragmentationHeader* fragmentation) = 0;
}; };
@ -40,7 +45,7 @@ class AudioCodingFeedback {
public: public:
virtual ~AudioCodingFeedback() {} virtual ~AudioCodingFeedback() {}
virtual WebRtc_Word32 IncomingDtmf(const WebRtc_UWord8 digitDtmf, virtual WebRtc_Word32 IncomingDtmf(const WebRtc_UWord8 digit_dtmf,
const bool end) = 0; const bool end) = 0;
}; };
@ -96,17 +101,17 @@ class AudioCodingModule: public Module {
// Get supported codec with list number. // Get supported codec with list number.
// //
// Input: // Input:
// -listId : list number. // -list_id : list number.
// //
// Output: // Output:
// -codec : a structure where the parameters of the codec, // -codec : a structure where the parameters of the codec,
// given by list number is written to. // given by list number is written to.
// //
// Return value: // Return value:
// -1 if the list number (listId) is invalid. // -1 if the list number (list_id) is invalid.
// 0 if succeeded. // 0 if succeeded.
// //
static WebRtc_Word32 Codec(const WebRtc_UWord8 listId, CodecInst& codec); static WebRtc_Word32 Codec(const WebRtc_UWord8 list_id, CodecInst& codec);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 Codec() // WebRtc_Word32 Codec()
@ -124,7 +129,7 @@ class AudioCodingModule: public Module {
// default parameters of the codec. // default parameters of the codec.
// //
// Return value: // Return value:
// -1 if the list number (listId) is invalid. // -1 if no codec matches the given parameters.
// 0 if succeeded. // 0 if succeeded.
// //
static WebRtc_Word32 Codec(const char* payload_name, CodecInst& codec, static WebRtc_Word32 Codec(const char* payload_name, CodecInst& codec,
@ -154,10 +159,10 @@ class AudioCodingModule: public Module {
// Checks the validity of the parameters of the given codec. // Checks the validity of the parameters of the given codec.
// //
// Input: // Input:
// -codec : the structur which keeps the parameters of the // -codec : the structure which keeps the parameters of the
// codec. // codec.
// //
// Reurn value: // Return value:
// true if the parameters are valid, // true if the parameters are valid,
// false if any parameter is not valid. // false if any parameter is not valid.
// //
@ -194,7 +199,7 @@ class AudioCodingModule: public Module {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 RegisterSendCodec() // WebRtc_Word32 RegisterSendCodec()
// Registers a codec, specified by "sendCodec," as sending codec. // Registers a codec, specified by |send_codec|, as sending codec.
// This API can be called multiple of times to register Codec. The last codec // This API can be called multiple of times to register Codec. The last codec
// registered overwrites the previous ones. // registered overwrites the previous ones.
// The API can also be used to change payload type for CNG and RED, which are // The API can also be used to change payload type for CNG and RED, which are
@ -211,7 +216,7 @@ class AudioCodingModule: public Module {
// secondary encoder will be unregistered. // secondary encoder will be unregistered.
// //
// Input: // Input:
// -sendCodec : Parameters of the codec to be registered, c.f. // -send_codec : Parameters of the codec to be registered, c.f.
// common_types.h for the definition of // common_types.h for the definition of
// CodecInst. // CodecInst.
// //
@ -219,7 +224,7 @@ class AudioCodingModule: public Module {
// -1 if failed to initialize, // -1 if failed to initialize,
// 0 if succeeded. // 0 if succeeded.
// //
virtual WebRtc_Word32 RegisterSendCodec(const CodecInst& sendCodec) = 0; virtual WebRtc_Word32 RegisterSendCodec(const CodecInst& send_codec) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// int RegisterSecondarySendCodec() // int RegisterSecondarySendCodec()
@ -253,13 +258,13 @@ class AudioCodingModule: public Module {
// Get parameters for the codec currently registered as send codec. // Get parameters for the codec currently registered as send codec.
// //
// Output: // Output:
// -currentSendCodec : parameters of the send codec. // -current_send_codec : parameters of the send codec.
// //
// Return value: // Return value:
// -1 if failed to get send codec, // -1 if failed to get send codec,
// 0 if succeeded. // 0 if succeeded.
// //
virtual WebRtc_Word32 SendCodec(CodecInst& currentSendCodec) const = 0; virtual WebRtc_Word32 SendCodec(CodecInst& current_send_codec) const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// int SecondarySendCodec() // int SecondarySendCodec()
@ -336,7 +341,7 @@ class AudioCodingModule: public Module {
// current encoder ACM will resample the audio. // current encoder ACM will resample the audio.
// //
// Input: // Input:
// -audioFrame : the input audio frame, containing raw audio // -audio_frame : the input audio frame, containing raw audio
// sampling frequency etc., // sampling frequency etc.,
// c.f. module_common_types.h for definition of // c.f. module_common_types.h for definition of
// AudioFrame. // AudioFrame.
@ -347,7 +352,7 @@ class AudioCodingModule: public Module {
// < -1 to add the frame to the buffer n samples had to be // < -1 to add the frame to the buffer n samples had to be
// overwritten, -n is the return value in this case. // overwritten, -n is the return value in this case.
// //
virtual WebRtc_Word32 Add10MsData(const AudioFrame& audioFrame) = 0; virtual WebRtc_Word32 Add10MsData(const AudioFrame& audio_frame) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// (FEC) Forward Error Correction // (FEC) Forward Error Correction
@ -368,14 +373,14 @@ class AudioCodingModule: public Module {
// This means that FEC is actually a RED scheme. // This means that FEC is actually a RED scheme.
// //
// Input: // Input:
// -enableFEC : if true FEC is enabled, otherwise FEC is // -enable_fec : if true FEC is enabled, otherwise FEC is
// disabled. // disabled.
// //
// Return value: // Return value:
// -1 if failed to set FEC status, // -1 if failed to set FEC status,
// 0 if succeeded. // 0 if succeeded.
// //
virtual WebRtc_Word32 SetFECStatus(const bool enableFEC) = 0; virtual WebRtc_Word32 SetFECStatus(const bool enable_fec) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// bool FECStatus() // bool FECStatus()
@ -394,7 +399,7 @@ class AudioCodingModule: public Module {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 SetVAD() // WebRtc_Word32 SetVAD()
// If DTX is enabled & the codec does not have internal DTX/VAD // If DTX is enabled & the codec does not have internal DTX/VAD
// WebRtc VAD will be automatically enabled and 'enableVAD' is ignored. // WebRtc VAD will be automatically enabled and |enable_vad| is ignored.
// //
// If DTX is disabled but VAD is enabled no DTX packets are send, // If DTX is disabled but VAD is enabled no DTX packets are send,
// regardless of whether the codec has internal DTX/VAD or not. In this // regardless of whether the codec has internal DTX/VAD or not. In this
@ -403,11 +408,11 @@ class AudioCodingModule: public Module {
// NOTE! VAD/DTX is not supported when sending stereo. // NOTE! VAD/DTX is not supported when sending stereo.
// //
// Inputs: // Inputs:
// -enableDTX : if true DTX is enabled, // -enable_dtx : if true DTX is enabled,
// otherwise DTX is disabled. // otherwise DTX is disabled.
// -enableVAD : if true VAD is enabled, // -enable_vad : if true VAD is enabled,
// otherwise VAD is disabled. // otherwise VAD is disabled.
// -vadMode : determines the aggressiveness of VAD. A more // -vad_mode : determines the aggressiveness of VAD. A more
// aggressive mode results in more frames labeled // aggressive mode results in more frames labeled
// as in-active, c.f. definition of // as in-active, c.f. definition of
// ACMVADMode in audio_coding_module_typedefs.h // ACMVADMode in audio_coding_module_typedefs.h
@ -417,27 +422,27 @@ class AudioCodingModule: public Module {
// -1 if failed to set up VAD/DTX, // -1 if failed to set up VAD/DTX,
// 0 if succeeded. // 0 if succeeded.
// //
virtual WebRtc_Word32 SetVAD(const bool enableDTX = true, virtual WebRtc_Word32 SetVAD(const bool enable_dtx = true,
const bool enableVAD = false, const bool enable_vad = false,
const ACMVADMode vadMode = VADNormal) = 0; const ACMVADMode vad_mode = VADNormal) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 VAD() // WebRtc_Word32 VAD()
// Get VAD status. // Get VAD status.
// //
// Outputs: // Outputs:
// -dtxEnabled : is set to true if DTX is enabled, otherwise // -dtx_enabled : is set to true if DTX is enabled, otherwise
// is set to false. // is set to false.
// -vadEnabled : is set to true if VAD is enabled, otherwise // -vad_enabled : is set to true if VAD is enabled, otherwise
// is set to false. // is set to false.
// -vadMode : is set to the current aggressiveness of VAD. // -vad_mode : is set to the current aggressiveness of VAD.
// //
// Return value: // Return value:
// -1 if fails to retrieve the setting of DTX/VAD, // -1 if fails to retrieve the setting of DTX/VAD,
// 0 if succeeeded. // 0 if succeeded.
// //
virtual WebRtc_Word32 VAD(bool& dtxEnabled, bool& vadEnabled, virtual WebRtc_Word32 VAD(bool& dtx_enabled, bool& vad_enabled,
ACMVADMode& vadMode) const = 0; ACMVADMode& vad_mode) const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 ReplaceInternalDTXWithWebRtc() // WebRtc_Word32 ReplaceInternalDTXWithWebRtc()
@ -445,7 +450,7 @@ class AudioCodingModule: public Module {
// supported for G729, where this call replaces AnnexB with WebRtc DTX. // supported for G729, where this call replaces AnnexB with WebRtc DTX.
// //
// Input: // Input:
// -useWebRtcDTX : if false (default) the codec built-in DTX/VAD // -use_webrtc_dtx : if false (default) the codec built-in DTX/VAD
// scheme is used, otherwise the internal DTX is // scheme is used, otherwise the internal DTX is
// replaced with WebRtc DTX/VAD. // replaced with WebRtc DTX/VAD.
// //
@ -454,7 +459,7 @@ class AudioCodingModule: public Module {
// 0 if succeeded. // 0 if succeeded.
// //
virtual WebRtc_Word32 ReplaceInternalDTXWithWebRtc( virtual WebRtc_Word32 ReplaceInternalDTXWithWebRtc(
const bool useWebRtcDTX = false) = 0; const bool use_webrtc_dtx = false) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 IsInternalDTXReplacedWithWebRtc() // WebRtc_Word32 IsInternalDTXReplacedWithWebRtc()
@ -462,7 +467,7 @@ class AudioCodingModule: public Module {
// WebRtc DTX. This is only supported for G729. // WebRtc DTX. This is only supported for G729.
// //
// Output: // Output:
// -usesWebRtcDTX : is set to true if the codec internal DTX is // -uses_webrtc_dtx : is set to true if the codec internal DTX is
// replaced with WebRtc DTX/VAD, otherwise it is set // replaced with WebRtc DTX/VAD, otherwise it is set
// to false. // to false.
// //
@ -471,7 +476,7 @@ class AudioCodingModule: public Module {
// 0 if succeeded. // 0 if succeeded.
// //
virtual WebRtc_Word32 IsInternalDTXReplacedWithWebRtc( virtual WebRtc_Word32 IsInternalDTXReplacedWithWebRtc(
bool& usesWebRtcDTX) = 0; bool& uses_webrtc_dtx) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 RegisterVADCallback() // WebRtc_Word32 RegisterVADCallback()
@ -481,13 +486,13 @@ class AudioCodingModule: public Module {
// VAD is employed to identify a frame as active/inactive. // VAD is employed to identify a frame as active/inactive.
// //
// Input: // Input:
// -vadCallback : pointer to a callback function. // -vad_callback : pointer to a callback function.
// //
// Return value: // Return value:
// -1 if failed to register the callback function. // -1 if failed to register the callback function.
// 0 if the callback function is registered successfully. // 0 if the callback function is registered successfully.
// //
virtual WebRtc_Word32 RegisterVADCallback(ACMVADCallback* vadCallback) = 0; virtual WebRtc_Word32 RegisterVADCallback(ACMVADCallback* vad_callback) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Receiver // Receiver
@ -544,7 +549,7 @@ class AudioCodingModule: public Module {
// codecs, CNG-NB, CNG-WB, CNG-SWB, AVT and RED. // codecs, CNG-NB, CNG-WB, CNG-SWB, AVT and RED.
// //
// Input: // Input:
// -receiveCodec : parameters of the codec to be registered, c.f. // -receive_codec : parameters of the codec to be registered, c.f.
// common_types.h for the definition of // common_types.h for the definition of
// CodecInst. // CodecInst.
// //
@ -552,7 +557,8 @@ class AudioCodingModule: public Module {
// -1 if failed to register the codec // -1 if failed to register the codec
// 0 if the codec registered successfully. // 0 if the codec registered successfully.
// //
virtual WebRtc_Word32 RegisterReceiveCodec(const CodecInst& receiveCodec) = 0; virtual WebRtc_Word32 RegisterReceiveCodec(
const CodecInst& receive_codec) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 UnregisterReceiveCodec() // WebRtc_Word32 UnregisterReceiveCodec()
@ -560,22 +566,22 @@ class AudioCodingModule: public Module {
// from the list of possible receive codecs. // from the list of possible receive codecs.
// //
// Input: // Input:
// -payloadType : The number representing the payload type to // -payload_type : The number representing the payload type to
// unregister. // unregister.
// //
// Output: // Output:
// -1 if the unregistration fails. // -1 if fails to unregister.
// 0 if the given codec is successfully unregistered. // 0 if the given codec is successfully unregistered.
// //
virtual WebRtc_Word32 UnregisterReceiveCodec( virtual WebRtc_Word32 UnregisterReceiveCodec(
const WebRtc_Word16 receiveCodec) = 0; const WebRtc_Word16 payload_type) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 ReceiveCodec() // WebRtc_Word32 ReceiveCodec()
// Get the codec associated with last received payload. // Get the codec associated with last received payload.
// //
// Output: // Output:
// -currRcvCodec : parameters of the codec associated with the last // -curr_receive_codec : parameters of the codec associated with the last
// received payload, c.f. common_types.h for // received payload, c.f. common_types.h for
// the definition of CodecInst. // the definition of CodecInst.
// //
@ -583,25 +589,25 @@ class AudioCodingModule: public Module {
// -1 if failed to retrieve the codec, // -1 if failed to retrieve the codec,
// 0 if the codec is successfully retrieved. // 0 if the codec is successfully retrieved.
// //
virtual WebRtc_Word32 ReceiveCodec(CodecInst& currRcvCodec) const = 0; virtual WebRtc_Word32 ReceiveCodec(CodecInst& curr_receive_codec) const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 IncomingPacket() // WebRtc_Word32 IncomingPacket()
// Call this function to insert a parsed RTP packet into ACM. // Call this function to insert a parsed RTP packet into ACM.
// //
// Inputs: // Inputs:
// -incomingPayload : received payload. // -incoming_payload : received payload.
// -payloadLengthByte : the length of payload in bytes. // -payload_len_bytes : the length of payload in bytes.
// -rtpInfo : the relevant information retrieved from RTP // -rtp_info : the relevant information retrieved from RTP
// header. // header.
// //
// Return value: // Return value:
// -1 if failed to push in the payload // -1 if failed to push in the payload
// 0 if payload is successfully pushed in. // 0 if payload is successfully pushed in.
// //
virtual WebRtc_Word32 IncomingPacket(const WebRtc_UWord8* incomingPayload, virtual WebRtc_Word32 IncomingPacket(const WebRtc_UWord8* incoming_payload,
const WebRtc_Word32 payloadLengthByte, const WebRtc_Word32 payload_len_bytes,
const WebRtcRTPHeader& rtpInfo) = 0; const WebRtcRTPHeader& rtp_info) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 IncomingPayload() // WebRtc_Word32 IncomingPayload()
@ -610,9 +616,9 @@ class AudioCodingModule: public Module {
// pre-encoded files are pushed in ACM // pre-encoded files are pushed in ACM
// //
// Inputs: // Inputs:
// -incomingPayload : received payload. // -incoming_payload : received payload.
// -payloadLenghtByte : the length, in bytes, of the received payload. // -payload_len_byte : the length, in bytes, of the received payload.
// -payloadType : the payload-type. This specifies which codec has // -payload_type : the payload-type. This specifies which codec has
// to be used to decode the payload. // to be used to decode the payload.
// -timestamp : send timestamp of the payload. ACM starts with // -timestamp : send timestamp of the payload. ACM starts with
// a random value and increment it by the // a random value and increment it by the
@ -627,9 +633,9 @@ class AudioCodingModule: public Module {
// -1 if failed to push in the payload // -1 if failed to push in the payload
// 0 if payload is successfully pushed in. // 0 if payload is successfully pushed in.
// //
virtual WebRtc_Word32 IncomingPayload(const WebRtc_UWord8* incomingPayload, virtual WebRtc_Word32 IncomingPayload(const WebRtc_UWord8* incoming_payload,
const WebRtc_Word32 payloadLengthByte, const WebRtc_Word32 payload_len_byte,
const WebRtc_UWord8 payloadType, const WebRtc_UWord8 payload_type,
const WebRtc_UWord32 timestamp = 0) = 0; const WebRtc_UWord32 timestamp = 0) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -637,22 +643,22 @@ class AudioCodingModule: public Module {
// Set Minimum playout delay, used for lip-sync. // Set Minimum playout delay, used for lip-sync.
// //
// Input: // Input:
// -timeMs : minimum delay in milliseconds. // -time_ms : minimum delay in milliseconds.
// //
// Return value: // Return value:
// -1 if failed to set the delay, // -1 if failed to set the delay,
// 0 if the minimum delay is set. // 0 if the minimum delay is set.
// //
virtual WebRtc_Word32 SetMinimumPlayoutDelay(const WebRtc_Word32 timeMs) = 0; virtual WebRtc_Word32 SetMinimumPlayoutDelay(const WebRtc_Word32 time_ms) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 RegisterIncomingMessagesCallback() // WebRtc_Word32 RegisterIncomingMessagesCallback()
// Used by the module to deliver messages to the codec module/application // Used by the module to deliver messages to the codec module/application
// when a Dtmf tone is detected, as well as when it stopped. // when a DTMF tone is detected, as well as when it stopped.
// //
// Inputs: // Inputs:
// -inMsgCallback : pointer to callback function which will be called // -in_message_callback: pointer to callback function which will be called
// if Dtmf is detected. // if DTMF is detected.
// -cpt : enables CPT (Call Progress Tone) detection for the // -cpt : enables CPT (Call Progress Tone) detection for the
// specified country. c.f. definition of ACMCountries // specified country. c.f. definition of ACMCountries
// in audio_coding_module_typedefs.h for valid // in audio_coding_module_typedefs.h for valid
@ -665,20 +671,20 @@ class AudioCodingModule: public Module {
// //
virtual WebRtc_Word32 virtual WebRtc_Word32
RegisterIncomingMessagesCallback( RegisterIncomingMessagesCallback(
AudioCodingFeedback* inMsgCallback, AudioCodingFeedback* in_message_callback,
const ACMCountries cpt = ACMDisableCountryDetection) = 0; const ACMCountries cpt = ACMDisableCountryDetection) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 SetDtmfPlayoutStatus() // WebRtc_Word32 SetDtmfPlayoutStatus()
// Configure Dtmf playout, i.e. whether out-of-band // Configure DTMF playout, i.e. whether out-of-band
// Dtmf tones are played or not. // DTMF tones are played or not.
// //
// Input: // Input:
// -enable : if true to enable playout out-of-band Dtmf tones, // -enable : if true to enable playout out-of-band DTMF tones,
// false to disable. // false to disable.
// //
// Return value: // Return value:
// -1 if the method fails, e.g. Dtmf playout is not supported. // -1 if the method fails, e.g. DTMF playout is not supported.
// 0 if the status is set successfully. // 0 if the status is set successfully.
// //
virtual WebRtc_Word32 SetDtmfPlayoutStatus(const bool enable) = 0; virtual WebRtc_Word32 SetDtmfPlayoutStatus(const bool enable) = 0;
@ -696,7 +702,7 @@ class AudioCodingModule: public Module {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 SetBackgroundNoiseMode() // WebRtc_Word32 SetBackgroundNoiseMode()
// Sets the mode of the background noise playout in an event of long // Sets the mode of the background noise playout in an event of long
// packetloss burst. For the valid modes see the declaration of // packet loss burst. For the valid modes see the declaration of
// ACMBackgroundNoiseMode in audio_coding_module_typedefs.h. // ACMBackgroundNoiseMode in audio_coding_module_typedefs.h.
// //
// Input: // Input:
@ -712,7 +718,7 @@ class AudioCodingModule: public Module {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 BackgroundNoiseMode() // WebRtc_Word32 BackgroundNoiseMode()
// Call this method to get the mode of the background noise playout. // Call this method to get the mode of the background noise playout.
// Playout of background noise is a result of a long packetloss burst. // Playout of background noise is a result of a long packet loss burst.
// See ACMBackgroundNoiseMode in audio_coding_module_typedefs.h for // See ACMBackgroundNoiseMode in audio_coding_module_typedefs.h for
// possible modes. // possible modes.
// //
@ -746,7 +752,7 @@ class AudioCodingModule: public Module {
// Get the estimate of the Bandwidth, in bits/second, based on the incoming // Get the estimate of the Bandwidth, in bits/second, based on the incoming
// stream. This API is useful in one-way communication scenarios, where // stream. This API is useful in one-way communication scenarios, where
// the bandwidth information is sent in an out-of-band fashion. // the bandwidth information is sent in an out-of-band fashion.
// Currently only supported if iSAC is registered as a reciever. // Currently only supported if iSAC is registered as a receiver.
// //
// Return value: // Return value:
// >0 bandwidth in bits/second. // >0 bandwidth in bits/second.
@ -762,7 +768,7 @@ class AudioCodingModule: public Module {
// delay. In FAX mode, NetEQ is optimized to have few delay changes as // delay. In FAX mode, NetEQ is optimized to have few delay changes as
// possible and maintain a constant delay, perhaps large relative to voice // possible and maintain a constant delay, perhaps large relative to voice
// mode, to avoid PLC. In streaming mode, we tolerate a little more delay // mode, to avoid PLC. In streaming mode, we tolerate a little more delay
// to acheive better jitter robustness. // to achieve better jitter robustness.
// //
// Input: // Input:
// -mode : playout mode. Possible inputs are: // -mode : playout mode. Possible inputs are:
@ -786,7 +792,7 @@ class AudioCodingModule: public Module {
// fax: a mode that is optimized for receiving FAX signals. // fax: a mode that is optimized for receiving FAX signals.
// In this mode NetEq tries to maintain a constant high // In this mode NetEq tries to maintain a constant high
// delay to avoid PLC if possible. // delay to avoid PLC if possible.
// streaming: a mode that is suitable for streaminq. In this mode we // streaming: a mode that is suitable for streaming. In this mode we
// accept longer delay to improve jitter robustness. // accept longer delay to improve jitter robustness.
// //
virtual AudioPlayoutMode PlayoutMode() const = 0; virtual AudioPlayoutMode PlayoutMode() const = 0;
@ -797,12 +803,12 @@ class AudioCodingModule: public Module {
// frequency. ACM will perform a resampling if required. // frequency. ACM will perform a resampling if required.
// //
// Input: // Input:
// -desiredFreqHz : the desired sampling frequency, in Hertz, of the // -desired_freq_hz : the desired sampling frequency, in Hertz, of the
// output audio. If set to -1, the function returns the // output audio. If set to -1, the function returns the
// audio at the current sampling frequency. // audio at the current sampling frequency.
// //
// Output: // Output:
// -audioFrame : output audio frame which contains raw audio data // -audio_frame : output audio frame which contains raw audio data
// and other relevant parameters, c.f. // and other relevant parameters, c.f.
// module_common_types.h for the definition of // module_common_types.h for the definition of
// AudioFrame. // AudioFrame.
@ -812,8 +818,8 @@ class AudioCodingModule: public Module {
// 0 if the function succeeds. // 0 if the function succeeds.
// //
virtual WebRtc_Word32 virtual WebRtc_Word32
PlayoutData10Ms(const WebRtc_Word32 desiredFreqHz, PlayoutData10Ms(const WebRtc_Word32 desired_freq_hz,
AudioFrame &audioFrame) = 0; AudioFrame &audio_frame) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// (CNG) Comfort Noise Generation // (CNG) Comfort Noise Generation
@ -855,43 +861,43 @@ class AudioCodingModule: public Module {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 SetISACMaxRate() // WebRtc_Word32 SetISACMaxRate()
// Set the maximum instantaneous rate of iSAC. For a payload of B bits // Set the maximum instantaneous rate of iSAC. For a payload of B bits
// with a frame-size of T sec the instantaneous rate is B/T bist per // with a frame-size of T sec the instantaneous rate is B/T bits per
// second. Therefore, (B/T < maxRateBitPerSec) and // second. Therefore, (B/T < |max_rate_bps|) and
// (B < maxPayloadLenBytes * 8) are always satisfied for iSAC payloads, // (B < |max_payload_len_bytes| * 8) are always satisfied for iSAC payloads,
// c.f SetISACMaxPayloadSize(). // c.f SetISACMaxPayloadSize().
// //
// Input: // Input:
// -maxRateBitPerSec : maximum instantaneous bit-rate given in bits/sec. // -max_rate_bps : maximum instantaneous bit-rate given in bits/sec.
// //
// Return value: // Return value:
// -1 if failed to set the maximum rate. // -1 if failed to set the maximum rate.
// 0 if the maximum rate is set successfully. // 0 if the maximum rate is set successfully.
// //
virtual WebRtc_Word32 SetISACMaxRate( virtual WebRtc_Word32 SetISACMaxRate(
const WebRtc_UWord32 maxRateBitPerSec) = 0; const WebRtc_UWord32 max_rate_bps) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 SetISACMaxPayloadSize() // WebRtc_Word32 SetISACMaxPayloadSize()
// Set the maximum payload size of iSAC packets. No iSAC payload, // Set the maximum payload size of iSAC packets. No iSAC payload,
// regardless of its frame-size, may exceed the given limit. For // regardless of its frame-size, may exceed the given limit. For
// an iSAC payload of size B bits and frame-size T sec we have; // an iSAC payload of size B bits and frame-size T seconds we have;
// (B < maxPayloadLenBytes * 8) and (B/T < maxRateBitPerSec), c.f. // (B < |max_payload_len_bytes| * 8) and (B/T < |max_rate_bps|), c.f.
// SetISACMaxRate(). // SetISACMaxRate().
// //
// Input: // Input:
// -maxPayloadLenBytes : maximum payload size in bytes. // -max_payload_len_bytes : maximum payload size in bytes.
// //
// Return value: // Return value:
// -1 if failed to set the maximm payload-size. // -1 if failed to set the maximum payload-size.
// 0 if the given linit is seet successfully. // 0 if the given length is set successfully.
// //
virtual WebRtc_Word32 SetISACMaxPayloadSize( virtual WebRtc_Word32 SetISACMaxPayloadSize(
const WebRtc_UWord16 maxPayloadLenBytes) = 0; const WebRtc_UWord16 max_payload_len_bytes) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 ConfigISACBandwidthEstimator() // WebRtc_Word32 ConfigISACBandwidthEstimator()
// Call this function to configure the bandwidth estimator of ISAC. // Call this function to configure the bandwidth estimator of ISAC.
// During the adaptation of bit-rate, iSAC atomatically adjusts the // During the adaptation of bit-rate, iSAC automatically adjusts the
// frame-size (either 30 or 60 ms) to save on RTP header. The initial // frame-size (either 30 or 60 ms) to save on RTP header. The initial
// frame-size can be specified by the first argument. The configuration also // frame-size can be specified by the first argument. The configuration also
// regards the initial estimate of bandwidths. The estimator starts from // regards the initial estimate of bandwidths. The estimator starts from
@ -900,22 +906,22 @@ class AudioCodingModule: public Module {
// adaptation of frame-size. This is specified by the last parameter. // adaptation of frame-size. This is specified by the last parameter.
// //
// Input: // Input:
// -initFrameSizeMsec : initial frame-size in milisecods. For iSAC-wb // -init_frame_size_ms : initial frame-size in milliseconds. For iSAC-wb
// 30 ms and 60 ms (default) are acceptable values, // 30 ms and 60 ms (default) are acceptable values,
// and for iSAC-swb 30 ms is the only acceptable // and for iSAC-swb 30 ms is the only acceptable
// value. Zero indiates default value. // value. Zero indicates default value.
// -initRateBitPerSec : initial estimate of the bandwidth. Values // -init_rate_bps : initial estimate of the bandwidth. Values
// between 10000 and 58000 are acceptable. // between 10000 and 58000 are acceptable.
// -enforceFrameSize : if true, the frame-size will not be adapted. // -enforce_srame_size : if true, the frame-size will not be adapted.
// //
// Return value: // Return value:
// -1 if failed to configure the bandwidth estimator, // -1 if failed to configure the bandwidth estimator,
// 0 if the configuration was successfully applied. // 0 if the configuration was successfully applied.
// //
virtual WebRtc_Word32 ConfigISACBandwidthEstimator( virtual WebRtc_Word32 ConfigISACBandwidthEstimator(
const WebRtc_UWord8 initFrameSizeMsec, const WebRtc_UWord8 init_frame_size_ms,
const WebRtc_UWord16 initRateBitPerSec, const WebRtc_UWord16 init_rate_bps,
const bool enforceFrameSize = false) = 0; const bool enforce_frame_size = false) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// statistics // statistics
@ -926,14 +932,14 @@ class AudioCodingModule: public Module {
// Get network statistics. // Get network statistics.
// //
// Input: // Input:
// -networkStatistics : a structure that contains network statistics. // -network_statistics : a structure that contains network statistics.
// //
// Return value: // Return value:
// -1 if failed to set the network statistics, // -1 if failed to set the network statistics,
// 0 if statistics are set successfully. // 0 if statistics are set successfully.
// //
virtual WebRtc_Word32 NetworkStatistics( virtual WebRtc_Word32 NetworkStatistics(
ACMNetworkStatistics& networkStatistics) const = 0; ACMNetworkStatistics& network_statistics) const = 0;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_TYPEDEFS_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_TYPEDEFS_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_TYPEDEFS_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_TYPEDEFS_H_
#include "typedefs.h" #include "webrtc/typedefs.h"
namespace webrtc { namespace webrtc {

View File

@ -8,14 +8,15 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_amr.h" #include "webrtc/modules/audio_coding/main/source/acm_amr.h"
#include "acm_common_defs.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "audio_coding_module_typedefs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "rw_lock_wrapper.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "trace.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
#include "webrtc/system_wrappers/interface/trace.h"
#ifdef WEBRTC_CODEC_AMR #ifdef WEBRTC_CODEC_AMR
// NOTE! GSM AMR is not included in the open-source package. The following // NOTE! GSM AMR is not included in the open-source package. The following
@ -25,23 +26,23 @@
// //
// The API in the header file should match the one below. // The API in the header file should match the one below.
// //
// int16_t WebRtcAmr_CreateEnc(AMR_encinst_t_** encInst); // int16_t WebRtcAmr_CreateEnc(AMR_encinst_t_** enc_inst);
// int16_t WebRtcAmr_CreateDec(AMR_decinst_t_** decInst); // int16_t WebRtcAmr_CreateDec(AMR_decinst_t_** dec_inst);
// int16_t WebRtcAmr_FreeEnc(AMR_encinst_t_* encInst); // int16_t WebRtcAmr_FreeEnc(AMR_encinst_t_* enc_inst);
// int16_t WebRtcAmr_FreeDec(AMR_decinst_t_* decInst); // int16_t WebRtcAmr_FreeDec(AMR_decinst_t_* dec_inst);
// int16_t WebRtcAmr_Encode(AMR_encinst_t_* encInst, // int16_t WebRtcAmr_Encode(AMR_encinst_t_* enc_inst,
// int16_t* input, // int16_t* input,
// int16_t len, // int16_t len,
// int16_t*output, // int16_t*output,
// int16_t mode); // int16_t mode);
// int16_t WebRtcAmr_EncoderInit(AMR_encinst_t_* encInst, // int16_t WebRtcAmr_EncoderInit(AMR_encinst_t_* enc_inst,
// int16_t dtxMode); // int16_t dtx_mode);
// int16_t WebRtcAmr_EncodeBitmode(AMR_encinst_t_* encInst, // int16_t WebRtcAmr_EncodeBitmode(AMR_encinst_t_* enc_inst,
// int format); // int format);
// int16_t WebRtcAmr_Decode(AMR_decinst_t_* decInst); // int16_t WebRtcAmr_Decode(AMR_decinst_t_* dec_inst);
// int16_t WebRtcAmr_DecodePlc(AMR_decinst_t_* decInst); // int16_t WebRtcAmr_DecodePlc(AMR_decinst_t_* dec_inst);
// int16_t WebRtcAmr_DecoderInit(AMR_decinst_t_* decInst); // int16_t WebRtcAmr_DecoderInit(AMR_decinst_t_* dec_inst);
// int16_t WebRtcAmr_DecodeBitmode(AMR_decinst_t_* decInst, // int16_t WebRtcAmr_DecodeBitmode(AMR_decinst_t_* dec_inst,
// int format); // int format);
#include "amr_interface.h" #include "amr_interface.h"
#endif #endif
@ -49,13 +50,13 @@
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_AMR #ifndef WEBRTC_CODEC_AMR
ACMAMR::ACMAMR(WebRtc_Word16 /* codecID */) ACMAMR::ACMAMR(WebRtc_Word16 /* codec_id */)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL), decoder_inst_ptr_(NULL),
_encodingMode(-1), // Invalid value. encoding_mode_(-1), // Invalid value.
_encodingRate(0), // Invalid value. encoding_rate_(0), // Invalid value.
_encoderPackingFormat(AMRBandwidthEfficient), encoder_packing_format_(AMRBandwidthEfficient),
_decoderPackingFormat(AMRBandwidthEfficient) { decoder_packing_format_(AMRBandwidthEfficient) {
return; return;
} }
@ -63,16 +64,16 @@ ACMAMR::~ACMAMR() {
return; return;
} }
WebRtc_Word16 ACMAMR::InternalEncode(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMAMR::InternalEncode(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_Word16* /* bitstream_len_byte */) {
return -1; return -1;
} }
WebRtc_Word16 ACMAMR::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMAMR::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return -1; return -1;
} }
@ -85,17 +86,17 @@ WebRtc_Word16 ACMAMR::DisableDTX() {
} }
WebRtc_Word16 ACMAMR::InternalInitEncoder( WebRtc_Word16 ACMAMR::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word16 ACMAMR::InternalInitDecoder( WebRtc_Word16 ACMAMR::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -123,12 +124,12 @@ WebRtc_Word16 ACMAMR::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
return -1; return -1;
} }
void ACMAMR::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMAMR::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
WebRtc_Word16 ACMAMR::SetAMREncoderPackingFormat( WebRtc_Word16 ACMAMR::SetAMREncoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */) { ACMAMRPackingFormat /* packing_format */) {
return -1; return -1;
} }
@ -137,7 +138,7 @@ ACMAMRPackingFormat ACMAMR::AMREncoderPackingFormat() const {
} }
WebRtc_Word16 ACMAMR::SetAMRDecoderPackingFormat( WebRtc_Word16 ACMAMR::SetAMRDecoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */) { ACMAMRPackingFormat /* packing_format */) {
return -1; return -1;
} }
@ -156,78 +157,78 @@ ACMAMRPackingFormat ACMAMR::AMRDecoderPackingFormat() const {
#define WEBRTC_AMR_MR102 6 #define WEBRTC_AMR_MR102 6
#define WEBRTC_AMR_MR122 7 #define WEBRTC_AMR_MR122 7
ACMAMR::ACMAMR(WebRtc_Word16 codecID) ACMAMR::ACMAMR(WebRtc_Word16 codec_id)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL), decoder_inst_ptr_(NULL),
_encodingMode(-1), // invalid value encoding_mode_(-1), // invalid value
_encodingRate(0) { // invalid value encoding_rate_(0) { // invalid value
_codecID = codecID; codec_id_ = codec_id;
_hasInternalDTX = true; has_internal_dtx_ = true;
_encoderPackingFormat = AMRBandwidthEfficient; encoder_packing_format_ = AMRBandwidthEfficient;
_decoderPackingFormat = AMRBandwidthEfficient; decoder_packing_format_ = AMRBandwidthEfficient;
return; return;
} }
ACMAMR::~ACMAMR() { ACMAMR::~ACMAMR() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcAmr_FreeEnc(_encoderInstPtr); WebRtcAmr_FreeEnc(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcAmr_FreeDec(_decoderInstPtr); WebRtcAmr_FreeDec(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
return; return;
} }
WebRtc_Word16 ACMAMR::InternalEncode(WebRtc_UWord8* bitStream, WebRtc_Word16 ACMAMR::InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte) { WebRtc_Word16* bitstream_len_byte) {
WebRtc_Word16 vadDecision = 1; WebRtc_Word16 vad_decision = 1;
// sanity check, if the rate is set correctly. we might skip this // sanity check, if the rate is set correctly. we might skip this
// sanity check. if rate is not set correctly, initialization flag // sanity check. if rate is not set correctly, initialization flag
// should be false and should not be here. // should be false and should not be here.
if ((_encodingMode < WEBRTC_AMR_MR475) || if ((encoding_mode_ < WEBRTC_AMR_MR475) ||
(_encodingMode > WEBRTC_AMR_MR122)) { (encoding_mode_ > WEBRTC_AMR_MR122)) {
*bitStreamLenByte = 0; *bitstream_len_byte = 0;
return -1; return -1;
} }
*bitStreamLenByte = WebRtcAmr_Encode(_encoderInstPtr, *bitstream_len_byte = WebRtcAmr_Encode(encoder_inst_ptr_,
&_inAudio[_inAudioIxRead], &in_audio_[in_audio_ix_read_],
_frameLenSmpl, frame_len_smpl_,
(WebRtc_Word16*) bitStream, (WebRtc_Word16*)bitstream,
_encodingMode); encoding_mode_);
// Update VAD, if internal DTX is used // Update VAD, if internal DTX is used
if (_hasInternalDTX && _dtxEnabled) { if (has_internal_dtx_ && dtx_enabled_) {
if (*bitStreamLenByte <= (7 * _frameLenSmpl / 160)) { if (*bitstream_len_byte <= (7 * frame_len_smpl_ / 160)) {
vadDecision = 0; vad_decision = 0;
} }
for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) { for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
_vadLabel[n] = vadDecision; vad_label_[n] = vad_decision;
} }
} }
// increment the read index // increment the read index
_inAudioIxRead += _frameLenSmpl; in_audio_ix_read_ += frame_len_smpl_;
return *bitStreamLenByte; return *bitstream_len_byte;
} }
WebRtc_Word16 ACMAMR::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMAMR::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMAMR::EnableDTX() { WebRtc_Word16 ACMAMR::EnableDTX() {
if (_dtxEnabled) { if (dtx_enabled_) {
return 0; return 0;
} else if (_encoderExist) { // check if encoder exist } else if (encoder_exist_) { // check if encoder exist
// enable DTX // enable DTX
if (WebRtcAmr_EncoderInit(_encoderInstPtr, 1) < 0) { if (WebRtcAmr_EncoderInit(encoder_inst_ptr_, 1) < 0) {
return -1; return -1;
} }
_dtxEnabled = true; dtx_enabled_ = true;
return 0; return 0;
} else { } else {
return -1; return -1;
@ -235,14 +236,14 @@ WebRtc_Word16 ACMAMR::EnableDTX() {
} }
WebRtc_Word16 ACMAMR::DisableDTX() { WebRtc_Word16 ACMAMR::DisableDTX() {
if (!_dtxEnabled) { if (!dtx_enabled_) {
return 0; return 0;
} else if (_encoderExist) { // check if encoder exist } else if (encoder_exist_) { // check if encoder exist
// disable DTX // disable DTX
if (WebRtcAmr_EncoderInit(_encoderInstPtr, 0) < 0) { if (WebRtcAmr_EncoderInit(encoder_inst_ptr_, 0) < 0) {
return -1; return -1;
} }
_dtxEnabled = false; dtx_enabled_ = false;
return 0; return 0;
} else { } else {
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless
@ -250,26 +251,26 @@ WebRtc_Word16 ACMAMR::DisableDTX() {
} }
} }
WebRtc_Word16 ACMAMR::InternalInitEncoder(WebRtcACMCodecParams* codecParams) { WebRtc_Word16 ACMAMR::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate); WebRtc_Word16 status = SetBitRateSafe((codec_params->codec_inst).rate);
status += (WebRtcAmr_EncoderInit( status += (WebRtcAmr_EncoderInit(
_encoderInstPtr, ((codecParams->enableDTX) ? 1 : 0)) < 0) ? -1 : 0; encoder_inst_ptr_, ((codec_params->enable_dtx) ? 1 : 0)) < 0) ? -1 : 0;
status += (WebRtcAmr_EncodeBitmode( status += (WebRtcAmr_EncodeBitmode(
_encoderInstPtr, _encoderPackingFormat) < 0) ? -1 : 0; encoder_inst_ptr_, encoder_packing_format_) < 0) ? -1 : 0;
return (status < 0) ? -1 : 0; return (status < 0) ? -1 : 0;
} }
WebRtc_Word16 ACMAMR::InternalInitDecoder( WebRtc_Word16 ACMAMR::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
WebRtc_Word16 status = WebRtc_Word16 status =
((WebRtcAmr_DecoderInit(_decoderInstPtr) < 0) ? -1 : 0); ((WebRtcAmr_DecoderInit(decoder_inst_ptr_) < 0) ? -1 : 0);
status += WebRtcAmr_DecodeBitmode(_decoderInstPtr, _decoderPackingFormat); status += WebRtcAmr_DecodeBitmode(decoder_inst_ptr_, decoder_packing_format_);
return (status < 0) ? -1 : 0; return (status < 0) ? -1 : 0;
} }
WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!_decoderInitialized) { if (!decoder_initialized_) {
// Todo: // Todo:
// log error // log error
return -1; return -1;
@ -278,9 +279,9 @@ WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
// "SET_CODEC_PAR" & "SET_AMR_FUNCTION." // "SET_CODEC_PAR" & "SET_AMR_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
SET_CODEC_PAR((codecDef), kDecoderAMR, codecInst.pltype, _decoderInstPtr, SET_CODEC_PAR((codec_def), kDecoderAMR, codec_inst.pltype, decoder_inst_ptr_,
8000); 8000);
SET_AMR_FUNCTIONS((codecDef)); SET_AMR_FUNCTIONS((codec_def));
return 0; return 0;
} }
@ -289,75 +290,75 @@ ACMGenericCodec* ACMAMR::CreateInstance(void) {
} }
WebRtc_Word16 ACMAMR::InternalCreateEncoder() { WebRtc_Word16 ACMAMR::InternalCreateEncoder() {
return WebRtcAmr_CreateEnc(&_encoderInstPtr); return WebRtcAmr_CreateEnc(&encoder_inst_ptr_);
} }
void ACMAMR::DestructEncoderSafe() { void ACMAMR::DestructEncoderSafe() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcAmr_FreeEnc(_encoderInstPtr); WebRtcAmr_FreeEnc(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
// there is no encoder set the following // there is no encoder set the following
_encoderExist = false; encoder_exist_ = false;
_encoderInitialized = false; encoder_initialized_ = false;
_encodingMode = -1; // invalid value encoding_mode_ = -1; // invalid value
_encodingRate = 0; // invalid value encoding_rate_ = 0; // invalid value
} }
WebRtc_Word16 ACMAMR::InternalCreateDecoder() { WebRtc_Word16 ACMAMR::InternalCreateDecoder() {
return WebRtcAmr_CreateDec(&_decoderInstPtr); return WebRtcAmr_CreateDec(&decoder_inst_ptr_);
} }
void ACMAMR::DestructDecoderSafe() { void ACMAMR::DestructDecoderSafe() {
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcAmr_FreeDec(_decoderInstPtr); WebRtcAmr_FreeDec(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
// there is no encoder instance set the followings // there is no encoder instance set the followings
_decoderExist = false; decoder_exist_ = false;
_decoderInitialized = false; decoder_initialized_ = false;
} }
WebRtc_Word16 ACMAMR::SetBitRateSafe(const WebRtc_Word32 rate) { WebRtc_Word16 ACMAMR::SetBitRateSafe(const WebRtc_Word32 rate) {
switch (rate) { switch (rate) {
case 4750: { case 4750: {
_encodingMode = WEBRTC_AMR_MR475; encoding_mode_ = WEBRTC_AMR_MR475;
_encodingRate = 4750; encoding_rate_ = 4750;
break; break;
} }
case 5150: { case 5150: {
_encodingMode = WEBRTC_AMR_MR515; encoding_mode_ = WEBRTC_AMR_MR515;
_encodingRate = 5150; encoding_rate_ = 5150;
break; break;
} }
case 5900: { case 5900: {
_encodingMode = WEBRTC_AMR_MR59; encoding_mode_ = WEBRTC_AMR_MR59;
_encodingRate = 5900; encoding_rate_ = 5900;
break; break;
} }
case 6700: { case 6700: {
_encodingMode = WEBRTC_AMR_MR67; encoding_mode_ = WEBRTC_AMR_MR67;
_encodingRate = 6700; encoding_rate_ = 6700;
break; break;
} }
case 7400: { case 7400: {
_encodingMode = WEBRTC_AMR_MR74; encoding_mode_ = WEBRTC_AMR_MR74;
_encodingRate = 7400; encoding_rate_ = 7400;
break; break;
} }
case 7950: { case 7950: {
_encodingMode = WEBRTC_AMR_MR795; encoding_mode_ = WEBRTC_AMR_MR795;
_encodingRate = 7950; encoding_rate_ = 7950;
break; break;
} }
case 10200: { case 10200: {
_encodingMode = WEBRTC_AMR_MR102; encoding_mode_ = WEBRTC_AMR_MR102;
_encodingRate = 10200; encoding_rate_ = 10200;
break; break;
} }
case 12200: { case 12200: {
_encodingMode = WEBRTC_AMR_MR122; encoding_mode_ = WEBRTC_AMR_MR122;
_encodingRate = 12200; encoding_rate_ = 12200;
break; break;
} }
default: { default: {
@ -367,58 +368,57 @@ WebRtc_Word16 ACMAMR::SetBitRateSafe(const WebRtc_Word32 rate) {
return 0; return 0;
} }
void ACMAMR::InternalDestructEncoderInst(void* ptrInst) { void ACMAMR::InternalDestructEncoderInst(void* ptr_inst) {
// Free the memory where ptrInst is pointing to // Free the memory where ptr_inst is pointing to
if (ptrInst != NULL) { if (ptr_inst != NULL) {
WebRtcAmr_FreeEnc(reinterpret_cast<AMR_encinst_t_*>(ptrInst)); WebRtcAmr_FreeEnc(reinterpret_cast<AMR_encinst_t_*>(ptr_inst));
} }
return; return;
} }
WebRtc_Word16 ACMAMR::SetAMREncoderPackingFormat( WebRtc_Word16 ACMAMR::SetAMREncoderPackingFormat(
ACMAMRPackingFormat packingFormat) { ACMAMRPackingFormat packing_format) {
if ((packingFormat != AMRBandwidthEfficient) && if ((packing_format != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) && (packing_format != AMROctetAlligned) &&
(packingFormat != AMRFileStorage)) { (packing_format != AMRFileStorage)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Invalid AMR Encoder packing-format."); "Invalid AMR Encoder packing-format.");
return -1; return -1;
} else { } else {
if (WebRtcAmr_EncodeBitmode(_encoderInstPtr, packingFormat) < 0) { if (WebRtcAmr_EncodeBitmode(encoder_inst_ptr_, packing_format) < 0) {
return -1; return -1;
} else { } else {
_encoderPackingFormat = packingFormat; encoder_packing_format_ = packing_format;
return 0; return 0;
} }
} }
} }
ACMAMRPackingFormat ACMAMR::AMREncoderPackingFormat() const { ACMAMRPackingFormat ACMAMR::AMREncoderPackingFormat() const {
return _encoderPackingFormat; return encoder_packing_format_;
} }
WebRtc_Word16 ACMAMR::SetAMRDecoderPackingFormat( WebRtc_Word16 ACMAMR::SetAMRDecoderPackingFormat(
ACMAMRPackingFormat packingFormat) { ACMAMRPackingFormat packing_format) {
if ((packingFormat != AMRBandwidthEfficient) && if ((packing_format != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) && (packing_format != AMROctetAlligned) &&
(packingFormat != AMRFileStorage)) { (packing_format != AMRFileStorage)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Invalid AMR decoder packing-format."); "Invalid AMR decoder packing-format.");
return -1; return -1;
} else { } else {
if (WebRtcAmr_DecodeBitmode(_decoderInstPtr, packingFormat) < 0) { if (WebRtcAmr_DecodeBitmode(decoder_inst_ptr_, packing_format) < 0) {
return -1; return -1;
} else { } else {
_decoderPackingFormat = packingFormat; decoder_packing_format_ = packing_format;
return 0; return 0;
} }
} }
} }
ACMAMRPackingFormat ACMAMR::AMRDecoderPackingFormat() const { ACMAMRPackingFormat ACMAMR::AMRDecoderPackingFormat() const {
return _decoderPackingFormat; return decoder_packing_format_;
} }
#endif #endif
} }

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
// forward declaration // forward declaration
struct AMR_encinst_t_; struct AMR_encinst_t_;
@ -23,36 +23,37 @@ enum ACMAMRPackingFormat;
class ACMAMR: public ACMGenericCodec { class ACMAMR: public ACMGenericCodec {
public: public:
ACMAMR(WebRtc_Word16 codecID); explicit ACMAMR(WebRtc_Word16 codec_id);
~ACMAMR(); ~ACMAMR();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 SetAMREncoderPackingFormat( WebRtc_Word16 SetAMREncoderPackingFormat(
const ACMAMRPackingFormat packingFormat); const ACMAMRPackingFormat packing_format);
ACMAMRPackingFormat AMREncoderPackingFormat() const; ACMAMRPackingFormat AMREncoderPackingFormat() const;
WebRtc_Word16 SetAMRDecoderPackingFormat( WebRtc_Word16 SetAMRDecoderPackingFormat(
const ACMAMRPackingFormat packingFormat); const ACMAMRPackingFormat packing_format);
ACMAMRPackingFormat AMRDecoderPackingFormat() const; ACMAMRPackingFormat AMRDecoderPackingFormat() const;
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audioSamples, WebRtc_Word16* audio, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -62,7 +63,7 @@ class ACMAMR: public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate); WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
@ -70,14 +71,14 @@ class ACMAMR: public ACMGenericCodec {
WebRtc_Word16 DisableDTX(); WebRtc_Word16 DisableDTX();
AMR_encinst_t_* _encoderInstPtr; AMR_encinst_t_* encoder_inst_ptr_;
AMR_decinst_t_* _decoderInstPtr; AMR_decinst_t_* decoder_inst_ptr_;
WebRtc_Word16 _encodingMode; WebRtc_Word16 encoding_mode_;
WebRtc_Word16 _encodingRate; WebRtc_Word16 encoding_rate_;
ACMAMRPackingFormat _encoderPackingFormat; ACMAMRPackingFormat encoder_packing_format_;
ACMAMRPackingFormat _decoderPackingFormat; ACMAMRPackingFormat decoder_packing_format_;
}; };
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_ #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_

View File

@ -8,14 +8,15 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_amrwb.h" #include "webrtc/modules/audio_coding/main/source/acm_amrwb.h"
#include "acm_common_defs.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "audio_coding_module_typedefs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "rw_lock_wrapper.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "trace.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
#include "webrtc/system_wrappers/interface/trace.h"
#ifdef WEBRTC_CODEC_AMRWB #ifdef WEBRTC_CODEC_AMRWB
// NOTE! GSM AMR-wb is not included in the open-source package. The // NOTE! GSM AMR-wb is not included in the open-source package. The
@ -25,20 +26,20 @@
// //
// The API in the header file should match the one below. // The API in the header file should match the one below.
// //
// int16_t WebRtcAmrWb_CreateEnc(AMRWB_encinst_t_** encInst); // int16_t WebRtcAmrWb_CreateEnc(AMRWB_encinst_t_** enc_inst);
// int16_t WebRtcAmrWb_CreateDec(AMRWB_decinst_t_** decInst); // int16_t WebRtcAmrWb_CreateDec(AMRWB_decinst_t_** dec_inst);
// int16_t WebRtcAmrWb_FreeEnc(AMRWB_encinst_t_* encInst); // int16_t WebRtcAmrWb_FreeEnc(AMRWB_encinst_t_* enc_inst);
// int16_t WebRtcAmrWb_FreeDec(AMRWB_decinst_t_* decInst); // int16_t WebRtcAmrWb_FreeDec(AMRWB_decinst_t_* dec_inst);
// int16_t WebRtcAmrWb_Encode(AMRWB_encinst_t_* encInst, int16_t* input, // int16_t WebRtcAmrWb_Encode(AMRWB_encinst_t_* enc_inst, int16_t* input,
// int16_t len, int16_t* output, int16_t mode); // int16_t len, int16_t* output, int16_t mode);
// int16_t WebRtcAmrWb_EncoderInit(AMRWB_encinst_t_* encInst, // int16_t WebRtcAmrWb_EncoderInit(AMRWB_encinst_t_* enc_inst,
// int16_t dtxMode); // int16_t dtx_mode);
// int16_t WebRtcAmrWb_EncodeBitmode(AMRWB_encinst_t_* encInst, // int16_t WebRtcAmrWb_EncodeBitmode(AMRWB_encinst_t_* enc_inst,
// int format); // int format);
// int16_t WebRtcAmrWb_Decode(AMRWB_decinst_t_* decInst); // int16_t WebRtcAmrWb_Decode(AMRWB_decinst_t_* dec_inst);
// int16_t WebRtcAmrWb_DecodePlc(AMRWB_decinst_t_* decInst); // int16_t WebRtcAmrWb_DecodePlc(AMRWB_decinst_t_* dec_inst);
// int16_t WebRtcAmrWb_DecoderInit(AMRWB_decinst_t_* decInst); // int16_t WebRtcAmrWb_DecoderInit(AMRWB_decinst_t_* dec_inst);
// int16_t WebRtcAmrWb_DecodeBitmode(AMRWB_decinst_t_* decInst, // int16_t WebRtcAmrWb_DecodeBitmode(AMRWB_decinst_t_* dec_inst,
// int format); // int format);
#include "amrwb_interface.h" #include "amrwb_interface.h"
#endif #endif
@ -46,30 +47,29 @@
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_AMRWB #ifndef WEBRTC_CODEC_AMRWB
ACMAMRwb::ACMAMRwb(WebRtc_Word16 /* codecID*/) ACMAMRwb::ACMAMRwb(WebRtc_Word16 /* codec_id */)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL), decoder_inst_ptr_(NULL),
_encodingMode(-1), // invalid value encoding_mode_(-1), // invalid value
_encodingRate(0), // invalid value encoding_rate_(0), // invalid value
_encoderPackingFormat(AMRBandwidthEfficient), encoder_packing_format_(AMRBandwidthEfficient),
_decoderPackingFormat(AMRBandwidthEfficient) { decoder_packing_format_(AMRBandwidthEfficient) {
return;
} }
ACMAMRwb::~ACMAMRwb() { ACMAMRwb::~ACMAMRwb() {
return;
} }
WebRtc_Word16 ACMAMRwb::InternalEncode(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMAMRwb::InternalEncode(
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitstream_len_byte */) {
return -1; return -1;
} }
WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return -1; return -1;
} }
@ -82,17 +82,17 @@ WebRtc_Word16 ACMAMRwb::DisableDTX() {
} }
WebRtc_Word16 ACMAMRwb::InternalInitEncoder( WebRtc_Word16 ACMAMRwb::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word16 ACMAMRwb::InternalInitDecoder( WebRtc_Word16 ACMAMRwb::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -121,12 +121,12 @@ WebRtc_Word16 ACMAMRwb::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
return -1; return -1;
} }
void ACMAMRwb::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMAMRwb::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
WebRtc_Word16 ACMAMRwb::SetAMRwbEncoderPackingFormat( WebRtc_Word16 ACMAMRwb::SetAMRwbEncoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */) { ACMAMRPackingFormat /* packing_format */) {
return -1; return -1;
} }
@ -135,7 +135,7 @@ ACMAMRPackingFormat ACMAMRwb::AMRwbEncoderPackingFormat() const {
} }
WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat( WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */) { ACMAMRPackingFormat /* packing_format */) {
return -1; return -1;
} }
@ -155,78 +155,78 @@ ACMAMRPackingFormat ACMAMRwb::AMRwbDecoderPackingFormat() const {
#define AMRWB_MODE_23k 7 #define AMRWB_MODE_23k 7
#define AMRWB_MODE_24k 8 #define AMRWB_MODE_24k 8
ACMAMRwb::ACMAMRwb(WebRtc_Word16 codecID) ACMAMRwb::ACMAMRwb(WebRtc_Word16 codec_id)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL), decoder_inst_ptr_(NULL),
_encodingMode(-1), // invalid value encoding_mode_(-1), // invalid value
_encodingRate(0) { // invalid value encoding_rate_(0) { // invalid value
_codecID = codecID; codec_id_ = codec_id;
_hasInternalDTX = true; has_internal_dtx_ = true;
_encoderPackingFormat = AMRBandwidthEfficient; encoder_packing_format_ = AMRBandwidthEfficient;
_decoderPackingFormat = AMRBandwidthEfficient; decoder_packing_format_ = AMRBandwidthEfficient;
return; return;
} }
ACMAMRwb::~ACMAMRwb() { ACMAMRwb::~ACMAMRwb() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcAmrWb_FreeEnc(_encoderInstPtr); WebRtcAmrWb_FreeEnc(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcAmrWb_FreeDec(_decoderInstPtr); WebRtcAmrWb_FreeDec(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
return; return;
} }
WebRtc_Word16 ACMAMRwb::InternalEncode(WebRtc_UWord8* bitStream, WebRtc_Word16 ACMAMRwb::InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte) { WebRtc_Word16* bitstream_len_byte) {
WebRtc_Word16 vadDecision = 1; WebRtc_Word16 vad_decision = 1;
// sanity check, if the rate is set correctly. we might skip this // sanity check, if the rate is set correctly. we might skip this
// sanity check. if rate is not set correctly, initialization flag // sanity check. if rate is not set correctly, initialization flag
// should be false and should not be here. // should be false and should not be here.
if ((_encodingMode < AMRWB_MODE_7k) || (_encodingMode > AMRWB_MODE_24k)) { if ((encoding_mode_ < AMRWB_MODE_7k) || (encoding_mode_ > AMRWB_MODE_24k)) {
*bitStreamLenByte = 0; *bitstream_len_byte = 0;
return -1; return -1;
} }
*bitStreamLenByte = WebRtcAmrWb_Encode(_encoderInstPtr, *bitstream_len_byte = WebRtcAmrWb_Encode(encoder_inst_ptr_,
&_inAudio[_inAudioIxRead], &in_audio_[in_audio_ix_read_],
_frameLenSmpl, frame_len_smpl_,
(WebRtc_Word16*) bitStream, (WebRtc_Word16*)bitstream,
_encodingMode); encoding_mode_);
// Update VAD, if internal DTX is used // Update VAD, if internal DTX is used
if (_hasInternalDTX && _dtxEnabled) { if (has_internal_dtx_ && dtx_enabled_) {
if (*bitStreamLenByte <= (7 * _frameLenSmpl / 160)) { if (*bitstream_len_byte <= (7 * frame_len_smpl_ / 160)) {
vadDecision = 0; vad_decision = 0;
} }
for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) { for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
_vadLabel[n] = vadDecision; vad_label_[n] = vad_decision;
} }
} }
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += _frameLenSmpl; in_audio_ix_read_ += frame_len_smpl_;
return *bitStreamLenByte; return *bitstream_len_byte;
} }
WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMAMRwb::EnableDTX() { WebRtc_Word16 ACMAMRwb::EnableDTX() {
if (_dtxEnabled) { if (dtx_enabled_) {
return 0; return 0;
} else if (_encoderExist) { // check if encoder exist } else if (encoder_exist_) { // check if encoder exist
// enable DTX // enable DTX
if (WebRtcAmrWb_EncoderInit(_encoderInstPtr, 1) < 0) { if (WebRtcAmrWb_EncoderInit(encoder_inst_ptr_, 1) < 0) {
return -1; return -1;
} }
_dtxEnabled = true; dtx_enabled_ = true;
return 0; return 0;
} else { } else {
return -1; return -1;
@ -234,14 +234,14 @@ WebRtc_Word16 ACMAMRwb::EnableDTX() {
} }
WebRtc_Word16 ACMAMRwb::DisableDTX() { WebRtc_Word16 ACMAMRwb::DisableDTX() {
if (!_dtxEnabled) { if (!dtx_enabled_) {
return 0; return 0;
} else if (_encoderExist) { // check if encoder exist } else if (encoder_exist_) { // check if encoder exist
// disable DTX // disable DTX
if (WebRtcAmrWb_EncoderInit(_encoderInstPtr, 0) < 0) { if (WebRtcAmrWb_EncoderInit(encoder_inst_ptr_, 0) < 0) {
return -1; return -1;
} }
_dtxEnabled = false; dtx_enabled_ = false;
return 0; return 0;
} else { } else {
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless
@ -249,31 +249,32 @@ WebRtc_Word16 ACMAMRwb::DisableDTX() {
} }
} }
WebRtc_Word16 ACMAMRwb::InternalInitEncoder(WebRtcACMCodecParams* codecParams) { WebRtc_Word16 ACMAMRwb::InternalInitEncoder(
WebRtcACMCodecParams* codec_params) {
// sanity check // sanity check
if (_encoderInstPtr == NULL) { if (encoder_inst_ptr_ == NULL) {
return -1; return -1;
} }
WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate); WebRtc_Word16 status = SetBitRateSafe((codec_params->codec_inst).rate);
status += (WebRtcAmrWb_EncoderInit( status += (WebRtcAmrWb_EncoderInit(
_encoderInstPtr, ((codecParams->enableDTX) ? 1 : 0)) < 0) ? -1 : 0; encoder_inst_ptr_, ((codec_params->enable_dtx) ? 1 : 0)) < 0) ? -1 : 0;
status += (WebRtcAmrWb_EncodeBitmode( status += (WebRtcAmrWb_EncodeBitmode(
_encoderInstPtr, _encoderPackingFormat) < 0) ? -1 : 0; encoder_inst_ptr_, encoder_packing_format_) < 0) ? -1 : 0;
return (status < 0) ? -1 : 0; return (status < 0) ? -1 : 0;
} }
WebRtc_Word16 ACMAMRwb::InternalInitDecoder( WebRtc_Word16 ACMAMRwb::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
WebRtc_Word16 status = WebRtcAmrWb_DecodeBitmode(_decoderInstPtr, WebRtc_Word16 status = WebRtcAmrWb_DecodeBitmode(decoder_inst_ptr_,
_decoderPackingFormat); decoder_packing_format_);
status += ((WebRtcAmrWb_DecoderInit(_decoderInstPtr) < 0) ? -1 : 0); status += ((WebRtcAmrWb_DecoderInit(decoder_inst_ptr_) < 0) ? -1 : 0);
return (status < 0) ? -1 : 0; return (status < 0) ? -1 : 0;
} }
WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!_decoderInitialized) { if (!decoder_initialized_) {
return -1; return -1;
} }
@ -281,9 +282,9 @@ WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
// "SET_CODEC_PAR" & "SET_AMRWB_FUNCTION." // "SET_CODEC_PAR" & "SET_AMRWB_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
SET_CODEC_PAR((codecDef), kDecoderAMRWB, codecInst.pltype, _decoderInstPtr, SET_CODEC_PAR((codec_def), kDecoderAMRWB, codec_inst.pltype,
16000); decoder_inst_ptr_, 16000);
SET_AMRWB_FUNCTIONS((codecDef)); SET_AMRWB_FUNCTIONS((codec_def));
return 0; return 0;
} }
@ -292,80 +293,80 @@ ACMGenericCodec* ACMAMRwb::CreateInstance(void) {
} }
WebRtc_Word16 ACMAMRwb::InternalCreateEncoder() { WebRtc_Word16 ACMAMRwb::InternalCreateEncoder() {
return WebRtcAmrWb_CreateEnc(&_encoderInstPtr); return WebRtcAmrWb_CreateEnc(&encoder_inst_ptr_);
} }
void ACMAMRwb::DestructEncoderSafe() { void ACMAMRwb::DestructEncoderSafe() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcAmrWb_FreeEnc(_encoderInstPtr); WebRtcAmrWb_FreeEnc(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
// there is no encoder set the following // there is no encoder set the following
_encoderExist = false; encoder_exist_ = false;
_encoderInitialized = false; encoder_initialized_ = false;
_encodingMode = -1; // invalid value encoding_mode_ = -1; // invalid value
_encodingRate = 0; encoding_rate_ = 0;
} }
WebRtc_Word16 ACMAMRwb::InternalCreateDecoder() { WebRtc_Word16 ACMAMRwb::InternalCreateDecoder() {
return WebRtcAmrWb_CreateDec(&_decoderInstPtr); return WebRtcAmrWb_CreateDec(&decoder_inst_ptr_);
} }
void ACMAMRwb::DestructDecoderSafe() { void ACMAMRwb::DestructDecoderSafe() {
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcAmrWb_FreeDec(_decoderInstPtr); WebRtcAmrWb_FreeDec(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
// there is no encoder instance set the followings // there is no encoder instance set the followings
_decoderExist = false; decoder_exist_ = false;
_decoderInitialized = false; decoder_initialized_ = false;
} }
WebRtc_Word16 ACMAMRwb::SetBitRateSafe(const WebRtc_Word32 rate) { WebRtc_Word16 ACMAMRwb::SetBitRateSafe(const WebRtc_Word32 rate) {
switch (rate) { switch (rate) {
case 7000: { case 7000: {
_encodingMode = AMRWB_MODE_7k; encoding_mode_ = AMRWB_MODE_7k;
_encodingRate = 7000; encoding_rate_ = 7000;
break; break;
} }
case 9000: { case 9000: {
_encodingMode = AMRWB_MODE_9k; encoding_mode_ = AMRWB_MODE_9k;
_encodingRate = 9000; encoding_rate_ = 9000;
break; break;
} }
case 12000: { case 12000: {
_encodingMode = AMRWB_MODE_12k; encoding_mode_ = AMRWB_MODE_12k;
_encodingRate = 12000; encoding_rate_ = 12000;
break; break;
} }
case 14000: { case 14000: {
_encodingMode = AMRWB_MODE_14k; encoding_mode_ = AMRWB_MODE_14k;
_encodingRate = 14000; encoding_rate_ = 14000;
break; break;
} }
case 16000: { case 16000: {
_encodingMode = AMRWB_MODE_16k; encoding_mode_ = AMRWB_MODE_16k;
_encodingRate = 16000; encoding_rate_ = 16000;
break; break;
} }
case 18000: { case 18000: {
_encodingMode = AMRWB_MODE_18k; encoding_mode_ = AMRWB_MODE_18k;
_encodingRate = 18000; encoding_rate_ = 18000;
break; break;
} }
case 20000: { case 20000: {
_encodingMode = AMRWB_MODE_20k; encoding_mode_ = AMRWB_MODE_20k;
_encodingRate = 20000; encoding_rate_ = 20000;
break; break;
} }
case 23000: { case 23000: {
_encodingMode = AMRWB_MODE_23k; encoding_mode_ = AMRWB_MODE_23k;
_encodingRate = 23000; encoding_rate_ = 23000;
break; break;
} }
case 24000: { case 24000: {
_encodingMode = AMRWB_MODE_24k; encoding_mode_ = AMRWB_MODE_24k;
_encodingRate = 24000; encoding_rate_ = 24000;
break; break;
} }
default: { default: {
@ -375,57 +376,57 @@ WebRtc_Word16 ACMAMRwb::SetBitRateSafe(const WebRtc_Word32 rate) {
return 0; return 0;
} }
void ACMAMRwb::InternalDestructEncoderInst(void* ptrInst) { void ACMAMRwb::InternalDestructEncoderInst(void* ptr_inst) {
if (ptrInst != NULL) { if (ptr_inst != NULL) {
WebRtcAmrWb_FreeEnc(static_cast<AMRWB_encinst_t_*>(ptrInst)); WebRtcAmrWb_FreeEnc(static_cast<AMRWB_encinst_t_*>(ptr_inst));
} }
return; return;
} }
WebRtc_Word16 ACMAMRwb::SetAMRwbEncoderPackingFormat( WebRtc_Word16 ACMAMRwb::SetAMRwbEncoderPackingFormat(
ACMAMRPackingFormat packingFormat) { ACMAMRPackingFormat packing_format) {
if ((packingFormat != AMRBandwidthEfficient) && if ((packing_format != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) && (packing_format != AMROctetAlligned) &&
(packingFormat != AMRFileStorage)) { (packing_format != AMRFileStorage)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Invalid AMRwb encoder packing-format."); "Invalid AMRwb encoder packing-format.");
return -1; return -1;
} else { } else {
if (WebRtcAmrWb_EncodeBitmode(_encoderInstPtr, packingFormat) < 0) { if (WebRtcAmrWb_EncodeBitmode(encoder_inst_ptr_, packing_format) < 0) {
return -1; return -1;
} else { } else {
_encoderPackingFormat = packingFormat; encoder_packing_format_ = packing_format;
return 0; return 0;
} }
} }
} }
ACMAMRPackingFormat ACMAMRwb::AMRwbEncoderPackingFormat() const { ACMAMRPackingFormat ACMAMRwb::AMRwbEncoderPackingFormat() const {
return _encoderPackingFormat; return encoder_packing_format_;
} }
WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat( WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat(
ACMAMRPackingFormat packingFormat) { ACMAMRPackingFormat packing_format) {
if ((packingFormat != AMRBandwidthEfficient) && if ((packing_format != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) && (packing_format != AMROctetAlligned) &&
(packingFormat != AMRFileStorage)) { (packing_format != AMRFileStorage)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Invalid AMRwb decoder packing-format."); "Invalid AMRwb decoder packing-format.");
return -1; return -1;
} else { } else {
if (WebRtcAmrWb_DecodeBitmode(_decoderInstPtr, packingFormat) < 0) { if (WebRtcAmrWb_DecodeBitmode(decoder_inst_ptr_, packing_format) < 0) {
return -1; return -1;
} else { } else {
_decoderPackingFormat = packingFormat; decoder_packing_format_ = packing_format;
return 0; return 0;
} }
} }
} }
ACMAMRPackingFormat ACMAMRwb::AMRwbDecoderPackingFormat() const { ACMAMRPackingFormat ACMAMRwb::AMRwbDecoderPackingFormat() const {
return _decoderPackingFormat; return decoder_packing_format_;
} }
#endif #endif
} // namespace webrtc } // namespace webrtc

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
// forward declaration // forward declaration
struct AMRWB_encinst_t_; struct AMRWB_encinst_t_;
@ -19,40 +19,39 @@ struct AMRWB_decinst_t_;
namespace webrtc { namespace webrtc {
enum ACMAMRPackingFormat;
class ACMAMRwb: public ACMGenericCodec { class ACMAMRwb: public ACMGenericCodec {
public: public:
ACMAMRwb(WebRtc_Word16 codecID); explicit ACMAMRwb(WebRtc_Word16 codec_id);
~ACMAMRwb(); ~ACMAMRwb();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams* codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams* codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams* codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams* codec_params);
WebRtc_Word16 SetAMRwbEncoderPackingFormat( WebRtc_Word16 SetAMRwbEncoderPackingFormat(
const ACMAMRPackingFormat packingFormat); const ACMAMRPackingFormat packing_format);
ACMAMRPackingFormat AMRwbEncoderPackingFormat() const; ACMAMRPackingFormat AMRwbEncoderPackingFormat() const;
WebRtc_Word16 SetAMRwbDecoderPackingFormat( WebRtc_Word16 SetAMRwbDecoderPackingFormat(
const ACMAMRPackingFormat packingFormat); const ACMAMRPackingFormat packing_format);
ACMAMRPackingFormat AMRwbDecoderPackingFormat() const; ACMAMRPackingFormat AMRwbDecoderPackingFormat() const;
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audioSamples, WebRtc_Word16* audio, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -62,7 +61,7 @@ class ACMAMRwb: public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate); WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
@ -70,15 +69,15 @@ class ACMAMRwb: public ACMGenericCodec {
WebRtc_Word16 DisableDTX(); WebRtc_Word16 DisableDTX();
AMRWB_encinst_t_* _encoderInstPtr; AMRWB_encinst_t_* encoder_inst_ptr_;
AMRWB_decinst_t_* _decoderInstPtr; AMRWB_decinst_t_* decoder_inst_ptr_;
WebRtc_Word16 _encodingMode; WebRtc_Word16 encoding_mode_;
WebRtc_Word16 _encodingRate; WebRtc_Word16 encoding_rate_;
ACMAMRPackingFormat _encoderPackingFormat; ACMAMRPackingFormat encoder_packing_format_;
ACMAMRPackingFormat _decoderPackingFormat; ACMAMRPackingFormat decoder_packing_format_;
}; };
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_ #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_

View File

@ -8,13 +8,13 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_celt.h"
#include "acm_neteq.h"
#include "acm_celt.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "trace.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
// TODO(tlegrand): Add full paths. #include "webrtc/system_wrappers/interface/trace.h"
#ifdef WEBRTC_CODEC_CELT #ifdef WEBRTC_CODEC_CELT
// NOTE! Celt is not included in the open-source package. Modify this file or // NOTE! Celt is not included in the open-source package. Modify this file or
@ -26,7 +26,7 @@ namespace webrtc {
#ifndef WEBRTC_CODEC_CELT #ifndef WEBRTC_CODEC_CELT
ACMCELT::ACMCELT(int16_t /* codecID */) ACMCELT::ACMCELT(int16_t /* codec_id */)
: enc_inst_ptr_(NULL), : enc_inst_ptr_(NULL),
dec_inst_ptr_(NULL), dec_inst_ptr_(NULL),
sampling_freq_(0), sampling_freq_(0),
@ -40,29 +40,29 @@ ACMCELT::~ACMCELT() {
return; return;
} }
int16_t ACMCELT::InternalEncode(uint8_t* /* bitStream */, int16_t ACMCELT::InternalEncode(uint8_t* /* bitstream */,
int16_t* /* bitStreamLenByte */) { int16_t* /* bitstream_len_byte */) {
return -1; return -1;
} }
int16_t ACMCELT::DecodeSafe(uint8_t* /* bitStream */, int16_t ACMCELT::DecodeSafe(uint8_t* /* bitstream */,
int16_t /* bitStreamLenByte */, int16_t /* bitstream_len_byte */,
int16_t* /* audio */, int16_t* /* audio */,
int16_t* /* audioSamples */, int16_t* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return -1; return -1;
} }
int16_t ACMCELT::InternalInitEncoder(WebRtcACMCodecParams* /* codecParams */) { int16_t ACMCELT::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
int16_t ACMCELT::InternalInitDecoder(WebRtcACMCodecParams* /* codecParams */) { int16_t ACMCELT::InternalInitDecoder(WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
int32_t ACMCELT::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, int32_t ACMCELT::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -86,7 +86,7 @@ void ACMCELT::DestructDecoderSafe() {
return; return;
} }
void ACMCELT::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMCELT::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
@ -103,7 +103,7 @@ void ACMCELT::SplitStereoPacket(uint8_t* /*payload*/,
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMCELT::ACMCELT(int16_t codecID) ACMCELT::ACMCELT(int16_t codec_id)
: enc_inst_ptr_(NULL), : enc_inst_ptr_(NULL),
dec_inst_ptr_(NULL), dec_inst_ptr_(NULL),
sampling_freq_(32000), // Default sampling frequency. sampling_freq_(32000), // Default sampling frequency.
@ -111,7 +111,7 @@ ACMCELT::ACMCELT(int16_t codecID)
channels_(1), // Default send mono. channels_(1), // Default send mono.
dec_channels_(1) { // Default receive mono. dec_channels_(1) { // Default receive mono.
// TODO(tlegrand): remove later when ACMGenericCodec has a new constructor. // TODO(tlegrand): remove later when ACMGenericCodec has a new constructor.
_codecID = codecID; codec_id_ = codec_id;
return; return;
} }
@ -128,52 +128,53 @@ ACMCELT::~ACMCELT() {
return; return;
} }
int16_t ACMCELT::InternalEncode(uint8_t* bitStream, int16_t* bitStreamLenByte) { int16_t ACMCELT::InternalEncode(uint8_t* bitstream,
*bitStreamLenByte = 0; int16_t* bitstream_len_byte) {
*bitstream_len_byte = 0;
// Call Encoder. // Call Encoder.
*bitStreamLenByte = WebRtcCelt_Encode(enc_inst_ptr_, *bitstream_len_byte = WebRtcCelt_Encode(enc_inst_ptr_,
&_inAudio[_inAudioIxRead], &in_audio_[in_audio_ix_read_],
bitStream); bitstream);
// Increment the read index this tell the caller that how far // Increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer. // we have gone forward in reading the audio buffer.
_inAudioIxRead += _frameLenSmpl * channels_; in_audio_ix_read_ += frame_len_smpl_ * channels_;
if (*bitStreamLenByte < 0) { if (*bitstream_len_byte < 0) {
// Error reported from the encoder. // Error reported from the encoder.
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalEncode: Encode error for Celt"); "InternalEncode: Encode error for Celt");
*bitStreamLenByte = 0; *bitstream_len_byte = 0;
return -1; return -1;
} }
return *bitStreamLenByte; return *bitstream_len_byte;
} }
int16_t ACMCELT::DecodeSafe(uint8_t* /* bitStream */, int16_t ACMCELT::DecodeSafe(uint8_t* /* bitstream */,
int16_t /* bitStreamLenByte */, int16_t /* bitstream_len_byte */,
int16_t* /* audio */, int16_t* /* audio */,
int16_t* /* audioSamples */, int16_t* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
int16_t ACMCELT::InternalInitEncoder(WebRtcACMCodecParams* codecParams) { int16_t ACMCELT::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
// Set bitrate and check that it is within the valid range. // Set bitrate and check that it is within the valid range.
int16_t status = SetBitRateSafe((codecParams->codecInstant).rate); int16_t status = SetBitRateSafe((codec_params->codec_inst).rate);
if (status < 0) { if (status < 0) {
return -1; return -1;
} }
// If number of channels changed we need to re-create memory. // If number of channels changed we need to re-create memory.
if (codecParams->codecInstant.channels != channels_) { if (codec_params->codec_inst.channels != channels_) {
WebRtcCelt_FreeEnc(enc_inst_ptr_); WebRtcCelt_FreeEnc(enc_inst_ptr_);
enc_inst_ptr_ = NULL; enc_inst_ptr_ = NULL;
// Store new number of channels. // Store new number of channels.
channels_ = codecParams->codecInstant.channels; channels_ = codec_params->codec_inst.channels;
if (WebRtcCelt_CreateEnc(&enc_inst_ptr_, channels_) < 0) { if (WebRtcCelt_CreateEnc(&enc_inst_ptr_, channels_) < 0) {
return -1; return -1;
} }
} }
@ -185,36 +186,36 @@ int16_t ACMCELT::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
} }
} }
int16_t ACMCELT::InternalInitDecoder(WebRtcACMCodecParams* codecParams) { int16_t ACMCELT::InternalInitDecoder(WebRtcACMCodecParams* codec_params) {
// If number of channels changed we need to re-create memory. // If number of channels changed we need to re-create memory.
if (codecParams->codecInstant.channels != dec_channels_) { if (codec_params->codec_inst.channels != dec_channels_) {
WebRtcCelt_FreeDec(dec_inst_ptr_); WebRtcCelt_FreeDec(dec_inst_ptr_);
dec_inst_ptr_ = NULL; dec_inst_ptr_ = NULL;
// Store new number of channels. // Store new number of channels.
dec_channels_ = codecParams->codecInstant.channels; dec_channels_ = codec_params->codec_inst.channels;
if (WebRtcCelt_CreateDec(&dec_inst_ptr_, dec_channels_) < 0) { if (WebRtcCelt_CreateDec(&dec_inst_ptr_, dec_channels_) < 0) {
return -1; return -1;
} }
} }
// Initiate decoder, both master and slave parts. // Initiate decoder, both master and slave parts.
if (WebRtcCelt_DecoderInit(dec_inst_ptr_) < 0) { if (WebRtcCelt_DecoderInit(dec_inst_ptr_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalInitDecoder: init decoder failed for Celt."); "InternalInitDecoder: init decoder failed for Celt.");
return -1; return -1;
} }
if (WebRtcCelt_DecoderInitSlave(dec_inst_ptr_) < 0) { if (WebRtcCelt_DecoderInitSlave(dec_inst_ptr_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalInitDecoder: init decoder failed for Celt."); "InternalInitDecoder: init decoder failed for Celt.");
return -1; return -1;
} }
return 0; return 0;
} }
int32_t ACMCELT::CodecDef(WebRtcNetEQ_CodecDef& codecDef, int32_t ACMCELT::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!_decoderInitialized) { if (!decoder_initialized_) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"CodecDef: Decoder uninitialized for Celt"); "CodecDef: Decoder uninitialized for Celt");
return -1; return -1;
} }
@ -223,20 +224,20 @@ int32_t ACMCELT::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
// "SET_CODEC_PAR" and "SET_CELT_FUNCTIONS" or "SET_CELTSLAVE_FUNCTIONS". // "SET_CODEC_PAR" and "SET_CELT_FUNCTIONS" or "SET_CELTSLAVE_FUNCTIONS".
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
if (codecInst.channels == 1) { if (codec_inst.channels == 1) {
SET_CODEC_PAR(codecDef, kDecoderCELT_32, codecInst.pltype, dec_inst_ptr_, SET_CODEC_PAR(codec_def, kDecoderCELT_32, codec_inst.pltype, dec_inst_ptr_,
32000); 32000);
} else { } else {
SET_CODEC_PAR(codecDef, kDecoderCELT_32_2ch, codecInst.pltype, SET_CODEC_PAR(codec_def, kDecoderCELT_32_2ch, codec_inst.pltype,
dec_inst_ptr_, 32000); dec_inst_ptr_, 32000);
} }
// If this is the master of NetEQ, regular decoder will be added, otherwise // If this is the master of NetEQ, regular decoder will be added, otherwise
// the slave decoder will be used. // the slave decoder will be used.
if (_isMaster) { if (is_master_) {
SET_CELT_FUNCTIONS(codecDef); SET_CELT_FUNCTIONS(codec_def);
} else { } else {
SET_CELTSLAVE_FUNCTIONS(codecDef); SET_CELTSLAVE_FUNCTIONS(codec_def);
} }
return 0; return 0;
} }
@ -246,18 +247,18 @@ ACMGenericCodec* ACMCELT::CreateInstance(void) {
} }
int16_t ACMCELT::InternalCreateEncoder() { int16_t ACMCELT::InternalCreateEncoder() {
if (WebRtcCelt_CreateEnc(&enc_inst_ptr_, _noChannels) < 0) { if (WebRtcCelt_CreateEnc(&enc_inst_ptr_, num_channels_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateEncoder: create encoder failed for Celt"); "InternalCreateEncoder: create encoder failed for Celt");
return -1; return -1;
} }
channels_ = _noChannels; channels_ = num_channels_;
return 0; return 0;
} }
void ACMCELT::DestructEncoderSafe() { void ACMCELT::DestructEncoderSafe() {
_encoderExist = false; encoder_exist_ = false;
_encoderInitialized = false; encoder_initialized_ = false;
if (enc_inst_ptr_ != NULL) { if (enc_inst_ptr_ != NULL) {
WebRtcCelt_FreeEnc(enc_inst_ptr_); WebRtcCelt_FreeEnc(enc_inst_ptr_);
enc_inst_ptr_ = NULL; enc_inst_ptr_ = NULL;
@ -266,7 +267,7 @@ void ACMCELT::DestructEncoderSafe() {
int16_t ACMCELT::InternalCreateDecoder() { int16_t ACMCELT::InternalCreateDecoder() {
if (WebRtcCelt_CreateDec(&dec_inst_ptr_, dec_channels_) < 0) { if (WebRtcCelt_CreateDec(&dec_inst_ptr_, dec_channels_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateDecoder: create decoder failed for Celt"); "InternalCreateDecoder: create decoder failed for Celt");
return -1; return -1;
} }
@ -275,17 +276,17 @@ int16_t ACMCELT::InternalCreateDecoder() {
} }
void ACMCELT::DestructDecoderSafe() { void ACMCELT::DestructDecoderSafe() {
_decoderExist = false; decoder_exist_ = false;
_decoderInitialized = false; decoder_initialized_ = false;
if (dec_inst_ptr_ != NULL) { if (dec_inst_ptr_ != NULL) {
WebRtcCelt_FreeDec(dec_inst_ptr_); WebRtcCelt_FreeDec(dec_inst_ptr_);
dec_inst_ptr_ = NULL; dec_inst_ptr_ = NULL;
} }
} }
void ACMCELT::InternalDestructEncoderInst(void* ptrInst) { void ACMCELT::InternalDestructEncoderInst(void* ptr_inst) {
if (ptrInst != NULL) { if (ptr_inst != NULL) {
WebRtcCelt_FreeEnc(static_cast<CELT_encinst_t*>(ptrInst)); WebRtcCelt_FreeEnc(static_cast<CELT_encinst_t*>(ptr_inst));
} }
return; return;
} }
@ -304,13 +305,13 @@ int16_t ACMCELT::SetBitRateSafe(const int32_t rate) {
if (WebRtcCelt_EncoderInit(enc_inst_ptr_, channels_, bitrate_) >= 0) { if (WebRtcCelt_EncoderInit(enc_inst_ptr_, channels_, bitrate_) >= 0) {
return 0; return 0;
} else { } else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetBitRateSafe: Failed to initiate Celt with rate %d", "SetBitRateSafe: Failed to initiate Celt with rate %d",
rate); rate);
return -1; return -1;
} }
} else { } else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetBitRateSafe: Invalid rate Celt, %d", rate); "SetBitRateSafe: Invalid rate Celt, %d", rate);
return -1; return -1;
} }

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CELT_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CELT_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CELT_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CELT_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
// forward declaration // forward declaration
struct CELT_encinst_t_; struct CELT_encinst_t_;
@ -21,29 +21,29 @@ namespace webrtc {
class ACMCELT : public ACMGenericCodec { class ACMCELT : public ACMGenericCodec {
public: public:
ACMCELT(int16_t codecID); explicit ACMCELT(int16_t codec_id);
~ACMCELT(); ~ACMCELT();
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
int16_t InternalEncode(uint8_t* bitstream, int16_t* bitStreamLenByte); int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte);
int16_t InternalInitEncoder(WebRtcACMCodecParams *codecParams); int16_t InternalInitEncoder(WebRtcACMCodecParams *codec_params);
int16_t InternalInitDecoder(WebRtcACMCodecParams *codecParams); int16_t InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(
uint8_t* /* bitStream */, uint8_t* /* bitstream */,
int16_t /* bitStreamLenByte */, int16_t /* bitstream_len_byte */,
int16_t* /* audio */, int16_t* /* audio */,
int16_t* /* audioSamples */, int16_t* /* audio_samples */,
// TODO(leozwang): use int8_t here when WebRtc_Word8 is properly typed. // TODO(leozwang): use int8_t here when WebRtc_Word8 is properly typed.
// http://code.google.com/p/webrtc/issues/detail?id=311 // http://code.google.com/p/webrtc/issues/detail?id=311
WebRtc_Word8* /* speechType */); WebRtc_Word8* /* speech_type */);
int32_t CodecDef(WebRtcNetEQ_CodecDef& codecDef, const CodecInst& codecInst); int32_t CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -53,7 +53,7 @@ class ACMCELT : public ACMGenericCodec {
int16_t InternalCreateDecoder(); int16_t InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
bool IsTrueStereoCodec(); bool IsTrueStereoCodec();
@ -69,6 +69,6 @@ class ACMCELT : public ACMGenericCodec {
uint16_t dec_channels_; uint16_t dec_channels_;
}; };
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CELT_H_ #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CELT_H_

View File

@ -8,33 +8,34 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_cng.h" #include "webrtc/modules/audio_coding/main/source/acm_cng.h"
#include "acm_codec_database.h"
#include "acm_common_defs.h" #include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "trace.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc_cng.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc { namespace webrtc {
ACMCNG::ACMCNG(WebRtc_Word16 codecID) { ACMCNG::ACMCNG(WebRtc_Word16 codec_id) {
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
_codecID = codecID; codec_id_ = codec_id;
_sampFreqHz = ACMCodecDB::CodecFreq(_codecID); samp_freq_hz_ = ACMCodecDB::CodecFreq(codec_id_);
return; return;
} }
ACMCNG::~ACMCNG() { ACMCNG::~ACMCNG() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcCng_FreeEnc(_encoderInstPtr); WebRtcCng_FreeEnc(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcCng_FreeDec(_decoderInstPtr); WebRtcCng_FreeDec(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
return; return;
} }
@ -43,16 +44,16 @@ ACMCNG::~ACMCNG() {
// should not be called normally // should not be called normally
// instead the following function is called from inside // instead the following function is called from inside
// ACMGenericCodec::ProcessFrameVADDTX // ACMGenericCodec::ProcessFrameVADDTX
WebRtc_Word16 ACMCNG::InternalEncode(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMCNG::InternalEncode(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_Word16* /* bitstream_len_byte */) {
return -1; return -1;
} }
WebRtc_Word16 ACMCNG::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMCNG::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
@ -61,19 +62,19 @@ WebRtc_Word16 ACMCNG::DecodeSafe(WebRtc_UWord8* /* bitStream */,
// instead the following function is called from inside // instead the following function is called from inside
// ACMGenericCodec::ProcessFrameVADDTX // ACMGenericCodec::ProcessFrameVADDTX
WebRtc_Word16 ACMCNG::InternalInitEncoder( WebRtc_Word16 ACMCNG::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word16 ACMCNG::InternalInitDecoder( WebRtc_Word16 ACMCNG::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return WebRtcCng_InitDec(_decoderInstPtr); return WebRtcCng_InitDec(decoder_inst_ptr_);
} }
WebRtc_Word32 ACMCNG::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMCNG::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!_decoderInitialized) { if (!decoder_initialized_) {
// TODO (tlegrand): log error // TODO(tlegrand): log error
return -1; return -1;
} }
// Fill up the structure by calling // Fill up the structure by calling
@ -81,11 +82,11 @@ WebRtc_Word32 ACMCNG::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
// Then return the structure back to NetEQ to add the codec to it's // Then return the structure back to NetEQ to add the codec to it's
// database. // database.
if (_sampFreqHz == 8000 || _sampFreqHz == 16000 || _sampFreqHz == 32000 || if (samp_freq_hz_ == 8000 || samp_freq_hz_ == 16000 ||
_sampFreqHz == 48000) { samp_freq_hz_ == 32000 || samp_freq_hz_ == 48000) {
SET_CODEC_PAR((codecDef), kDecoderCNG, codecInst.pltype, SET_CODEC_PAR((codec_def), kDecoderCNG, codec_inst.pltype,
_decoderInstPtr, _sampFreqHz); decoder_inst_ptr_, samp_freq_hz_);
SET_CNG_FUNCTIONS((codecDef)); SET_CNG_FUNCTIONS((codec_def));
return 0; return 0;
} else { } else {
return -1; return -1;
@ -97,8 +98,8 @@ ACMGenericCodec* ACMCNG::CreateInstance(void) {
} }
WebRtc_Word16 ACMCNG::InternalCreateEncoder() { WebRtc_Word16 ACMCNG::InternalCreateEncoder() {
if (WebRtcCng_CreateEnc(&_encoderInstPtr) < 0) { if (WebRtcCng_CreateEnc(&encoder_inst_ptr_) < 0) {
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
return -1; return -1;
} else { } else {
return 0; return 0;
@ -106,17 +107,17 @@ WebRtc_Word16 ACMCNG::InternalCreateEncoder() {
} }
void ACMCNG::DestructEncoderSafe() { void ACMCNG::DestructEncoderSafe() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcCng_FreeEnc(_encoderInstPtr); WebRtcCng_FreeEnc(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
_encoderExist = false; encoder_exist_ = false;
_encoderInitialized = false; encoder_initialized_ = false;
} }
WebRtc_Word16 ACMCNG::InternalCreateDecoder() { WebRtc_Word16 ACMCNG::InternalCreateDecoder() {
if (WebRtcCng_CreateDec(&_decoderInstPtr) < 0) { if (WebRtcCng_CreateDec(&decoder_inst_ptr_) < 0) {
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
return -1; return -1;
} else { } else {
return 0; return 0;
@ -124,19 +125,19 @@ WebRtc_Word16 ACMCNG::InternalCreateDecoder() {
} }
void ACMCNG::DestructDecoderSafe() { void ACMCNG::DestructDecoderSafe() {
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcCng_FreeDec(_decoderInstPtr); WebRtcCng_FreeDec(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
_decoderExist = false; decoder_exist_ = false;
_decoderInitialized = false; decoder_initialized_ = false;
} }
void ACMCNG::InternalDestructEncoderInst(void* ptrInst) { void ACMCNG::InternalDestructEncoderInst(void* ptr_inst) {
if (ptrInst != NULL) { if (ptr_inst != NULL) {
WebRtcCng_FreeEnc(static_cast<CNG_enc_inst*>(ptrInst)); WebRtcCng_FreeEnc(static_cast<CNG_enc_inst*>(ptr_inst));
} }
return; return;
} }
} // namespace webrtc } // namespace webrtc

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
// forward declaration // forward declaration
struct WebRtcCngEncInst; struct WebRtcCngEncInst;
@ -21,26 +21,27 @@ namespace webrtc {
class ACMCNG: public ACMGenericCodec { class ACMCNG: public ACMGenericCodec {
public: public:
ACMCNG(WebRtc_Word16 codecID); explicit ACMCNG(WebRtc_Word16 codec_id);
~ACMCNG(); ~ACMCNG();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audioSamples, WebRtc_Word16* audio, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -50,7 +51,7 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
WebRtc_Word16 EnableDTX() { WebRtc_Word16 EnableDTX() {
return -1; return -1;
@ -60,11 +61,11 @@ protected:
return -1; return -1;
} }
WebRtcCngEncInst* _encoderInstPtr; WebRtcCngEncInst* encoder_inst_ptr_;
WebRtcCngDecInst* _decoderInstPtr; WebRtcCngDecInst* decoder_inst_ptr_;
WebRtc_UWord16 _sampFreqHz; WebRtc_UWord16 samp_freq_hz_;
}; };
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_ #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_

View File

@ -15,90 +15,90 @@
// TODO(tlegrand): Change constant input pointers in all functions to constant // TODO(tlegrand): Change constant input pointers in all functions to constant
// references, where appropriate. // references, where appropriate.
#include "acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include <stdio.h> #include <stdio.h>
#include "acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "trace.h" #include "webrtc/system_wrappers/interface/trace.h"
// Includes needed to create the codecs. // Includes needed to create the codecs.
// G.711, PCM mu-law and A-law. // G.711, PCM mu-law and A-law.
#include "acm_pcma.h" #include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h"
#include "acm_pcmu.h" #include "webrtc/modules/audio_coding/main/source/acm_pcma.h"
#include "g711_interface.h" #include "webrtc/modules/audio_coding/main/source/acm_pcmu.h"
// CNG. // CNG.
#include "acm_cng.h" #include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h"
#include "webrtc_cng.h" #include "webrtc/modules/audio_coding/main/source/acm_cng.h"
// NetEQ. // NetEQ.
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#ifdef WEBRTC_CODEC_ISAC #ifdef WEBRTC_CODEC_ISAC
#include "acm_isac.h" #include "webrtc/modules/audio_coding/codecs/isac/main/interface/isac.h"
#include "acm_isac_macros.h" #include "webrtc/modules/audio_coding/main/source/acm_isac.h"
#include "isac.h" #include "webrtc/modules/audio_coding/main/source/acm_isac_macros.h"
#endif #endif
#ifdef WEBRTC_CODEC_ISACFX #ifdef WEBRTC_CODEC_ISACFX
#include "acm_isac.h" #include "webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h"
#include "acm_isac_macros.h" #include "webrtc/modules/audio_coding/main/source/acm_isac.h"
#include "isacfix.h" #include "webrtc/modules/audio_coding/main/source/acm_isac_macros.h"
#endif #endif
#ifdef WEBRTC_CODEC_PCM16 #ifdef WEBRTC_CODEC_PCM16
#include "pcm16b.h" #include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h"
#include "acm_pcm16b.h" #include "webrtc/modules/audio_coding/main/source/acm_pcm16b.h"
#endif #endif
#ifdef WEBRTC_CODEC_ILBC #ifdef WEBRTC_CODEC_ILBC
#include "acm_ilbc.h" #include "webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h"
#include "ilbc.h" #include "webrtc/modules/audio_coding/main/source/acm_ilbc.h"
#endif #endif
#ifdef WEBRTC_CODEC_AMR #ifdef WEBRTC_CODEC_AMR
#include "acm_amr.h" #include "amr_interface.h"
#include "amr_interface.h" #include "webrtc/modules/audio_coding/main/source/acm_amr.h"
#endif #endif
#ifdef WEBRTC_CODEC_AMRWB #ifdef WEBRTC_CODEC_AMRWB
#include "acm_amrwb.h" #include "amrwb_interface.h"
#include "amrwb_interface.h" #include "webrtc/modules/audio_coding/main/source/acm_amrwb.h"
#endif #endif
#ifdef WEBRTC_CODEC_CELT #ifdef WEBRTC_CODEC_CELT
#include "acm_celt.h" #include "celt_interface.h"
#include "celt_interface.h" #include "webrtc/modules/audio_coding/main/source/acm_celt.h"
#endif #endif
#ifdef WEBRTC_CODEC_G722 #ifdef WEBRTC_CODEC_G722
#include "acm_g722.h" #include "webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h"
#include "g722_interface.h" #include "webrtc/modules/audio_coding/main/source/acm_g722.h"
#endif #endif
#ifdef WEBRTC_CODEC_G722_1 #ifdef WEBRTC_CODEC_G722_1
#include "acm_g7221.h" #include "g7221_interface.h"
#include "g7221_interface.h" #include "webrtc/modules/audio_coding/main/source/acm_g7221.h"
#endif #endif
#ifdef WEBRTC_CODEC_G722_1C #ifdef WEBRTC_CODEC_G722_1C
#include "acm_g7221c.h" #include "g7221c_interface.h"
#include "g7221c_interface.h" #include "webrtc/modules/audio_coding/main/source/acm_g7221c.h"
#endif #endif
#ifdef WEBRTC_CODEC_G729 #ifdef WEBRTC_CODEC_G729
#include "acm_g729.h" #include "g729_interface.h"
#include "g729_interface.h" #include "webrtc/modules/audio_coding/main/source/acm_g729.h"
#endif #endif
#ifdef WEBRTC_CODEC_G729_1 #ifdef WEBRTC_CODEC_G729_1
#include "acm_g7291.h" #include "g7291_interface.h"
#include "g7291_interface.h" #include "webrtc/modules/audio_coding/main/source/acm_g7291.h"
#endif #endif
#ifdef WEBRTC_CODEC_GSMFR #ifdef WEBRTC_CODEC_GSMFR
#include "acm_gsmfr.h" #include "gsmfr_interface.h"
#include "gsmfr_interface.h" #include "webrtc/modules/audio_coding/main/source/acm_gsmfr.h"
#endif #endif
#ifdef WEBRTC_CODEC_OPUS #ifdef WEBRTC_CODEC_OPUS
#include "acm_opus.h" #include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h"
#include "modules/audio_coding/codecs/opus/interface/opus_interface.h" #include "webrtc/modules/audio_coding/main/source/acm_opus.h"
#endif #endif
#ifdef WEBRTC_CODEC_SPEEX #ifdef WEBRTC_CODEC_SPEEX
#include "acm_speex.h" #include "speex_interface.h"
#include "speex_interface.h" #include "webrtc/modules/audio_coding/main/source/acm_speex.h"
#endif #endif
#ifdef WEBRTC_CODEC_AVT #ifdef WEBRTC_CODEC_AVT
#include "acm_dtmf_playout.h" #include "webrtc/modules/audio_coding/main/source/acm_dtmf_playout.h"
#endif #endif
#ifdef WEBRTC_CODEC_RED #ifdef WEBRTC_CODEC_RED
#include "acm_red.h" #include "webrtc/modules/audio_coding/main/source/acm_red.h"
#endif #endif
namespace webrtc { namespace webrtc {
@ -108,19 +108,19 @@ namespace webrtc {
// are defined they will receive reserved fixed payload types (values 69-95). // are defined they will receive reserved fixed payload types (values 69-95).
const int kDynamicPayloadtypes[ACMCodecDB::kMaxNumCodecs] = { const int kDynamicPayloadtypes[ACMCodecDB::kMaxNumCodecs] = {
107, 108, 109, 111, 112, 113, 114, 115, 116, 117, 92, 107, 108, 109, 111, 112, 113, 114, 115, 116, 117, 92,
91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80,
79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68,
67, 66, 65 67, 66, 65
}; };
// Creates database with all supported codecs at compile time. // Creates database with all supported codecs at compile time.
// Each entry needs the following parameters in the given order: // Each entry needs the following parameters in the given order:
// payload type, name, sampling frequency, packet size in samples, // payload type, name, sampling frequency, packet size in samples,
// number of channels, and default rate. // number of channels, and default rate.
#if (defined(WEBRTC_CODEC_AMR) || defined(WEBRTC_CODEC_AMRWB) \ #if (defined(WEBRTC_CODEC_AMR) || defined(WEBRTC_CODEC_AMRWB) || \
|| defined(WEBRTC_CODEC_CELT) || defined(WEBRTC_CODEC_G722_1) \ defined(WEBRTC_CODEC_CELT) || defined(WEBRTC_CODEC_G722_1) || \
|| defined(WEBRTC_CODEC_G722_1C) || defined(WEBRTC_CODEC_G729_1) \ defined(WEBRTC_CODEC_G722_1C) || defined(WEBRTC_CODEC_G729_1) || \
|| defined(WEBRTC_CODEC_PCM16) || defined(WEBRTC_CODEC_SPEEX)) defined(WEBRTC_CODEC_PCM16) || defined(WEBRTC_CODEC_SPEEX))
static int count_database = 0; static int count_database = 0;
#endif #endif
@ -219,180 +219,180 @@ const CodecInst ACMCodecDB::database_[] = {
// Basic block samples, max number of channels that are supported. // Basic block samples, max number of channels that are supported.
const ACMCodecDB::CodecSettings ACMCodecDB::codec_settings_[] = { const ACMCodecDB::CodecSettings ACMCodecDB::codec_settings_[] = {
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
{2, {kIsacPacSize480, kIsacPacSize960}, 0, 1}, {2, {kIsacPacSize480, kIsacPacSize960}, 0, 1},
# if (defined(WEBRTC_CODEC_ISAC)) # if (defined(WEBRTC_CODEC_ISAC))
{1, {kIsacPacSize960}, 0, 1}, {1, {kIsacPacSize960}, 0, 1},
{1, {kIsacPacSize1440}, 0, 1}, {1, {kIsacPacSize1440}, 0, 1},
# endif # endif
#endif #endif
#ifdef WEBRTC_CODEC_PCM16 #ifdef WEBRTC_CODEC_PCM16
// Mono // Mono
{4, {80, 160, 240, 320}, 0, 2}, {4, {80, 160, 240, 320}, 0, 2},
{4, {160, 320, 480, 640}, 0, 2}, {4, {160, 320, 480, 640}, 0, 2},
{2, {320, 640}, 0, 2}, {2, {320, 640}, 0, 2},
// Stereo // Stereo
{4, {80, 160, 240, 320}, 0, 2}, {4, {80, 160, 240, 320}, 0, 2},
{4, {160, 320, 480, 640}, 0, 2}, {4, {160, 320, 480, 640}, 0, 2},
{2, {320, 640}, 0, 2}, {2, {320, 640}, 0, 2},
#endif #endif
// G.711, PCM mu-law and A-law. // G.711, PCM mu-law and A-law.
// Mono // Mono
{6, {80, 160, 240, 320, 400, 480}, 0, 2}, {6, {80, 160, 240, 320, 400, 480}, 0, 2},
{6, {80, 160, 240, 320, 400, 480}, 0, 2}, {6, {80, 160, 240, 320, 400, 480}, 0, 2},
// Stereo // Stereo
{6, {80, 160, 240, 320, 400, 480}, 0, 2}, {6, {80, 160, 240, 320, 400, 480}, 0, 2},
{6, {80, 160, 240, 320, 400, 480}, 0, 2}, {6, {80, 160, 240, 320, 400, 480}, 0, 2},
#ifdef WEBRTC_CODEC_ILBC #ifdef WEBRTC_CODEC_ILBC
{4, {160, 240, 320, 480}, 0, 1}, {4, {160, 240, 320, 480}, 0, 1},
#endif #endif
#ifdef WEBRTC_CODEC_AMR #ifdef WEBRTC_CODEC_AMR
{3, {160, 320, 480}, 0, 1}, {3, {160, 320, 480}, 0, 1},
#endif #endif
#ifdef WEBRTC_CODEC_AMRWB #ifdef WEBRTC_CODEC_AMRWB
{3, {320, 640, 960}, 0, 1}, {3, {320, 640, 960}, 0, 1},
#endif #endif
#ifdef WEBRTC_CODEC_CELT #ifdef WEBRTC_CODEC_CELT
// Mono // Mono
{1, {640}, 0, 2}, {1, {640}, 0, 2},
// Stereo // Stereo
{1, {640}, 0, 2}, {1, {640}, 0, 2},
#endif #endif
#ifdef WEBRTC_CODEC_G722 #ifdef WEBRTC_CODEC_G722
// Mono // Mono
{6, {160, 320, 480, 640, 800, 960}, 0, 2}, {6, {160, 320, 480, 640, 800, 960}, 0, 2},
// Stereo // Stereo
{6, {160, 320, 480, 640, 800, 960}, 0, 2}, {6, {160, 320, 480, 640, 800, 960}, 0, 2},
#endif #endif
#ifdef WEBRTC_CODEC_G722_1 #ifdef WEBRTC_CODEC_G722_1
{1, {320}, 320, 1}, {1, {320}, 320, 1},
{1, {320}, 320, 1}, {1, {320}, 320, 1},
{1, {320}, 320, 1}, {1, {320}, 320, 1},
#endif #endif
#ifdef WEBRTC_CODEC_G722_1C #ifdef WEBRTC_CODEC_G722_1C
{1, {640}, 640, 1}, {1, {640}, 640, 1},
{1, {640}, 640, 1}, {1, {640}, 640, 1},
{1, {640}, 640, 1}, {1, {640}, 640, 1},
#endif #endif
#ifdef WEBRTC_CODEC_G729 #ifdef WEBRTC_CODEC_G729
{6, {80, 160, 240, 320, 400, 480}, 0, 1}, {6, {80, 160, 240, 320, 400, 480}, 0, 1},
#endif #endif
#ifdef WEBRTC_CODEC_G729_1 #ifdef WEBRTC_CODEC_G729_1
{3, {320, 640, 960}, 0, 1}, {3, {320, 640, 960}, 0, 1},
#endif #endif
#ifdef WEBRTC_CODEC_GSMFR #ifdef WEBRTC_CODEC_GSMFR
{3, {160, 320, 480}, 160, 1}, {3, {160, 320, 480}, 160, 1},
#endif #endif
#ifdef WEBRTC_CODEC_OPUS #ifdef WEBRTC_CODEC_OPUS
// Opus supports frames shorter than 10ms, // Opus supports frames shorter than 10ms,
// but it doesn't help us to use them. // but it doesn't help us to use them.
// Mono and stereo. // Mono and stereo.
{1, {960}, 0, 2}, {1, {960}, 0, 2},
#endif #endif
#ifdef WEBRTC_CODEC_SPEEX #ifdef WEBRTC_CODEC_SPEEX
{3, {160, 320, 480}, 0, 1}, {3, {160, 320, 480}, 0, 1},
{3, {320, 640, 960}, 0, 1}, {3, {320, 640, 960}, 0, 1},
#endif #endif
// Comfort noise for three different sampling frequencies. // Comfort noise for three different sampling frequencies.
{1, {240}, 240, 1}, {1, {240}, 240, 1},
{1, {480}, 480, 1}, {1, {480}, 480, 1},
{1, {960}, 960, 1}, {1, {960}, 960, 1},
{1, {1440}, 1440, 1}, {1, {1440}, 1440, 1},
#ifdef WEBRTC_CODEC_AVT #ifdef WEBRTC_CODEC_AVT
{1, {240}, 240, 1}, {1, {240}, 240, 1},
#endif #endif
#ifdef WEBRTC_CODEC_RED #ifdef WEBRTC_CODEC_RED
{1, {0}, 0, 1}, {1, {0}, 0, 1},
#endif #endif
// To prevent compile errors due to trailing commas. // To prevent compile errors due to trailing commas.
{-1, {-1}, -1, -1} {-1, {-1}, -1, -1}
}; };
// Create a database of all NetEQ decoders at compile time. // Create a database of all NetEQ decoders at compile time.
const WebRtcNetEQDecoder ACMCodecDB::neteq_decoders_[] = { const WebRtcNetEQDecoder ACMCodecDB::neteq_decoders_[] = {
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
kDecoderISAC, kDecoderISAC,
# if (defined(WEBRTC_CODEC_ISAC)) # if (defined(WEBRTC_CODEC_ISAC))
kDecoderISACswb, kDecoderISACswb,
kDecoderISACfb, kDecoderISACfb,
# endif # endif
#endif #endif
#ifdef WEBRTC_CODEC_PCM16 #ifdef WEBRTC_CODEC_PCM16
// Mono // Mono
kDecoderPCM16B, kDecoderPCM16B,
kDecoderPCM16Bwb, kDecoderPCM16Bwb,
kDecoderPCM16Bswb32kHz, kDecoderPCM16Bswb32kHz,
// Stereo // Stereo
kDecoderPCM16B_2ch, kDecoderPCM16B_2ch,
kDecoderPCM16Bwb_2ch, kDecoderPCM16Bwb_2ch,
kDecoderPCM16Bswb32kHz_2ch, kDecoderPCM16Bswb32kHz_2ch,
#endif #endif
// G.711, PCM mu-las and A-law. // G.711, PCM mu-las and A-law.
// Mono // Mono
kDecoderPCMu, kDecoderPCMu,
kDecoderPCMa, kDecoderPCMa,
// Stereo // Stereo
kDecoderPCMu_2ch, kDecoderPCMu_2ch,
kDecoderPCMa_2ch, kDecoderPCMa_2ch,
#ifdef WEBRTC_CODEC_ILBC #ifdef WEBRTC_CODEC_ILBC
kDecoderILBC, kDecoderILBC,
#endif #endif
#ifdef WEBRTC_CODEC_AMR #ifdef WEBRTC_CODEC_AMR
kDecoderAMR, kDecoderAMR,
#endif #endif
#ifdef WEBRTC_CODEC_AMRWB #ifdef WEBRTC_CODEC_AMRWB
kDecoderAMRWB, kDecoderAMRWB,
#endif #endif
#ifdef WEBRTC_CODEC_CELT #ifdef WEBRTC_CODEC_CELT
// Mono // Mono
kDecoderCELT_32, kDecoderCELT_32,
// Stereo // Stereo
kDecoderCELT_32_2ch, kDecoderCELT_32_2ch,
#endif #endif
#ifdef WEBRTC_CODEC_G722 #ifdef WEBRTC_CODEC_G722
// Mono // Mono
kDecoderG722, kDecoderG722,
// Stereo // Stereo
kDecoderG722_2ch, kDecoderG722_2ch,
#endif #endif
#ifdef WEBRTC_CODEC_G722_1 #ifdef WEBRTC_CODEC_G722_1
kDecoderG722_1_32, kDecoderG722_1_32,
kDecoderG722_1_24, kDecoderG722_1_24,
kDecoderG722_1_16, kDecoderG722_1_16,
#endif #endif
#ifdef WEBRTC_CODEC_G722_1C #ifdef WEBRTC_CODEC_G722_1C
kDecoderG722_1C_48, kDecoderG722_1C_48,
kDecoderG722_1C_32, kDecoderG722_1C_32,
kDecoderG722_1C_24, kDecoderG722_1C_24,
#endif #endif
#ifdef WEBRTC_CODEC_G729 #ifdef WEBRTC_CODEC_G729
kDecoderG729, kDecoderG729,
#endif #endif
#ifdef WEBRTC_CODEC_G729_1 #ifdef WEBRTC_CODEC_G729_1
kDecoderG729_1, kDecoderG729_1,
#endif #endif
#ifdef WEBRTC_CODEC_GSMFR #ifdef WEBRTC_CODEC_GSMFR
kDecoderGSMFR, kDecoderGSMFR,
#endif #endif
#ifdef WEBRTC_CODEC_OPUS #ifdef WEBRTC_CODEC_OPUS
// Mono and stereo. // Mono and stereo.
kDecoderOpus, kDecoderOpus,
#endif #endif
#ifdef WEBRTC_CODEC_SPEEX #ifdef WEBRTC_CODEC_SPEEX
kDecoderSPEEX_8, kDecoderSPEEX_8,
kDecoderSPEEX_16, kDecoderSPEEX_16,
#endif #endif
// Comfort noise for three different sampling frequencies. // Comfort noise for three different sampling frequencies.
kDecoderCNG, kDecoderCNG,
kDecoderCNG, kDecoderCNG,
kDecoderCNG, kDecoderCNG,
kDecoderCNG, kDecoderCNG,
#ifdef WEBRTC_CODEC_AVT #ifdef WEBRTC_CODEC_AVT
kDecoderAVT, kDecoderAVT,
#endif #endif
#ifdef WEBRTC_CODEC_RED #ifdef WEBRTC_CODEC_RED
kDecoderRED, kDecoderRED,
#endif #endif
kDecoderReservedEnd kDecoderReservedEnd
}; };
// Get codec information from database. // Get codec information from database.
@ -587,7 +587,7 @@ int ACMCodecDB::CodecId(const char* payload_name, int frequency, int channels) {
} }
// Gets codec id number, and mirror id, from database for the receiver. // Gets codec id number, and mirror id, from database for the receiver.
int ACMCodecDB::ReceiverCodecNumber(const CodecInst* codec_inst, int ACMCodecDB::ReceiverCodecNumber(const CodecInst* codec_inst,
int* mirror_id) { int* mirror_id) {
// Look for a matching codec in the database. // Look for a matching codec in the database.
int codec_id = CodecId(codec_inst); int codec_id = CodecId(codec_inst);
@ -618,7 +618,7 @@ int ACMCodecDB::CodecFreq(int codec_id) {
int ACMCodecDB::BasicCodingBlock(int codec_id) { int ACMCodecDB::BasicCodingBlock(int codec_id) {
// Error check to see that codec_id is not out of bounds. // Error check to see that codec_id is not out of bounds.
if (codec_id < 0 || codec_id >= kNumCodecs) { if (codec_id < 0 || codec_id >= kNumCodecs) {
return -1; return -1;
} }
return codec_settings_[codec_id].basic_block_samples; return codec_settings_[codec_id].basic_block_samples;

View File

@ -16,9 +16,9 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CODEC_DATABASE_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CODEC_DATABASE_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CODEC_DATABASE_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CODEC_DATABASE_H_
#include "acm_generic_codec.h" #include "webrtc/common_types.h"
#include "common_types.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
namespace webrtc { namespace webrtc {

View File

@ -13,10 +13,10 @@
#include <string.h> #include <string.h>
#include "audio_coding_module_typedefs.h" #include "webrtc/common_types.h"
#include "common_types.h" #include "webrtc/engine_configurations.h"
#include "engine_configurations.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "typedefs.h" #include "webrtc/typedefs.h"
// Checks for enabled codecs, we prevent enabling codecs which are not // Checks for enabled codecs, we prevent enabling codecs which are not
// compatible. // compatible.
@ -26,10 +26,10 @@
#ifdef WIN32 #ifdef WIN32
// OS-dependent case-insensitive string comparison // OS-dependent case-insensitive string comparison
#define STR_CASE_CMP(x,y) ::_stricmp(x,y) #define STR_CASE_CMP(x, y) ::_stricmp(x, y)
#else #else
// OS-dependent case-insensitive string comparison // OS-dependent case-insensitive string comparison
#define STR_CASE_CMP(x,y) ::strcasecmp(x,y) #define STR_CASE_CMP(x, y) ::strcasecmp(x, y)
#endif #endif
namespace webrtc { namespace webrtc {
@ -78,40 +78,40 @@ enum WebRtcACMEncodingType {
// A structure which contains codec parameters. For instance, used when // A structure which contains codec parameters. For instance, used when
// initializing encoder and decoder. // initializing encoder and decoder.
// //
// codecInstant : c.f. common_types.h // codec_inst: c.f. common_types.h
// enableDTX : set true to enable DTX. If codec does not have // enable_dtx: set true to enable DTX. If codec does not have
// internal DTX, this will enable VAD. // internal DTX, this will enable VAD.
// enableVAD : set true to enable VAD. // enable_vad: set true to enable VAD.
// vadMode : VAD mode, c.f. audio_coding_module_typedefs.h // vad_mode: VAD mode, c.f. audio_coding_module_typedefs.h
// for possible values. // for possible values.
struct WebRtcACMCodecParams { struct WebRtcACMCodecParams {
CodecInst codecInstant; CodecInst codec_inst;
bool enableDTX; bool enable_dtx;
bool enableVAD; bool enable_vad;
ACMVADMode vadMode; ACMVADMode vad_mode;
}; };
// A structure that encapsulates audio buffer and related parameters // A structure that encapsulates audio buffer and related parameters
// used for synchronization of audio of two ACMs. // used for synchronization of audio of two ACMs.
// //
// inAudio : same as ACMGenericCodec::_inAudio // in_audio: same as ACMGenericCodec::in_audio_
// inAudioIxRead : same as ACMGenericCodec::_inAudioIxRead // in_audio_ix_read: same as ACMGenericCodec::in_audio_ix_read_
// inAudioIxWrite : same as ACMGenericCodec::_inAudioIxWrite // in_audio_ix_write: same as ACMGenericCodec::in_audio_ix_write_
// inTimestamp : same as ACMGenericCodec::_inTimestamp // in_timestamp: same as ACMGenericCodec::in_timestamp_
// inTimestampIxWrite : same as ACMGenericCodec::_inTImestampIxWrite // in_timestamp_ix_write: same as ACMGenericCodec::in_timestamp_ix_write_
// lastTimestamp : same as ACMGenericCodec::_lastTimestamp // last_timestamp: same as ACMGenericCodec::last_timestamp_
// lastInTimestamp : same as AudioCodingModuleImpl::_lastInTimestamp // last_in_timestamp: same as AudioCodingModuleImpl::last_in_timestamp_
// //
struct WebRtcACMAudioBuff { struct WebRtcACMAudioBuff {
WebRtc_Word16 inAudio[AUDIO_BUFFER_SIZE_W16]; WebRtc_Word16 in_audio[AUDIO_BUFFER_SIZE_W16];
WebRtc_Word16 inAudioIxRead; WebRtc_Word16 in_audio_ix_read;
WebRtc_Word16 inAudioIxWrite; WebRtc_Word16 in_audio_ix_write;
WebRtc_UWord32 inTimestamp[TIMESTAMP_BUFFER_SIZE_W32]; WebRtc_UWord32 in_timestamp[TIMESTAMP_BUFFER_SIZE_W32];
WebRtc_Word16 inTimestampIxWrite; WebRtc_Word16 in_timestamp_ix_write;
WebRtc_UWord32 lastTimestamp; WebRtc_UWord32 last_timestamp;
WebRtc_UWord32 lastInTimestamp; WebRtc_UWord32 last_in_timestamp;
}; };
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_ #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_

View File

@ -8,8 +8,9 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_dtmf_detection.h" #include "webrtc/modules/audio_coding/main/source/acm_dtmf_detection.h"
#include "audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
namespace webrtc { namespace webrtc {
@ -26,12 +27,12 @@ WebRtc_Word16 ACMDTMFDetection::Disable() {
} }
WebRtc_Word16 ACMDTMFDetection::Detect( WebRtc_Word16 ACMDTMFDetection::Detect(
const WebRtc_Word16* /* inAudioBuff */, const WebRtc_Word16* /* in_audio_buff */,
const WebRtc_UWord16 /* inBuffLenWord16 */, const WebRtc_UWord16 /* in_buff_len_word16 */,
const WebRtc_Word32 /* inFreqHz */, const WebRtc_Word32 /* in_freq_hz */,
bool& /* toneDetected */, bool& /* tone_detected */,
WebRtc_Word16& /* tone */) { WebRtc_Word16& /* tone */) {
return -1; return -1;
} }
} // namespace webrtc } // namespace webrtc

View File

@ -11,9 +11,9 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_
#include "acm_resampler.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "audio_coding_module_typedefs.h" #include "webrtc/modules/audio_coding/main/source/acm_resampler.h"
#include "typedefs.h" #include "webrtc/typedefs.h"
namespace webrtc { namespace webrtc {
@ -23,14 +23,14 @@ class ACMDTMFDetection {
~ACMDTMFDetection(); ~ACMDTMFDetection();
WebRtc_Word16 Enable(ACMCountries cpt = ACMDisableCountryDetection); WebRtc_Word16 Enable(ACMCountries cpt = ACMDisableCountryDetection);
WebRtc_Word16 Disable(); WebRtc_Word16 Disable();
WebRtc_Word16 Detect(const WebRtc_Word16* inAudioBuff, WebRtc_Word16 Detect(const WebRtc_Word16* in_audio_buff,
const WebRtc_UWord16 inBuffLenWord16, const WebRtc_UWord16 in_buff_len_word16,
const WebRtc_Word32 inFreqHz, const WebRtc_Word32 in_freq_hz,
bool& toneDetected, bool& tone_detected,
WebRtc_Word16& tone); WebRtc_Word16& tone);
private: private:
ACMResampler _resampler; ACMResampler resampler_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -8,19 +8,20 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_dtmf_playout.h" #include "webrtc/modules/audio_coding/main/source/acm_dtmf_playout.h"
#include "acm_common_defs.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "trace.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_AVT #ifndef WEBRTC_CODEC_AVT
ACMDTMFPlayout::ACMDTMFPlayout( ACMDTMFPlayout::ACMDTMFPlayout(
WebRtc_Word16 /* codecID */) { WebRtc_Word16 /* codec_id */) {
return; return;
} }
@ -29,31 +30,32 @@ ACMDTMFPlayout::~ACMDTMFPlayout() {
} }
WebRtc_Word16 ACMDTMFPlayout::InternalEncode( WebRtc_Word16 ACMDTMFPlayout::InternalEncode(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_Word16* /* bitstream_len_byte */) {
return -1; return -1;
} }
WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* audio */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio */,
WebRtc_Word8* /* speechType */) { WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speech_type */) {
return -1; return -1;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalInitEncoder( WebRtc_Word16 ACMDTMFPlayout::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalInitDecoder( WebRtc_Word16 ACMDTMFPlayout::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word32 ACMDTMFPlayout::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, WebRtc_Word32 ACMDTMFPlayout::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -69,7 +71,7 @@ WebRtc_Word16 ACMDTMFPlayout::InternalCreateDecoder() {
return -1; return -1;
} }
void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
@ -83,8 +85,8 @@ void ACMDTMFPlayout::DestructDecoderSafe() {
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMDTMFPlayout::ACMDTMFPlayout(WebRtc_Word16 codecID) { ACMDTMFPlayout::ACMDTMFPlayout(WebRtc_Word16 codec_id) {
_codecID = codecID; codec_id_ = codec_id;
} }
ACMDTMFPlayout::~ACMDTMFPlayout() { ACMDTMFPlayout::~ACMDTMFPlayout() {
@ -92,41 +94,42 @@ ACMDTMFPlayout::~ACMDTMFPlayout() {
} }
WebRtc_Word16 ACMDTMFPlayout::InternalEncode( WebRtc_Word16 ACMDTMFPlayout::InternalEncode(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_Word16* /* bitstream_len_byte */) {
return 0; return 0;
} }
WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* audio */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio */,
WebRtc_Word8* /* speechType */) { WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalInitEncoder( WebRtc_Word16 ACMDTMFPlayout::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
// This codec does not need initialization, // This codec does not need initialization,
// DTMFPlayout has no instance // DTMFPlayout has no instance
return 0; return 0;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalInitDecoder( WebRtc_Word16 ACMDTMFPlayout::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
// This codec does not need initialization, // This codec does not need initialization,
// DTMFPlayout has no instance // DTMFPlayout has no instance
return 0; return 0;
} }
WebRtc_Word32 ACMDTMFPlayout::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMDTMFPlayout::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
// Fill up the structure by calling // Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_AVT_FUNCTION." // "SET_CODEC_PAR" & "SET_AVT_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
SET_CODEC_PAR((codecDef), kDecoderAVT, codecInst.pltype, NULL, 8000); SET_CODEC_PAR((codec_def), kDecoderAVT, codec_inst.pltype, NULL, 8000);
SET_AVT_FUNCTIONS((codecDef)); SET_AVT_FUNCTIONS((codec_def));
return 0; return 0;
} }
@ -144,7 +147,7 @@ WebRtc_Word16 ACMDTMFPlayout::InternalCreateDecoder() {
return 0; return 0;
} }
void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptr_inst */) {
// DTMFPlayout has no instance // DTMFPlayout has no instance
return; return;
} }
@ -161,4 +164,4 @@ void ACMDTMFPlayout::DestructDecoderSafe() {
#endif #endif
} // namespace webrtc } // namespace webrtc

View File

@ -11,32 +11,33 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
namespace webrtc { namespace webrtc {
class ACMDTMFPlayout: public ACMGenericCodec { class ACMDTMFPlayout: public ACMGenericCodec {
public: public:
ACMDTMFPlayout(WebRtc_Word16 codecID); explicit ACMDTMFPlayout(WebRtc_Word16 codec_id);
~ACMDTMFPlayout(); ~ACMDTMFPlayout();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audioSamples, WebRtc_Word16* audio, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -46,9 +47,9 @@ class ACMDTMFPlayout: public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
}; };
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_ #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_

View File

@ -8,64 +8,63 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_g722.h" #include "webrtc/modules/audio_coding/main/source/acm_g722.h"
#include "acm_codec_database.h"
#include "acm_common_defs.h" #include "webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "trace.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "g722_interface.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_G722 #ifndef WEBRTC_CODEC_G722
ACMG722::ACMG722(WebRtc_Word16 /* codecID */) ACMG722::ACMG722(WebRtc_Word16 /* codec_id */)
: _ptrEncStr(NULL), : ptr_enc_str_(NULL),
_ptrDecStr(NULL), ptr_dec_str_(NULL),
_encoderInstPtr(NULL), encoder_inst_ptr_(NULL),
_encoderInstPtrRight(NULL), encoder_inst_ptr_right_(NULL),
_decoderInstPtr(NULL) { decoder_inst_ptr_(NULL) {}
return;
}
ACMG722::~ACMG722() { ACMG722::~ACMG722() {}
return;
}
WebRtc_Word32 ACMG722::Add10MsDataSafe(const WebRtc_UWord32 /* timestamp */, WebRtc_Word32 ACMG722::Add10MsDataSafe(
const WebRtc_Word16* /* data */, const WebRtc_UWord32 /* timestamp */,
const WebRtc_UWord16 /* lengthSmpl */, const WebRtc_Word16* /* data */,
const WebRtc_UWord8 /* audioChannel */) { const WebRtc_UWord16 /* length_smpl */,
const WebRtc_UWord8 /* audio_channel */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG722::InternalEncode(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG722::InternalEncode(
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitstream_len_byte */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG722::InternalInitEncoder( WebRtc_Word16 ACMG722::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG722::InternalInitDecoder( WebRtc_Word16 ACMG722::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -89,7 +88,7 @@ void ACMG722::DestructDecoderSafe() {
return; return;
} }
void ACMG722::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMG722::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
@ -100,158 +99,160 @@ void ACMG722::SplitStereoPacket(uint8_t* /*payload*/,
// Encoder and decoder memory // Encoder and decoder memory
struct ACMG722EncStr { struct ACMG722EncStr {
G722EncInst* inst; // instance for left channel in case of stereo G722EncInst* inst; // instance for left channel in case of stereo
G722EncInst* instRight; // instance for right channel in case of stereo G722EncInst* inst_right; // instance for right channel in case of stereo
}; };
struct ACMG722DecStr { struct ACMG722DecStr {
G722DecInst* inst; // instance for left channel in case of stereo G722DecInst* inst; // instance for left channel in case of stereo
G722DecInst* instRight; // instance for right channel in case of stereo G722DecInst* inst_right; // instance for right channel in case of stereo
}; };
ACMG722::ACMG722(WebRtc_Word16 codecID) ACMG722::ACMG722(WebRtc_Word16 codec_id)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_encoderInstPtrRight(NULL), encoder_inst_ptr_right_(NULL),
_decoderInstPtr(NULL) { decoder_inst_ptr_(NULL) {
// Encoder // Encoder
_ptrEncStr = new ACMG722EncStr; ptr_enc_str_ = new ACMG722EncStr;
if (_ptrEncStr != NULL) { if (ptr_enc_str_ != NULL) {
_ptrEncStr->inst = NULL; ptr_enc_str_->inst = NULL;
_ptrEncStr->instRight = NULL; ptr_enc_str_->inst_right = NULL;
} }
// Decoder // Decoder
_ptrDecStr = new ACMG722DecStr; ptr_dec_str_ = new ACMG722DecStr;
if (_ptrDecStr != NULL) { if (ptr_dec_str_ != NULL) {
_ptrDecStr->inst = NULL; ptr_dec_str_->inst = NULL;
_ptrDecStr->instRight = NULL; // Not used ptr_dec_str_->inst_right = NULL; // Not used
} }
_codecID = codecID; codec_id_ = codec_id;
return; return;
} }
ACMG722::~ACMG722() { ACMG722::~ACMG722() {
// Encoder // Encoder
if (_ptrEncStr != NULL) { if (ptr_enc_str_ != NULL) {
if (_ptrEncStr->inst != NULL) { if (ptr_enc_str_->inst != NULL) {
WebRtcG722_FreeEncoder(_ptrEncStr->inst); WebRtcG722_FreeEncoder(ptr_enc_str_->inst);
_ptrEncStr->inst = NULL; ptr_enc_str_->inst = NULL;
} }
if (_ptrEncStr->instRight != NULL) { if (ptr_enc_str_->inst_right != NULL) {
WebRtcG722_FreeEncoder(_ptrEncStr->instRight); WebRtcG722_FreeEncoder(ptr_enc_str_->inst_right);
_ptrEncStr->instRight = NULL; ptr_enc_str_->inst_right = NULL;
} }
delete _ptrEncStr; delete ptr_enc_str_;
_ptrEncStr = NULL; ptr_enc_str_ = NULL;
} }
// Decoder // Decoder
if (_ptrDecStr != NULL) { if (ptr_dec_str_ != NULL) {
if (_ptrDecStr->inst != NULL) { if (ptr_dec_str_->inst != NULL) {
WebRtcG722_FreeDecoder(_ptrDecStr->inst); WebRtcG722_FreeDecoder(ptr_dec_str_->inst);
_ptrDecStr->inst = NULL; ptr_dec_str_->inst = NULL;
} }
if (_ptrDecStr->instRight != NULL) { if (ptr_dec_str_->inst_right != NULL) {
WebRtcG722_FreeDecoder(_ptrDecStr->instRight); WebRtcG722_FreeDecoder(ptr_dec_str_->inst_right);
_ptrDecStr->instRight = NULL; ptr_dec_str_->inst_right = NULL;
} }
delete _ptrDecStr; delete ptr_dec_str_;
_ptrDecStr = NULL; ptr_dec_str_ = NULL;
} }
return; return;
} }
WebRtc_Word32 ACMG722::Add10MsDataSafe(const WebRtc_UWord32 timestamp, WebRtc_Word32 ACMG722::Add10MsDataSafe(const WebRtc_UWord32 timestamp,
const WebRtc_Word16* data, const WebRtc_Word16* data,
const WebRtc_UWord16 lengthSmpl, const WebRtc_UWord16 length_smpl,
const WebRtc_UWord8 audioChannel) { const WebRtc_UWord8 audio_channel) {
return ACMGenericCodec::Add10MsDataSafe((timestamp >> 1), data, lengthSmpl, return ACMGenericCodec::Add10MsDataSafe((timestamp >> 1), data, length_smpl,
audioChannel); audio_channel);
} }
WebRtc_Word16 ACMG722::InternalEncode(WebRtc_UWord8* bitStream, WebRtc_Word16 ACMG722::InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte) { WebRtc_Word16* bitstream_len_byte) {
// If stereo, split input signal in left and right channel before encoding // If stereo, split input signal in left and right channel before encoding
if (_noChannels == 2) { if (num_channels_ == 2) {
WebRtc_Word16 leftChannel[960]; WebRtc_Word16 left_channel[960];
WebRtc_Word16 rightChannel[960]; WebRtc_Word16 right_channel[960];
WebRtc_UWord8 outLeft[480]; WebRtc_UWord8 out_left[480];
WebRtc_UWord8 outRight[480]; WebRtc_UWord8 out_right[480];
WebRtc_Word16 lenInBytes; WebRtc_Word16 len_in_bytes;
for (int i = 0, j = 0; i < _frameLenSmpl * 2; i += 2, j++) { for (int i = 0, j = 0; i < frame_len_smpl_ * 2; i += 2, j++) {
leftChannel[j] = _inAudio[_inAudioIxRead + i]; left_channel[j] = in_audio_[in_audio_ix_read_ + i];
rightChannel[j] = _inAudio[_inAudioIxRead + i + 1]; right_channel[j] = in_audio_[in_audio_ix_read_ + i + 1];
} }
lenInBytes = WebRtcG722_Encode(_encoderInstPtr, leftChannel, _frameLenSmpl, len_in_bytes = WebRtcG722_Encode(encoder_inst_ptr_, left_channel,
(WebRtc_Word16*) outLeft); frame_len_smpl_,
lenInBytes += WebRtcG722_Encode(_encoderInstPtrRight, rightChannel, (WebRtc_Word16*)out_left);
_frameLenSmpl, (WebRtc_Word16*) outRight); len_in_bytes += WebRtcG722_Encode(encoder_inst_ptr_right_, right_channel,
*bitStreamLenByte = lenInBytes; frame_len_smpl_,
(WebRtc_Word16*)out_right);
*bitstream_len_byte = len_in_bytes;
// Interleave the 4 bits per sample from left and right channel // Interleave the 4 bits per sample from left and right channel
for (int i = 0, j = 0; i < lenInBytes; i += 2, j++) { for (int i = 0, j = 0; i < len_in_bytes; i += 2, j++) {
bitStream[i] = (outLeft[j] & 0xF0) + (outRight[j] >> 4); bitstream[i] = (out_left[j] & 0xF0) + (out_right[j] >> 4);
bitStream[i + 1] = ((outLeft[j] & 0x0F) << 4) + (outRight[j] & 0x0F); bitstream[i + 1] = ((out_left[j] & 0x0F) << 4) + (out_right[j] & 0x0F);
} }
} else { } else {
*bitStreamLenByte = WebRtcG722_Encode(_encoderInstPtr, *bitstream_len_byte = WebRtcG722_Encode(encoder_inst_ptr_,
&_inAudio[_inAudioIxRead], &in_audio_[in_audio_ix_read_],
_frameLenSmpl, frame_len_smpl_,
(WebRtc_Word16*) bitStream); (WebRtc_Word16*)bitstream);
} }
// increment the read index this tell the caller how far // increment the read index this tell the caller how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += _frameLenSmpl * _noChannels; in_audio_ix_read_ += frame_len_smpl_ * num_channels_;
return *bitStreamLenByte; return *bitstream_len_byte;
} }
WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMG722::InternalInitEncoder(WebRtcACMCodecParams* codecParams) { WebRtc_Word16 ACMG722::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
if (codecParams->codecInstant.channels == 2) { if (codec_params->codec_inst.channels == 2) {
// Create codec struct for right channel // Create codec struct for right channel
if (_ptrEncStr->instRight == NULL) { if (ptr_enc_str_->inst_right == NULL) {
WebRtcG722_CreateEncoder(&_ptrEncStr->instRight); WebRtcG722_CreateEncoder(&ptr_enc_str_->inst_right);
if (_ptrEncStr->instRight == NULL) { if (ptr_enc_str_->inst_right == NULL) {
return -1; return -1;
} }
} }
_encoderInstPtrRight = _ptrEncStr->instRight; encoder_inst_ptr_right_ = ptr_enc_str_->inst_right;
if (WebRtcG722_EncoderInit(_encoderInstPtrRight) < 0) { if (WebRtcG722_EncoderInit(encoder_inst_ptr_right_) < 0) {
return -1; return -1;
} }
} }
return WebRtcG722_EncoderInit(_encoderInstPtr); return WebRtcG722_EncoderInit(encoder_inst_ptr_);
} }
WebRtc_Word16 ACMG722::InternalInitDecoder( WebRtc_Word16 ACMG722::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return WebRtcG722_DecoderInit(_decoderInstPtr); return WebRtcG722_DecoderInit(decoder_inst_ptr_);
} }
WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!_decoderInitialized) { if (!decoder_initialized_) {
// TODO: log error // TODO(turajs): log error
return -1; return -1;
} }
// Fill up the structure by calling // Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_G722_FUNCTION." // "SET_CODEC_PAR" & "SET_G722_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
if (codecInst.channels == 1) { if (codec_inst.channels == 1) {
SET_CODEC_PAR(codecDef, kDecoderG722, codecInst.pltype, _decoderInstPtr, SET_CODEC_PAR(codec_def, kDecoderG722, codec_inst.pltype, decoder_inst_ptr_,
16000); 16000);
} else { } else {
SET_CODEC_PAR(codecDef, kDecoderG722_2ch, codecInst.pltype, SET_CODEC_PAR(codec_def, kDecoderG722_2ch, codec_inst.pltype,
_decoderInstPtr, 16000); decoder_inst_ptr_, 16000);
} }
SET_G722_FUNCTIONS(codecDef); SET_G722_FUNCTIONS(codec_def);
return 0; return 0;
} }
@ -260,61 +261,61 @@ ACMGenericCodec* ACMG722::CreateInstance(void) {
} }
WebRtc_Word16 ACMG722::InternalCreateEncoder() { WebRtc_Word16 ACMG722::InternalCreateEncoder() {
if (_ptrEncStr == NULL) { if (ptr_enc_str_ == NULL) {
// this structure must be created at the costructor // this structure must be created at the costructor
// if it is still NULL then there is a probelm and // if it is still NULL then there is a probelm and
// we dont continue // we dont continue
return -1; return -1;
} }
WebRtcG722_CreateEncoder(&_ptrEncStr->inst); WebRtcG722_CreateEncoder(&ptr_enc_str_->inst);
if (_ptrEncStr->inst == NULL) { if (ptr_enc_str_->inst == NULL) {
return -1; return -1;
} }
_encoderInstPtr = _ptrEncStr->inst; encoder_inst_ptr_ = ptr_enc_str_->inst;
return 0; return 0;
} }
void ACMG722::DestructEncoderSafe() { void ACMG722::DestructEncoderSafe() {
if (_ptrEncStr != NULL) { if (ptr_enc_str_ != NULL) {
if (_ptrEncStr->inst != NULL) { if (ptr_enc_str_->inst != NULL) {
WebRtcG722_FreeEncoder(_ptrEncStr->inst); WebRtcG722_FreeEncoder(ptr_enc_str_->inst);
_ptrEncStr->inst = NULL; ptr_enc_str_->inst = NULL;
} }
} }
_encoderExist = false; encoder_exist_ = false;
_encoderInitialized = false; encoder_initialized_ = false;
} }
WebRtc_Word16 ACMG722::InternalCreateDecoder() { WebRtc_Word16 ACMG722::InternalCreateDecoder() {
if (_ptrDecStr == NULL) { if (ptr_dec_str_ == NULL) {
// this structure must be created at the costructor // this structure must be created at the costructor
// if it is still NULL then there is a probelm and // if it is still NULL then there is a probelm and
// we dont continue // we dont continue
return -1; return -1;
} }
WebRtcG722_CreateDecoder(&_ptrDecStr->inst); WebRtcG722_CreateDecoder(&ptr_dec_str_->inst);
if (_ptrDecStr->inst == NULL) { if (ptr_dec_str_->inst == NULL) {
return -1; return -1;
} }
_decoderInstPtr = _ptrDecStr->inst; decoder_inst_ptr_ = ptr_dec_str_->inst;
return 0; return 0;
} }
void ACMG722::DestructDecoderSafe() { void ACMG722::DestructDecoderSafe() {
_decoderExist = false; decoder_exist_ = false;
_decoderInitialized = false; decoder_initialized_ = false;
if (_ptrDecStr != NULL) { if (ptr_dec_str_ != NULL) {
if (_ptrDecStr->inst != NULL) { if (ptr_dec_str_->inst != NULL) {
WebRtcG722_FreeDecoder(_ptrDecStr->inst); WebRtcG722_FreeDecoder(ptr_dec_str_->inst);
_ptrDecStr->inst = NULL; ptr_dec_str_->inst = NULL;
} }
} }
} }
void ACMG722::InternalDestructEncoderInst(void* ptrInst) { void ACMG722::InternalDestructEncoderInst(void* ptr_inst) {
if (ptrInst != NULL) { if (ptr_inst != NULL) {
WebRtcG722_FreeEncoder(static_cast<G722EncInst*>(ptrInst)); WebRtcG722_FreeEncoder(static_cast<G722EncInst*>(ptr_inst));
} }
return; return;
} }
@ -350,4 +351,4 @@ void ACMG722::SplitStereoPacket(uint8_t* payload, int32_t* payload_length) {
#endif #endif
} // namespace webrtc } // namespace webrtc

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
typedef struct WebRtcG722EncInst G722EncInst; typedef struct WebRtcG722EncInst G722EncInst;
typedef struct WebRtcG722DecInst G722DecInst; typedef struct WebRtcG722DecInst G722DecInst;
@ -24,31 +24,32 @@ struct ACMG722DecStr;
class ACMG722: public ACMGenericCodec { class ACMG722: public ACMGenericCodec {
public: public:
ACMG722(WebRtc_Word16 codecID); explicit ACMG722(WebRtc_Word16 codec_id);
~ACMG722(); ~ACMG722();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audioSamples, WebRtc_Word16* audio, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
WebRtc_Word32 Add10MsDataSafe(const WebRtc_UWord32 timestamp, WebRtc_Word32 Add10MsDataSafe(const WebRtc_UWord32 timestamp,
const WebRtc_Word16* data, const WebRtc_Word16* data,
const WebRtc_UWord16 lengthSmpl, const WebRtc_UWord16 length_smpl,
const WebRtc_UWord8 audioChannel); const WebRtc_UWord8 audio_channel);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -58,18 +59,18 @@ class ACMG722: public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length); void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
ACMG722EncStr* _ptrEncStr; ACMG722EncStr* ptr_enc_str_;
ACMG722DecStr* _ptrDecStr; ACMG722DecStr* ptr_dec_str_;
G722EncInst* _encoderInstPtr; G722EncInst* encoder_inst_ptr_;
G722EncInst* _encoderInstPtrRight; // Prepared for stereo G722EncInst* encoder_inst_ptr_right_; // Prepared for stereo
G722DecInst* _decoderInstPtr; G722DecInst* decoder_inst_ptr_;
}; };
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_ #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_

View File

@ -8,13 +8,14 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_g7221.h" #include "webrtc/modules/audio_coding/main/source/acm_g7221.h"
#include "acm_codec_database.h"
#include "acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "trace.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc/system_wrappers/interface/trace.h"
#ifdef WEBRTC_CODEC_G722_1 #ifdef WEBRTC_CODEC_G722_1
// NOTE! G.722.1 is not included in the open-source package. The following // NOTE! G.722.1 is not included in the open-source package. The following
@ -24,62 +25,62 @@
// //
// The API in the header file should match the one below. // The API in the header file should match the one below.
// //
// int16_t WebRtcG7221_CreateEnc16(G722_1_16_encinst_t_** encInst); // int16_t WebRtcG7221_CreateEnc16(G722_1_16_encinst_t_** enc_inst);
// int16_t WebRtcG7221_CreateEnc24(G722_1_24_encinst_t_** encInst); // int16_t WebRtcG7221_CreateEnc24(G722_1_24_encinst_t_** enc_inst);
// int16_t WebRtcG7221_CreateEnc32(G722_1_32_encinst_t_** encInst); // int16_t WebRtcG7221_CreateEnc32(G722_1_32_encinst_t_** enc_inst);
// int16_t WebRtcG7221_CreateDec16(G722_1_16_decinst_t_** decInst); // int16_t WebRtcG7221_CreateDec16(G722_1_16_decinst_t_** dec_inst);
// int16_t WebRtcG7221_CreateDec24(G722_1_24_decinst_t_** decInst); // int16_t WebRtcG7221_CreateDec24(G722_1_24_decinst_t_** dec_inst);
// int16_t WebRtcG7221_CreateDec32(G722_1_32_decinst_t_** decInst); // int16_t WebRtcG7221_CreateDec32(G722_1_32_decinst_t_** dec_inst);
// //
// int16_t WebRtcG7221_FreeEnc16(G722_1_16_encinst_t_** encInst); // int16_t WebRtcG7221_FreeEnc16(G722_1_16_encinst_t_** enc_inst);
// int16_t WebRtcG7221_FreeEnc24(G722_1_24_encinst_t_** encInst); // int16_t WebRtcG7221_FreeEnc24(G722_1_24_encinst_t_** enc_inst);
// int16_t WebRtcG7221_FreeEnc32(G722_1_32_encinst_t_** encInst); // int16_t WebRtcG7221_FreeEnc32(G722_1_32_encinst_t_** enc_inst);
// int16_t WebRtcG7221_FreeDec16(G722_1_16_decinst_t_** decInst); // int16_t WebRtcG7221_FreeDec16(G722_1_16_decinst_t_** dec_inst);
// int16_t WebRtcG7221_FreeDec24(G722_1_24_decinst_t_** decInst); // int16_t WebRtcG7221_FreeDec24(G722_1_24_decinst_t_** dec_inst);
// int16_t WebRtcG7221_FreeDec32(G722_1_32_decinst_t_** decInst); // int16_t WebRtcG7221_FreeDec32(G722_1_32_decinst_t_** dec_inst);
// //
// int16_t WebRtcG7221_EncoderInit16(G722_1_16_encinst_t_* encInst); // int16_t WebRtcG7221_EncoderInit16(G722_1_16_encinst_t_* enc_inst);
// int16_t WebRtcG7221_EncoderInit24(G722_1_24_encinst_t_* encInst); // int16_t WebRtcG7221_EncoderInit24(G722_1_24_encinst_t_* enc_inst);
// int16_t WebRtcG7221_EncoderInit32(G722_1_32_encinst_t_* encInst); // int16_t WebRtcG7221_EncoderInit32(G722_1_32_encinst_t_* enc_inst);
// int16_t WebRtcG7221_DecoderInit16(G722_1_16_decinst_t_* decInst); // int16_t WebRtcG7221_DecoderInit16(G722_1_16_decinst_t_* dec_inst);
// int16_t WebRtcG7221_DecoderInit24(G722_1_24_decinst_t_* decInst); // int16_t WebRtcG7221_DecoderInit24(G722_1_24_decinst_t_* dec_inst);
// int16_t WebRtcG7221_DecoderInit32(G722_1_32_decinst_t_* decInst); // int16_t WebRtcG7221_DecoderInit32(G722_1_32_decinst_t_* dec_inst);
// //
// int16_t WebRtcG7221_Encode16(G722_1_16_encinst_t_* encInst, // int16_t WebRtcG7221_Encode16(G722_1_16_encinst_t_* enc_inst,
// int16_t* input, // int16_t* input,
// int16_t len, // int16_t len,
// int16_t* output); // int16_t* output);
// int16_t WebRtcG7221_Encode24(G722_1_24_encinst_t_* encInst, // int16_t WebRtcG7221_Encode24(G722_1_24_encinst_t_* enc_inst,
// int16_t* input, // int16_t* input,
// int16_t len, // int16_t len,
// int16_t* output); // int16_t* output);
// int16_t WebRtcG7221_Encode32(G722_1_32_encinst_t_* encInst, // int16_t WebRtcG7221_Encode32(G722_1_32_encinst_t_* enc_inst,
// int16_t* input, // int16_t* input,
// int16_t len, // int16_t len,
// int16_t* output); // int16_t* output);
// //
// int16_t WebRtcG7221_Decode16(G722_1_16_decinst_t_* decInst, // int16_t WebRtcG7221_Decode16(G722_1_16_decinst_t_* dec_inst,
// int16_t* bitstream, // int16_t* bitstream,
// int16_t len, // int16_t len,
// int16_t* output); // int16_t* output);
// int16_t WebRtcG7221_Decode24(G722_1_24_decinst_t_* decInst, // int16_t WebRtcG7221_Decode24(G722_1_24_decinst_t_* dec_inst,
// int16_t* bitstream, // int16_t* bitstream,
// int16_t len, // int16_t len,
// int16_t* output); // int16_t* output);
// int16_t WebRtcG7221_Decode32(G722_1_32_decinst_t_* decInst, // int16_t WebRtcG7221_Decode32(G722_1_32_decinst_t_* dec_inst,
// int16_t* bitstream, // int16_t* bitstream,
// int16_t len, // int16_t len,
// int16_t* output); // int16_t* output);
// //
// int16_t WebRtcG7221_DecodePlc16(G722_1_16_decinst_t_* decInst, // int16_t WebRtcG7221_DecodePlc16(G722_1_16_decinst_t_* dec_inst,
// int16_t* output, // int16_t* output,
// int16_t nrLostFrames); // int16_t nr_lost_frames);
// int16_t WebRtcG7221_DecodePlc24(G722_1_24_decinst_t_* decInst, // int16_t WebRtcG7221_DecodePlc24(G722_1_24_decinst_t_* dec_inst,
// int16_t* output, // int16_t* output,
// int16_t nrLostFrames); // int16_t nr_lost_frames);
// int16_t WebRtcG7221_DecodePlc32(G722_1_32_decinst_t_* decInst, // int16_t WebRtcG7221_DecodePlc32(G722_1_32_decinst_t_* dec_inst,
// int16_t* output, // int16_t* output,
// int16_t nrLostFrames); // int16_t nr_lost_frames);
#include "g7221_interface.h" #include "g7221_interface.h"
#endif #endif
@ -87,20 +88,20 @@ namespace webrtc {
#ifndef WEBRTC_CODEC_G722_1 #ifndef WEBRTC_CODEC_G722_1
ACMG722_1::ACMG722_1(WebRtc_Word16 /* codecID */) ACMG722_1::ACMG722_1(WebRtc_Word16 /* codec_id */)
: _operationalRate(-1), : operational_rate_(-1),
_encoderInstPtr(NULL), encoder_inst_ptr_(NULL),
_encoderInstPtrRight(NULL), encoder_inst_ptr_right_(NULL),
_decoderInstPtr(NULL), decoder_inst_ptr_(NULL),
_encoderInst16Ptr(NULL), encoder_inst16_ptr_(NULL),
_encoderInst16PtrR(NULL), encoder_inst16_ptr_right_(NULL),
_encoderInst24Ptr(NULL), encoder_inst24_ptr_(NULL),
_encoderInst24PtrR(NULL), encoder_inst24_ptr_right_(NULL),
_encoderInst32Ptr(NULL), encoder_inst32_ptr_(NULL),
_encoderInst32PtrR(NULL), encoder_inst32_ptr_right_(NULL),
_decoderInst16Ptr(NULL), decoder_inst16_ptr_(NULL),
_decoderInst24Ptr(NULL), decoder_inst24_ptr_(NULL),
_decoderInst32Ptr(NULL) { decoder_inst32_ptr_(NULL) {
return; return;
} }
@ -108,31 +109,32 @@ ACMG722_1::~ACMG722_1() {
return; return;
} }
WebRtc_Word16 ACMG722_1::InternalEncode(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG722_1::InternalEncode(
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitstream_len_byte */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG722_1::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG722_1::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG722_1::InternalInitEncoder( WebRtc_Word16 ACMG722_1::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG722_1::InternalInitDecoder( WebRtc_Word16 ACMG722_1::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word32 ACMG722_1::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, WebRtc_Word32 ACMG722_1::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -156,69 +158,68 @@ void ACMG722_1::DestructDecoderSafe() {
return; return;
} }
void ACMG722_1::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMG722_1::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMG722_1::ACMG722_1( ACMG722_1::ACMG722_1(WebRtc_Word16 codec_id)
WebRtc_Word16 codecID): : encoder_inst_ptr_(NULL),
_encoderInstPtr(NULL), encoder_inst_ptr_right_(NULL),
_encoderInstPtrRight(NULL), decoder_inst_ptr_(NULL),
_decoderInstPtr(NULL), encoder_inst16_ptr_(NULL),
_encoderInst16Ptr(NULL), encoder_inst16_ptr_right_(NULL),
_encoderInst16PtrR(NULL), encoder_inst24_ptr_(NULL),
_encoderInst24Ptr(NULL), encoder_inst24_ptr_right_(NULL),
_encoderInst24PtrR(NULL), encoder_inst32_ptr_(NULL),
_encoderInst32Ptr(NULL), encoder_inst32_ptr_right_(NULL),
_encoderInst32PtrR(NULL), decoder_inst16_ptr_(NULL),
_decoderInst16Ptr(NULL), decoder_inst24_ptr_(NULL),
_decoderInst24Ptr(NULL), decoder_inst32_ptr_(NULL) {
_decoderInst32Ptr(NULL) { codec_id_ = codec_id;
_codecID = codecID; if (codec_id_ == ACMCodecDB::kG722_1_16) {
if (_codecID == ACMCodecDB::kG722_1_16) { operational_rate_ = 16000;
_operationalRate = 16000; } else if (codec_id_ == ACMCodecDB::kG722_1_24) {
} else if (_codecID == ACMCodecDB::kG722_1_24) { operational_rate_ = 24000;
_operationalRate = 24000; } else if (codec_id_ == ACMCodecDB::kG722_1_32) {
} else if (_codecID == ACMCodecDB::kG722_1_32) { operational_rate_ = 32000;
_operationalRate = 32000;
} else { } else {
_operationalRate = -1; operational_rate_ = -1;
} }
return; return;
} }
ACMG722_1::~ACMG722_1() { ACMG722_1::~ACMG722_1() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
delete _encoderInstPtr; delete encoder_inst_ptr_;
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
if (_encoderInstPtrRight != NULL) { if (encoder_inst_ptr_right_ != NULL) {
delete _encoderInstPtrRight; delete encoder_inst_ptr_right_;
_encoderInstPtrRight = NULL; encoder_inst_ptr_right_ = NULL;
} }
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
delete _decoderInstPtr; delete decoder_inst_ptr_;
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
switch (_operationalRate) { switch (operational_rate_) {
case 16000: { case 16000: {
_encoderInst16Ptr = NULL; encoder_inst16_ptr_ = NULL;
_encoderInst16PtrR = NULL; encoder_inst16_ptr_right_ = NULL;
_decoderInst16Ptr = NULL; decoder_inst16_ptr_ = NULL;
break; break;
} }
case 24000: { case 24000: {
_encoderInst24Ptr = NULL; encoder_inst24_ptr_ = NULL;
_encoderInst24PtrR = NULL; encoder_inst24_ptr_right_ = NULL;
_decoderInst24Ptr = NULL; decoder_inst24_ptr_ = NULL;
break; break;
} }
case 32000: { case 32000: {
_encoderInst32Ptr = NULL; encoder_inst32_ptr_ = NULL;
_encoderInst32PtrR = NULL; encoder_inst32_ptr_right_ = NULL;
_decoderInst32Ptr = NULL; decoder_inst32_ptr_ = NULL;
break; break;
} }
default: { default: {
@ -228,131 +229,134 @@ ACMG722_1::~ACMG722_1() {
return; return;
} }
WebRtc_Word16 ACMG722_1::InternalEncode(WebRtc_UWord8* bitStream, WebRtc_Word16 ACMG722_1::InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte) { WebRtc_Word16* bitstream_len_byte) {
WebRtc_Word16 leftChannel[320]; WebRtc_Word16 left_channel[320];
WebRtc_Word16 rightChannel[320]; WebRtc_Word16 right_channel[320];
WebRtc_Word16 lenInBytes; WebRtc_Word16 len_in_bytes;
WebRtc_Word16 outB[160]; WebRtc_Word16 out_bits[160];
// If stereo, split input signal in left and right channel before encoding // If stereo, split input signal in left and right channel before encoding
if (_noChannels == 2) { if (num_channels_ == 2) {
for (int i = 0, j = 0; i < _frameLenSmpl * 2; i += 2, j++) { for (int i = 0, j = 0; i < frame_len_smpl_ * 2; i += 2, j++) {
leftChannel[j] = _inAudio[_inAudioIxRead + i]; left_channel[j] = in_audio_[in_audio_ix_read_ + i];
rightChannel[j] = _inAudio[_inAudioIxRead + i + 1]; right_channel[j] = in_audio_[in_audio_ix_read_ + i + 1];
} }
} else { } else {
memcpy(leftChannel, &_inAudio[_inAudioIxRead], 320); memcpy(left_channel, &in_audio_[in_audio_ix_read_], 320);
} }
switch (_operationalRate) { switch (operational_rate_) {
case 16000: { case 16000: {
Inst lenInBytes = WebRtcG7221_Encode16(_encoderInst16Ptr, leftChannel, len_in_bytes = WebRtcG7221_Encode16(encoder_inst16_ptr_, left_channel,
320, &outB[0]); 320, &out_bits[0]);
if (_noChannels == 2) { if (num_channels_ == 2) {
lenInBytes += WebRtcG7221_Encode16(_encoderInst16PtrR, rightChannel, len_in_bytes += WebRtcG7221_Encode16(encoder_inst16_ptr_right_,
320, &outB[lenInBytes / 2]); right_channel, 320,
&out_bits[len_in_bytes / 2]);
} }
break; break;
} }
case 24000: { case 24000: {
lenInBytes = WebRtcG7221_Encode24(_encoderInst24Ptr, leftChannel, 320, len_in_bytes = WebRtcG7221_Encode24(encoder_inst24_ptr_, left_channel,
&outB[0]); 320, &out_bits[0]);
if (_noChannels == 2) { if (num_channels_ == 2) {
lenInBytes += WebRtcG7221_Encode24(_encoderInst24PtrR, rightChannel, len_in_bytes += WebRtcG7221_Encode24(encoder_inst24_ptr_right_,
320, &outB[lenInBytes / 2]); right_channel, 320,
&out_bits[len_in_bytes / 2]);
} }
break; break;
} }
case 32000: { case 32000: {
lenInBytes = WebRtcG7221_Encode32(_encoderInst32Ptr, leftChannel, 320, len_in_bytes = WebRtcG7221_Encode32(encoder_inst32_ptr_, left_channel,
&outB[0]); 320, &out_bits[0]);
if (_noChannels == 2) { if (num_channels_ == 2) {
lenInBytes += WebRtcG7221_Encode32(_encoderInst32PtrR, rightChannel, len_in_bytes += WebRtcG7221_Encode32(encoder_inst32_ptr_right_,
320, &outB[lenInBytes / 2]); right_channel, 320,
&out_bits[len_in_bytes / 2]);
} }
break; break;
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalInitEncode: Wrong rate for G722_1."); "InternalInitEncode: Wrong rate for G722_1.");
return -1; return -1;
} }
} }
memcpy(bitStream, outB, lenInBytes); memcpy(bitstream, out_bits, len_in_bytes);
*bitStreamLenByte = lenInBytes; *bitstream_len_byte = len_in_bytes;
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += 320 * _noChannels; in_audio_ix_read_ += 320 * num_channels_;
return *bitStreamLenByte; return *bitstream_len_byte;
} }
WebRtc_Word16 ACMG722_1::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG722_1::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMG722_1::InternalInitEncoder( WebRtc_Word16 ACMG722_1::InternalInitEncoder(
WebRtcACMCodecParams* codecParams) { WebRtcACMCodecParams* codec_params) {
WebRtc_Word16 ret; WebRtc_Word16 ret;
switch (_operationalRate) { switch (operational_rate_) {
case 16000: { case 16000: {
ret = WebRtcG7221_EncoderInit16(_encoderInst16PtrR); ret = WebRtcG7221_EncoderInit16(encoder_inst16_ptr_right_);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
return WebRtcG7221_EncoderInit16(_encoderInst16Ptr); return WebRtcG7221_EncoderInit16(encoder_inst16_ptr_);
} }
case 24000: { case 24000: {
ret = WebRtcG7221_EncoderInit24(_encoderInst24PtrR); ret = WebRtcG7221_EncoderInit24(encoder_inst24_ptr_right_);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
return WebRtcG7221_EncoderInit24(_encoderInst24Ptr); return WebRtcG7221_EncoderInit24(encoder_inst24_ptr_);
} }
case 32000: { case 32000: {
ret = WebRtcG7221_EncoderInit32(_encoderInst32PtrR); ret = WebRtcG7221_EncoderInit32(encoder_inst32_ptr_right_);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
return WebRtcG7221_EncoderInit32(_encoderInst32Ptr); return WebRtcG7221_EncoderInit32(encoder_inst32_ptr_);
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError,Inst webrtc::kTraceAudioCoding, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding,
_uniqueID, "InternalInitEncoder: Wrong rate for G722_1."); unique_id_, "InternalInitEncoder: Wrong rate for G722_1.");
return -1; return -1;
} }
} }
} }
WebRtc_Word16 ACMG722_1::InternalInitDecoder( WebRtc_Word16 ACMG722_1::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
switch (_operationalRate) { switch (operational_rate_) {
case 16000: { case 16000: {
return WebRtcG7221_DecoderInit16(_decoderInst16Ptr); return WebRtcG7221_DecoderInit16(decoder_inst16_ptr_);
} }
case 24000: { case 24000: {
return WebRtcG7221_DecoderInit24(_decoderInst24Ptr); return WebRtcG7221_DecoderInit24(decoder_inst24_ptr_);
} }
case 32000: { case 32000: {
return WebRtcG7221_DecoderInit32(_decoderInst32Ptr); return WebRtcG7221_DecoderInit32(decoder_inst32_ptr_);
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalInitDecoder: Wrong rate for G722_1."); "InternalInitDecoder: Wrong rate for G722_1.");
return -1; return -1;
} }
} }
} }
WebRtc_Word32 ACMG722_1::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMG722_1::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!_decoderInitialized) { if (!decoder_initialized_) {
// Todo: // Todo:
// log error // log error
return -1; return -1;
@ -365,27 +369,27 @@ WebRtc_Word32 ACMG722_1::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
// "SET_CODEC_PAR" & "SET_G722_1_XX_FUNCTION." // "SET_CODEC_PAR" & "SET_G722_1_XX_FUNCTION."
// Then return the structure back to NetEQ to add the codec to it's // Then return the structure back to NetEQ to add the codec to it's
// database. // database.
switch (_operationalRate) { switch (operational_rate_) {
case 16000: { case 16000: {
SET_CODEC_PAR((codecDef), kDecoderG722_1_16, codecInst.pltype, SET_CODEC_PAR((codec_def), kDecoderG722_1_16, codec_inst.pltype,
_decoderInst16Ptr, 16000); decoder_inst16_ptr_, 16000);
SET_G722_1_16_FUNCTIONS((codecDef)); SET_G722_1_16_FUNCTIONS((codec_def));
break; break;
} }
case 24000: { case 24000: {
SET_CODEC_PAR((codecDef), kDecoderG722_1_24, codecInst.pltype, SET_CODEC_PAR((codec_def), kDecoderG722_1_24, codec_inst.pltype,
_decoderInst24Ptr, 16000); decoder_inst24_ptr_, 16000);
SET_G722_1_24_FUNCTIONS((codecDef)); SET_G722_1_24_FUNCTIONS((codec_def));
break; break;
} }
case 32000: { case 32000: {
SET_CODEC_PAR((codecDef), kDecoderG722_1_32, codecInst.pltype, SET_CODEC_PAR((codec_def), kDecoderG722_1_32, codec_inst.pltype,
_decoderInst32Ptr, 16000); decoder_inst32_ptr_, 16000);
SET_G722_1_32_FUNCTIONS((codecDef)); SET_G722_1_32_FUNCTIONS((codec_def));
break; break;
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"CodecDef: Wrong rate for G722_1."); "CodecDef: Wrong rate for G722_1.");
return -1; return -1;
} }
@ -398,27 +402,27 @@ ACMGenericCodec* ACMG722_1::CreateInstance(void) {
} }
WebRtc_Word16 ACMG722_1::InternalCreateEncoder() { WebRtc_Word16 ACMG722_1::InternalCreateEncoder() {
if ((_encoderInstPtr == NULL) || (_encoderInstPtrRight == NULL)) { if ((encoder_inst_ptr_ == NULL) || (encoder_inst_ptr_right_ == NULL)) {
return -1; return -1;
} }
switch (_operationalRate) { switch (operational_rate_) {
case 16000: { case 16000: {
WebRtcG7221_CreateEnc16(&_encoderInst16Ptr); WebRtcG7221_CreateEnc16(&encoder_inst16_ptr_);
WebRtcG7221_CreateEnc16(&_encoderInst16PtrR); WebRtcG7221_CreateEnc16(&encoder_inst16_ptr_right_);
break; break;
} }
case 24000: { case 24000: {
WebRtcG7221_CreateEnc24(&_encoderInst24Ptr); WebRtcG7221_CreateEnc24(&encoder_inst24_ptr_);
WebRtcG7221_CreateEnc24(&_encoderInst24PtrR); WebRtcG7221_CreateEnc24(&encoder_inst24_ptr_right_);
break; break;
} }
case 32000: { case 32000: {
WebRtcG7221_CreateEnc32(&_encoderInst32Ptr); WebRtcG7221_CreateEnc32(&encoder_inst32_ptr_);
WebRtcG7221_CreateEnc32(&_encoderInst32PtrR); WebRtcG7221_CreateEnc32(&encoder_inst32_ptr_right_);
break; break;
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateEncoder: Wrong rate for G722_1."); "InternalCreateEncoder: Wrong rate for G722_1.");
return -1; return -1;
} }
@ -427,40 +431,40 @@ WebRtc_Word16 ACMG722_1::InternalCreateEncoder() {
} }
void ACMG722_1::DestructEncoderSafe() { void ACMG722_1::DestructEncoderSafe() {
_encoderExist = false; encoder_exist_ = false;
_encoderInitialized = false; encoder_initialized_ = false;
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
delete _encoderInstPtr; delete encoder_inst_ptr_;
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
if (_encoderInstPtrRight != NULL) { if (encoder_inst_ptr_right_ != NULL) {
delete _encoderInstPtrRight; delete encoder_inst_ptr_right_;
_encoderInstPtrRight = NULL; encoder_inst_ptr_right_ = NULL;
} }
_encoderInst16Ptr = NULL; encoder_inst16_ptr_ = NULL;
_encoderInst24Ptr = NULL; encoder_inst24_ptr_ = NULL;
_encoderInst32Ptr = NULL; encoder_inst32_ptr_ = NULL;
} }
WebRtc_Word16 ACMG722_1::InternalCreateDecoder() { WebRtc_Word16 ACMG722_1::InternalCreateDecoder() {
if (_decoderInstPtr == NULL) { if (decoder_inst_ptr_ == NULL) {
return -1; return -1;
} }
switch (_operationalRate) { switch (operational_rate_) {
case 16000: { case 16000: {
WebRtcG7221_CreateDec16(&_decoderInst16Ptr); WebRtcG7221_CreateDec16(&decoder_inst16_ptr_);
break; break;
} }
case 24000: { case 24000: {
WebRtcG7221_CreateDec24(&_decoderInst24Ptr); WebRtcG7221_CreateDec24(&decoder_inst24_ptr_);
break; break;
} }
case 32000: { case 32000: {
WebRtcG7221_CreateDec32(&_decoderInst32Ptr); WebRtcG7221_CreateDec32(&decoder_inst32_ptr_);
break; break;
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateDecoder: Wrong rate for G722_1."); "InternalCreateDecoder: Wrong rate for G722_1.");
return -1; return -1;
} }
@ -469,24 +473,24 @@ WebRtc_Word16 ACMG722_1::InternalCreateDecoder() {
} }
void ACMG722_1::DestructDecoderSafe() { void ACMG722_1::DestructDecoderSafe() {
_decoderExist = false; decoder_exist_ = false;
_decoderInitialized = false; decoder_initialized_ = false;
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
delete _decoderInstPtr; delete decoder_inst_ptr_;
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
_decoderInst16Ptr = NULL; decoder_inst16_ptr_ = NULL;
_decoderInst24Ptr = NULL; decoder_inst24_ptr_ = NULL;
_decoderInst32Ptr = NULL; decoder_inst32_ptr_ = NULL;
} }
void ACMG722_1::InternalDestructEncoderInst(void* ptrInst) { void ACMG722_1::InternalDestructEncoderInst(void* ptr_inst) {
if (ptrInst != NULL) { if (ptr_inst != NULL) {
delete ptrInst; delete ptr_inst;
} }
return; return;
} }
#endif #endif
} // namespace webrtc } // namespace webrtc

View File

@ -8,10 +8,10 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7221_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7221_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
// forward declaration // forward declaration
struct G722_1_16_encinst_t_; struct G722_1_16_encinst_t_;
@ -26,26 +26,27 @@ namespace webrtc {
class ACMG722_1: public ACMGenericCodec { class ACMG722_1: public ACMGenericCodec {
public: public:
ACMG722_1(WebRtc_Word16 codecID); explicit ACMG722_1(WebRtc_Word16 codec_id);
~ACMG722_1(); ~ACMG722_1();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audioSamples, WebRtc_Word16* audio, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -55,28 +56,28 @@ class ACMG722_1: public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
WebRtc_Word32 _operationalRate; WebRtc_Word32 operational_rate_;
G722_1_Inst_t_* _encoderInstPtr; G722_1_Inst_t_* encoder_inst_ptr_;
G722_1_Inst_t_* _encoderInstPtrRight; //Used in stereo mode G722_1_Inst_t_* encoder_inst_ptr_right_; // Used in stereo mode
G722_1_Inst_t_* _decoderInstPtr; G722_1_Inst_t_* decoder_inst_ptr_;
// Only one set of these pointer is valid at any instance // Only one set of these pointer is valid at any instance
G722_1_16_encinst_t_* _encoderInst16Ptr; G722_1_16_encinst_t_* encoder_inst16_ptr_;
G722_1_16_encinst_t_* _encoderInst16PtrR; G722_1_16_encinst_t_* encoder_inst16_ptr_right_;
G722_1_24_encinst_t_* _encoderInst24Ptr; G722_1_24_encinst_t_* encoder_inst24_ptr_;
G722_1_24_encinst_t_* _encoderInst24PtrR; G722_1_24_encinst_t_* encoder_inst24_ptr_right_;
G722_1_32_encinst_t_* _encoderInst32Ptr; G722_1_32_encinst_t_* encoder_inst32_ptr_;
G722_1_32_encinst_t_* _encoderInst32PtrR; G722_1_32_encinst_t_* encoder_inst32_ptr_right_;
// Only one of these pointer is valid at any instance // Only one of these pointer is valid at any instance
G722_1_16_decinst_t_* _decoderInst16Ptr; G722_1_16_decinst_t_* decoder_inst16_ptr_;
G722_1_24_decinst_t_* _decoderInst24Ptr; G722_1_24_decinst_t_* decoder_inst24_ptr_;
G722_1_32_decinst_t_* _decoderInst32Ptr; G722_1_32_decinst_t_* decoder_inst32_ptr_;
}; };
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_ #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7221_H_

View File

@ -8,13 +8,14 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_g7221c.h" #include "webrtc/modules/audio_coding/main/source/acm_g7221c.h"
#include "acm_codec_database.h"
#include "acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "trace.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc/system_wrappers/interface/trace.h"
#ifdef WEBRTC_CODEC_G722_1C #ifdef WEBRTC_CODEC_G722_1C
// NOTE! G.722.1C is not included in the open-source package. The following // NOTE! G.722.1C is not included in the open-source package. The following
@ -24,62 +25,63 @@
// //
// The API in the header file should match the one below. // The API in the header file should match the one below.
// //
// int16_t WebRtcG7221C_CreateEnc24(G722_1C_24_encinst_t_** encInst);
// int16_t WebRtcG7221C_CreateEnc32(G722_1C_32_encinst_t_** encInst); // int16_t WebRtcG7221C_CreateEnc24(G722_1C_24_encinst_t_** enc_inst);
// int16_t WebRtcG7221C_CreateEnc48(G722_1C_48_encinst_t_** encInst); // int16_t WebRtcG7221C_CreateEnc32(G722_1C_32_encinst_t_** enc_inst);
// int16_t WebRtcG7221C_CreateDec24(G722_1C_24_decinst_t_** decInst); // int16_t WebRtcG7221C_CreateEnc48(G722_1C_48_encinst_t_** enc_inst);
// int16_t WebRtcG7221C_CreateDec32(G722_1C_32_decinst_t_** decInst); // int16_t WebRtcG7221C_CreateDec24(G722_1C_24_decinst_t_** dec_inst);
// int16_t WebRtcG7221C_CreateDec48(G722_1C_48_decinst_t_** decInst); // int16_t WebRtcG7221C_CreateDec32(G722_1C_32_decinst_t_** dec_inst);
// int16_t WebRtcG7221C_CreateDec48(G722_1C_48_decinst_t_** dec_inst);
// //
// int16_t WebRtcG7221C_FreeEnc24(G722_1C_24_encinst_t_** encInst); // int16_t WebRtcG7221C_FreeEnc24(G722_1C_24_encinst_t_** enc_inst);
// int16_t WebRtcG7221C_FreeEnc32(G722_1C_32_encinst_t_** encInst); // int16_t WebRtcG7221C_FreeEnc32(G722_1C_32_encinst_t_** enc_inst);
// int16_t WebRtcG7221C_FreeEnc48(G722_1C_48_encinst_t_** encInst); // int16_t WebRtcG7221C_FreeEnc48(G722_1C_48_encinst_t_** enc_inst);
// int16_t WebRtcG7221C_FreeDec24(G722_1C_24_decinst_t_** decInst); // int16_t WebRtcG7221C_FreeDec24(G722_1C_24_decinst_t_** dec_inst);
// int16_t WebRtcG7221C_FreeDec32(G722_1C_32_decinst_t_** decInst); // int16_t WebRtcG7221C_FreeDec32(G722_1C_32_decinst_t_** dec_inst);
// int16_t WebRtcG7221C_FreeDec48(G722_1C_48_decinst_t_** decInst); // int16_t WebRtcG7221C_FreeDec48(G722_1C_48_decinst_t_** dec_inst);
// //
// int16_t WebRtcG7221C_EncoderInit24(G722_1C_24_encinst_t_* encInst); // int16_t WebRtcG7221C_EncoderInit24(G722_1C_24_encinst_t_* enc_inst);
// int16_t WebRtcG7221C_EncoderInit32(G722_1C_32_encinst_t_* encInst); // int16_t WebRtcG7221C_EncoderInit32(G722_1C_32_encinst_t_* enc_inst);
// int16_t WebRtcG7221C_EncoderInit48(G722_1C_48_encinst_t_* encInst); // int16_t WebRtcG7221C_EncoderInit48(G722_1C_48_encinst_t_* enc_inst);
// int16_t WebRtcG7221C_DecoderInit24(G722_1C_24_decinst_t_* decInst); // int16_t WebRtcG7221C_DecoderInit24(G722_1C_24_decinst_t_* dec_inst);
// int16_t WebRtcG7221C_DecoderInit32(G722_1C_32_decinst_t_* decInst); // int16_t WebRtcG7221C_DecoderInit32(G722_1C_32_decinst_t_* dec_inst);
// int16_t WebRtcG7221C_DecoderInit48(G722_1C_48_decinst_t_* decInst); // int16_t WebRtcG7221C_DecoderInit48(G722_1C_48_decinst_t_* dec_inst);
// //
// int16_t WebRtcG7221C_Encode24(G722_1C_24_encinst_t_* encInst, // int16_t WebRtcG7221C_Encode24(G722_1C_24_encinst_t_* enc_inst,
// int16_t* input, // int16_t* input,
// int16_t len, // int16_t len,
// int16_t* output); // int16_t* output);
// int16_t WebRtcG7221C_Encode32(G722_1C_32_encinst_t_* encInst, // int16_t WebRtcG7221C_Encode32(G722_1C_32_encinst_t_* enc_inst,
// int16_t* input, // int16_t* input,
// int16_t len, // int16_t len,
// int16_t* output); // int16_t* output);
// int16_t WebRtcG7221C_Encode48(G722_1C_48_encinst_t_* encInst, // int16_t WebRtcG7221C_Encode48(G722_1C_48_encinst_t_* enc_inst,
// int16_t* input, // int16_t* input,
// int16_t len, // int16_t len,
// int16_t* output); // int16_t* output);
// //
// int16_t WebRtcG7221C_Decode24(G722_1C_24_decinst_t_* decInst, // int16_t WebRtcG7221C_Decode24(G722_1C_24_decinst_t_* dec_inst,
// int16_t* bitstream, // int16_t* bitstream,
// int16_t len, // int16_t len,
// int16_t* output); // int16_t* output);
// int16_t WebRtcG7221C_Decode32(G722_1C_32_decinst_t_* decInst, // int16_t WebRtcG7221C_Decode32(G722_1C_32_decinst_t_* dec_inst,
// int16_t* bitstream, // int16_t* bitstream,
// int16_t len, // int16_t len,
// int16_t* output); // int16_t* output);
// int16_t WebRtcG7221C_Decode48(G722_1C_48_decinst_t_* decInst, // int16_t WebRtcG7221C_Decode48(G722_1C_48_decinst_t_* dec_inst,
// int16_t* bitstream, // int16_t* bitstream,
// int16_t len, // int16_t len,
// int16_t* output); // int16_t* output);
// //
// int16_t WebRtcG7221C_DecodePlc24(G722_1C_24_decinst_t_* decInst, // int16_t WebRtcG7221C_DecodePlc24(G722_1C_24_decinst_t_* dec_inst,
// int16_t* output, // int16_t* output,
// int16_t nrLostFrames); // int16_t nr_lost_frames);
// int16_t WebRtcG7221C_DecodePlc32(G722_1C_32_decinst_t_* decInst, // int16_t WebRtcG7221C_DecodePlc32(G722_1C_32_decinst_t_* dec_inst,
// int16_t* output, // int16_t* output,
// int16_t nrLostFrames); // int16_t nr_lost_frames);
// int16_t WebRtcG7221C_DecodePlc48(G722_1C_48_decinst_t_* decInst, // int16_t WebRtcG7221C_DecodePlc48(G722_1C_48_decinst_t_* dec_inst,
// int16_t* output, // int16_t* output,
// int16_t nrLostFrames); // int16_t nr_lost_frames);
#include "g7221c_interface.h" #include "g7221c_interface.h"
#endif #endif
@ -87,20 +89,20 @@ namespace webrtc {
#ifndef WEBRTC_CODEC_G722_1C #ifndef WEBRTC_CODEC_G722_1C
ACMG722_1C::ACMG722_1C(WebRtc_Word16 /* codecID */) ACMG722_1C::ACMG722_1C(WebRtc_Word16 /* codec_id */)
: _operationalRate(-1), : operational_rate_(-1),
_encoderInstPtr(NULL), encoder_inst_ptr_(NULL),
_encoderInstPtrRight(NULL), encoder_inst_ptr_right_(NULL),
_decoderInstPtr(NULL), decoder_inst_ptr_(NULL),
_encoderInst24Ptr(NULL), encoder_inst24_ptr_(NULL),
_encoderInst24PtrR(NULL), encoder_inst24_ptr_right_(NULL),
_encoderInst32Ptr(NULL), encoder_inst32_ptr_(NULL),
_encoderInst32PtrR(NULL), encoder_inst32_ptr_right_(NULL),
_encoderInst48Ptr(NULL), encoder_inst48_ptr_(NULL),
_encoderInst48PtrR(NULL), encoder_inst48_ptr_right_(NULL),
_decoderInst24Ptr(NULL), decoder_inst24_ptr_(NULL),
_decoderInst32Ptr(NULL), decoder_inst32_ptr_(NULL),
_decoderInst48Ptr(NULL) { decoder_inst48_ptr_(NULL) {
return; return;
} }
@ -109,31 +111,31 @@ ACMG722_1C::~ACMG722_1C() {
} }
WebRtc_Word16 ACMG722_1C::InternalEncode( WebRtc_Word16 ACMG722_1C::InternalEncode(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_Word16* /* bitstream_len_byte */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG722_1C::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG722_1C::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG722_1C::InternalInitEncoder( WebRtc_Word16 ACMG722_1C::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG722_1C::InternalInitDecoder( WebRtc_Word16 ACMG722_1C::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -157,66 +159,74 @@ void ACMG722_1C::DestructDecoderSafe() {
return; return;
} }
void ACMG722_1C::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMG722_1C::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMG722_1C::ACMG722_1C(WebRtc_Word16 codecID) : ACMG722_1C::ACMG722_1C(WebRtc_Word16 codec_id)
_encoderInstPtr(NULL), _encoderInstPtrRight(NULL), _decoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_encoderInst24Ptr(NULL), _encoderInst24PtrR(NULL), _encoderInst32Ptr(NULL), encoder_inst_ptr_right_(NULL),
_encoderInst32PtrR(NULL), _encoderInst48Ptr(NULL), _encoderInst48PtrR(NULL), decoder_inst_ptr_(NULL),
_decoderInst24Ptr(NULL), _decoderInst32Ptr(NULL), _decoderInst48Ptr(NULL) { encoder_inst24_ptr_(NULL),
_codecID = codecID; encoder_inst24_ptr_right_(NULL),
if (_codecID == ACMCodecDB::kG722_1C_24) { encoder_inst32_ptr_(NULL),
_operationalRate = 24000; encoder_inst32_ptr_right_(NULL),
} else if (_codecID == ACMCodecDB::kG722_1C_32) { encoder_inst48_ptr_(NULL),
_operationalRate = 32000; encoder_inst48_ptr_right_(NULL),
} else if (_codecID == ACMCodecDB::kG722_1C_48) { decoder_inst24_ptr_(NULL),
_operationalRate = 48000; decoder_inst32_ptr_(NULL),
decoder_inst48_ptr_(NULL) {
codec_id_ = codec_id;
if (codec_id_ == ACMCodecDB::kG722_1C_24) {
operational_rate_ = 24000;
} else if (codec_id_ == ACMCodecDB::kG722_1C_32) {
operational_rate_ = 32000;
} else if (codec_id_ == ACMCodecDB::kG722_1C_48) {
operational_rate_ = 48000;
} else { } else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Wrong codec id for G722_1c."); "Wrong codec id for G722_1c.");
_operationalRate = -1; operational_rate_ = -1;
} }
return; return;
} }
ACMG722_1C::~ACMG722_1C() { ACMG722_1C::~ACMG722_1C() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
delete _encoderInstPtr; delete encoder_inst_ptr_;
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
if (_encoderInstPtrRight != NULL) { if (encoder_inst_ptr_right_ != NULL) {
delete _encoderInstPtrRight; delete encoder_inst_ptr_right_;
_encoderInstPtrRight = NULL; encoder_inst_ptr_right_ = NULL;
} }
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
delete _decoderInstPtr; delete decoder_inst_ptr_;
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
switch (_operationalRate) { switch (operational_rate_) {
case 24000: { case 24000: {
_encoderInst24Ptr = NULL; encoder_inst24_ptr_ = NULL;
_encoderInst24PtrR = NULL; encoder_inst24_ptr_right_ = NULL;
_decoderInst24Ptr = NULL; decoder_inst24_ptr_ = NULL;
break; break;
} }
case 32000: { case 32000: {
_encoderInst32Ptr = NULL; encoder_inst32_ptr_ = NULL;
_encoderInst32PtrR = NULL; encoder_inst32_ptr_right_ = NULL;
_decoderInst32Ptr = NULL; decoder_inst32_ptr_ = NULL;
break; break;
} }
case 48000: { case 48000: {
_encoderInst48Ptr = NULL; encoder_inst48_ptr_ = NULL;
_encoderInst48PtrR = NULL; encoder_inst48_ptr_right_ = NULL;
_decoderInst48Ptr = NULL; decoder_inst48_ptr_ = NULL;
break; break;
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Wrong rate for G722_1c."); "Wrong rate for G722_1c.");
break; break;
} }
@ -224,104 +234,107 @@ ACMG722_1C::~ACMG722_1C() {
return; return;
} }
WebRtc_Word16 ACMG722_1C::InternalEncode(WebRtc_UWord8* bitStream, WebRtc_Word16 ACMG722_1C::InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte) { WebRtc_Word16* bitstream_len_byte) {
WebRtc_Word16 leftChannel[640]; WebRtc_Word16 left_channel[640];
WebRtc_Word16 rightChannel[640]; WebRtc_Word16 right_channel[640];
WebRtc_Word16 lenInBytes; WebRtc_Word16 len_in_bytes;
WebRtc_Word16 outB[240]; WebRtc_Word16 out_bits[240];
// If stereo, split input signal in left and right channel before encoding // If stereo, split input signal in left and right channel before encoding
if (_noChannels == 2) { if (num_channels_ == 2) {
for (int i = 0, j = 0; i < _frameLenSmpl * 2; i += 2, j++) { for (int i = 0, j = 0; i < frame_len_smpl_ * 2; i += 2, j++) {
leftChannel[j] = _inAudio[_inAudioIxRead + i]; left_channel[j] = in_audio_[in_audio_ix_read_ + i];
rightChannel[j] = _inAudio[_inAudioIxRead + i + 1]; right_channel[j] = in_audio_[in_audio_ix_read_ + i + 1];
} }
} else { } else {
memcpy(leftChannel, &_inAudio[_inAudioIxRead], 640); memcpy(left_channel, &in_audio_[in_audio_ix_read_], 640);
} }
switch (_operationalRate) { switch (operational_rate_) {
case 24000: { case 24000: {
lenInBytes = WebRtcG7221C_Encode24(_encoderInst24Ptr, leftChannel, 640, len_in_bytes = WebRtcG7221C_Encode24(encoder_inst24_ptr_, left_channel,
&outB[0]); 640, &out_bits[0]);
if (_noChannels == 2) { if (num_channels_ == 2) {
lenInBytes += WebRtcG7221C_Encode24(_encoderInst24PtrR, rightChannel, len_in_bytes += WebRtcG7221C_Encode24(encoder_inst24_ptr_right_,
640, &outB[lenInBytes / 2]); right_channel, 640,
&out_bits[len_in_bytes / 2]);
} }
break; break;
} }
case 32000: { case 32000: {
lenInBytes = WebRtcG7221C_Encode32(_encoderInst32Ptr, leftChannel, 640, len_in_bytes = WebRtcG7221C_Encode32(encoder_inst32_ptr_, left_channel,
&outB[0]); 640, &out_bits[0]);
if (_noChannels == 2) { if (num_channels_ == 2) {
lenInBytes += WebRtcG7221C_Encode32(_encoderInst32PtrR, rightChannel, len_in_bytes += WebRtcG7221C_Encode32(encoder_inst32_ptr_right_,
640, &outB[lenInBytes / 2]); right_channel, 640,
&out_bits[len_in_bytes / 2]);
} }
break; break;
} }
case 48000: { case 48000: {
lenInBytes = WebRtcG7221C_Encode48(_encoderInst48Ptr, leftChannel, 640, len_in_bytes = WebRtcG7221C_Encode48(encoder_inst48_ptr_, left_channel,
&outB[0]); 640, &out_bits[0]);
if (_noChannels == 2) { if (num_channels_ == 2) {
lenInBytes += WebRtcG7221C_Encode48(_encoderInst48PtrR, rightChannel, len_in_bytes += WebRtcG7221C_Encode48(encoder_inst48_ptr_right_,
640, &outB[lenInBytes / 2]); right_channel, 640,
&out_bits[len_in_bytes / 2]);
} }
break; break;
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalEncode: Wrong rate for G722_1c."); "InternalEncode: Wrong rate for G722_1c.");
return -1; return -1;
} }
} }
memcpy(bitStream, outB, lenInBytes); memcpy(bitstream, out_bits, len_in_bytes);
*bitStreamLenByte = lenInBytes; *bitstream_len_byte = len_in_bytes;
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += 640 * _noChannels; in_audio_ix_read_ += 640 * num_channels_;
return *bitStreamLenByte; return *bitstream_len_byte;
} }
WebRtc_Word16 ACMG722_1C::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG722_1C::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMG722_1C::InternalInitEncoder( WebRtc_Word16 ACMG722_1C::InternalInitEncoder(
WebRtcACMCodecParams* codecParams) { WebRtcACMCodecParams* codec_params) {
WebRtc_Word16 ret; WebRtc_Word16 ret;
switch (_operationalRate) { switch (operational_rate_) {
case 24000: { case 24000: {
ret = WebRtcG7221C_EncoderInit24(_encoderInst24PtrR); ret = WebRtcG7221C_EncoderInit24(encoder_inst24_ptr_right_);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
return WebRtcG7221C_EncoderInit24(_encoderInst24Ptr); return WebRtcG7221C_EncoderInit24(encoder_inst24_ptr_);
} }
case 32000: { case 32000: {
ret = WebRtcG7221C_EncoderInit32(_encoderInst32PtrR); ret = WebRtcG7221C_EncoderInit32(encoder_inst32_ptr_right_);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
return WebRtcG7221C_EncoderInit32(_encoderInst32Ptr); return WebRtcG7221C_EncoderInit32(encoder_inst32_ptr_);
} }
case 48000: { case 48000: {
ret = WebRtcG7221C_EncoderInit48(_encoderInst48PtrR); ret = WebRtcG7221C_EncoderInit48(encoder_inst48_ptr_right_);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
return WebRtcG7221C_EncoderInit48(_encoderInst48Ptr); return WebRtcG7221C_EncoderInit48(encoder_inst48_ptr_);
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalInitEncode: Wrong rate for G722_1c."); "InternalInitEncode: Wrong rate for G722_1c.");
return -1; return -1;
} }
@ -329,30 +342,29 @@ WebRtc_Word16 ACMG722_1C::InternalInitEncoder(
} }
WebRtc_Word16 ACMG722_1C::InternalInitDecoder( WebRtc_Word16 ACMG722_1C::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
switch (_operationalRate) { switch (operational_rate_) {
case 24000: { case 24000: {
return WebRtcG7221C_DecoderInit24(_decoderInst24Ptr); return WebRtcG7221C_DecoderInit24(decoder_inst24_ptr_);
} }
case 32000: { case 32000: {
return WebRtcG7221C_DecoderInit32(_decoderInst32Ptr); return WebRtcG7221C_DecoderInit32(decoder_inst32_ptr_);
} }
case 48000: { case 48000: {
return WebRtcG7221C_DecoderInit48(_decoderInst48Ptr); return WebRtcG7221C_DecoderInit48(decoder_inst48_ptr_);
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalInitDecoder: Wrong rate for G722_1c."); "InternalInitDecoder: Wrong rate for G722_1c.");
return -1; return -1;
} }
} }
} }
WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!decoder_initialized_) {
if (!_decoderInitialized) { WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodeDef: decoder not initialized for G722_1c"); "CodeDef: decoder not initialized for G722_1c");
return -1; return -1;
} }
@ -364,27 +376,27 @@ WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
// "SET_CODEC_PAR" & "SET_G722_1_XX_FUNCTION." // "SET_CODEC_PAR" & "SET_G722_1_XX_FUNCTION."
// Then return the structure back to NetEQ to add the codec to it's // Then return the structure back to NetEQ to add the codec to it's
// database. // database.
switch (_operationalRate) { switch (operational_rate_) {
case 24000: { case 24000: {
SET_CODEC_PAR((codecDef), kDecoderG722_1C_24, codecInst.pltype, SET_CODEC_PAR((codec_def), kDecoderG722_1C_24, codec_inst.pltype,
_decoderInst24Ptr, 32000); decoder_inst24_ptr_, 32000);
SET_G722_1C_24_FUNCTIONS((codecDef)); SET_G722_1C_24_FUNCTIONS((codec_def));
break; break;
} }
case 32000: { case 32000: {
SET_CODEC_PAR((codecDef), kDecoderG722_1C_32, codecInst.pltype, SET_CODEC_PAR((codec_def), kDecoderG722_1C_32, codec_inst.pltype,
_decoderInst32Ptr, 32000); decoder_inst32_ptr_, 32000);
SET_G722_1C_32_FUNCTIONS((codecDef)); SET_G722_1C_32_FUNCTIONS((codec_def));
break; break;
} }
case 48000: { case 48000: {
SET_CODEC_PAR((codecDef), kDecoderG722_1C_32, codecInst.pltype, SET_CODEC_PAR((codec_def), kDecoderG722_1C_32, codec_inst.pltype,
_decoderInst48Ptr, 32000); decoder_inst48_ptr_, 32000);
SET_G722_1C_48_FUNCTIONS((codecDef)); SET_G722_1C_48_FUNCTIONS((codec_def));
break; break;
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"CodeDef: Wrong rate for G722_1c."); "CodeDef: Wrong rate for G722_1c.");
return -1; return -1;
} }
@ -398,27 +410,27 @@ ACMG722_1C::CreateInstance(void) {
} }
WebRtc_Word16 ACMG722_1C::InternalCreateEncoder() { WebRtc_Word16 ACMG722_1C::InternalCreateEncoder() {
if ((_encoderInstPtr == NULL) || (_encoderInstPtrRight == NULL)) { if ((encoder_inst_ptr_ == NULL) || (encoder_inst_ptr_right_ == NULL)) {
return -1; return -1;
} }
switch (_operationalRate) { switch (operational_rate_) {
case 24000: { case 24000: {
WebRtcG7221C_CreateEnc24(&_encoderInst24Ptr); WebRtcG7221C_CreateEnc24(&encoder_inst24_ptr_);
WebRtcG7221C_CreateEnc24(&_encoderInst24PtrR); WebRtcG7221C_CreateEnc24(&encoder_inst24_ptr_right_);
break; break;
} }
case 32000: { case 32000: {
WebRtcG7221C_CreateEnc32(&_encoderInst32Ptr); WebRtcG7221C_CreateEnc32(&encoder_inst32_ptr_);
WebRtcG7221C_CreateEnc32(&_encoderInst32PtrR); WebRtcG7221C_CreateEnc32(&encoder_inst32_ptr_right_);
break; break;
} }
case 48000: { case 48000: {
WebRtcG7221C_CreateEnc48(&_encoderInst48Ptr); WebRtcG7221C_CreateEnc48(&encoder_inst48_ptr_);
WebRtcG7221C_CreateEnc48(&_encoderInst48PtrR); WebRtcG7221C_CreateEnc48(&encoder_inst48_ptr_right_);
break; break;
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateEncoder: Wrong rate for G722_1c."); "InternalCreateEncoder: Wrong rate for G722_1c.");
return -1; return -1;
} }
@ -427,42 +439,42 @@ WebRtc_Word16 ACMG722_1C::InternalCreateEncoder() {
} }
void ACMG722_1C::DestructEncoderSafe() { void ACMG722_1C::DestructEncoderSafe() {
_encoderExist = false; encoder_exist_ = false;
_encoderInitialized = false; encoder_initialized_ = false;
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
delete _encoderInstPtr; delete encoder_inst_ptr_;
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
if (_encoderInstPtrRight != NULL) { if (encoder_inst_ptr_right_ != NULL) {
delete _encoderInstPtrRight; delete encoder_inst_ptr_right_;
_encoderInstPtrRight = NULL; encoder_inst_ptr_right_ = NULL;
} }
_encoderInst24Ptr = NULL; encoder_inst24_ptr_ = NULL;
_encoderInst32Ptr = NULL; encoder_inst32_ptr_ = NULL;
_encoderInst48Ptr = NULL; encoder_inst48_ptr_ = NULL;
} }
WebRtc_Word16 ACMG722_1C::InternalCreateDecoder() { WebRtc_Word16 ACMG722_1C::InternalCreateDecoder() {
if (_decoderInstPtr == NULL) { if (decoder_inst_ptr_ == NULL) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateEncoder: cannot create decoder"); "InternalCreateEncoder: cannot create decoder");
return -1; return -1;
} }
switch (_operationalRate) { switch (operational_rate_) {
case 24000: { case 24000: {
WebRtcG7221C_CreateDec24(&_decoderInst24Ptr); WebRtcG7221C_CreateDec24(&decoder_inst24_ptr_);
break; break;
} }
case 32000: { case 32000: {
WebRtcG7221C_CreateDec32(&_decoderInst32Ptr); WebRtcG7221C_CreateDec32(&decoder_inst32_ptr_);
break; break;
} }
case 48000: { case 48000: {
WebRtcG7221C_CreateDec48(&_decoderInst48Ptr); WebRtcG7221C_CreateDec48(&decoder_inst48_ptr_);
break; break;
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateEncoder: Wrong rate for G722_1c."); "InternalCreateEncoder: Wrong rate for G722_1c.");
return -1; return -1;
} }
@ -471,24 +483,24 @@ WebRtc_Word16 ACMG722_1C::InternalCreateDecoder() {
} }
void ACMG722_1C::DestructDecoderSafe() { void ACMG722_1C::DestructDecoderSafe() {
_decoderExist = false; decoder_exist_ = false;
_decoderInitialized = false; decoder_initialized_ = false;
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
delete _decoderInstPtr; delete decoder_inst_ptr_;
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
_decoderInst24Ptr = NULL; decoder_inst24_ptr_ = NULL;
_decoderInst32Ptr = NULL; decoder_inst32_ptr_ = NULL;
_decoderInst48Ptr = NULL; decoder_inst48_ptr_ = NULL;
} }
void ACMG722_1C::InternalDestructEncoderInst(void* ptrInst) { void ACMG722_1C::InternalDestructEncoderInst(void* ptr_inst) {
if (ptrInst != NULL) { if (ptr_inst != NULL) {
delete ptrInst; delete ptr_inst;
} }
return; return;
} }
#endif #endif
} // namespace webrtc } // namespace webrtc

View File

@ -8,10 +8,10 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7221C_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7221C_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
// forward declaration // forward declaration
struct G722_1C_24_encinst_t_; struct G722_1C_24_encinst_t_;
@ -24,67 +24,67 @@ struct G722_1_Inst_t_;
namespace webrtc { namespace webrtc {
class ACMG722_1C : public ACMGenericCodec class ACMG722_1C : public ACMGenericCodec {
{ public:
public: explicit ACMG722_1C(WebRtc_Word16 codec_id);
ACMG722_1C(WebRtc_Word16 codecID); ~ACMG722_1C();
~ACMG722_1C();
// for FEC
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( // for FEC
WebRtc_UWord8* bitstream, ACMGenericCodec* CreateInstance(void);
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalEncode(
WebRtcACMCodecParams *codecParams); WebRtc_UWord8* bitstream,
WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitEncoder(
WebRtcACMCodecParams *codecParams); WebRtcACMCodecParams *codec_params);
protected: WebRtc_Word16 InternalInitDecoder(
WebRtc_Word16 DecodeSafe( WebRtcACMCodecParams *codec_params);
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( protected:
WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word16 DecodeSafe(
const CodecInst& codecInst); WebRtc_UWord8* bitstream,
WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio,
WebRtc_Word16* audio_samples,
WebRtc_Word8* speech_type);
void DestructEncoderSafe(); WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codec_inst);
void DestructDecoderSafe(); void DestructEncoderSafe();
WebRtc_Word16 InternalCreateEncoder(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateEncoder();
void InternalDestructEncoderInst( WebRtc_Word16 InternalCreateDecoder();
void* ptrInst);
WebRtc_Word32 _operationalRate; void InternalDestructEncoderInst(
void* ptr_inst);
G722_1_Inst_t_* _encoderInstPtr; WebRtc_Word32 operational_rate_;
G722_1_Inst_t_* _encoderInstPtrRight; //Used in stereo mode
G722_1_Inst_t_* _decoderInstPtr;
// Only one set of these pointer is valid at any instance G722_1_Inst_t_* encoder_inst_ptr_;
G722_1C_24_encinst_t_* _encoderInst24Ptr; G722_1_Inst_t_* encoder_inst_ptr_right_; // Used in stereo mode
G722_1C_24_encinst_t_* _encoderInst24PtrR; G722_1_Inst_t_* decoder_inst_ptr_;
G722_1C_32_encinst_t_* _encoderInst32Ptr;
G722_1C_32_encinst_t_* _encoderInst32PtrR;
G722_1C_48_encinst_t_* _encoderInst48Ptr;
G722_1C_48_encinst_t_* _encoderInst48PtrR;
// Only one of these pointer is valid at any instance // Only one set of these pointer is valid at any instance
G722_1C_24_decinst_t_* _decoderInst24Ptr; G722_1C_24_encinst_t_* encoder_inst24_ptr_;
G722_1C_32_decinst_t_* _decoderInst32Ptr; G722_1C_24_encinst_t_* encoder_inst24_ptr_right_;
G722_1C_48_decinst_t_* _decoderInst48Ptr; G722_1C_32_encinst_t_* encoder_inst32_ptr_;
G722_1C_32_encinst_t_* encoder_inst32_ptr_right_;
G722_1C_48_encinst_t_* encoder_inst48_ptr_;
G722_1C_48_encinst_t_* encoder_inst48_ptr_right_;
// Only one of these pointer is valid at any instance
G722_1C_24_decinst_t_* decoder_inst24_ptr_;
G722_1C_32_decinst_t_* decoder_inst32_ptr_;
G722_1C_48_decinst_t_* decoder_inst48_ptr_;
}; };
} // namespace webrtc; } // namespace webrtc;
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_ #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7221C_H_

View File

@ -8,12 +8,13 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_g729.h" #include "webrtc/modules/audio_coding/main/source/acm_g729.h"
#include "acm_common_defs.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "trace.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc/system_wrappers/interface/trace.h"
#ifdef WEBRTC_CODEC_G729 #ifdef WEBRTC_CODEC_G729
// NOTE! G.729 is not included in the open-source package. Modify this file // NOTE! G.729 is not included in the open-source package. Modify this file
@ -26,9 +27,9 @@ namespace webrtc {
#ifndef WEBRTC_CODEC_G729 #ifndef WEBRTC_CODEC_G729
ACMG729::ACMG729(WebRtc_Word16 /* codecID */) ACMG729::ACMG729(WebRtc_Word16 /* codec_id */)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL) { decoder_inst_ptr_(NULL) {
return; return;
} }
@ -36,8 +37,9 @@ ACMG729::~ACMG729() {
return; return;
} }
WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG729::InternalEncode(
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitstream_len_byte */) {
return -1; return -1;
} }
@ -50,35 +52,35 @@ WebRtc_Word16 ACMG729::DisableDTX() {
} }
WebRtc_Word32 ACMG729::ReplaceInternalDTXSafe( WebRtc_Word32 ACMG729::ReplaceInternalDTXSafe(
const bool /*replaceInternalDTX*/) { const bool /*replace_internal_dtx */) {
return -1; return -1;
} }
WebRtc_Word32 ACMG729::IsInternalDTXReplacedSafe( WebRtc_Word32 ACMG729::IsInternalDTXReplacedSafe(
bool* /* internalDTXReplaced */) { bool* /* internal_dtx_replaced */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG729::InternalInitEncoder( WebRtc_Word16 ACMG729::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG729::InternalInitDecoder( WebRtc_Word16 ACMG729::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -102,63 +104,63 @@ void ACMG729::DestructDecoderSafe() {
return; return;
} }
void ACMG729::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMG729::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMG729::ACMG729(WebRtc_Word16 codecID) ACMG729::ACMG729(WebRtc_Word16 codec_id)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL) { decoder_inst_ptr_(NULL) {
_codecID = codecID; codec_id_ = codec_id;
_hasInternalDTX = true; has_internal_dtx_ = true;
return; return;
} }
ACMG729::~ACMG729() { ACMG729::~ACMG729() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
// Delete encoder memory // Delete encoder memory
WebRtcG729_FreeEnc(_encoderInstPtr); WebRtcG729_FreeEnc(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
// Delete decoder memory // Delete decoder memory
WebRtcG729_FreeDec(_decoderInstPtr); WebRtcG729_FreeDec(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
return; return;
} }
WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* bitStream, WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte) { WebRtc_Word16* bitstream_len_byte) {
// Initialize before entering the loop // Initialize before entering the loop
WebRtc_Word16 noEncodedSamples = 0; WebRtc_Word16 num_encoded_samples = 0;
WebRtc_Word16 tmpLenByte = 0; WebRtc_Word16 tmp_len_byte = 0;
WebRtc_Word16 vadDecision = 0; WebRtc_Word16 vad_decision = 0;
*bitStreamLenByte = 0; *bitstream_len_byte = 0;
while (noEncodedSamples < _frameLenSmpl) { while (num_encoded_samples < frame_len_smpl_) {
// Call G.729 encoder with pointer to encoder memory, input // Call G.729 encoder with pointer to encoder memory, input
// audio, number of samples and bitsream // audio, number of samples and bitsream
tmpLenByte = WebRtcG729_Encode( tmp_len_byte = WebRtcG729_Encode(
_encoderInstPtr, &_inAudio[_inAudioIxRead], 80, encoder_inst_ptr_, &in_audio_[in_audio_ix_read_], 80,
(WebRtc_Word16*) (&(bitStream[*bitStreamLenByte]))); (WebRtc_Word16*)(&(bitstream[*bitstream_len_byte])));
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += 80; in_audio_ix_read_ += 80;
// sanity check // sanity check
if (tmpLenByte < 0) { if (tmp_len_byte < 0) {
// error has happened // error has happened
*bitStreamLenByte = 0; *bitstream_len_byte = 0;
return -1; return -1;
} }
// increment number of written bytes // increment number of written bytes
*bitStreamLenByte += tmpLenByte; *bitstream_len_byte += tmp_len_byte;
switch (tmpLenByte) { switch (tmp_len_byte) {
case 0: { case 0: {
if (0 == noEncodedSamples) { if (0 == num_encoded_samples) {
// this is the first 10 ms in this packet and there is // this is the first 10 ms in this packet and there is
// no data generated, perhaps DTX is enabled and the // no data generated, perhaps DTX is enabled and the
// codec is not generating any bit-stream for this 10 ms. // codec is not generating any bit-stream for this 10 ms.
@ -169,18 +171,18 @@ WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* bitStream,
} }
case 2: { case 2: {
// check if G.729 internal DTX is enabled // check if G.729 internal DTX is enabled
if (_hasInternalDTX && _dtxEnabled) { if (has_internal_dtx_ && dtx_enabled_) {
vadDecision = 0; vad_decision = 0;
for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) { for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
_vadLabel[n] = vadDecision; vad_label_[n] = vad_decision;
} }
} }
// we got a SID and have to send out this packet no matter // we got a SID and have to send out this packet no matter
// how much audio we have encoded // how much audio we have encoded
return *bitStreamLenByte; return *bitstream_len_byte;
} }
case 10: { case 10: {
vadDecision = 1; vad_decision = 1;
// this is a valid length just continue encoding // this is a valid length just continue encoding
break; break;
} }
@ -190,30 +192,30 @@ WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* bitStream,
} }
// update number of encoded samples // update number of encoded samples
noEncodedSamples += 80; num_encoded_samples += 80;
} }
// update VAD decision vector // update VAD decision vector
if (_hasInternalDTX && !vadDecision && _dtxEnabled) { if (has_internal_dtx_ && !vad_decision && dtx_enabled_) {
for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) { for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
_vadLabel[n] = vadDecision; vad_label_[n] = vad_decision;
} }
} }
// done encoding, return number of encoded bytes // done encoding, return number of encoded bytes
return *bitStreamLenByte; return *bitstream_len_byte;
} }
WebRtc_Word16 ACMG729::EnableDTX() { WebRtc_Word16 ACMG729::EnableDTX() {
if (_dtxEnabled) { if (dtx_enabled_) {
// DTX already enabled, do nothing // DTX already enabled, do nothing
return 0; return 0;
} else if (_encoderExist) { } else if (encoder_exist_) {
// Re-init the G.729 encoder to turn on DTX // Re-init the G.729 encoder to turn on DTX
if (WebRtcG729_EncoderInit(_encoderInstPtr, 1) < 0) { if (WebRtcG729_EncoderInit(encoder_inst_ptr_, 1) < 0) {
return -1; return -1;
} }
_dtxEnabled = true; dtx_enabled_ = true;
return 0; return 0;
} else { } else {
return -1; return -1;
@ -221,15 +223,15 @@ WebRtc_Word16 ACMG729::EnableDTX() {
} }
WebRtc_Word16 ACMG729::DisableDTX() { WebRtc_Word16 ACMG729::DisableDTX() {
if (!_dtxEnabled) { if (!dtx_enabled_) {
// DTX already dissabled, do nothing // DTX already dissabled, do nothing
return 0; return 0;
} else if (_encoderExist) { } else if (encoder_exist_) {
// Re-init the G.729 decoder to turn off DTX // Re-init the G.729 decoder to turn off DTX
if (WebRtcG729_EncoderInit(_encoderInstPtr, 0) < 0) { if (WebRtcG729_EncoderInit(encoder_inst_ptr_, 0) < 0) {
return -1; return -1;
} }
_dtxEnabled = false; dtx_enabled_ = false;
return 0; return 0;
} else { } else {
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless
@ -237,67 +239,67 @@ WebRtc_Word16 ACMG729::DisableDTX() {
} }
} }
WebRtc_Word32 ACMG729::ReplaceInternalDTXSafe(const bool replaceInternalDTX) { WebRtc_Word32 ACMG729::ReplaceInternalDTXSafe(const bool replace_internal_dtx) {
// This function is used to disable the G.729 built in DTX and use an // This function is used to disable the G.729 built in DTX and use an
// external instead. // external instead.
if (replaceInternalDTX == _hasInternalDTX) { if (replace_internal_dtx == has_internal_dtx_) {
// Make sure we keep the DTX/VAD setting if possible // Make sure we keep the DTX/VAD setting if possible
bool oldEnableDTX = _dtxEnabled; bool old_enable_dtx = dtx_enabled_;
bool oldEnableVAD = _vadEnabled; bool old_enable_vad = vad_enabled_;
ACMVADMode oldMode = _vadMode; ACMVADMode old_mode = vad_mode_;
if (replaceInternalDTX) { if (replace_internal_dtx) {
// Disable internal DTX before enabling external DTX // Disable internal DTX before enabling external DTX
DisableDTX(); DisableDTX();
} else { } else {
// Disable external DTX before enabling internal // Disable external DTX before enabling internal
ACMGenericCodec::DisableDTX(); ACMGenericCodec::DisableDTX();
} }
_hasInternalDTX = !replaceInternalDTX; has_internal_dtx_ = !replace_internal_dtx;
WebRtc_Word16 status = SetVADSafe(oldEnableDTX, oldEnableVAD, oldMode); WebRtc_Word16 status = SetVADSafe(old_enable_dtx, old_enable_vad, old_mode);
// Check if VAD status has changed from inactive to active, or if error was // Check if VAD status has changed from inactive to active, or if error was
// reported // reported
if (status == 1) { if (status == 1) {
_vadEnabled = true; vad_enabled_ = true;
return status; return status;
} else if (status < 0) { } else if (status < 0) {
_hasInternalDTX = replaceInternalDTX; has_internal_dtx_ = replace_internal_dtx;
return -1; return -1;
} }
} }
return 0; return 0;
} }
WebRtc_Word32 ACMG729::IsInternalDTXReplacedSafe(bool* internalDTXReplaced) { WebRtc_Word32 ACMG729::IsInternalDTXReplacedSafe(bool* internal_dtx_replaced) {
// Get status of wether DTX is replaced or not // Get status of wether DTX is replaced or not
*internalDTXReplaced = !_hasInternalDTX; *internal_dtx_replaced = !has_internal_dtx_;
return 0; return 0;
} }
WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
// This function is not used. G.729 decoder is called from inside NetEQ // This function is not used. G.729 decoder is called from inside NetEQ
return 0; return 0;
} }
WebRtc_Word16 ACMG729::InternalInitEncoder(WebRtcACMCodecParams* codecParams) { WebRtc_Word16 ACMG729::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
// Init G.729 encoder // Init G.729 encoder
return WebRtcG729_EncoderInit(_encoderInstPtr, return WebRtcG729_EncoderInit(encoder_inst_ptr_,
((codecParams->enableDTX) ? 1 : 0)); ((codec_params->enable_dtx) ? 1 : 0));
} }
WebRtc_Word16 ACMG729::InternalInitDecoder( WebRtc_Word16 ACMG729::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
// Init G.729 decoder // Init G.729 decoder
return WebRtcG729_DecoderInit(_decoderInstPtr); return WebRtcG729_DecoderInit(decoder_inst_ptr_);
} }
WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!_decoderInitialized) { if (!decoder_initialized_) {
// Todo: // Todo:
// log error // log error
return -1; return -1;
@ -307,9 +309,9 @@ WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
// "SET_CODEC_PAR" & "SET_G729_FUNCTION." // "SET_CODEC_PAR" & "SET_G729_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
SET_CODEC_PAR((codecDef), kDecoderG729, codecInst.pltype, _decoderInstPtr, SET_CODEC_PAR((codec_def), kDecoderG729, codec_inst.pltype, decoder_inst_ptr_,
8000); 8000);
SET_G729_FUNCTIONS((codecDef)); SET_G729_FUNCTIONS((codec_def));
return 0; return 0;
} }
@ -320,37 +322,37 @@ ACMGenericCodec* ACMG729::CreateInstance(void) {
WebRtc_Word16 ACMG729::InternalCreateEncoder() { WebRtc_Word16 ACMG729::InternalCreateEncoder() {
// Create encoder memory // Create encoder memory
return WebRtcG729_CreateEnc(&_encoderInstPtr); return WebRtcG729_CreateEnc(&encoder_inst_ptr_);
} }
void ACMG729::DestructEncoderSafe() { void ACMG729::DestructEncoderSafe() {
// Free encoder memory // Free encoder memory
_encoderExist = false; encoder_exist_ = false;
_encoderInitialized = false; encoder_initialized_ = false;
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcG729_FreeEnc(_encoderInstPtr); WebRtcG729_FreeEnc(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
} }
WebRtc_Word16 ACMG729::InternalCreateDecoder() { WebRtc_Word16 ACMG729::InternalCreateDecoder() {
// Create decoder memory // Create decoder memory
return WebRtcG729_CreateDec(&_decoderInstPtr); return WebRtcG729_CreateDec(&decoder_inst_ptr_);
} }
void ACMG729::DestructDecoderSafe() { void ACMG729::DestructDecoderSafe() {
// Free decoder memory // Free decoder memory
_decoderExist = false; decoder_exist_ = false;
_decoderInitialized = false; decoder_initialized_ = false;
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcG729_FreeDec(_decoderInstPtr); WebRtcG729_FreeDec(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
} }
void ACMG729::InternalDestructEncoderInst(void* ptrInst) { void ACMG729::InternalDestructEncoderInst(void* ptr_inst) {
if (ptrInst != NULL) { if (ptr_inst != NULL) {
WebRtcG729_FreeEnc((G729_encinst_t_*) ptrInst); WebRtcG729_FreeEnc((G729_encinst_t_*) ptr_inst);
} }
return; return;
} }

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
// forward declaration // forward declaration
struct G729_encinst_t_; struct G729_encinst_t_;
@ -21,27 +21,28 @@ namespace webrtc {
class ACMG729 : public ACMGenericCodec { class ACMG729 : public ACMGenericCodec {
public: public:
ACMG729(WebRtc_Word16 codecID); explicit ACMG729(WebRtc_Word16 codec_id);
~ACMG729(); ~ACMG729();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -51,18 +52,18 @@ class ACMG729 : public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
WebRtc_Word16 EnableDTX(); WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX(); WebRtc_Word16 DisableDTX();
WebRtc_Word32 ReplaceInternalDTXSafe(const bool replaceInternalDTX); WebRtc_Word32 ReplaceInternalDTXSafe(const bool replace_internal_dtx);
WebRtc_Word32 IsInternalDTXReplacedSafe(bool* internalDTXReplaced); WebRtc_Word32 IsInternalDTXReplacedSafe(bool* internal_dtx_replaced);
G729_encinst_t_* _encoderInstPtr; G729_encinst_t_* encoder_inst_ptr_;
G729_decinst_t_* _decoderInstPtr; G729_decinst_t_* decoder_inst_ptr_;
}; };

View File

@ -8,30 +8,30 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_g7291.h" #include "webrtc/modules/audio_coding/main/source/acm_g7291.h"
#include "acm_common_defs.h"
#include "acm_neteq.h"
#include "trace.h"
#include "webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h"
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc/system_wrappers/interface/trace.h"
#ifdef WEBRTC_CODEC_G729_1 #ifdef WEBRTC_CODEC_G729_1
// NOTE! G.729.1 is not included in the open-source package. Modify this file // NOTE! G.729.1 is not included in the open-source package. Modify this file
// or your codec API to match the function calls and names of used G.729.1 API // or your codec API to match the function calls and names of used G.729.1 API
// file. // file.
#include "g7291_interface.h" #include "g7291_interface.h"
#endif #endif
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_G729_1 #ifndef WEBRTC_CODEC_G729_1
ACMG729_1::ACMG729_1(WebRtc_Word16 /* codecID */) ACMG729_1::ACMG729_1(WebRtc_Word16 /* codec_id */)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL), decoder_inst_ptr_(NULL),
_myRate(32000), my_rate_(32000),
_flag8kHz(0), flag_8khz_(0),
_flagG729mode(0) { flag_g729_mode_(0) {
return; return;
} }
@ -39,31 +39,32 @@ ACMG729_1::~ACMG729_1() {
return; return;
} }
WebRtc_Word16 ACMG729_1::InternalEncode(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG729_1::InternalEncode(
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitstream_len_byte */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG729_1::InternalInitEncoder( WebRtc_Word16 ACMG729_1::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word16 ACMG729_1::InternalInitDecoder( WebRtc_Word16 ACMG729_1::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -87,7 +88,7 @@ void ACMG729_1::DestructDecoderSafe() {
return; return;
} }
void ACMG729_1::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMG729_1::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
@ -99,113 +100,114 @@ WebRtc_Word16 ACMG729_1::SetBitRateSafe(const WebRtc_Word32 /*rate*/) {
struct G729_1_inst_t_; struct G729_1_inst_t_;
ACMG729_1::ACMG729_1(WebRtc_Word16 codecID) ACMG729_1::ACMG729_1(WebRtc_Word16 codec_id)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL), decoder_inst_ptr_(NULL),
_myRate(32000), // Default rate. my_rate_(32000), // Default rate.
_flag8kHz(0), flag_8khz_(0),
_flagG729mode(0) { flag_g729_mode_(0) {
// TODO(tlegrand): We should add codecID as a input variable to the // TODO(tlegrand): We should add codec_id as a input variable to the
// constructor of ACMGenericCodec. // constructor of ACMGenericCodec.
_codecID = codecID; codec_id_ = codec_id;
return; return;
} }
ACMG729_1::~ACMG729_1() { ACMG729_1::~ACMG729_1() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcG7291_Free(_encoderInstPtr); WebRtcG7291_Free(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcG7291_Free(_decoderInstPtr); WebRtcG7291_Free(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
return; return;
} }
WebRtc_Word16 ACMG729_1::InternalEncode(WebRtc_UWord8* bitStream, WebRtc_Word16 ACMG729_1::InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte) { WebRtc_Word16* bitstream_len_byte) {
// Initialize before entering the loop // Initialize before entering the loop
WebRtc_Word16 noEncodedSamples = 0; WebRtc_Word16 num_encoded_samples = 0;
*bitStreamLenByte = 0; *bitstream_len_byte = 0;
WebRtc_Word16 byteLengthFrame = 0; WebRtc_Word16 byte_length_frame = 0;
// Derive number of 20ms frames per encoded packet. // Derive number of 20ms frames per encoded packet.
// [1,2,3] <=> [20,40,60]ms <=> [320,640,960] samples // [1,2,3] <=> [20,40,60]ms <=> [320,640,960] samples
WebRtc_Word16 n20msFrames = (_frameLenSmpl / 320); WebRtc_Word16 num_20ms_frames = (frame_len_smpl_ / 320);
// Byte length for the frame. +1 is for rate information. // Byte length for the frame. +1 is for rate information.
byteLengthFrame = _myRate / (8 * 50) * n20msFrames + (1 - _flagG729mode); byte_length_frame = my_rate_ / (8 * 50) * num_20ms_frames + (1 -
flag_g729_mode_);
// The following might be revised if we have G729.1 Annex C (support for DTX); // The following might be revised if we have G729.1 Annex C (support for DTX);
do { do {
*bitStreamLenByte = WebRtcG7291_Encode(_encoderInstPtr, *bitstream_len_byte = WebRtcG7291_Encode(encoder_inst_ptr_,
&_inAudio[_inAudioIxRead], &in_audio_[in_audio_ix_read_],
(WebRtc_Word16*) bitStream, _myRate, (WebRtc_Word16*) bitstream,
n20msFrames); my_rate_, num_20ms_frames);
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += 160; in_audio_ix_read_ += 160;
// sanity check // sanity check
if (*bitStreamLenByte < 0) { if (*bitstream_len_byte < 0) {
// error has happened // error has happened
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalEncode: Encode error for G729_1"); "InternalEncode: Encode error for G729_1");
*bitStreamLenByte = 0; *bitstream_len_byte = 0;
return -1; return -1;
} }
noEncodedSamples += 160; num_encoded_samples += 160;
} while (*bitStreamLenByte == 0); } while (*bitstream_len_byte == 0);
// This criteria will change if we have Annex C. // This criteria will change if we have Annex C.
if (*bitStreamLenByte != byteLengthFrame) { if (*bitstream_len_byte != byte_length_frame) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalEncode: Encode error for G729_1"); "InternalEncode: Encode error for G729_1");
*bitStreamLenByte = 0; *bitstream_len_byte = 0;
return -1; return -1;
} }
if (noEncodedSamples != _frameLenSmpl) { if (num_encoded_samples != frame_len_smpl_) {
*bitStreamLenByte = 0; *bitstream_len_byte = 0;
return -1; return -1;
} }
return *bitStreamLenByte; return *bitstream_len_byte;
} }
WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMG729_1::InternalInitEncoder( WebRtc_Word16 ACMG729_1::InternalInitEncoder(
WebRtcACMCodecParams* codecParams) { WebRtcACMCodecParams* codec_params) {
//set the bit rate and initialize //set the bit rate and initialize
_myRate = codecParams->codecInstant.rate; my_rate_ = codec_params->codec_inst.rate;
return SetBitRateSafe((WebRtc_UWord32) _myRate); return SetBitRateSafe((WebRtc_UWord32) my_rate_);
} }
WebRtc_Word16 ACMG729_1::InternalInitDecoder( WebRtc_Word16 ACMG729_1::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
if (WebRtcG7291_DecoderInit(_decoderInstPtr) < 0) { if (WebRtcG7291_DecoderInit(decoder_inst_ptr_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalInitDecoder: init decoder failed for G729_1"); "InternalInitDecoder: init decoder failed for G729_1");
return -1; return -1;
} }
return 0; return 0;
} }
WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!_decoderInitialized) { if (!decoder_initialized_) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"CodeDef: Decoder uninitialized for G729_1"); "CodeDef: Decoder uninitialized for G729_1");
return -1; return -1;
} }
@ -214,9 +216,9 @@ WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
// "SET_CODEC_PAR" & "SET_G729_FUNCTION." // "SET_CODEC_PAR" & "SET_G729_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
SET_CODEC_PAR((codecDef), kDecoderG729_1, codecInst.pltype, _decoderInstPtr, SET_CODEC_PAR((codec_def), kDecoderG729_1, codec_inst.pltype,
16000); decoder_inst_ptr_, 16000);
SET_G729_1_FUNCTIONS((codecDef)); SET_G729_1_FUNCTIONS((codec_def));
return 0; return 0;
} }
@ -225,8 +227,8 @@ ACMGenericCodec* ACMG729_1::CreateInstance(void) {
} }
WebRtc_Word16 ACMG729_1::InternalCreateEncoder() { WebRtc_Word16 ACMG729_1::InternalCreateEncoder() {
if (WebRtcG7291_Create(&_encoderInstPtr) < 0) { if (WebRtcG7291_Create(&encoder_inst_ptr_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateEncoder: create encoder failed for G729_1"); "InternalCreateEncoder: create encoder failed for G729_1");
return -1; return -1;
} }
@ -234,17 +236,17 @@ WebRtc_Word16 ACMG729_1::InternalCreateEncoder() {
} }
void ACMG729_1::DestructEncoderSafe() { void ACMG729_1::DestructEncoderSafe() {
_encoderExist = false; encoder_exist_ = false;
_encoderInitialized = false; encoder_initialized_ = false;
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcG7291_Free(_encoderInstPtr); WebRtcG7291_Free(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
} }
WebRtc_Word16 ACMG729_1::InternalCreateDecoder() { WebRtc_Word16 ACMG729_1::InternalCreateDecoder() {
if (WebRtcG7291_Create(&_decoderInstPtr) < 0) { if (WebRtcG7291_Create(&decoder_inst_ptr_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateDecoder: create decoder failed for G729_1"); "InternalCreateDecoder: create decoder failed for G729_1");
return -1; return -1;
} }
@ -252,86 +254,86 @@ WebRtc_Word16 ACMG729_1::InternalCreateDecoder() {
} }
void ACMG729_1::DestructDecoderSafe() { void ACMG729_1::DestructDecoderSafe() {
_decoderExist = false; decoder_exist_ = false;
_decoderInitialized = false; decoder_initialized_ = false;
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcG7291_Free(_decoderInstPtr); WebRtcG7291_Free(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
} }
void ACMG729_1::InternalDestructEncoderInst(void* ptrInst) { void ACMG729_1::InternalDestructEncoderInst(void* ptr_inst) {
if (ptrInst != NULL) { if (ptr_inst != NULL) {
//WebRtcG7291_Free((G729_1_inst_t*)ptrInst); // WebRtcG7291_Free((G729_1_inst_t*)ptrInst);
} }
return; return;
} }
WebRtc_Word16 ACMG729_1::SetBitRateSafe(const WebRtc_Word32 rate) { WebRtc_Word16 ACMG729_1::SetBitRateSafe(const WebRtc_Word32 rate) {
//allowed rates: { 8000, 12000, 14000, 16000, 18000, 20000, // allowed rates: { 8000, 12000, 14000, 16000, 18000, 20000,
// 22000, 24000, 26000, 28000, 30000, 32000}; // 22000, 24000, 26000, 28000, 30000, 32000};
// TODO(tlegrand): This check exists in one other place two. Should be // TODO(tlegrand): This check exists in one other place two. Should be
// possible to reuse code. // possible to reuse code.
switch (rate) { switch (rate) {
case 8000: { case 8000: {
_myRate = 8000; my_rate_ = 8000;
break; break;
} }
case 12000: { case 12000: {
_myRate = 12000; my_rate_ = 12000;
break; break;
} }
case 14000: { case 14000: {
_myRate = 14000; my_rate_ = 14000;
break; break;
} }
case 16000: { case 16000: {
_myRate = 16000; my_rate_ = 16000;
break; break;
} }
case 18000: { case 18000: {
_myRate = 18000; my_rate_ = 18000;
break; break;
} }
case 20000: { case 20000: {
_myRate = 20000; my_rate_ = 20000;
break; break;
} }
case 22000: { case 22000: {
_myRate = 22000; my_rate_ = 22000;
break; break;
} }
case 24000: { case 24000: {
_myRate = 24000; my_rate_ = 24000;
break; break;
} }
case 26000: { case 26000: {
_myRate = 26000; my_rate_ = 26000;
break; break;
} }
case 28000: { case 28000: {
_myRate = 28000; my_rate_ = 28000;
break; break;
} }
case 30000: { case 30000: {
_myRate = 30000; my_rate_ = 30000;
break; break;
} }
case 32000: { case 32000: {
_myRate = 32000; my_rate_ = 32000;
break; break;
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetBitRateSafe: Invalid rate G729_1"); "SetBitRateSafe: Invalid rate G729_1");
return -1; return -1;
} }
} }
// Re-init with new rate // Re-init with new rate
if (WebRtcG7291_EncoderInit(_encoderInstPtr, _myRate, _flag8kHz, if (WebRtcG7291_EncoderInit(encoder_inst_ptr_, my_rate_, flag_8khz_,
_flagG729mode) >= 0) { flag_g729_mode_) >= 0) {
_encoderParams.codecInstant.rate = _myRate; encoder_params_.codec_inst.rate = my_rate_;
return 0; return 0;
} else { } else {
return -1; return -1;

View File

@ -8,10 +8,10 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7291_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7291_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
// forward declaration // forward declaration
struct G729_1_inst_t_; struct G729_1_inst_t_;
@ -21,27 +21,28 @@ namespace webrtc {
class ACMG729_1 : public ACMGenericCodec { class ACMG729_1 : public ACMGenericCodec {
public: public:
ACMG729_1(WebRtc_Word16 codecID); explicit ACMG729_1(WebRtc_Word16 codec_id);
~ACMG729_1(); ~ACMG729_1();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -51,18 +52,18 @@ class ACMG729_1 : public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate); WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
G729_1_inst_t_* _encoderInstPtr; G729_1_inst_t_* encoder_inst_ptr_;
G729_1_inst_t_* _decoderInstPtr; G729_1_inst_t_* decoder_inst_ptr_;
WebRtc_UWord16 _myRate; WebRtc_UWord16 my_rate_;
WebRtc_Word16 _flag8kHz; WebRtc_Word16 flag_8khz_;
WebRtc_Word16 _flagG729mode; WebRtc_Word16 flag_g729_mode_;
}; };
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_ #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7291_H_

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,13 +8,13 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_gsmfr.h" #include "webrtc/modules/audio_coding/main/source/acm_gsmfr.h"
#include "acm_common_defs.h"
#include "acm_neteq.h"
#include "trace.h"
#include "webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h"
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc/system_wrappers/interface/trace.h"
#ifdef WEBRTC_CODEC_GSMFR #ifdef WEBRTC_CODEC_GSMFR
// NOTE! GSM-FR is not included in the open-source package. Modify this file // NOTE! GSM-FR is not included in the open-source package. Modify this file
// or your codec API to match the function calls and names of used GSM-FR API // or your codec API to match the function calls and names of used GSM-FR API
@ -26,9 +26,9 @@ namespace webrtc {
#ifndef WEBRTC_CODEC_GSMFR #ifndef WEBRTC_CODEC_GSMFR
ACMGSMFR::ACMGSMFR(WebRtc_Word16 /* codecID */) ACMGSMFR::ACMGSMFR(WebRtc_Word16 /* codec_id */)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL) { decoder_inst_ptr_(NULL) {
return; return;
} }
@ -36,16 +36,17 @@ ACMGSMFR::~ACMGSMFR() {
return; return;
} }
WebRtc_Word16 ACMGSMFR::InternalEncode(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMGSMFR::InternalEncode(
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitstream_len_byte */) {
return -1; return -1;
} }
WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return -1; return -1;
} }
@ -58,17 +59,17 @@ WebRtc_Word16 ACMGSMFR::DisableDTX() {
} }
WebRtc_Word16 ACMGSMFR::InternalInitEncoder( WebRtc_Word16 ACMGSMFR::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word16 ACMGSMFR::InternalInitDecoder( WebRtc_Word16 ACMGSMFR::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -92,62 +93,62 @@ void ACMGSMFR::DestructDecoderSafe() {
return; return;
} }
void ACMGSMFR::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMGSMFR::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMGSMFR::ACMGSMFR(WebRtc_Word16 codecID) ACMGSMFR::ACMGSMFR(WebRtc_Word16 codec_id)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL) { decoder_inst_ptr_(NULL) {
_codecID = codecID; codec_id_ = codec_id;
_hasInternalDTX = true; has_internal_dtx_ = true;
return; return;
} }
ACMGSMFR::~ACMGSMFR() { ACMGSMFR::~ACMGSMFR() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcGSMFR_FreeEnc(_encoderInstPtr); WebRtcGSMFR_FreeEnc(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcGSMFR_FreeDec(_decoderInstPtr); WebRtcGSMFR_FreeDec(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
return; return;
} }
WebRtc_Word16 ACMGSMFR::InternalEncode(WebRtc_UWord8* bitStream, WebRtc_Word16 ACMGSMFR::InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte) { WebRtc_Word16* bitstream_len_byte) {
*bitStreamLenByte = WebRtcGSMFR_Encode(_encoderInstPtr, *bitstream_len_byte = WebRtcGSMFR_Encode(encoder_inst_ptr_,
&_inAudio[_inAudioIxRead], &in_audio_[in_audio_ix_read_],
_frameLenSmpl, frame_len_smpl_,
(WebRtc_Word16*) bitStream); (WebRtc_Word16*)bitstream);
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += _frameLenSmpl; in_audio_ix_read_ += frame_len_smpl_;
return *bitStreamLenByte; return *bitstream_len_byte;
} }
WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMGSMFR::EnableDTX() { WebRtc_Word16 ACMGSMFR::EnableDTX() {
if (_dtxEnabled) { if (dtx_enabled_) {
return 0; return 0;
} else if (_encoderExist) { } else if (encoder_exist_) {
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, 1) < 0) { if (WebRtcGSMFR_EncoderInit(encoder_inst_ptr_, 1) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"EnableDTX: cannot init encoder for GSMFR"); "EnableDTX: cannot init encoder for GSMFR");
return -1; return -1;
} }
_dtxEnabled = true; dtx_enabled_ = true;
return 0; return 0;
} else { } else {
return -1; return -1;
@ -155,15 +156,15 @@ WebRtc_Word16 ACMGSMFR::EnableDTX() {
} }
WebRtc_Word16 ACMGSMFR::DisableDTX() { WebRtc_Word16 ACMGSMFR::DisableDTX() {
if (!_dtxEnabled) { if (!dtx_enabled_) {
return 0; return 0;
} else if (_encoderExist) { } else if (encoder_exist_) {
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, 0) < 0) { if (WebRtcGSMFR_EncoderInit(encoder_inst_ptr_, 0) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"DisableDTX: cannot init encoder for GSMFR"); "DisableDTX: cannot init encoder for GSMFR");
return -1; return -1;
} }
_dtxEnabled = false; dtx_enabled_ = false;
return 0; return 0;
} else { } else {
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless
@ -171,29 +172,30 @@ WebRtc_Word16 ACMGSMFR::DisableDTX() {
} }
} }
WebRtc_Word16 ACMGSMFR::InternalInitEncoder(WebRtcACMCodecParams* codecParams) { WebRtc_Word16 ACMGSMFR::InternalInitEncoder(
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, WebRtcACMCodecParams* codec_params) {
((codecParams->enableDTX) ? 1 : 0)) < 0) { if (WebRtcGSMFR_EncoderInit(encoder_inst_ptr_,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, ((codec_params->enable_dtx) ? 1 : 0)) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalInitEncoder: cannot init encoder for GSMFR"); "InternalInitEncoder: cannot init encoder for GSMFR");
} }
return 0; return 0;
} }
WebRtc_Word16 ACMGSMFR::InternalInitDecoder( WebRtc_Word16 ACMGSMFR::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
if (WebRtcGSMFR_DecoderInit(_decoderInstPtr) < 0) { if (WebRtcGSMFR_DecoderInit(decoder_inst_ptr_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalInitDecoder: cannot init decoder for GSMFR"); "InternalInitDecoder: cannot init decoder for GSMFR");
return -1; return -1;
} }
return 0; return 0;
} }
WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!_decoderInitialized) { if (!decoder_initialized_) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"CodecDef: decoder is not initialized for GSMFR"); "CodecDef: decoder is not initialized for GSMFR");
return -1; return -1;
} }
@ -201,9 +203,9 @@ WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
// "SET_CODEC_PAR" & "SET_GSMFR_FUNCTION." // "SET_CODEC_PAR" & "SET_GSMFR_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
SET_CODEC_PAR((codecDef), kDecoderGSMFR, codecInst.pltype, _decoderInstPtr, SET_CODEC_PAR((codec_def), kDecoderGSMFR, codec_inst.pltype,
8000); decoder_inst_ptr_, 8000);
SET_GSMFR_FUNCTIONS((codecDef)); SET_GSMFR_FUNCTIONS((codec_def));
return 0; return 0;
} }
@ -212,44 +214,46 @@ ACMGenericCodec* ACMGSMFR::CreateInstance(void) {
} }
WebRtc_Word16 ACMGSMFR::InternalCreateEncoder() { WebRtc_Word16 ACMGSMFR::InternalCreateEncoder() {
if (WebRtcGSMFR_CreateEnc(&_encoderInstPtr) < 0) { if (WebRtcGSMFR_CreateEnc(&encoder_inst_ptr_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateEncoder: cannot create instance for GSMFR encoder"); "InternalCreateEncoder: cannot create instance for GSMFR "
"encoder");
return -1; return -1;
} }
return 0; return 0;
} }
void ACMGSMFR::DestructEncoderSafe() { void ACMGSMFR::DestructEncoderSafe() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcGSMFR_FreeEnc(_encoderInstPtr); WebRtcGSMFR_FreeEnc(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
_encoderExist = false; encoder_exist_ = false;
_encoderInitialized = false; encoder_initialized_ = false;
} }
WebRtc_Word16 ACMGSMFR::InternalCreateDecoder() { WebRtc_Word16 ACMGSMFR::InternalCreateDecoder() {
if (WebRtcGSMFR_CreateDec(&_decoderInstPtr) < 0) { if (WebRtcGSMFR_CreateDec(&decoder_inst_ptr_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateDecoder: cannot create instance for GSMFR decoder"); "InternalCreateDecoder: cannot create instance for GSMFR "
"decoder");
return -1; return -1;
} }
return 0; return 0;
} }
void ACMGSMFR::DestructDecoderSafe() { void ACMGSMFR::DestructDecoderSafe() {
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcGSMFR_FreeDec(_decoderInstPtr); WebRtcGSMFR_FreeDec(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
_decoderExist = false; decoder_exist_ = false;
_decoderInitialized = false; decoder_initialized_ = false;
} }
void ACMGSMFR::InternalDestructEncoderInst(void* ptrInst) { void ACMGSMFR::InternalDestructEncoderInst(void* ptr_inst) {
if (ptrInst != NULL) { if (ptr_inst != NULL) {
WebRtcGSMFR_FreeEnc((GSMFR_encinst_t_*) ptrInst); WebRtcGSMFR_FreeEnc((GSMFR_encinst_t_*) ptr_inst);
} }
return; return;
} }

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
// forward declaration // forward declaration
struct GSMFR_encinst_t_; struct GSMFR_encinst_t_;
@ -21,27 +21,28 @@ namespace webrtc {
class ACMGSMFR : public ACMGenericCodec { class ACMGSMFR : public ACMGenericCodec {
public: public:
ACMGSMFR(WebRtc_Word16 codecID); explicit ACMGSMFR(WebRtc_Word16 codec_id);
~ACMGSMFR(); ~ACMGSMFR();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -51,14 +52,14 @@ class ACMGSMFR : public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
WebRtc_Word16 EnableDTX(); WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX(); WebRtc_Word16 DisableDTX();
GSMFR_encinst_t_* _encoderInstPtr; GSMFR_encinst_t_* encoder_inst_ptr_;
GSMFR_decinst_t_* _decoderInstPtr; GSMFR_decinst_t_* decoder_inst_ptr_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -7,25 +7,25 @@
* in the file PATENTS. All contributing project authors may * in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "webrtc/modules/audio_coding/main/source/acm_ilbc.h"
#include "acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "acm_ilbc.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "trace.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc_neteq.h" #include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc_neteq_help_macros.h"
#ifdef WEBRTC_CODEC_ILBC #ifdef WEBRTC_CODEC_ILBC
#include "ilbc.h" #include "webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h"
#endif #endif
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_ILBC #ifndef WEBRTC_CODEC_ILBC
ACMILBC::ACMILBC(WebRtc_Word16 /* codecID */) ACMILBC::ACMILBC(WebRtc_Word16 /* codec_id */)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL) { decoder_inst_ptr_(NULL) {
return; return;
} }
@ -33,31 +33,32 @@ ACMILBC::~ACMILBC() {
return; return;
} }
WebRtc_Word16 ACMILBC::InternalEncode(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMILBC::InternalEncode(
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitstream_len_byte */) {
return -1; return -1;
} }
WebRtc_Word16 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return -1; return -1;
} }
WebRtc_Word16 ACMILBC::InternalInitEncoder( WebRtc_Word16 ACMILBC::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word16 ACMILBC::InternalInitDecoder( WebRtc_Word16 ACMILBC::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -81,7 +82,7 @@ void ACMILBC::DestructDecoderSafe() {
return; return;
} }
void ACMILBC::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMILBC::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
@ -91,88 +92,88 @@ WebRtc_Word16 ACMILBC::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMILBC::ACMILBC(WebRtc_Word16 codecID) ACMILBC::ACMILBC(WebRtc_Word16 codec_id)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL) { decoder_inst_ptr_(NULL) {
_codecID = codecID; codec_id_ = codec_id;
return; return;
} }
ACMILBC::~ACMILBC() { ACMILBC::~ACMILBC() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcIlbcfix_EncoderFree(_encoderInstPtr); WebRtcIlbcfix_EncoderFree(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcIlbcfix_DecoderFree(_decoderInstPtr); WebRtcIlbcfix_DecoderFree(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
return; return;
} }
WebRtc_Word16 ACMILBC::InternalEncode(WebRtc_UWord8* bitStream, WebRtc_Word16 ACMILBC::InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte) { WebRtc_Word16* bitstream_len_byte) {
*bitStreamLenByte = WebRtcIlbcfix_Encode(_encoderInstPtr, *bitstream_len_byte = WebRtcIlbcfix_Encode(encoder_inst_ptr_,
&_inAudio[_inAudioIxRead], &in_audio_[in_audio_ix_read_],
_frameLenSmpl, frame_len_smpl_,
(WebRtc_Word16*) bitStream); (WebRtc_Word16*)bitstream);
if (*bitStreamLenByte < 0) { if (*bitstream_len_byte < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalEncode: error in encode for ILBC"); "InternalEncode: error in encode for ILBC");
return -1; return -1;
} }
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += _frameLenSmpl; in_audio_ix_read_ += frame_len_smpl_;
return *bitStreamLenByte; return *bitstream_len_byte;
} }
WebRtc_Word16 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMILBC::InternalInitEncoder(WebRtcACMCodecParams* codecParams) { WebRtc_Word16 ACMILBC::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
// initialize with a correct processing block length // initialize with a correct processing block length
if ((160 == (codecParams->codecInstant).pacsize) || if ((160 == (codec_params->codec_inst).pacsize) ||
(320 == (codecParams->codecInstant).pacsize)) { (320 == (codec_params->codec_inst).pacsize)) {
// processing block of 20ms // processing block of 20ms
return WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20); return WebRtcIlbcfix_EncoderInit(encoder_inst_ptr_, 20);
} else if ((240 == (codecParams->codecInstant).pacsize) || } else if ((240 == (codec_params->codec_inst).pacsize) ||
(480 == (codecParams->codecInstant).pacsize)) { (480 == (codec_params->codec_inst).pacsize)) {
// processing block of 30ms // processing block of 30ms
return WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30); return WebRtcIlbcfix_EncoderInit(encoder_inst_ptr_, 30);
} else { } else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalInitEncoder: invalid processing block"); "InternalInitEncoder: invalid processing block");
return -1; return -1;
} }
} }
WebRtc_Word16 ACMILBC::InternalInitDecoder(WebRtcACMCodecParams* codecParams) { WebRtc_Word16 ACMILBC::InternalInitDecoder(WebRtcACMCodecParams* codec_params) {
// initialize with a correct processing block length // initialize with a correct processing block length
if ((160 == (codecParams->codecInstant).pacsize) || if ((160 == (codec_params->codec_inst).pacsize) ||
(320 == (codecParams->codecInstant).pacsize)) { (320 == (codec_params->codec_inst).pacsize)) {
// processing block of 20ms // processing block of 20ms
return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 20); return WebRtcIlbcfix_DecoderInit(decoder_inst_ptr_, 20);
} else if ((240 == (codecParams->codecInstant).pacsize) || } else if ((240 == (codec_params->codec_inst).pacsize) ||
(480 == (codecParams->codecInstant).pacsize)) { (480 == (codec_params->codec_inst).pacsize)) {
// processing block of 30ms // processing block of 30ms
return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 30); return WebRtcIlbcfix_DecoderInit(decoder_inst_ptr_, 30);
} else { } else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalInitDecoder: invalid processing block"); "InternalInitDecoder: invalid processing block");
return -1; return -1;
} }
} }
WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!_decoderInitialized) { if (!decoder_initialized_) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"CodeDef: decoder not initialized for ILBC"); "CodeDef: decoder not initialized for ILBC");
return -1; return -1;
} }
@ -180,9 +181,9 @@ WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
// "SET_CODEC_PAR" & "SET_ILBC_FUNCTION." // "SET_CODEC_PAR" & "SET_ILBC_FUNCTION."
// Then return the structure back to NetEQ to add the codec to it's // Then return the structure back to NetEQ to add the codec to it's
// database. // database.
SET_CODEC_PAR((codecDef), kDecoderILBC, codecInst.pltype, _decoderInstPtr, SET_CODEC_PAR((codec_def), kDecoderILBC, codec_inst.pltype, decoder_inst_ptr_,
8000); 8000);
SET_ILBC_FUNCTIONS((codecDef)); SET_ILBC_FUNCTIONS((codec_def));
return 0; return 0;
} }
@ -191,44 +192,46 @@ ACMGenericCodec* ACMILBC::CreateInstance(void) {
} }
WebRtc_Word16 ACMILBC::InternalCreateEncoder() { WebRtc_Word16 ACMILBC::InternalCreateEncoder() {
if (WebRtcIlbcfix_EncoderCreate(&_encoderInstPtr) < 0) { if (WebRtcIlbcfix_EncoderCreate(&encoder_inst_ptr_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateEncoder: cannot create instance for ILBC encoder"); "InternalCreateEncoder: cannot create instance for ILBC "
"encoder");
return -1; return -1;
} }
return 0; return 0;
} }
void ACMILBC::DestructEncoderSafe() { void ACMILBC::DestructEncoderSafe() {
_encoderInitialized = false; encoder_initialized_ = false;
_encoderExist = false; encoder_exist_ = false;
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcIlbcfix_EncoderFree(_encoderInstPtr); WebRtcIlbcfix_EncoderFree(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
} }
WebRtc_Word16 ACMILBC::InternalCreateDecoder() { WebRtc_Word16 ACMILBC::InternalCreateDecoder() {
if (WebRtcIlbcfix_DecoderCreate(&_decoderInstPtr) < 0) { if (WebRtcIlbcfix_DecoderCreate(&decoder_inst_ptr_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateDecoder: cannot create instance for ILBC decoder"); "InternalCreateDecoder: cannot create instance for ILBC "
"decoder");
return -1; return -1;
} }
return 0; return 0;
} }
void ACMILBC::DestructDecoderSafe() { void ACMILBC::DestructDecoderSafe() {
_decoderInitialized = false; decoder_initialized_ = false;
_decoderExist = false; decoder_exist_ = false;
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcIlbcfix_DecoderFree(_decoderInstPtr); WebRtcIlbcfix_DecoderFree(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
} }
void ACMILBC::InternalDestructEncoderInst(void* ptrInst) { void ACMILBC::InternalDestructEncoderInst(void* ptr_inst) {
if (ptrInst != NULL) { if (ptr_inst != NULL) {
WebRtcIlbcfix_EncoderFree((iLBC_encinst_t_*) ptrInst); WebRtcIlbcfix_EncoderFree((iLBC_encinst_t_*) ptr_inst);
} }
return; return;
} }
@ -236,13 +239,13 @@ void ACMILBC::InternalDestructEncoderInst(void* ptrInst) {
WebRtc_Word16 ACMILBC::SetBitRateSafe(const WebRtc_Word32 rate) { WebRtc_Word16 ACMILBC::SetBitRateSafe(const WebRtc_Word32 rate) {
// Check that rate is valid. No need to store the value // Check that rate is valid. No need to store the value
if (rate == 13300) { if (rate == 13300) {
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30); WebRtcIlbcfix_EncoderInit(encoder_inst_ptr_, 30);
} else if (rate == 15200) { } else if (rate == 15200) {
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20); WebRtcIlbcfix_EncoderInit(encoder_inst_ptr_, 20);
} else { } else {
return -1; return -1;
} }
_encoderParams.codecInstant.rate = rate; encoder_params_.codec_inst.rate = rate;
return 0; return 0;
} }

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
// forward declaration // forward declaration
struct iLBC_encinst_t_; struct iLBC_encinst_t_;
@ -21,27 +21,28 @@ namespace webrtc {
class ACMILBC : public ACMGenericCodec { class ACMILBC : public ACMGenericCodec {
public: public:
ACMILBC(WebRtc_Word16 codecID); explicit ACMILBC(WebRtc_Word16 codec_id);
~ACMILBC(); ~ACMILBC();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate); WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
@ -53,10 +54,10 @@ class ACMILBC : public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
iLBC_encinst_t_* _encoderInstPtr; iLBC_encinst_t_* encoder_inst_ptr_;
iLBC_decinst_t_* _decoderInstPtr; iLBC_decinst_t_* decoder_inst_ptr_;
}; };
} // namespace webrtc } // namespace webrtc

File diff suppressed because it is too large Load Diff

View File

@ -11,112 +11,118 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
namespace webrtc { namespace webrtc {
struct ACMISACInst; struct ACMISACInst;
enum iSACCodingMode { enum IsacCodingMode {
ADAPTIVE, ADAPTIVE,
CHANNEL_INDEPENDENT CHANNEL_INDEPENDENT
}; };
class ACMISAC : public ACMGenericCodec { class ACMISAC : public ACMGenericCodec {
public: public:
ACMISAC(WebRtc_Word16 codecID); explicit ACMISAC(WebRtc_Word16 codec_id);
~ACMISAC(); ~ACMISAC();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 DeliverCachedIsacData(WebRtc_UWord8* bitStream, WebRtc_Word16 DeliverCachedIsacData(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte, WebRtc_Word16* bitstream_len_byte,
WebRtc_UWord32* timestamp, WebRtc_UWord32* timestamp,
WebRtcACMEncodingType* encodingType, WebRtcACMEncodingType* encoding_type,
const WebRtc_UWord16 isacRate, const WebRtc_UWord16 isac_rate,
const WebRtc_UWord8 isacBWestimate); const WebRtc_UWord8 isac_bwestimate);
WebRtc_Word16 DeliverCachedData(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 DeliverCachedData(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitStreamLenByte */, WebRtc_Word16* /* bitstream_len_byte */,
WebRtc_UWord32* /* timestamp */, WebRtc_UWord32* /* timestamp */,
WebRtcACMEncodingType* /* encodingType */) { WebRtcACMEncodingType* /* encoding_type */) {
return -1; return -1;
} }
WebRtc_Word16 UpdateDecoderSampFreq(WebRtc_Word16 codecId); WebRtc_Word16 UpdateDecoderSampFreq(WebRtc_Word16 codec_id);
WebRtc_Word16 UpdateEncoderSampFreq(WebRtc_UWord16 sampFreqHz); WebRtc_Word16 UpdateEncoderSampFreq(WebRtc_UWord16 samp_freq_hz);
WebRtc_Word16 EncoderSampFreq(WebRtc_UWord16& sampFreqHz); WebRtc_Word16 EncoderSampFreq(WebRtc_UWord16& samp_freq_hz);
WebRtc_Word32 ConfigISACBandwidthEstimator( WebRtc_Word32 ConfigISACBandwidthEstimator(
const WebRtc_UWord8 initFrameSizeMsec, const WebRtc_UWord8 init_frame_size_msec,
const WebRtc_UWord16 initRateBitPerSec, const bool enforceFrameSize); const WebRtc_UWord16 init_rate_bit_per_sec,
const bool enforce_frame_size);
WebRtc_Word32 SetISACMaxPayloadSize(const WebRtc_UWord16 maxPayloadLenBytes); WebRtc_Word32 SetISACMaxPayloadSize(
const WebRtc_UWord16 max_payload_len_bytes);
WebRtc_Word32 SetISACMaxRate(const WebRtc_UWord32 maxRateBitPerSec); WebRtc_Word32 SetISACMaxRate(const WebRtc_UWord32 max_rate_bit_per_sec);
WebRtc_Word16 REDPayloadISAC(const WebRtc_Word32 isacRate, WebRtc_Word16 REDPayloadISAC(const WebRtc_Word32 isac_rate,
const WebRtc_Word16 isacBwEstimate, const WebRtc_Word16 isac_bw_estimate,
WebRtc_UWord8* payload, WebRtc_UWord8* payload,
WebRtc_Word16* payloadLenBytes); WebRtc_Word16* payload_len_bytes);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16* audio, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audioSamples, WebRtc_Word16* audio,
WebRtc_Word8* speechType); WebRtc_Word16* audio_samples,
WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 bitRate); WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 bit_rate);
WebRtc_Word32 GetEstimatedBandwidthSafe(); WebRtc_Word32 GetEstimatedBandwidthSafe();
WebRtc_Word32 SetEstimatedBandwidthSafe(WebRtc_Word32 estimatedBandwidth); WebRtc_Word32 SetEstimatedBandwidthSafe(WebRtc_Word32 estimated_bandwidth);
WebRtc_Word32 GetRedPayloadSafe(WebRtc_UWord8* redPayload, WebRtc_Word32 GetRedPayloadSafe(WebRtc_UWord8* red_payload,
WebRtc_Word16* payloadBytes); WebRtc_Word16* payload_bytes);
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
WebRtc_Word16 Transcode(WebRtc_UWord8* bitStream, WebRtc_Word16 Transcode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte, WebRtc_Word16 qBWE, WebRtc_Word16* bitstream_len_byte,
WebRtc_Word32 rate, bool isRED); WebRtc_Word16 q_bwe,
WebRtc_Word32 rate,
bool is_red);
void CurrentRate(WebRtc_Word32& rateBitPerSec); void CurrentRate(WebRtc_Word32& rate_bit_per_sec);
void UpdateFrameLen(); void UpdateFrameLen();
bool DecoderParamsSafe(WebRtcACMCodecParams *decParams, bool DecoderParamsSafe(WebRtcACMCodecParams *dec_params,
const WebRtc_UWord8 payloadType); const WebRtc_UWord8 payload_type);
void SaveDecoderParamSafe(const WebRtcACMCodecParams* codecParams); void SaveDecoderParamSafe(const WebRtcACMCodecParams* codec_params);
ACMISACInst* _codecInstPtr; ACMISACInst* codec_inst_ptr_;
bool _isEncInitialized; bool is_enc_initialized_;
iSACCodingMode _isacCodingMode; IsacCodingMode isac_coding_mode_;
bool _enforceFrameSize; bool enforce_frame_size_;
WebRtc_Word32 _isacCurrentBN; WebRtc_Word32 isac_current_bn_;
WebRtc_UWord16 _samplesIn10MsAudio; WebRtc_UWord16 samples_in_10ms_audio_;
WebRtcACMCodecParams _decoderParams32kHz; WebRtcACMCodecParams decoder_params_32khz_;
}; };
} // namespace } // namespace

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_
#include "engine_configurations.h" #include "webrtc/engine_configurations.h"
namespace webrtc { namespace webrtc {

File diff suppressed because it is too large Load Diff

View File

@ -11,26 +11,29 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_
#include "audio_coding_module.h" #include "webrtc/common_audio/vad/include/webrtc_vad.h"
#include "audio_coding_module_typedefs.h" #include "webrtc/engine_configurations.h"
#include "engine_configurations.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
#include "module_common_types.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "typedefs.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/interface/module_common_types.h"
#include "webrtc_vad.h" #include "webrtc/typedefs.h"
namespace webrtc { namespace webrtc {
class CriticalSectionWrapper; class CriticalSectionWrapper;
class RWLockWrapper; class RWLockWrapper;
struct CodecInst; struct CodecInst;
enum AudioPlayoutMode;
enum ACMSpeechType;
#define MAX_NUM_SLAVE_NETEQ 1 #define MAX_NUM_SLAVE_NETEQ 1
class ACMNetEQ { class ACMNetEQ {
public: public:
enum JitterBuffer {
kMasterJb = 0,
kSlaveJb = 1
};
// Constructor of the class // Constructor of the class
ACMNetEQ(); ACMNetEQ();
@ -41,9 +44,9 @@ class ACMNetEQ {
// Init() // Init()
// Allocates memory for NetEQ and VAD and initializes them. // Allocates memory for NetEQ and VAD and initializes them.
// //
// Return value : 0 if ok. // Return value : 0 if ok.
// -1 if NetEQ or VAD returned an error or // -1 if NetEQ or VAD returned an error or
// if out of memory. // if out of memory.
// //
WebRtc_Word32 Init(); WebRtc_Word32 Init();
@ -52,82 +55,83 @@ class ACMNetEQ {
// Gives the payload to NetEQ. // Gives the payload to NetEQ.
// //
// Input: // Input:
// - incomingPayload : Incoming audio payload. // - incoming_payload : Incoming audio payload.
// - payloadLength : Length of incoming audio payload. // - length_payload : Length of incoming audio payload.
// - rtpInfo : RTP header for the incoming payload containing // - rtp_info : RTP header for the incoming payload containing
// information about payload type, sequence number, // information about payload type, sequence number,
// timestamp, ssrc and marker bit. // timestamp, SSRC and marker bit.
// //
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 RecIn(const WebRtc_UWord8* incomingPayload, WebRtc_Word32 RecIn(const WebRtc_UWord8* incoming_payload,
const WebRtc_Word32 payloadLength, const WebRtc_Word32 length_payload,
const WebRtcRTPHeader& rtpInfo); const WebRtcRTPHeader& rtp_info);
// //
// RecOut() // RecOut()
// Asks NetEQ for 10 ms of decoded audio. // Asks NetEQ for 10 ms of decoded audio.
// //
// Input: // Input:
// -audioFrame : an audio frame were output data and // -audio_frame : an audio frame were output data and
// associated parameters are written to. // associated parameters are written to.
// //
// Return value : 0 if ok. // Return value : 0 if ok.
// -1 if NetEQ returned an error. // -1 if NetEQ returned an error.
// //
WebRtc_Word32 RecOut(AudioFrame& audioFrame); WebRtc_Word32 RecOut(AudioFrame& audio_frame);
// //
// AddCodec() // AddCodec()
// Adds a new codec to the NetEQ codec database. // Adds a new codec to the NetEQ codec database.
// //
// Input: // Input:
// - codecDef : The codec to be added. // - codec_def : The codec to be added.
// - toMaster : true if the codec has to be added to Master // - to_master : true if the codec has to be added to Master
// NetEq, otherwise will be added to the Slave // NetEq, otherwise will be added to the Slave
// NetEQ. // NetEQ.
// //
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 AddCodec(WebRtcNetEQ_CodecDef *codecDef, bool toMaster = true); WebRtc_Word32 AddCodec(WebRtcNetEQ_CodecDef *codec_def,
bool to_master = true);
// //
// AllocatePacketBuffer() // AllocatePacketBuffer()
// Allocates the NetEQ packet buffer. // Allocates the NetEQ packet buffer.
// //
// Input: // Input:
// - usedCodecs : An array of the codecs to be used by NetEQ. // - used_codecs : An array of the codecs to be used by NetEQ.
// - noOfCodecs : Number of codecs in usedCodecs. // - num_codecs : Number of codecs in used_codecs.
// //
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 AllocatePacketBuffer(const WebRtcNetEQDecoder* usedCodecs, WebRtc_Word32 AllocatePacketBuffer(const WebRtcNetEQDecoder* used_codecs,
WebRtc_Word16 noOfCodecs); WebRtc_Word16 num_codecs);
// //
// SetExtraDelay() // SetExtraDelay()
// Sets an delayInMS milliseconds extra delay in NetEQ. // Sets a |delay_in_ms| milliseconds extra delay in NetEQ.
// //
// Input: // Input:
// - delayInMS : Extra delay in milliseconds. // - delay_in_ms : Extra delay in milliseconds.
// //
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 SetExtraDelay(const WebRtc_Word32 delayInMS); WebRtc_Word32 SetExtraDelay(const WebRtc_Word32 delay_in_ms);
// //
// SetAVTPlayout() // SetAVTPlayout()
// Enable/disable playout of AVT payloads. // Enable/disable playout of AVT payloads.
// //
// Input: // Input:
// - enable : Enable if true, disable if false. // - enable : Enable if true, disable if false.
// //
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 SetAVTPlayout(const bool enable); WebRtc_Word32 SetAVTPlayout(const bool enable);
@ -135,16 +139,16 @@ class ACMNetEQ {
// AVTPlayout() // AVTPlayout()
// Get the current AVT playout state. // Get the current AVT playout state.
// //
// Return value : True if AVT playout is enabled. // Return value : True if AVT playout is enabled.
// False if AVT playout is disabled. // False if AVT playout is disabled.
// //
bool AVTPlayout() const; bool avt_playout() const;
// //
// CurrentSampFreqHz() // CurrentSampFreqHz()
// Get the current sampling frequency in Hz. // Get the current sampling frequency in Hz.
// //
// Return value : Sampling frequency in Hz. // Return value : Sampling frequency in Hz.
// //
WebRtc_Word32 CurrentSampFreqHz() const; WebRtc_Word32 CurrentSampFreqHz() const;
@ -153,11 +157,11 @@ class ACMNetEQ {
// Sets the playout mode to voice or fax. // Sets the playout mode to voice or fax.
// //
// Input: // Input:
// - mode : The playout mode to be used, voice, // - mode : The playout mode to be used, voice,
// fax, or streaming. // fax, or streaming.
// //
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 SetPlayoutMode(const AudioPlayoutMode mode); WebRtc_Word32 SetPlayoutMode(const AudioPlayoutMode mode);
@ -165,19 +169,19 @@ class ACMNetEQ {
// PlayoutMode() // PlayoutMode()
// Get the current playout mode. // Get the current playout mode.
// //
// Return value : The current playout mode. // Return value : The current playout mode.
// //
AudioPlayoutMode PlayoutMode() const; AudioPlayoutMode playout_mode() const;
// //
// NetworkStatistics() // NetworkStatistics()
// Get the current network statistics from NetEQ. // Get the current network statistics from NetEQ.
// //
// Output: // Output:
// - statistics : The current network statistics. // - statistics : The current network statistics.
// //
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 NetworkStatistics(ACMNetworkStatistics* statistics) const; WebRtc_Word32 NetworkStatistics(ACMNetworkStatistics* statistics) const;
@ -185,19 +189,19 @@ class ACMNetEQ {
// VADMode() // VADMode()
// Get the current VAD Mode. // Get the current VAD Mode.
// //
// Return value : The current VAD mode. // Return value : The current VAD mode.
// //
ACMVADMode VADMode() const; ACMVADMode vad_mode() const;
// //
// SetVADMode() // SetVADMode()
// Set the VAD mode. // Set the VAD mode.
// //
// Input: // Input:
// - mode : The new VAD mode. // - mode : The new VAD mode.
// //
// Return value : 0 if ok. // Return value : 0 if ok.
// -1 if an error occurred. // -1 if an error occurred.
// //
WebRtc_Word16 SetVADMode(const ACMVADMode mode); WebRtc_Word16 SetVADMode(const ACMVADMode mode);
@ -205,18 +209,18 @@ class ACMNetEQ {
// DecodeLock() // DecodeLock()
// Get the decode lock used to protect decoder instances while decoding. // Get the decode lock used to protect decoder instances while decoding.
// //
// Return value : Pointer to the decode lock. // Return value : Pointer to the decode lock.
// //
RWLockWrapper* DecodeLock() const { RWLockWrapper* DecodeLock() const {
return _decodeLock; return decode_lock_;
} }
// //
// FlushBuffers() // FlushBuffers()
// Flushes the NetEQ packet and speech buffers. // Flushes the NetEQ packet and speech buffers.
// //
// Return value : 0 if ok. // Return value : 0 if ok.
// -1 if NetEQ returned an error. // -1 if NetEQ returned an error.
// //
WebRtc_Word32 FlushBuffers(); WebRtc_Word32 FlushBuffers();
@ -225,23 +229,24 @@ class ACMNetEQ {
// Removes a codec from the NetEQ codec database. // Removes a codec from the NetEQ codec database.
// //
// Input: // Input:
// - codecIdx : Codec to be removed. // - codec_idx : Codec to be removed.
// //
// Return value : 0 if ok. // Return value : 0 if ok.
// -1 if an error occurred. // -1 if an error occurred.
// //
WebRtc_Word16 RemoveCodec(WebRtcNetEQDecoder codecIdx, bool isStereo = false); WebRtc_Word16 RemoveCodec(WebRtcNetEQDecoder codec_idx,
bool is_stereo = false);
// //
// SetBackgroundNoiseMode() // SetBackgroundNoiseMode()
// Set the mode of the background noise. // Set the mode of the background noise.
// //
// Input: // Input:
// - mode : an enumerator specifying the mode of the // - mode : an enumerator specifying the mode of the
// background noise. // background noise.
// //
// Return value : 0 if succeeded, // Return value : 0 if succeeded,
// -1 if failed to set the mode. // -1 if failed to set the mode.
// //
WebRtc_Word16 SetBackgroundNoiseMode(const ACMBackgroundNoiseMode mode); WebRtc_Word16 SetBackgroundNoiseMode(const ACMBackgroundNoiseMode mode);
@ -249,28 +254,23 @@ class ACMNetEQ {
// BackgroundNoiseMode() // BackgroundNoiseMode()
// return the mode of the background noise. // return the mode of the background noise.
// //
// Return value : The mode of background noise. // Return value : The mode of background noise.
// //
WebRtc_Word16 BackgroundNoiseMode(ACMBackgroundNoiseMode& mode); WebRtc_Word16 BackgroundNoiseMode(ACMBackgroundNoiseMode& mode);
void SetUniqueId(WebRtc_Word32 id); void set_id(WebRtc_Word32 id);
WebRtc_Word32 PlayoutTimestamp(WebRtc_UWord32& timestamp); WebRtc_Word32 PlayoutTimestamp(WebRtc_UWord32& timestamp);
void SetReceivedStereo(bool receivedStereo); void set_received_stereo(bool received_stereo);
WebRtc_UWord8 NumSlaves(); WebRtc_UWord8 num_slaves();
enum JB {
masterJB = 0,
slaveJB = 1
};
// Delete all slaves. // Delete all slaves.
void RemoveSlaves(); void RemoveSlaves();
WebRtc_Word16 AddSlave(const WebRtcNetEQDecoder* usedCodecs, WebRtc_Word16 AddSlave(const WebRtcNetEQDecoder* used_codecs,
WebRtc_Word16 noOfCodecs); WebRtc_Word16 num_codecs);
private: private:
// //
@ -279,34 +279,35 @@ class ACMNetEQ {
// a WebRtcRTPHeader. // a WebRtcRTPHeader.
// //
// Input: // Input:
// - payload : Payload to be packetized. // - payload : Payload to be packetized.
// - payloadLengthW8 : Length of the payload in bytes. // - payload_length_bytes : Length of the payload in bytes.
// - rtpInfo : RTP header struct. // - rtp_info : RTP header structure.
// //
// Output: // Output:
// - rtpPacket : The RTP packet. // - rtp_packet : The RTP packet.
// //
static void RTPPack(WebRtc_Word16* rtpPacket, const WebRtc_Word8* payload, static void RTPPack(WebRtc_Word16* rtp_packet, const WebRtc_Word8* payload,
const WebRtc_Word32 payloadLengthW8, const WebRtc_Word32 payload_length_bytes,
const WebRtcRTPHeader& rtpInfo); const WebRtcRTPHeader& rtp_info);
void LogError(const char* neteqFuncName, const WebRtc_Word16 idx) const; void LogError(const char* neteq_func_name, const WebRtc_Word16 idx) const;
WebRtc_Word16 InitByIdxSafe(const WebRtc_Word16 idx); WebRtc_Word16 InitByIdxSafe(const WebRtc_Word16 idx);
//
// EnableVAD() // EnableVAD()
// Enable VAD. // Enable VAD.
// //
// Return value : 0 if ok. // Return value : 0 if ok.
// -1 if an error occurred. // -1 if an error occurred.
// //
WebRtc_Word16 EnableVAD(); WebRtc_Word16 EnableVAD();
WebRtc_Word16 EnableVADByIdxSafe(const WebRtc_Word16 idx); WebRtc_Word16 EnableVADByIdxSafe(const WebRtc_Word16 idx);
WebRtc_Word16 AllocatePacketBufferByIdxSafe( WebRtc_Word16 AllocatePacketBufferByIdxSafe(
const WebRtcNetEQDecoder* usedCodecs, const WebRtcNetEQDecoder* used_codecs,
WebRtc_Word16 noOfCodecs, WebRtc_Word16 num_codecs,
const WebRtc_Word16 idx); const WebRtc_Word16 idx);
// Delete the NetEQ corresponding to |index|. // Delete the NetEQ corresponding to |index|.
@ -314,32 +315,32 @@ class ACMNetEQ {
void RemoveSlavesSafe(); void RemoveSlavesSafe();
void* _inst[MAX_NUM_SLAVE_NETEQ + 1]; void* inst_[MAX_NUM_SLAVE_NETEQ + 1];
void* _instMem[MAX_NUM_SLAVE_NETEQ + 1]; void* inst_mem_[MAX_NUM_SLAVE_NETEQ + 1];
WebRtc_Word16* _netEqPacketBuffer[MAX_NUM_SLAVE_NETEQ + 1]; WebRtc_Word16* neteq_packet_buffer_[MAX_NUM_SLAVE_NETEQ + 1];
WebRtc_Word32 _id; WebRtc_Word32 id_;
float _currentSampFreqKHz; float current_samp_freq_khz_;
bool _avtPlayout; bool avt_playout_;
AudioPlayoutMode _playoutMode; AudioPlayoutMode playout_mode_;
CriticalSectionWrapper* _netEqCritSect; CriticalSectionWrapper* neteq_crit_sect_;
WebRtcVadInst* _ptrVADInst[MAX_NUM_SLAVE_NETEQ + 1]; WebRtcVadInst* ptr_vadinst_[MAX_NUM_SLAVE_NETEQ + 1];
bool _vadStatus; bool vad_status_;
ACMVADMode _vadMode; ACMVADMode vad_mode_;
RWLockWrapper* _decodeLock; RWLockWrapper* decode_lock_;
bool _isInitialized[MAX_NUM_SLAVE_NETEQ + 1]; bool is_initialized_[MAX_NUM_SLAVE_NETEQ + 1];
WebRtc_UWord8 _numSlaves; WebRtc_UWord8 num_slaves_;
bool _receivedStereo; bool received_stereo_;
void* _masterSlaveInfo; void* master_slave_info_;
AudioFrame::VADActivity _previousAudioActivity; AudioFrame::VADActivity previous_audio_activity_;
WebRtc_Word32 _extraDelay; WebRtc_Word32 extra_delay_;
CriticalSectionWrapper* _callbackCritSect; CriticalSectionWrapper* callback_crit_sect_;
}; };
} //namespace webrtc } // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_ #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_

View File

@ -10,16 +10,17 @@
// This file contains unit tests for ACM's NetEQ wrapper (class ACMNetEQ). // This file contains unit tests for ACM's NetEQ wrapper (class ACMNetEQ).
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include <stdlib.h> #include <stdlib.h>
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "modules/audio_coding/codecs/pcm16b/include/pcm16b.h" #include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h"
#include "modules/audio_coding/main/interface/audio_coding_module_typedefs.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "modules/audio_coding/main/source/acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/interface/module_common_types.h"
#include "modules/interface/module_common_types.h" #include "webrtc/typedefs.h"
#include "typedefs.h" // NOLINT(build/include)
namespace webrtc { namespace webrtc {

View File

@ -8,29 +8,29 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_opus.h" #include "webrtc/modules/audio_coding/main/source/acm_opus.h"
#include "acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "trace.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/system_wrappers/interface/trace.h"
#ifdef WEBRTC_CODEC_OPUS #ifdef WEBRTC_CODEC_OPUS
#include "modules/audio_coding/codecs/opus/interface/opus_interface.h" #include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h"
#endif #endif
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_OPUS #ifndef WEBRTC_CODEC_OPUS
ACMOpus::ACMOpus(int16_t /* codecID */) ACMOpus::ACMOpus(int16_t /* codec_id */)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL), decoder_inst_ptr_(NULL),
_sampleFreq(0), sample_freq_(0),
_bitrate(0), bitrate_(0),
_channels(1) { channels_(1) {
return; return;
} }
@ -38,29 +38,29 @@ ACMOpus::~ACMOpus() {
return; return;
} }
int16_t ACMOpus::InternalEncode(uint8_t* /* bitStream */, int16_t ACMOpus::InternalEncode(uint8_t* /* bitstream */,
int16_t* /* bitStreamLenByte */) { int16_t* /* bitstream_len_byte */) {
return -1; return -1;
} }
int16_t ACMOpus::DecodeSafe(uint8_t* /* bitStream */, int16_t ACMOpus::DecodeSafe(uint8_t* /* bitstream */,
int16_t /* bitStreamLenByte */, int16_t /* bitstream_len_byte */,
int16_t* /* audio */, int16_t* /* audio */,
int16_t* /* audioSamples */, int16_t* /* audio_samples */,
int8_t* /* speechType */) { int8_t* /* speech_type */) {
return -1; return -1;
} }
int16_t ACMOpus::InternalInitEncoder(WebRtcACMCodecParams* /* codecParams */) { int16_t ACMOpus::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
int16_t ACMOpus::InternalInitDecoder(WebRtcACMCodecParams* /* codecParams */) { int16_t ACMOpus::InternalInitDecoder(WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
int32_t ACMOpus::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, int32_t ACMOpus::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -84,7 +84,7 @@ void ACMOpus::DestructDecoderSafe() {
return; return;
} }
void ACMOpus::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMOpus::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
@ -101,119 +101,120 @@ void ACMOpus::SplitStereoPacket(uint8_t* /*payload*/,
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMOpus::ACMOpus(int16_t codecID) ACMOpus::ACMOpus(int16_t codec_id)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL), decoder_inst_ptr_(NULL),
_sampleFreq(32000), // Default sampling frequency. sample_freq_(32000), // Default sampling frequency.
_bitrate(20000), // Default bit-rate. bitrate_(20000), // Default bit-rate.
_channels(1) { // Default mono channels_(1) { // Default mono
_codecID = codecID; codec_id_ = codec_id;
// Opus has internal DTX, but we dont use it for now. // Opus has internal DTX, but we dont use it for now.
_hasInternalDTX = false; has_internal_dtx_ = false;
if (_codecID != ACMCodecDB::kOpus) { if (codec_id_ != ACMCodecDB::kOpus) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Wrong codec id for Opus."); "Wrong codec id for Opus.");
_sampleFreq = -1; sample_freq_ = -1;
_bitrate = -1; bitrate_ = -1;
} }
return; return;
} }
ACMOpus::~ACMOpus() { ACMOpus::~ACMOpus() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcOpus_EncoderFree(_encoderInstPtr); WebRtcOpus_EncoderFree(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcOpus_DecoderFree(_decoderInstPtr); WebRtcOpus_DecoderFree(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
return; return;
} }
int16_t ACMOpus::InternalEncode(uint8_t* bitStream, int16_t* bitStreamLenByte) { int16_t ACMOpus::InternalEncode(uint8_t* bitstream,
int16_t* bitstream_len_byte) {
// Call Encoder. // Call Encoder.
*bitStreamLenByte = WebRtcOpus_Encode(_encoderInstPtr, *bitstream_len_byte = WebRtcOpus_Encode(encoder_inst_ptr_,
&_inAudio[_inAudioIxRead], &in_audio_[in_audio_ix_read_],
_frameLenSmpl, frame_len_smpl_,
MAX_PAYLOAD_SIZE_BYTE, MAX_PAYLOAD_SIZE_BYTE, bitstream);
bitStream);
// Check for error reported from encoder. // Check for error reported from encoder.
if (*bitStreamLenByte < 0) { if (*bitstream_len_byte < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalEncode: Encode error for Opus"); "InternalEncode: Encode error for Opus");
*bitStreamLenByte = 0; *bitstream_len_byte = 0;
return -1; return -1;
} }
// Increment the read index. This tells the caller how far // Increment the read index. This tells the caller how far
// we have gone forward in reading the audio buffer. // we have gone forward in reading the audio buffer.
_inAudioIxRead += _frameLenSmpl * _channels; in_audio_ix_read_ += frame_len_smpl_ * channels_;
return *bitStreamLenByte; return *bitstream_len_byte;
} }
int16_t ACMOpus::DecodeSafe(uint8_t* bitStream, int16_t bitStreamLenByte, int16_t ACMOpus::DecodeSafe(uint8_t* bitstream, int16_t bitstream_len_byte,
int16_t* audio, int16_t* audioSamples, int16_t* audio, int16_t* audio_samples,
int8_t* speechType) { int8_t* speech_type) {
return 0; return 0;
} }
int16_t ACMOpus::InternalInitEncoder(WebRtcACMCodecParams* codecParams) { int16_t ACMOpus::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
int16_t ret; int16_t ret;
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcOpus_EncoderFree(_encoderInstPtr); WebRtcOpus_EncoderFree(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
ret = WebRtcOpus_EncoderCreate(&_encoderInstPtr, ret = WebRtcOpus_EncoderCreate(&encoder_inst_ptr_,
codecParams->codecInstant.channels); codec_params->codec_inst.channels);
// Store number of channels. // Store number of channels.
_channels = codecParams->codecInstant.channels; channels_ = codec_params->codec_inst.channels;
if (ret < 0) { if (ret < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Encoder creation failed for Opus"); "Encoder creation failed for Opus");
return ret; return ret;
} }
ret = WebRtcOpus_SetBitRate(_encoderInstPtr, codecParams->codecInstant.rate); ret = WebRtcOpus_SetBitRate(encoder_inst_ptr_,
codec_params->codec_inst.rate);
if (ret < 0) { if (ret < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Setting initial bitrate failed for Opus"); "Setting initial bitrate failed for Opus");
return ret; return ret;
} }
// Store bitrate. // Store bitrate.
_bitrate = codecParams->codecInstant.rate; bitrate_ = codec_params->codec_inst.rate;
return 0; return 0;
} }
int16_t ACMOpus::InternalInitDecoder(WebRtcACMCodecParams* codecParams) { int16_t ACMOpus::InternalInitDecoder(WebRtcACMCodecParams* codec_params) {
if(_decoderInstPtr == NULL) { if (decoder_inst_ptr_ == NULL) {
if (WebRtcOpus_DecoderCreate(&_decoderInstPtr, if (WebRtcOpus_DecoderCreate(&decoder_inst_ptr_,
codecParams->codecInstant.channels) < 0) { codec_params->codec_inst.channels) < 0) {
return -1; return -1;
} }
} }
// Number of channels in decoder should match the number in |codecParams|. // Number of channels in decoder should match the number in |codec_params|.
assert(codecParams->codecInstant.channels == assert(codec_params->codec_inst.channels ==
WebRtcOpus_DecoderChannels(_decoderInstPtr)); WebRtcOpus_DecoderChannels(decoder_inst_ptr_));
if (WebRtcOpus_DecoderInit(_decoderInstPtr) < 0) { if (WebRtcOpus_DecoderInit(decoder_inst_ptr_) < 0) {
return -1; return -1;
} }
if (WebRtcOpus_DecoderInitSlave(_decoderInstPtr) < 0) { if (WebRtcOpus_DecoderInitSlave(decoder_inst_ptr_) < 0) {
return -1; return -1;
} }
return 0; return 0;
} }
int32_t ACMOpus::CodecDef(WebRtcNetEQ_CodecDef& codecDef, int32_t ACMOpus::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!_decoderInitialized) { if (!decoder_initialized_) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"CodeDef: Decoder uninitialized for Opus"); "CodeDef: Decoder uninitialized for Opus");
return -1; return -1;
} }
@ -223,21 +224,20 @@ int32_t ACMOpus::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
// TODO(tlegrand): Decoder is registered in NetEQ as a 32 kHz decoder, which // TODO(tlegrand): Decoder is registered in NetEQ as a 32 kHz decoder, which
// is true until we have a full 48 kHz system, and remove the downsampling // is true until we have a full 48 kHz system, and remove the downsampling
// in the Opus decoder wrapper. // in the Opus decoder wrapper.
SET_CODEC_PAR(codecDef, kDecoderOpus, codecInst.pltype, SET_CODEC_PAR(codec_def, kDecoderOpus, codec_inst.pltype,
_decoderInstPtr, 32000); decoder_inst_ptr_, 32000);
// If this is the master of NetEQ, regular decoder will be added, otherwise // If this is the master of NetEQ, regular decoder will be added, otherwise
// the slave decoder will be used. // the slave decoder will be used.
if (_isMaster) { if (is_master_) {
SET_OPUS_FUNCTIONS(codecDef); SET_OPUS_FUNCTIONS(codec_def);
} else { } else {
SET_OPUSSLAVE_FUNCTIONS(codecDef); SET_OPUSSLAVE_FUNCTIONS(codec_def);
} }
return 0; return 0;
} }
ACMGenericCodec* ACMOpus::CreateInstance(void) { ACMGenericCodec* ACMOpus::CreateInstance(void) {
return NULL; return NULL;
} }
@ -248,9 +248,9 @@ int16_t ACMOpus::InternalCreateEncoder() {
} }
void ACMOpus::DestructEncoderSafe() { void ACMOpus::DestructEncoderSafe() {
if (_encoderInstPtr) { if (encoder_inst_ptr_) {
WebRtcOpus_EncoderFree(_encoderInstPtr); WebRtcOpus_EncoderFree(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
} }
@ -260,32 +260,32 @@ int16_t ACMOpus::InternalCreateDecoder() {
} }
void ACMOpus::DestructDecoderSafe() { void ACMOpus::DestructDecoderSafe() {
_decoderInitialized = false; decoder_initialized_ = false;
if (_decoderInstPtr) { if (decoder_inst_ptr_) {
WebRtcOpus_DecoderFree(_decoderInstPtr); WebRtcOpus_DecoderFree(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
} }
void ACMOpus::InternalDestructEncoderInst(void* ptrInst) { void ACMOpus::InternalDestructEncoderInst(void* ptr_inst) {
if (ptrInst != NULL) { if (ptr_inst != NULL) {
WebRtcOpus_EncoderFree((OpusEncInst*) ptrInst); WebRtcOpus_EncoderFree((OpusEncInst*) ptr_inst);
} }
return; return;
} }
int16_t ACMOpus::SetBitRateSafe(const int32_t rate) { int16_t ACMOpus::SetBitRateSafe(const int32_t rate) {
if (rate < 6000 || rate > 510000) { if (rate < 6000 || rate > 510000) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetBitRateSafe: Invalid rate Opus"); "SetBitRateSafe: Invalid rate Opus");
return -1; return -1;
} }
_bitrate = rate; bitrate_ = rate;
// Ask the encoder for the new rate. // Ask the encoder for the new rate.
if (WebRtcOpus_SetBitRate(_encoderInstPtr, _bitrate) >= 0) { if (WebRtcOpus_SetBitRate(encoder_inst_ptr_, bitrate_) >= 0) {
_encoderParams.codecInstant.rate = _bitrate; encoder_params_.codec_inst.rate = bitrate_;
return 0; return 0;
} }

View File

@ -11,8 +11,8 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_
#include "acm_generic_codec.h" #include "webrtc/common_audio/resampler/include/resampler.h"
#include "resampler.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
struct WebRtcOpusEncInst; struct WebRtcOpusEncInst;
struct WebRtcOpusDecInst; struct WebRtcOpusDecInst;
@ -21,22 +21,26 @@ namespace webrtc {
class ACMOpus : public ACMGenericCodec { class ACMOpus : public ACMGenericCodec {
public: public:
ACMOpus(int16_t codecID); explicit ACMOpus(int16_t codec_id);
~ACMOpus(); ~ACMOpus();
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
int16_t InternalEncode(uint8_t* bitstream, int16_t* bitStreamLenByte); int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte);
int16_t InternalInitEncoder(WebRtcACMCodecParams *codecParams); int16_t InternalInitEncoder(WebRtcACMCodecParams *codec_params);
int16_t InternalInitDecoder(WebRtcACMCodecParams *codecParams); int16_t InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
int16_t DecodeSafe(uint8_t* bitStream, int16_t bitStreamLenByte, int16_t DecodeSafe(uint8_t* bitstream,
int16_t* audio, int16_t* audioSamples, int8_t* speechType); int16_t bitstream_len_byte,
int16_t* audio,
int16_t* audio_samples,
int8_t* speech_type);
int32_t CodecDef(WebRtcNetEQ_CodecDef& codecDef, const CodecInst& codecInst); int32_t CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -46,7 +50,7 @@ class ACMOpus : public ACMGenericCodec {
int16_t InternalCreateDecoder(); int16_t InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
int16_t SetBitRateSafe(const int32_t rate); int16_t SetBitRateSafe(const int32_t rate);
@ -54,11 +58,11 @@ class ACMOpus : public ACMGenericCodec {
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length); void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
WebRtcOpusEncInst* _encoderInstPtr; WebRtcOpusEncInst* encoder_inst_ptr_;
WebRtcOpusDecInst* _decoderInstPtr; WebRtcOpusDecInst* decoder_inst_ptr_;
uint16_t _sampleFreq; uint16_t sample_freq_;
uint16_t _bitrate; uint16_t bitrate_;
int _channels; int channels_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -8,24 +8,24 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_pcm16b.h" #include "webrtc/modules/audio_coding/main/source/acm_pcm16b.h"
#include "acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "trace.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/system_wrappers/interface/trace.h"
#ifdef WEBRTC_CODEC_PCM16 #ifdef WEBRTC_CODEC_PCM16
#include "pcm16b.h" #include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h"
#endif #endif
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_PCM16 #ifndef WEBRTC_CODEC_PCM16
ACMPCM16B::ACMPCM16B(WebRtc_Word16 /* codecID */) { ACMPCM16B::ACMPCM16B(WebRtc_Word16 /* codec_id */) {
return; return;
} }
@ -33,31 +33,32 @@ ACMPCM16B::~ACMPCM16B() {
return; return;
} }
WebRtc_Word16 ACMPCM16B::InternalEncode(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMPCM16B::InternalEncode(
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitstream_len_byte */) {
return -1; return -1;
} }
WebRtc_Word16 ACMPCM16B::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMPCM16B::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return -1; return -1;
} }
WebRtc_Word16 ACMPCM16B::InternalInitEncoder( WebRtc_Word16 ACMPCM16B::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word16 ACMPCM16B::InternalInitDecoder( WebRtc_Word16 ACMPCM16B::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -73,7 +74,7 @@ WebRtc_Word16 ACMPCM16B::InternalCreateDecoder() {
return -1; return -1;
} }
void ACMPCM16B::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMPCM16B::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
@ -90,67 +91,67 @@ void ACMPCM16B::SplitStereoPacket(uint8_t* /*payload*/,
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMPCM16B::ACMPCM16B(WebRtc_Word16 codecID) { ACMPCM16B::ACMPCM16B(WebRtc_Word16 codec_id) {
_codecID = codecID; codec_id_ = codec_id;
_samplingFreqHz = ACMCodecDB::CodecFreq(_codecID); sampling_freq_hz_ = ACMCodecDB::CodecFreq(codec_id_);
} }
ACMPCM16B::~ACMPCM16B() { ACMPCM16B::~ACMPCM16B() {
return; return;
} }
WebRtc_Word16 ACMPCM16B::InternalEncode(WebRtc_UWord8* bitStream, WebRtc_Word16 ACMPCM16B::InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte) { WebRtc_Word16* bitstream_len_byte) {
*bitStreamLenByte = WebRtcPcm16b_Encode(&_inAudio[_inAudioIxRead], *bitstream_len_byte = WebRtcPcm16b_Encode(&in_audio_[in_audio_ix_read_],
_frameLenSmpl * _noChannels, frame_len_smpl_ * num_channels_,
bitStream); bitstream);
// Increment the read index to tell the caller that how far // Increment the read index to tell the caller that how far
// we have gone forward in reading the audio buffer. // we have gone forward in reading the audio buffer.
_inAudioIxRead += _frameLenSmpl * _noChannels; in_audio_ix_read_ += frame_len_smpl_ * num_channels_;
return *bitStreamLenByte; return *bitstream_len_byte;
} }
WebRtc_Word16 ACMPCM16B::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMPCM16B::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMPCM16B::InternalInitEncoder( WebRtc_Word16 ACMPCM16B::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
// This codec does not need initialization, PCM has no instance. // This codec does not need initialization, PCM has no instance.
return 0; return 0;
} }
WebRtc_Word16 ACMPCM16B::InternalInitDecoder( WebRtc_Word16 ACMPCM16B::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
// This codec does not need initialization, PCM has no instance. // This codec does not need initialization, PCM has no instance.
return 0; return 0;
} }
WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
// Fill up the structure by calling "SET_CODEC_PAR" & "SET_PCMU_FUNCTION". // Fill up the structure by calling "SET_CODEC_PAR" & "SET_PCMU_FUNCTION".
// Then call NetEQ to add the codec to it's database. // Then call NetEQ to add the codec to it's database.
if (codecInst.channels == 1) { if (codec_inst.channels == 1) {
switch(_samplingFreqHz) { switch (sampling_freq_hz_) {
case 8000: { case 8000: {
SET_CODEC_PAR(codecDef, kDecoderPCM16B, codecInst.pltype, NULL, 8000); SET_CODEC_PAR(codec_def, kDecoderPCM16B, codec_inst.pltype, NULL, 8000);
SET_PCM16B_FUNCTIONS(codecDef); SET_PCM16B_FUNCTIONS(codec_def);
break; break;
} }
case 16000: { case 16000: {
SET_CODEC_PAR(codecDef, kDecoderPCM16Bwb, codecInst.pltype, NULL, SET_CODEC_PAR(codec_def, kDecoderPCM16Bwb, codec_inst.pltype, NULL,
16000); 16000);
SET_PCM16B_WB_FUNCTIONS(codecDef); SET_PCM16B_WB_FUNCTIONS(codec_def);
break; break;
} }
case 32000: { case 32000: {
SET_CODEC_PAR(codecDef, kDecoderPCM16Bswb32kHz, codecInst.pltype, SET_CODEC_PAR(codec_def, kDecoderPCM16Bswb32kHz, codec_inst.pltype,
NULL, 32000); NULL, 32000);
SET_PCM16B_SWB32_FUNCTIONS(codecDef); SET_PCM16B_SWB32_FUNCTIONS(codec_def);
break; break;
} }
default: { default: {
@ -158,23 +159,23 @@ WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
} }
} }
} else { } else {
switch(_samplingFreqHz) { switch (sampling_freq_hz_) {
case 8000: { case 8000: {
SET_CODEC_PAR(codecDef, kDecoderPCM16B_2ch, codecInst.pltype, NULL, SET_CODEC_PAR(codec_def, kDecoderPCM16B_2ch, codec_inst.pltype, NULL,
8000); 8000);
SET_PCM16B_FUNCTIONS(codecDef); SET_PCM16B_FUNCTIONS(codec_def);
break; break;
} }
case 16000: { case 16000: {
SET_CODEC_PAR(codecDef, kDecoderPCM16Bwb_2ch, codecInst.pltype, SET_CODEC_PAR(codec_def, kDecoderPCM16Bwb_2ch, codec_inst.pltype,
NULL, 16000); NULL, 16000);
SET_PCM16B_WB_FUNCTIONS(codecDef); SET_PCM16B_WB_FUNCTIONS(codec_def);
break; break;
} }
case 32000: { case 32000: {
SET_CODEC_PAR(codecDef, kDecoderPCM16Bswb32kHz_2ch, codecInst.pltype, SET_CODEC_PAR(codec_def, kDecoderPCM16Bswb32kHz_2ch, codec_inst.pltype,
NULL, 32000); NULL, 32000);
SET_PCM16B_SWB32_FUNCTIONS(codecDef); SET_PCM16B_SWB32_FUNCTIONS(codec_def);
break; break;
} }
default: { default: {
@ -199,22 +200,22 @@ WebRtc_Word16 ACMPCM16B::InternalCreateDecoder() {
return 0; return 0;
} }
void ACMPCM16B::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMPCM16B::InternalDestructEncoderInst(void* /* ptr_inst */) {
// PCM has no instance. // PCM has no instance.
return; return;
} }
void ACMPCM16B::DestructEncoderSafe() { void ACMPCM16B::DestructEncoderSafe() {
// PCM has no instance. // PCM has no instance.
_encoderExist = false; encoder_exist_ = false;
_encoderInitialized = false; encoder_initialized_ = false;
return; return;
} }
void ACMPCM16B::DestructDecoderSafe() { void ACMPCM16B::DestructDecoderSafe() {
// PCM has no instance. // PCM has no instance.
_decoderExist = false; decoder_exist_ = false;
_decoderInitialized = false; decoder_initialized_ = false;
return; return;
} }

View File

@ -11,33 +11,34 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
namespace webrtc { namespace webrtc {
class ACMPCM16B : public ACMGenericCodec { class ACMPCM16B : public ACMGenericCodec {
public: public:
ACMPCM16B(WebRtc_Word16 codecID); explicit ACMPCM16B(WebRtc_Word16 codec_id);
~ACMPCM16B(); ~ACMPCM16B();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -47,11 +48,11 @@ class ACMPCM16B : public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length); void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
WebRtc_Word32 _samplingFreqHz; WebRtc_Word32 sampling_freq_hz_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -8,71 +8,71 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_pcma.h" #include "webrtc/modules/audio_coding/main/source/acm_pcma.h"
#include "acm_common_defs.h" #include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "trace.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc/system_wrappers/interface/trace.h"
// Codec interface // Codec interface
#include "g711_interface.h"
namespace webrtc { namespace webrtc {
ACMPCMA::ACMPCMA(WebRtc_Word16 codecID) { ACMPCMA::ACMPCMA(WebRtc_Word16 codec_id) {
_codecID = codecID; codec_id_ = codec_id;
} }
ACMPCMA::~ACMPCMA() { ACMPCMA::~ACMPCMA() {
return; return;
} }
WebRtc_Word16 ACMPCMA::InternalEncode(WebRtc_UWord8* bitStream, WebRtc_Word16 ACMPCMA::InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte) { WebRtc_Word16* bitstream_len_byte) {
*bitStreamLenByte = WebRtcG711_EncodeA(NULL, &_inAudio[_inAudioIxRead], *bitstream_len_byte = WebRtcG711_EncodeA(NULL, &in_audio_[in_audio_ix_read_],
_frameLenSmpl * _noChannels, frame_len_smpl_ * num_channels_,
(WebRtc_Word16*) bitStream); (WebRtc_Word16*) bitstream);
// Increment the read index this tell the caller that how far // Increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer. // we have gone forward in reading the audio buffer.
_inAudioIxRead += _frameLenSmpl * _noChannels; in_audio_ix_read_ += frame_len_smpl_ * num_channels_;
return *bitStreamLenByte; return *bitstream_len_byte;
} }
WebRtc_Word16 ACMPCMA::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMPCMA::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMPCMA::InternalInitEncoder( WebRtc_Word16 ACMPCMA::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
// This codec does not need initialization, PCM has no instance. // This codec does not need initialization, PCM has no instance.
return 0; return 0;
} }
WebRtc_Word16 ACMPCMA::InternalInitDecoder( WebRtc_Word16 ACMPCMA::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
// This codec does not need initialization, PCM has no instance. // This codec does not need initialization, PCM has no instance.
return 0; return 0;
} }
WebRtc_Word32 ACMPCMA::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMPCMA::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
// Fill up the structure by calling // Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_PCMA_FUNCTION." // "SET_CODEC_PAR" & "SET_PCMA_FUNCTION."
// Then call NetEQ to add the codec to it's database. // Then call NetEQ to add the codec to it's database.
if (codecInst.channels == 1) { if (codec_inst.channels == 1) {
// Mono mode. // Mono mode.
SET_CODEC_PAR(codecDef, kDecoderPCMa, codecInst.pltype, NULL, 8000); SET_CODEC_PAR(codec_def, kDecoderPCMa, codec_inst.pltype, NULL, 8000);
} else { } else {
// Stereo mode. // Stereo mode.
SET_CODEC_PAR(codecDef, kDecoderPCMa_2ch, codecInst.pltype, NULL, 8000); SET_CODEC_PAR(codec_def, kDecoderPCMa_2ch, codec_inst.pltype, NULL, 8000);
} }
SET_PCMA_FUNCTIONS(codecDef); SET_PCMA_FUNCTIONS(codec_def);
return 0; return 0;
} }
@ -90,7 +90,7 @@ WebRtc_Word16 ACMPCMA::InternalCreateDecoder() {
return 0; return 0;
} }
void ACMPCMA::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMPCMA::InternalDestructEncoderInst(void* /* ptr_inst */) {
// PCM has no instance. // PCM has no instance.
return; return;
} }
@ -102,8 +102,8 @@ void ACMPCMA::DestructEncoderSafe() {
void ACMPCMA::DestructDecoderSafe() { void ACMPCMA::DestructDecoderSafe() {
// PCM has no instance. // PCM has no instance.
_decoderInitialized = false; decoder_initialized_ = false;
_decoderExist = false; decoder_exist_ = false;
return; return;
} }

View File

@ -11,33 +11,34 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
namespace webrtc { namespace webrtc {
class ACMPCMA : public ACMGenericCodec { class ACMPCMA : public ACMGenericCodec {
public: public:
ACMPCMA(WebRtc_Word16 codecID); explicit ACMPCMA(WebRtc_Word16 codec_id);
~ACMPCMA(); ~ACMPCMA();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -47,7 +48,7 @@ class ACMPCMA : public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length); void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
}; };

View File

@ -8,71 +8,71 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_pcmu.h" #include "webrtc/modules/audio_coding/main/source/acm_pcmu.h"
#include "acm_common_defs.h" #include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "trace.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc/system_wrappers/interface/trace.h"
// Codec interface // Codec interface
#include "g711_interface.h"
namespace webrtc { namespace webrtc {
ACMPCMU::ACMPCMU(WebRtc_Word16 codecID) { ACMPCMU::ACMPCMU(WebRtc_Word16 codec_id) {
_codecID = codecID; codec_id_ = codec_id;
} }
ACMPCMU::~ACMPCMU() { ACMPCMU::~ACMPCMU() {
return; return;
} }
WebRtc_Word16 ACMPCMU::InternalEncode(WebRtc_UWord8* bitStream, WebRtc_Word16 ACMPCMU::InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte) { WebRtc_Word16* bitstream_len_byte) {
*bitStreamLenByte = WebRtcG711_EncodeU(NULL, &_inAudio[_inAudioIxRead], *bitstream_len_byte = WebRtcG711_EncodeU(NULL, &in_audio_[in_audio_ix_read_],
_frameLenSmpl * _noChannels, frame_len_smpl_ * num_channels_,
(WebRtc_Word16*) bitStream); (WebRtc_Word16*)bitstream);
// Increment the read index this tell the caller that how far // Increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer. // we have gone forward in reading the audio buffer.
_inAudioIxRead += _frameLenSmpl * _noChannels; in_audio_ix_read_ += frame_len_smpl_ * num_channels_;
return *bitStreamLenByte; return *bitstream_len_byte;
} }
WebRtc_Word16 ACMPCMU::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMPCMU::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMPCMU::InternalInitEncoder( WebRtc_Word16 ACMPCMU::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
// This codec does not need initialization, PCM has no instance. // This codec does not need initialization, PCM has no instance.
return 0; return 0;
} }
WebRtc_Word16 ACMPCMU::InternalInitDecoder( WebRtc_Word16 ACMPCMU::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
// This codec does not need initialization, PCM has no instance. // This codec does not need initialization, PCM has no instance.
return 0; return 0;
} }
WebRtc_Word32 ACMPCMU::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMPCMU::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
// Fill up the structure by calling // Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_PCMU_FUNCTION." // "SET_CODEC_PAR" & "SET_PCMU_FUNCTION."
// Then call NetEQ to add the codec to it's database. // Then call NetEQ to add the codec to it's database.
if (codecInst.channels == 1) { if (codec_inst.channels == 1) {
// Mono mode. // Mono mode.
SET_CODEC_PAR(codecDef, kDecoderPCMu, codecInst.pltype, NULL, 8000); SET_CODEC_PAR(codec_def, kDecoderPCMu, codec_inst.pltype, NULL, 8000);
} else { } else {
// Stereo mode. // Stereo mode.
SET_CODEC_PAR(codecDef, kDecoderPCMu_2ch, codecInst.pltype, NULL, 8000); SET_CODEC_PAR(codec_def, kDecoderPCMu_2ch, codec_inst.pltype, NULL, 8000);
} }
SET_PCMU_FUNCTIONS(codecDef); SET_PCMU_FUNCTIONS(codec_def);
return 0; return 0;
} }
@ -90,22 +90,22 @@ WebRtc_Word16 ACMPCMU::InternalCreateDecoder() {
return 0; return 0;
} }
void ACMPCMU::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMPCMU::InternalDestructEncoderInst(void* /* ptr_inst */) {
// PCM has no instance. // PCM has no instance.
return; return;
} }
void ACMPCMU::DestructEncoderSafe() { void ACMPCMU::DestructEncoderSafe() {
// PCM has no instance. // PCM has no instance.
_encoderExist = false; encoder_exist_ = false;
_encoderInitialized = false; encoder_initialized_ = false;
return; return;
} }
void ACMPCMU::DestructDecoderSafe() { void ACMPCMU::DestructDecoderSafe() {
// PCM has no instance. // PCM has no instance.
_decoderInitialized = false; decoder_initialized_ = false;
_decoderExist = false; decoder_exist_ = false;
return; return;
} }

View File

@ -11,33 +11,34 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
namespace webrtc { namespace webrtc {
class ACMPCMU : public ACMGenericCodec { class ACMPCMU : public ACMGenericCodec {
public: public:
ACMPCMU(WebRtc_Word16 codecID); explicit ACMPCMU(WebRtc_Word16 codec_id);
~ACMPCMU(); ~ACMPCMU();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -47,7 +48,7 @@ class ACMPCMU : public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length); void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
}; };

View File

@ -8,55 +8,56 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_red.h" #include "webrtc/modules/audio_coding/main/source/acm_red.h"
#include "acm_neteq.h"
#include "acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "trace.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc { namespace webrtc {
ACMRED::ACMRED(WebRtc_Word16 codecID) { ACMRED::ACMRED(WebRtc_Word16 codec_id) {
_codecID = codecID; codec_id_ = codec_id;
} }
ACMRED::~ACMRED() { ACMRED::~ACMRED() {
return; return;
} }
WebRtc_Word16 ACMRED::InternalEncode(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMRED::InternalEncode(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_Word16* /* bitstream_len_byte */) {
// RED is never used as an encoder // RED is never used as an encoder
// RED has no instance // RED has no instance
return 0; return 0;
} }
WebRtc_Word16 ACMRED::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMRED::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMRED::InternalInitEncoder( WebRtc_Word16 ACMRED::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
// This codec does not need initialization, // This codec does not need initialization,
// RED has no instance // RED has no instance
return 0; return 0;
} }
WebRtc_Word16 ACMRED::InternalInitDecoder( WebRtc_Word16 ACMRED::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
// This codec does not need initialization, // This codec does not need initialization,
// RED has no instance // RED has no instance
return 0; return 0;
} }
WebRtc_Word32 ACMRED::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMRED::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!_decoderInitialized) { if (!decoder_initialized_) {
// Todo: // Todo:
// log error // log error
return -1; return -1;
@ -66,8 +67,8 @@ WebRtc_Word32 ACMRED::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
// "SET_CODEC_PAR" & "SET_PCMU_FUNCTION." // "SET_CODEC_PAR" & "SET_PCMU_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
SET_CODEC_PAR((codecDef), kDecoderRED, codecInst.pltype, NULL, 8000); SET_CODEC_PAR((codec_def), kDecoderRED, codec_inst.pltype, NULL, 8000);
SET_RED_FUNCTIONS((codecDef)); SET_RED_FUNCTIONS((codec_def));
return 0; return 0;
} }
@ -85,7 +86,7 @@ WebRtc_Word16 ACMRED::InternalCreateDecoder() {
return 0; return 0;
} }
void ACMRED::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMRED::InternalDestructEncoderInst(void* /* ptr_inst */) {
// RED has no instance // RED has no instance
return; return;
} }

View File

@ -11,33 +11,34 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
namespace webrtc { namespace webrtc {
class ACMRED : public ACMGenericCodec { class ACMRED : public ACMGenericCodec {
public: public:
ACMRED(WebRtc_Word16 codecID); explicit ACMRED(WebRtc_Word16 codec_id);
~ACMRED(); ~ACMRED();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -47,7 +48,7 @@ class ACMRED : public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -8,65 +8,66 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "webrtc/modules/audio_coding/main/source/acm_resampler.h"
#include <string.h> #include <string.h>
#include "acm_resampler.h" #include "webrtc/common_audio/resampler/include/resampler.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
#include "critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "resampler.h" #include "webrtc/system_wrappers/interface/trace.h"
#include "signal_processing_library.h"
#include "trace.h"
namespace webrtc { namespace webrtc {
ACMResampler::ACMResampler() ACMResampler::ACMResampler()
: _resamplerCritSect(CriticalSectionWrapper::CreateCriticalSection()) { : resampler_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()) {
} }
ACMResampler::~ACMResampler() { ACMResampler::~ACMResampler() {
delete _resamplerCritSect; delete resampler_crit_sect_;
} }
WebRtc_Word16 ACMResampler::Resample10Msec(const WebRtc_Word16* inAudio, WebRtc_Word16 ACMResampler::Resample10Msec(const WebRtc_Word16* in_audio,
WebRtc_Word32 inFreqHz, WebRtc_Word32 in_freq_hz,
WebRtc_Word16* outAudio, WebRtc_Word16* out_audio,
WebRtc_Word32 outFreqHz, WebRtc_Word32 out_freq_hz,
WebRtc_UWord8 numAudioChannels) { WebRtc_UWord8 num_audio_channels) {
CriticalSectionScoped cs(_resamplerCritSect); CriticalSectionScoped cs(resampler_crit_sect_);
if (inFreqHz == outFreqHz) { if (in_freq_hz == out_freq_hz) {
size_t length = static_cast<size_t>(inFreqHz * numAudioChannels / 100); size_t length = static_cast<size_t>(in_freq_hz * num_audio_channels / 100);
memcpy(outAudio, inAudio, length * sizeof(WebRtc_Word16)); memcpy(out_audio, in_audio, length * sizeof(WebRtc_Word16));
return static_cast<WebRtc_Word16>(inFreqHz / 100); return static_cast<WebRtc_Word16>(in_freq_hz / 100);
} }
// |maxLen| is maximum number of samples for 10ms at 48kHz. // |maxLen| is maximum number of samples for 10ms at 48kHz.
int maxLen = 480 * numAudioChannels; int max_len = 480 * num_audio_channels;
int lengthIn = (WebRtc_Word16)(inFreqHz / 100) * numAudioChannels; int length_in = (WebRtc_Word16)(in_freq_hz / 100) * num_audio_channels;
int outLen; int out_len;
WebRtc_Word32 ret; WebRtc_Word32 ret;
ResamplerType type; ResamplerType type;
type = (numAudioChannels == 1) ? kResamplerSynchronous : type = (num_audio_channels == 1) ? kResamplerSynchronous :
kResamplerSynchronousStereo; kResamplerSynchronousStereo;
ret = _resampler.ResetIfNeeded(inFreqHz, outFreqHz, type); ret = resampler_.ResetIfNeeded(in_freq_hz, out_freq_hz, type);
if (ret < 0) { if (ret < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0,
"Error in reset of resampler"); "Error in reset of resampler");
return -1; return -1;
} }
ret = _resampler.Push(inAudio, lengthIn, outAudio, maxLen, outLen); ret = resampler_.Push(in_audio, length_in, out_audio, max_len, out_len);
if (ret < 0) { if (ret < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0,
"Error in resampler: resampler.Push"); "Error in resampler: resampler.Push");
return -1; return -1;
} }
WebRtc_Word16 outAudioLenSmpl = (WebRtc_Word16) outLen / numAudioChannels; WebRtc_Word16 out_audio_len_smpl = (WebRtc_Word16) out_len /
num_audio_channels;
return outAudioLenSmpl; return out_audio_len_smpl;
} }
} // namespace webrtc } // namespace webrtc

View File

@ -11,8 +11,8 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_
#include "resampler.h" #include "webrtc/common_audio/resampler/include/resampler.h"
#include "typedefs.h" #include "webrtc/typedefs.h"
namespace webrtc { namespace webrtc {
@ -23,16 +23,16 @@ class ACMResampler {
ACMResampler(); ACMResampler();
~ACMResampler(); ~ACMResampler();
WebRtc_Word16 Resample10Msec(const WebRtc_Word16* inAudio, WebRtc_Word16 Resample10Msec(const WebRtc_Word16* in_audio,
const WebRtc_Word32 inFreqHz, const WebRtc_Word32 in_freq_hz,
WebRtc_Word16* outAudio, WebRtc_Word16* out_audio,
const WebRtc_Word32 outFreqHz, const WebRtc_Word32 out_freq_hz,
WebRtc_UWord8 numAudioChannels); WebRtc_UWord8 num_audio_channels);
private: private:
// Use the Resampler class. // Use the Resampler class.
Resampler _resampler; Resampler resampler_;
CriticalSectionWrapper* _resamplerCritSect; CriticalSectionWrapper* resampler_crit_sect_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -8,13 +8,14 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_speex.h" #include "webrtc/modules/audio_coding/main/source/acm_speex.h"
#include "acm_codec_database.h"
#include "acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "trace.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc/system_wrappers/interface/trace.h"
#ifdef WEBRTC_CODEC_SPEEX #ifdef WEBRTC_CODEC_SPEEX
// NOTE! Speex is not included in the open-source package. Modify this file or // NOTE! Speex is not included in the open-source package. Modify this file or
@ -25,14 +26,14 @@
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_SPEEX #ifndef WEBRTC_CODEC_SPEEX
ACMSPEEX::ACMSPEEX(WebRtc_Word16 /* codecID */) ACMSPEEX::ACMSPEEX(WebRtc_Word16 /* codec_id */)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL), decoder_inst_ptr_(NULL),
_complMode(0), compl_mode_(0),
_vbrEnabled(false), vbr_enabled_(false),
_encodingRate(-1), encoding_rate_(-1),
_samplingFrequency(-1), sampling_frequency_(-1),
_samplesIn20MsAudio(-1) { samples_in_20ms_audio_(-1) {
return; return;
} }
@ -40,16 +41,17 @@ ACMSPEEX::~ACMSPEEX() {
return; return;
} }
WebRtc_Word16 ACMSPEEX::InternalEncode(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMSPEEX::InternalEncode(
WebRtc_Word16* /* bitStreamLenByte */) { WebRtc_UWord8* /* bitstream */,
WebRtc_Word16* /* bitstream_len_byte */) {
return -1; return -1;
} }
WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return -1; return -1;
} }
@ -62,17 +64,17 @@ WebRtc_Word16 ACMSPEEX::DisableDTX() {
} }
WebRtc_Word16 ACMSPEEX::InternalInitEncoder( WebRtc_Word16 ACMSPEEX::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word16 ACMSPEEX::InternalInitDecoder( WebRtc_Word16 ACMSPEEX::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
return -1; return -1;
} }
WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */, WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
const CodecInst& /* codecInst */) { const CodecInst& /* codec_inst */) {
return -1; return -1;
} }
@ -100,7 +102,7 @@ WebRtc_Word16 ACMSPEEX::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
return -1; return -1;
} }
void ACMSPEEX::InternalDestructEncoderInst(void* /* ptrInst */) { void ACMSPEEX::InternalDestructEncoderInst(void* /* ptr_inst */) {
return; return;
} }
@ -120,111 +122,110 @@ WebRtc_Word16 ACMSPEEX::SetComplMode(WebRtc_Word16 mode) {
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMSPEEX::ACMSPEEX(WebRtc_Word16 codecID) ACMSPEEX::ACMSPEEX(WebRtc_Word16 codec_id)
: _encoderInstPtr(NULL), : encoder_inst_ptr_(NULL),
_decoderInstPtr(NULL) { decoder_inst_ptr_(NULL) {
_codecID = codecID; codec_id_ = codec_id;
// Set sampling frequency, frame size and rate Speex // Set sampling frequency, frame size and rate Speex
if (_codecID == ACMCodecDB::kSPEEX8) { if (codec_id_ == ACMCodecDB::kSPEEX8) {
_samplingFrequency = 8000; sampling_frequency_ = 8000;
_samplesIn20MsAudio = 160; samples_in_20ms_audio_ = 160;
_encodingRate = 11000; encoding_rate_ = 11000;
} else if (_codecID == ACMCodecDB::kSPEEX16) { } else if (codec_id_ == ACMCodecDB::kSPEEX16) {
_samplingFrequency = 16000; sampling_frequency_ = 16000;
_samplesIn20MsAudio = 320; samples_in_20ms_audio_ = 320;
_encodingRate = 22000; encoding_rate_ = 22000;
} else { } else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Wrong codec id for Speex."); "Wrong codec id for Speex.");
_samplingFrequency = -1; sampling_frequency_ = -1;
_samplesIn20MsAudio = -1; samples_in_20ms_audio_ = -1;
_encodingRate = -1; encoding_rate_ = -1;
} }
_hasInternalDTX = true; has_internal_dtx_ = true;
_dtxEnabled = false; dtx_enabled_ = false;
_vbrEnabled = false; vbr_enabled_ = false;
_complMode = 3; // default complexity value compl_mode_ = 3; // default complexity value
return; return;
} }
ACMSPEEX::~ACMSPEEX() { ACMSPEEX::~ACMSPEEX() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcSpeex_FreeEnc(_encoderInstPtr); WebRtcSpeex_FreeEnc(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcSpeex_FreeDec(_decoderInstPtr); WebRtcSpeex_FreeDec(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
return; return;
} }
WebRtc_Word16 ACMSPEEX::InternalEncode(WebRtc_UWord8* bitStream, WebRtc_Word16 ACMSPEEX::InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte) { WebRtc_Word16* bitstream_len_byte) {
WebRtc_Word16 status; WebRtc_Word16 status;
WebRtc_Word16 numEncodedSamples = 0; WebRtc_Word16 num_encoded_samples = 0;
WebRtc_Word16 n = 0; WebRtc_Word16 n = 0;
while (numEncodedSamples < _frameLenSmpl) { while (num_encoded_samples < frame_len_smpl_) {
status = WebRtcSpeex_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead], status = WebRtcSpeex_Encode(encoder_inst_ptr_,
_encodingRate); &in_audio_[in_audio_ix_read_], encoding_rate_);
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += _samplesIn20MsAudio; in_audio_ix_read_ += samples_in_20ms_audio_;
numEncodedSamples += _samplesIn20MsAudio; num_encoded_samples += samples_in_20ms_audio_;
if (status < 0) { if (status < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Error in Speex encoder"); "Error in Speex encoder");
return status; return status;
} }
// Update VAD, if internal DTX is used // Update VAD, if internal DTX is used
if (_hasInternalDTX && _dtxEnabled) { if (has_internal_dtx_ && dtx_enabled_) {
_vadLabel[n++] = status; vad_label_[n++] = status;
_vadLabel[n++] = status; vad_label_[n++] = status;
} }
if (status == 0) { if (status == 0) {
// This frame is detected as inactive. We need send whatever // This frame is detected as inactive. We need send whatever
// encoded so far. // encoded so far.
*bitStreamLenByte = WebRtcSpeex_GetBitstream(_encoderInstPtr, *bitstream_len_byte = WebRtcSpeex_GetBitstream(encoder_inst_ptr_,
(WebRtc_Word16*) bitStream); (WebRtc_Word16*)bitstream);
return *bitstream_len_byte;
return *bitStreamLenByte;
} }
} }
*bitStreamLenByte = WebRtcSpeex_GetBitstream(_encoderInstPtr, *bitstream_len_byte = WebRtcSpeex_GetBitstream(encoder_inst_ptr_,
(WebRtc_Word16*) bitStream); (WebRtc_Word16*)bitstream);
return *bitStreamLenByte; return *bitstream_len_byte;
} }
WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitStream */, WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitstream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitstream_len_byte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audio_samples */,
WebRtc_Word8* /* speechType */) { WebRtc_Word8* /* speech_type */) {
return 0; return 0;
} }
WebRtc_Word16 ACMSPEEX::EnableDTX() { WebRtc_Word16 ACMSPEEX::EnableDTX() {
if (_dtxEnabled) { if (dtx_enabled_) {
return 0; return 0;
} else if (_encoderExist) { // check if encoder exist } else if (encoder_exist_) { // check if encoder exist
// enable DTX // enable DTX
if (WebRtcSpeex_EncoderInit(_encoderInstPtr, (_vbrEnabled ? 1 : 0), if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, (vbr_enabled_ ? 1 : 0),
_complMode, 1) < 0) { compl_mode_, 1) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Cannot enable DTX for Speex"); "Cannot enable DTX for Speex");
return -1; return -1;
} }
_dtxEnabled = true; dtx_enabled_ = true;
return 0; return 0;
} else { } else {
return -1; return -1;
@ -234,17 +235,17 @@ WebRtc_Word16 ACMSPEEX::EnableDTX() {
} }
WebRtc_Word16 ACMSPEEX::DisableDTX() { WebRtc_Word16 ACMSPEEX::DisableDTX() {
if (!_dtxEnabled) { if (!dtx_enabled_) {
return 0; return 0;
} else if (_encoderExist) { // check if encoder exist } else if (encoder_exist_) { // check if encoder exist
// disable DTX // disable DTX
if (WebRtcSpeex_EncoderInit(_encoderInstPtr, (_vbrEnabled ? 1 : 0), if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, (vbr_enabled_ ? 1 : 0),
_complMode, 0) < 0) { compl_mode_, 0) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Cannot disable DTX for Speex"); "Cannot disable DTX for Speex");
return -1; return -1;
} }
_dtxEnabled = false; dtx_enabled_ = false;
return 0; return 0;
} else { } else {
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless
@ -254,54 +255,55 @@ WebRtc_Word16 ACMSPEEX::DisableDTX() {
return 0; return 0;
} }
WebRtc_Word16 ACMSPEEX::InternalInitEncoder(WebRtcACMCodecParams* codecParams) { WebRtc_Word16 ACMSPEEX::InternalInitEncoder(
WebRtcACMCodecParams* codec_params) {
// sanity check // sanity check
if (_encoderInstPtr == NULL) { if (encoder_inst_ptr_ == NULL) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Cannot initialize Speex encoder, instance does not exist"); "Cannot initialize Speex encoder, instance does not exist");
return -1; return -1;
} }
WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate); WebRtc_Word16 status = SetBitRateSafe((codec_params->codecInstant).rate);
status += status +=
(WebRtcSpeex_EncoderInit(_encoderInstPtr, _vbrEnabled, _complMode, (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, vbr_enabled_, compl_mode_,
((codecParams->enableDTX) ? 1 : 0)) < 0) ? ((codec_params->enable_dtx) ? 1 : 0)) < 0) ?
-1 : 0; -1 : 0;
if (status >= 0) { if (status >= 0) {
return 0; return 0;
} else { } else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Error in initialization of Speex encoder"); "Error in initialization of Speex encoder");
return -1; return -1;
} }
} }
WebRtc_Word16 ACMSPEEX::InternalInitDecoder( WebRtc_Word16 ACMSPEEX::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) { WebRtcACMCodecParams* /* codec_params */) {
WebRtc_Word16 status; WebRtc_Word16 status;
// sanity check // sanity check
if (_decoderInstPtr == NULL) { if (decoder_inst_ptr_ == NULL) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Cannot initialize Speex decoder, instance does not exist"); "Cannot initialize Speex decoder, instance does not exist");
return -1; return -1;
} }
status = ((WebRtcSpeex_DecoderInit(_decoderInstPtr) < 0) ? -1 : 0); status = ((WebRtcSpeex_DecoderInit(decoder_inst_ptr_) < 0) ? -1 : 0);
if (status >= 0) { if (status >= 0) {
return 0; return 0;
} else { } else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Error in initialization of Speex decoder"); "Error in initialization of Speex decoder");
return -1; return -1;
} }
} }
WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst) { const CodecInst& codec_inst) {
if (!_decoderInitialized) { if (!decoder_initialized_) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Error, Speex decoder is not initialized"); "Error, Speex decoder is not initialized");
return -1; return -1;
} }
@ -311,26 +313,26 @@ WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
// Then call NetEQ to add the codec to its // Then call NetEQ to add the codec to its
// database. // database.
switch (_samplingFrequency) { switch (sampling_frequency_) {
case 8000: { case 8000: {
SET_CODEC_PAR((codecDef), kDecoderSPEEX_8, codecInst.pltype, SET_CODEC_PAR((codec_def), kDecoderSPEEX_8, codec_inst.pltype,
_decoderInstPtr, 8000); decoder_inst_ptr_, 8000);
break; break;
} }
case 16000: { case 16000: {
SET_CODEC_PAR((codecDef), kDecoderSPEEX_16, codecInst.pltype, SET_CODEC_PAR((codec_def), kDecoderSPEEX_16, codec_inst.pltype,
_decoderInstPtr, 16000); decoder_inst_ptr_, 16000);
break; break;
} }
default: { default: {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Unsupported sampling frequency for Speex"); "Unsupported sampling frequency for Speex");
return -1; return -1;
} }
} }
SET_SPEEX_FUNCTIONS((codecDef)); SET_SPEEX_FUNCTIONS((codec_def));
return 0; return 0;
} }
@ -339,43 +341,43 @@ ACMGenericCodec* ACMSPEEX::CreateInstance(void) {
} }
WebRtc_Word16 ACMSPEEX::InternalCreateEncoder() { WebRtc_Word16 ACMSPEEX::InternalCreateEncoder() {
return WebRtcSpeex_CreateEnc(&_encoderInstPtr, _samplingFrequency); return WebRtcSpeex_CreateEnc(&encoder_inst_ptr_, sampling_frequency_);
} }
void ACMSPEEX::DestructEncoderSafe() { void ACMSPEEX::DestructEncoderSafe() {
if (_encoderInstPtr != NULL) { if (encoder_inst_ptr_ != NULL) {
WebRtcSpeex_FreeEnc(_encoderInstPtr); WebRtcSpeex_FreeEnc(encoder_inst_ptr_);
_encoderInstPtr = NULL; encoder_inst_ptr_ = NULL;
} }
// there is no encoder set the following // there is no encoder set the following
_encoderExist = false; encoder_exist_ = false;
_encoderInitialized = false; encoder_initialized_ = false;
_encodingRate = 0; encoding_rate_ = 0;
} }
WebRtc_Word16 ACMSPEEX::InternalCreateDecoder() { WebRtc_Word16 ACMSPEEX::InternalCreateDecoder() {
return WebRtcSpeex_CreateDec(&_decoderInstPtr, _samplingFrequency, 1); return WebRtcSpeex_CreateDec(&decoder_inst_ptr_, sampling_frequency_, 1);
} }
void ACMSPEEX::DestructDecoderSafe() { void ACMSPEEX::DestructDecoderSafe() {
if (_decoderInstPtr != NULL) { if (decoder_inst_ptr_ != NULL) {
WebRtcSpeex_FreeDec(_decoderInstPtr); WebRtcSpeex_FreeDec(decoder_inst_ptr_);
_decoderInstPtr = NULL; decoder_inst_ptr_ = NULL;
} }
// there is no encoder instance set the followings // there is no encoder instance set the followings
_decoderExist = false; decoder_exist_ = false;
_decoderInitialized = false; decoder_initialized_ = false;
} }
WebRtc_Word16 ACMSPEEX::SetBitRateSafe(const WebRtc_Word32 rate) { WebRtc_Word16 ACMSPEEX::SetBitRateSafe(const WebRtc_Word32 rate) {
// Check if changed rate // Check if changed rate
if (rate == _encodingRate) { if (rate == encoding_rate_) {
return 0; return 0;
} else if (rate > 2000) { } else if (rate > 2000) {
_encodingRate = rate; encoding_rate_ = rate;
_encoderParams.codecInstant.rate = rate; encoder_params_.codecInstant.rate = rate;
} else { } else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Unsupported encoding rate for Speex"); "Unsupported encoding rate for Speex");
return -1; return -1;
@ -384,31 +386,30 @@ WebRtc_Word16 ACMSPEEX::SetBitRateSafe(const WebRtc_Word32 rate) {
return 0; return 0;
} }
void ACMSPEEX::InternalDestructEncoderInst(void* ptrInst) { void ACMSPEEX::InternalDestructEncoderInst(void* ptr_inst) {
if (ptrInst != NULL) { if (ptr_inst != NULL) {
WebRtcSpeex_FreeEnc((SPEEX_encinst_t_*) ptrInst); WebRtcSpeex_FreeEnc((SPEEX_encinst_t_*) ptr_inst);
} }
return; return;
} }
#ifdef UNUSEDSPEEX #ifdef UNUSEDSPEEX
// This API is currently not in use. If requested to be able to enable/disable VBR // This API is currently not in use. If requested to be able to enable/disable
// an ACM API need to be added. // VBR an ACM API need to be added.
WebRtc_Word16 ACMSPEEX::EnableVBR() { WebRtc_Word16 ACMSPEEX::EnableVBR() {
if (_vbrEnabled) { if (vbr_enabled_) {
return 0; return 0;
} else if (_encoderExist) // check if encoder exist } else if (encoder_exist_) { // check if encoder exist
{
// enable Variable Bit Rate (VBR) // enable Variable Bit Rate (VBR)
if (WebRtcSpeex_EncoderInit(_encoderInstPtr, 1, _complMode, if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, 1, compl_mode_,
(_dtxEnabled ? 1 : 0)) < 0) { (dtx_enabled_ ? 1 : 0)) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Cannot enable VBR mode for Speex"); "Cannot enable VBR mode for Speex");
return -1; return -1;
} }
_vbrEnabled = true; vbr_enabled_ = true;
return 0; return 0;
} else { } else {
return -1; return -1;
@ -418,18 +419,18 @@ WebRtc_Word16 ACMSPEEX::EnableVBR() {
// This API is currently not in use. If requested to be able to enable/disable // This API is currently not in use. If requested to be able to enable/disable
// VBR an ACM API need to be added. // VBR an ACM API need to be added.
WebRtc_Word16 ACMSPEEX::DisableVBR() { WebRtc_Word16 ACMSPEEX::DisableVBR() {
if (!_vbrEnabled) { if (!vbr_enabled_) {
return 0; return 0;
} else if (_encoderExist) { // check if encoder exist } else if (encoder_exist_) { // check if encoder exist
// disable DTX // disable DTX
if (WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, _complMode, if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, 0, compl_mode_,
(_dtxEnabled ? 1 : 0)) < 0) { (dtx_enabled_ ? 1 : 0)) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Cannot disable DTX for Speex"); "Cannot disable DTX for Speex");
return -1; return -1;
} }
_vbrEnabled = false; vbr_enabled_ = false;
return 0; return 0;
} else { } else {
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless
@ -441,17 +442,17 @@ WebRtc_Word16 ACMSPEEX::DisableVBR() {
// an ACM API need to be added. // an ACM API need to be added.
WebRtc_Word16 ACMSPEEX::SetComplMode(WebRtc_Word16 mode) { WebRtc_Word16 ACMSPEEX::SetComplMode(WebRtc_Word16 mode) {
// Check if new mode // Check if new mode
if (mode == _complMode) { if (mode == compl_mode_) {
return 0; return 0;
} else if (_encoderExist) { // check if encoder exist } else if (encoder_exist_) { // check if encoder exist
// Set new mode // Set new mode
if (WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, mode, (_dtxEnabled ? 1 : 0)) if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, 0, mode,
< 0) { (dtx_enabled_ ? 1 : 0)) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Error in complexity mode for Speex"); "Error in complexity mode for Speex");
return -1; return -1;
} }
_complMode = mode; compl_mode_ = mode;
return 0; return 0;
} else { } else {
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_
#include "acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
// forward declaration // forward declaration
struct SPEEX_encinst_t_; struct SPEEX_encinst_t_;
@ -21,27 +21,28 @@ namespace webrtc {
class ACMSPEEX : public ACMGenericCodec { class ACMSPEEX : public ACMGenericCodec {
public: public:
ACMSPEEX(WebRtc_Word16 codecID); explicit ACMSPEEX(WebRtc_Word16 codec_id);
~ACMSPEEX(); ~ACMSPEEX();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream, WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitstream_len_byte);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams); WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
protected: protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream, WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitstream_len_byte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audio_samples,
WebRtc_Word8* speechType); WebRtc_Word8* speech_type);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef, WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
const CodecInst& codecInst); const CodecInst& codec_inst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -51,7 +52,7 @@ class ACMSPEEX : public ACMGenericCodec {
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(void* ptrInst); void InternalDestructEncoderInst(void* ptr_inst);
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate); WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
@ -67,13 +68,13 @@ class ACMSPEEX : public ACMGenericCodec {
WebRtc_Word16 SetComplMode(WebRtc_Word16 mode); WebRtc_Word16 SetComplMode(WebRtc_Word16 mode);
#endif #endif
SPEEX_encinst_t_* _encoderInstPtr; SPEEX_encinst_t_* encoder_inst_ptr_;
SPEEX_decinst_t_* _decoderInstPtr; SPEEX_decinst_t_* decoder_inst_ptr_;
WebRtc_Word16 _complMode; WebRtc_Word16 compl_mode_;
bool _vbrEnabled; bool vbr_enabled_;
WebRtc_Word32 _encodingRate; WebRtc_Word32 encoding_rate_;
WebRtc_Word16 _samplingFrequency; WebRtc_Word16 sampling_frequency_;
WebRtc_UWord16 _samplesIn20MsAudio; WebRtc_UWord16 samples_in_20ms_audio_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -8,10 +8,13 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_dtmf_detection.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
#include "audio_coding_module.h"
#include "audio_coding_module_impl.h" #include "webrtc/common_types.h"
#include "trace.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/source/acm_dtmf_detection.h"
#include "webrtc/modules/audio_coding/main/source/audio_coding_module_impl.h"
#include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc { namespace webrtc {
@ -31,10 +34,10 @@ WebRtc_UWord8 AudioCodingModule::NumberOfCodecs() {
} }
// Get supported codec param with id // Get supported codec param with id
WebRtc_Word32 AudioCodingModule::Codec(const WebRtc_UWord8 listId, WebRtc_Word32 AudioCodingModule::Codec(const WebRtc_UWord8 list_id,
CodecInst& codec) { CodecInst& codec) {
// Get the codec settings for the codec with the given list ID // Get the codec settings for the codec with the given list ID
return ACMCodecDB::Codec(listId, &codec); return ACMCodecDB::Codec(list_id, &codec);
} }
// Get supported codec Param with name, frequency and number of channels. // Get supported codec Param with name, frequency and number of channels.
@ -74,13 +77,13 @@ WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
// Checks the validity of the parameters of the given codec // Checks the validity of the parameters of the given codec
bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
int mirrorID; int mirror_id;
char errMsg[500]; char err_msg[500];
int codecNumber = ACMCodecDB::CodecNumber(&codec, &mirrorID, errMsg, 500); int codec_number = ACMCodecDB::CodecNumber(&codec, &mirror_id, err_msg, 500);
if (codecNumber < 0) { if (codec_number < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, errMsg); WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, err_msg);
return false; return false;
} else { } else {
return true; return true;

View File

@ -11,11 +11,11 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_
#include "acm_codec_database.h" #include "webrtc/common_types.h"
#include "acm_neteq.h" #include "webrtc/engine_configurations.h"
#include "acm_resampler.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "common_types.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "engine_configurations.h" #include "webrtc/modules/audio_coding/main/source/acm_resampler.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h" #include "webrtc/system_wrappers/interface/scoped_ptr.h"
namespace webrtc { namespace webrtc {
@ -25,14 +25,10 @@ class ACMGenericCodec;
class CriticalSectionWrapper; class CriticalSectionWrapper;
class RWLockWrapper; class RWLockWrapper;
#ifdef ACM_QA_TEST
# include <stdio.h>
#endif
class AudioCodingModuleImpl : public AudioCodingModule { class AudioCodingModuleImpl : public AudioCodingModule {
public: public:
// Constructor // Constructor
AudioCodingModuleImpl(const WebRtc_Word32 id); explicit AudioCodingModuleImpl(const WebRtc_Word32 id);
// Destructor // Destructor
~AudioCodingModuleImpl(); ~AudioCodingModuleImpl();
@ -77,9 +73,9 @@ class AudioCodingModuleImpl : public AudioCodingModule {
// Get current send frequency. // Get current send frequency.
WebRtc_Word32 SendFrequency() const; WebRtc_Word32 SendFrequency() const;
// Get encode bitrate. // Get encode bit-rate.
// Adaptive rate codecs return their current encode target rate, while other // Adaptive rate codecs return their current encode target rate, while other
// codecs return there longterm avarage or their fixed rate. // codecs return there long-term average or their fixed rate.
WebRtc_Word32 SendBitrate() const; WebRtc_Word32 SendBitrate() const;
// Set available bandwidth, inform the encoder about the // Set available bandwidth, inform the encoder about the
@ -96,7 +92,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
WebRtc_Word32 RegisterIncomingMessagesCallback( WebRtc_Word32 RegisterIncomingMessagesCallback(
AudioCodingFeedback* incoming_message, const ACMCountries cpt); AudioCodingFeedback* incoming_message, const ACMCountries cpt);
// Add 10MS of raw (PCM) audio data to the encoder. // Add 10 ms of raw (PCM) audio data to the encoder.
WebRtc_Word32 Add10MsData(const AudioFrame& audio_frame); WebRtc_Word32 Add10MsData(const AudioFrame& audio_frame);
// Set background noise mode for NetEQ, on, off or fade. // Set background noise mode for NetEQ, on, off or fade.
@ -128,7 +124,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
WebRtc_Word32 VAD(bool& dtx_enabled, bool& vad_enabled, WebRtc_Word32 VAD(bool& dtx_enabled, bool& vad_enabled,
ACMVADMode& mode) const; ACMVADMode& mode) const;
WebRtc_Word32 RegisterVADCallback(ACMVADCallback* vadCallback); WebRtc_Word32 RegisterVADCallback(ACMVADCallback* vad_callback);
// Get VAD aggressiveness on the incoming stream. // Get VAD aggressiveness on the incoming stream.
ACMVADMode ReceiveVADMode() const; ACMVADMode ReceiveVADMode() const;
@ -152,7 +148,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
// Get current playout frequency. // Get current playout frequency.
WebRtc_Word32 PlayoutFrequency() const; WebRtc_Word32 PlayoutFrequency() const;
// Register possible reveive codecs, can be called multiple times, // Register possible receive codecs, can be called multiple times,
// for codecs, CNG, DTMF, RED. // for codecs, CNG, DTMF, RED.
WebRtc_Word32 RegisterReceiveCodec(const CodecInst& receive_codec); WebRtc_Word32 RegisterReceiveCodec(const CodecInst& receive_codec);
@ -171,7 +167,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
const WebRtc_UWord8 payload_type, const WebRtc_UWord8 payload_type,
const WebRtc_UWord32 timestamp = 0); const WebRtc_UWord32 timestamp = 0);
// Minimum playout dealy (used for lip-sync). // Minimum playout delay (used for lip-sync).
WebRtc_Word32 SetMinimumPlayoutDelay(const WebRtc_Word32 time_ms); WebRtc_Word32 SetMinimumPlayoutDelay(const WebRtc_Word32 time_ms);
// Configure Dtmf playout status i.e on/off playout the incoming outband Dtmf // Configure Dtmf playout status i.e on/off playout the incoming outband Dtmf
@ -258,7 +254,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
WebRtc_Word32 RegisterRecCodecMSSafe(const CodecInst& receive_codec, WebRtc_Word32 RegisterRecCodecMSSafe(const CodecInst& receive_codec,
WebRtc_Word16 codec_id, WebRtc_Word16 codec_id,
WebRtc_Word16 mirror_id, WebRtc_Word16 mirror_id,
ACMNetEQ::JB jitter_buffer); ACMNetEQ::JitterBuffer jitter_buffer);
// Set VAD/DTX status. This function does not acquire a lock, and it is // Set VAD/DTX status. This function does not acquire a lock, and it is
// created to be called only from inside a critical section. // created to be called only from inside a critical section.
@ -273,19 +269,16 @@ class AudioCodingModuleImpl : public AudioCodingModule {
int ProcessDualStream(); int ProcessDualStream();
// Preprocessing of input audio, including resampling and down-mixing if // Preprocessing of input audio, including resampling and down-mixing if
// required, before pushing audio into encoder'r buffer. // required, before pushing audio into encoder's buffer.
// //
// in_frame: input audio-frame // in_frame: input audio-frame
// out_frame: output audio_frame, the output is valid only if a preprocessing // ptr_out: pointer to output audio_frame. If no preprocessing is required
// is required. // |ptr_out| will be pointing to |in_frame|, otherwise pointing to
// |preprocess_frame_|.
// //
// Return value: // Return value:
// -1: if encountering an error. // -1: if encountering an error.
// kPreprocessingSuccessful: if a preprocessing successfully performed. // 0: otherwise.
// kNoPreprocessingRequired: if there was no need for preprocessing. In
// this case |out_frame| is not updated and
// |in_frame| has to be used for further
// operations.
int PreprocessToAddData(const AudioFrame& in_frame, int PreprocessToAddData(const AudioFrame& in_frame,
const AudioFrame** ptr_out); const AudioFrame** ptr_out);
@ -304,89 +297,84 @@ class AudioCodingModuleImpl : public AudioCodingModule {
int EncodeFragmentation(int fragmentation_index, int payload_type, int EncodeFragmentation(int fragmentation_index, int payload_type,
uint32_t current_timestamp, uint32_t current_timestamp,
ACMGenericCodec* _secondary_encoder, ACMGenericCodec* encoder,
uint8_t* stream); uint8_t* stream);
void ResetFragmentation(int vector_size); void ResetFragmentation(int vector_size);
AudioPacketizationCallback* _packetizationCallback; AudioPacketizationCallback* packetization_callback_;
WebRtc_Word32 _id; WebRtc_Word32 id_;
WebRtc_UWord32 _lastTimestamp; WebRtc_UWord32 last_timestamp_;
WebRtc_UWord32 _lastInTimestamp; WebRtc_UWord32 last_in_timestamp_;
CodecInst _sendCodecInst; CodecInst send_codec_inst_;
uint8_t _cng_nb_pltype; uint8_t cng_nb_pltype_;
uint8_t _cng_wb_pltype; uint8_t cng_wb_pltype_;
uint8_t _cng_swb_pltype; uint8_t cng_swb_pltype_;
uint8_t _cng_fb_pltype; uint8_t cng_fb_pltype_;
uint8_t _red_pltype; uint8_t red_pltype_;
bool _vadEnabled; bool vad_enabled_;
bool _dtxEnabled; bool dtx_enabled_;
ACMVADMode _vadMode; ACMVADMode vad_mode_;
ACMGenericCodec* _codecs[ACMCodecDB::kMaxNumCodecs]; ACMGenericCodec* codecs_[ACMCodecDB::kMaxNumCodecs];
ACMGenericCodec* _slaveCodecs[ACMCodecDB::kMaxNumCodecs]; ACMGenericCodec* slave_codecs_[ACMCodecDB::kMaxNumCodecs];
WebRtc_Word16 _mirrorCodecIdx[ACMCodecDB::kMaxNumCodecs]; WebRtc_Word16 mirror_codec_idx_[ACMCodecDB::kMaxNumCodecs];
bool _stereoReceive[ACMCodecDB::kMaxNumCodecs]; bool stereo_receive_[ACMCodecDB::kMaxNumCodecs];
bool _stereoReceiveRegistered; bool stereo_receive_registered_;
bool _stereoSend; bool stereo_send_;
int _prev_received_channel; int prev_received_channel_;
int _expected_channels; int expected_channels_;
WebRtc_Word32 _currentSendCodecIdx; WebRtc_Word32 current_send_codec_idx_;
int _current_receive_codec_idx; int current_receive_codec_idx_;
bool _sendCodecRegistered; bool send_codec_registered_;
ACMResampler _inputResampler; ACMResampler input_resampler_;
ACMResampler _outputResampler; ACMResampler output_resampler_;
ACMNetEQ _netEq; ACMNetEQ neteq_;
CriticalSectionWrapper* _acmCritSect; CriticalSectionWrapper* acm_crit_sect_;
ACMVADCallback* _vadCallback; ACMVADCallback* vad_callback_;
WebRtc_UWord8 _lastRecvAudioCodecPlType; WebRtc_UWord8 last_recv_audio_codec_pltype_;
// RED/FEC. // RED/FEC.
bool _isFirstRED; bool is_first_red_;
bool _fecEnabled; bool fec_enabled_;
// TODO(turajs): |_redBuffer| is allocated in constructor, why having them // TODO(turajs): |red_buffer_| is allocated in constructor, why having them
// as pointers and not an array. If concerned about the memory, then make a // as pointers and not an array. If concerned about the memory, then make a
// set-up function to allocate them only when they are going to be used, i.e. // set-up function to allocate them only when they are going to be used, i.e.
// FEC or Dual-streaming is enabled. // FEC or Dual-streaming is enabled.
WebRtc_UWord8* _redBuffer; WebRtc_UWord8* red_buffer_;
// TODO(turajs): we actually don't need |_fragmentation| as a member variable. // TODO(turajs): we actually don't need |fragmentation_| as a member variable.
// It is sufficient to keep the length & payload type of previous payload in // It is sufficient to keep the length & payload type of previous payload in
// member variables. // member variables.
RTPFragmentationHeader _fragmentation; RTPFragmentationHeader fragmentation_;
WebRtc_UWord32 _lastFECTimestamp; WebRtc_UWord32 last_fec_timestamp_;
// If no RED is registered as receive codec this // If no RED is registered as receive codec this
// will have an invalid value. // will have an invalid value.
WebRtc_UWord8 _receiveREDPayloadType; WebRtc_UWord8 receive_red_pltype_;
// This is to keep track of CN instances where we can send DTMFs. // This is to keep track of CN instances where we can send DTMFs.
WebRtc_UWord8 _previousPayloadType; WebRtc_UWord8 previous_pltype_;
// This keeps track of payload types associated with _codecs[]. // This keeps track of payload types associated with codecs_[].
// We define it as signed variable and initialize with -1 to indicate // We define it as signed variable and initialize with -1 to indicate
// unused elements. // unused elements.
WebRtc_Word16 _registeredPlTypes[ACMCodecDB::kMaxNumCodecs]; WebRtc_Word16 registered_pltypes_[ACMCodecDB::kMaxNumCodecs];
// Used when payloads are pushed into ACM without any RTP info // Used when payloads are pushed into ACM without any RTP info
// One example is when pre-encoded bit-stream is pushed from // One example is when pre-encoded bit-stream is pushed from
// a file. // a file.
WebRtcRTPHeader* _dummyRTPHeader; WebRtcRTPHeader* dummy_rtp_header_;
WebRtc_UWord16 _recvPlFrameSizeSmpls; WebRtc_UWord16 recv_pl_frame_size_smpls_;
bool _receiverInitialized; bool receiver_initialized_;
ACMDTMFDetection* _dtmfDetector; ACMDTMFDetection* dtmf_detector_;
AudioCodingFeedback* _dtmfCallback; AudioCodingFeedback* dtmf_callback_;
WebRtc_Word16 _lastDetectedTone; WebRtc_Word16 last_detected_tone_;
CriticalSectionWrapper* _callbackCritSect; CriticalSectionWrapper* callback_crit_sect_;
AudioFrame _audioFrame;
AudioFrame _preprocess_frame;
CodecInst _secondarySendCodecInst;
scoped_ptr<ACMGenericCodec> _secondaryEncoder;
#ifdef ACM_QA_TEST
FILE* _outgoingPL;
FILE* _incomingPL;
#endif
AudioFrame audio_frame_;
AudioFrame preprocess_frame_;
CodecInst secondary_send_codec_inst_;
scoped_ptr<ACMGenericCodec> secondary_encoder_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -16,6 +16,7 @@
#include "audio_coding_module.h" #include "audio_coding_module.h"
#include "critical_section_wrapper.h" #include "critical_section_wrapper.h"
#include "rw_lock_wrapper.h" #include "rw_lock_wrapper.h"
#include "webrtc/modules/interface/module_common_types.h"
namespace webrtc { namespace webrtc {