This CL is divided in several patches, to make review easier.

Patch Set 1: Removing blanks at end of lines.
Patch Set 2: Removing tabs.
Patch Set 3: Fixing include-guards.
Patch Set 4-7: Formatting files in the list.
Patch Set 8: Formatting CNG.

Patch Set 9: 
* Fixing comments from code review
* Fixing formating in acm_dtmf_playout.cc
* Started fixing formating of acm_g7221.cc. More work needed, so don't spend too much time reviewing.
* Refactored constructor of ACMGenericCodec. Rest of file still to be fixed.
* Fixing break; after return ...; in several files.

Patch Set 10:
* Chaning from reintepret_cast to static_cast in three files, acm_amr.cc, acm_cng.cc and acm_g722.cc
NOTE! Not all files have the right format. That work will continue in separate CLs.

Review URL: http://webrtc-codereview.appspot.com/175002

git-svn-id: http://webrtc.googlecode.com/svn/trunk@881 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tina.legrand@webrtc.org
2011-11-03 17:20:10 +00:00
parent a4b9660372
commit fb389e3b02
49 changed files with 4572 additions and 5660 deletions

View File

@@ -8,63 +8,51 @@
* 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 AUDIO_CODING_MODULE_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_H
#define AUDIO_CODING_MODULE_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_H
#include "module.h"
#include "audio_coding_module_typedefs.h" #include "audio_coding_module_typedefs.h"
#include "module.h"
#include "module_common_types.h" #include "module_common_types.h"
namespace webrtc {
namespace webrtc
{
// forward declarations // forward declarations
struct CodecInst; struct CodecInst;
#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 {
{ public:
public:
virtual ~AudioPacketizationCallback() {} virtual ~AudioPacketizationCallback() {}
virtual WebRtc_Word32 SendData( virtual WebRtc_Word32 SendData(
FrameType frameType, FrameType frameType, WebRtc_UWord8 payloadType, WebRtc_UWord32 timeStamp,
WebRtc_UWord8 payloadType, const WebRtc_UWord8* payloadData, WebRtc_UWord16 payloadSize,
WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
WebRtc_UWord16 payloadSize,
const RTPFragmentationHeader* fragmentation) = 0; const RTPFragmentationHeader* fragmentation) = 0;
}; };
// Callback class used for inband Dtmf detection // Callback class used for inband Dtmf detection
class AudioCodingFeedback class AudioCodingFeedback {
{ public:
public:
virtual ~AudioCodingFeedback() {} virtual ~AudioCodingFeedback() {}
virtual WebRtc_Word32 IncomingDtmf( virtual WebRtc_Word32 IncomingDtmf(const WebRtc_UWord8 digitDtmf,
const WebRtc_UWord8 digitDtmf,
const bool end) = 0; const bool end) = 0;
}; };
// Callback class used for reporting VAD decision // Callback class used for reporting VAD decision
class ACMVADCallback class ACMVADCallback {
{ public:
public:
virtual ~ACMVADCallback() {} virtual ~ACMVADCallback() {}
virtual WebRtc_Word32 InFrameType(
WebRtc_Word16 frameType) = 0; virtual WebRtc_Word32 InFrameType(WebRtc_Word16 frameType) = 0;
}; };
// Callback class used for reporting receiver statistics // Callback class used for reporting receiver statistics
class ACMVQMonCallback class ACMVQMonCallback {
{ public:
public:
virtual ~ACMVQMonCallback() {} virtual ~ACMVQMonCallback() {}
virtual WebRtc_Word32 NetEqStatistics( virtual WebRtc_Word32 NetEqStatistics(
@@ -75,21 +63,18 @@ public:
const WebRtc_UWord16 delayMS) = 0; // average delay in ms const WebRtc_UWord16 delayMS) = 0; // average delay in ms
}; };
class AudioCodingModule: public Module class AudioCodingModule: public Module {
{ protected:
protected: AudioCodingModule() {}
AudioCodingModule(){} virtual ~AudioCodingModule() {}
virtual ~AudioCodingModule(){}
public: public:
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Creation and destruction of a ACM // Creation and destruction of a ACM
// //
static AudioCodingModule* Create( static AudioCodingModule* Create(const WebRtc_Word32 id);
const WebRtc_Word32 id);
static void Destroy( static void Destroy(AudioCodingModule* module);
AudioCodingModule* module);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Utility functions // Utility functions
@@ -110,12 +95,10 @@ public:
// -1 if failed to write the whole version string, // -1 if failed to write the whole version string,
// 0 if succeeded. // 0 if succeeded.
// //
static WebRtc_Word32 GetVersion( static WebRtc_Word32 GetVersion(WebRtc_Word8* version,
WebRtc_Word8* version,
WebRtc_UWord32& remainBuffBytes, WebRtc_UWord32& remainBuffBytes,
WebRtc_UWord32& position); WebRtc_UWord32& position);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_UWord8 NumberOfCodecs() // WebRtc_UWord8 NumberOfCodecs()
// Returns number of supported codecs. // Returns number of supported codecs.
@@ -125,7 +108,6 @@ public:
/// ///
static WebRtc_UWord8 NumberOfCodecs(); static WebRtc_UWord8 NumberOfCodecs();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 Codec() // WebRtc_Word32 Codec()
// Get supported codec with list number. // Get supported codec with list number.
@@ -141,10 +123,7 @@ public:
// -1 if the list number (listId) is invalid. // -1 if the list number (listId) is invalid.
// 0 if succeeded. // 0 if succeeded.
// //
static WebRtc_Word32 Codec( static WebRtc_Word32 Codec(const WebRtc_UWord8 listId, CodecInst& codec);
const WebRtc_UWord8 listId,
CodecInst& codec);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 Codec() // WebRtc_Word32 Codec()
@@ -164,12 +143,9 @@ public:
// -1 if the list number (listId) is invalid. // -1 if the list number (listId) is invalid.
// 0 if succeeded. // 0 if succeeded.
// //
static WebRtc_Word32 Codec( static WebRtc_Word32 Codec(const WebRtc_Word8* payloadName, CodecInst& codec,
const WebRtc_Word8* payloadName,
CodecInst& codec,
const WebRtc_Word32 samplingFreqHz = -1); const WebRtc_Word32 samplingFreqHz = -1);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 Codec() // WebRtc_Word32 Codec()
// //
@@ -185,11 +161,9 @@ public:
// if the codec is found, the index of the codec in the list, // if the codec is found, the index of the codec in the list,
// -1 if the codec is not found. // -1 if the codec is not found.
// //
static WebRtc_Word32 Codec( static WebRtc_Word32 Codec(const WebRtc_Word8* payloadName,
const WebRtc_Word8* payloadName,
const WebRtc_Word32 samplingFreqHz = -1); const WebRtc_Word32 samplingFreqHz = -1);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// bool IsCodecValid() // bool IsCodecValid()
// Checks the validity of the parameters of the given codec. // Checks the validity of the parameters of the given codec.
@@ -222,7 +196,6 @@ public:
// //
virtual WebRtc_Word32 InitializeSender() = 0; virtual WebRtc_Word32 InitializeSender() = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 ResetEncoder() // WebRtc_Word32 ResetEncoder()
// This API resets the states of encoder. All the encoder settings, such as // This API resets the states of encoder. All the encoder settings, such as
@@ -234,7 +207,6 @@ public:
// //
virtual WebRtc_Word32 ResetEncoder() = 0; virtual WebRtc_Word32 ResetEncoder() = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 RegisterSendCodec() // WebRtc_Word32 RegisterSendCodec()
// Registers a codec, specified by "sendCodec," as sending codec. // Registers a codec, specified by "sendCodec," as sending codec.
@@ -255,9 +227,7 @@ public:
// -1 if failed to initialize, // -1 if failed to initialize,
// 0 if succeeded. // 0 if succeeded.
// //
virtual WebRtc_Word32 RegisterSendCodec( virtual WebRtc_Word32 RegisterSendCodec(const CodecInst& sendCodec) = 0;
const CodecInst& sendCodec) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 SendCodec() // WebRtc_Word32 SendCodec()
@@ -270,9 +240,7 @@ public:
// -1 if failed to get send codec, // -1 if failed to get send codec,
// 0 if succeeded. // 0 if succeeded.
// //
virtual WebRtc_Word32 SendCodec( virtual WebRtc_Word32 SendCodec(CodecInst& currentSendCodec) const = 0;
CodecInst& currentSendCodec) const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 SendFrequency() // WebRtc_Word32 SendFrequency()
@@ -284,7 +252,6 @@ public:
// //
virtual WebRtc_Word32 SendFrequency() const = 0; virtual WebRtc_Word32 SendFrequency() const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 Bitrate() // WebRtc_Word32 Bitrate()
// Get encoding bit-rate in bits per second. // Get encoding bit-rate in bits per second.
@@ -295,7 +262,6 @@ public:
// //
virtual WebRtc_Word32 SendBitrate() const = 0; virtual WebRtc_Word32 SendBitrate() const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 SetReceivedEstimatedBandwidth() // WebRtc_Word32 SetReceivedEstimatedBandwidth()
// Set available bandwidth [bits/sec] of the up-link channel. // Set available bandwidth [bits/sec] of the up-link channel.
@@ -312,7 +278,6 @@ public:
virtual WebRtc_Word32 SetReceivedEstimatedBandwidth( virtual WebRtc_Word32 SetReceivedEstimatedBandwidth(
const WebRtc_Word32 bw) = 0; const WebRtc_Word32 bw) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 RegisterTransportCallback() // WebRtc_Word32 RegisterTransportCallback()
// Register a transport callback which will be called to deliver // Register a transport callback which will be called to deliver
@@ -332,7 +297,6 @@ public:
virtual WebRtc_Word32 RegisterTransportCallback( virtual WebRtc_Word32 RegisterTransportCallback(
AudioPacketizationCallback* transport) = 0; AudioPacketizationCallback* transport) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 Add10MsData() // WebRtc_Word32 Add10MsData()
// Add 10MS of raw (PCM) audio data to the encoder. If the sampling // Add 10MS of raw (PCM) audio data to the encoder. If the sampling
@@ -351,9 +315,7 @@ public:
// < -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( virtual WebRtc_Word32 Add10MsData(const AudioFrame& audioFrame) = 0;
const AudioFrame& audioFrame) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// (FEC) Forward Error Correction // (FEC) Forward Error Correction
@@ -381,8 +343,7 @@ public:
// -1 if failed to set FEC status, // -1 if failed to set FEC status,
// 0 if succeeded. // 0 if succeeded.
// //
virtual WebRtc_Word32 SetFECStatus( virtual WebRtc_Word32 SetFECStatus(const bool enableFEC) = 0;
const bool enableFEC) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// bool FECStatus() // bool FECStatus()
@@ -394,7 +355,6 @@ public:
// //
virtual bool FECStatus() const = 0; virtual bool FECStatus() const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// (VAD) Voice Activity Detection // (VAD) Voice Activity Detection
// //
@@ -423,12 +383,10 @@ public:
// -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( virtual WebRtc_Word32 SetVAD(const bool enableDTX = true,
const bool enableDTX = true,
const bool enableVAD = false, const bool enableVAD = false,
const ACMVADMode vadMode = VADNormal) = 0; const ACMVADMode vadMode = VADNormal) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 VAD() // WebRtc_Word32 VAD()
// Get VAD status. // Get VAD status.
@@ -444,12 +402,9 @@ public:
// -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 succeeeded.
// //
virtual WebRtc_Word32 VAD( virtual WebRtc_Word32 VAD(bool& dtxEnabled, bool& vadEnabled,
bool& dtxEnabled,
bool& vadEnabled,
ACMVADMode& vadMode) const = 0; ACMVADMode& vadMode) const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 ReplaceInternalDTXWithWebRtc() // WebRtc_Word32 ReplaceInternalDTXWithWebRtc()
// Used to replace codec internal DTX scheme with WebRtc. This is only // Used to replace codec internal DTX scheme with WebRtc. This is only
@@ -467,7 +422,6 @@ public:
virtual WebRtc_Word32 ReplaceInternalDTXWithWebRtc( virtual WebRtc_Word32 ReplaceInternalDTXWithWebRtc(
const bool useWebRtcDTX = false) = 0; const bool useWebRtcDTX = false) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 IsInternalDTXReplacedWithWebRtc() // WebRtc_Word32 IsInternalDTXReplacedWithWebRtc()
// Get status if the codec internal DTX (when such exists) is replaced with // Get status if the codec internal DTX (when such exists) is replaced with
@@ -485,7 +439,6 @@ public:
virtual WebRtc_Word32 IsInternalDTXReplacedWithWebRtc( virtual WebRtc_Word32 IsInternalDTXReplacedWithWebRtc(
bool& usesWebRtcDTX) = 0; bool& usesWebRtcDTX) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 RegisterVADCallback() // WebRtc_Word32 RegisterVADCallback()
// Call this method to register a callback function which is called // Call this method to register a callback function which is called
@@ -500,9 +453,7 @@ public:
// -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( virtual WebRtc_Word32 RegisterVADCallback(ACMVADCallback* vadCallback) = 0;
ACMVADCallback* vadCallback) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Receiver // Receiver
@@ -523,7 +474,6 @@ public:
// //
virtual WebRtc_Word32 InitializeReceiver() = 0; virtual WebRtc_Word32 InitializeReceiver() = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 ResetDecoder() // WebRtc_Word32 ResetDecoder()
// This API resets the states of decoders. ACM will not lose any // This API resets the states of decoders. ACM will not lose any
@@ -535,7 +485,6 @@ public:
// //
virtual WebRtc_Word32 ResetDecoder() = 0; virtual WebRtc_Word32 ResetDecoder() = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 ReceiveFrequency() // WebRtc_Word32 ReceiveFrequency()
// Get sampling frequency of the last received payload. // Get sampling frequency of the last received payload.
@@ -546,7 +495,6 @@ public:
// //
virtual WebRtc_Word32 ReceiveFrequency() const = 0; virtual WebRtc_Word32 ReceiveFrequency() const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 PlayoutFrequency() // WebRtc_Word32 PlayoutFrequency()
// Get sampling frequency of audio played out. // Get sampling frequency of audio played out.
@@ -556,7 +504,6 @@ public:
// //
virtual WebRtc_Word32 PlayoutFrequency() const = 0; virtual WebRtc_Word32 PlayoutFrequency() const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 RegisterReceiveCodec() // WebRtc_Word32 RegisterReceiveCodec()
// Register possible decoders, can be called multiple times for // Register possible decoders, can be called multiple times for
@@ -571,9 +518,7 @@ public:
// -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( virtual WebRtc_Word32 RegisterReceiveCodec(const CodecInst& receiveCodec) = 0;
const CodecInst& receiveCodec) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 UnregisterReceiveCodec() // WebRtc_Word32 UnregisterReceiveCodec()
@@ -591,7 +536,6 @@ public:
virtual WebRtc_Word32 UnregisterReceiveCodec( virtual WebRtc_Word32 UnregisterReceiveCodec(
const WebRtc_Word16 receiveCodec) = 0; const WebRtc_Word16 receiveCodec) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 ReceiveCodec() // WebRtc_Word32 ReceiveCodec()
// Get the codec associated with last received payload. // Get the codec associated with last received payload.
@@ -605,9 +549,7 @@ public:
// -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( virtual WebRtc_Word32 ReceiveCodec(CodecInst& currRcvCodec) const = 0;
CodecInst& currRcvCodec) const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 IncomingPacket() // WebRtc_Word32 IncomingPacket()
@@ -623,12 +565,10 @@ public:
// -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( virtual WebRtc_Word32 IncomingPacket(const WebRtc_Word8* incomingPayload,
const WebRtc_Word8* incomingPayload,
const WebRtc_Word32 payloadLengthByte, const WebRtc_Word32 payloadLengthByte,
const WebRtcRTPHeader& rtpInfo) = 0; const WebRtcRTPHeader& rtpInfo) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 IncomingPayload() // WebRtc_Word32 IncomingPayload()
// Call this API to push incoming payloads when there is no rtp-info. // Call this API to push incoming payloads when there is no rtp-info.
@@ -653,13 +593,11 @@ public:
// -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( virtual WebRtc_Word32 IncomingPayload(const WebRtc_Word8* incomingPayload,
const WebRtc_Word8* incomingPayload,
const WebRtc_Word32 payloadLengthByte, const WebRtc_Word32 payloadLengthByte,
const WebRtc_UWord8 payloadType, const WebRtc_UWord8 payloadType,
const WebRtc_UWord32 timestamp = 0) = 0; const WebRtc_UWord32 timestamp = 0) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 SetMinimumPlayoutDelay() // WebRtc_Word32 SetMinimumPlayoutDelay()
// Set Minimum playout delay, used for lip-sync. // Set Minimum playout delay, used for lip-sync.
@@ -671,9 +609,7 @@ public:
// -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( virtual WebRtc_Word32 SetMinimumPlayoutDelay(const WebRtc_Word32 timeMs) = 0;
const WebRtc_Word32 timeMs) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 Delay() // WebRtc_Word32 Delay()
@@ -688,7 +624,6 @@ public:
// //
virtual WebRtc_Word32 Delay(WebRtc_UWord16& delayMs) const = 0; virtual WebRtc_Word32 Delay(WebRtc_UWord16& delayMs) const = 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
@@ -707,11 +642,11 @@ public:
// -1 if the message callback could not be registered // -1 if the message callback could not be registered
// 0 if registration is successful. // 0 if registration is successful.
// //
virtual WebRtc_Word32 RegisterIncomingMessagesCallback( virtual WebRtc_Word32
RegisterIncomingMessagesCallback(
AudioCodingFeedback* inMsgCallback, AudioCodingFeedback* inMsgCallback,
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
@@ -727,7 +662,6 @@ public:
// //
virtual WebRtc_Word32 SetDtmfPlayoutStatus(const bool enable) = 0; virtual WebRtc_Word32 SetDtmfPlayoutStatus(const bool enable) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// bool DtmfPlayoutStatus() // bool DtmfPlayoutStatus()
// Get Dtmf playout status. // Get Dtmf playout status.
@@ -738,7 +672,6 @@ public:
// //
virtual bool DtmfPlayoutStatus() const = 0; virtual bool DtmfPlayoutStatus() const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// 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
@@ -755,7 +688,6 @@ public:
virtual WebRtc_Word32 SetBackgroundNoiseMode( virtual WebRtc_Word32 SetBackgroundNoiseMode(
const ACMBackgroundNoiseMode mode) = 0; const ACMBackgroundNoiseMode mode) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// 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.
@@ -770,9 +702,7 @@ public:
// 0 if the output is a valid mode. // 0 if the output is a valid mode.
// -1 if ACM failed to output a valid mode. // -1 if ACM failed to output a valid mode.
// //
virtual WebRtc_Word32 BackgroundNoiseMode( virtual WebRtc_Word32 BackgroundNoiseMode(ACMBackgroundNoiseMode& mode) = 0;
ACMBackgroundNoiseMode& mode) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 PlayoutTimestamp() // WebRtc_Word32 PlayoutTimestamp()
@@ -788,9 +718,7 @@ public:
// -1 if failed to output the correct timestamp. // -1 if failed to output the correct timestamp.
// //
// //
virtual WebRtc_Word32 PlayoutTimestamp( virtual WebRtc_Word32 PlayoutTimestamp(WebRtc_UWord32& timestamp) = 0;
WebRtc_UWord32& timestamp) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 DecoderEstimatedBandwidth() // WebRtc_Word32 DecoderEstimatedBandwidth()
@@ -805,7 +733,6 @@ public:
// //
virtual WebRtc_Word32 DecoderEstimatedBandwidth() const = 0; virtual WebRtc_Word32 DecoderEstimatedBandwidth() const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 SetPlayoutMode() // WebRtc_Word32 SetPlayoutMode()
// Call this API to set the playout mode. Playout mode could be optimized // Call this API to set the playout mode. Playout mode could be optimized
@@ -826,9 +753,7 @@ public:
// -1 if failed to set the mode, // -1 if failed to set the mode,
// 0 if succeeding. // 0 if succeeding.
// //
virtual WebRtc_Word32 SetPlayoutMode( virtual WebRtc_Word32 SetPlayoutMode(const AudioPlayoutMode mode) = 0;
const AudioPlayoutMode mode) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// AudioPlayoutMode PlayoutMode() // AudioPlayoutMode PlayoutMode()
@@ -845,7 +770,6 @@ public:
// //
virtual AudioPlayoutMode PlayoutMode() const = 0; virtual AudioPlayoutMode PlayoutMode() const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 PlayoutData10Ms( // WebRtc_Word32 PlayoutData10Ms(
// Get 10 milliseconds of raw audio data for playout, at the given sampling // Get 10 milliseconds of raw audio data for playout, at the given sampling
@@ -866,11 +790,10 @@ public:
// -1 if the function fails, // -1 if the function fails,
// 0 if the function succeeds. // 0 if the function succeeds.
// //
virtual WebRtc_Word32 PlayoutData10Ms( virtual WebRtc_Word32
const WebRtc_Word32 desiredFreqHz, PlayoutData10Ms(const WebRtc_Word32 desiredFreqHz,
AudioFrame &audioFrame) = 0; AudioFrame &audioFrame) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// (CNG) Comfort Noise Generation // (CNG) Comfort Noise Generation
// Generate comfort noise when receiving DTX packets // Generate comfort noise when receiving DTX packets
@@ -890,9 +813,7 @@ public:
// -1 if failed to enable/disable VAD, // -1 if failed to enable/disable VAD,
// 0 if succeded to enable/disable VAD. // 0 if succeded to enable/disable VAD.
// //
virtual WebRtc_Word16 SetReceiveVADStatus( virtual WebRtc_Word16 SetReceiveVADStatus(const bool enable) = 0;
const bool enable) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// bool ReceiveVADStatus() // bool ReceiveVADStatus()
@@ -906,7 +827,6 @@ public:
// //
virtual bool ReceiveVADStatus() const = 0; virtual bool ReceiveVADStatus() const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 SetReceiveVADMode() // WebRtc_Word16 SetReceiveVADMode()
// Configure VAD aggressiveness on the incoming stream. // Configure VAD aggressiveness on the incoming stream.
@@ -921,9 +841,7 @@ public:
// -1 if fails to set the mode, // -1 if fails to set the mode,
// 0 if the mode is set successfully. // 0 if the mode is set successfully.
// //
virtual WebRtc_Word16 SetReceiveVADMode( virtual WebRtc_Word16 SetReceiveVADMode(const ACMVADMode mode) = 0;
const ACMVADMode mode) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// ACMVADMode ReceiveVADMode() // ACMVADMode ReceiveVADMode()
@@ -977,7 +895,6 @@ public:
virtual WebRtc_Word32 SetISACMaxPayloadSize( virtual WebRtc_Word32 SetISACMaxPayloadSize(
const WebRtc_UWord16 maxPayloadLenBytes) = 0; const WebRtc_UWord16 maxPayloadLenBytes) = 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.
@@ -1007,7 +924,6 @@ public:
const WebRtc_UWord16 initRateBitPerSec, const WebRtc_UWord16 initRateBitPerSec,
const bool enforceFrameSize = false) = 0; const bool enforceFrameSize = false) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// statistics // statistics
// //
@@ -1026,7 +942,6 @@ public:
virtual WebRtc_Word32 NetworkStatistics( virtual WebRtc_Word32 NetworkStatistics(
ACMNetworkStatistics& networkStatistics) const = 0; ACMNetworkStatistics& networkStatistics) const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 JitterStatistics() // WebRtc_Word32 JitterStatistics()
// Get the jitter statistics. // Get the jitter statistics.
@@ -1041,7 +956,6 @@ public:
virtual WebRtc_Word32 JitterStatistics( virtual WebRtc_Word32 JitterStatistics(
ACMJitterStatistics& jitterStatistics) const = 0; ACMJitterStatistics& jitterStatistics) const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 PreferredBufferSize() // WebRtc_Word32 PreferredBufferSize()
// Get the optimal buffer size calculated for the current network // Get the optimal buffer size calculated for the current network
@@ -1058,7 +972,6 @@ public:
virtual WebRtc_Word32 PreferredBufferSize( virtual WebRtc_Word32 PreferredBufferSize(
WebRtc_UWord16& prefBufSize) const = 0; WebRtc_UWord16& prefBufSize) const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 ResetJitterStatistics() // WebRtc_Word32 ResetJitterStatistics()
// Reset jitter statistics. // Reset jitter statistics.
@@ -1072,5 +985,4 @@ public:
} // namespace webrtc } // namespace webrtc
#endif #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_H

View File

@@ -8,13 +8,12 @@
* 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 AUDIO_CODING_MODULE_TYPEDEFS_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_TYPEDEFS_H_
#define AUDIO_CODING_MODULE_TYPEDEFS_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_TYPEDEFS_H_
#include "typedefs.h" #include "typedefs.h"
namespace webrtc namespace webrtc {
{
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// enum AudioPlayoutMode // enum AudioPlayoutMode
@@ -36,14 +35,12 @@ namespace webrtc
// this mode can be used to improve the jitter robustness at // this mode can be used to improve the jitter robustness at
// the cost of increased delay. // the cost of increased delay.
// //
enum AudioPlayoutMode enum AudioPlayoutMode {
{
voice = 0, voice = 0,
fax = 1, fax = 1,
streaming = 2 streaming = 2
}; };
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// enum ACMSpeechType // enum ACMSpeechType
// An enumerator for possible labels of a decoded frame. // An enumerator for possible labels of a decoded frame.
@@ -61,8 +58,7 @@ enum AudioPlayoutMode
// -VADPassive : the VAD at the receiver recognizes this frame as // -VADPassive : the VAD at the receiver recognizes this frame as
// passive. // passive.
// //
enum ACMSpeechType enum ACMSpeechType {
{
normal = 0, normal = 0,
PLC = 1, PLC = 1,
CNG = 2, CNG = 2,
@@ -70,7 +66,6 @@ enum ACMSpeechType
VADPassive = 4 VADPassive = 4
}; };
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// enum ACMVADMode // enum ACMVADMode
// An enumerator for aggressiveness of VAD // An enumerator for aggressiveness of VAD
@@ -80,21 +75,18 @@ enum ACMSpeechType
// -VADAggr : an aggressive mode. // -VADAggr : an aggressive mode.
// -VADVeryAggr : the most agressive mode. // -VADVeryAggr : the most agressive mode.
// //
enum ACMVADMode enum ACMVADMode {
{
VADNormal = 0, VADNormal = 0,
VADLowBitrate = 1, VADLowBitrate = 1,
VADAggr = 2, VADAggr = 2,
VADVeryAggr = 3 VADVeryAggr = 3
}; };
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// enum ACMCountries // enum ACMCountries
// An enumerator for countries, used when enabling CPT for a specific country. // An enumerator for countries, used when enabling CPT for a specific country.
// //
enum ACMCountries enum ACMCountries {
{
ACMDisableCountryDetection = -1, // disable CPT detection ACMDisableCountryDetection = -1, // disable CPT detection
ACMUSA = 0, ACMUSA = 0,
ACMJapan, ACMJapan,
@@ -109,7 +101,7 @@ enum ACMCountries
ACMFinland, ACMFinland,
ACMGreece, ACMGreece,
ACMHungary, ACMHungary,
ACMIceland , ACMIceland,
ACMIreland, ACMIreland,
ACMItaly, ACMItaly,
ACMLuxembourg, ACMLuxembourg,
@@ -125,7 +117,8 @@ enum ACMCountries
ACMTaiwan, ACMTaiwan,
ACMKorea, ACMKorea,
ACMSingapore, ACMSingapore,
ACMNonStandard1 // non-standard countries ACMNonStandard1
// non-standard countries
}; };
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -138,8 +131,7 @@ enum ACMCountries
// -AMROctetAlligned : Octet-alligned mode. // -AMROctetAlligned : Octet-alligned mode.
// -AMRFileStorage : file-storage mode. // -AMRFileStorage : file-storage mode.
// //
enum ACMAMRPackingFormat enum ACMAMRPackingFormat {
{
AMRUndefined = -1, AMRUndefined = -1,
AMRBandwidthEfficient = 0, AMRBandwidthEfficient = 0,
AMROctetAlligned = 1, AMROctetAlligned = 1,
@@ -155,13 +147,13 @@ enum ACMAMRPackingFormat
// -preferredBufferSize : preferred (optimal) buffer size in ms // -preferredBufferSize : preferred (optimal) buffer size in ms
// -currentPacketLossRate : loss rate (network + late) (in Q14) // -currentPacketLossRate : loss rate (network + late) (in Q14)
// -currentDiscardRate : late loss rate (in Q14) // -currentDiscardRate : late loss rate (in Q14)
// -currentExpandRate : fraction (of original stream) of synthesized speech // -currentExpandRate : fraction (of original stream) of synthesized
// inserted through expansion (in Q14) // speech inserted through expansion (in Q14)
// -currentPreemptiveRate : fraction of synthesized speech inserted through // -currentPreemptiveRate : fraction of synthesized speech inserted through
// pre-emptive expansion (in Q14) // pre-emptive expansion (in Q14)
// -currentAccelerateRate : fraction of data removed through acceleration (in Q14) // -currentAccelerateRate : fraction of data removed through acceleration
typedef struct // (in Q14)
{ typedef struct {
WebRtc_UWord16 currentBufferSize; WebRtc_UWord16 currentBufferSize;
WebRtc_UWord16 preferredBufferSize; WebRtc_UWord16 preferredBufferSize;
WebRtc_UWord16 currentPacketLossRate; WebRtc_UWord16 currentPacketLossRate;
@@ -178,28 +170,37 @@ typedef struct
// -jbMinSize : smallest Jitter Buffer size during call in ms // -jbMinSize : smallest Jitter Buffer size during call in ms
// -jbMaxSize : largest Jitter Buffer size during call in ms // -jbMaxSize : largest Jitter Buffer size during call in ms
// -jbAvgSize : the average JB size, measured over time - ms // -jbAvgSize : the average JB size, measured over time - ms
// -jbChangeCount : number of times the Jitter Buffer changed (using Accelerate or Pre-emptive Expand) // -jbChangeCount : number of times the Jitter Buffer changed (using
// Accelerate or Pre-emptive Expand)
// -lateLossMs : amount (in ms) of audio data received late // -lateLossMs : amount (in ms) of audio data received late
// -accelerateMs : milliseconds removed to reduce jitter buffer size // -accelerateMs : milliseconds removed to reduce jitter buffer size
// -flushedMs : milliseconds discarded through buffer flushing // -flushedMs : milliseconds discarded through buffer flushing
// -generatedSilentMs : milliseconds of generated silence // -generatedSilentMs : milliseconds of generated silence
// -interpolatedVoiceMs : milliseconds of synthetic audio data (non-background noise) // -interpolatedVoiceMs : milliseconds of synthetic audio data
// -interpolatedSilentMs : milliseconds of synthetic audio data (background noise level) // (non-background noise)
// -numExpandTiny : count of tiny expansions in output audio less than 250 ms*/ // -interpolatedSilentMs : milliseconds of synthetic audio data (background
// -numExpandSmall : count of small expansions in output audio 250 to 500 ms*/ // noise level)
// -numExpandMedium : count of medium expansions in output audio 500 to 2000 ms*/ // -numExpandTiny : count of tiny expansions in output audio less
// -numExpandLong : count of long expansions in output audio longer than 2000 // than 250 ms
// -numExpandSmall : count of small expansions in output audio 250 to
// 500 ms
// -numExpandMedium : count of medium expansions in output audio 500 to
// 2000 ms
// -numExpandLong : count of long expansions in output audio longer
// than 2000
// -longestExpandDurationMs : duration of longest audio drop-out // -longestExpandDurationMs : duration of longest audio drop-out
// -countIAT500ms : count of times we got small network outage (inter-arrival time in [500, 1000) ms) // -countIAT500ms : count of times we got small network outage
// -countIAT1000ms : count of times we got medium network outage (inter-arrival time in [1000, 2000) ms) // (inter-arrival time in [500, 1000) ms)
// -countIAT2000ms : count of times we got large network outage (inter-arrival time >= 2000 ms) // -countIAT1000ms : count of times we got medium network outage
// (inter-arrival time in [1000, 2000) ms)
// -countIAT2000ms : count of times we got large network outage
// (inter-arrival time >= 2000 ms)
// -longestIATms : longest packet inter-arrival time in ms // -longestIATms : longest packet inter-arrival time in ms
// -minPacketDelayMs : min time incoming Packet "waited" to be played // -minPacketDelayMs : min time incoming Packet "waited" to be played
// -maxPacketDelayMs : max time incoming Packet "waited" to be played // -maxPacketDelayMs : max time incoming Packet "waited" to be played
// -avgPacketDelayMs : avg time incoming Packet "waited" to be played // -avgPacketDelayMs : avg time incoming Packet "waited" to be played
// //
typedef struct typedef struct {
{
WebRtc_UWord32 jbMinSize; WebRtc_UWord32 jbMinSize;
WebRtc_UWord32 jbMaxSize; WebRtc_UWord32 jbMaxSize;
WebRtc_UWord32 jbAvgSize; WebRtc_UWord32 jbAvgSize;
@@ -232,14 +233,12 @@ typedef struct
// -Fade : noise fades to zero after some time // -Fade : noise fades to zero after some time
// -Off : background noise is always zero // -Off : background noise is always zero
// //
enum ACMBackgroundNoiseMode enum ACMBackgroundNoiseMode {
{
On, On,
Fade, Fade,
Off Off
}; };
} // namespace webrtc } // namespace webrtc
#endif #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_TYPEDEFS_H_

View File

@@ -18,191 +18,130 @@
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.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
// interface file is needed: // interface file is needed:
// //
// /modules/audio_coding/codecs/amr/main/interface/amr_interface.h // /modules/audio_coding/codecs/amr/main/interface/amr_interface.h
// //
// 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_** encInst);
// int16_t WebRtcAmr_CreateDec(AMR_decinst_t_** decInst); // int16_t WebRtcAmr_CreateDec(AMR_decinst_t_** decInst);
// int16_t WebRtcAmr_FreeEnc(AMR_encinst_t_* encInst); // int16_t WebRtcAmr_FreeEnc(AMR_encinst_t_* encInst);
// int16_t WebRtcAmr_FreeDec(AMR_decinst_t_* decInst); // int16_t WebRtcAmr_FreeDec(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_Encode(AMR_encinst_t_* encInst, // int16_t WebRtcAmr_Encode(AMR_encinst_t_* encInst,
// 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_* encInst,
// int16_t dtxMode); // int16_t dtxMode);
// int16_t WebRtcAmr_EncodeBitmode(AMR_encinst_t_* encInst, // int16_t WebRtcAmr_EncodeBitmode(AMR_encinst_t_* encInst,
// int format); // int format);
// int16_t WebRtcAmr_Decode(AMR_decinst_t_* decInst); // int16_t WebRtcAmr_Decode(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_DecodePlc(AMR_decinst_t_* decInst); // int16_t WebRtcAmr_DecodePlc(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_DecoderInit(AMR_decinst_t_* decInst); // int16_t WebRtcAmr_DecoderInit(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_DecodeBitmode(AMR_decinst_t_* decInst, // int16_t WebRtcAmr_DecodeBitmode(AMR_decinst_t_* decInst,
// int format); // int format);
// void WebRtcAmr_Version(char *versionStr, short len); // void WebRtcAmr_Version(char *versionStr, short len);
#include "amr_interface.h" #include "amr_interface.h"
#endif #endif
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_AMR #ifndef WEBRTC_CODEC_AMR
ACMAMR::ACMAMR(WebRtc_Word16 /* codecID */) ACMAMR::ACMAMR(WebRtc_Word16 /* codecID */) {
{
return; return;
} }
ACMAMR::~ACMAMR() {
ACMAMR::~ACMAMR()
{
return; return;
} }
WebRtc_Word16 ACMAMR::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16* /* bitStreamLenByte */) {
ACMAMR::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMAMR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMAMR::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return -1; return -1;
} }
WebRtc_Word16 ACMAMR::EnableDTX() {
WebRtc_Word16
ACMAMR::EnableDTX()
{
return -1; return -1;
} }
WebRtc_Word16 ACMAMR::DisableDTX() {
WebRtc_Word16
ACMAMR::DisableDTX()
{
return -1; return -1;
} }
WebRtc_Word16 ACMAMR::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMAMR::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMAMR::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMAMR::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word32 WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
ACMAMR::CodecDef( const CodecInst& /* codecInst */) {
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1; return -1;
} }
ACMGenericCodec* ACMGenericCodec* ACMAMR::CreateInstance(void) {
ACMAMR::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMAMR::InternalCreateEncoder() {
WebRtc_Word16
ACMAMR::InternalCreateEncoder()
{
return -1; return -1;
} }
void ACMAMR::DestructEncoderSafe() {
void
ACMAMR::DestructEncoderSafe()
{
return; return;
} }
WebRtc_Word16 ACMAMR::InternalCreateDecoder() {
WebRtc_Word16
ACMAMR::InternalCreateDecoder()
{
return -1; return -1;
} }
void ACMAMR::DestructDecoderSafe() {
void
ACMAMR::DestructDecoderSafe()
{
return; return;
} }
WebRtc_Word16 ACMAMR::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
WebRtc_Word16
ACMAMR::SetBitRateSafe(
const WebRtc_Word32 /* rate */)
{
return -1; return -1;
} }
void ACMAMR::InternalDestructEncoderInst(void* /* ptrInst */) {
void
ACMAMR::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return; return;
} }
WebRtc_Word16 ACMAMR::SetAMREncoderPackingFormat(
WebRtc_Word16 ACMAMRPackingFormat /* packingFormat */) {
ACMAMR::SetAMREncoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */)
{
return -1; return -1;
} }
ACMAMRPackingFormat ACMAMR::AMREncoderPackingFormat() const {
ACMAMRPackingFormat
ACMAMR::AMREncoderPackingFormat() const
{
return AMRUndefined; return AMRUndefined;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMR::SetAMRDecoderPackingFormat(
ACMAMR::SetAMRDecoderPackingFormat( ACMAMRPackingFormat /* packingFormat */) {
ACMAMRPackingFormat /* packingFormat */)
{
return -1; return -1;
} }
ACMAMRPackingFormat ACMAMRPackingFormat ACMAMR::AMRDecoderPackingFormat() const {
ACMAMR::AMRDecoderPackingFormat() const
{
return AMRUndefined; return AMRUndefined;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMR::UnregisterFromNetEqSafe(ACMNetEQ* /* netEq */,
ACMAMR::UnregisterFromNetEqSafe( WebRtc_Word16 /* payloadType */) {
ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */)
{
return -1; return -1;
} }
@@ -218,12 +157,11 @@ ACMAMR::UnregisterFromNetEqSafe(
#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 codecID)
_encoderInstPtr(NULL), : _encoderInstPtr(NULL),
_decoderInstPtr(NULL), _decoderInstPtr(NULL),
_encodingMode(-1), // invalid value _encodingMode(-1), // invalid value
_encodingRate(0) // invalid value _encodingRate(0) { // invalid value
{
_codecID = codecID; _codecID = codecID;
_hasInternalDTX = true; _hasInternalDTX = true;
_encoderPackingFormat = AMRBandwidthEfficient; _encoderPackingFormat = AMRBandwidthEfficient;
@@ -231,50 +169,41 @@ _encodingRate(0) // invalid value
return; return;
} }
ACMAMR::~ACMAMR() {
ACMAMR::~ACMAMR() if (_encoderInstPtr != NULL) {
{
if(_encoderInstPtr != NULL)
{
WebRtcAmr_FreeEnc(_encoderInstPtr); WebRtcAmr_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
WebRtcAmr_FreeDec(_decoderInstPtr); WebRtcAmr_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
return; return;
} }
WebRtc_Word16 ACMAMR::InternalEncode(WebRtc_UWord8* bitStream,
WebRtc_Word16 WebRtc_Word16* bitStreamLenByte) {
ACMAMR::InternalEncode(
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
WebRtc_Word16 vadDecision = 1; WebRtc_Word16 vadDecision = 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) || (_encodingMode > WEBRTC_AMR_MR122)) if ((_encodingMode < WEBRTC_AMR_MR475) ||
{ (_encodingMode > WEBRTC_AMR_MR122)) {
*bitStreamLenByte = 0; *bitStreamLenByte = 0;
return -1; return -1;
} }
*bitStreamLenByte = WebRtcAmr_Encode(_encoderInstPtr, *bitStreamLenByte = WebRtcAmr_Encode(_encoderInstPtr,
&_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream, &_inAudio[_inAudioIxRead],
_frameLenSmpl,
(WebRtc_Word16*) bitStream,
_encodingMode); _encodingMode);
// Update VAD, if internal DTX is used // Update VAD, if internal DTX is used
if(_hasInternalDTX && _dtxEnabled) if (_hasInternalDTX && _dtxEnabled) {
{ if (*bitStreamLenByte <= (7 * _frameLenSmpl / 160)) {
if(*bitStreamLenByte <= (7*_frameLenSmpl/160))
{
vadDecision = 0; vadDecision = 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; _vadLabel[n] = vadDecision;
} }
} }
@@ -283,100 +212,65 @@ ACMAMR::InternalEncode(
return *bitStreamLenByte; return *bitStreamLenByte;
} }
WebRtc_Word16 ACMAMR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMAMR::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return 0; return 0;
} }
WebRtc_Word16 ACMAMR::EnableDTX() {
WebRtc_Word16 if (_dtxEnabled) {
ACMAMR::EnableDTX()
{
if(_dtxEnabled)
{
return 0; return 0;
} } else if (_encoderExist) { // check if encoder exist
else if(_encoderExist) // check if encoder exist
{
// enable DTX // enable DTX
if(WebRtcAmr_EncoderInit(_encoderInstPtr, 1) < 0) if (WebRtcAmr_EncoderInit(_encoderInstPtr, 1) < 0) {
{
return -1; return -1;
} }
_dtxEnabled = true; _dtxEnabled = true;
return 0; return 0;
} } else {
else
{
return -1; return -1;
} }
} }
WebRtc_Word16 ACMAMR::DisableDTX() {
WebRtc_Word16 if (!_dtxEnabled) {
ACMAMR::DisableDTX()
{
if(!_dtxEnabled)
{
return 0; return 0;
} } else if (_encoderExist) { // check if encoder exist
else if(_encoderExist) // check if encoder exist
{
// disable DTX // disable DTX
if(WebRtcAmr_EncoderInit(_encoderInstPtr, 0) < 0) if (WebRtcAmr_EncoderInit(_encoderInstPtr, 0) < 0) {
{
return -1; return -1;
} }
_dtxEnabled = false; _dtxEnabled = false;
return 0; return 0;
} } else {
else
{
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless
return 0; return 0;
} }
} }
WebRtc_Word16 ACMAMR::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
WebRtc_Word16
ACMAMR::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate); WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate);
status += (WebRtcAmr_EncoderInit(_encoderInstPtr, status += (WebRtcAmr_EncoderInit(
((codecParams->enableDTX)? 1:0)) < 0)? -1:0; _encoderInstPtr, ((codecParams->enableDTX) ? 1 : 0)) < 0) ? -1 : 0;
status += (WebRtcAmr_EncodeBitmode(_encoderInstPtr, status += (WebRtcAmr_EncodeBitmode(
_encoderPackingFormat ) < 0)? -1:0; _encoderInstPtr, _encoderPackingFormat) < 0) ? -1 : 0;
return (status < 0)? -1:0; return (status < 0) ? -1 : 0;
} }
WebRtc_Word16 ACMAMR::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMAMR::InternalInitDecoder( WebRtc_Word16 status =
WebRtcACMCodecParams* /* codecParams */) ((WebRtcAmr_DecoderInit(_decoderInstPtr) < 0) ? -1 : 0);
{ status += WebRtcAmr_DecodeBitmode(_decoderInstPtr, _decoderPackingFormat);
WebRtc_Word16 status = ( return (status < 0) ? -1 : 0;
(WebRtcAmr_DecoderInit(_decoderInstPtr) < 0)? -1:0);
status +=
WebRtcAmr_DecodeBitmode(_decoderInstPtr, _decoderPackingFormat);
return (status < 0)? -1:0;
} }
WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtc_Word32 const CodecInst& codecInst) {
ACMAMR::CodecDef( if (!_decoderInitialized) {
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
// Todo: // Todo:
// log error // log error
return -1; return -1;
@@ -385,32 +279,22 @@ ACMAMR::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, SET_CODEC_PAR((codecDef), kDecoderAMR, codecInst.pltype, _decoderInstPtr,
_decoderInstPtr, 8000); 8000);
SET_AMR_FUNCTIONS((codecDef)); SET_AMR_FUNCTIONS((codecDef));
return 0; return 0;
} }
ACMGenericCodec* ACMAMR::CreateInstance(void) {
ACMGenericCodec*
ACMAMR::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMAMR::InternalCreateEncoder() {
WebRtc_Word16
ACMAMR::InternalCreateEncoder()
{
return WebRtcAmr_CreateEnc(&_encoderInstPtr); return WebRtcAmr_CreateEnc(&_encoderInstPtr);
} }
void ACMAMR::DestructEncoderSafe() {
void if (_encoderInstPtr != NULL) {
ACMAMR::DestructEncoderSafe()
{
if(_encoderInstPtr != NULL)
{
WebRtcAmr_FreeEnc(_encoderInstPtr); WebRtcAmr_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
@@ -421,19 +305,12 @@ ACMAMR::DestructEncoderSafe()
_encodingRate = 0; // invalid value _encodingRate = 0; // invalid value
} }
WebRtc_Word16 ACMAMR::InternalCreateDecoder() {
WebRtc_Word16
ACMAMR::InternalCreateDecoder()
{
return WebRtcAmr_CreateDec(&_decoderInstPtr); return WebRtcAmr_CreateDec(&_decoderInstPtr);
} }
void ACMAMR::DestructDecoderSafe() {
void if (_decoderInstPtr != NULL) {
ACMAMR::DestructDecoderSafe()
{
if(_decoderInstPtr != NULL)
{
WebRtcAmr_FreeDec(_decoderInstPtr); WebRtcAmr_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
@@ -442,146 +319,114 @@ ACMAMR::DestructDecoderSafe()
_decoderInitialized = false; _decoderInitialized = false;
} }
WebRtc_Word16 ACMAMR::SetBitRateSafe(const WebRtc_Word32 rate) {
WebRtc_Word16 switch (rate) {
ACMAMR::SetBitRateSafe(const WebRtc_Word32 rate) case 4750: {
{
switch(rate)
{
case 4750:
_encodingMode = WEBRTC_AMR_MR475; _encodingMode = WEBRTC_AMR_MR475;
_encodingRate = 4750; _encodingRate = 4750;
break; break;
case 5150: }
case 5150: {
_encodingMode = WEBRTC_AMR_MR515; _encodingMode = WEBRTC_AMR_MR515;
_encodingRate = 5150; _encodingRate = 5150;
break; break;
case 5900: }
case 5900: {
_encodingMode = WEBRTC_AMR_MR59; _encodingMode = WEBRTC_AMR_MR59;
_encodingRate = 5900; _encodingRate = 5900;
break; break;
case 6700: }
case 6700: {
_encodingMode = WEBRTC_AMR_MR67; _encodingMode = WEBRTC_AMR_MR67;
_encodingRate = 6700; _encodingRate = 6700;
break; break;
case 7400: }
case 7400: {
_encodingMode = WEBRTC_AMR_MR74; _encodingMode = WEBRTC_AMR_MR74;
_encodingRate = 7400; _encodingRate = 7400;
break; break;
case 7950: }
case 7950: {
_encodingMode = WEBRTC_AMR_MR795; _encodingMode = WEBRTC_AMR_MR795;
_encodingRate = 7950; _encodingRate = 7950;
break; break;
case 10200: }
case 10200: {
_encodingMode = WEBRTC_AMR_MR102; _encodingMode = WEBRTC_AMR_MR102;
_encodingRate = 10200; _encodingRate = 10200;
break; break;
case 12200: }
case 12200: {
_encodingMode = WEBRTC_AMR_MR122; _encodingMode = WEBRTC_AMR_MR122;
_encodingRate = 12200; _encodingRate = 12200;
break; break;
default: }
default: {
return -1; return -1;
break; }
} }
return 0; return 0;
} }
void ACMAMR::InternalDestructEncoderInst(void* ptrInst) {
void
ACMAMR::InternalDestructEncoderInst(
void* ptrInst)
{
// Free the memory where ptrInst is pointing to // Free the memory where ptrInst is pointing to
if(ptrInst != NULL) if (ptrInst != NULL) {
{ WebRtcAmr_FreeEnc(reinterpret_cast<AMR_encinst_t_*>(ptrInst));
WebRtcAmr_FreeEnc((AMR_encinst_t_*)ptrInst);
} }
return; return;
} }
WebRtc_Word16 ACMAMR::SetAMREncoderPackingFormat(
WebRtc_Word16 ACMAMRPackingFormat packingFormat) {
ACMAMR::SetAMREncoderPackingFormat( if ((packingFormat != AMRBandwidthEfficient) &&
ACMAMRPackingFormat packingFormat)
{
if((packingFormat != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) && (packingFormat != AMROctetAlligned) &&
(packingFormat != AMRFileStorage)) (packingFormat != AMRFileStorage)) {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"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(_encoderInstPtr,
packingFormat) < 0)
{
return -1; return -1;
} } else {
else
{
_encoderPackingFormat = packingFormat; _encoderPackingFormat = packingFormat;
return 0; return 0;
} }
} }
} }
ACMAMRPackingFormat ACMAMR::AMREncoderPackingFormat() const {
ACMAMRPackingFormat
ACMAMR::AMREncoderPackingFormat() const
{
return _encoderPackingFormat; return _encoderPackingFormat;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMR::SetAMRDecoderPackingFormat(
ACMAMR::SetAMRDecoderPackingFormat( ACMAMRPackingFormat packingFormat) {
ACMAMRPackingFormat packingFormat) if ((packingFormat != AMRBandwidthEfficient) &&
{
if((packingFormat != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) && (packingFormat != AMROctetAlligned) &&
(packingFormat != AMRFileStorage)) (packingFormat != AMRFileStorage)) {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"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(_decoderInstPtr,
packingFormat) < 0)
{
return -1; return -1;
} } else {
else
{
_decoderPackingFormat = packingFormat; _decoderPackingFormat = packingFormat;
return 0; return 0;
} }
} }
} }
ACMAMRPackingFormat ACMAMRPackingFormat ACMAMR::AMRDecoderPackingFormat() const {
ACMAMR::AMRDecoderPackingFormat() const
{
return _decoderPackingFormat; return _decoderPackingFormat;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMR::UnregisterFromNetEqSafe(ACMNetEQ* netEq,
ACMAMR::UnregisterFromNetEqSafe( WebRtc_Word16 payloadType) {
ACMNetEQ* netEq, if (payloadType != _decoderParams.codecInstant.pltype) {
WebRtc_Word16 payloadType)
{
if(payloadType != _decoderParams.codecInstant.pltype)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec %s given payload-type %d does not match \ "Cannot unregister codec %s given payload-type %d does not "
the stored payload type", "match the stored payload type",
_decoderParams.codecInstant.plname, _decoderParams.codecInstant.plname, payloadType,
payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }
@@ -591,4 +436,3 @@ the stored payload type",
#endif #endif
} }

View File

@@ -8,8 +8,8 @@
* 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 ACM_AMR_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_
#define ACM_AMR_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -21,23 +21,19 @@ namespace webrtc {
enum ACMAMRPackingFormat; enum ACMAMRPackingFormat;
class ACMAMR : public ACMGenericCodec class ACMAMR: public ACMGenericCodec {
{ public:
public:
ACMAMR(WebRtc_Word16 codecID); ACMAMR(WebRtc_Word16 codecID);
~ACMAMR(); ~ACMAMR();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 SetAMREncoderPackingFormat( WebRtc_Word16 SetAMREncoderPackingFormat(
const ACMAMRPackingFormat packingFormat); const ACMAMRPackingFormat packingFormat);
@@ -49,16 +45,13 @@ public:
ACMAMRPackingFormat AMRDecoderPackingFormat() const; ACMAMRPackingFormat AMRDecoderPackingFormat() const;
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@@ -69,18 +62,15 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
WebRtc_Word16 SetBitRateSafe( WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
const WebRtc_Word32 rate);
WebRtc_Word16 EnableDTX(); WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX(); WebRtc_Word16 DisableDTX();
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
ACMNetEQ* netEq,
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
AMR_encinst_t_* _encoderInstPtr; AMR_encinst_t_* _encoderInstPtr;
@@ -93,4 +83,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif // ACM_AMR_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_

View File

@@ -18,175 +18,129 @@
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.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
// following interface file is needed: // following interface file is needed:
// //
// /modules/audio_coding/codecs/amrwb/main/interface/amrwb_interface.h // /modules/audio_coding/codecs/amrwb/main/interface/amrwb_interface.h
// //
// 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_** encInst);
// int16_t WebRtcAmrWb_CreateDec(AMRWB_decinst_t_** decInst); // int16_t WebRtcAmrWb_CreateDec(AMRWB_decinst_t_** decInst);
// int16_t WebRtcAmrWb_FreeEnc(AMRWB_encinst_t_* encInst); // int16_t WebRtcAmrWb_FreeEnc(AMRWB_encinst_t_* encInst);
// int16_t WebRtcAmrWb_FreeDec(AMRWB_decinst_t_* decInst); // int16_t WebRtcAmrWb_FreeDec(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_Encode(AMRWB_encinst_t_* encInst, int16_t* input, // int16_t WebRtcAmrWb_Encode(AMRWB_encinst_t_* encInst, 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_* encInst,
// int16_t dtxMode); // int16_t dtxMode);
// int16_t WebRtcAmrWb_EncodeBitmode(AMRWB_encinst_t_* encInst, // int16_t WebRtcAmrWb_EncodeBitmode(AMRWB_encinst_t_* encInst,
// int format); // int format);
// int16_t WebRtcAmrWb_Decode(AMRWB_decinst_t_* decInst); // int16_t WebRtcAmrWb_Decode(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_DecodePlc(AMRWB_decinst_t_* decInst); // int16_t WebRtcAmrWb_DecodePlc(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_DecoderInit(AMRWB_decinst_t_* decInst); // int16_t WebRtcAmrWb_DecoderInit(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_DecodeBitmode(AMRWB_decinst_t_* decInst, // int16_t WebRtcAmrWb_DecodeBitmode(AMRWB_decinst_t_* decInst,
// int format); // int format);
// void WebRtcAmrWb_Version(char *versionStr, short len); // void WebRtcAmrWb_Version(char *versionStr, short len);
#include "amrwb_interface.h" #include "amrwb_interface.h"
#endif #endif
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_AMRWB #ifndef WEBRTC_CODEC_AMRWB
ACMAMRwb::ACMAMRwb(WebRtc_Word16 /* codecID*/) ACMAMRwb::ACMAMRwb(WebRtc_Word16 /* codecID*/) {
{
return; return;
} }
ACMAMRwb::~ACMAMRwb() ACMAMRwb::~ACMAMRwb() {
{
return; return;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::InternalEncode(WebRtc_UWord8* /* bitStream */,
ACMAMRwb::InternalEncode( WebRtc_Word16* /* bitStreamLenByte */) {
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitStream */,
ACMAMRwb::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::EnableDTX() {
ACMAMRwb::EnableDTX()
{
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::DisableDTX() {
ACMAMRwb::DisableDTX()
{
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::InternalInitEncoder(
ACMAMRwb::InternalInitEncoder( WebRtcACMCodecParams* /* codecParams */) {
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::InternalInitDecoder(
ACMAMRwb::InternalInitDecoder( WebRtcACMCodecParams* /* codecParams */) {
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word32 WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
ACMAMRwb::CodecDef( const CodecInst& /* codecInst */) {
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1; return -1;
} }
ACMGenericCodec* ACMGenericCodec*
ACMAMRwb::CreateInstance(void) ACMAMRwb::CreateInstance(void) {
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMAMRwb::InternalCreateEncoder() {
WebRtc_Word16
ACMAMRwb::InternalCreateEncoder()
{
return -1; return -1;
} }
void void ACMAMRwb::DestructEncoderSafe() {
ACMAMRwb::DestructEncoderSafe()
{
return; return;
} }
WebRtc_Word16 ACMAMRwb::InternalCreateDecoder() {
WebRtc_Word16
ACMAMRwb::InternalCreateDecoder()
{
return -1; return -1;
} }
void void ACMAMRwb::DestructDecoderSafe() {
ACMAMRwb::DestructDecoderSafe()
{
return; return;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
ACMAMRwb::SetBitRateSafe(
const WebRtc_Word32 /* rate */)
{
return -1; return -1;
} }
void void ACMAMRwb::InternalDestructEncoderInst(void* /* ptrInst */) {
ACMAMRwb::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return; return;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::SetAMRwbEncoderPackingFormat(
ACMAMRwb::SetAMRwbEncoderPackingFormat( ACMAMRPackingFormat /* packingFormat */) {
ACMAMRPackingFormat /* packingFormat */)
{
return -1; return -1;
} }
ACMAMRPackingFormat ACMAMRPackingFormat ACMAMRwb::AMRwbEncoderPackingFormat() const {
ACMAMRwb::AMRwbEncoderPackingFormat() const
{
return AMRUndefined; return AMRUndefined;
} }
WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat( WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */) ACMAMRPackingFormat /* packingFormat */) {
{
return -1; return -1;
} }
ACMAMRPackingFormat ACMAMRPackingFormat ACMAMRwb::AMRwbDecoderPackingFormat() const {
ACMAMRwb::AMRwbDecoderPackingFormat() const
{
return AMRUndefined; return AMRUndefined;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::UnregisterFromNetEqSafe(
ACMAMRwb::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */, ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */) WebRtc_Word16 /* payloadType */) {
{
return -1; return -1;
} }
@@ -202,12 +156,11 @@ ACMAMRwb::UnregisterFromNetEqSafe(
#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 codecID)
_encoderInstPtr(NULL), : _encoderInstPtr(NULL),
_decoderInstPtr(NULL), _decoderInstPtr(NULL),
_encodingMode(-1), // invalid value _encodingMode(-1), // invalid value
_encodingRate(0) // invalid value _encodingRate(0) { // invalid value
{
_codecID = codecID; _codecID = codecID;
_hasInternalDTX = true; _hasInternalDTX = true;
_encoderPackingFormat = AMRBandwidthEfficient; _encoderPackingFormat = AMRBandwidthEfficient;
@@ -215,48 +168,40 @@ _encodingRate(0) // invalid value
return; return;
} }
ACMAMRwb::~ACMAMRwb() ACMAMRwb::~ACMAMRwb() {
{ if (_encoderInstPtr != NULL) {
if(_encoderInstPtr != NULL)
{
WebRtcAmrWb_FreeEnc(_encoderInstPtr); WebRtcAmrWb_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
WebRtcAmrWb_FreeDec(_decoderInstPtr); WebRtcAmrWb_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
return; return;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::InternalEncode(WebRtc_UWord8* bitStream,
ACMAMRwb::InternalEncode( WebRtc_Word16* bitStreamLenByte) {
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
WebRtc_Word16 vadDecision = 1; WebRtc_Word16 vadDecision = 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 ((_encodingMode < AMRWB_MODE_7k) || (_encodingMode > AMRWB_MODE_24k)) {
{
*bitStreamLenByte = 0; *bitStreamLenByte = 0;
return -1; return -1;
} }
*bitStreamLenByte = *bitStreamLenByte = WebRtcAmrWb_Encode(_encoderInstPtr,
WebRtcAmrWb_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead], &_inAudio[_inAudioIxRead],
_frameLenSmpl, (WebRtc_Word16*)bitStream, _encodingMode); _frameLenSmpl,
(WebRtc_Word16*) bitStream,
_encodingMode);
// Update VAD, if internal DTX is used // Update VAD, if internal DTX is used
if(_hasInternalDTX && _dtxEnabled) if (_hasInternalDTX && _dtxEnabled) {
{ if (*bitStreamLenByte <= (7 * _frameLenSmpl / 160)) {
if (*bitStreamLenByte <= (7*_frameLenSmpl/160))
{
vadDecision = 0; vadDecision = 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; _vadLabel[n] = vadDecision;
} }
} }
@@ -266,101 +211,70 @@ ACMAMRwb::InternalEncode(
return *bitStreamLenByte; return *bitStreamLenByte;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitStream */,
ACMAMRwb::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return 0; return 0;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::EnableDTX() {
ACMAMRwb::EnableDTX() if (_dtxEnabled) {
{
if(_dtxEnabled)
{
return 0; return 0;
} } else if (_encoderExist) { // check if encoder exist
else if(_encoderExist) // check if encoder exist
{
// enable DTX // enable DTX
if(WebRtcAmrWb_EncoderInit(_encoderInstPtr, 1) < 0) if (WebRtcAmrWb_EncoderInit(_encoderInstPtr, 1) < 0) {
{
return -1; return -1;
} }
_dtxEnabled = true; _dtxEnabled = true;
return 0; return 0;
} } else {
else
{
return -1; return -1;
} }
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::DisableDTX() {
ACMAMRwb::DisableDTX() if (!_dtxEnabled) {
{
if(!_dtxEnabled)
{
return 0; return 0;
} } else if (_encoderExist) { // check if encoder exist
else if(_encoderExist) // check if encoder exist
{
// disable DTX // disable DTX
if(WebRtcAmrWb_EncoderInit(_encoderInstPtr, 0) < 0) if (WebRtcAmrWb_EncoderInit(_encoderInstPtr, 0) < 0) {
{
return -1; return -1;
} }
_dtxEnabled = false; _dtxEnabled = false;
return 0; return 0;
} } else {
else
{
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless
return 0; return 0;
} }
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
ACMAMRwb::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
// sanity check // sanity check
if (_encoderInstPtr == NULL) if (_encoderInstPtr == NULL) {
{
return -1; return -1;
} }
WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate); WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate);
status += (WebRtcAmrWb_EncoderInit( status += (WebRtcAmrWb_EncoderInit(
_encoderInstPtr, ((codecParams->enableDTX)? 1:0)) < 0)? -1:0; _encoderInstPtr, ((codecParams->enableDTX) ? 1 : 0)) < 0) ? -1 : 0;
status += (WebRtcAmrWb_EncodeBitmode( status += (WebRtcAmrWb_EncodeBitmode(
_encoderInstPtr, _encoderPackingFormat ) < 0)? -1:0; _encoderInstPtr, _encoderPackingFormat) < 0) ? -1 : 0;
return (status < 0)? -1:0; return (status < 0) ? -1 : 0;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::InternalInitDecoder(
ACMAMRwb::InternalInitDecoder( WebRtcACMCodecParams* /* codecParams */) {
WebRtcACMCodecParams* /* codecParams */) WebRtc_Word16 status = WebRtcAmrWb_DecodeBitmode(_decoderInstPtr,
{ _decoderPackingFormat);
WebRtc_Word16 status = WebRtcAmrWb_DecodeBitmode( status += ((WebRtcAmrWb_DecoderInit(_decoderInstPtr) < 0) ? -1 : 0);
_decoderInstPtr, _decoderPackingFormat); return (status < 0) ? -1 : 0;
status += ((WebRtcAmrWb_DecoderInit(_decoderInstPtr) < 0)? -1:0);
return (status < 0)? -1:0;
} }
WebRtc_Word32 WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
ACMAMRwb::CodecDef( const CodecInst& codecInst) {
WebRtcNetEQ_CodecDef& codecDef, if (!_decoderInitialized) {
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
// Todo:
// log error
return -1; return -1;
} }
@@ -368,29 +282,22 @@ ACMAMRwb::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, SET_CODEC_PAR((codecDef), kDecoderAMRWB, codecInst.pltype, _decoderInstPtr,
_decoderInstPtr, 16000); 16000);
SET_AMRWB_FUNCTIONS((codecDef)); SET_AMRWB_FUNCTIONS((codecDef));
return 0; return 0;
} }
ACMGenericCodec* ACMGenericCodec* ACMAMRwb::CreateInstance(void) {
ACMAMRwb::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::InternalCreateEncoder() {
ACMAMRwb::InternalCreateEncoder()
{
return WebRtcAmrWb_CreateEnc(&_encoderInstPtr); return WebRtcAmrWb_CreateEnc(&_encoderInstPtr);
} }
void void ACMAMRwb::DestructEncoderSafe() {
ACMAMRwb::DestructEncoderSafe() if (_encoderInstPtr != NULL) {
{
if(_encoderInstPtr != NULL)
{
WebRtcAmrWb_FreeEnc(_encoderInstPtr); WebRtcAmrWb_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
@@ -401,18 +308,12 @@ ACMAMRwb::DestructEncoderSafe()
_encodingRate = 0; _encodingRate = 0;
} }
WebRtc_Word16 ACMAMRwb::InternalCreateDecoder() {
WebRtc_Word16
ACMAMRwb::InternalCreateDecoder()
{
return WebRtcAmrWb_CreateDec(&_decoderInstPtr); return WebRtcAmrWb_CreateDec(&_decoderInstPtr);
} }
void void ACMAMRwb::DestructDecoderSafe() {
ACMAMRwb::DestructDecoderSafe() if (_decoderInstPtr != NULL) {
{
if(_decoderInstPtr != NULL)
{
WebRtcAmrWb_FreeDec(_decoderInstPtr); WebRtcAmrWb_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
@@ -421,164 +322,118 @@ ACMAMRwb::DestructDecoderSafe()
_decoderInitialized = false; _decoderInitialized = false;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::SetBitRateSafe(const WebRtc_Word32 rate) {
ACMAMRwb::SetBitRateSafe( switch (rate) {
const WebRtc_Word32 rate) case 7000: {
{
switch(rate)
{
case 7000:
{
_encodingMode = AMRWB_MODE_7k; _encodingMode = AMRWB_MODE_7k;
_encodingRate = 7000; _encodingRate = 7000;
break; break;
} }
case 9000: case 9000: {
{
_encodingMode = AMRWB_MODE_9k; _encodingMode = AMRWB_MODE_9k;
_encodingRate = 9000; _encodingRate = 9000;
break; break;
} }
case 12000: case 12000: {
{
_encodingMode = AMRWB_MODE_12k; _encodingMode = AMRWB_MODE_12k;
_encodingRate = 12000; _encodingRate = 12000;
break; break;
} }
case 14000: case 14000: {
{
_encodingMode = AMRWB_MODE_14k; _encodingMode = AMRWB_MODE_14k;
_encodingRate = 14000; _encodingRate = 14000;
break; break;
} }
case 16000: case 16000: {
{
_encodingMode = AMRWB_MODE_16k; _encodingMode = AMRWB_MODE_16k;
_encodingRate = 16000; _encodingRate = 16000;
break; break;
} }
case 18000: case 18000: {
{
_encodingMode = AMRWB_MODE_18k; _encodingMode = AMRWB_MODE_18k;
_encodingRate = 18000; _encodingRate = 18000;
break; break;
} }
case 20000: case 20000: {
{
_encodingMode = AMRWB_MODE_20k; _encodingMode = AMRWB_MODE_20k;
_encodingRate = 20000; _encodingRate = 20000;
break; break;
} }
case 23000: case 23000: {
{
_encodingMode = AMRWB_MODE_23k; _encodingMode = AMRWB_MODE_23k;
_encodingRate = 23000; _encodingRate = 23000;
break; break;
} }
case 24000: case 24000: {
{
_encodingMode = AMRWB_MODE_24k; _encodingMode = AMRWB_MODE_24k;
_encodingRate = 24000; _encodingRate = 24000;
break; break;
} }
default: default: {
{
return -1; return -1;
break;
} }
} }
return 0; return 0;
} }
void void ACMAMRwb::InternalDestructEncoderInst(void* ptrInst) {
ACMAMRwb::InternalDestructEncoderInst( if (ptrInst != NULL) {
void* ptrInst) WebRtcAmrWb_FreeEnc(static_cast<AMRWB_encinst_t_*>(ptrInst));
{
if(ptrInst != NULL)
{
WebRtcAmrWb_FreeEnc((AMRWB_encinst_t_*)ptrInst);
} }
return; return;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::SetAMRwbEncoderPackingFormat(
ACMAMRwb::SetAMRwbEncoderPackingFormat( ACMAMRPackingFormat packingFormat) {
ACMAMRPackingFormat packingFormat) if ((packingFormat != AMRBandwidthEfficient) &&
{
if((packingFormat != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) && (packingFormat != AMROctetAlligned) &&
(packingFormat != AMRFileStorage)) (packingFormat != AMRFileStorage)) {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"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(_encoderInstPtr,
packingFormat) < 0)
{
return -1; return -1;
} } else {
else
{
_encoderPackingFormat = packingFormat; _encoderPackingFormat = packingFormat;
return 0; return 0;
} }
} }
} }
ACMAMRPackingFormat ACMAMRPackingFormat ACMAMRwb::AMRwbEncoderPackingFormat() const {
ACMAMRwb::AMRwbEncoderPackingFormat() const
{
return _encoderPackingFormat; return _encoderPackingFormat;
} }
WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat( WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat(
ACMAMRPackingFormat packingFormat) ACMAMRPackingFormat packingFormat) {
{ if ((packingFormat != AMRBandwidthEfficient) &&
if((packingFormat != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) && (packingFormat != AMROctetAlligned) &&
(packingFormat != AMRFileStorage)) (packingFormat != AMRFileStorage)) {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"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(_decoderInstPtr,
packingFormat) < 0)
{
return -1; return -1;
} } else {
else
{
_decoderPackingFormat = packingFormat; _decoderPackingFormat = packingFormat;
return 0; return 0;
} }
} }
} }
ACMAMRPackingFormat ACMAMRPackingFormat ACMAMRwb::AMRwbDecoderPackingFormat() const {
ACMAMRwb::AMRwbDecoderPackingFormat() const
{
return _decoderPackingFormat; return _decoderPackingFormat;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::UnregisterFromNetEqSafe(ACMNetEQ* netEq,
ACMAMRwb::UnregisterFromNetEqSafe( WebRtc_Word16 payloadType) {
ACMNetEQ* netEq, if (payloadType != _decoderParams.codecInstant.pltype) {
WebRtc_Word16 payloadType)
{
if(payloadType != _decoderParams.codecInstant.pltype)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec %s given payload-type %d does not match \ "Cannot unregister codec %s given payload-type %d does not"
the stored payload type", "match the stored payload type",
_decoderParams.codecInstant.plname, _decoderParams.codecInstant.plname, payloadType,
payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }

View File

@@ -8,8 +8,8 @@
* 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 ACM_AMRWB_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_
#define ACM_AMRWB_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -21,23 +21,19 @@ namespace webrtc {
enum ACMAMRPackingFormat; enum ACMAMRPackingFormat;
class ACMAMRwb : public ACMGenericCodec class ACMAMRwb: public ACMGenericCodec {
{ public:
public:
ACMAMRwb(WebRtc_Word16 codecID); ACMAMRwb(WebRtc_Word16 codecID);
~ACMAMRwb(); ~ACMAMRwb();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams* codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams* codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 SetAMRwbEncoderPackingFormat( WebRtc_Word16 SetAMRwbEncoderPackingFormat(
const ACMAMRPackingFormat packingFormat); const ACMAMRPackingFormat packingFormat);
@@ -49,16 +45,13 @@ public:
ACMAMRPackingFormat AMRwbDecoderPackingFormat() const; ACMAMRPackingFormat AMRwbDecoderPackingFormat() const;
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@@ -69,18 +62,15 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
WebRtc_Word16 SetBitRateSafe( WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
const WebRtc_Word32 rate);
WebRtc_Word16 EnableDTX(); WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX(); WebRtc_Word16 DisableDTX();
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
ACMNetEQ* netEq,
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
AMRWB_encinst_t_* _encoderInstPtr; AMRWB_encinst_t_* _encoderInstPtr;
@@ -94,4 +84,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif // ACM_AMRWB_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_

View File

@@ -17,11 +17,9 @@
#include "webrtc_neteq.h" #include "webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.h"
namespace webrtc namespace webrtc {
{
ACMCNG::ACMCNG(WebRtc_Word16 codecID) ACMCNG::ACMCNG(WebRtc_Word16 codecID) {
{
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
_codecID = codecID; _codecID = codecID;
@@ -29,74 +27,52 @@ ACMCNG::ACMCNG(WebRtc_Word16 codecID)
return; return;
} }
ACMCNG::~ACMCNG() {
ACMCNG::~ACMCNG() if (_encoderInstPtr != NULL) {
{
if(_encoderInstPtr != NULL)
{
WebRtcCng_FreeEnc(_encoderInstPtr); WebRtcCng_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
WebRtcCng_FreeDec(_decoderInstPtr); WebRtcCng_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
return; return;
} }
// CNG is not like a regular encoder, this function // CNG is not like a regular encoder, this function
// 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 WebRtc_Word16 ACMCNG::InternalEncode(WebRtc_UWord8* /* bitStream */,
ACMCNG::InternalEncode( WebRtc_Word16* /* bitStreamLenByte */) {
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMCNG::DecodeSafe(WebRtc_UWord8* /* bitStream */,
ACMCNG::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return 0; return 0;
} }
// CNG is not like a regular encoder, // CNG is not like a regular encoder,
// this function should not be called normally // this function 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 WebRtc_Word16 ACMCNG::InternalInitEncoder(
ACMCNG::InternalInitEncoder( WebRtcACMCodecParams* /* codecParams */) {
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMCNG::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMCNG::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return WebRtcCng_InitDec(_decoderInstPtr); return WebRtcCng_InitDec(_decoderInstPtr);
} }
WebRtc_Word32 ACMCNG::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtc_Word32 const CodecInst& codecInst) {
ACMCNG::CodecDef( if (!_decoderInitialized) {
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
// TODO (tlegrand): log error // TODO (tlegrand): log error
return -1; return -1;
} }
@@ -105,46 +81,31 @@ ACMCNG::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 (_sampFreqHz == 8000 || _sampFreqHz == 16000 || _sampFreqHz == 32000) {
{
SET_CODEC_PAR((codecDef), kDecoderCNG, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderCNG, codecInst.pltype,
_decoderInstPtr, _sampFreqHz); _decoderInstPtr, _sampFreqHz);
SET_CNG_FUNCTIONS((codecDef)); SET_CNG_FUNCTIONS((codecDef));
return 0; return 0;
} } else {
else
{
return -1; return -1;
} }
} }
ACMGenericCodec* ACMCNG::CreateInstance(void) {
ACMGenericCodec* ACMCNG::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMCNG::InternalCreateEncoder() {
WebRtc_Word16 if (WebRtcCng_CreateEnc(&_encoderInstPtr) < 0) {
ACMCNG::InternalCreateEncoder()
{
if(WebRtcCng_CreateEnc(&_encoderInstPtr) < 0)
{
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
return -1; return -1;
} } else {
else
{
return 0; return 0;
} }
} }
void ACMCNG::DestructEncoderSafe() {
void if (_encoderInstPtr != NULL) {
ACMCNG::DestructEncoderSafe()
{
if(_encoderInstPtr != NULL)
{
WebRtcCng_FreeEnc(_encoderInstPtr); WebRtcCng_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
@@ -152,27 +113,17 @@ ACMCNG::DestructEncoderSafe()
_encoderInitialized = false; _encoderInitialized = false;
} }
WebRtc_Word16 ACMCNG::InternalCreateDecoder() {
WebRtc_Word16 if (WebRtcCng_CreateDec(&_decoderInstPtr) < 0) {
ACMCNG::InternalCreateDecoder()
{
if(WebRtcCng_CreateDec(&_decoderInstPtr) < 0)
{
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
return -1; return -1;
} } else {
else
{
return 0; return 0;
} }
} }
void ACMCNG::DestructDecoderSafe() {
void if (_decoderInstPtr != NULL) {
ACMCNG::DestructDecoderSafe()
{
if(_decoderInstPtr != NULL)
{
WebRtcCng_FreeDec(_decoderInstPtr); WebRtcCng_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
@@ -180,30 +131,23 @@ ACMCNG::DestructDecoderSafe()
_decoderInitialized = false; _decoderInitialized = false;
} }
void ACMCNG::InternalDestructEncoderInst(void* ptrInst) {
void if (ptrInst != NULL) {
ACMCNG::InternalDestructEncoderInst( WebRtcCng_FreeEnc(static_cast<CNG_enc_inst*>(ptrInst));
void* ptrInst)
{
if(ptrInst != NULL)
{
WebRtcCng_FreeEnc((CNG_enc_inst*)ptrInst);
} }
return; return;
} }
WebRtc_Word16 WebRtc_Word16 ACMCNG::UnregisterFromNetEqSafe(ACMNetEQ* netEq,
ACMCNG::UnregisterFromNetEqSafe( WebRtc_Word16 payloadType) {
ACMNetEQ* netEq, if (payloadType != _decoderParams.codecInstant.pltype) {
WebRtc_Word16 payloadType) WEBRTC_TRACE(
{ webrtc::kTraceError,
if(payloadType != _decoderParams.codecInstant.pltype) webrtc::kTraceAudioCoding,
{ _uniqueID,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, "Cannot unregister codec %s given payload-type %d does not "
"Cannot unregister codec %s given payload-type %d does not match \ "match the stored payload type",
the stored payload type", _decoderParams.codecInstant.plname, payloadType,
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }

View File

@@ -8,47 +8,38 @@
* 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 ACM_CNG_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_
#define ACM_CNG_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
// forward declaration // forward declaration
struct WebRtcCngEncInst; struct WebRtcCngEncInst;
struct WebRtcCngDecInst; struct WebRtcCngDecInst;
namespace webrtc namespace webrtc {
{
class ACMCNG : public ACMGenericCodec class ACMCNG: public ACMGenericCodec {
{ public:
public:
ACMCNG(WebRtc_Word16 codecID); ACMCNG(WebRtc_Word16 codecID);
~ACMCNG(); ~ACMCNG();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@@ -59,21 +50,17 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
WebRtc_Word16 EnableDTX() WebRtc_Word16 EnableDTX() {
{
return -1; return -1;
} }
WebRtc_Word16 DisableDTX() WebRtc_Word16 DisableDTX() {
{
return -1; return -1;
} }
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
ACMNetEQ* netEq,
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
WebRtcCngEncInst* _encoderInstPtr; WebRtcCngEncInst* _encoderInstPtr;
@@ -83,5 +70,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif // ACM_CNG_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_

View File

@@ -8,8 +8,8 @@
* 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_ACM_COMMON_DEFS_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_
#define WEBRTC_ACM_COMMON_DEFS_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_
#include <string.h> #include <string.h>
@@ -18,23 +18,21 @@
#include "engine_configurations.h" #include "engine_configurations.h"
#include "typedefs.h" #include "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.
#if ((defined WEBRTC_CODEC_ISAC) && (defined WEBRTC_CODEC_ISACFX)) #if ((defined WEBRTC_CODEC_ISAC) && (defined WEBRTC_CODEC_ISACFX))
# error iSAC and iSACFX codecs cannot be enabled at the same time #error iSAC and iSACFX codecs cannot be enabled at the same time
#endif #endif
#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 {
{
// 60 ms is the maximum block size we support. An extra 20 ms is considered // 60 ms is the maximum block size we support. An extra 20 ms is considered
// for safety if process() method is not called when it should be, i.e. we // for safety if process() method is not called when it should be, i.e. we
@@ -46,16 +44,16 @@ namespace webrtc
// audio if the sampling frequency is 8000 Hz (80 samples per block). // audio if the sampling frequency is 8000 Hz (80 samples per block).
// Therefore, The size of the buffer where we keep timestamps // Therefore, The size of the buffer where we keep timestamps
// is defined as follows // is defined as follows
#define TIMESTAMP_BUFFER_SIZE_W32 AUDIO_BUFFER_SIZE_W16/80 #define TIMESTAMP_BUFFER_SIZE_W32 (AUDIO_BUFFER_SIZE_W16/80)
// The maximum size of a payload, that is 60 ms of PCM-16 @ 32 kHz stereo // The maximum size of a payload, that is 60 ms of PCM-16 @ 32 kHz stereo
#define MAX_PAYLOAD_SIZE_BYTE 7680 #define MAX_PAYLOAD_SIZE_BYTE 7680
// General codec specific defines // General codec specific defines
#define ISACWB_DEFAULT_RATE 32000 const int kIsacWbDefaultRate = 32000;
#define ISACSWB_DEFAULT_RATE 56000 const int kIsacSwbDefaultRate = 56000;
#define ISACWB_PAC_SIZE 480 const int kIsacPacSize480 = 480;
#define ISACSWB_PAC_SIZE 960 const int kIsacPacSize960 = 960;
// An encoded bit-stream is labeled by one of the following enumerators. // An encoded bit-stream is labeled by one of the following enumerators.
// //
@@ -66,8 +64,7 @@ namespace webrtc
// kPassiveDTXWB : Passive audio frame coded by wide-band CN. // kPassiveDTXWB : Passive audio frame coded by wide-band CN.
// kPassiveDTXSWB : Passive audio frame coded by super-wide-band CN. // kPassiveDTXSWB : Passive audio frame coded by super-wide-band CN.
// //
enum WebRtcACMEncodingType enum WebRtcACMEncodingType {
{
kNoEncoding, kNoEncoding,
kActiveNormalEncoded, kActiveNormalEncoded,
kPassiveNormalEncoded, kPassiveNormalEncoded,
@@ -85,8 +82,7 @@ enum WebRtcACMEncodingType
// enableVAD : set true to enable VAD. // enableVAD : set true to enable VAD.
// vadMode : VAD mode, c.f. audio_coding_module_typedefs.h // vadMode : VAD mode, c.f. audio_coding_module_typedefs.h
// for possible values. // for possible values.
struct WebRtcACMCodecParams struct WebRtcACMCodecParams {
{
CodecInst codecInstant; CodecInst codecInstant;
bool enableDTX; bool enableDTX;
bool enableVAD; bool enableVAD;
@@ -104,8 +100,7 @@ struct WebRtcACMCodecParams
// lastTimestamp : same as ACMGenericCodec::_lastTimestamp // lastTimestamp : same as ACMGenericCodec::_lastTimestamp
// lastInTimestamp : same as AudioCodingModuleImpl::_lastInTimestamp // lastInTimestamp : same as AudioCodingModuleImpl::_lastInTimestamp
// //
struct WebRtcACMAudioBuff struct WebRtcACMAudioBuff {
{
WebRtc_Word16 inAudio[AUDIO_BUFFER_SIZE_W16]; WebRtc_Word16 inAudio[AUDIO_BUFFER_SIZE_W16];
WebRtc_Word16 inAudioIxRead; WebRtc_Word16 inAudioIxRead;
WebRtc_Word16 inAudioIxWrite; WebRtc_Word16 inAudioIxWrite;
@@ -117,4 +112,4 @@ struct WebRtcACMAudioBuff
} // namespace webrtc } // namespace webrtc
#endif #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_

View File

@@ -8,56 +8,36 @@
* 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 "acm_dtmf_detection.h"
#include "audio_coding_module_typedefs.h" #include "audio_coding_module_typedefs.h"
namespace webrtc namespace webrtc {
{
ACMDTMFDetection::ACMDTMFDetection() ACMDTMFDetection::ACMDTMFDetection() {}
{
}
ACMDTMFDetection::~ACMDTMFDetection() {}
ACMDTMFDetection::~ACMDTMFDetection() WebRtc_Word16 ACMDTMFDetection::Enable(ACMCountries /* cpt */) {
{
}
WebRtc_Word16
ACMDTMFDetection::Enable(
ACMCountries /* cpt */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMDTMFDetection::Disable() {
WebRtc_Word16
ACMDTMFDetection::Disable()
{
return -1; return -1;
} }
WebRtc_Word16 ACMDTMFDetection::Detect(
WebRtc_Word16
ACMDTMFDetection::Detect(
const WebRtc_Word16* /* inAudioBuff */, const WebRtc_Word16* /* inAudioBuff */,
const WebRtc_UWord16 /* inBuffLenWord16 */, const WebRtc_UWord16 /* inBuffLenWord16 */,
const WebRtc_Word32 /* inFreqHz */, const WebRtc_Word32 /* inFreqHz */,
bool& /* toneDetected */, bool& /* toneDetected */,
WebRtc_Word16& /* tone */) WebRtc_Word16& /* tone */) {
{
return -1; return -1;
} }
WebRtc_Word16 ACMDTMFDetection::GetVersion(
WebRtc_Word16
ACMDTMFDetection::GetVersion(
WebRtc_Word8* /* version */, WebRtc_Word8* /* version */,
WebRtc_UWord32& /* remainingBufferInBytes */, WebRtc_UWord32& /* remainingBufferInBytes */,
WebRtc_UWord32& /* position */) WebRtc_UWord32& /* position */) {
{
return -1; return -1;
} }

View File

@@ -8,40 +8,36 @@
* 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 ACM_DTMF_DETECTION_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_
#define ACM_DTMF_DETECTION_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_
#include "acm_resampler.h" #include "acm_resampler.h"
#include "audio_coding_module_typedefs.h" #include "audio_coding_module_typedefs.h"
#include "typedefs.h" #include "typedefs.h"
namespace webrtc namespace webrtc {
{
class ACMDTMFDetection class ACMDTMFDetection {
{ public:
public:
ACMDTMFDetection(); ACMDTMFDetection();
~ACMDTMFDetection(); ~ACMDTMFDetection();
WebRtc_Word16 Enable(ACMCountries cpt = ACMDisableCountryDetection); WebRtc_Word16 Enable(ACMCountries cpt = ACMDisableCountryDetection);
WebRtc_Word16 Disable(); WebRtc_Word16 Disable();
WebRtc_Word16 Detect( WebRtc_Word16 Detect(const WebRtc_Word16* inAudioBuff,
const WebRtc_Word16* inAudioBuff,
const WebRtc_UWord16 inBuffLenWord16, const WebRtc_UWord16 inBuffLenWord16,
const WebRtc_Word32 inFreqHz, const WebRtc_Word32 inFreqHz,
bool& toneDetected, bool& toneDetected,
WebRtc_Word16& tone); WebRtc_Word16& tone);
static WebRtc_Word16 GetVersion( static WebRtc_Word16 GetVersion(WebRtc_Word8* version,
WebRtc_Word8* version,
WebRtc_UWord32& remainingBufferInBytes, WebRtc_UWord32& remainingBufferInBytes,
WebRtc_UWord32& position); WebRtc_UWord32& position);
private: private:
ACMResampler _resampler; ACMResampler _resampler;
bool _init; bool _init;
}; };
} // namespace webrtc } // namespace webrtc
#endif // ACM_DTMF_DETECTION_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_

View File

@@ -8,187 +8,125 @@
* 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 "acm_dtmf_playout.h" #include "acm_dtmf_playout.h"
#include "acm_common_defs.h"
#include "acm_neteq.h" #include "acm_neteq.h"
#include "trace.h" #include "trace.h"
#include "webrtc_neteq.h" #include "webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.h"
namespace webrtc namespace webrtc {
{
#ifndef WEBRTC_CODEC_AVT #ifndef WEBRTC_CODEC_AVT
ACMDTMFPlayout::ACMDTMFPlayout( ACMDTMFPlayout::ACMDTMFPlayout(
WebRtc_Word16 /* codecID */) WebRtc_Word16 /* codecID */) {
{
return; return;
} }
ACMDTMFPlayout::~ACMDTMFPlayout() {
ACMDTMFPlayout::~ACMDTMFPlayout()
{
return; return;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalEncode(
WebRtc_Word16
ACMDTMFPlayout::InternalEncode(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) WebRtc_Word16* /* bitStreamLenByte */) {
{
return -1; return -1;
} }
WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMDTMFPlayout::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return -1; return -1;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMDTMFPlayout::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMDTMFPlayout::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word32 ACMDTMFPlayout::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtc_Word32 const CodecInst& /* codecInst */) {
ACMDTMFPlayout::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1; return -1;
} }
ACMGenericCodec* ACMDTMFPlayout::CreateInstance(void) {
ACMGenericCodec*
ACMDTMFPlayout::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalCreateEncoder() {
WebRtc_Word16
ACMDTMFPlayout::InternalCreateEncoder()
{
return -1; return -1;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalCreateDecoder() {
WebRtc_Word16
ACMDTMFPlayout::InternalCreateDecoder()
{
return -1; return -1;
} }
void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptrInst */) {
void
ACMDTMFPlayout::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return; return;
} }
void void ACMDTMFPlayout::DestructEncoderSafe() {
ACMDTMFPlayout::DestructEncoderSafe()
{
return; return;
} }
void void ACMDTMFPlayout::DestructDecoderSafe() {
ACMDTMFPlayout::DestructDecoderSafe()
{
return; return;
} }
WebRtc_Word16 ACMDTMFPlayout::UnregisterFromNetEqSafe(
WebRtc_Word16
ACMDTMFPlayout::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */, ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */) WebRtc_Word16 /* payloadType */) {
{
return -1; return -1;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMDTMFPlayout::ACMDTMFPlayout( ACMDTMFPlayout::ACMDTMFPlayout(WebRtc_Word16 codecID) {
WebRtc_Word16 codecID)
{
_codecID = codecID; _codecID = codecID;
} }
ACMDTMFPlayout::~ACMDTMFPlayout() {
ACMDTMFPlayout::~ACMDTMFPlayout()
{
return; return;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalEncode(
WebRtc_Word16
ACMDTMFPlayout::InternalEncode(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) WebRtc_Word16* /* bitStreamLenByte */) {
{
return 0; return 0;
} }
WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMDTMFPlayout::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return 0; return 0;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMDTMFPlayout::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
// 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 WebRtcACMCodecParams* /* codecParams */) {
ACMDTMFPlayout::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
// 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 const CodecInst& codecInst) {
ACMDTMFPlayout::CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
// 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
@@ -198,66 +136,45 @@ ACMDTMFPlayout::CodecDef(
return 0; return 0;
} }
ACMGenericCodec* ACMDTMFPlayout::CreateInstance(void) {
ACMGenericCodec*
ACMDTMFPlayout::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalCreateEncoder() {
WebRtc_Word16
ACMDTMFPlayout::InternalCreateEncoder()
{
// DTMFPlayout has no instance // DTMFPlayout has no instance
return 0; return 0;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalCreateDecoder() {
WebRtc_Word16
ACMDTMFPlayout::InternalCreateDecoder()
{
// DTMFPlayout has no instance // DTMFPlayout has no instance
return 0; return 0;
} }
void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptrInst */) {
void
ACMDTMFPlayout::InternalDestructEncoderInst(
void* /* ptrInst */)
{
// DTMFPlayout has no instance // DTMFPlayout has no instance
return; return;
} }
void ACMDTMFPlayout::DestructEncoderSafe() {
void
ACMDTMFPlayout::DestructEncoderSafe()
{
// DTMFPlayout has no instance // DTMFPlayout has no instance
return; return;
} }
void void ACMDTMFPlayout::DestructDecoderSafe() {
ACMDTMFPlayout::DestructDecoderSafe()
{
// DTMFPlayout has no instance // DTMFPlayout has no instance
return; return;
} }
WebRtc_Word16 ACMDTMFPlayout::UnregisterFromNetEqSafe(
WebRtc_Word16
ACMDTMFPlayout::UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType) WebRtc_Word16 payloadType) {
{ if (payloadType != _decoderParams.codecInstant.pltype) {
if(payloadType != _decoderParams.codecInstant.pltype) WEBRTC_TRACE(webrtc::kTraceError,
{ webrtc::kTraceAudioCoding,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, _uniqueID,
"Cannot unregister codec %s given payload-type %d does not match \ "Cannot unregister codec %s given payload-type %d does not "
the stored payload type", "match the stored payload type",
_decoderParams.codecInstant.plname, _decoderParams.codecInstant.plname, payloadType,
payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }

View File

@@ -8,42 +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.
*/ */
#ifndef ACM_DTMF_PLAYOUT_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_
#define ACM_DTMF_PLAYOUT_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
namespace webrtc namespace webrtc {
{
class ACMDTMFPlayout : public ACMGenericCodec class ACMDTMFPlayout: public ACMGenericCodec {
{ public:
public:
ACMDTMFPlayout(WebRtc_Word16 codecID); ACMDTMFPlayout(WebRtc_Word16 codecID);
~ACMDTMFPlayout(); ~ACMDTMFPlayout();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@@ -54,15 +46,12 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
ACMNetEQ* netEq,
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
}; };
} // namespace webrtc } // namespace webrtc
#endif // ACM_DTMF_PLAYOUT_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_

View File

@@ -21,131 +21,81 @@ namespace webrtc {
#ifndef WEBRTC_CODEC_G722 #ifndef WEBRTC_CODEC_G722
ACMG722::ACMG722( ACMG722::ACMG722(WebRtc_Word16 /* codecID */) {
WebRtc_Word16 /* codecID */)
{
return; return;
} }
ACMG722::~ACMG722() {
ACMG722::~ACMG722()
{
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 /* lengthSmpl */,
const WebRtc_UWord8 /* audioChannel */) const WebRtc_UWord8 /* audioChannel */) {
{
return -1; return -1;
} }
WebRtc_Word16 ACMG722::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16* /* bitStreamLenByte */) {
ACMG722::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMG722::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return -1; return -1;
} }
WebRtc_Word16 ACMG722::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG722::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMG722::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG722::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtc_Word32 const CodecInst& /* codecInst */) {
ACMG722::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1; return -1;
} }
ACMGenericCodec* ACMG722::CreateInstance(void) {
ACMGenericCodec*
ACMG722::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMG722::InternalCreateEncoder() {
WebRtc_Word16
ACMG722::InternalCreateEncoder()
{
return -1; return -1;
} }
void ACMG722::DestructEncoderSafe() {
void
ACMG722::DestructEncoderSafe()
{
return; return;
} }
WebRtc_Word16 ACMG722::InternalCreateDecoder() {
WebRtc_Word16
ACMG722::InternalCreateDecoder()
{
return -1; return -1;
} }
void ACMG722::DestructDecoderSafe() {
void
ACMG722::DestructDecoderSafe()
{
return; return;
} }
void ACMG722::InternalDestructEncoderInst(void* /* ptrInst */) {
void
ACMG722::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return; return;
} }
WebRtc_Word16 ACMG722::UnregisterFromNetEqSafe(
WebRtc_Word16
ACMG722::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */, ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */) WebRtc_Word16 /* payloadType */) {
{
return -1; return -1;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
// 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
@@ -156,20 +106,16 @@ struct ACMG722DecStr {
G722DecInst* instRight; // instance for right channel in case of stereo G722DecInst* instRight; // instance for right channel in case of stereo
}; };
ACMG722::ACMG722( ACMG722::ACMG722(WebRtc_Word16 codecID) {
WebRtc_Word16 codecID)
{
// Encoder // Encoder
_ptrEncStr = new ACMG722EncStr; _ptrEncStr = new ACMG722EncStr;
if(_ptrEncStr != NULL) if (_ptrEncStr != NULL) {
{
_ptrEncStr->inst = NULL; _ptrEncStr->inst = NULL;
_ptrEncStr->instRight = NULL; _ptrEncStr->instRight = NULL;
} }
// Decoder // Decoder
_ptrDecStr = new ACMG722DecStr; _ptrDecStr = new ACMG722DecStr;
if(_ptrDecStr != NULL) if (_ptrDecStr != NULL) {
{
_ptrDecStr->inst = NULL; _ptrDecStr->inst = NULL;
_ptrDecStr->instRight = NULL; // Not used _ptrDecStr->instRight = NULL; // Not used
} }
@@ -177,127 +123,100 @@ ACMG722::ACMG722(
return; return;
} }
ACMG722::~ACMG722() {
ACMG722::~ACMG722() // Encoder
{ if (_ptrEncStr != NULL) {
if(_ptrEncStr != NULL) if (_ptrEncStr->inst != NULL) {
{
if(_ptrEncStr->inst != NULL)
{
WebRtcG722_FreeEncoder(_ptrEncStr->inst); WebRtcG722_FreeEncoder(_ptrEncStr->inst);
_ptrEncStr->inst = NULL; _ptrEncStr->inst = NULL;
} }
if (_ptrEncStr->instRight != NULL) {
if(_ptrEncStr->instRight != NULL)
{
WebRtcG722_FreeEncoder(_ptrEncStr->instRight); WebRtcG722_FreeEncoder(_ptrEncStr->instRight);
_ptrEncStr->instRight = NULL; _ptrEncStr->instRight = NULL;
} }
delete _ptrEncStr; delete _ptrEncStr;
_ptrEncStr = NULL; _ptrEncStr = NULL;
} }
if(_ptrDecStr != NULL) // Decoder
{ if (_ptrDecStr != NULL) {
if(_ptrDecStr->inst != NULL) if (_ptrDecStr->inst != NULL) {
{
WebRtcG722_FreeDecoder(_ptrDecStr->inst); WebRtcG722_FreeDecoder(_ptrDecStr->inst);
_ptrDecStr->inst = NULL; _ptrDecStr->inst = NULL;
} }
if(_ptrDecStr->instRight != NULL) if (_ptrDecStr->instRight != NULL) {
{
WebRtcG722_FreeDecoder(_ptrDecStr->instRight); WebRtcG722_FreeDecoder(_ptrDecStr->instRight);
_ptrDecStr->instRight = NULL; _ptrDecStr->instRight = NULL;
} }
delete _ptrDecStr; delete _ptrDecStr;
_ptrDecStr = NULL; _ptrDecStr = 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 lengthSmpl,
const WebRtc_UWord8 audioChannel) const WebRtc_UWord8 audioChannel) {
{ return ACMGenericCodec::Add10MsDataSafe((timestamp >> 1), data, lengthSmpl,
return ACMGenericCodec::Add10MsDataSafe((timestamp>>1), data, lengthSmpl,
audioChannel); audioChannel);
} }
WebRtc_Word16 WebRtc_Word16 ACMG722::InternalEncode(WebRtc_UWord8* bitStream,
ACMG722::InternalEncode( WebRtc_Word16* bitStreamLenByte) {
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
// 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 (_noChannels == 2) {
WebRtc_Word16 leftChannel[960]; WebRtc_Word16 leftChannel[960];
WebRtc_Word16 rightChannel[960]; WebRtc_Word16 rightChannel[960];
WebRtc_UWord8 outLeft[480]; WebRtc_UWord8 outLeft[480];
WebRtc_UWord8 outRight[480]; WebRtc_UWord8 outRight[480];
WebRtc_Word16 lenInBytes; WebRtc_Word16 lenInBytes;
for (int i=0, j=0; i<_frameLenSmpl*2; i+=2, j++) { for (int i = 0, j = 0; i < _frameLenSmpl * 2; i += 2, j++) {
leftChannel[j] = _inAudio[_inAudioIxRead+i]; leftChannel[j] = _inAudio[_inAudioIxRead + i];
rightChannel[j] = _inAudio[_inAudioIxRead+i+1]; rightChannel[j] = _inAudio[_inAudioIxRead + i + 1];
} }
lenInBytes = WebRtcG722_Encode(_encoderInstPtr, lenInBytes = WebRtcG722_Encode(_encoderInstPtr, leftChannel, _frameLenSmpl,
leftChannel, _frameLenSmpl, (WebRtc_Word16*)outLeft); (WebRtc_Word16*) outLeft);
lenInBytes += WebRtcG722_Encode(_encoderInstPtrRight, lenInBytes += WebRtcG722_Encode(_encoderInstPtrRight, rightChannel,
rightChannel, _frameLenSmpl, (WebRtc_Word16*)outRight); _frameLenSmpl, (WebRtc_Word16*) outRight);
*bitStreamLenByte = lenInBytes; *bitStreamLenByte = lenInBytes;
// 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 < lenInBytes; i += 2, j++) {
{
bitStream[i] = (outRight[j] & 0xF0) + (outLeft[j] >> 4); bitStream[i] = (outRight[j] & 0xF0) + (outLeft[j] >> 4);
bitStream[i+1] = ((outRight[j] & 0x0F) << 4) + (outLeft[j] & 0x0F); bitStream[i + 1] = ((outRight[j] & 0x0F) << 4) + (outLeft[j] & 0x0F);
} }
} else { } else {
*bitStreamLenByte = WebRtcG722_Encode(_encoderInstPtr, *bitStreamLenByte = WebRtcG722_Encode(_encoderInstPtr,
&_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream); &_inAudio[_inAudioIxRead],
_frameLenSmpl,
(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; _inAudioIxRead += _frameLenSmpl * _noChannels;
return *bitStreamLenByte; return *bitStreamLenByte;
} }
WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMG722::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return 0; return 0;
} }
WebRtc_Word16 ACMG722::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
WebRtc_Word16 if (codecParams->codecInstant.channels == 2) {
ACMG722::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
if(codecParams->codecInstant.channels == 2)
{
// Create codec struct for right channel // Create codec struct for right channel
if (_ptrEncStr->instRight == NULL) if (_ptrEncStr->instRight == NULL) {
{
WebRtcG722_CreateEncoder(&_ptrEncStr->instRight); WebRtcG722_CreateEncoder(&_ptrEncStr->instRight);
if(_ptrEncStr->instRight == NULL) if (_ptrEncStr->instRight == NULL) {
{
return -1; return -1;
} }
} }
_encoderInstPtrRight = (G722EncInst*)_ptrEncStr->instRight; _encoderInstPtrRight = _ptrEncStr->instRight;
if (WebRtcG722_EncoderInit(_encoderInstPtrRight) < 0) if (WebRtcG722_EncoderInit(_encoderInstPtrRight) < 0) {
{
return -1; return -1;
} }
} }
@@ -305,22 +224,14 @@ ACMG722::InternalInitEncoder(
return WebRtcG722_EncoderInit(_encoderInstPtr); return WebRtcG722_EncoderInit(_encoderInstPtr);
} }
WebRtc_Word16 ACMG722::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG722::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return WebRtcG722_DecoderInit(_decoderInstPtr); return WebRtcG722_DecoderInit(_decoderInstPtr);
} }
WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtc_Word32 const CodecInst& codecInst) {
ACMG722::CodecDef( if (!_decoderInitialized) {
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
// TODO: log error // TODO: log error
return -1; return -1;
} }
@@ -328,61 +239,44 @@ ACMG722::CodecDef(
// "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.
SET_CODEC_PAR((codecDef), kDecoderG722, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderG722, codecInst.pltype, _decoderInstPtr,
_decoderInstPtr, 16000); 16000);
SET_G722_FUNCTIONS((codecDef)); SET_G722_FUNCTIONS((codecDef));
return 0; return 0;
} }
ACMGenericCodec* ACMG722::CreateInstance(void) {
ACMGenericCodec*
ACMG722::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMG722::InternalCreateEncoder() {
WebRtc_Word16 if (_ptrEncStr == NULL) {
ACMG722::InternalCreateEncoder()
{
if(_ptrEncStr == 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(&_ptrEncStr->inst);
if(_ptrEncStr->inst == NULL) if (_ptrEncStr->inst == NULL) {
{
return -1; return -1;
} }
_encoderInstPtr = (G722EncInst*)_ptrEncStr->inst; _encoderInstPtr = _ptrEncStr->inst;
return 0; return 0;
} }
void ACMG722::DestructEncoderSafe() {
void if (_ptrEncStr != NULL) {
ACMG722::DestructEncoderSafe() if (_ptrEncStr->inst != NULL) {
{
if(_ptrEncStr != NULL)
{
if(_ptrEncStr->inst != NULL)
{
WebRtcG722_FreeEncoder(_ptrEncStr->inst); WebRtcG722_FreeEncoder(_ptrEncStr->inst);
_ptrEncStr->inst = NULL; _ptrEncStr->inst = NULL;
} }
} }
_encoderExist = false; _encoderExist = false;
_encoderInitialized = false; _encoderInitialized = false;
} }
WebRtc_Word16 WebRtc_Word16 ACMG722::InternalCreateDecoder() {
ACMG722::InternalCreateDecoder() if (_ptrDecStr == NULL) {
{
if(_ptrDecStr == 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
@@ -390,54 +284,40 @@ ACMG722::InternalCreateDecoder()
} }
WebRtcG722_CreateDecoder(&_ptrDecStr->inst); WebRtcG722_CreateDecoder(&_ptrDecStr->inst);
if(_ptrDecStr->inst == NULL) if (_ptrDecStr->inst == NULL) {
{
return -1; return -1;
} }
_decoderInstPtr = (G722DecInst*)_ptrDecStr->inst; _decoderInstPtr = _ptrDecStr->inst;
return 0; return 0;
} }
void void ACMG722::DestructDecoderSafe() {
ACMG722::DestructDecoderSafe()
{
_decoderExist = false; _decoderExist = false;
_decoderInitialized = false; _decoderInitialized = false;
if(_ptrDecStr != NULL) if (_ptrDecStr != NULL) {
{ if (_ptrDecStr->inst != NULL) {
if(_ptrDecStr->inst != NULL)
{
WebRtcG722_FreeDecoder(_ptrDecStr->inst); WebRtcG722_FreeDecoder(_ptrDecStr->inst);
_ptrDecStr->inst = NULL; _ptrDecStr->inst = NULL;
} }
} }
} }
void ACMG722::InternalDestructEncoderInst(void* ptrInst) {
void if (ptrInst != NULL) {
ACMG722::InternalDestructEncoderInst( WebRtcG722_FreeEncoder(static_cast<G722EncInst*>(ptrInst));
void* ptrInst)
{
if(ptrInst != NULL)
{
WebRtcG722_FreeEncoder((G722EncInst*)ptrInst);
} }
return; return;
} }
WebRtc_Word16 ACMG722::UnregisterFromNetEqSafe(ACMNetEQ* netEq,
WebRtc_Word16 WebRtc_Word16 payloadType) {
ACMG722::UnregisterFromNetEqSafe( if (payloadType != _decoderParams.codecInstant.pltype) {
ACMNetEQ* netEq, WEBRTC_TRACE(webrtc::kTraceError,
WebRtc_Word16 payloadType) webrtc::kTraceAudioCoding,
{ _uniqueID,
if(payloadType != _decoderParams.codecInstant.pltype) "Cannot unregister codec %s given payload-type %d does not "
{ "match the stored payload type",
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, _decoderParams.codecInstant.plname, payloadType,
"Cannot unregister codec %s given payload-type %d does not match \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }

View File

@@ -8,8 +8,8 @@
* 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 ACM_G722_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_
#define ACM_G722_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -22,38 +22,30 @@ namespace webrtc {
struct ACMG722EncStr; struct ACMG722EncStr;
struct ACMG722DecStr; struct ACMG722DecStr;
class ACMG722 : public ACMGenericCodec class ACMG722: public ACMGenericCodec {
{ public:
public:
ACMG722(WebRtc_Word16 codecID); ACMG722(WebRtc_Word16 codecID);
~ACMG722(); ~ACMG722();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
WebRtc_Word32 Add10MsDataSafe( WebRtc_Word32 Add10MsDataSafe(const WebRtc_UWord32 timestamp,
const WebRtc_UWord32 timestamp,
const WebRtc_Word16* data, const WebRtc_Word16* data,
const WebRtc_UWord16 lengthSmpl, const WebRtc_UWord16 lengthSmpl,
const WebRtc_UWord8 audioChannel); const WebRtc_UWord8 audioChannel);
@@ -66,11 +58,9 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
ACMNetEQ* netEq,
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
ACMG722EncStr* _ptrEncStr; ACMG722EncStr* _ptrEncStr;
@@ -83,4 +73,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif // ACM_G722_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_

View File

@@ -17,335 +17,259 @@
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.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
// interface file is needed: // interface file is needed:
// //
// /modules/audio_coding/codecs/g7221/main/interface/g7221_interface.h // /modules/audio_coding/codecs/g7221/main/interface/g7221_interface.h
// //
// 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_** encInst);
// int16_t WebRtcG7221_CreateEnc24(G722_1_24_encinst_t_** encInst); // int16_t WebRtcG7221_CreateEnc24(G722_1_24_encinst_t_** encInst);
// int16_t WebRtcG7221_CreateEnc32(G722_1_32_encinst_t_** encInst); // int16_t WebRtcG7221_CreateEnc32(G722_1_32_encinst_t_** encInst);
// int16_t WebRtcG7221_CreateDec16(G722_1_16_decinst_t_** decInst); // int16_t WebRtcG7221_CreateDec16(G722_1_16_decinst_t_** decInst);
// int16_t WebRtcG7221_CreateDec24(G722_1_24_decinst_t_** decInst); // int16_t WebRtcG7221_CreateDec24(G722_1_24_decinst_t_** decInst);
// int16_t WebRtcG7221_CreateDec32(G722_1_32_decinst_t_** decInst); // int16_t WebRtcG7221_CreateDec32(G722_1_32_decinst_t_** decInst);
// //
// int16_t WebRtcG7221_FreeEnc16(G722_1_16_encinst_t_** encInst); // int16_t WebRtcG7221_FreeEnc16(G722_1_16_encinst_t_** encInst);
// int16_t WebRtcG7221_FreeEnc24(G722_1_24_encinst_t_** encInst); // int16_t WebRtcG7221_FreeEnc24(G722_1_24_encinst_t_** encInst);
// int16_t WebRtcG7221_FreeEnc32(G722_1_32_encinst_t_** encInst); // int16_t WebRtcG7221_FreeEnc32(G722_1_32_encinst_t_** encInst);
// int16_t WebRtcG7221_FreeDec16(G722_1_16_decinst_t_** decInst); // int16_t WebRtcG7221_FreeDec16(G722_1_16_decinst_t_** decInst);
// int16_t WebRtcG7221_FreeDec24(G722_1_24_decinst_t_** decInst); // int16_t WebRtcG7221_FreeDec24(G722_1_24_decinst_t_** decInst);
// int16_t WebRtcG7221_FreeDec32(G722_1_32_decinst_t_** decInst); // int16_t WebRtcG7221_FreeDec32(G722_1_32_decinst_t_** decInst);
// //
// int16_t WebRtcG7221_EncoderInit16(G722_1_16_encinst_t_* encInst); // int16_t WebRtcG7221_EncoderInit16(G722_1_16_encinst_t_* encInst);
// int16_t WebRtcG7221_EncoderInit24(G722_1_24_encinst_t_* encInst); // int16_t WebRtcG7221_EncoderInit24(G722_1_24_encinst_t_* encInst);
// int16_t WebRtcG7221_EncoderInit32(G722_1_32_encinst_t_* encInst); // int16_t WebRtcG7221_EncoderInit32(G722_1_32_encinst_t_* encInst);
// int16_t WebRtcG7221_DecoderInit16(G722_1_16_decinst_t_* decInst); // int16_t WebRtcG7221_DecoderInit16(G722_1_16_decinst_t_* decInst);
// int16_t WebRtcG7221_DecoderInit24(G722_1_24_decinst_t_* decInst); // int16_t WebRtcG7221_DecoderInit24(G722_1_24_decinst_t_* decInst);
// int16_t WebRtcG7221_DecoderInit32(G722_1_32_decinst_t_* decInst); // int16_t WebRtcG7221_DecoderInit32(G722_1_32_decinst_t_* decInst);
// //
// int16_t WebRtcG7221_Encode16(G722_1_16_encinst_t_* encInst, // int16_t WebRtcG7221_Encode16(G722_1_16_encinst_t_* encInst,
// 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_* encInst,
// 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_* encInst,
// 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_* decInst,
// 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_* decInst,
// 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_* decInst,
// 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_* decInst,
// int16_t* output, // int16_t* output,
// int16_t nrLostFrames); // int16_t nrLostFrames);
// int16_t WebRtcG7221_DecodePlc24(G722_1_24_decinst_t_* decInst, // int16_t WebRtcG7221_DecodePlc24(G722_1_24_decinst_t_* decInst,
// int16_t* output, // int16_t* output,
// int16_t nrLostFrames); // int16_t nrLostFrames);
// int16_t WebRtcG7221_DecodePlc32(G722_1_32_decinst_t_* decInst, // int16_t WebRtcG7221_DecodePlc32(G722_1_32_decinst_t_* decInst,
// int16_t* output, // int16_t* output,
// int16_t nrLostFrames); // int16_t nrLostFrames);
// void WebRtcG7221_Version(char *versionStr, short len); // void WebRtcG7221_Version(char *versionStr, short len);
#include "g7221_interface.h" #include "g7221_interface.h"
#endif #endif
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_G722_1 #ifndef WEBRTC_CODEC_G722_1
ACMG722_1::ACMG722_1( ACMG722_1::ACMG722_1(WebRtc_Word16 /* codecID */) {
WebRtc_Word16 /* codecID */)
{
return; return;
} }
ACMG722_1::~ACMG722_1() ACMG722_1::~ACMG722_1() {
{
return; return;
} }
WebRtc_Word16 ACMG722_1::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16* /* bitStreamLenByte */) {
ACMG722_1::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
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 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return -1; return -1;
} }
WebRtc_Word16 ACMG722_1::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG722_1::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMG722_1::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG722_1::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word32 ACMG722_1::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtc_Word32 const CodecInst& /* codecInst */) {
ACMG722_1::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1; return -1;
} }
ACMGenericCodec* ACMGenericCodec* ACMG722_1::CreateInstance(void) {
ACMG722_1::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMG722_1::InternalCreateEncoder() {
WebRtc_Word16
ACMG722_1::InternalCreateEncoder()
{
return -1; return -1;
} }
void ACMG722_1::DestructEncoderSafe() {
void
ACMG722_1::DestructEncoderSafe()
{
return; return;
} }
WebRtc_Word16 ACMG722_1::InternalCreateDecoder() {
WebRtc_Word16
ACMG722_1::InternalCreateDecoder()
{
return -1; return -1;
} }
void ACMG722_1::DestructDecoderSafe() {
void
ACMG722_1::DestructDecoderSafe()
{
return; return;
} }
void ACMG722_1::InternalDestructEncoderInst(void* /* ptrInst */) {
void
ACMG722_1::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return; return;
} }
WebRtc_Word16 ACMG722_1::UnregisterFromNetEqSafe(
WebRtc_Word16 ACMNetEQ* /* netEq */, WebRtc_Word16 /* payloadType */) {
ACMG722_1::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */)
{
return -1; return -1;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMG722_1::ACMG722_1( ACMG722_1::ACMG722_1(
WebRtc_Word16 codecID): WebRtc_Word16 codecID):
_encoderInstPtr(NULL), _encoderInstPtr(NULL),
_encoderInstPtrRight(NULL), _encoderInstPtrRight(NULL),
_decoderInstPtr(NULL), _decoderInstPtr(NULL),
_encoderInst16Ptr(NULL), _encoderInst16Ptr(NULL),
_encoderInst16PtrR(NULL), _encoderInst16PtrR(NULL),
_encoderInst24Ptr(NULL), _encoderInst24Ptr(NULL),
_encoderInst24PtrR(NULL), _encoderInst24PtrR(NULL),
_encoderInst32Ptr(NULL), _encoderInst32Ptr(NULL),
_encoderInst32PtrR(NULL), _encoderInst32PtrR(NULL),
_decoderInst16Ptr(NULL), _decoderInst16Ptr(NULL),
_decoderInst24Ptr(NULL), _decoderInst24Ptr(NULL),
_decoderInst32Ptr(NULL) _decoderInst32Ptr(NULL) {
{
_codecID = codecID; _codecID = codecID;
if(_codecID == ACMCodecDB::kG722_1_16) if (_codecID == ACMCodecDB::kG722_1_16) {
{
_operationalRate = 16000; _operationalRate = 16000;
} } else if (_codecID == ACMCodecDB::kG722_1_24) {
else if(_codecID == ACMCodecDB::kG722_1_24)
{
_operationalRate = 24000; _operationalRate = 24000;
} } else if (_codecID == ACMCodecDB::kG722_1_32) {
else if(_codecID == ACMCodecDB::kG722_1_32)
{
_operationalRate = 32000; _operationalRate = 32000;
} } else {
else
{
_operationalRate = -1; _operationalRate = -1;
} }
return; return;
} }
ACMG722_1::~ACMG722_1() ACMG722_1::~ACMG722_1() {
{ if (_encoderInstPtr != NULL) {
if(_encoderInstPtr != NULL)
{
delete _encoderInstPtr; delete _encoderInstPtr;
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
if(_encoderInstPtrRight != NULL) if (_encoderInstPtrRight != NULL) {
{Inst
delete _encoderInstPtrRight; delete _encoderInstPtrRight;
_encoderInstPtrRight = NULL; _encoderInstPtrRight = NULL;
} }
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
delete _decoderInstPtr; delete _decoderInstPtr;
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
switch(_operationalRate) switch (_operationalRate) {
{ case 16000: {
case 16000:
{
_encoderInst16Ptr = NULL; _encoderInst16Ptr = NULL;
_encoderInst16PtrR = NULL; _encoderInst16PtrR = NULL;
_decoderInst16Ptr = NULL; _decoderInst16Ptr = NULL;
break; break;
} }
case 24000: case 24000: {
{
_encoderInst24Ptr = NULL; _encoderInst24Ptr = NULL;
_encoderInst24PtrR = NULL; _encoderInst24PtrR = NULL;
_decoderInst24Ptr = NULL; _decoderInst24Ptr = NULL;
break; break;
} }
case 32000: case 32000: {
{
_encoderInst32Ptr = NULL; _encoderInst32Ptr = NULL;
_encoderInst32PtrR = NULL; _encoderInst32PtrR = NULL;
_decoderInst32Ptr = NULL; _decoderInst32Ptr = NULL;
break; break;
} }
default: default: {
{
break; break;
} }
} }
return; return;
} }
WebRtc_Word16 ACMG722_1::InternalEncode(WebRtc_UWord8* bitStream,
WebRtc_Word16 WebRtc_Word16* bitStreamLenByte) {
ACMG722_1::InternalEncode(
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
WebRtc_Word16 leftChannel[320]; WebRtc_Word16 leftChannel[320];
WebRtc_Word16 rightChannel[320]; WebRtc_Word16 rightChannel[320];
WebRtc_Word16 lenInBytes; WebRtc_Word16 lenInBytes;
WebRtc_Word16 outB[160]; WebRtc_Word16 outB[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 (_noChannels == 2) {
{ for (int i = 0, j = 0; i < _frameLenSmpl * 2; i += 2, j++) {
for (int i=0, j=0; i<_frameLenSmpl*2; i+=2, j++) { leftChannel[j] = _inAudio[_inAudioIxRead + i];
leftChannel[j] = _inAudio[_inAudioIxRead+i]; rightChannel[j] = _inAudio[_inAudioIxRead + i + 1];
rightChannel[j] = _inAudio[_inAudioIxRead+i+1];
} }
} else { } else {
memcpy(leftChannel, &_inAudio[_inAudioIxRead], 320); memcpy(leftChannel, &_inAudio[_inAudioIxRead], 320);
} }
switch(_operationalRate) switch (_operationalRate) {
{ case 16000: {
case 16000: Inst lenInBytes = WebRtcG7221_Encode16(_encoderInst16Ptr, leftChannel,
{Inst 320, &outB[0]);
lenInBytes = WebRtcG7221_Encode16(_encoderInst16Ptr, if (_noChannels == 2) {
leftChannel, 320, &outB[0]); lenInBytes += WebRtcG7221_Encode16(_encoderInst16PtrR, rightChannel,
if (_noChannels == 2) 320, &outB[lenInBytes / 2]);
{
lenInBytes += WebRtcG7221_Encode16(_encoderInst16PtrR,
rightChannel, 320, &outB[lenInBytes/2]);
} }
break; break;
} }
case 24000: case 24000: {
{ lenInBytes = WebRtcG7221_Encode24(_encoderInst24Ptr, leftChannel, 320,
lenInBytes = WebRtcG7221_Encode24(_encoderInst24Ptr, &outB[0]);
leftChannel, 320, &outB[0]); if (_noChannels == 2) {
if (_noChannels == 2) lenInBytes += WebRtcG7221_Encode24(_encoderInst24PtrR, rightChannel,
{ 320, &outB[lenInBytes / 2]);
lenInBytes += WebRtcG7221_Encode24(_encoderInst24PtrR,
rightChannel, 320, &outB[lenInBytes/2]);
} }
break; break;
} }
case 32000: case 32000: {
{ lenInBytes = WebRtcG7221_Encode32(_encoderInst32Ptr, leftChannel, 320,
lenInBytes = WebRtcG7221_Encode32(_encoderInst32Ptr, &outB[0]);
leftChannel, 320, &outB[0]); if (_noChannels == 2) {
if (_noChannels == 2) lenInBytes += WebRtcG7221_Encode32(_encoderInst32PtrR, rightChannel,
{ 320, &outB[lenInBytes / 2]);
lenInBytes += WebRtcG7221_Encode32(_encoderInst32PtrR,
rightChannel, 320, &outB[lenInBytes/2]);
} }
break; break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitEncode: Wrong rate for G722_1."); "InternalInitEncode: Wrong rate for G722_1.");
return -1; return -1;
break;
} }
} }
memcpy(bitStream, outB, lenInBytes); memcpy(bitStream, outB, lenInBytes);
@@ -353,212 +277,156 @@ ACMG722_1::InternalEncode(
// 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; _inAudioIxRead += 320 * _noChannels;
return *bitStreamLenByte; return *bitStreamLenByte;
} }
WebRtc_Word16 ACMG722_1::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMG722_1::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return 0; return 0;
} }
WebRtc_Word16 ACMG722_1::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* codecParams) {
ACMG722_1::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
WebRtc_Word16 ret; WebRtc_Word16 ret;
switch(_operationalRate) switch (_operationalRate) {
{ case 16000: {
case 16000:
{
ret = WebRtcG7221_EncoderInit16(_encoderInst16PtrR); ret = WebRtcG7221_EncoderInit16(_encoderInst16PtrR);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
return WebRtcG7221_EncoderInit16(_encoderInst16Ptr); return WebRtcG7221_EncoderInit16(_encoderInst16Ptr);
break;
} }
case 24000: case 24000: {
{
ret = WebRtcG7221_EncoderInit24(_encoderInst24PtrR); ret = WebRtcG7221_EncoderInit24(_encoderInst24PtrR);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
return WebRtcG7221_EncoderInit24(_encoderInst24Ptr); return WebRtcG7221_EncoderInit24(_encoderInst24Ptr);
break;
} }
case 32000: case 32000: {
{
ret = WebRtcG7221_EncoderInit32(_encoderInst32PtrR); ret = WebRtcG7221_EncoderInit32(_encoderInst32PtrR);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
return WebRtcG7221_EncoderInit32(_encoderInst32Ptr); return WebRtcG7221_EncoderInit32(_encoderInst32Ptr);
break;
} }
default: default: {
{ WEBRTC_TRACE(webrtc::kTraceError,Inst webrtc::kTraceAudioCoding,
WEBRTC_TRACE(webrtc::kTraceError,Inst webrtc::kTraceAudioCoding, _uniqueID, _uniqueID, "InternalInitEncoder: Wrong rate for G722_1.");
"InternalInitEncoder: Wrong rate for G722_1.");
return -1; return -1;
break;
} }
} }
} }
WebRtc_Word16 ACMG722_1::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG722_1::InternalInitDecoder( switch (_operationalRate) {
WebRtcACMCodecParams* /* codecParams */) case 16000: {
{
switch(_operationalRate)
{
case 16000:
{
return WebRtcG7221_DecoderInit16(_decoderInst16Ptr); return WebRtcG7221_DecoderInit16(_decoderInst16Ptr);
break;
} }
case 24000: case 24000: {
{
return WebRtcG7221_DecoderInit24(_decoderInst24Ptr); return WebRtcG7221_DecoderInit24(_decoderInst24Ptr);
break;
} }
case 32000: case 32000: {
{
return WebRtcG7221_DecoderInit32(_decoderInst32Ptr); return WebRtcG7221_DecoderInit32(_decoderInst32Ptr);
break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: Wrong rate for G722_1."); "InternalInitDecoder: Wrong rate for G722_1.");
return -1; return -1;
break;
} }
} }
} }
WebRtc_Word32 ACMG722_1::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtc_Word32 const CodecInst& codecInst) {
ACMG722_1::CodecDef( if (!_decoderInitialized) {
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
// Todo: // Todo:
// log error // log error
return -1; return -1;
} }
// NetEq has an array of pointers to WebRtcNetEQ_CodecDef. // NetEq has an array of pointers to WebRtcNetEQ_CodecDef.
// get an entry of that array (neteq wrapper will allocate memory) // Get an entry of that array (neteq wrapper will allocate memory)
// by calling "netEq->CodecDef", where "NETEQ_CODEC_G722_1_XX" would // by calling "netEq->CodecDef", where "NETEQ_CODEC_G722_1_XX" would
// be the index of the entry. // be the index of the entry.
// Fill up the given structure by calling // Fill up the given structure by calling
// "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 (_operationalRate) {
{ case 16000: {
case 16000:
{
SET_CODEC_PAR((codecDef), kDecoderG722_1_16, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderG722_1_16, codecInst.pltype,
_decoderInst16Ptr, 16000); _decoderInst16Ptr, 16000);
SET_G722_1_16_FUNCTIONS((codecDef)); SET_G722_1_16_FUNCTIONS((codecDef));
break; break;
} }
case 24000: case 24000: {
{
SET_CODEC_PAR((codecDef), kDecoderG722_1_24, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderG722_1_24, codecInst.pltype,
_decoderInst24Ptr, 16000); _decoderInst24Ptr, 16000);
SET_G722_1_24_FUNCTIONS((codecDef)); SET_G722_1_24_FUNCTIONS((codecDef));
break; break;
} }
case 32000: case 32000: {
{
SET_CODEC_PAR((codecDef), kDecoderG722_1_32, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderG722_1_32, codecInst.pltype,
_decoderInst32Ptr, 16000); _decoderInst32Ptr, 16000);
SET_G722_1_32_FUNCTIONS((codecDef)); SET_G722_1_32_FUNCTIONS((codecDef));
break; break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodecDef: Wrong rate for G722_1."); "CodecDef: Wrong rate for G722_1.");
return -1; return -1;
break;
} }
} }
return 0; return 0;
} }
ACMGenericCodec* ACMGenericCodec* ACMG722_1::CreateInstance(void) {
ACMG722_1::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMG722_1::InternalCreateEncoder() {
WebRtc_Word16 if ((_encoderInstPtr == NULL) || (_encoderInstPtrRight == NULL)) {
ACMG722_1::InternalCreateEncoder()
{
if((_encoderInstPtr == NULL) || (_encoderInstPtrRight == NULL))
{
return -1; return -1;
} }
switch(_operationalRate) switch (_operationalRate) {
{ case 16000: {
case 16000:
{
WebRtcG7221_CreateEnc16(&_encoderInst16Ptr); WebRtcG7221_CreateEnc16(&_encoderInst16Ptr);
WebRtcG7221_CreateEnc16(&_encoderInst16PtrR); WebRtcG7221_CreateEnc16(&_encoderInst16PtrR);
break; break;
} }
case 24000: case 24000: {
{
WebRtcG7221_CreateEnc24(&_encoderInst24Ptr); WebRtcG7221_CreateEnc24(&_encoderInst24Ptr);
WebRtcG7221_CreateEnc24(&_encoderInst24PtrR); WebRtcG7221_CreateEnc24(&_encoderInst24PtrR);
break; break;
} }
case 32000: case 32000: {
{
WebRtcG7221_CreateEnc32(&_encoderInst32Ptr); WebRtcG7221_CreateEnc32(&_encoderInst32Ptr);
WebRtcG7221_CreateEnc32(&_encoderInst32PtrR); WebRtcG7221_CreateEnc32(&_encoderInst32PtrR);
break; break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: Wrong rate for G722_1."); "InternalCreateEncoder: Wrong rate for G722_1.");
return -1; return -1;
break;
} }
} }
return 0; return 0;
} }
void ACMG722_1::DestructEncoderSafe() {
void
ACMG722_1::DestructEncoderSafe()
{
_encoderExist = false; _encoderExist = false;
_encoderInitialized = false; _encoderInitialized = false;
if(_encoderInstPtr != NULL) if (_encoderInstPtr != NULL) {
{
delete _encoderInstPtr; delete _encoderInstPtr;
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
if(_encoderInstPtrRight != NULL) if (_encoderInstPtrRight != NULL) {
{
delete _encoderInstPtrRight; delete _encoderInstPtrRight;
_encoderInstPtrRight = NULL; _encoderInstPtrRight = NULL;
} }
@@ -567,50 +435,36 @@ ACMG722_1::DestructEncoderSafe()
_encoderInst32Ptr = NULL; _encoderInst32Ptr = NULL;
} }
WebRtc_Word16 ACMG722_1::InternalCreateDecoder() {
WebRtc_Word16 if (_decoderInstPtr == NULL) {
ACMG722_1::InternalCreateDecoder()
{
if(_decoderInstPtr == NULL)
{
return -1; return -1;
} }
switch(_operationalRate) switch (_operationalRate) {
{ case 16000: {
case 16000:
{
WebRtcG7221_CreateDec16(&_decoderInst16Ptr); WebRtcG7221_CreateDec16(&_decoderInst16Ptr);
break; break;
} }
case 24000: case 24000: {
{
WebRtcG7221_CreateDec24(&_decoderInst24Ptr); WebRtcG7221_CreateDec24(&_decoderInst24Ptr);
break; break;
} }
case 32000: case 32000: {
{
WebRtcG7221_CreateDec32(&_decoderInst32Ptr); WebRtcG7221_CreateDec32(&_decoderInst32Ptr);
break; break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: Wrong rate for G722_1."); "InternalCreateDecoder: Wrong rate for G722_1.");
return -1; return -1;
break;
} }
} }
return 0; return 0;
} }
void ACMG722_1::DestructDecoderSafe() {
void
ACMG722_1::DestructDecoderSafe()
{
_decoderExist = false; _decoderExist = false;
_decoderInitialized = false; _decoderInitialized = false;
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
delete _decoderInstPtr; delete _decoderInstPtr;
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
@@ -619,50 +473,36 @@ ACMG722_1::DestructDecoderSafe()
_decoderInst32Ptr = NULL; _decoderInst32Ptr = NULL;
} }
void ACMG722_1::InternalDestructEncoderInst(void* ptrInst) {
void if (ptrInst != NULL) {
ACMG722_1::InternalDestructEncoderInst(
void* ptrInst)
{
if(ptrInst != NULL)
{
delete ptrInst; delete ptrInst;
} }
return; return;
} }
WebRtc_Word16 ACMG722_1::UnregisterFromNetEqSafe(ACMNetEQ* netEq,
WebRtc_Word16 WebRtc_Word16 payloadType) {
ACMG722_1::UnregisterFromNetEqSafe( if (payloadType != _decoderParams.codecInstant.pltype) {
ACMNetEQ* netEq, WEBRTC_TRACE(webrtc::kTraceError,
WebRtc_Word16 payloadType) webrtc::kTraceAudioCoding,
{ _uniqueID,
if(payloadType != _decoderParams.codecInstant.pltype) "Cannot unregister codec %s given payload-type %d does not "
{ "match the stored payload type",
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, _decoderParams.codecInstant.plname, payloadType,
"Cannot unregister codec %s given payload-type %d does not match \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }
switch(_operationalRate) switch (_operationalRate) {
{ case 16000: {
case 16000:
{
return netEq->RemoveCodec(kDecoderG722_1_16); return netEq->RemoveCodec(kDecoderG722_1_16);
} }
case 24000: case 24000: {
{
return netEq->RemoveCodec(kDecoderG722_1_24); return netEq->RemoveCodec(kDecoderG722_1_24);
} }
case 32000: case 32000: {
{
return netEq->RemoveCodec(kDecoderG722_1_32); return netEq->RemoveCodec(kDecoderG722_1_32);
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"UnregisterFromNetEqSafe: Wrong rate for G722_1."); "UnregisterFromNetEqSafe: Wrong rate for G722_1.");
return -1; return -1;

View File

@@ -8,8 +8,8 @@
* 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 ACM_G722_1_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_
#define ACM_G722_1_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -24,34 +24,27 @@ struct G722_1_Inst_t_;
namespace webrtc { namespace webrtc {
class ACMG722_1 : public ACMGenericCodec class ACMG722_1: public ACMGenericCodec {
{ public:
public:
ACMG722_1(WebRtc_Word16 codecID); ACMG722_1(WebRtc_Word16 codecID);
~ACMG722_1(); ~ACMG722_1();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@@ -62,11 +55,9 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
ACMNetEQ* netEq,
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
WebRtc_Word32 _operationalRate; WebRtc_Word32 _operationalRate;
@@ -91,4 +82,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif // ACM_G722_1_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_

View File

@@ -17,71 +17,71 @@
#include "trace.h" #include "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
// interface file is needed: // interface file is needed:
// //
// /modules/audio_coding/codecs/g7221c/main/interface/g7221c_interface.h // /modules/audio_coding/codecs/g7221c/main/interface/g7221c_interface.h
// //
// 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_CreateEnc24(G722_1C_24_encinst_t_** encInst);
// int16_t WebRtcG7221C_CreateEnc32(G722_1C_32_encinst_t_** encInst); // int16_t WebRtcG7221C_CreateEnc32(G722_1C_32_encinst_t_** encInst);
// int16_t WebRtcG7221C_CreateEnc48(G722_1C_48_encinst_t_** encInst); // int16_t WebRtcG7221C_CreateEnc48(G722_1C_48_encinst_t_** encInst);
// int16_t WebRtcG7221C_CreateDec24(G722_1C_24_decinst_t_** decInst); // int16_t WebRtcG7221C_CreateDec24(G722_1C_24_decinst_t_** decInst);
// int16_t WebRtcG7221C_CreateDec32(G722_1C_32_decinst_t_** decInst); // int16_t WebRtcG7221C_CreateDec32(G722_1C_32_decinst_t_** decInst);
// int16_t WebRtcG7221C_CreateDec48(G722_1C_48_decinst_t_** decInst); // int16_t WebRtcG7221C_CreateDec48(G722_1C_48_decinst_t_** decInst);
// //
// int16_t WebRtcG7221C_FreeEnc24(G722_1C_24_encinst_t_** encInst); // int16_t WebRtcG7221C_FreeEnc24(G722_1C_24_encinst_t_** encInst);
// int16_t WebRtcG7221C_FreeEnc32(G722_1C_32_encinst_t_** encInst); // int16_t WebRtcG7221C_FreeEnc32(G722_1C_32_encinst_t_** encInst);
// int16_t WebRtcG7221C_FreeEnc48(G722_1C_48_encinst_t_** encInst); // int16_t WebRtcG7221C_FreeEnc48(G722_1C_48_encinst_t_** encInst);
// int16_t WebRtcG7221C_FreeDec24(G722_1C_24_decinst_t_** decInst); // int16_t WebRtcG7221C_FreeDec24(G722_1C_24_decinst_t_** decInst);
// int16_t WebRtcG7221C_FreeDec32(G722_1C_32_decinst_t_** decInst); // int16_t WebRtcG7221C_FreeDec32(G722_1C_32_decinst_t_** decInst);
// int16_t WebRtcG7221C_FreeDec48(G722_1C_48_decinst_t_** decInst); // int16_t WebRtcG7221C_FreeDec48(G722_1C_48_decinst_t_** decInst);
// //
// int16_t WebRtcG7221C_EncoderInit24(G722_1C_24_encinst_t_* encInst); // int16_t WebRtcG7221C_EncoderInit24(G722_1C_24_encinst_t_* encInst);
// int16_t WebRtcG7221C_EncoderInit32(G722_1C_32_encinst_t_* encInst); // int16_t WebRtcG7221C_EncoderInit32(G722_1C_32_encinst_t_* encInst);
// int16_t WebRtcG7221C_EncoderInit48(G722_1C_48_encinst_t_* encInst); // int16_t WebRtcG7221C_EncoderInit48(G722_1C_48_encinst_t_* encInst);
// int16_t WebRtcG7221C_DecoderInit24(G722_1C_24_decinst_t_* decInst); // int16_t WebRtcG7221C_DecoderInit24(G722_1C_24_decinst_t_* decInst);
// int16_t WebRtcG7221C_DecoderInit32(G722_1C_32_decinst_t_* decInst); // int16_t WebRtcG7221C_DecoderInit32(G722_1C_32_decinst_t_* decInst);
// int16_t WebRtcG7221C_DecoderInit48(G722_1C_48_decinst_t_* decInst); // int16_t WebRtcG7221C_DecoderInit48(G722_1C_48_decinst_t_* decInst);
// //
// int16_t WebRtcG7221C_Encode24(G722_1C_24_encinst_t_* encInst, // int16_t WebRtcG7221C_Encode24(G722_1C_24_encinst_t_* encInst,
// 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_* encInst,
// 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_* encInst,
// 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_* decInst,
// 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_* decInst,
// 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_* decInst,
// 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_* decInst,
// int16_t* output, // int16_t* output,
// int16_t nrLostFrames); // int16_t nrLostFrames);
// int16_t WebRtcG7221C_DecodePlc32(G722_1C_32_decinst_t_* decInst, // int16_t WebRtcG7221C_DecodePlc32(G722_1C_32_decinst_t_* decInst,
// int16_t* output, // int16_t* output,
// int16_t nrLostFrames); // int16_t nrLostFrames);
// int16_t WebRtcG7221C_DecodePlc48(G722_1C_48_decinst_t_* decInst, // int16_t WebRtcG7221C_DecodePlc48(G722_1C_48_decinst_t_* decInst,
// int16_t* output, // int16_t* output,
// int16_t nrLostFrames); // int16_t nrLostFrames);
// void WebRtcG7221C_Version(char *versionStr, short len); // void WebRtcG7221C_Version(char *versionStr, short len);
#include "g7221c_interface.h" #include "g7221c_interface.h"
#endif #endif
namespace webrtc { namespace webrtc {
@@ -89,197 +89,128 @@ namespace webrtc {
#ifndef WEBRTC_CODEC_G722_1C #ifndef WEBRTC_CODEC_G722_1C
ACMG722_1C::ACMG722_1C( ACMG722_1C::ACMG722_1C(
WebRtc_Word16 /* codecID */) WebRtc_Word16 /* codecID */) {
{
return; return;
} }
ACMG722_1C::~ACMG722_1C() ACMG722_1C::~ACMG722_1C() {
{
return; return;
} }
WebRtc_Word16 ACMG722_1C::InternalEncode(
WebRtc_Word16
ACMG722_1C::InternalEncode(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) WebRtc_Word16* /* bitStreamLenByte */) {
{
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 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return -1; return -1;
} }
WebRtc_Word16 ACMG722_1C::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG722_1C::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMG722_1C::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG722_1C::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtc_Word32 const CodecInst& /* codecInst */) {
ACMG722_1C::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1; return -1;
} }
ACMGenericCodec* ACMGenericCodec* ACMG722_1C::CreateInstance(void) {
ACMG722_1C::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMG722_1C::InternalCreateEncoder() {
WebRtc_Word16
ACMG722_1C::InternalCreateEncoder()
{
return -1; return -1;
} }
void ACMG722_1C::DestructEncoderSafe() {
void
ACMG722_1C::DestructEncoderSafe()
{
return; return;
} }
WebRtc_Word16 ACMG722_1C::InternalCreateDecoder() {
WebRtc_Word16
ACMG722_1C::InternalCreateDecoder()
{
return -1; return -1;
} }
void ACMG722_1C::DestructDecoderSafe() {
void
ACMG722_1C::DestructDecoderSafe()
{
return; return;
} }
void ACMG722_1C::InternalDestructEncoderInst(void* /* ptrInst */) {
void
ACMG722_1C::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return; return;
} }
WebRtc_Word16 ACMG722_1C::UnregisterFromNetEqSafe(
WebRtc_Word16
ACMG722_1C::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */, ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */) WebRtc_Word16 /* payloadType */) {
{
return -1; return -1;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMG722_1C::ACMG722_1C(WebRtc_Word16 codecID) :
ACMG722_1C::ACMG722_1C( _encoderInstPtr(NULL), _encoderInstPtrRight(NULL), _decoderInstPtr(NULL),
WebRtc_Word16 codecID): _encoderInst24Ptr(NULL), _encoderInst24PtrR(NULL), _encoderInst32Ptr(NULL),
_encoderInstPtr(NULL), _encoderInst32PtrR(NULL), _encoderInst48Ptr(NULL), _encoderInst48PtrR(NULL),
_encoderInstPtrRight(NULL), _decoderInst24Ptr(NULL), _decoderInst32Ptr(NULL), _decoderInst48Ptr(NULL) {
_decoderInstPtr(NULL),
_encoderInst24Ptr(NULL),
_encoderInst24PtrR(NULL),
_encoderInst32Ptr(NULL),
_encoderInst32PtrR(NULL),
_encoderInst48Ptr(NULL),
_encoderInst48PtrR(NULL),
_decoderInst24Ptr(NULL),
_decoderInst32Ptr(NULL),
_decoderInst48Ptr(NULL)
{
_codecID = codecID; _codecID = codecID;
if(_codecID == ACMCodecDB::kG722_1C_24) if (_codecID == ACMCodecDB::kG722_1C_24) {
{
_operationalRate = 24000; _operationalRate = 24000;
} } else if (_codecID == ACMCodecDB::kG722_1C_32) {
else if(_codecID == ACMCodecDB::kG722_1C_32)
{
_operationalRate = 32000; _operationalRate = 32000;
} } else if (_codecID == ACMCodecDB::kG722_1C_48) {
else if(_codecID == ACMCodecDB::kG722_1C_48)
{
_operationalRate = 48000; _operationalRate = 48000;
} } else {
else
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Wrong codec id for G722_1c."); "Wrong codec id for G722_1c.");
_operationalRate = -1; _operationalRate = -1;
} }
return; return;
} }
ACMG722_1C::~ACMG722_1C() ACMG722_1C::~ACMG722_1C() {
{ if (_encoderInstPtr != NULL) {
if(_encoderInstPtr != NULL)
{
delete _encoderInstPtr; delete _encoderInstPtr;
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
if(_encoderInstPtrRight != NULL) if (_encoderInstPtrRight != NULL) {
{
delete _encoderInstPtrRight; delete _encoderInstPtrRight;
_encoderInstPtrRight = NULL; _encoderInstPtrRight = NULL;
} }
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
delete _decoderInstPtr; delete _decoderInstPtr;
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
switch(_operationalRate) switch (_operationalRate) {
{ case 24000: {
case 24000:
{
_encoderInst24Ptr = NULL; _encoderInst24Ptr = NULL;
_encoderInst24PtrR = NULL; _encoderInst24PtrR = NULL;
_decoderInst24Ptr = NULL; _decoderInst24Ptr = NULL;
break; break;
} }
case 32000: case 32000: {
{
_encoderInst32Ptr = NULL; _encoderInst32Ptr = NULL;
_encoderInst32PtrR = NULL; _encoderInst32PtrR = NULL;
_decoderInst32Ptr = NULL; _decoderInst32Ptr = NULL;
break; break;
} }
case 48000: case 48000: {
{
_encoderInst48Ptr = NULL; _encoderInst48Ptr = NULL;
_encoderInst48PtrR = NULL; _encoderInst48PtrR = NULL;
_decoderInst48Ptr = NULL; _decoderInst48Ptr = NULL;
break; break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Wrong rate for G722_1c."); "Wrong rate for G722_1c.");
break; break;
@@ -288,69 +219,55 @@ ACMG722_1C::~ACMG722_1C()
return; return;
} }
WebRtc_Word16 ACMG722_1C::InternalEncode(WebRtc_UWord8* bitStream,
WebRtc_Word16 WebRtc_Word16* bitStreamLenByte) {
ACMG722_1C::InternalEncode(
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
WebRtc_Word16 leftChannel[640]; WebRtc_Word16 leftChannel[640];
WebRtc_Word16 rightChannel[640]; WebRtc_Word16 rightChannel[640];
WebRtc_Word16 lenInBytes; WebRtc_Word16 lenInBytes;
WebRtc_Word16 outB[240]; WebRtc_Word16 outB[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 (_noChannels == 2) {
{ for (int i = 0, j = 0; i < _frameLenSmpl * 2; i += 2, j++) {
for (int i=0, j=0; i<_frameLenSmpl*2; i+=2, j++) { leftChannel[j] = _inAudio[_inAudioIxRead + i];
leftChannel[j] = _inAudio[_inAudioIxRead+i]; rightChannel[j] = _inAudio[_inAudioIxRead + i + 1];
rightChannel[j] = _inAudio[_inAudioIxRead+i+1];
} }
} else { } else {
memcpy(leftChannel, &_inAudio[_inAudioIxRead], 640); memcpy(leftChannel, &_inAudio[_inAudioIxRead], 640);
} }
switch(_operationalRate) switch (_operationalRate) {
{ case 24000: {
case 24000: lenInBytes = WebRtcG7221C_Encode24(_encoderInst24Ptr, leftChannel, 640,
{ &outB[0]);
lenInBytes = WebRtcG7221C_Encode24(_encoderInst24Ptr, if (_noChannels == 2) {
leftChannel, 640, &outB[0]); lenInBytes += WebRtcG7221C_Encode24(_encoderInst24PtrR, rightChannel,
if (_noChannels == 2) 640, &outB[lenInBytes / 2]);
{
lenInBytes += WebRtcG7221C_Encode24(_encoderInst24PtrR,
rightChannel, 640, &outB[lenInBytes/2]);
} }
break; break;
} }
case 32000: case 32000: {
{ lenInBytes = WebRtcG7221C_Encode32(_encoderInst32Ptr, leftChannel, 640,
lenInBytes = WebRtcG7221C_Encode32(_encoderInst32Ptr, &outB[0]);
leftChannel, 640, &outB[0]); if (_noChannels == 2) {
if (_noChannels == 2) lenInBytes += WebRtcG7221C_Encode32(_encoderInst32PtrR, rightChannel,
{ 640, &outB[lenInBytes / 2]);
lenInBytes += WebRtcG7221C_Encode32(_encoderInst32PtrR,
rightChannel, 640, &outB[lenInBytes/2]);
} }
break; break;
} }
case 48000: case 48000: {
{ lenInBytes = WebRtcG7221C_Encode48(_encoderInst48Ptr, leftChannel, 640,
lenInBytes = WebRtcG7221C_Encode48(_encoderInst48Ptr, &outB[0]);
leftChannel, 640, &outB[0]); if (_noChannels == 2) {
if (_noChannels == 2) lenInBytes += WebRtcG7221C_Encode48(_encoderInst48PtrR, rightChannel,
{ 640, &outB[lenInBytes / 2]);
lenInBytes += WebRtcG7221C_Encode48(_encoderInst48PtrR,
rightChannel, 640, &outB[lenInBytes/2]);
} }
break; break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: Wrong rate for G722_1c."); "InternalEncode: Wrong rate for G722_1c.");
return -1; return -1;
break;
} }
} }
@@ -359,109 +276,77 @@ ACMG722_1C::InternalEncode(
// 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; _inAudioIxRead += 640 * _noChannels;
return *bitStreamLenByte; return *bitStreamLenByte;
} }
WebRtc_Word16 ACMG722_1C::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMG722_1C::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return 0; return 0;
} }
WebRtc_Word16 WebRtc_Word16 ACMG722_1C::InternalInitEncoder(
ACMG722_1C::InternalInitEncoder( WebRtcACMCodecParams* codecParams) {
WebRtcACMCodecParams* codecParams)
{
WebRtc_Word16 ret; WebRtc_Word16 ret;
switch(_operationalRate) switch (_operationalRate) {
{ case 24000: {
case 24000:
{
ret = WebRtcG7221C_EncoderInit24(_encoderInst24PtrR); ret = WebRtcG7221C_EncoderInit24(_encoderInst24PtrR);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
return WebRtcG7221C_EncoderInit24(_encoderInst24Ptr); return WebRtcG7221C_EncoderInit24(_encoderInst24Ptr);
break;
} }
case 32000: case 32000: {
{
ret = WebRtcG7221C_EncoderInit32(_encoderInst32PtrR); ret = WebRtcG7221C_EncoderInit32(_encoderInst32PtrR);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
return WebRtcG7221C_EncoderInit32(_encoderInst32Ptr); return WebRtcG7221C_EncoderInit32(_encoderInst32Ptr);
break;
} }
case 48000: case 48000: {
{
ret = WebRtcG7221C_EncoderInit48(_encoderInst48PtrR); ret = WebRtcG7221C_EncoderInit48(_encoderInst48PtrR);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
return WebRtcG7221C_EncoderInit48(_encoderInst48Ptr); return WebRtcG7221C_EncoderInit48(_encoderInst48Ptr);
break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitEncode: Wrong rate for G722_1c."); "InternalInitEncode: Wrong rate for G722_1c.");
return -1; return -1;
break;
} }
} }
} }
WebRtc_Word16 ACMG722_1C::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG722_1C::InternalInitDecoder( switch (_operationalRate) {
WebRtcACMCodecParams* /* codecParams */) case 24000: {
{
switch(_operationalRate)
{
case 24000:
{
return WebRtcG7221C_DecoderInit24(_decoderInst24Ptr); return WebRtcG7221C_DecoderInit24(_decoderInst24Ptr);
break;
} }
case 32000: case 32000: {
{
return WebRtcG7221C_DecoderInit32(_decoderInst32Ptr); return WebRtcG7221C_DecoderInit32(_decoderInst32Ptr);
break;
} }
case 48000: case 48000: {
{
return WebRtcG7221C_DecoderInit48(_decoderInst48Ptr); return WebRtcG7221C_DecoderInit48(_decoderInst48Ptr);
break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: Wrong rate for G722_1c."); "InternalInitDecoder: Wrong rate for G722_1c.");
return -1; return -1;
break;
} }
} }
} }
WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) {
WebRtc_Word32 if (!_decoderInitialized) {
ACMG722_1C::CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, 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;
@@ -474,98 +359,76 @@ ACMG722_1C::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 (_operationalRate) {
{ case 24000: {
case 24000:
{
SET_CODEC_PAR((codecDef), kDecoderG722_1C_24, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderG722_1C_24, codecInst.pltype,
_decoderInst24Ptr, 32000); _decoderInst24Ptr, 32000);
SET_G722_1C_24_FUNCTIONS((codecDef)); SET_G722_1C_24_FUNCTIONS((codecDef));
break; break;
} }
case 32000: case 32000: {
{
SET_CODEC_PAR((codecDef), kDecoderG722_1C_32, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderG722_1C_32, codecInst.pltype,
_decoderInst32Ptr, 32000); _decoderInst32Ptr, 32000);
SET_G722_1C_32_FUNCTIONS((codecDef)); SET_G722_1C_32_FUNCTIONS((codecDef));
break; break;
} }
case 48000: case 48000: {
{
SET_CODEC_PAR((codecDef), kDecoderG722_1C_32, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderG722_1C_32, codecInst.pltype,
_decoderInst48Ptr, 32000); _decoderInst48Ptr, 32000);
SET_G722_1C_48_FUNCTIONS((codecDef)); SET_G722_1C_48_FUNCTIONS((codecDef));
break; break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodeDef: Wrong rate for G722_1c."); "CodeDef: Wrong rate for G722_1c.");
return -1; return -1;
break;
} }
} }
return 0; return 0;
} }
ACMGenericCodec* ACMGenericCodec*
ACMG722_1C::CreateInstance(void) ACMG722_1C::CreateInstance(void) {
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMG722_1C::InternalCreateEncoder() {
WebRtc_Word16 if ((_encoderInstPtr == NULL) || (_encoderInstPtrRight == NULL)) {
ACMG722_1C::InternalCreateEncoder()
{
if((_encoderInstPtr == NULL) || (_encoderInstPtrRight == NULL))
{
return -1; return -1;
} }
switch(_operationalRate) switch (_operationalRate) {
{ case 24000: {
case 24000:
{
WebRtcG7221C_CreateEnc24(&_encoderInst24Ptr); WebRtcG7221C_CreateEnc24(&_encoderInst24Ptr);
WebRtcG7221C_CreateEnc24(&_encoderInst24PtrR); WebRtcG7221C_CreateEnc24(&_encoderInst24PtrR);
break; break;
} }
case 32000: case 32000: {
{
WebRtcG7221C_CreateEnc32(&_encoderInst32Ptr); WebRtcG7221C_CreateEnc32(&_encoderInst32Ptr);
WebRtcG7221C_CreateEnc32(&_encoderInst32PtrR); WebRtcG7221C_CreateEnc32(&_encoderInst32PtrR);
break; break;
} }
case 48000: case 48000: {
{
WebRtcG7221C_CreateEnc48(&_encoderInst48Ptr); WebRtcG7221C_CreateEnc48(&_encoderInst48Ptr);
WebRtcG7221C_CreateEnc48(&_encoderInst48PtrR); WebRtcG7221C_CreateEnc48(&_encoderInst48PtrR);
break; break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: Wrong rate for G722_1c."); "InternalCreateEncoder: Wrong rate for G722_1c.");
return -1; return -1;
break;
} }
} }
return 0; return 0;
} }
void ACMG722_1C::DestructEncoderSafe() {
void
ACMG722_1C::DestructEncoderSafe()
{
_encoderExist = false; _encoderExist = false;
_encoderInitialized = false; _encoderInitialized = false;
if(_encoderInstPtr != NULL) if (_encoderInstPtr != NULL) {
{
delete _encoderInstPtr; delete _encoderInstPtr;
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
if(_encoderInstPtrRight != NULL) if (_encoderInstPtrRight != NULL) {
{
delete _encoderInstPtrRight; delete _encoderInstPtrRight;
_encoderInstPtrRight = NULL; _encoderInstPtrRight = NULL;
} }
@@ -574,52 +437,38 @@ ACMG722_1C::DestructEncoderSafe()
_encoderInst48Ptr = NULL; _encoderInst48Ptr = NULL;
} }
WebRtc_Word16 ACMG722_1C::InternalCreateDecoder() {
WebRtc_Word16 if (_decoderInstPtr == NULL) {
ACMG722_1C::InternalCreateDecoder()
{
if(_decoderInstPtr == NULL)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: cannot create decoder"); "InternalCreateEncoder: cannot create decoder");
return -1; return -1;
} }
switch(_operationalRate) switch (_operationalRate) {
{ case 24000: {
case 24000:
{
WebRtcG7221C_CreateDec24(&_decoderInst24Ptr); WebRtcG7221C_CreateDec24(&_decoderInst24Ptr);
break; break;
} }
case 32000: case 32000: {
{
WebRtcG7221C_CreateDec32(&_decoderInst32Ptr); WebRtcG7221C_CreateDec32(&_decoderInst32Ptr);
break; break;
} }
case 48000: case 48000: {
{
WebRtcG7221C_CreateDec48(&_decoderInst48Ptr); WebRtcG7221C_CreateDec48(&_decoderInst48Ptr);
break; break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: Wrong rate for G722_1c."); "InternalCreateEncoder: Wrong rate for G722_1c.");
return -1; return -1;
break;
} }
} }
return 0; return 0;
} }
void ACMG722_1C::DestructDecoderSafe() {
void
ACMG722_1C::DestructDecoderSafe()
{
_decoderExist = false; _decoderExist = false;
_decoderInitialized = false; _decoderInitialized = false;
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
delete _decoderInstPtr; delete _decoderInstPtr;
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
@@ -628,53 +477,39 @@ ACMG722_1C::DestructDecoderSafe()
_decoderInst48Ptr = NULL; _decoderInst48Ptr = NULL;
} }
void ACMG722_1C::InternalDestructEncoderInst(void* ptrInst) {
void if (ptrInst != NULL) {
ACMG722_1C::InternalDestructEncoderInst(
void* ptrInst)
{
if(ptrInst != NULL)
{
delete ptrInst; delete ptrInst;
} }
return; return;
} }
WebRtc_Word16 ACMG722_1C::UnregisterFromNetEqSafe(ACMNetEQ* netEq,
WebRtc_Word16 WebRtc_Word16 payloadType) {
ACMG722_1C::UnregisterFromNetEqSafe( if (payloadType != _decoderParams.codecInstant.pltype) {
ACMNetEQ* netEq, WEBRTC_TRACE(webrtc::kTraceError,
WebRtc_Word16 payloadType) webrtc::kTraceAudioCoding,
{ _uniqueID,
if(payloadType != _decoderParams.codecInstant.pltype) "Cannot unregister codec %s given payload-type %d does not"
{ "match the stored payload type",
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, _decoderParams.codecInstant.plname, payloadType,
"Cannot unregister codec %s given payload-type %d does not match \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }
switch(_operationalRate) switch (_operationalRate) {
{ case 24000: {
case 24000:
{
return netEq->RemoveCodec(kDecoderG722_1C_24); return netEq->RemoveCodec(kDecoderG722_1C_24);
} }
case 32000: case 32000: {
{
return netEq->RemoveCodec(kDecoderG722_1C_32); return netEq->RemoveCodec(kDecoderG722_1C_32);
} }
case 48000: case 48000: {
{
return netEq->RemoveCodec(kDecoderG722_1C_48); return netEq->RemoveCodec(kDecoderG722_1C_48);
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Could not remove codec from NetEQ for G722_1c. \ "Could not remove codec from NetEQ for G722_1c."
Sampling frequency doesn't match"); "Sampling frequency doesn't match");
return -1; return -1;
} }
} }

View File

@@ -8,8 +8,8 @@
* 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 ACM_G722_1C_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_
#define ACM_G722_1C_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -91,4 +91,4 @@ protected:
} // namespace webrtc; } // namespace webrtc;
#endif // ACM_G722_1C_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_

View File

@@ -8,8 +8,8 @@
* 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 ACM_G729_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_
#define ACM_G729_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -81,5 +81,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif //ACM_G729_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_

View File

@@ -482,7 +482,6 @@ ACMG729_1::SetBitRateSafe(
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"SetBitRateSafe: Invalid rate G729_1"); "SetBitRateSafe: Invalid rate G729_1");
return -1; return -1;
break;
} }
} }

View File

@@ -8,8 +8,8 @@
* 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 ACM_G729_1_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_
#define ACM_G729_1_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -82,5 +82,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif // ACM_G729_1_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_

View File

@@ -34,37 +34,36 @@ enum
// We set some of the variables to invalid values as a check point // We set some of the variables to invalid values as a check point
// if a proper initialization has happened. Another approach is // if a proper initialization has happened. Another approach is
// to initialize to a default codec that we are sure is always included. // to initialize to a default codec that we are sure is always included.
ACMGenericCodec::ACMGenericCodec(): ACMGenericCodec::ACMGenericCodec()
_inAudioIxWrite(0), : _inAudioIxWrite(0),
_inAudioIxRead(0), _inAudioIxRead(0),
_inTimestampIxWrite(0), _inTimestampIxWrite(0),
_inAudio(NULL), _inAudio(NULL),
_inTimestamp(NULL), _inTimestamp(NULL),
_frameLenSmpl(-1), // invalid value _frameLenSmpl(-1), // invalid value
_noChannels(1), _noChannels(1),
_codecID(-1), // invalid value _codecID(-1), // invalid value
_noMissedSamples(0), _noMissedSamples(0),
_encoderExist(false), _encoderExist(false),
_decoderExist(false), _decoderExist(false),
_encoderInitialized(false), _encoderInitialized(false),
_decoderInitialized(false), _decoderInitialized(false),
_registeredInNetEq(false), _registeredInNetEq(false),
_hasInternalDTX(false), _hasInternalDTX(false),
_ptrVADInst(NULL), _ptrVADInst(NULL),
_vadEnabled(false), _vadEnabled(false),
_vadMode(VADNormal), _vadMode(VADNormal),
_dtxEnabled(false), _dtxEnabled(false),
_ptrDTXInst(NULL), _ptrDTXInst(NULL),
_numLPCParams(kNewCNGNumPLCParams), _numLPCParams(kNewCNGNumPLCParams),
_sentCNPrevious(false), _sentCNPrevious(false),
_isMaster(true), _isMaster(true),
_netEqDecodeLock(NULL), _netEqDecodeLock(NULL),
_codecWrapperLock(*RWLockWrapper::CreateRWLock()), _codecWrapperLock(*RWLockWrapper::CreateRWLock()),
_lastEncodedTimestamp(0), _lastEncodedTimestamp(0),
_lastTimestamp(0), _lastTimestamp(0),
_isAudioBuffFresh(true), _isAudioBuffFresh(true),
_uniqueID(0) _uniqueID(0) {
{
_lastTimestamp = 0xD87F3F9F; _lastTimestamp = 0xD87F3F9F;
//NullifyCodecInstance(); //NullifyCodecInstance();
} }

View File

@@ -8,8 +8,8 @@
* 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 ACM_GENERIC_CODEC_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GENERIC_CODEC_H_
#define ACM_GENERIC_CODEC_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GENERIC_CODEC_H_
#include "acm_common_defs.h" #include "acm_common_defs.h"
#include "audio_coding_module_typedefs.h" #include "audio_coding_module_typedefs.h"
@@ -1256,7 +1256,6 @@ protected:
virtual void CurrentRate( virtual void CurrentRate(
WebRtc_Word32& /* rateBitPerSec */) WebRtc_Word32& /* rateBitPerSec */)
{ {
return; return;
} }
@@ -1330,4 +1329,4 @@ protected:
} // namespace webrt } // namespace webrt
#endif // ACM_GENERIC_CODEC_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GENERIC_CODEC_H_

View File

@@ -8,8 +8,8 @@
* 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 ACM_GSMFR_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_
#define ACM_GSMFR_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -74,5 +74,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif // ACM_GSMFR_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_

View File

@@ -8,8 +8,8 @@
* 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 ACM_ILBC_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_
#define ACM_ILBC_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -75,5 +75,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif //ACM_ILBC_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_

View File

@@ -644,8 +644,8 @@ ACMISAC::InternalInitDecoder(
{ {
// Since we don't require a valid rate or a valid packet size when initializing // Since we don't require a valid rate or a valid packet size when initializing
// the decoder, we set valid values before initializing encoder // the decoder, we set valid values before initializing encoder
codecParams->codecInstant.rate = ISACWB_DEFAULT_RATE; codecParams->codecInstant.rate = kIsacWbDefaultRate;
codecParams->codecInstant.pacsize = ISACSWB_PAC_SIZE; codecParams->codecInstant.pacsize = kIsacPacSize960;
if(InternalInitEncoder(codecParams) < 0) if(InternalInitEncoder(codecParams) < 0)
{ {
return -1; return -1;

View File

@@ -8,8 +8,8 @@
* 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 ACM_ISAC_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_
#define ACM_ISAC_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -150,4 +150,4 @@ protected:
} //namespace } //namespace
#endif // ACM_ISAC_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_

View File

@@ -8,8 +8,8 @@
* 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 ACM_ISAC_MACROS_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_
#define ACM_ISAC_MACROS_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_
#include "engine_configurations.h" #include "engine_configurations.h"
@@ -72,5 +72,5 @@ namespace webrtc
} //namespace } //namespace
#endif // ACM_ISAC_MACROS_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_

View File

@@ -413,7 +413,6 @@ ACMNetEQ::SetPlayoutMode(
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetPlayoutMode: NetEq Error playout mode not recognized"); "SetPlayoutMode: NetEq Error playout mode not recognized");
return -1; return -1;
break;
} }
if(WebRtcNetEQ_SetPlayoutMode(_inst[idx], playoutMode) < 0) if(WebRtcNetEQ_SetPlayoutMode(_inst[idx], playoutMode) < 0)
{ {
@@ -1335,7 +1334,6 @@ ACMNetEQ::AddSlave(
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: NetEq Error, playout mode not recognized"); "AddSlave: NetEq Error, playout mode not recognized");
return -1; return -1;
break;
} }
if(WebRtcNetEQ_SetPlayoutMode(_inst[slaveIdx], playoutMode) < 0) if(WebRtcNetEQ_SetPlayoutMode(_inst[slaveIdx], playoutMode) < 0)
{ {
@@ -1365,4 +1363,3 @@ ACMNetEQ::NumSlaves()
} }
} // namespace webrtc } // namespace webrtc

View File

@@ -8,8 +8,8 @@
* 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 ACM_NETEQ_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_
#define ACM_NETEQ_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_
#include "audio_coding_module.h" #include "audio_coding_module.h"
#include "audio_coding_module_typedefs.h" #include "audio_coding_module_typedefs.h"
@@ -443,4 +443,4 @@ private:
} //namespace webrtc } //namespace webrtc
#endif //ACM_NETEQ_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_

View File

@@ -459,7 +459,6 @@ ACMOPUS::SetBitRateSafe(
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"SetBitRateSafe: Invalid rate Opus"); "SetBitRateSafe: Invalid rate Opus");
return -1; return -1;
break;
} }
} }

View File

@@ -8,8 +8,8 @@
* 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 ACM_OPUS_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_
#define ACM_OPUS_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -80,5 +80,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif // ACM_OPUS_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_

View File

@@ -313,17 +313,14 @@ the stored payload type",
case 8000: case 8000:
{ {
return netEq->RemoveCodec(kDecoderPCM16B); return netEq->RemoveCodec(kDecoderPCM16B);
break;
} }
case 16000: case 16000:
{ {
return netEq->RemoveCodec(kDecoderPCM16Bwb); return netEq->RemoveCodec(kDecoderPCM16Bwb);
break;
} }
case 32000: case 32000:
{ {
return netEq->RemoveCodec(kDecoderPCM16Bswb32kHz); return netEq->RemoveCodec(kDecoderPCM16Bswb32kHz);
break;
} }
default: default:
{ {

View File

@@ -8,8 +8,8 @@
* 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 ACM_PCM16B_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_
#define ACM_PCM16B_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -66,5 +66,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif //ACM_PCM16B_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_

View File

@@ -8,8 +8,8 @@
* 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 ACM_PCMA_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_
#define ACM_PCMA_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -64,5 +64,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif //ACM_PCMA_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_

View File

@@ -8,8 +8,8 @@
* 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 ACM_PCMU_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_
#define ACM_PCMU_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -64,5 +64,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif //ACM_PCMU_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_

View File

@@ -8,8 +8,8 @@
* 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 ACM_RED_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_
#define ACM_RED_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -64,5 +64,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif //ACM_RED_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_

View File

@@ -8,8 +8,8 @@
* 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 ACM_RESAMPLER_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_
#define ACM_RESAMPLER_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_
#include "resampler.h" #include "resampler.h"
#include "typedefs.h" #include "typedefs.h"
@@ -44,4 +44,4 @@ private:
} // namespace webrtc } // namespace webrtc
#endif //ACM_RESAMPLER_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_

View File

@@ -443,7 +443,6 @@ ACMSPEEX::CodecDef(
"Unsupported sampling frequency for Speex"); "Unsupported sampling frequency for Speex");
return -1; return -1;
break;
} }
} }
@@ -662,4 +661,3 @@ ACMSPEEX::SetComplMode(
#endif #endif
} // namespace webrtc } // namespace webrtc

View File

@@ -8,8 +8,8 @@
* 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 ACM_SPEEX_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_
#define ACM_SPEEX_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -91,4 +91,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif // ACM_SPEEX_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_

View File

@@ -8,8 +8,8 @@
* 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 AUDIO_CODING_MODULE_IMPL_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_
#define AUDIO_CODING_MODULE_IMPL_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_
#include "acm_codec_database.h" #include "acm_codec_database.h"
#include "acm_neteq.h" #include "acm_neteq.h"
@@ -397,4 +397,4 @@ private:
} // namespace webrtc } // namespace webrtc
#endif #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_