Reformatting ACM. All changes are bit-exact in this CL.
TEST=VoE auto-test, audio_coding_module_test; only 15 ms of teststereo_out_1.pcm is not bit-exact with output file of the head revision Review URL: https://webrtc-codereview.appspot.com/937035 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3287 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
ddebc17bee
commit
c454fab03b
@ -11,18 +11,20 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_H
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_H
|
||||
|
||||
#include "audio_coding_module_typedefs.h"
|
||||
#include "module.h"
|
||||
// TODO(turajs): If possible, forward declare and remove the following include.
|
||||
#include "module_common_types.h"
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
|
||||
#include "webrtc/modules/interface/module.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// forward declarations
|
||||
struct CodecInst;
|
||||
struct WebRtcRTPHeader;
|
||||
class AudioFrame;
|
||||
class RTPFragmentationHeader;
|
||||
|
||||
#define WEBRTC_10MS_PCM_AUDIO 960 // 16 bits super wideband 48 Khz
|
||||
#define WEBRTC_10MS_PCM_AUDIO 960 // 16 bits super wideband 48 kHz
|
||||
|
||||
// Callback class used for sending data ready to be packetized
|
||||
class AudioPacketizationCallback {
|
||||
@ -30,8 +32,11 @@ class AudioPacketizationCallback {
|
||||
virtual ~AudioPacketizationCallback() {}
|
||||
|
||||
virtual WebRtc_Word32 SendData(
|
||||
FrameType frameType, WebRtc_UWord8 payloadType, WebRtc_UWord32 timeStamp,
|
||||
const WebRtc_UWord8* payloadData, WebRtc_UWord16 payloadSize,
|
||||
FrameType frame_type,
|
||||
WebRtc_UWord8 payload_type,
|
||||
WebRtc_UWord32 timestamp,
|
||||
const WebRtc_UWord8* payload_data,
|
||||
WebRtc_UWord16 payload_len_bytes,
|
||||
const RTPFragmentationHeader* fragmentation) = 0;
|
||||
};
|
||||
|
||||
@ -40,7 +45,7 @@ class AudioCodingFeedback {
|
||||
public:
|
||||
virtual ~AudioCodingFeedback() {}
|
||||
|
||||
virtual WebRtc_Word32 IncomingDtmf(const WebRtc_UWord8 digitDtmf,
|
||||
virtual WebRtc_Word32 IncomingDtmf(const WebRtc_UWord8 digit_dtmf,
|
||||
const bool end) = 0;
|
||||
};
|
||||
|
||||
@ -96,17 +101,17 @@ class AudioCodingModule: public Module {
|
||||
// Get supported codec with list number.
|
||||
//
|
||||
// Input:
|
||||
// -listId : list number.
|
||||
// -list_id : list number.
|
||||
//
|
||||
// Output:
|
||||
// -codec : a structure where the parameters of the codec,
|
||||
// given by list number is written to.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if the list number (listId) is invalid.
|
||||
// -1 if the list number (list_id) is invalid.
|
||||
// 0 if succeeded.
|
||||
//
|
||||
static WebRtc_Word32 Codec(const WebRtc_UWord8 listId, CodecInst& codec);
|
||||
static WebRtc_Word32 Codec(const WebRtc_UWord8 list_id, CodecInst& codec);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 Codec()
|
||||
@ -124,7 +129,7 @@ class AudioCodingModule: public Module {
|
||||
// default parameters of the codec.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if the list number (listId) is invalid.
|
||||
// -1 if no codec matches the given parameters.
|
||||
// 0 if succeeded.
|
||||
//
|
||||
static WebRtc_Word32 Codec(const char* payload_name, CodecInst& codec,
|
||||
@ -154,10 +159,10 @@ class AudioCodingModule: public Module {
|
||||
// Checks the validity of the parameters of the given codec.
|
||||
//
|
||||
// Input:
|
||||
// -codec : the structur which keeps the parameters of the
|
||||
// -codec : the structure which keeps the parameters of the
|
||||
// codec.
|
||||
//
|
||||
// Reurn value:
|
||||
// Return value:
|
||||
// true if the parameters are valid,
|
||||
// false if any parameter is not valid.
|
||||
//
|
||||
@ -194,7 +199,7 @@ class AudioCodingModule: public Module {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 RegisterSendCodec()
|
||||
// Registers a codec, specified by "sendCodec," as sending codec.
|
||||
// Registers a codec, specified by |send_codec|, as sending codec.
|
||||
// This API can be called multiple of times to register Codec. The last codec
|
||||
// registered overwrites the previous ones.
|
||||
// The API can also be used to change payload type for CNG and RED, which are
|
||||
@ -211,7 +216,7 @@ class AudioCodingModule: public Module {
|
||||
// secondary encoder will be unregistered.
|
||||
//
|
||||
// Input:
|
||||
// -sendCodec : Parameters of the codec to be registered, c.f.
|
||||
// -send_codec : Parameters of the codec to be registered, c.f.
|
||||
// common_types.h for the definition of
|
||||
// CodecInst.
|
||||
//
|
||||
@ -219,7 +224,7 @@ class AudioCodingModule: public Module {
|
||||
// -1 if failed to initialize,
|
||||
// 0 if succeeded.
|
||||
//
|
||||
virtual WebRtc_Word32 RegisterSendCodec(const CodecInst& sendCodec) = 0;
|
||||
virtual WebRtc_Word32 RegisterSendCodec(const CodecInst& send_codec) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// int RegisterSecondarySendCodec()
|
||||
@ -253,13 +258,13 @@ class AudioCodingModule: public Module {
|
||||
// Get parameters for the codec currently registered as send codec.
|
||||
//
|
||||
// Output:
|
||||
// -currentSendCodec : parameters of the send codec.
|
||||
// -current_send_codec : parameters of the send codec.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if failed to get send codec,
|
||||
// 0 if succeeded.
|
||||
//
|
||||
virtual WebRtc_Word32 SendCodec(CodecInst& currentSendCodec) const = 0;
|
||||
virtual WebRtc_Word32 SendCodec(CodecInst& current_send_codec) const = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// int SecondarySendCodec()
|
||||
@ -336,7 +341,7 @@ class AudioCodingModule: public Module {
|
||||
// current encoder ACM will resample the audio.
|
||||
//
|
||||
// Input:
|
||||
// -audioFrame : the input audio frame, containing raw audio
|
||||
// -audio_frame : the input audio frame, containing raw audio
|
||||
// sampling frequency etc.,
|
||||
// c.f. module_common_types.h for definition of
|
||||
// AudioFrame.
|
||||
@ -347,7 +352,7 @@ class AudioCodingModule: public Module {
|
||||
// < -1 to add the frame to the buffer n samples had to be
|
||||
// overwritten, -n is the return value in this case.
|
||||
//
|
||||
virtual WebRtc_Word32 Add10MsData(const AudioFrame& audioFrame) = 0;
|
||||
virtual WebRtc_Word32 Add10MsData(const AudioFrame& audio_frame) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// (FEC) Forward Error Correction
|
||||
@ -368,14 +373,14 @@ class AudioCodingModule: public Module {
|
||||
// This means that FEC is actually a RED scheme.
|
||||
//
|
||||
// Input:
|
||||
// -enableFEC : if true FEC is enabled, otherwise FEC is
|
||||
// -enable_fec : if true FEC is enabled, otherwise FEC is
|
||||
// disabled.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if failed to set FEC status,
|
||||
// 0 if succeeded.
|
||||
//
|
||||
virtual WebRtc_Word32 SetFECStatus(const bool enableFEC) = 0;
|
||||
virtual WebRtc_Word32 SetFECStatus(const bool enable_fec) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// bool FECStatus()
|
||||
@ -394,7 +399,7 @@ class AudioCodingModule: public Module {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 SetVAD()
|
||||
// If DTX is enabled & the codec does not have internal DTX/VAD
|
||||
// WebRtc VAD will be automatically enabled and 'enableVAD' is ignored.
|
||||
// WebRtc VAD will be automatically enabled and |enable_vad| is ignored.
|
||||
//
|
||||
// If DTX is disabled but VAD is enabled no DTX packets are send,
|
||||
// regardless of whether the codec has internal DTX/VAD or not. In this
|
||||
@ -403,11 +408,11 @@ class AudioCodingModule: public Module {
|
||||
// NOTE! VAD/DTX is not supported when sending stereo.
|
||||
//
|
||||
// Inputs:
|
||||
// -enableDTX : if true DTX is enabled,
|
||||
// -enable_dtx : if true DTX is enabled,
|
||||
// otherwise DTX is disabled.
|
||||
// -enableVAD : if true VAD is enabled,
|
||||
// -enable_vad : if true VAD is enabled,
|
||||
// otherwise VAD is disabled.
|
||||
// -vadMode : determines the aggressiveness of VAD. A more
|
||||
// -vad_mode : determines the aggressiveness of VAD. A more
|
||||
// aggressive mode results in more frames labeled
|
||||
// as in-active, c.f. definition of
|
||||
// ACMVADMode in audio_coding_module_typedefs.h
|
||||
@ -417,27 +422,27 @@ class AudioCodingModule: public Module {
|
||||
// -1 if failed to set up VAD/DTX,
|
||||
// 0 if succeeded.
|
||||
//
|
||||
virtual WebRtc_Word32 SetVAD(const bool enableDTX = true,
|
||||
const bool enableVAD = false,
|
||||
const ACMVADMode vadMode = VADNormal) = 0;
|
||||
virtual WebRtc_Word32 SetVAD(const bool enable_dtx = true,
|
||||
const bool enable_vad = false,
|
||||
const ACMVADMode vad_mode = VADNormal) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 VAD()
|
||||
// Get VAD status.
|
||||
//
|
||||
// Outputs:
|
||||
// -dtxEnabled : is set to true if DTX is enabled, otherwise
|
||||
// -dtx_enabled : is set to true if DTX is enabled, otherwise
|
||||
// is set to false.
|
||||
// -vadEnabled : is set to true if VAD is enabled, otherwise
|
||||
// -vad_enabled : is set to true if VAD is enabled, otherwise
|
||||
// is set to false.
|
||||
// -vadMode : is set to the current aggressiveness of VAD.
|
||||
// -vad_mode : is set to the current aggressiveness of VAD.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if fails to retrieve the setting of DTX/VAD,
|
||||
// 0 if succeeeded.
|
||||
// 0 if succeeded.
|
||||
//
|
||||
virtual WebRtc_Word32 VAD(bool& dtxEnabled, bool& vadEnabled,
|
||||
ACMVADMode& vadMode) const = 0;
|
||||
virtual WebRtc_Word32 VAD(bool& dtx_enabled, bool& vad_enabled,
|
||||
ACMVADMode& vad_mode) const = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 ReplaceInternalDTXWithWebRtc()
|
||||
@ -445,7 +450,7 @@ class AudioCodingModule: public Module {
|
||||
// supported for G729, where this call replaces AnnexB with WebRtc DTX.
|
||||
//
|
||||
// Input:
|
||||
// -useWebRtcDTX : if false (default) the codec built-in DTX/VAD
|
||||
// -use_webrtc_dtx : if false (default) the codec built-in DTX/VAD
|
||||
// scheme is used, otherwise the internal DTX is
|
||||
// replaced with WebRtc DTX/VAD.
|
||||
//
|
||||
@ -454,7 +459,7 @@ class AudioCodingModule: public Module {
|
||||
// 0 if succeeded.
|
||||
//
|
||||
virtual WebRtc_Word32 ReplaceInternalDTXWithWebRtc(
|
||||
const bool useWebRtcDTX = false) = 0;
|
||||
const bool use_webrtc_dtx = false) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 IsInternalDTXReplacedWithWebRtc()
|
||||
@ -462,7 +467,7 @@ class AudioCodingModule: public Module {
|
||||
// WebRtc DTX. This is only supported for G729.
|
||||
//
|
||||
// Output:
|
||||
// -usesWebRtcDTX : is set to true if the codec internal DTX is
|
||||
// -uses_webrtc_dtx : is set to true if the codec internal DTX is
|
||||
// replaced with WebRtc DTX/VAD, otherwise it is set
|
||||
// to false.
|
||||
//
|
||||
@ -471,7 +476,7 @@ class AudioCodingModule: public Module {
|
||||
// 0 if succeeded.
|
||||
//
|
||||
virtual WebRtc_Word32 IsInternalDTXReplacedWithWebRtc(
|
||||
bool& usesWebRtcDTX) = 0;
|
||||
bool& uses_webrtc_dtx) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 RegisterVADCallback()
|
||||
@ -481,13 +486,13 @@ class AudioCodingModule: public Module {
|
||||
// VAD is employed to identify a frame as active/inactive.
|
||||
//
|
||||
// Input:
|
||||
// -vadCallback : pointer to a callback function.
|
||||
// -vad_callback : pointer to a callback function.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if failed to register the callback function.
|
||||
// 0 if the callback function is registered successfully.
|
||||
//
|
||||
virtual WebRtc_Word32 RegisterVADCallback(ACMVADCallback* vadCallback) = 0;
|
||||
virtual WebRtc_Word32 RegisterVADCallback(ACMVADCallback* vad_callback) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Receiver
|
||||
@ -544,7 +549,7 @@ class AudioCodingModule: public Module {
|
||||
// codecs, CNG-NB, CNG-WB, CNG-SWB, AVT and RED.
|
||||
//
|
||||
// Input:
|
||||
// -receiveCodec : parameters of the codec to be registered, c.f.
|
||||
// -receive_codec : parameters of the codec to be registered, c.f.
|
||||
// common_types.h for the definition of
|
||||
// CodecInst.
|
||||
//
|
||||
@ -552,7 +557,8 @@ class AudioCodingModule: public Module {
|
||||
// -1 if failed to register the codec
|
||||
// 0 if the codec registered successfully.
|
||||
//
|
||||
virtual WebRtc_Word32 RegisterReceiveCodec(const CodecInst& receiveCodec) = 0;
|
||||
virtual WebRtc_Word32 RegisterReceiveCodec(
|
||||
const CodecInst& receive_codec) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 UnregisterReceiveCodec()
|
||||
@ -560,22 +566,22 @@ class AudioCodingModule: public Module {
|
||||
// from the list of possible receive codecs.
|
||||
//
|
||||
// Input:
|
||||
// -payloadType : The number representing the payload type to
|
||||
// -payload_type : The number representing the payload type to
|
||||
// unregister.
|
||||
//
|
||||
// Output:
|
||||
// -1 if the unregistration fails.
|
||||
// -1 if fails to unregister.
|
||||
// 0 if the given codec is successfully unregistered.
|
||||
//
|
||||
virtual WebRtc_Word32 UnregisterReceiveCodec(
|
||||
const WebRtc_Word16 receiveCodec) = 0;
|
||||
const WebRtc_Word16 payload_type) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 ReceiveCodec()
|
||||
// Get the codec associated with last received payload.
|
||||
//
|
||||
// Output:
|
||||
// -currRcvCodec : parameters of the codec associated with the last
|
||||
// -curr_receive_codec : parameters of the codec associated with the last
|
||||
// received payload, c.f. common_types.h for
|
||||
// the definition of CodecInst.
|
||||
//
|
||||
@ -583,25 +589,25 @@ class AudioCodingModule: public Module {
|
||||
// -1 if failed to retrieve the codec,
|
||||
// 0 if the codec is successfully retrieved.
|
||||
//
|
||||
virtual WebRtc_Word32 ReceiveCodec(CodecInst& currRcvCodec) const = 0;
|
||||
virtual WebRtc_Word32 ReceiveCodec(CodecInst& curr_receive_codec) const = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 IncomingPacket()
|
||||
// Call this function to insert a parsed RTP packet into ACM.
|
||||
//
|
||||
// Inputs:
|
||||
// -incomingPayload : received payload.
|
||||
// -payloadLengthByte : the length of payload in bytes.
|
||||
// -rtpInfo : the relevant information retrieved from RTP
|
||||
// -incoming_payload : received payload.
|
||||
// -payload_len_bytes : the length of payload in bytes.
|
||||
// -rtp_info : the relevant information retrieved from RTP
|
||||
// header.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if failed to push in the payload
|
||||
// 0 if payload is successfully pushed in.
|
||||
//
|
||||
virtual WebRtc_Word32 IncomingPacket(const WebRtc_UWord8* incomingPayload,
|
||||
const WebRtc_Word32 payloadLengthByte,
|
||||
const WebRtcRTPHeader& rtpInfo) = 0;
|
||||
virtual WebRtc_Word32 IncomingPacket(const WebRtc_UWord8* incoming_payload,
|
||||
const WebRtc_Word32 payload_len_bytes,
|
||||
const WebRtcRTPHeader& rtp_info) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 IncomingPayload()
|
||||
@ -610,9 +616,9 @@ class AudioCodingModule: public Module {
|
||||
// pre-encoded files are pushed in ACM
|
||||
//
|
||||
// Inputs:
|
||||
// -incomingPayload : received payload.
|
||||
// -payloadLenghtByte : the length, in bytes, of the received payload.
|
||||
// -payloadType : the payload-type. This specifies which codec has
|
||||
// -incoming_payload : received payload.
|
||||
// -payload_len_byte : the length, in bytes, of the received payload.
|
||||
// -payload_type : the payload-type. This specifies which codec has
|
||||
// to be used to decode the payload.
|
||||
// -timestamp : send timestamp of the payload. ACM starts with
|
||||
// a random value and increment it by the
|
||||
@ -627,9 +633,9 @@ class AudioCodingModule: public Module {
|
||||
// -1 if failed to push in the payload
|
||||
// 0 if payload is successfully pushed in.
|
||||
//
|
||||
virtual WebRtc_Word32 IncomingPayload(const WebRtc_UWord8* incomingPayload,
|
||||
const WebRtc_Word32 payloadLengthByte,
|
||||
const WebRtc_UWord8 payloadType,
|
||||
virtual WebRtc_Word32 IncomingPayload(const WebRtc_UWord8* incoming_payload,
|
||||
const WebRtc_Word32 payload_len_byte,
|
||||
const WebRtc_UWord8 payload_type,
|
||||
const WebRtc_UWord32 timestamp = 0) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -637,22 +643,22 @@ class AudioCodingModule: public Module {
|
||||
// Set Minimum playout delay, used for lip-sync.
|
||||
//
|
||||
// Input:
|
||||
// -timeMs : minimum delay in milliseconds.
|
||||
// -time_ms : minimum delay in milliseconds.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if failed to set the delay,
|
||||
// 0 if the minimum delay is set.
|
||||
//
|
||||
virtual WebRtc_Word32 SetMinimumPlayoutDelay(const WebRtc_Word32 timeMs) = 0;
|
||||
virtual WebRtc_Word32 SetMinimumPlayoutDelay(const WebRtc_Word32 time_ms) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 RegisterIncomingMessagesCallback()
|
||||
// Used by the module to deliver messages to the codec module/application
|
||||
// when a Dtmf tone is detected, as well as when it stopped.
|
||||
// when a DTMF tone is detected, as well as when it stopped.
|
||||
//
|
||||
// Inputs:
|
||||
// -inMsgCallback : pointer to callback function which will be called
|
||||
// if Dtmf is detected.
|
||||
// -in_message_callback: pointer to callback function which will be called
|
||||
// if DTMF is detected.
|
||||
// -cpt : enables CPT (Call Progress Tone) detection for the
|
||||
// specified country. c.f. definition of ACMCountries
|
||||
// in audio_coding_module_typedefs.h for valid
|
||||
@ -665,20 +671,20 @@ class AudioCodingModule: public Module {
|
||||
//
|
||||
virtual WebRtc_Word32
|
||||
RegisterIncomingMessagesCallback(
|
||||
AudioCodingFeedback* inMsgCallback,
|
||||
AudioCodingFeedback* in_message_callback,
|
||||
const ACMCountries cpt = ACMDisableCountryDetection) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 SetDtmfPlayoutStatus()
|
||||
// Configure Dtmf playout, i.e. whether out-of-band
|
||||
// Dtmf tones are played or not.
|
||||
// Configure DTMF playout, i.e. whether out-of-band
|
||||
// DTMF tones are played or not.
|
||||
//
|
||||
// Input:
|
||||
// -enable : if true to enable playout out-of-band Dtmf tones,
|
||||
// -enable : if true to enable playout out-of-band DTMF tones,
|
||||
// false to disable.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if the method fails, e.g. Dtmf playout is not supported.
|
||||
// -1 if the method fails, e.g. DTMF playout is not supported.
|
||||
// 0 if the status is set successfully.
|
||||
//
|
||||
virtual WebRtc_Word32 SetDtmfPlayoutStatus(const bool enable) = 0;
|
||||
@ -746,7 +752,7 @@ class AudioCodingModule: public Module {
|
||||
// Get the estimate of the Bandwidth, in bits/second, based on the incoming
|
||||
// stream. This API is useful in one-way communication scenarios, where
|
||||
// the bandwidth information is sent in an out-of-band fashion.
|
||||
// Currently only supported if iSAC is registered as a reciever.
|
||||
// Currently only supported if iSAC is registered as a receiver.
|
||||
//
|
||||
// Return value:
|
||||
// >0 bandwidth in bits/second.
|
||||
@ -762,7 +768,7 @@ class AudioCodingModule: public Module {
|
||||
// delay. In FAX mode, NetEQ is optimized to have few delay changes as
|
||||
// possible and maintain a constant delay, perhaps large relative to voice
|
||||
// mode, to avoid PLC. In streaming mode, we tolerate a little more delay
|
||||
// to acheive better jitter robustness.
|
||||
// to achieve better jitter robustness.
|
||||
//
|
||||
// Input:
|
||||
// -mode : playout mode. Possible inputs are:
|
||||
@ -786,7 +792,7 @@ class AudioCodingModule: public Module {
|
||||
// fax: a mode that is optimized for receiving FAX signals.
|
||||
// In this mode NetEq tries to maintain a constant high
|
||||
// delay to avoid PLC if possible.
|
||||
// streaming: a mode that is suitable for streaminq. In this mode we
|
||||
// streaming: a mode that is suitable for streaming. In this mode we
|
||||
// accept longer delay to improve jitter robustness.
|
||||
//
|
||||
virtual AudioPlayoutMode PlayoutMode() const = 0;
|
||||
@ -797,12 +803,12 @@ class AudioCodingModule: public Module {
|
||||
// frequency. ACM will perform a resampling if required.
|
||||
//
|
||||
// Input:
|
||||
// -desiredFreqHz : the desired sampling frequency, in Hertz, of the
|
||||
// -desired_freq_hz : the desired sampling frequency, in Hertz, of the
|
||||
// output audio. If set to -1, the function returns the
|
||||
// audio at the current sampling frequency.
|
||||
//
|
||||
// Output:
|
||||
// -audioFrame : output audio frame which contains raw audio data
|
||||
// -audio_frame : output audio frame which contains raw audio data
|
||||
// and other relevant parameters, c.f.
|
||||
// module_common_types.h for the definition of
|
||||
// AudioFrame.
|
||||
@ -812,8 +818,8 @@ class AudioCodingModule: public Module {
|
||||
// 0 if the function succeeds.
|
||||
//
|
||||
virtual WebRtc_Word32
|
||||
PlayoutData10Ms(const WebRtc_Word32 desiredFreqHz,
|
||||
AudioFrame &audioFrame) = 0;
|
||||
PlayoutData10Ms(const WebRtc_Word32 desired_freq_hz,
|
||||
AudioFrame &audio_frame) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// (CNG) Comfort Noise Generation
|
||||
@ -855,43 +861,43 @@ class AudioCodingModule: public Module {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 SetISACMaxRate()
|
||||
// Set the maximum instantaneous rate of iSAC. For a payload of B bits
|
||||
// with a frame-size of T sec the instantaneous rate is B/T bist per
|
||||
// second. Therefore, (B/T < maxRateBitPerSec) and
|
||||
// (B < maxPayloadLenBytes * 8) are always satisfied for iSAC payloads,
|
||||
// with a frame-size of T sec the instantaneous rate is B/T bits per
|
||||
// second. Therefore, (B/T < |max_rate_bps|) and
|
||||
// (B < |max_payload_len_bytes| * 8) are always satisfied for iSAC payloads,
|
||||
// c.f SetISACMaxPayloadSize().
|
||||
//
|
||||
// Input:
|
||||
// -maxRateBitPerSec : maximum instantaneous bit-rate given in bits/sec.
|
||||
// -max_rate_bps : maximum instantaneous bit-rate given in bits/sec.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if failed to set the maximum rate.
|
||||
// 0 if the maximum rate is set successfully.
|
||||
//
|
||||
virtual WebRtc_Word32 SetISACMaxRate(
|
||||
const WebRtc_UWord32 maxRateBitPerSec) = 0;
|
||||
const WebRtc_UWord32 max_rate_bps) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 SetISACMaxPayloadSize()
|
||||
// Set the maximum payload size of iSAC packets. No iSAC payload,
|
||||
// regardless of its frame-size, may exceed the given limit. For
|
||||
// an iSAC payload of size B bits and frame-size T sec we have;
|
||||
// (B < maxPayloadLenBytes * 8) and (B/T < maxRateBitPerSec), c.f.
|
||||
// an iSAC payload of size B bits and frame-size T seconds we have;
|
||||
// (B < |max_payload_len_bytes| * 8) and (B/T < |max_rate_bps|), c.f.
|
||||
// SetISACMaxRate().
|
||||
//
|
||||
// Input:
|
||||
// -maxPayloadLenBytes : maximum payload size in bytes.
|
||||
// -max_payload_len_bytes : maximum payload size in bytes.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if failed to set the maximm payload-size.
|
||||
// 0 if the given linit is seet successfully.
|
||||
// -1 if failed to set the maximum payload-size.
|
||||
// 0 if the given length is set successfully.
|
||||
//
|
||||
virtual WebRtc_Word32 SetISACMaxPayloadSize(
|
||||
const WebRtc_UWord16 maxPayloadLenBytes) = 0;
|
||||
const WebRtc_UWord16 max_payload_len_bytes) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 ConfigISACBandwidthEstimator()
|
||||
// Call this function to configure the bandwidth estimator of ISAC.
|
||||
// During the adaptation of bit-rate, iSAC atomatically adjusts the
|
||||
// During the adaptation of bit-rate, iSAC automatically adjusts the
|
||||
// frame-size (either 30 or 60 ms) to save on RTP header. The initial
|
||||
// frame-size can be specified by the first argument. The configuration also
|
||||
// regards the initial estimate of bandwidths. The estimator starts from
|
||||
@ -900,22 +906,22 @@ class AudioCodingModule: public Module {
|
||||
// adaptation of frame-size. This is specified by the last parameter.
|
||||
//
|
||||
// Input:
|
||||
// -initFrameSizeMsec : initial frame-size in milisecods. For iSAC-wb
|
||||
// -init_frame_size_ms : initial frame-size in milliseconds. For iSAC-wb
|
||||
// 30 ms and 60 ms (default) are acceptable values,
|
||||
// and for iSAC-swb 30 ms is the only acceptable
|
||||
// value. Zero indiates default value.
|
||||
// -initRateBitPerSec : initial estimate of the bandwidth. Values
|
||||
// value. Zero indicates default value.
|
||||
// -init_rate_bps : initial estimate of the bandwidth. Values
|
||||
// between 10000 and 58000 are acceptable.
|
||||
// -enforceFrameSize : if true, the frame-size will not be adapted.
|
||||
// -enforce_srame_size : if true, the frame-size will not be adapted.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if failed to configure the bandwidth estimator,
|
||||
// 0 if the configuration was successfully applied.
|
||||
//
|
||||
virtual WebRtc_Word32 ConfigISACBandwidthEstimator(
|
||||
const WebRtc_UWord8 initFrameSizeMsec,
|
||||
const WebRtc_UWord16 initRateBitPerSec,
|
||||
const bool enforceFrameSize = false) = 0;
|
||||
const WebRtc_UWord8 init_frame_size_ms,
|
||||
const WebRtc_UWord16 init_rate_bps,
|
||||
const bool enforce_frame_size = false) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// statistics
|
||||
@ -926,14 +932,14 @@ class AudioCodingModule: public Module {
|
||||
// Get network statistics.
|
||||
//
|
||||
// Input:
|
||||
// -networkStatistics : a structure that contains network statistics.
|
||||
// -network_statistics : a structure that contains network statistics.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if failed to set the network statistics,
|
||||
// 0 if statistics are set successfully.
|
||||
//
|
||||
virtual WebRtc_Word32 NetworkStatistics(
|
||||
ACMNetworkStatistics& networkStatistics) const = 0;
|
||||
ACMNetworkStatistics& network_statistics) const = 0;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_TYPEDEFS_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_TYPEDEFS_H_
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
@ -8,14 +8,15 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_amr.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "audio_coding_module_typedefs.h"
|
||||
#include "rw_lock_wrapper.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_amr.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_AMR
|
||||
// NOTE! GSM AMR is not included in the open-source package. The following
|
||||
@ -25,23 +26,23 @@
|
||||
//
|
||||
// The API in the header file should match the one below.
|
||||
//
|
||||
// int16_t WebRtcAmr_CreateEnc(AMR_encinst_t_** encInst);
|
||||
// int16_t WebRtcAmr_CreateDec(AMR_decinst_t_** decInst);
|
||||
// int16_t WebRtcAmr_FreeEnc(AMR_encinst_t_* encInst);
|
||||
// int16_t WebRtcAmr_FreeDec(AMR_decinst_t_* decInst);
|
||||
// int16_t WebRtcAmr_Encode(AMR_encinst_t_* encInst,
|
||||
// int16_t WebRtcAmr_CreateEnc(AMR_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcAmr_CreateDec(AMR_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcAmr_FreeEnc(AMR_encinst_t_* enc_inst);
|
||||
// int16_t WebRtcAmr_FreeDec(AMR_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcAmr_Encode(AMR_encinst_t_* enc_inst,
|
||||
// int16_t* input,
|
||||
// int16_t len,
|
||||
// int16_t*output,
|
||||
// int16_t mode);
|
||||
// int16_t WebRtcAmr_EncoderInit(AMR_encinst_t_* encInst,
|
||||
// int16_t dtxMode);
|
||||
// int16_t WebRtcAmr_EncodeBitmode(AMR_encinst_t_* encInst,
|
||||
// int16_t WebRtcAmr_EncoderInit(AMR_encinst_t_* enc_inst,
|
||||
// int16_t dtx_mode);
|
||||
// int16_t WebRtcAmr_EncodeBitmode(AMR_encinst_t_* enc_inst,
|
||||
// int format);
|
||||
// int16_t WebRtcAmr_Decode(AMR_decinst_t_* decInst);
|
||||
// int16_t WebRtcAmr_DecodePlc(AMR_decinst_t_* decInst);
|
||||
// int16_t WebRtcAmr_DecoderInit(AMR_decinst_t_* decInst);
|
||||
// int16_t WebRtcAmr_DecodeBitmode(AMR_decinst_t_* decInst,
|
||||
// int16_t WebRtcAmr_Decode(AMR_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcAmr_DecodePlc(AMR_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcAmr_DecoderInit(AMR_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcAmr_DecodeBitmode(AMR_decinst_t_* dec_inst,
|
||||
// int format);
|
||||
#include "amr_interface.h"
|
||||
#endif
|
||||
@ -49,13 +50,13 @@
|
||||
namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_AMR
|
||||
ACMAMR::ACMAMR(WebRtc_Word16 /* codecID */)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL),
|
||||
_encodingMode(-1), // Invalid value.
|
||||
_encodingRate(0), // Invalid value.
|
||||
_encoderPackingFormat(AMRBandwidthEfficient),
|
||||
_decoderPackingFormat(AMRBandwidthEfficient) {
|
||||
ACMAMR::ACMAMR(WebRtc_Word16 /* codec_id */)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
encoding_mode_(-1), // Invalid value.
|
||||
encoding_rate_(0), // Invalid value.
|
||||
encoder_packing_format_(AMRBandwidthEfficient),
|
||||
decoder_packing_format_(AMRBandwidthEfficient) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -63,16 +64,16 @@ ACMAMR::~ACMAMR() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_Word16 ACMAMR::InternalEncode(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMAMR::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -85,17 +86,17 @@ WebRtc_Word16 ACMAMR::DisableDTX() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -123,12 +124,12 @@ WebRtc_Word16 ACMAMR::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ACMAMR::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMAMR::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::SetAMREncoderPackingFormat(
|
||||
ACMAMRPackingFormat /* packingFormat */) {
|
||||
ACMAMRPackingFormat /* packing_format */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -137,7 +138,7 @@ ACMAMRPackingFormat ACMAMR::AMREncoderPackingFormat() const {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::SetAMRDecoderPackingFormat(
|
||||
ACMAMRPackingFormat /* packingFormat */) {
|
||||
ACMAMRPackingFormat /* packing_format */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -156,78 +157,78 @@ ACMAMRPackingFormat ACMAMR::AMRDecoderPackingFormat() const {
|
||||
#define WEBRTC_AMR_MR102 6
|
||||
#define WEBRTC_AMR_MR122 7
|
||||
|
||||
ACMAMR::ACMAMR(WebRtc_Word16 codecID)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL),
|
||||
_encodingMode(-1), // invalid value
|
||||
_encodingRate(0) { // invalid value
|
||||
_codecID = codecID;
|
||||
_hasInternalDTX = true;
|
||||
_encoderPackingFormat = AMRBandwidthEfficient;
|
||||
_decoderPackingFormat = AMRBandwidthEfficient;
|
||||
ACMAMR::ACMAMR(WebRtc_Word16 codec_id)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
encoding_mode_(-1), // invalid value
|
||||
encoding_rate_(0) { // invalid value
|
||||
codec_id_ = codec_id;
|
||||
has_internal_dtx_ = true;
|
||||
encoder_packing_format_ = AMRBandwidthEfficient;
|
||||
decoder_packing_format_ = AMRBandwidthEfficient;
|
||||
return;
|
||||
}
|
||||
|
||||
ACMAMR::~ACMAMR() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcAmr_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcAmr_FreeEnc(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcAmr_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcAmr_FreeDec(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
WebRtc_Word16 vadDecision = 1;
|
||||
WebRtc_Word16 ACMAMR::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
WebRtc_Word16 vad_decision = 1;
|
||||
// sanity check, if the rate is set correctly. we might skip this
|
||||
// sanity check. if rate is not set correctly, initialization flag
|
||||
// should be false and should not be here.
|
||||
if ((_encodingMode < WEBRTC_AMR_MR475) ||
|
||||
(_encodingMode > WEBRTC_AMR_MR122)) {
|
||||
*bitStreamLenByte = 0;
|
||||
if ((encoding_mode_ < WEBRTC_AMR_MR475) ||
|
||||
(encoding_mode_ > WEBRTC_AMR_MR122)) {
|
||||
*bitstream_len_byte = 0;
|
||||
return -1;
|
||||
}
|
||||
*bitStreamLenByte = WebRtcAmr_Encode(_encoderInstPtr,
|
||||
&_inAudio[_inAudioIxRead],
|
||||
_frameLenSmpl,
|
||||
(WebRtc_Word16*) bitStream,
|
||||
_encodingMode);
|
||||
*bitstream_len_byte = WebRtcAmr_Encode(encoder_inst_ptr_,
|
||||
&in_audio_[in_audio_ix_read_],
|
||||
frame_len_smpl_,
|
||||
(WebRtc_Word16*)bitstream,
|
||||
encoding_mode_);
|
||||
|
||||
// Update VAD, if internal DTX is used
|
||||
if (_hasInternalDTX && _dtxEnabled) {
|
||||
if (*bitStreamLenByte <= (7 * _frameLenSmpl / 160)) {
|
||||
vadDecision = 0;
|
||||
if (has_internal_dtx_ && dtx_enabled_) {
|
||||
if (*bitstream_len_byte <= (7 * frame_len_smpl_ / 160)) {
|
||||
vad_decision = 0;
|
||||
}
|
||||
for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
|
||||
_vadLabel[n] = vadDecision;
|
||||
vad_label_[n] = vad_decision;
|
||||
}
|
||||
}
|
||||
// increment the read index
|
||||
_inAudioIxRead += _frameLenSmpl;
|
||||
return *bitStreamLenByte;
|
||||
in_audio_ix_read_ += frame_len_smpl_;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMAMR::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::EnableDTX() {
|
||||
if (_dtxEnabled) {
|
||||
if (dtx_enabled_) {
|
||||
return 0;
|
||||
} else if (_encoderExist) { // check if encoder exist
|
||||
} else if (encoder_exist_) { // check if encoder exist
|
||||
// enable DTX
|
||||
if (WebRtcAmr_EncoderInit(_encoderInstPtr, 1) < 0) {
|
||||
if (WebRtcAmr_EncoderInit(encoder_inst_ptr_, 1) < 0) {
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = true;
|
||||
dtx_enabled_ = true;
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
@ -235,14 +236,14 @@ WebRtc_Word16 ACMAMR::EnableDTX() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::DisableDTX() {
|
||||
if (!_dtxEnabled) {
|
||||
if (!dtx_enabled_) {
|
||||
return 0;
|
||||
} else if (_encoderExist) { // check if encoder exist
|
||||
} else if (encoder_exist_) { // check if encoder exist
|
||||
// disable DTX
|
||||
if (WebRtcAmr_EncoderInit(_encoderInstPtr, 0) < 0) {
|
||||
if (WebRtcAmr_EncoderInit(encoder_inst_ptr_, 0) < 0) {
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = false;
|
||||
dtx_enabled_ = false;
|
||||
return 0;
|
||||
} else {
|
||||
// encoder doesn't exists, therefore disabling is harmless
|
||||
@ -250,26 +251,26 @@ WebRtc_Word16 ACMAMR::DisableDTX() {
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate);
|
||||
WebRtc_Word16 ACMAMR::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
|
||||
WebRtc_Word16 status = SetBitRateSafe((codec_params->codec_inst).rate);
|
||||
status += (WebRtcAmr_EncoderInit(
|
||||
_encoderInstPtr, ((codecParams->enableDTX) ? 1 : 0)) < 0) ? -1 : 0;
|
||||
encoder_inst_ptr_, ((codec_params->enable_dtx) ? 1 : 0)) < 0) ? -1 : 0;
|
||||
status += (WebRtcAmr_EncodeBitmode(
|
||||
_encoderInstPtr, _encoderPackingFormat) < 0) ? -1 : 0;
|
||||
encoder_inst_ptr_, encoder_packing_format_) < 0) ? -1 : 0;
|
||||
return (status < 0) ? -1 : 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
WebRtc_Word16 status =
|
||||
((WebRtcAmr_DecoderInit(_decoderInstPtr) < 0) ? -1 : 0);
|
||||
status += WebRtcAmr_DecodeBitmode(_decoderInstPtr, _decoderPackingFormat);
|
||||
((WebRtcAmr_DecoderInit(decoder_inst_ptr_) < 0) ? -1 : 0);
|
||||
status += WebRtcAmr_DecodeBitmode(decoder_inst_ptr_, decoder_packing_format_);
|
||||
return (status < 0) ? -1 : 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
// Todo:
|
||||
// log error
|
||||
return -1;
|
||||
@ -278,9 +279,9 @@ WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// "SET_CODEC_PAR" & "SET_AMR_FUNCTION."
|
||||
// Then call NetEQ to add the codec to it's
|
||||
// database.
|
||||
SET_CODEC_PAR((codecDef), kDecoderAMR, codecInst.pltype, _decoderInstPtr,
|
||||
SET_CODEC_PAR((codec_def), kDecoderAMR, codec_inst.pltype, decoder_inst_ptr_,
|
||||
8000);
|
||||
SET_AMR_FUNCTIONS((codecDef));
|
||||
SET_AMR_FUNCTIONS((codec_def));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -289,75 +290,75 @@ ACMGenericCodec* ACMAMR::CreateInstance(void) {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::InternalCreateEncoder() {
|
||||
return WebRtcAmr_CreateEnc(&_encoderInstPtr);
|
||||
return WebRtcAmr_CreateEnc(&encoder_inst_ptr_);
|
||||
}
|
||||
|
||||
void ACMAMR::DestructEncoderSafe() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcAmr_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcAmr_FreeEnc(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
// there is no encoder set the following
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
_encodingMode = -1; // invalid value
|
||||
_encodingRate = 0; // invalid value
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
encoding_mode_ = -1; // invalid value
|
||||
encoding_rate_ = 0; // invalid value
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::InternalCreateDecoder() {
|
||||
return WebRtcAmr_CreateDec(&_decoderInstPtr);
|
||||
return WebRtcAmr_CreateDec(&decoder_inst_ptr_);
|
||||
}
|
||||
|
||||
void ACMAMR::DestructDecoderSafe() {
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcAmr_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcAmr_FreeDec(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
// there is no encoder instance set the followings
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::SetBitRateSafe(const WebRtc_Word32 rate) {
|
||||
switch (rate) {
|
||||
case 4750: {
|
||||
_encodingMode = WEBRTC_AMR_MR475;
|
||||
_encodingRate = 4750;
|
||||
encoding_mode_ = WEBRTC_AMR_MR475;
|
||||
encoding_rate_ = 4750;
|
||||
break;
|
||||
}
|
||||
case 5150: {
|
||||
_encodingMode = WEBRTC_AMR_MR515;
|
||||
_encodingRate = 5150;
|
||||
encoding_mode_ = WEBRTC_AMR_MR515;
|
||||
encoding_rate_ = 5150;
|
||||
break;
|
||||
}
|
||||
case 5900: {
|
||||
_encodingMode = WEBRTC_AMR_MR59;
|
||||
_encodingRate = 5900;
|
||||
encoding_mode_ = WEBRTC_AMR_MR59;
|
||||
encoding_rate_ = 5900;
|
||||
break;
|
||||
}
|
||||
case 6700: {
|
||||
_encodingMode = WEBRTC_AMR_MR67;
|
||||
_encodingRate = 6700;
|
||||
encoding_mode_ = WEBRTC_AMR_MR67;
|
||||
encoding_rate_ = 6700;
|
||||
break;
|
||||
}
|
||||
case 7400: {
|
||||
_encodingMode = WEBRTC_AMR_MR74;
|
||||
_encodingRate = 7400;
|
||||
encoding_mode_ = WEBRTC_AMR_MR74;
|
||||
encoding_rate_ = 7400;
|
||||
break;
|
||||
}
|
||||
case 7950: {
|
||||
_encodingMode = WEBRTC_AMR_MR795;
|
||||
_encodingRate = 7950;
|
||||
encoding_mode_ = WEBRTC_AMR_MR795;
|
||||
encoding_rate_ = 7950;
|
||||
break;
|
||||
}
|
||||
case 10200: {
|
||||
_encodingMode = WEBRTC_AMR_MR102;
|
||||
_encodingRate = 10200;
|
||||
encoding_mode_ = WEBRTC_AMR_MR102;
|
||||
encoding_rate_ = 10200;
|
||||
break;
|
||||
}
|
||||
case 12200: {
|
||||
_encodingMode = WEBRTC_AMR_MR122;
|
||||
_encodingRate = 12200;
|
||||
encoding_mode_ = WEBRTC_AMR_MR122;
|
||||
encoding_rate_ = 12200;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -367,58 +368,57 @@ WebRtc_Word16 ACMAMR::SetBitRateSafe(const WebRtc_Word32 rate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMAMR::InternalDestructEncoderInst(void* ptrInst) {
|
||||
// Free the memory where ptrInst is pointing to
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcAmr_FreeEnc(reinterpret_cast<AMR_encinst_t_*>(ptrInst));
|
||||
void ACMAMR::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
// Free the memory where ptr_inst is pointing to
|
||||
if (ptr_inst != NULL) {
|
||||
WebRtcAmr_FreeEnc(reinterpret_cast<AMR_encinst_t_*>(ptr_inst));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::SetAMREncoderPackingFormat(
|
||||
ACMAMRPackingFormat packingFormat) {
|
||||
if ((packingFormat != AMRBandwidthEfficient) &&
|
||||
(packingFormat != AMROctetAlligned) &&
|
||||
(packingFormat != AMRFileStorage)) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
ACMAMRPackingFormat packing_format) {
|
||||
if ((packing_format != AMRBandwidthEfficient) &&
|
||||
(packing_format != AMROctetAlligned) &&
|
||||
(packing_format != AMRFileStorage)) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Invalid AMR Encoder packing-format.");
|
||||
return -1;
|
||||
} else {
|
||||
if (WebRtcAmr_EncodeBitmode(_encoderInstPtr, packingFormat) < 0) {
|
||||
if (WebRtcAmr_EncodeBitmode(encoder_inst_ptr_, packing_format) < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
_encoderPackingFormat = packingFormat;
|
||||
encoder_packing_format_ = packing_format;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ACMAMRPackingFormat ACMAMR::AMREncoderPackingFormat() const {
|
||||
return _encoderPackingFormat;
|
||||
return encoder_packing_format_;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMR::SetAMRDecoderPackingFormat(
|
||||
ACMAMRPackingFormat packingFormat) {
|
||||
if ((packingFormat != AMRBandwidthEfficient) &&
|
||||
(packingFormat != AMROctetAlligned) &&
|
||||
(packingFormat != AMRFileStorage)) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
ACMAMRPackingFormat packing_format) {
|
||||
if ((packing_format != AMRBandwidthEfficient) &&
|
||||
(packing_format != AMROctetAlligned) &&
|
||||
(packing_format != AMRFileStorage)) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Invalid AMR decoder packing-format.");
|
||||
return -1;
|
||||
} else {
|
||||
if (WebRtcAmr_DecodeBitmode(_decoderInstPtr, packingFormat) < 0) {
|
||||
if (WebRtcAmr_DecodeBitmode(decoder_inst_ptr_, packing_format) < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
_decoderPackingFormat = packingFormat;
|
||||
decoder_packing_format_ = packing_format;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ACMAMRPackingFormat ACMAMR::AMRDecoderPackingFormat() const {
|
||||
return _decoderPackingFormat;
|
||||
return decoder_packing_format_;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
// forward declaration
|
||||
struct AMR_encinst_t_;
|
||||
@ -23,36 +23,37 @@ enum ACMAMRPackingFormat;
|
||||
|
||||
class ACMAMR: public ACMGenericCodec {
|
||||
public:
|
||||
ACMAMR(WebRtc_Word16 codecID);
|
||||
explicit ACMAMR(WebRtc_Word16 codec_id);
|
||||
~ACMAMR();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 SetAMREncoderPackingFormat(
|
||||
const ACMAMRPackingFormat packingFormat);
|
||||
const ACMAMRPackingFormat packing_format);
|
||||
|
||||
ACMAMRPackingFormat AMREncoderPackingFormat() const;
|
||||
|
||||
WebRtc_Word16 SetAMRDecoderPackingFormat(
|
||||
const ACMAMRPackingFormat packingFormat);
|
||||
const ACMAMRPackingFormat packing_format);
|
||||
|
||||
ACMAMRPackingFormat AMRDecoderPackingFormat() const;
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio, WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -62,7 +63,7 @@ class ACMAMR: public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
|
||||
|
||||
@ -70,12 +71,12 @@ class ACMAMR: public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 DisableDTX();
|
||||
|
||||
AMR_encinst_t_* _encoderInstPtr;
|
||||
AMR_decinst_t_* _decoderInstPtr;
|
||||
WebRtc_Word16 _encodingMode;
|
||||
WebRtc_Word16 _encodingRate;
|
||||
ACMAMRPackingFormat _encoderPackingFormat;
|
||||
ACMAMRPackingFormat _decoderPackingFormat;
|
||||
AMR_encinst_t_* encoder_inst_ptr_;
|
||||
AMR_decinst_t_* decoder_inst_ptr_;
|
||||
WebRtc_Word16 encoding_mode_;
|
||||
WebRtc_Word16 encoding_rate_;
|
||||
ACMAMRPackingFormat encoder_packing_format_;
|
||||
ACMAMRPackingFormat decoder_packing_format_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,14 +8,15 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_amrwb.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "audio_coding_module_typedefs.h"
|
||||
#include "rw_lock_wrapper.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_amrwb.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_AMRWB
|
||||
// NOTE! GSM AMR-wb is not included in the open-source package. The
|
||||
@ -25,20 +26,20 @@
|
||||
//
|
||||
// The API in the header file should match the one below.
|
||||
//
|
||||
// int16_t WebRtcAmrWb_CreateEnc(AMRWB_encinst_t_** encInst);
|
||||
// int16_t WebRtcAmrWb_CreateDec(AMRWB_decinst_t_** decInst);
|
||||
// int16_t WebRtcAmrWb_FreeEnc(AMRWB_encinst_t_* encInst);
|
||||
// int16_t WebRtcAmrWb_FreeDec(AMRWB_decinst_t_* decInst);
|
||||
// int16_t WebRtcAmrWb_Encode(AMRWB_encinst_t_* encInst, int16_t* input,
|
||||
// int16_t WebRtcAmrWb_CreateEnc(AMRWB_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcAmrWb_CreateDec(AMRWB_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcAmrWb_FreeEnc(AMRWB_encinst_t_* enc_inst);
|
||||
// int16_t WebRtcAmrWb_FreeDec(AMRWB_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcAmrWb_Encode(AMRWB_encinst_t_* enc_inst, int16_t* input,
|
||||
// int16_t len, int16_t* output, int16_t mode);
|
||||
// int16_t WebRtcAmrWb_EncoderInit(AMRWB_encinst_t_* encInst,
|
||||
// int16_t dtxMode);
|
||||
// int16_t WebRtcAmrWb_EncodeBitmode(AMRWB_encinst_t_* encInst,
|
||||
// int16_t WebRtcAmrWb_EncoderInit(AMRWB_encinst_t_* enc_inst,
|
||||
// int16_t dtx_mode);
|
||||
// int16_t WebRtcAmrWb_EncodeBitmode(AMRWB_encinst_t_* enc_inst,
|
||||
// int format);
|
||||
// int16_t WebRtcAmrWb_Decode(AMRWB_decinst_t_* decInst);
|
||||
// int16_t WebRtcAmrWb_DecodePlc(AMRWB_decinst_t_* decInst);
|
||||
// int16_t WebRtcAmrWb_DecoderInit(AMRWB_decinst_t_* decInst);
|
||||
// int16_t WebRtcAmrWb_DecodeBitmode(AMRWB_decinst_t_* decInst,
|
||||
// int16_t WebRtcAmrWb_Decode(AMRWB_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcAmrWb_DecodePlc(AMRWB_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcAmrWb_DecoderInit(AMRWB_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcAmrWb_DecodeBitmode(AMRWB_decinst_t_* dec_inst,
|
||||
// int format);
|
||||
#include "amrwb_interface.h"
|
||||
#endif
|
||||
@ -46,30 +47,29 @@
|
||||
namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_AMRWB
|
||||
ACMAMRwb::ACMAMRwb(WebRtc_Word16 /* codecID*/)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL),
|
||||
_encodingMode(-1), // invalid value
|
||||
_encodingRate(0), // invalid value
|
||||
_encoderPackingFormat(AMRBandwidthEfficient),
|
||||
_decoderPackingFormat(AMRBandwidthEfficient) {
|
||||
return;
|
||||
ACMAMRwb::ACMAMRwb(WebRtc_Word16 /* codec_id */)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
encoding_mode_(-1), // invalid value
|
||||
encoding_rate_(0), // invalid value
|
||||
encoder_packing_format_(AMRBandwidthEfficient),
|
||||
decoder_packing_format_(AMRBandwidthEfficient) {
|
||||
}
|
||||
|
||||
ACMAMRwb::~ACMAMRwb() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_Word16 ACMAMRwb::InternalEncode(
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -82,17 +82,17 @@ WebRtc_Word16 ACMAMRwb::DisableDTX() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -121,12 +121,12 @@ WebRtc_Word16 ACMAMRwb::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ACMAMRwb::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMAMRwb::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::SetAMRwbEncoderPackingFormat(
|
||||
ACMAMRPackingFormat /* packingFormat */) {
|
||||
ACMAMRPackingFormat /* packing_format */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ ACMAMRPackingFormat ACMAMRwb::AMRwbEncoderPackingFormat() const {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat(
|
||||
ACMAMRPackingFormat /* packingFormat */) {
|
||||
ACMAMRPackingFormat /* packing_format */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -155,78 +155,78 @@ ACMAMRPackingFormat ACMAMRwb::AMRwbDecoderPackingFormat() const {
|
||||
#define AMRWB_MODE_23k 7
|
||||
#define AMRWB_MODE_24k 8
|
||||
|
||||
ACMAMRwb::ACMAMRwb(WebRtc_Word16 codecID)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL),
|
||||
_encodingMode(-1), // invalid value
|
||||
_encodingRate(0) { // invalid value
|
||||
_codecID = codecID;
|
||||
_hasInternalDTX = true;
|
||||
_encoderPackingFormat = AMRBandwidthEfficient;
|
||||
_decoderPackingFormat = AMRBandwidthEfficient;
|
||||
ACMAMRwb::ACMAMRwb(WebRtc_Word16 codec_id)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
encoding_mode_(-1), // invalid value
|
||||
encoding_rate_(0) { // invalid value
|
||||
codec_id_ = codec_id;
|
||||
has_internal_dtx_ = true;
|
||||
encoder_packing_format_ = AMRBandwidthEfficient;
|
||||
decoder_packing_format_ = AMRBandwidthEfficient;
|
||||
return;
|
||||
}
|
||||
|
||||
ACMAMRwb::~ACMAMRwb() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcAmrWb_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcAmrWb_FreeEnc(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcAmrWb_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcAmrWb_FreeDec(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
WebRtc_Word16 vadDecision = 1;
|
||||
WebRtc_Word16 ACMAMRwb::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
WebRtc_Word16 vad_decision = 1;
|
||||
// sanity check, if the rate is set correctly. we might skip this
|
||||
// sanity check. if rate is not set correctly, initialization flag
|
||||
// should be false and should not be here.
|
||||
if ((_encodingMode < AMRWB_MODE_7k) || (_encodingMode > AMRWB_MODE_24k)) {
|
||||
*bitStreamLenByte = 0;
|
||||
if ((encoding_mode_ < AMRWB_MODE_7k) || (encoding_mode_ > AMRWB_MODE_24k)) {
|
||||
*bitstream_len_byte = 0;
|
||||
return -1;
|
||||
}
|
||||
*bitStreamLenByte = WebRtcAmrWb_Encode(_encoderInstPtr,
|
||||
&_inAudio[_inAudioIxRead],
|
||||
_frameLenSmpl,
|
||||
(WebRtc_Word16*) bitStream,
|
||||
_encodingMode);
|
||||
*bitstream_len_byte = WebRtcAmrWb_Encode(encoder_inst_ptr_,
|
||||
&in_audio_[in_audio_ix_read_],
|
||||
frame_len_smpl_,
|
||||
(WebRtc_Word16*)bitstream,
|
||||
encoding_mode_);
|
||||
|
||||
// Update VAD, if internal DTX is used
|
||||
if (_hasInternalDTX && _dtxEnabled) {
|
||||
if (*bitStreamLenByte <= (7 * _frameLenSmpl / 160)) {
|
||||
vadDecision = 0;
|
||||
if (has_internal_dtx_ && dtx_enabled_) {
|
||||
if (*bitstream_len_byte <= (7 * frame_len_smpl_ / 160)) {
|
||||
vad_decision = 0;
|
||||
}
|
||||
for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
|
||||
_vadLabel[n] = vadDecision;
|
||||
vad_label_[n] = vad_decision;
|
||||
}
|
||||
}
|
||||
// increment the read index this tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer
|
||||
_inAudioIxRead += _frameLenSmpl;
|
||||
return *bitStreamLenByte;
|
||||
in_audio_ix_read_ += frame_len_smpl_;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::EnableDTX() {
|
||||
if (_dtxEnabled) {
|
||||
if (dtx_enabled_) {
|
||||
return 0;
|
||||
} else if (_encoderExist) { // check if encoder exist
|
||||
} else if (encoder_exist_) { // check if encoder exist
|
||||
// enable DTX
|
||||
if (WebRtcAmrWb_EncoderInit(_encoderInstPtr, 1) < 0) {
|
||||
if (WebRtcAmrWb_EncoderInit(encoder_inst_ptr_, 1) < 0) {
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = true;
|
||||
dtx_enabled_ = true;
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
@ -234,14 +234,14 @@ WebRtc_Word16 ACMAMRwb::EnableDTX() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::DisableDTX() {
|
||||
if (!_dtxEnabled) {
|
||||
if (!dtx_enabled_) {
|
||||
return 0;
|
||||
} else if (_encoderExist) { // check if encoder exist
|
||||
} else if (encoder_exist_) { // check if encoder exist
|
||||
// disable DTX
|
||||
if (WebRtcAmrWb_EncoderInit(_encoderInstPtr, 0) < 0) {
|
||||
if (WebRtcAmrWb_EncoderInit(encoder_inst_ptr_, 0) < 0) {
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = false;
|
||||
dtx_enabled_ = false;
|
||||
return 0;
|
||||
} else {
|
||||
// encoder doesn't exists, therefore disabling is harmless
|
||||
@ -249,31 +249,32 @@ WebRtc_Word16 ACMAMRwb::DisableDTX() {
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
WebRtc_Word16 ACMAMRwb::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* codec_params) {
|
||||
// sanity check
|
||||
if (_encoderInstPtr == NULL) {
|
||||
if (encoder_inst_ptr_ == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate);
|
||||
WebRtc_Word16 status = SetBitRateSafe((codec_params->codec_inst).rate);
|
||||
status += (WebRtcAmrWb_EncoderInit(
|
||||
_encoderInstPtr, ((codecParams->enableDTX) ? 1 : 0)) < 0) ? -1 : 0;
|
||||
encoder_inst_ptr_, ((codec_params->enable_dtx) ? 1 : 0)) < 0) ? -1 : 0;
|
||||
status += (WebRtcAmrWb_EncodeBitmode(
|
||||
_encoderInstPtr, _encoderPackingFormat) < 0) ? -1 : 0;
|
||||
encoder_inst_ptr_, encoder_packing_format_) < 0) ? -1 : 0;
|
||||
return (status < 0) ? -1 : 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtc_Word16 status = WebRtcAmrWb_DecodeBitmode(_decoderInstPtr,
|
||||
_decoderPackingFormat);
|
||||
status += ((WebRtcAmrWb_DecoderInit(_decoderInstPtr) < 0) ? -1 : 0);
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
WebRtc_Word16 status = WebRtcAmrWb_DecodeBitmode(decoder_inst_ptr_,
|
||||
decoder_packing_format_);
|
||||
status += ((WebRtcAmrWb_DecoderInit(decoder_inst_ptr_) < 0) ? -1 : 0);
|
||||
return (status < 0) ? -1 : 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -281,9 +282,9 @@ WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// "SET_CODEC_PAR" & "SET_AMRWB_FUNCTION."
|
||||
// Then call NetEQ to add the codec to it's
|
||||
// database.
|
||||
SET_CODEC_PAR((codecDef), kDecoderAMRWB, codecInst.pltype, _decoderInstPtr,
|
||||
16000);
|
||||
SET_AMRWB_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderAMRWB, codec_inst.pltype,
|
||||
decoder_inst_ptr_, 16000);
|
||||
SET_AMRWB_FUNCTIONS((codec_def));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -292,80 +293,80 @@ ACMGenericCodec* ACMAMRwb::CreateInstance(void) {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::InternalCreateEncoder() {
|
||||
return WebRtcAmrWb_CreateEnc(&_encoderInstPtr);
|
||||
return WebRtcAmrWb_CreateEnc(&encoder_inst_ptr_);
|
||||
}
|
||||
|
||||
void ACMAMRwb::DestructEncoderSafe() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcAmrWb_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcAmrWb_FreeEnc(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
// there is no encoder set the following
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
_encodingMode = -1; // invalid value
|
||||
_encodingRate = 0;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
encoding_mode_ = -1; // invalid value
|
||||
encoding_rate_ = 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::InternalCreateDecoder() {
|
||||
return WebRtcAmrWb_CreateDec(&_decoderInstPtr);
|
||||
return WebRtcAmrWb_CreateDec(&decoder_inst_ptr_);
|
||||
}
|
||||
|
||||
void ACMAMRwb::DestructDecoderSafe() {
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcAmrWb_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcAmrWb_FreeDec(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
// there is no encoder instance set the followings
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::SetBitRateSafe(const WebRtc_Word32 rate) {
|
||||
switch (rate) {
|
||||
case 7000: {
|
||||
_encodingMode = AMRWB_MODE_7k;
|
||||
_encodingRate = 7000;
|
||||
encoding_mode_ = AMRWB_MODE_7k;
|
||||
encoding_rate_ = 7000;
|
||||
break;
|
||||
}
|
||||
case 9000: {
|
||||
_encodingMode = AMRWB_MODE_9k;
|
||||
_encodingRate = 9000;
|
||||
encoding_mode_ = AMRWB_MODE_9k;
|
||||
encoding_rate_ = 9000;
|
||||
break;
|
||||
}
|
||||
case 12000: {
|
||||
_encodingMode = AMRWB_MODE_12k;
|
||||
_encodingRate = 12000;
|
||||
encoding_mode_ = AMRWB_MODE_12k;
|
||||
encoding_rate_ = 12000;
|
||||
break;
|
||||
}
|
||||
case 14000: {
|
||||
_encodingMode = AMRWB_MODE_14k;
|
||||
_encodingRate = 14000;
|
||||
encoding_mode_ = AMRWB_MODE_14k;
|
||||
encoding_rate_ = 14000;
|
||||
break;
|
||||
}
|
||||
case 16000: {
|
||||
_encodingMode = AMRWB_MODE_16k;
|
||||
_encodingRate = 16000;
|
||||
encoding_mode_ = AMRWB_MODE_16k;
|
||||
encoding_rate_ = 16000;
|
||||
break;
|
||||
}
|
||||
case 18000: {
|
||||
_encodingMode = AMRWB_MODE_18k;
|
||||
_encodingRate = 18000;
|
||||
encoding_mode_ = AMRWB_MODE_18k;
|
||||
encoding_rate_ = 18000;
|
||||
break;
|
||||
}
|
||||
case 20000: {
|
||||
_encodingMode = AMRWB_MODE_20k;
|
||||
_encodingRate = 20000;
|
||||
encoding_mode_ = AMRWB_MODE_20k;
|
||||
encoding_rate_ = 20000;
|
||||
break;
|
||||
}
|
||||
case 23000: {
|
||||
_encodingMode = AMRWB_MODE_23k;
|
||||
_encodingRate = 23000;
|
||||
encoding_mode_ = AMRWB_MODE_23k;
|
||||
encoding_rate_ = 23000;
|
||||
break;
|
||||
}
|
||||
case 24000: {
|
||||
_encodingMode = AMRWB_MODE_24k;
|
||||
_encodingRate = 24000;
|
||||
encoding_mode_ = AMRWB_MODE_24k;
|
||||
encoding_rate_ = 24000;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -375,55 +376,55 @@ WebRtc_Word16 ACMAMRwb::SetBitRateSafe(const WebRtc_Word32 rate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMAMRwb::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcAmrWb_FreeEnc(static_cast<AMRWB_encinst_t_*>(ptrInst));
|
||||
void ACMAMRwb::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
WebRtcAmrWb_FreeEnc(static_cast<AMRWB_encinst_t_*>(ptr_inst));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::SetAMRwbEncoderPackingFormat(
|
||||
ACMAMRPackingFormat packingFormat) {
|
||||
if ((packingFormat != AMRBandwidthEfficient) &&
|
||||
(packingFormat != AMROctetAlligned) &&
|
||||
(packingFormat != AMRFileStorage)) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
ACMAMRPackingFormat packing_format) {
|
||||
if ((packing_format != AMRBandwidthEfficient) &&
|
||||
(packing_format != AMROctetAlligned) &&
|
||||
(packing_format != AMRFileStorage)) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Invalid AMRwb encoder packing-format.");
|
||||
return -1;
|
||||
} else {
|
||||
if (WebRtcAmrWb_EncodeBitmode(_encoderInstPtr, packingFormat) < 0) {
|
||||
if (WebRtcAmrWb_EncodeBitmode(encoder_inst_ptr_, packing_format) < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
_encoderPackingFormat = packingFormat;
|
||||
encoder_packing_format_ = packing_format;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ACMAMRPackingFormat ACMAMRwb::AMRwbEncoderPackingFormat() const {
|
||||
return _encoderPackingFormat;
|
||||
return encoder_packing_format_;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat(
|
||||
ACMAMRPackingFormat packingFormat) {
|
||||
if ((packingFormat != AMRBandwidthEfficient) &&
|
||||
(packingFormat != AMROctetAlligned) &&
|
||||
(packingFormat != AMRFileStorage)) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
ACMAMRPackingFormat packing_format) {
|
||||
if ((packing_format != AMRBandwidthEfficient) &&
|
||||
(packing_format != AMROctetAlligned) &&
|
||||
(packing_format != AMRFileStorage)) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Invalid AMRwb decoder packing-format.");
|
||||
return -1;
|
||||
} else {
|
||||
if (WebRtcAmrWb_DecodeBitmode(_decoderInstPtr, packingFormat) < 0) {
|
||||
if (WebRtcAmrWb_DecodeBitmode(decoder_inst_ptr_, packing_format) < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
_decoderPackingFormat = packingFormat;
|
||||
decoder_packing_format_ = packing_format;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ACMAMRPackingFormat ACMAMRwb::AMRwbDecoderPackingFormat() const {
|
||||
return _decoderPackingFormat;
|
||||
return decoder_packing_format_;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
// forward declaration
|
||||
struct AMRWB_encinst_t_;
|
||||
@ -19,40 +19,39 @@ struct AMRWB_decinst_t_;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
enum ACMAMRPackingFormat;
|
||||
|
||||
class ACMAMRwb: public ACMGenericCodec {
|
||||
public:
|
||||
ACMAMRwb(WebRtc_Word16 codecID);
|
||||
explicit ACMAMRwb(WebRtc_Word16 codec_id);
|
||||
~ACMAMRwb();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams* codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams* codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams* codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams* codec_params);
|
||||
|
||||
WebRtc_Word16 SetAMRwbEncoderPackingFormat(
|
||||
const ACMAMRPackingFormat packingFormat);
|
||||
const ACMAMRPackingFormat packing_format);
|
||||
|
||||
ACMAMRPackingFormat AMRwbEncoderPackingFormat() const;
|
||||
|
||||
WebRtc_Word16 SetAMRwbDecoderPackingFormat(
|
||||
const ACMAMRPackingFormat packingFormat);
|
||||
const ACMAMRPackingFormat packing_format);
|
||||
|
||||
ACMAMRPackingFormat AMRwbDecoderPackingFormat() const;
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio, WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -62,7 +61,7 @@ class ACMAMRwb: public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
|
||||
|
||||
@ -70,13 +69,13 @@ class ACMAMRwb: public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 DisableDTX();
|
||||
|
||||
AMRWB_encinst_t_* _encoderInstPtr;
|
||||
AMRWB_decinst_t_* _decoderInstPtr;
|
||||
AMRWB_encinst_t_* encoder_inst_ptr_;
|
||||
AMRWB_decinst_t_* decoder_inst_ptr_;
|
||||
|
||||
WebRtc_Word16 _encodingMode;
|
||||
WebRtc_Word16 _encodingRate;
|
||||
ACMAMRPackingFormat _encoderPackingFormat;
|
||||
ACMAMRPackingFormat _decoderPackingFormat;
|
||||
WebRtc_Word16 encoding_mode_;
|
||||
WebRtc_Word16 encoding_rate_;
|
||||
ACMAMRPackingFormat encoder_packing_format_;
|
||||
ACMAMRPackingFormat decoder_packing_format_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,13 +8,13 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "acm_celt.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
// TODO(tlegrand): Add full paths.
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_celt.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_CELT
|
||||
// NOTE! Celt is not included in the open-source package. Modify this file or
|
||||
@ -26,7 +26,7 @@ namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_CELT
|
||||
|
||||
ACMCELT::ACMCELT(int16_t /* codecID */)
|
||||
ACMCELT::ACMCELT(int16_t /* codec_id */)
|
||||
: enc_inst_ptr_(NULL),
|
||||
dec_inst_ptr_(NULL),
|
||||
sampling_freq_(0),
|
||||
@ -40,29 +40,29 @@ ACMCELT::~ACMCELT() {
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t ACMCELT::InternalEncode(uint8_t* /* bitStream */,
|
||||
int16_t* /* bitStreamLenByte */) {
|
||||
int16_t ACMCELT::InternalEncode(uint8_t* /* bitstream */,
|
||||
int16_t* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int16_t ACMCELT::DecodeSafe(uint8_t* /* bitStream */,
|
||||
int16_t /* bitStreamLenByte */,
|
||||
int16_t ACMCELT::DecodeSafe(uint8_t* /* bitstream */,
|
||||
int16_t /* bitstream_len_byte */,
|
||||
int16_t* /* audio */,
|
||||
int16_t* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
int16_t* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int16_t ACMCELT::InternalInitEncoder(WebRtcACMCodecParams* /* codecParams */) {
|
||||
int16_t ACMCELT::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int16_t ACMCELT::InternalInitDecoder(WebRtcACMCodecParams* /* codecParams */) {
|
||||
int16_t ACMCELT::InternalInitDecoder(WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t ACMCELT::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
int32_t ACMCELT::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ void ACMCELT::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMCELT::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMCELT::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ void ACMCELT::SplitStereoPacket(uint8_t* /*payload*/,
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
|
||||
ACMCELT::ACMCELT(int16_t codecID)
|
||||
ACMCELT::ACMCELT(int16_t codec_id)
|
||||
: enc_inst_ptr_(NULL),
|
||||
dec_inst_ptr_(NULL),
|
||||
sampling_freq_(32000), // Default sampling frequency.
|
||||
@ -111,7 +111,7 @@ ACMCELT::ACMCELT(int16_t codecID)
|
||||
channels_(1), // Default send mono.
|
||||
dec_channels_(1) { // Default receive mono.
|
||||
// TODO(tlegrand): remove later when ACMGenericCodec has a new constructor.
|
||||
_codecID = codecID;
|
||||
codec_id_ = codec_id;
|
||||
|
||||
return;
|
||||
}
|
||||
@ -128,50 +128,51 @@ ACMCELT::~ACMCELT() {
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t ACMCELT::InternalEncode(uint8_t* bitStream, int16_t* bitStreamLenByte) {
|
||||
*bitStreamLenByte = 0;
|
||||
int16_t ACMCELT::InternalEncode(uint8_t* bitstream,
|
||||
int16_t* bitstream_len_byte) {
|
||||
*bitstream_len_byte = 0;
|
||||
|
||||
// Call Encoder.
|
||||
*bitStreamLenByte = WebRtcCelt_Encode(enc_inst_ptr_,
|
||||
&_inAudio[_inAudioIxRead],
|
||||
bitStream);
|
||||
*bitstream_len_byte = WebRtcCelt_Encode(enc_inst_ptr_,
|
||||
&in_audio_[in_audio_ix_read_],
|
||||
bitstream);
|
||||
|
||||
// Increment the read index this tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer.
|
||||
_inAudioIxRead += _frameLenSmpl * channels_;
|
||||
in_audio_ix_read_ += frame_len_smpl_ * channels_;
|
||||
|
||||
if (*bitStreamLenByte < 0) {
|
||||
if (*bitstream_len_byte < 0) {
|
||||
// Error reported from the encoder.
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalEncode: Encode error for Celt");
|
||||
*bitStreamLenByte = 0;
|
||||
*bitstream_len_byte = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return *bitStreamLenByte;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
int16_t ACMCELT::DecodeSafe(uint8_t* /* bitStream */,
|
||||
int16_t /* bitStreamLenByte */,
|
||||
int16_t ACMCELT::DecodeSafe(uint8_t* /* bitstream */,
|
||||
int16_t /* bitstream_len_byte */,
|
||||
int16_t* /* audio */,
|
||||
int16_t* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
int16_t* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16_t ACMCELT::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
int16_t ACMCELT::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
|
||||
// Set bitrate and check that it is within the valid range.
|
||||
int16_t status = SetBitRateSafe((codecParams->codecInstant).rate);
|
||||
int16_t status = SetBitRateSafe((codec_params->codec_inst).rate);
|
||||
if (status < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// If number of channels changed we need to re-create memory.
|
||||
if (codecParams->codecInstant.channels != channels_) {
|
||||
if (codec_params->codec_inst.channels != channels_) {
|
||||
WebRtcCelt_FreeEnc(enc_inst_ptr_);
|
||||
enc_inst_ptr_ = NULL;
|
||||
// Store new number of channels.
|
||||
channels_ = codecParams->codecInstant.channels;
|
||||
channels_ = codec_params->codec_inst.channels;
|
||||
if (WebRtcCelt_CreateEnc(&enc_inst_ptr_, channels_) < 0) {
|
||||
return -1;
|
||||
}
|
||||
@ -185,13 +186,13 @@ int16_t ACMCELT::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
}
|
||||
}
|
||||
|
||||
int16_t ACMCELT::InternalInitDecoder(WebRtcACMCodecParams* codecParams) {
|
||||
int16_t ACMCELT::InternalInitDecoder(WebRtcACMCodecParams* codec_params) {
|
||||
// If number of channels changed we need to re-create memory.
|
||||
if (codecParams->codecInstant.channels != dec_channels_) {
|
||||
if (codec_params->codec_inst.channels != dec_channels_) {
|
||||
WebRtcCelt_FreeDec(dec_inst_ptr_);
|
||||
dec_inst_ptr_ = NULL;
|
||||
// Store new number of channels.
|
||||
dec_channels_ = codecParams->codecInstant.channels;
|
||||
dec_channels_ = codec_params->codec_inst.channels;
|
||||
if (WebRtcCelt_CreateDec(&dec_inst_ptr_, dec_channels_) < 0) {
|
||||
return -1;
|
||||
}
|
||||
@ -199,22 +200,22 @@ int16_t ACMCELT::InternalInitDecoder(WebRtcACMCodecParams* codecParams) {
|
||||
|
||||
// Initiate decoder, both master and slave parts.
|
||||
if (WebRtcCelt_DecoderInit(dec_inst_ptr_) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalInitDecoder: init decoder failed for Celt.");
|
||||
return -1;
|
||||
}
|
||||
if (WebRtcCelt_DecoderInitSlave(dec_inst_ptr_) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalInitDecoder: init decoder failed for Celt.");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ACMCELT::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
int32_t ACMCELT::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"CodecDef: Decoder uninitialized for Celt");
|
||||
return -1;
|
||||
}
|
||||
@ -223,20 +224,20 @@ int32_t ACMCELT::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// "SET_CODEC_PAR" and "SET_CELT_FUNCTIONS" or "SET_CELTSLAVE_FUNCTIONS".
|
||||
// Then call NetEQ to add the codec to it's
|
||||
// database.
|
||||
if (codecInst.channels == 1) {
|
||||
SET_CODEC_PAR(codecDef, kDecoderCELT_32, codecInst.pltype, dec_inst_ptr_,
|
||||
if (codec_inst.channels == 1) {
|
||||
SET_CODEC_PAR(codec_def, kDecoderCELT_32, codec_inst.pltype, dec_inst_ptr_,
|
||||
32000);
|
||||
} else {
|
||||
SET_CODEC_PAR(codecDef, kDecoderCELT_32_2ch, codecInst.pltype,
|
||||
SET_CODEC_PAR(codec_def, kDecoderCELT_32_2ch, codec_inst.pltype,
|
||||
dec_inst_ptr_, 32000);
|
||||
}
|
||||
|
||||
// If this is the master of NetEQ, regular decoder will be added, otherwise
|
||||
// the slave decoder will be used.
|
||||
if (_isMaster) {
|
||||
SET_CELT_FUNCTIONS(codecDef);
|
||||
if (is_master_) {
|
||||
SET_CELT_FUNCTIONS(codec_def);
|
||||
} else {
|
||||
SET_CELTSLAVE_FUNCTIONS(codecDef);
|
||||
SET_CELTSLAVE_FUNCTIONS(codec_def);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -246,18 +247,18 @@ ACMGenericCodec* ACMCELT::CreateInstance(void) {
|
||||
}
|
||||
|
||||
int16_t ACMCELT::InternalCreateEncoder() {
|
||||
if (WebRtcCelt_CreateEnc(&enc_inst_ptr_, _noChannels) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (WebRtcCelt_CreateEnc(&enc_inst_ptr_, num_channels_) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateEncoder: create encoder failed for Celt");
|
||||
return -1;
|
||||
}
|
||||
channels_ = _noChannels;
|
||||
channels_ = num_channels_;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMCELT::DestructEncoderSafe() {
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
if (enc_inst_ptr_ != NULL) {
|
||||
WebRtcCelt_FreeEnc(enc_inst_ptr_);
|
||||
enc_inst_ptr_ = NULL;
|
||||
@ -266,7 +267,7 @@ void ACMCELT::DestructEncoderSafe() {
|
||||
|
||||
int16_t ACMCELT::InternalCreateDecoder() {
|
||||
if (WebRtcCelt_CreateDec(&dec_inst_ptr_, dec_channels_) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateDecoder: create decoder failed for Celt");
|
||||
return -1;
|
||||
}
|
||||
@ -275,17 +276,17 @@ int16_t ACMCELT::InternalCreateDecoder() {
|
||||
}
|
||||
|
||||
void ACMCELT::DestructDecoderSafe() {
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
if (dec_inst_ptr_ != NULL) {
|
||||
WebRtcCelt_FreeDec(dec_inst_ptr_);
|
||||
dec_inst_ptr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ACMCELT::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcCelt_FreeEnc(static_cast<CELT_encinst_t*>(ptrInst));
|
||||
void ACMCELT::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
WebRtcCelt_FreeEnc(static_cast<CELT_encinst_t*>(ptr_inst));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -304,13 +305,13 @@ int16_t ACMCELT::SetBitRateSafe(const int32_t rate) {
|
||||
if (WebRtcCelt_EncoderInit(enc_inst_ptr_, channels_, bitrate_) >= 0) {
|
||||
return 0;
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"SetBitRateSafe: Failed to initiate Celt with rate %d",
|
||||
rate);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"SetBitRateSafe: Invalid rate Celt, %d", rate);
|
||||
return -1;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CELT_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CELT_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
// forward declaration
|
||||
struct CELT_encinst_t_;
|
||||
@ -21,29 +21,29 @@ namespace webrtc {
|
||||
|
||||
class ACMCELT : public ACMGenericCodec {
|
||||
public:
|
||||
ACMCELT(int16_t codecID);
|
||||
explicit ACMCELT(int16_t codec_id);
|
||||
~ACMCELT();
|
||||
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
int16_t InternalEncode(uint8_t* bitstream, int16_t* bitStreamLenByte);
|
||||
int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte);
|
||||
|
||||
int16_t InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
int16_t InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
int16_t InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
int16_t InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
|
||||
WebRtc_Word16 DecodeSafe(
|
||||
uint8_t* /* bitStream */,
|
||||
int16_t /* bitStreamLenByte */,
|
||||
uint8_t* /* bitstream */,
|
||||
int16_t /* bitstream_len_byte */,
|
||||
int16_t* /* audio */,
|
||||
int16_t* /* audioSamples */,
|
||||
int16_t* /* audio_samples */,
|
||||
// TODO(leozwang): use int8_t here when WebRtc_Word8 is properly typed.
|
||||
// http://code.google.com/p/webrtc/issues/detail?id=311
|
||||
WebRtc_Word8* /* speechType */);
|
||||
WebRtc_Word8* /* speech_type */);
|
||||
|
||||
int32_t CodecDef(WebRtcNetEQ_CodecDef& codecDef, const CodecInst& codecInst);
|
||||
int32_t CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -53,7 +53,7 @@ class ACMCELT : public ACMGenericCodec {
|
||||
|
||||
int16_t InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
bool IsTrueStereoCodec();
|
||||
|
||||
|
@ -8,33 +8,34 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_cng.h"
|
||||
#include "acm_codec_database.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_cng.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_cng.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
ACMCNG::ACMCNG(WebRtc_Word16 codecID) {
|
||||
_encoderInstPtr = NULL;
|
||||
_decoderInstPtr = NULL;
|
||||
_codecID = codecID;
|
||||
_sampFreqHz = ACMCodecDB::CodecFreq(_codecID);
|
||||
ACMCNG::ACMCNG(WebRtc_Word16 codec_id) {
|
||||
encoder_inst_ptr_ = NULL;
|
||||
decoder_inst_ptr_ = NULL;
|
||||
codec_id_ = codec_id;
|
||||
samp_freq_hz_ = ACMCodecDB::CodecFreq(codec_id_);
|
||||
return;
|
||||
}
|
||||
|
||||
ACMCNG::~ACMCNG() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcCng_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcCng_FreeEnc(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcCng_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcCng_FreeDec(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -43,16 +44,16 @@ ACMCNG::~ACMCNG() {
|
||||
// should not be called normally
|
||||
// instead the following function is called from inside
|
||||
// ACMGenericCodec::ProcessFrameVADDTX
|
||||
WebRtc_Word16 ACMCNG::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_Word16 ACMCNG::InternalEncode(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMCNG::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMCNG::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -61,18 +62,18 @@ WebRtc_Word16 ACMCNG::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
// instead the following function is called from inside
|
||||
// ACMGenericCodec::ProcessFrameVADDTX
|
||||
WebRtc_Word16 ACMCNG::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMCNG::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
return WebRtcCng_InitDec(_decoderInstPtr);
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return WebRtcCng_InitDec(decoder_inst_ptr_);
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMCNG::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WebRtc_Word32 ACMCNG::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
// TODO(tlegrand): log error
|
||||
return -1;
|
||||
}
|
||||
@ -81,11 +82,11 @@ WebRtc_Word32 ACMCNG::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// Then return the structure back to NetEQ to add the codec to it's
|
||||
// database.
|
||||
|
||||
if (_sampFreqHz == 8000 || _sampFreqHz == 16000 || _sampFreqHz == 32000 ||
|
||||
_sampFreqHz == 48000) {
|
||||
SET_CODEC_PAR((codecDef), kDecoderCNG, codecInst.pltype,
|
||||
_decoderInstPtr, _sampFreqHz);
|
||||
SET_CNG_FUNCTIONS((codecDef));
|
||||
if (samp_freq_hz_ == 8000 || samp_freq_hz_ == 16000 ||
|
||||
samp_freq_hz_ == 32000 || samp_freq_hz_ == 48000) {
|
||||
SET_CODEC_PAR((codec_def), kDecoderCNG, codec_inst.pltype,
|
||||
decoder_inst_ptr_, samp_freq_hz_);
|
||||
SET_CNG_FUNCTIONS((codec_def));
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
@ -97,8 +98,8 @@ ACMGenericCodec* ACMCNG::CreateInstance(void) {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMCNG::InternalCreateEncoder() {
|
||||
if (WebRtcCng_CreateEnc(&_encoderInstPtr) < 0) {
|
||||
_encoderInstPtr = NULL;
|
||||
if (WebRtcCng_CreateEnc(&encoder_inst_ptr_) < 0) {
|
||||
encoder_inst_ptr_ = NULL;
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
@ -106,17 +107,17 @@ WebRtc_Word16 ACMCNG::InternalCreateEncoder() {
|
||||
}
|
||||
|
||||
void ACMCNG::DestructEncoderSafe() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcCng_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcCng_FreeEnc(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMCNG::InternalCreateDecoder() {
|
||||
if (WebRtcCng_CreateDec(&_decoderInstPtr) < 0) {
|
||||
_decoderInstPtr = NULL;
|
||||
if (WebRtcCng_CreateDec(&decoder_inst_ptr_) < 0) {
|
||||
decoder_inst_ptr_ = NULL;
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
@ -124,17 +125,17 @@ WebRtc_Word16 ACMCNG::InternalCreateDecoder() {
|
||||
}
|
||||
|
||||
void ACMCNG::DestructDecoderSafe() {
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcCng_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcCng_FreeDec(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
}
|
||||
|
||||
void ACMCNG::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcCng_FreeEnc(static_cast<CNG_enc_inst*>(ptrInst));
|
||||
void ACMCNG::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
WebRtcCng_FreeEnc(static_cast<CNG_enc_inst*>(ptr_inst));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
// forward declaration
|
||||
struct WebRtcCngEncInst;
|
||||
@ -21,26 +21,27 @@ namespace webrtc {
|
||||
|
||||
class ACMCNG: public ACMGenericCodec {
|
||||
public:
|
||||
ACMCNG(WebRtc_Word16 codecID);
|
||||
explicit ACMCNG(WebRtc_Word16 codec_id);
|
||||
~ACMCNG();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio, WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -50,7 +51,7 @@ protected:
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
WebRtc_Word16 EnableDTX() {
|
||||
return -1;
|
||||
@ -60,9 +61,9 @@ protected:
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtcCngEncInst* _encoderInstPtr;
|
||||
WebRtcCngDecInst* _decoderInstPtr;
|
||||
WebRtc_UWord16 _sampFreqHz;
|
||||
WebRtcCngEncInst* encoder_inst_ptr_;
|
||||
WebRtcCngDecInst* decoder_inst_ptr_;
|
||||
WebRtc_UWord16 samp_freq_hz_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -15,90 +15,90 @@
|
||||
|
||||
// TODO(tlegrand): Change constant input pointers in all functions to constant
|
||||
// references, where appropriate.
|
||||
#include "acm_codec_database.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "acm_common_defs.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
// Includes needed to create the codecs.
|
||||
// G.711, PCM mu-law and A-law.
|
||||
#include "acm_pcma.h"
|
||||
#include "acm_pcmu.h"
|
||||
#include "g711_interface.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_pcma.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_pcmu.h"
|
||||
// CNG.
|
||||
#include "acm_cng.h"
|
||||
#include "webrtc_cng.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_cng.h"
|
||||
// NetEQ.
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#ifdef WEBRTC_CODEC_ISAC
|
||||
#include "acm_isac.h"
|
||||
#include "acm_isac_macros.h"
|
||||
#include "isac.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/isac/main/interface/isac.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_isac.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_isac_macros.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_ISACFX
|
||||
#include "acm_isac.h"
|
||||
#include "acm_isac_macros.h"
|
||||
#include "isacfix.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_isac.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_isac_macros.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_PCM16
|
||||
#include "pcm16b.h"
|
||||
#include "acm_pcm16b.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_pcm16b.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_ILBC
|
||||
#include "acm_ilbc.h"
|
||||
#include "ilbc.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_ilbc.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_AMR
|
||||
#include "acm_amr.h"
|
||||
#include "amr_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_amr.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_AMRWB
|
||||
#include "acm_amrwb.h"
|
||||
#include "amrwb_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_amrwb.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_CELT
|
||||
#include "acm_celt.h"
|
||||
#include "celt_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_celt.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_G722
|
||||
#include "acm_g722.h"
|
||||
#include "g722_interface.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_g722.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_G722_1
|
||||
#include "acm_g7221.h"
|
||||
#include "g7221_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_g7221.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_G722_1C
|
||||
#include "acm_g7221c.h"
|
||||
#include "g7221c_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_g7221c.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_G729
|
||||
#include "acm_g729.h"
|
||||
#include "g729_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_g729.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_G729_1
|
||||
#include "acm_g7291.h"
|
||||
#include "g7291_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_g7291.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_GSMFR
|
||||
#include "acm_gsmfr.h"
|
||||
#include "gsmfr_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_gsmfr.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
#include "acm_opus.h"
|
||||
#include "modules/audio_coding/codecs/opus/interface/opus_interface.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_opus.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_SPEEX
|
||||
#include "acm_speex.h"
|
||||
#include "speex_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_speex.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_AVT
|
||||
#include "acm_dtmf_playout.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_dtmf_playout.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_RED
|
||||
#include "acm_red.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_red.h"
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
@ -117,10 +117,10 @@ const int kDynamicPayloadtypes[ACMCodecDB::kMaxNumCodecs] = {
|
||||
// Each entry needs the following parameters in the given order:
|
||||
// payload type, name, sampling frequency, packet size in samples,
|
||||
// number of channels, and default rate.
|
||||
#if (defined(WEBRTC_CODEC_AMR) || defined(WEBRTC_CODEC_AMRWB) \
|
||||
|| defined(WEBRTC_CODEC_CELT) || defined(WEBRTC_CODEC_G722_1) \
|
||||
|| defined(WEBRTC_CODEC_G722_1C) || defined(WEBRTC_CODEC_G729_1) \
|
||||
|| defined(WEBRTC_CODEC_PCM16) || defined(WEBRTC_CODEC_SPEEX))
|
||||
#if (defined(WEBRTC_CODEC_AMR) || defined(WEBRTC_CODEC_AMRWB) || \
|
||||
defined(WEBRTC_CODEC_CELT) || defined(WEBRTC_CODEC_G722_1) || \
|
||||
defined(WEBRTC_CODEC_G722_1C) || defined(WEBRTC_CODEC_G729_1) || \
|
||||
defined(WEBRTC_CODEC_PCM16) || defined(WEBRTC_CODEC_SPEEX))
|
||||
static int count_database = 0;
|
||||
#endif
|
||||
|
||||
|
@ -16,9 +16,9 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CODEC_DATABASE_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CODEC_DATABASE_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "common_types.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
@ -13,10 +13,10 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "audio_coding_module_typedefs.h"
|
||||
#include "common_types.h"
|
||||
#include "engine_configurations.h"
|
||||
#include "typedefs.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
// Checks for enabled codecs, we prevent enabling codecs which are not
|
||||
// compatible.
|
||||
@ -78,38 +78,38 @@ enum WebRtcACMEncodingType {
|
||||
// A structure which contains codec parameters. For instance, used when
|
||||
// initializing encoder and decoder.
|
||||
//
|
||||
// codecInstant : c.f. common_types.h
|
||||
// enableDTX : set true to enable DTX. If codec does not have
|
||||
// codec_inst: c.f. common_types.h
|
||||
// enable_dtx: set true to enable DTX. If codec does not have
|
||||
// internal DTX, this will enable VAD.
|
||||
// enableVAD : set true to enable VAD.
|
||||
// vadMode : VAD mode, c.f. audio_coding_module_typedefs.h
|
||||
// enable_vad: set true to enable VAD.
|
||||
// vad_mode: VAD mode, c.f. audio_coding_module_typedefs.h
|
||||
// for possible values.
|
||||
struct WebRtcACMCodecParams {
|
||||
CodecInst codecInstant;
|
||||
bool enableDTX;
|
||||
bool enableVAD;
|
||||
ACMVADMode vadMode;
|
||||
CodecInst codec_inst;
|
||||
bool enable_dtx;
|
||||
bool enable_vad;
|
||||
ACMVADMode vad_mode;
|
||||
};
|
||||
|
||||
// A structure that encapsulates audio buffer and related parameters
|
||||
// used for synchronization of audio of two ACMs.
|
||||
//
|
||||
// inAudio : same as ACMGenericCodec::_inAudio
|
||||
// inAudioIxRead : same as ACMGenericCodec::_inAudioIxRead
|
||||
// inAudioIxWrite : same as ACMGenericCodec::_inAudioIxWrite
|
||||
// inTimestamp : same as ACMGenericCodec::_inTimestamp
|
||||
// inTimestampIxWrite : same as ACMGenericCodec::_inTImestampIxWrite
|
||||
// lastTimestamp : same as ACMGenericCodec::_lastTimestamp
|
||||
// lastInTimestamp : same as AudioCodingModuleImpl::_lastInTimestamp
|
||||
// in_audio: same as ACMGenericCodec::in_audio_
|
||||
// in_audio_ix_read: same as ACMGenericCodec::in_audio_ix_read_
|
||||
// in_audio_ix_write: same as ACMGenericCodec::in_audio_ix_write_
|
||||
// in_timestamp: same as ACMGenericCodec::in_timestamp_
|
||||
// in_timestamp_ix_write: same as ACMGenericCodec::in_timestamp_ix_write_
|
||||
// last_timestamp: same as ACMGenericCodec::last_timestamp_
|
||||
// last_in_timestamp: same as AudioCodingModuleImpl::last_in_timestamp_
|
||||
//
|
||||
struct WebRtcACMAudioBuff {
|
||||
WebRtc_Word16 inAudio[AUDIO_BUFFER_SIZE_W16];
|
||||
WebRtc_Word16 inAudioIxRead;
|
||||
WebRtc_Word16 inAudioIxWrite;
|
||||
WebRtc_UWord32 inTimestamp[TIMESTAMP_BUFFER_SIZE_W32];
|
||||
WebRtc_Word16 inTimestampIxWrite;
|
||||
WebRtc_UWord32 lastTimestamp;
|
||||
WebRtc_UWord32 lastInTimestamp;
|
||||
WebRtc_Word16 in_audio[AUDIO_BUFFER_SIZE_W16];
|
||||
WebRtc_Word16 in_audio_ix_read;
|
||||
WebRtc_Word16 in_audio_ix_write;
|
||||
WebRtc_UWord32 in_timestamp[TIMESTAMP_BUFFER_SIZE_W32];
|
||||
WebRtc_Word16 in_timestamp_ix_write;
|
||||
WebRtc_UWord32 last_timestamp;
|
||||
WebRtc_UWord32 last_in_timestamp;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,8 +8,9 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_dtmf_detection.h"
|
||||
#include "audio_coding_module_typedefs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_dtmf_detection.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -26,10 +27,10 @@ WebRtc_Word16 ACMDTMFDetection::Disable() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMDTMFDetection::Detect(
|
||||
const WebRtc_Word16* /* inAudioBuff */,
|
||||
const WebRtc_UWord16 /* inBuffLenWord16 */,
|
||||
const WebRtc_Word32 /* inFreqHz */,
|
||||
bool& /* toneDetected */,
|
||||
const WebRtc_Word16* /* in_audio_buff */,
|
||||
const WebRtc_UWord16 /* in_buff_len_word16 */,
|
||||
const WebRtc_Word32 /* in_freq_hz */,
|
||||
bool& /* tone_detected */,
|
||||
WebRtc_Word16& /* tone */) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -11,9 +11,9 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_
|
||||
|
||||
#include "acm_resampler.h"
|
||||
#include "audio_coding_module_typedefs.h"
|
||||
#include "typedefs.h"
|
||||
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_resampler.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -23,14 +23,14 @@ class ACMDTMFDetection {
|
||||
~ACMDTMFDetection();
|
||||
WebRtc_Word16 Enable(ACMCountries cpt = ACMDisableCountryDetection);
|
||||
WebRtc_Word16 Disable();
|
||||
WebRtc_Word16 Detect(const WebRtc_Word16* inAudioBuff,
|
||||
const WebRtc_UWord16 inBuffLenWord16,
|
||||
const WebRtc_Word32 inFreqHz,
|
||||
bool& toneDetected,
|
||||
WebRtc_Word16 Detect(const WebRtc_Word16* in_audio_buff,
|
||||
const WebRtc_UWord16 in_buff_len_word16,
|
||||
const WebRtc_Word32 in_freq_hz,
|
||||
bool& tone_detected,
|
||||
WebRtc_Word16& tone);
|
||||
|
||||
private:
|
||||
ACMResampler _resampler;
|
||||
ACMResampler resampler_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,19 +8,20 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_dtmf_playout.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_dtmf_playout.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_AVT
|
||||
|
||||
ACMDTMFPlayout::ACMDTMFPlayout(
|
||||
WebRtc_Word16 /* codecID */) {
|
||||
WebRtc_Word16 /* codec_id */) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -29,31 +30,32 @@ ACMDTMFPlayout::~ACMDTMFPlayout() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMDTMFPlayout::InternalEncode(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMDTMFPlayout::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMDTMFPlayout::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMDTMFPlayout::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMDTMFPlayout::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -69,7 +71,7 @@ WebRtc_Word16 ACMDTMFPlayout::InternalCreateDecoder() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -83,8 +85,8 @@ void ACMDTMFPlayout::DestructDecoderSafe() {
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
|
||||
ACMDTMFPlayout::ACMDTMFPlayout(WebRtc_Word16 codecID) {
|
||||
_codecID = codecID;
|
||||
ACMDTMFPlayout::ACMDTMFPlayout(WebRtc_Word16 codec_id) {
|
||||
codec_id_ = codec_id;
|
||||
}
|
||||
|
||||
ACMDTMFPlayout::~ACMDTMFPlayout() {
|
||||
@ -92,41 +94,42 @@ ACMDTMFPlayout::~ACMDTMFPlayout() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMDTMFPlayout::InternalEncode(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMDTMFPlayout::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
// This codec does not need initialization,
|
||||
// DTMFPlayout has no instance
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMDTMFPlayout::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
// This codec does not need initialization,
|
||||
// DTMFPlayout has no instance
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMDTMFPlayout::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
WebRtc_Word32 ACMDTMFPlayout::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
// Fill up the structure by calling
|
||||
// "SET_CODEC_PAR" & "SET_AVT_FUNCTION."
|
||||
// Then call NetEQ to add the codec to it's
|
||||
// database.
|
||||
SET_CODEC_PAR((codecDef), kDecoderAVT, codecInst.pltype, NULL, 8000);
|
||||
SET_AVT_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderAVT, codec_inst.pltype, NULL, 8000);
|
||||
SET_AVT_FUNCTIONS((codec_def));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -144,7 +147,7 @@ WebRtc_Word16 ACMDTMFPlayout::InternalCreateDecoder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
// DTMFPlayout has no instance
|
||||
return;
|
||||
}
|
||||
|
@ -11,32 +11,33 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class ACMDTMFPlayout: public ACMGenericCodec {
|
||||
public:
|
||||
ACMDTMFPlayout(WebRtc_Word16 codecID);
|
||||
explicit ACMDTMFPlayout(WebRtc_Word16 codec_id);
|
||||
~ACMDTMFPlayout();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio, WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -46,7 +47,7 @@ class ACMDTMFPlayout: public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,64 +8,63 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_g722.h"
|
||||
#include "acm_codec_database.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "g722_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_g722.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_G722
|
||||
|
||||
ACMG722::ACMG722(WebRtc_Word16 /* codecID */)
|
||||
: _ptrEncStr(NULL),
|
||||
_ptrDecStr(NULL),
|
||||
_encoderInstPtr(NULL),
|
||||
_encoderInstPtrRight(NULL),
|
||||
_decoderInstPtr(NULL) {
|
||||
return;
|
||||
}
|
||||
ACMG722::ACMG722(WebRtc_Word16 /* codec_id */)
|
||||
: ptr_enc_str_(NULL),
|
||||
ptr_dec_str_(NULL),
|
||||
encoder_inst_ptr_(NULL),
|
||||
encoder_inst_ptr_right_(NULL),
|
||||
decoder_inst_ptr_(NULL) {}
|
||||
|
||||
ACMG722::~ACMG722() {
|
||||
return;
|
||||
}
|
||||
ACMG722::~ACMG722() {}
|
||||
|
||||
WebRtc_Word32 ACMG722::Add10MsDataSafe(const WebRtc_UWord32 /* timestamp */,
|
||||
WebRtc_Word32 ACMG722::Add10MsDataSafe(
|
||||
const WebRtc_UWord32 /* timestamp */,
|
||||
const WebRtc_Word16* /* data */,
|
||||
const WebRtc_UWord16 /* lengthSmpl */,
|
||||
const WebRtc_UWord8 /* audioChannel */) {
|
||||
const WebRtc_UWord16 /* length_smpl */,
|
||||
const WebRtc_UWord8 /* audio_channel */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_Word16 ACMG722::InternalEncode(
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -89,7 +88,7 @@ void ACMG722::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMG722::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMG722::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -101,157 +100,159 @@ void ACMG722::SplitStereoPacket(uint8_t* /*payload*/,
|
||||
// Encoder and decoder memory
|
||||
struct ACMG722EncStr {
|
||||
G722EncInst* inst; // instance for left channel in case of stereo
|
||||
G722EncInst* instRight; // instance for right channel in case of stereo
|
||||
G722EncInst* inst_right; // instance for right channel in case of stereo
|
||||
};
|
||||
struct ACMG722DecStr {
|
||||
G722DecInst* inst; // instance for left channel in case of stereo
|
||||
G722DecInst* instRight; // instance for right channel in case of stereo
|
||||
G722DecInst* inst_right; // instance for right channel in case of stereo
|
||||
};
|
||||
|
||||
ACMG722::ACMG722(WebRtc_Word16 codecID)
|
||||
: _encoderInstPtr(NULL),
|
||||
_encoderInstPtrRight(NULL),
|
||||
_decoderInstPtr(NULL) {
|
||||
ACMG722::ACMG722(WebRtc_Word16 codec_id)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
encoder_inst_ptr_right_(NULL),
|
||||
decoder_inst_ptr_(NULL) {
|
||||
// Encoder
|
||||
_ptrEncStr = new ACMG722EncStr;
|
||||
if (_ptrEncStr != NULL) {
|
||||
_ptrEncStr->inst = NULL;
|
||||
_ptrEncStr->instRight = NULL;
|
||||
ptr_enc_str_ = new ACMG722EncStr;
|
||||
if (ptr_enc_str_ != NULL) {
|
||||
ptr_enc_str_->inst = NULL;
|
||||
ptr_enc_str_->inst_right = NULL;
|
||||
}
|
||||
// Decoder
|
||||
_ptrDecStr = new ACMG722DecStr;
|
||||
if (_ptrDecStr != NULL) {
|
||||
_ptrDecStr->inst = NULL;
|
||||
_ptrDecStr->instRight = NULL; // Not used
|
||||
ptr_dec_str_ = new ACMG722DecStr;
|
||||
if (ptr_dec_str_ != NULL) {
|
||||
ptr_dec_str_->inst = NULL;
|
||||
ptr_dec_str_->inst_right = NULL; // Not used
|
||||
}
|
||||
_codecID = codecID;
|
||||
codec_id_ = codec_id;
|
||||
return;
|
||||
}
|
||||
|
||||
ACMG722::~ACMG722() {
|
||||
// Encoder
|
||||
if (_ptrEncStr != NULL) {
|
||||
if (_ptrEncStr->inst != NULL) {
|
||||
WebRtcG722_FreeEncoder(_ptrEncStr->inst);
|
||||
_ptrEncStr->inst = NULL;
|
||||
if (ptr_enc_str_ != NULL) {
|
||||
if (ptr_enc_str_->inst != NULL) {
|
||||
WebRtcG722_FreeEncoder(ptr_enc_str_->inst);
|
||||
ptr_enc_str_->inst = NULL;
|
||||
}
|
||||
if (_ptrEncStr->instRight != NULL) {
|
||||
WebRtcG722_FreeEncoder(_ptrEncStr->instRight);
|
||||
_ptrEncStr->instRight = NULL;
|
||||
if (ptr_enc_str_->inst_right != NULL) {
|
||||
WebRtcG722_FreeEncoder(ptr_enc_str_->inst_right);
|
||||
ptr_enc_str_->inst_right = NULL;
|
||||
}
|
||||
delete _ptrEncStr;
|
||||
_ptrEncStr = NULL;
|
||||
delete ptr_enc_str_;
|
||||
ptr_enc_str_ = NULL;
|
||||
}
|
||||
// Decoder
|
||||
if (_ptrDecStr != NULL) {
|
||||
if (_ptrDecStr->inst != NULL) {
|
||||
WebRtcG722_FreeDecoder(_ptrDecStr->inst);
|
||||
_ptrDecStr->inst = NULL;
|
||||
if (ptr_dec_str_ != NULL) {
|
||||
if (ptr_dec_str_->inst != NULL) {
|
||||
WebRtcG722_FreeDecoder(ptr_dec_str_->inst);
|
||||
ptr_dec_str_->inst = NULL;
|
||||
}
|
||||
if (_ptrDecStr->instRight != NULL) {
|
||||
WebRtcG722_FreeDecoder(_ptrDecStr->instRight);
|
||||
_ptrDecStr->instRight = NULL;
|
||||
if (ptr_dec_str_->inst_right != NULL) {
|
||||
WebRtcG722_FreeDecoder(ptr_dec_str_->inst_right);
|
||||
ptr_dec_str_->inst_right = NULL;
|
||||
}
|
||||
delete _ptrDecStr;
|
||||
_ptrDecStr = NULL;
|
||||
delete ptr_dec_str_;
|
||||
ptr_dec_str_ = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG722::Add10MsDataSafe(const WebRtc_UWord32 timestamp,
|
||||
const WebRtc_Word16* data,
|
||||
const WebRtc_UWord16 lengthSmpl,
|
||||
const WebRtc_UWord8 audioChannel) {
|
||||
return ACMGenericCodec::Add10MsDataSafe((timestamp >> 1), data, lengthSmpl,
|
||||
audioChannel);
|
||||
const WebRtc_UWord16 length_smpl,
|
||||
const WebRtc_UWord8 audio_channel) {
|
||||
return ACMGenericCodec::Add10MsDataSafe((timestamp >> 1), data, length_smpl,
|
||||
audio_channel);
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
WebRtc_Word16 ACMG722::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
// If stereo, split input signal in left and right channel before encoding
|
||||
if (_noChannels == 2) {
|
||||
WebRtc_Word16 leftChannel[960];
|
||||
WebRtc_Word16 rightChannel[960];
|
||||
WebRtc_UWord8 outLeft[480];
|
||||
WebRtc_UWord8 outRight[480];
|
||||
WebRtc_Word16 lenInBytes;
|
||||
for (int i = 0, j = 0; i < _frameLenSmpl * 2; i += 2, j++) {
|
||||
leftChannel[j] = _inAudio[_inAudioIxRead + i];
|
||||
rightChannel[j] = _inAudio[_inAudioIxRead + i + 1];
|
||||
if (num_channels_ == 2) {
|
||||
WebRtc_Word16 left_channel[960];
|
||||
WebRtc_Word16 right_channel[960];
|
||||
WebRtc_UWord8 out_left[480];
|
||||
WebRtc_UWord8 out_right[480];
|
||||
WebRtc_Word16 len_in_bytes;
|
||||
for (int i = 0, j = 0; i < frame_len_smpl_ * 2; i += 2, j++) {
|
||||
left_channel[j] = in_audio_[in_audio_ix_read_ + i];
|
||||
right_channel[j] = in_audio_[in_audio_ix_read_ + i + 1];
|
||||
}
|
||||
lenInBytes = WebRtcG722_Encode(_encoderInstPtr, leftChannel, _frameLenSmpl,
|
||||
(WebRtc_Word16*) outLeft);
|
||||
lenInBytes += WebRtcG722_Encode(_encoderInstPtrRight, rightChannel,
|
||||
_frameLenSmpl, (WebRtc_Word16*) outRight);
|
||||
*bitStreamLenByte = lenInBytes;
|
||||
len_in_bytes = WebRtcG722_Encode(encoder_inst_ptr_, left_channel,
|
||||
frame_len_smpl_,
|
||||
(WebRtc_Word16*)out_left);
|
||||
len_in_bytes += WebRtcG722_Encode(encoder_inst_ptr_right_, right_channel,
|
||||
frame_len_smpl_,
|
||||
(WebRtc_Word16*)out_right);
|
||||
*bitstream_len_byte = len_in_bytes;
|
||||
|
||||
// Interleave the 4 bits per sample from left and right channel
|
||||
for (int i = 0, j = 0; i < lenInBytes; i += 2, j++) {
|
||||
bitStream[i] = (outLeft[j] & 0xF0) + (outRight[j] >> 4);
|
||||
bitStream[i + 1] = ((outLeft[j] & 0x0F) << 4) + (outRight[j] & 0x0F);
|
||||
for (int i = 0, j = 0; i < len_in_bytes; i += 2, j++) {
|
||||
bitstream[i] = (out_left[j] & 0xF0) + (out_right[j] >> 4);
|
||||
bitstream[i + 1] = ((out_left[j] & 0x0F) << 4) + (out_right[j] & 0x0F);
|
||||
}
|
||||
} else {
|
||||
*bitStreamLenByte = WebRtcG722_Encode(_encoderInstPtr,
|
||||
&_inAudio[_inAudioIxRead],
|
||||
_frameLenSmpl,
|
||||
(WebRtc_Word16*) bitStream);
|
||||
*bitstream_len_byte = WebRtcG722_Encode(encoder_inst_ptr_,
|
||||
&in_audio_[in_audio_ix_read_],
|
||||
frame_len_smpl_,
|
||||
(WebRtc_Word16*)bitstream);
|
||||
}
|
||||
|
||||
// increment the read index this tell the caller how far
|
||||
// we have gone forward in reading the audio buffer
|
||||
_inAudioIxRead += _frameLenSmpl * _noChannels;
|
||||
return *bitStreamLenByte;
|
||||
in_audio_ix_read_ += frame_len_smpl_ * num_channels_;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
if (codecParams->codecInstant.channels == 2) {
|
||||
WebRtc_Word16 ACMG722::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
|
||||
if (codec_params->codec_inst.channels == 2) {
|
||||
// Create codec struct for right channel
|
||||
if (_ptrEncStr->instRight == NULL) {
|
||||
WebRtcG722_CreateEncoder(&_ptrEncStr->instRight);
|
||||
if (_ptrEncStr->instRight == NULL) {
|
||||
if (ptr_enc_str_->inst_right == NULL) {
|
||||
WebRtcG722_CreateEncoder(&ptr_enc_str_->inst_right);
|
||||
if (ptr_enc_str_->inst_right == NULL) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
_encoderInstPtrRight = _ptrEncStr->instRight;
|
||||
if (WebRtcG722_EncoderInit(_encoderInstPtrRight) < 0) {
|
||||
encoder_inst_ptr_right_ = ptr_enc_str_->inst_right;
|
||||
if (WebRtcG722_EncoderInit(encoder_inst_ptr_right_) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return WebRtcG722_EncoderInit(_encoderInstPtr);
|
||||
return WebRtcG722_EncoderInit(encoder_inst_ptr_);
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
return WebRtcG722_DecoderInit(_decoderInstPtr);
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return WebRtcG722_DecoderInit(decoder_inst_ptr_);
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
// TODO: log error
|
||||
WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
// TODO(turajs): log error
|
||||
return -1;
|
||||
}
|
||||
// Fill up the structure by calling
|
||||
// "SET_CODEC_PAR" & "SET_G722_FUNCTION."
|
||||
// Then call NetEQ to add the codec to it's
|
||||
// database.
|
||||
if (codecInst.channels == 1) {
|
||||
SET_CODEC_PAR(codecDef, kDecoderG722, codecInst.pltype, _decoderInstPtr,
|
||||
if (codec_inst.channels == 1) {
|
||||
SET_CODEC_PAR(codec_def, kDecoderG722, codec_inst.pltype, decoder_inst_ptr_,
|
||||
16000);
|
||||
} else {
|
||||
SET_CODEC_PAR(codecDef, kDecoderG722_2ch, codecInst.pltype,
|
||||
_decoderInstPtr, 16000);
|
||||
SET_CODEC_PAR(codec_def, kDecoderG722_2ch, codec_inst.pltype,
|
||||
decoder_inst_ptr_, 16000);
|
||||
}
|
||||
SET_G722_FUNCTIONS(codecDef);
|
||||
SET_G722_FUNCTIONS(codec_def);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -260,61 +261,61 @@ ACMGenericCodec* ACMG722::CreateInstance(void) {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722::InternalCreateEncoder() {
|
||||
if (_ptrEncStr == NULL) {
|
||||
if (ptr_enc_str_ == NULL) {
|
||||
// this structure must be created at the costructor
|
||||
// if it is still NULL then there is a probelm and
|
||||
// we dont continue
|
||||
return -1;
|
||||
}
|
||||
WebRtcG722_CreateEncoder(&_ptrEncStr->inst);
|
||||
if (_ptrEncStr->inst == NULL) {
|
||||
WebRtcG722_CreateEncoder(&ptr_enc_str_->inst);
|
||||
if (ptr_enc_str_->inst == NULL) {
|
||||
return -1;
|
||||
}
|
||||
_encoderInstPtr = _ptrEncStr->inst;
|
||||
encoder_inst_ptr_ = ptr_enc_str_->inst;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMG722::DestructEncoderSafe() {
|
||||
if (_ptrEncStr != NULL) {
|
||||
if (_ptrEncStr->inst != NULL) {
|
||||
WebRtcG722_FreeEncoder(_ptrEncStr->inst);
|
||||
_ptrEncStr->inst = NULL;
|
||||
if (ptr_enc_str_ != NULL) {
|
||||
if (ptr_enc_str_->inst != NULL) {
|
||||
WebRtcG722_FreeEncoder(ptr_enc_str_->inst);
|
||||
ptr_enc_str_->inst = NULL;
|
||||
}
|
||||
}
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722::InternalCreateDecoder() {
|
||||
if (_ptrDecStr == NULL) {
|
||||
if (ptr_dec_str_ == NULL) {
|
||||
// this structure must be created at the costructor
|
||||
// if it is still NULL then there is a probelm and
|
||||
// we dont continue
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtcG722_CreateDecoder(&_ptrDecStr->inst);
|
||||
if (_ptrDecStr->inst == NULL) {
|
||||
WebRtcG722_CreateDecoder(&ptr_dec_str_->inst);
|
||||
if (ptr_dec_str_->inst == NULL) {
|
||||
return -1;
|
||||
}
|
||||
_decoderInstPtr = _ptrDecStr->inst;
|
||||
decoder_inst_ptr_ = ptr_dec_str_->inst;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMG722::DestructDecoderSafe() {
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
if (_ptrDecStr != NULL) {
|
||||
if (_ptrDecStr->inst != NULL) {
|
||||
WebRtcG722_FreeDecoder(_ptrDecStr->inst);
|
||||
_ptrDecStr->inst = NULL;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
if (ptr_dec_str_ != NULL) {
|
||||
if (ptr_dec_str_->inst != NULL) {
|
||||
WebRtcG722_FreeDecoder(ptr_dec_str_->inst);
|
||||
ptr_dec_str_->inst = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ACMG722::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcG722_FreeEncoder(static_cast<G722EncInst*>(ptrInst));
|
||||
void ACMG722::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
WebRtcG722_FreeEncoder(static_cast<G722EncInst*>(ptr_inst));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
typedef struct WebRtcG722EncInst G722EncInst;
|
||||
typedef struct WebRtcG722DecInst G722DecInst;
|
||||
@ -24,31 +24,32 @@ struct ACMG722DecStr;
|
||||
|
||||
class ACMG722: public ACMGenericCodec {
|
||||
public:
|
||||
ACMG722(WebRtc_Word16 codecID);
|
||||
explicit ACMG722(WebRtc_Word16 codec_id);
|
||||
~ACMG722();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio, WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
WebRtc_Word32 Add10MsDataSafe(const WebRtc_UWord32 timestamp,
|
||||
const WebRtc_Word16* data,
|
||||
const WebRtc_UWord16 lengthSmpl,
|
||||
const WebRtc_UWord8 audioChannel);
|
||||
const WebRtc_UWord16 length_smpl,
|
||||
const WebRtc_UWord8 audio_channel);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -58,16 +59,16 @@ class ACMG722: public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
||||
|
||||
ACMG722EncStr* _ptrEncStr;
|
||||
ACMG722DecStr* _ptrDecStr;
|
||||
ACMG722EncStr* ptr_enc_str_;
|
||||
ACMG722DecStr* ptr_dec_str_;
|
||||
|
||||
G722EncInst* _encoderInstPtr;
|
||||
G722EncInst* _encoderInstPtrRight; // Prepared for stereo
|
||||
G722DecInst* _decoderInstPtr;
|
||||
G722EncInst* encoder_inst_ptr_;
|
||||
G722EncInst* encoder_inst_ptr_right_; // Prepared for stereo
|
||||
G722DecInst* decoder_inst_ptr_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,13 +8,14 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_g7221.h"
|
||||
#include "acm_codec_database.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_g7221.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_G722_1
|
||||
// NOTE! G.722.1 is not included in the open-source package. The following
|
||||
@ -24,62 +25,62 @@
|
||||
//
|
||||
// The API in the header file should match the one below.
|
||||
//
|
||||
// int16_t WebRtcG7221_CreateEnc16(G722_1_16_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_CreateDec16(G722_1_16_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_CreateEnc16(G722_1_16_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221_CreateEnc24(G722_1_24_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221_CreateEnc32(G722_1_32_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221_CreateDec16(G722_1_16_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcG7221_CreateDec24(G722_1_24_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcG7221_CreateDec32(G722_1_32_decinst_t_** dec_inst);
|
||||
//
|
||||
// int16_t WebRtcG7221_FreeEnc16(G722_1_16_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_FreeDec16(G722_1_16_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_FreeEnc16(G722_1_16_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221_FreeEnc24(G722_1_24_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221_FreeEnc32(G722_1_32_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221_FreeDec16(G722_1_16_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcG7221_FreeDec24(G722_1_24_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcG7221_FreeDec32(G722_1_32_decinst_t_** dec_inst);
|
||||
//
|
||||
// int16_t WebRtcG7221_EncoderInit16(G722_1_16_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_DecoderInit16(G722_1_16_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_EncoderInit16(G722_1_16_encinst_t_* enc_inst);
|
||||
// int16_t WebRtcG7221_EncoderInit24(G722_1_24_encinst_t_* enc_inst);
|
||||
// int16_t WebRtcG7221_EncoderInit32(G722_1_32_encinst_t_* enc_inst);
|
||||
// int16_t WebRtcG7221_DecoderInit16(G722_1_16_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcG7221_DecoderInit24(G722_1_24_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcG7221_DecoderInit32(G722_1_32_decinst_t_* dec_inst);
|
||||
//
|
||||
// int16_t WebRtcG7221_Encode16(G722_1_16_encinst_t_* encInst,
|
||||
// int16_t WebRtcG7221_Encode16(G722_1_16_encinst_t_* enc_inst,
|
||||
// int16_t* input,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
// int16_t WebRtcG7221_Encode24(G722_1_24_encinst_t_* encInst,
|
||||
// int16_t WebRtcG7221_Encode24(G722_1_24_encinst_t_* enc_inst,
|
||||
// int16_t* input,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
// int16_t WebRtcG7221_Encode32(G722_1_32_encinst_t_* encInst,
|
||||
// int16_t WebRtcG7221_Encode32(G722_1_32_encinst_t_* enc_inst,
|
||||
// int16_t* input,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
//
|
||||
// int16_t WebRtcG7221_Decode16(G722_1_16_decinst_t_* decInst,
|
||||
// int16_t WebRtcG7221_Decode16(G722_1_16_decinst_t_* dec_inst,
|
||||
// int16_t* bitstream,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
// int16_t WebRtcG7221_Decode24(G722_1_24_decinst_t_* decInst,
|
||||
// int16_t WebRtcG7221_Decode24(G722_1_24_decinst_t_* dec_inst,
|
||||
// int16_t* bitstream,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
// int16_t WebRtcG7221_Decode32(G722_1_32_decinst_t_* decInst,
|
||||
// int16_t WebRtcG7221_Decode32(G722_1_32_decinst_t_* dec_inst,
|
||||
// int16_t* bitstream,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
//
|
||||
// int16_t WebRtcG7221_DecodePlc16(G722_1_16_decinst_t_* decInst,
|
||||
// int16_t WebRtcG7221_DecodePlc16(G722_1_16_decinst_t_* dec_inst,
|
||||
// int16_t* output,
|
||||
// int16_t nrLostFrames);
|
||||
// int16_t WebRtcG7221_DecodePlc24(G722_1_24_decinst_t_* decInst,
|
||||
// int16_t nr_lost_frames);
|
||||
// int16_t WebRtcG7221_DecodePlc24(G722_1_24_decinst_t_* dec_inst,
|
||||
// int16_t* output,
|
||||
// int16_t nrLostFrames);
|
||||
// int16_t WebRtcG7221_DecodePlc32(G722_1_32_decinst_t_* decInst,
|
||||
// int16_t nr_lost_frames);
|
||||
// int16_t WebRtcG7221_DecodePlc32(G722_1_32_decinst_t_* dec_inst,
|
||||
// int16_t* output,
|
||||
// int16_t nrLostFrames);
|
||||
// int16_t nr_lost_frames);
|
||||
#include "g7221_interface.h"
|
||||
#endif
|
||||
|
||||
@ -87,20 +88,20 @@ namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_G722_1
|
||||
|
||||
ACMG722_1::ACMG722_1(WebRtc_Word16 /* codecID */)
|
||||
: _operationalRate(-1),
|
||||
_encoderInstPtr(NULL),
|
||||
_encoderInstPtrRight(NULL),
|
||||
_decoderInstPtr(NULL),
|
||||
_encoderInst16Ptr(NULL),
|
||||
_encoderInst16PtrR(NULL),
|
||||
_encoderInst24Ptr(NULL),
|
||||
_encoderInst24PtrR(NULL),
|
||||
_encoderInst32Ptr(NULL),
|
||||
_encoderInst32PtrR(NULL),
|
||||
_decoderInst16Ptr(NULL),
|
||||
_decoderInst24Ptr(NULL),
|
||||
_decoderInst32Ptr(NULL) {
|
||||
ACMG722_1::ACMG722_1(WebRtc_Word16 /* codec_id */)
|
||||
: operational_rate_(-1),
|
||||
encoder_inst_ptr_(NULL),
|
||||
encoder_inst_ptr_right_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
encoder_inst16_ptr_(NULL),
|
||||
encoder_inst16_ptr_right_(NULL),
|
||||
encoder_inst24_ptr_(NULL),
|
||||
encoder_inst24_ptr_right_(NULL),
|
||||
encoder_inst32_ptr_(NULL),
|
||||
encoder_inst32_ptr_right_(NULL),
|
||||
decoder_inst16_ptr_(NULL),
|
||||
decoder_inst24_ptr_(NULL),
|
||||
decoder_inst32_ptr_(NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -108,31 +109,32 @@ ACMG722_1::~ACMG722_1() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_Word16 ACMG722_1::InternalEncode(
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMG722_1::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG722_1::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMG722_1::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -156,69 +158,68 @@ void ACMG722_1::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMG722_1::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMG722_1::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
ACMG722_1::ACMG722_1(
|
||||
WebRtc_Word16 codecID):
|
||||
_encoderInstPtr(NULL),
|
||||
_encoderInstPtrRight(NULL),
|
||||
_decoderInstPtr(NULL),
|
||||
_encoderInst16Ptr(NULL),
|
||||
_encoderInst16PtrR(NULL),
|
||||
_encoderInst24Ptr(NULL),
|
||||
_encoderInst24PtrR(NULL),
|
||||
_encoderInst32Ptr(NULL),
|
||||
_encoderInst32PtrR(NULL),
|
||||
_decoderInst16Ptr(NULL),
|
||||
_decoderInst24Ptr(NULL),
|
||||
_decoderInst32Ptr(NULL) {
|
||||
_codecID = codecID;
|
||||
if (_codecID == ACMCodecDB::kG722_1_16) {
|
||||
_operationalRate = 16000;
|
||||
} else if (_codecID == ACMCodecDB::kG722_1_24) {
|
||||
_operationalRate = 24000;
|
||||
} else if (_codecID == ACMCodecDB::kG722_1_32) {
|
||||
_operationalRate = 32000;
|
||||
ACMG722_1::ACMG722_1(WebRtc_Word16 codec_id)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
encoder_inst_ptr_right_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
encoder_inst16_ptr_(NULL),
|
||||
encoder_inst16_ptr_right_(NULL),
|
||||
encoder_inst24_ptr_(NULL),
|
||||
encoder_inst24_ptr_right_(NULL),
|
||||
encoder_inst32_ptr_(NULL),
|
||||
encoder_inst32_ptr_right_(NULL),
|
||||
decoder_inst16_ptr_(NULL),
|
||||
decoder_inst24_ptr_(NULL),
|
||||
decoder_inst32_ptr_(NULL) {
|
||||
codec_id_ = codec_id;
|
||||
if (codec_id_ == ACMCodecDB::kG722_1_16) {
|
||||
operational_rate_ = 16000;
|
||||
} else if (codec_id_ == ACMCodecDB::kG722_1_24) {
|
||||
operational_rate_ = 24000;
|
||||
} else if (codec_id_ == ACMCodecDB::kG722_1_32) {
|
||||
operational_rate_ = 32000;
|
||||
} else {
|
||||
_operationalRate = -1;
|
||||
operational_rate_ = -1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ACMG722_1::~ACMG722_1() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
delete _encoderInstPtr;
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
delete encoder_inst_ptr_;
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_encoderInstPtrRight != NULL) {
|
||||
delete _encoderInstPtrRight;
|
||||
_encoderInstPtrRight = NULL;
|
||||
if (encoder_inst_ptr_right_ != NULL) {
|
||||
delete encoder_inst_ptr_right_;
|
||||
encoder_inst_ptr_right_ = NULL;
|
||||
}
|
||||
if (_decoderInstPtr != NULL) {
|
||||
delete _decoderInstPtr;
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
delete decoder_inst_ptr_;
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 16000: {
|
||||
_encoderInst16Ptr = NULL;
|
||||
_encoderInst16PtrR = NULL;
|
||||
_decoderInst16Ptr = NULL;
|
||||
encoder_inst16_ptr_ = NULL;
|
||||
encoder_inst16_ptr_right_ = NULL;
|
||||
decoder_inst16_ptr_ = NULL;
|
||||
break;
|
||||
}
|
||||
case 24000: {
|
||||
_encoderInst24Ptr = NULL;
|
||||
_encoderInst24PtrR = NULL;
|
||||
_decoderInst24Ptr = NULL;
|
||||
encoder_inst24_ptr_ = NULL;
|
||||
encoder_inst24_ptr_right_ = NULL;
|
||||
decoder_inst24_ptr_ = NULL;
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
_encoderInst32Ptr = NULL;
|
||||
_encoderInst32PtrR = NULL;
|
||||
_decoderInst32Ptr = NULL;
|
||||
encoder_inst32_ptr_ = NULL;
|
||||
encoder_inst32_ptr_right_ = NULL;
|
||||
decoder_inst32_ptr_ = NULL;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -228,131 +229,134 @@ ACMG722_1::~ACMG722_1() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
WebRtc_Word16 leftChannel[320];
|
||||
WebRtc_Word16 rightChannel[320];
|
||||
WebRtc_Word16 lenInBytes;
|
||||
WebRtc_Word16 outB[160];
|
||||
WebRtc_Word16 ACMG722_1::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
WebRtc_Word16 left_channel[320];
|
||||
WebRtc_Word16 right_channel[320];
|
||||
WebRtc_Word16 len_in_bytes;
|
||||
WebRtc_Word16 out_bits[160];
|
||||
|
||||
// If stereo, split input signal in left and right channel before encoding
|
||||
if (_noChannels == 2) {
|
||||
for (int i = 0, j = 0; i < _frameLenSmpl * 2; i += 2, j++) {
|
||||
leftChannel[j] = _inAudio[_inAudioIxRead + i];
|
||||
rightChannel[j] = _inAudio[_inAudioIxRead + i + 1];
|
||||
if (num_channels_ == 2) {
|
||||
for (int i = 0, j = 0; i < frame_len_smpl_ * 2; i += 2, j++) {
|
||||
left_channel[j] = in_audio_[in_audio_ix_read_ + i];
|
||||
right_channel[j] = in_audio_[in_audio_ix_read_ + i + 1];
|
||||
}
|
||||
} else {
|
||||
memcpy(leftChannel, &_inAudio[_inAudioIxRead], 320);
|
||||
memcpy(left_channel, &in_audio_[in_audio_ix_read_], 320);
|
||||
}
|
||||
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 16000: {
|
||||
Inst lenInBytes = WebRtcG7221_Encode16(_encoderInst16Ptr, leftChannel,
|
||||
320, &outB[0]);
|
||||
if (_noChannels == 2) {
|
||||
lenInBytes += WebRtcG7221_Encode16(_encoderInst16PtrR, rightChannel,
|
||||
320, &outB[lenInBytes / 2]);
|
||||
len_in_bytes = WebRtcG7221_Encode16(encoder_inst16_ptr_, left_channel,
|
||||
320, &out_bits[0]);
|
||||
if (num_channels_ == 2) {
|
||||
len_in_bytes += WebRtcG7221_Encode16(encoder_inst16_ptr_right_,
|
||||
right_channel, 320,
|
||||
&out_bits[len_in_bytes / 2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 24000: {
|
||||
lenInBytes = WebRtcG7221_Encode24(_encoderInst24Ptr, leftChannel, 320,
|
||||
&outB[0]);
|
||||
if (_noChannels == 2) {
|
||||
lenInBytes += WebRtcG7221_Encode24(_encoderInst24PtrR, rightChannel,
|
||||
320, &outB[lenInBytes / 2]);
|
||||
len_in_bytes = WebRtcG7221_Encode24(encoder_inst24_ptr_, left_channel,
|
||||
320, &out_bits[0]);
|
||||
if (num_channels_ == 2) {
|
||||
len_in_bytes += WebRtcG7221_Encode24(encoder_inst24_ptr_right_,
|
||||
right_channel, 320,
|
||||
&out_bits[len_in_bytes / 2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
lenInBytes = WebRtcG7221_Encode32(_encoderInst32Ptr, leftChannel, 320,
|
||||
&outB[0]);
|
||||
if (_noChannels == 2) {
|
||||
lenInBytes += WebRtcG7221_Encode32(_encoderInst32PtrR, rightChannel,
|
||||
320, &outB[lenInBytes / 2]);
|
||||
len_in_bytes = WebRtcG7221_Encode32(encoder_inst32_ptr_, left_channel,
|
||||
320, &out_bits[0]);
|
||||
if (num_channels_ == 2) {
|
||||
len_in_bytes += WebRtcG7221_Encode32(encoder_inst32_ptr_right_,
|
||||
right_channel, 320,
|
||||
&out_bits[len_in_bytes / 2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalInitEncode: Wrong rate for G722_1.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
memcpy(bitStream, outB, lenInBytes);
|
||||
*bitStreamLenByte = lenInBytes;
|
||||
memcpy(bitstream, out_bits, len_in_bytes);
|
||||
*bitstream_len_byte = len_in_bytes;
|
||||
|
||||
// increment the read index this tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer
|
||||
_inAudioIxRead += 320 * _noChannels;
|
||||
return *bitStreamLenByte;
|
||||
in_audio_ix_read_ += 320 * num_channels_;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMG722_1::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* codecParams) {
|
||||
WebRtcACMCodecParams* codec_params) {
|
||||
WebRtc_Word16 ret;
|
||||
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 16000: {
|
||||
ret = WebRtcG7221_EncoderInit16(_encoderInst16PtrR);
|
||||
ret = WebRtcG7221_EncoderInit16(encoder_inst16_ptr_right_);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return WebRtcG7221_EncoderInit16(_encoderInst16Ptr);
|
||||
return WebRtcG7221_EncoderInit16(encoder_inst16_ptr_);
|
||||
}
|
||||
case 24000: {
|
||||
ret = WebRtcG7221_EncoderInit24(_encoderInst24PtrR);
|
||||
ret = WebRtcG7221_EncoderInit24(encoder_inst24_ptr_right_);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return WebRtcG7221_EncoderInit24(_encoderInst24Ptr);
|
||||
return WebRtcG7221_EncoderInit24(encoder_inst24_ptr_);
|
||||
}
|
||||
case 32000: {
|
||||
ret = WebRtcG7221_EncoderInit32(_encoderInst32PtrR);
|
||||
ret = WebRtcG7221_EncoderInit32(encoder_inst32_ptr_right_);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return WebRtcG7221_EncoderInit32(_encoderInst32Ptr);
|
||||
return WebRtcG7221_EncoderInit32(encoder_inst32_ptr_);
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError,Inst webrtc::kTraceAudioCoding,
|
||||
_uniqueID, "InternalInitEncoder: Wrong rate for G722_1.");
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding,
|
||||
unique_id_, "InternalInitEncoder: Wrong rate for G722_1.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
switch (_operationalRate) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
switch (operational_rate_) {
|
||||
case 16000: {
|
||||
return WebRtcG7221_DecoderInit16(_decoderInst16Ptr);
|
||||
return WebRtcG7221_DecoderInit16(decoder_inst16_ptr_);
|
||||
}
|
||||
case 24000: {
|
||||
return WebRtcG7221_DecoderInit24(_decoderInst24Ptr);
|
||||
return WebRtcG7221_DecoderInit24(decoder_inst24_ptr_);
|
||||
}
|
||||
case 32000: {
|
||||
return WebRtcG7221_DecoderInit32(_decoderInst32Ptr);
|
||||
return WebRtcG7221_DecoderInit32(decoder_inst32_ptr_);
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalInitDecoder: Wrong rate for G722_1.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG722_1::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WebRtc_Word32 ACMG722_1::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
// Todo:
|
||||
// log error
|
||||
return -1;
|
||||
@ -365,27 +369,27 @@ WebRtc_Word32 ACMG722_1::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// "SET_CODEC_PAR" & "SET_G722_1_XX_FUNCTION."
|
||||
// Then return the structure back to NetEQ to add the codec to it's
|
||||
// database.
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 16000: {
|
||||
SET_CODEC_PAR((codecDef), kDecoderG722_1_16, codecInst.pltype,
|
||||
_decoderInst16Ptr, 16000);
|
||||
SET_G722_1_16_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderG722_1_16, codec_inst.pltype,
|
||||
decoder_inst16_ptr_, 16000);
|
||||
SET_G722_1_16_FUNCTIONS((codec_def));
|
||||
break;
|
||||
}
|
||||
case 24000: {
|
||||
SET_CODEC_PAR((codecDef), kDecoderG722_1_24, codecInst.pltype,
|
||||
_decoderInst24Ptr, 16000);
|
||||
SET_G722_1_24_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderG722_1_24, codec_inst.pltype,
|
||||
decoder_inst24_ptr_, 16000);
|
||||
SET_G722_1_24_FUNCTIONS((codec_def));
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
SET_CODEC_PAR((codecDef), kDecoderG722_1_32, codecInst.pltype,
|
||||
_decoderInst32Ptr, 16000);
|
||||
SET_G722_1_32_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderG722_1_32, codec_inst.pltype,
|
||||
decoder_inst32_ptr_, 16000);
|
||||
SET_G722_1_32_FUNCTIONS((codec_def));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"CodecDef: Wrong rate for G722_1.");
|
||||
return -1;
|
||||
}
|
||||
@ -398,27 +402,27 @@ ACMGenericCodec* ACMG722_1::CreateInstance(void) {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1::InternalCreateEncoder() {
|
||||
if ((_encoderInstPtr == NULL) || (_encoderInstPtrRight == NULL)) {
|
||||
if ((encoder_inst_ptr_ == NULL) || (encoder_inst_ptr_right_ == NULL)) {
|
||||
return -1;
|
||||
}
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 16000: {
|
||||
WebRtcG7221_CreateEnc16(&_encoderInst16Ptr);
|
||||
WebRtcG7221_CreateEnc16(&_encoderInst16PtrR);
|
||||
WebRtcG7221_CreateEnc16(&encoder_inst16_ptr_);
|
||||
WebRtcG7221_CreateEnc16(&encoder_inst16_ptr_right_);
|
||||
break;
|
||||
}
|
||||
case 24000: {
|
||||
WebRtcG7221_CreateEnc24(&_encoderInst24Ptr);
|
||||
WebRtcG7221_CreateEnc24(&_encoderInst24PtrR);
|
||||
WebRtcG7221_CreateEnc24(&encoder_inst24_ptr_);
|
||||
WebRtcG7221_CreateEnc24(&encoder_inst24_ptr_right_);
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
WebRtcG7221_CreateEnc32(&_encoderInst32Ptr);
|
||||
WebRtcG7221_CreateEnc32(&_encoderInst32PtrR);
|
||||
WebRtcG7221_CreateEnc32(&encoder_inst32_ptr_);
|
||||
WebRtcG7221_CreateEnc32(&encoder_inst32_ptr_right_);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateEncoder: Wrong rate for G722_1.");
|
||||
return -1;
|
||||
}
|
||||
@ -427,40 +431,40 @@ WebRtc_Word16 ACMG722_1::InternalCreateEncoder() {
|
||||
}
|
||||
|
||||
void ACMG722_1::DestructEncoderSafe() {
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
if (_encoderInstPtr != NULL) {
|
||||
delete _encoderInstPtr;
|
||||
_encoderInstPtr = NULL;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
delete encoder_inst_ptr_;
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_encoderInstPtrRight != NULL) {
|
||||
delete _encoderInstPtrRight;
|
||||
_encoderInstPtrRight = NULL;
|
||||
if (encoder_inst_ptr_right_ != NULL) {
|
||||
delete encoder_inst_ptr_right_;
|
||||
encoder_inst_ptr_right_ = NULL;
|
||||
}
|
||||
_encoderInst16Ptr = NULL;
|
||||
_encoderInst24Ptr = NULL;
|
||||
_encoderInst32Ptr = NULL;
|
||||
encoder_inst16_ptr_ = NULL;
|
||||
encoder_inst24_ptr_ = NULL;
|
||||
encoder_inst32_ptr_ = NULL;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1::InternalCreateDecoder() {
|
||||
if (_decoderInstPtr == NULL) {
|
||||
if (decoder_inst_ptr_ == NULL) {
|
||||
return -1;
|
||||
}
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 16000: {
|
||||
WebRtcG7221_CreateDec16(&_decoderInst16Ptr);
|
||||
WebRtcG7221_CreateDec16(&decoder_inst16_ptr_);
|
||||
break;
|
||||
}
|
||||
case 24000: {
|
||||
WebRtcG7221_CreateDec24(&_decoderInst24Ptr);
|
||||
WebRtcG7221_CreateDec24(&decoder_inst24_ptr_);
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
WebRtcG7221_CreateDec32(&_decoderInst32Ptr);
|
||||
WebRtcG7221_CreateDec32(&decoder_inst32_ptr_);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateDecoder: Wrong rate for G722_1.");
|
||||
return -1;
|
||||
}
|
||||
@ -469,20 +473,20 @@ WebRtc_Word16 ACMG722_1::InternalCreateDecoder() {
|
||||
}
|
||||
|
||||
void ACMG722_1::DestructDecoderSafe() {
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
if (_decoderInstPtr != NULL) {
|
||||
delete _decoderInstPtr;
|
||||
_decoderInstPtr = NULL;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
delete decoder_inst_ptr_;
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
_decoderInst16Ptr = NULL;
|
||||
_decoderInst24Ptr = NULL;
|
||||
_decoderInst32Ptr = NULL;
|
||||
decoder_inst16_ptr_ = NULL;
|
||||
decoder_inst24_ptr_ = NULL;
|
||||
decoder_inst32_ptr_ = NULL;
|
||||
}
|
||||
|
||||
void ACMG722_1::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
delete ptrInst;
|
||||
void ACMG722_1::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
delete ptr_inst;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7221_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7221_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
// forward declaration
|
||||
struct G722_1_16_encinst_t_;
|
||||
@ -26,26 +26,27 @@ namespace webrtc {
|
||||
|
||||
class ACMG722_1: public ACMGenericCodec {
|
||||
public:
|
||||
ACMG722_1(WebRtc_Word16 codecID);
|
||||
explicit ACMG722_1(WebRtc_Word16 codec_id);
|
||||
~ACMG722_1();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio, WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -55,28 +56,28 @@ class ACMG722_1: public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
WebRtc_Word32 _operationalRate;
|
||||
WebRtc_Word32 operational_rate_;
|
||||
|
||||
G722_1_Inst_t_* _encoderInstPtr;
|
||||
G722_1_Inst_t_* _encoderInstPtrRight; //Used in stereo mode
|
||||
G722_1_Inst_t_* _decoderInstPtr;
|
||||
G722_1_Inst_t_* encoder_inst_ptr_;
|
||||
G722_1_Inst_t_* encoder_inst_ptr_right_; // Used in stereo mode
|
||||
G722_1_Inst_t_* decoder_inst_ptr_;
|
||||
|
||||
// Only one set of these pointer is valid at any instance
|
||||
G722_1_16_encinst_t_* _encoderInst16Ptr;
|
||||
G722_1_16_encinst_t_* _encoderInst16PtrR;
|
||||
G722_1_24_encinst_t_* _encoderInst24Ptr;
|
||||
G722_1_24_encinst_t_* _encoderInst24PtrR;
|
||||
G722_1_32_encinst_t_* _encoderInst32Ptr;
|
||||
G722_1_32_encinst_t_* _encoderInst32PtrR;
|
||||
G722_1_16_encinst_t_* encoder_inst16_ptr_;
|
||||
G722_1_16_encinst_t_* encoder_inst16_ptr_right_;
|
||||
G722_1_24_encinst_t_* encoder_inst24_ptr_;
|
||||
G722_1_24_encinst_t_* encoder_inst24_ptr_right_;
|
||||
G722_1_32_encinst_t_* encoder_inst32_ptr_;
|
||||
G722_1_32_encinst_t_* encoder_inst32_ptr_right_;
|
||||
|
||||
// Only one of these pointer is valid at any instance
|
||||
G722_1_16_decinst_t_* _decoderInst16Ptr;
|
||||
G722_1_24_decinst_t_* _decoderInst24Ptr;
|
||||
G722_1_32_decinst_t_* _decoderInst32Ptr;
|
||||
G722_1_16_decinst_t_* decoder_inst16_ptr_;
|
||||
G722_1_24_decinst_t_* decoder_inst24_ptr_;
|
||||
G722_1_32_decinst_t_* decoder_inst32_ptr_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_
|
||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7221_H_
|
||||
|
@ -8,13 +8,14 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_g7221c.h"
|
||||
#include "acm_codec_database.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_g7221c.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_G722_1C
|
||||
// NOTE! G.722.1C is not included in the open-source package. The following
|
||||
@ -24,62 +25,63 @@
|
||||
//
|
||||
// The API in the header file should match the one below.
|
||||
//
|
||||
// int16_t WebRtcG7221C_CreateEnc24(G722_1C_24_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_CreateDec24(G722_1C_24_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_CreateEnc24(G722_1C_24_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221C_CreateEnc32(G722_1C_32_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221C_CreateEnc48(G722_1C_48_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221C_CreateDec24(G722_1C_24_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcG7221C_CreateDec32(G722_1C_32_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcG7221C_CreateDec48(G722_1C_48_decinst_t_** dec_inst);
|
||||
//
|
||||
// int16_t WebRtcG7221C_FreeEnc24(G722_1C_24_encinst_t_** encInst);
|
||||
// int16_t WebRtcG7221C_FreeEnc32(G722_1C_32_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_FreeDec32(G722_1C_32_decinst_t_** decInst);
|
||||
// int16_t WebRtcG7221C_FreeDec48(G722_1C_48_decinst_t_** decInst);
|
||||
// int16_t WebRtcG7221C_FreeEnc24(G722_1C_24_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221C_FreeEnc32(G722_1C_32_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221C_FreeEnc48(G722_1C_48_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221C_FreeDec24(G722_1C_24_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcG7221C_FreeDec32(G722_1C_32_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcG7221C_FreeDec48(G722_1C_48_decinst_t_** dec_inst);
|
||||
//
|
||||
// int16_t WebRtcG7221C_EncoderInit24(G722_1C_24_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_DecoderInit24(G722_1C_24_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_EncoderInit24(G722_1C_24_encinst_t_* enc_inst);
|
||||
// int16_t WebRtcG7221C_EncoderInit32(G722_1C_32_encinst_t_* enc_inst);
|
||||
// int16_t WebRtcG7221C_EncoderInit48(G722_1C_48_encinst_t_* enc_inst);
|
||||
// int16_t WebRtcG7221C_DecoderInit24(G722_1C_24_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcG7221C_DecoderInit32(G722_1C_32_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcG7221C_DecoderInit48(G722_1C_48_decinst_t_* dec_inst);
|
||||
//
|
||||
// int16_t WebRtcG7221C_Encode24(G722_1C_24_encinst_t_* encInst,
|
||||
// int16_t WebRtcG7221C_Encode24(G722_1C_24_encinst_t_* enc_inst,
|
||||
// int16_t* input,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
// int16_t WebRtcG7221C_Encode32(G722_1C_32_encinst_t_* encInst,
|
||||
// int16_t WebRtcG7221C_Encode32(G722_1C_32_encinst_t_* enc_inst,
|
||||
// int16_t* input,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
// int16_t WebRtcG7221C_Encode48(G722_1C_48_encinst_t_* encInst,
|
||||
// int16_t WebRtcG7221C_Encode48(G722_1C_48_encinst_t_* enc_inst,
|
||||
// int16_t* input,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
//
|
||||
// int16_t WebRtcG7221C_Decode24(G722_1C_24_decinst_t_* decInst,
|
||||
// int16_t WebRtcG7221C_Decode24(G722_1C_24_decinst_t_* dec_inst,
|
||||
// int16_t* bitstream,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
// int16_t WebRtcG7221C_Decode32(G722_1C_32_decinst_t_* decInst,
|
||||
// int16_t WebRtcG7221C_Decode32(G722_1C_32_decinst_t_* dec_inst,
|
||||
// int16_t* bitstream,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
// int16_t WebRtcG7221C_Decode48(G722_1C_48_decinst_t_* decInst,
|
||||
// int16_t WebRtcG7221C_Decode48(G722_1C_48_decinst_t_* dec_inst,
|
||||
// int16_t* bitstream,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
//
|
||||
// int16_t WebRtcG7221C_DecodePlc24(G722_1C_24_decinst_t_* decInst,
|
||||
// int16_t WebRtcG7221C_DecodePlc24(G722_1C_24_decinst_t_* dec_inst,
|
||||
// int16_t* output,
|
||||
// int16_t nrLostFrames);
|
||||
// int16_t WebRtcG7221C_DecodePlc32(G722_1C_32_decinst_t_* decInst,
|
||||
// int16_t nr_lost_frames);
|
||||
// int16_t WebRtcG7221C_DecodePlc32(G722_1C_32_decinst_t_* dec_inst,
|
||||
// int16_t* output,
|
||||
// int16_t nrLostFrames);
|
||||
// int16_t WebRtcG7221C_DecodePlc48(G722_1C_48_decinst_t_* decInst,
|
||||
// int16_t nr_lost_frames);
|
||||
// int16_t WebRtcG7221C_DecodePlc48(G722_1C_48_decinst_t_* dec_inst,
|
||||
// int16_t* output,
|
||||
// int16_t nrLostFrames);
|
||||
// int16_t nr_lost_frames);
|
||||
#include "g7221c_interface.h"
|
||||
#endif
|
||||
|
||||
@ -87,20 +89,20 @@ namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_G722_1C
|
||||
|
||||
ACMG722_1C::ACMG722_1C(WebRtc_Word16 /* codecID */)
|
||||
: _operationalRate(-1),
|
||||
_encoderInstPtr(NULL),
|
||||
_encoderInstPtrRight(NULL),
|
||||
_decoderInstPtr(NULL),
|
||||
_encoderInst24Ptr(NULL),
|
||||
_encoderInst24PtrR(NULL),
|
||||
_encoderInst32Ptr(NULL),
|
||||
_encoderInst32PtrR(NULL),
|
||||
_encoderInst48Ptr(NULL),
|
||||
_encoderInst48PtrR(NULL),
|
||||
_decoderInst24Ptr(NULL),
|
||||
_decoderInst32Ptr(NULL),
|
||||
_decoderInst48Ptr(NULL) {
|
||||
ACMG722_1C::ACMG722_1C(WebRtc_Word16 /* codec_id */)
|
||||
: operational_rate_(-1),
|
||||
encoder_inst_ptr_(NULL),
|
||||
encoder_inst_ptr_right_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
encoder_inst24_ptr_(NULL),
|
||||
encoder_inst24_ptr_right_(NULL),
|
||||
encoder_inst32_ptr_(NULL),
|
||||
encoder_inst32_ptr_right_(NULL),
|
||||
encoder_inst48_ptr_(NULL),
|
||||
encoder_inst48_ptr_right_(NULL),
|
||||
decoder_inst24_ptr_(NULL),
|
||||
decoder_inst32_ptr_(NULL),
|
||||
decoder_inst48_ptr_(NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -109,31 +111,31 @@ ACMG722_1C::~ACMG722_1C() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalEncode(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMG722_1C::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -157,66 +159,74 @@ void ACMG722_1C::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMG722_1C::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMG722_1C::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
ACMG722_1C::ACMG722_1C(WebRtc_Word16 codecID) :
|
||||
_encoderInstPtr(NULL), _encoderInstPtrRight(NULL), _decoderInstPtr(NULL),
|
||||
_encoderInst24Ptr(NULL), _encoderInst24PtrR(NULL), _encoderInst32Ptr(NULL),
|
||||
_encoderInst32PtrR(NULL), _encoderInst48Ptr(NULL), _encoderInst48PtrR(NULL),
|
||||
_decoderInst24Ptr(NULL), _decoderInst32Ptr(NULL), _decoderInst48Ptr(NULL) {
|
||||
_codecID = codecID;
|
||||
if (_codecID == ACMCodecDB::kG722_1C_24) {
|
||||
_operationalRate = 24000;
|
||||
} else if (_codecID == ACMCodecDB::kG722_1C_32) {
|
||||
_operationalRate = 32000;
|
||||
} else if (_codecID == ACMCodecDB::kG722_1C_48) {
|
||||
_operationalRate = 48000;
|
||||
ACMG722_1C::ACMG722_1C(WebRtc_Word16 codec_id)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
encoder_inst_ptr_right_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
encoder_inst24_ptr_(NULL),
|
||||
encoder_inst24_ptr_right_(NULL),
|
||||
encoder_inst32_ptr_(NULL),
|
||||
encoder_inst32_ptr_right_(NULL),
|
||||
encoder_inst48_ptr_(NULL),
|
||||
encoder_inst48_ptr_right_(NULL),
|
||||
decoder_inst24_ptr_(NULL),
|
||||
decoder_inst32_ptr_(NULL),
|
||||
decoder_inst48_ptr_(NULL) {
|
||||
codec_id_ = codec_id;
|
||||
if (codec_id_ == ACMCodecDB::kG722_1C_24) {
|
||||
operational_rate_ = 24000;
|
||||
} else if (codec_id_ == ACMCodecDB::kG722_1C_32) {
|
||||
operational_rate_ = 32000;
|
||||
} else if (codec_id_ == ACMCodecDB::kG722_1C_48) {
|
||||
operational_rate_ = 48000;
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Wrong codec id for G722_1c.");
|
||||
_operationalRate = -1;
|
||||
operational_rate_ = -1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ACMG722_1C::~ACMG722_1C() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
delete _encoderInstPtr;
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
delete encoder_inst_ptr_;
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_encoderInstPtrRight != NULL) {
|
||||
delete _encoderInstPtrRight;
|
||||
_encoderInstPtrRight = NULL;
|
||||
if (encoder_inst_ptr_right_ != NULL) {
|
||||
delete encoder_inst_ptr_right_;
|
||||
encoder_inst_ptr_right_ = NULL;
|
||||
}
|
||||
if (_decoderInstPtr != NULL) {
|
||||
delete _decoderInstPtr;
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
delete decoder_inst_ptr_;
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
_encoderInst24Ptr = NULL;
|
||||
_encoderInst24PtrR = NULL;
|
||||
_decoderInst24Ptr = NULL;
|
||||
encoder_inst24_ptr_ = NULL;
|
||||
encoder_inst24_ptr_right_ = NULL;
|
||||
decoder_inst24_ptr_ = NULL;
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
_encoderInst32Ptr = NULL;
|
||||
_encoderInst32PtrR = NULL;
|
||||
_decoderInst32Ptr = NULL;
|
||||
encoder_inst32_ptr_ = NULL;
|
||||
encoder_inst32_ptr_right_ = NULL;
|
||||
decoder_inst32_ptr_ = NULL;
|
||||
break;
|
||||
}
|
||||
case 48000: {
|
||||
_encoderInst48Ptr = NULL;
|
||||
_encoderInst48PtrR = NULL;
|
||||
_decoderInst48Ptr = NULL;
|
||||
encoder_inst48_ptr_ = NULL;
|
||||
encoder_inst48_ptr_right_ = NULL;
|
||||
decoder_inst48_ptr_ = NULL;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Wrong rate for G722_1c.");
|
||||
break;
|
||||
}
|
||||
@ -224,104 +234,107 @@ ACMG722_1C::~ACMG722_1C() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
WebRtc_Word16 leftChannel[640];
|
||||
WebRtc_Word16 rightChannel[640];
|
||||
WebRtc_Word16 lenInBytes;
|
||||
WebRtc_Word16 outB[240];
|
||||
WebRtc_Word16 ACMG722_1C::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
WebRtc_Word16 left_channel[640];
|
||||
WebRtc_Word16 right_channel[640];
|
||||
WebRtc_Word16 len_in_bytes;
|
||||
WebRtc_Word16 out_bits[240];
|
||||
|
||||
// If stereo, split input signal in left and right channel before encoding
|
||||
if (_noChannels == 2) {
|
||||
for (int i = 0, j = 0; i < _frameLenSmpl * 2; i += 2, j++) {
|
||||
leftChannel[j] = _inAudio[_inAudioIxRead + i];
|
||||
rightChannel[j] = _inAudio[_inAudioIxRead + i + 1];
|
||||
if (num_channels_ == 2) {
|
||||
for (int i = 0, j = 0; i < frame_len_smpl_ * 2; i += 2, j++) {
|
||||
left_channel[j] = in_audio_[in_audio_ix_read_ + i];
|
||||
right_channel[j] = in_audio_[in_audio_ix_read_ + i + 1];
|
||||
}
|
||||
} else {
|
||||
memcpy(leftChannel, &_inAudio[_inAudioIxRead], 640);
|
||||
memcpy(left_channel, &in_audio_[in_audio_ix_read_], 640);
|
||||
}
|
||||
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
lenInBytes = WebRtcG7221C_Encode24(_encoderInst24Ptr, leftChannel, 640,
|
||||
&outB[0]);
|
||||
if (_noChannels == 2) {
|
||||
lenInBytes += WebRtcG7221C_Encode24(_encoderInst24PtrR, rightChannel,
|
||||
640, &outB[lenInBytes / 2]);
|
||||
len_in_bytes = WebRtcG7221C_Encode24(encoder_inst24_ptr_, left_channel,
|
||||
640, &out_bits[0]);
|
||||
if (num_channels_ == 2) {
|
||||
len_in_bytes += WebRtcG7221C_Encode24(encoder_inst24_ptr_right_,
|
||||
right_channel, 640,
|
||||
&out_bits[len_in_bytes / 2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
lenInBytes = WebRtcG7221C_Encode32(_encoderInst32Ptr, leftChannel, 640,
|
||||
&outB[0]);
|
||||
if (_noChannels == 2) {
|
||||
lenInBytes += WebRtcG7221C_Encode32(_encoderInst32PtrR, rightChannel,
|
||||
640, &outB[lenInBytes / 2]);
|
||||
len_in_bytes = WebRtcG7221C_Encode32(encoder_inst32_ptr_, left_channel,
|
||||
640, &out_bits[0]);
|
||||
if (num_channels_ == 2) {
|
||||
len_in_bytes += WebRtcG7221C_Encode32(encoder_inst32_ptr_right_,
|
||||
right_channel, 640,
|
||||
&out_bits[len_in_bytes / 2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 48000: {
|
||||
lenInBytes = WebRtcG7221C_Encode48(_encoderInst48Ptr, leftChannel, 640,
|
||||
&outB[0]);
|
||||
if (_noChannels == 2) {
|
||||
lenInBytes += WebRtcG7221C_Encode48(_encoderInst48PtrR, rightChannel,
|
||||
640, &outB[lenInBytes / 2]);
|
||||
len_in_bytes = WebRtcG7221C_Encode48(encoder_inst48_ptr_, left_channel,
|
||||
640, &out_bits[0]);
|
||||
if (num_channels_ == 2) {
|
||||
len_in_bytes += WebRtcG7221C_Encode48(encoder_inst48_ptr_right_,
|
||||
right_channel, 640,
|
||||
&out_bits[len_in_bytes / 2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalEncode: Wrong rate for G722_1c.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(bitStream, outB, lenInBytes);
|
||||
*bitStreamLenByte = lenInBytes;
|
||||
memcpy(bitstream, out_bits, len_in_bytes);
|
||||
*bitstream_len_byte = len_in_bytes;
|
||||
|
||||
// increment the read index this tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer
|
||||
_inAudioIxRead += 640 * _noChannels;
|
||||
in_audio_ix_read_ += 640 * num_channels_;
|
||||
|
||||
return *bitStreamLenByte;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMG722_1C::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* codecParams) {
|
||||
WebRtcACMCodecParams* codec_params) {
|
||||
WebRtc_Word16 ret;
|
||||
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
ret = WebRtcG7221C_EncoderInit24(_encoderInst24PtrR);
|
||||
ret = WebRtcG7221C_EncoderInit24(encoder_inst24_ptr_right_);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return WebRtcG7221C_EncoderInit24(_encoderInst24Ptr);
|
||||
return WebRtcG7221C_EncoderInit24(encoder_inst24_ptr_);
|
||||
}
|
||||
case 32000: {
|
||||
ret = WebRtcG7221C_EncoderInit32(_encoderInst32PtrR);
|
||||
ret = WebRtcG7221C_EncoderInit32(encoder_inst32_ptr_right_);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return WebRtcG7221C_EncoderInit32(_encoderInst32Ptr);
|
||||
return WebRtcG7221C_EncoderInit32(encoder_inst32_ptr_);
|
||||
}
|
||||
case 48000: {
|
||||
ret = WebRtcG7221C_EncoderInit48(_encoderInst48PtrR);
|
||||
ret = WebRtcG7221C_EncoderInit48(encoder_inst48_ptr_right_);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return WebRtcG7221C_EncoderInit48(_encoderInst48Ptr);
|
||||
return WebRtcG7221C_EncoderInit48(encoder_inst48_ptr_);
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalInitEncode: Wrong rate for G722_1c.");
|
||||
return -1;
|
||||
}
|
||||
@ -329,30 +342,29 @@ WebRtc_Word16 ACMG722_1C::InternalInitEncoder(
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
switch (_operationalRate) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
return WebRtcG7221C_DecoderInit24(_decoderInst24Ptr);
|
||||
return WebRtcG7221C_DecoderInit24(decoder_inst24_ptr_);
|
||||
}
|
||||
case 32000: {
|
||||
return WebRtcG7221C_DecoderInit32(_decoderInst32Ptr);
|
||||
return WebRtcG7221C_DecoderInit32(decoder_inst32_ptr_);
|
||||
}
|
||||
case 48000: {
|
||||
return WebRtcG7221C_DecoderInit48(_decoderInst48Ptr);
|
||||
return WebRtcG7221C_DecoderInit48(decoder_inst48_ptr_);
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalInitDecoder: Wrong rate for G722_1c.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
|
||||
if (!_decoderInitialized) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"CodeDef: decoder not initialized for G722_1c");
|
||||
return -1;
|
||||
}
|
||||
@ -364,27 +376,27 @@ WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// "SET_CODEC_PAR" & "SET_G722_1_XX_FUNCTION."
|
||||
// Then return the structure back to NetEQ to add the codec to it's
|
||||
// database.
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
SET_CODEC_PAR((codecDef), kDecoderG722_1C_24, codecInst.pltype,
|
||||
_decoderInst24Ptr, 32000);
|
||||
SET_G722_1C_24_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderG722_1C_24, codec_inst.pltype,
|
||||
decoder_inst24_ptr_, 32000);
|
||||
SET_G722_1C_24_FUNCTIONS((codec_def));
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
SET_CODEC_PAR((codecDef), kDecoderG722_1C_32, codecInst.pltype,
|
||||
_decoderInst32Ptr, 32000);
|
||||
SET_G722_1C_32_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderG722_1C_32, codec_inst.pltype,
|
||||
decoder_inst32_ptr_, 32000);
|
||||
SET_G722_1C_32_FUNCTIONS((codec_def));
|
||||
break;
|
||||
}
|
||||
case 48000: {
|
||||
SET_CODEC_PAR((codecDef), kDecoderG722_1C_32, codecInst.pltype,
|
||||
_decoderInst48Ptr, 32000);
|
||||
SET_G722_1C_48_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderG722_1C_32, codec_inst.pltype,
|
||||
decoder_inst48_ptr_, 32000);
|
||||
SET_G722_1C_48_FUNCTIONS((codec_def));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"CodeDef: Wrong rate for G722_1c.");
|
||||
return -1;
|
||||
}
|
||||
@ -398,27 +410,27 @@ ACMG722_1C::CreateInstance(void) {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalCreateEncoder() {
|
||||
if ((_encoderInstPtr == NULL) || (_encoderInstPtrRight == NULL)) {
|
||||
if ((encoder_inst_ptr_ == NULL) || (encoder_inst_ptr_right_ == NULL)) {
|
||||
return -1;
|
||||
}
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
WebRtcG7221C_CreateEnc24(&_encoderInst24Ptr);
|
||||
WebRtcG7221C_CreateEnc24(&_encoderInst24PtrR);
|
||||
WebRtcG7221C_CreateEnc24(&encoder_inst24_ptr_);
|
||||
WebRtcG7221C_CreateEnc24(&encoder_inst24_ptr_right_);
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
WebRtcG7221C_CreateEnc32(&_encoderInst32Ptr);
|
||||
WebRtcG7221C_CreateEnc32(&_encoderInst32PtrR);
|
||||
WebRtcG7221C_CreateEnc32(&encoder_inst32_ptr_);
|
||||
WebRtcG7221C_CreateEnc32(&encoder_inst32_ptr_right_);
|
||||
break;
|
||||
}
|
||||
case 48000: {
|
||||
WebRtcG7221C_CreateEnc48(&_encoderInst48Ptr);
|
||||
WebRtcG7221C_CreateEnc48(&_encoderInst48PtrR);
|
||||
WebRtcG7221C_CreateEnc48(&encoder_inst48_ptr_);
|
||||
WebRtcG7221C_CreateEnc48(&encoder_inst48_ptr_right_);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateEncoder: Wrong rate for G722_1c.");
|
||||
return -1;
|
||||
}
|
||||
@ -427,42 +439,42 @@ WebRtc_Word16 ACMG722_1C::InternalCreateEncoder() {
|
||||
}
|
||||
|
||||
void ACMG722_1C::DestructEncoderSafe() {
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
if (_encoderInstPtr != NULL) {
|
||||
delete _encoderInstPtr;
|
||||
_encoderInstPtr = NULL;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
delete encoder_inst_ptr_;
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_encoderInstPtrRight != NULL) {
|
||||
delete _encoderInstPtrRight;
|
||||
_encoderInstPtrRight = NULL;
|
||||
if (encoder_inst_ptr_right_ != NULL) {
|
||||
delete encoder_inst_ptr_right_;
|
||||
encoder_inst_ptr_right_ = NULL;
|
||||
}
|
||||
_encoderInst24Ptr = NULL;
|
||||
_encoderInst32Ptr = NULL;
|
||||
_encoderInst48Ptr = NULL;
|
||||
encoder_inst24_ptr_ = NULL;
|
||||
encoder_inst32_ptr_ = NULL;
|
||||
encoder_inst48_ptr_ = NULL;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalCreateDecoder() {
|
||||
if (_decoderInstPtr == NULL) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (decoder_inst_ptr_ == NULL) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateEncoder: cannot create decoder");
|
||||
return -1;
|
||||
}
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
WebRtcG7221C_CreateDec24(&_decoderInst24Ptr);
|
||||
WebRtcG7221C_CreateDec24(&decoder_inst24_ptr_);
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
WebRtcG7221C_CreateDec32(&_decoderInst32Ptr);
|
||||
WebRtcG7221C_CreateDec32(&decoder_inst32_ptr_);
|
||||
break;
|
||||
}
|
||||
case 48000: {
|
||||
WebRtcG7221C_CreateDec48(&_decoderInst48Ptr);
|
||||
WebRtcG7221C_CreateDec48(&decoder_inst48_ptr_);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateEncoder: Wrong rate for G722_1c.");
|
||||
return -1;
|
||||
}
|
||||
@ -471,20 +483,20 @@ WebRtc_Word16 ACMG722_1C::InternalCreateDecoder() {
|
||||
}
|
||||
|
||||
void ACMG722_1C::DestructDecoderSafe() {
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
if (_decoderInstPtr != NULL) {
|
||||
delete _decoderInstPtr;
|
||||
_decoderInstPtr = NULL;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
delete decoder_inst_ptr_;
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
_decoderInst24Ptr = NULL;
|
||||
_decoderInst32Ptr = NULL;
|
||||
_decoderInst48Ptr = NULL;
|
||||
decoder_inst24_ptr_ = NULL;
|
||||
decoder_inst32_ptr_ = NULL;
|
||||
decoder_inst48_ptr_ = NULL;
|
||||
}
|
||||
|
||||
void ACMG722_1C::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
delete ptrInst;
|
||||
void ACMG722_1C::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
delete ptr_inst;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7221C_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7221C_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
// forward declaration
|
||||
struct G722_1C_24_encinst_t_;
|
||||
@ -24,35 +24,35 @@ struct G722_1_Inst_t_;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class ACMG722_1C : public ACMGenericCodec
|
||||
{
|
||||
class ACMG722_1C : public ACMGenericCodec {
|
||||
public:
|
||||
ACMG722_1C(WebRtc_Word16 codecID);
|
||||
explicit ACMG722_1C(WebRtc_Word16 codec_id);
|
||||
~ACMG722_1C();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(
|
||||
WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -63,28 +63,28 @@ protected:
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(
|
||||
void* ptrInst);
|
||||
void* ptr_inst);
|
||||
|
||||
WebRtc_Word32 _operationalRate;
|
||||
WebRtc_Word32 operational_rate_;
|
||||
|
||||
G722_1_Inst_t_* _encoderInstPtr;
|
||||
G722_1_Inst_t_* _encoderInstPtrRight; //Used in stereo mode
|
||||
G722_1_Inst_t_* _decoderInstPtr;
|
||||
G722_1_Inst_t_* encoder_inst_ptr_;
|
||||
G722_1_Inst_t_* encoder_inst_ptr_right_; // Used in stereo mode
|
||||
G722_1_Inst_t_* decoder_inst_ptr_;
|
||||
|
||||
// Only one set of these pointer is valid at any instance
|
||||
G722_1C_24_encinst_t_* _encoderInst24Ptr;
|
||||
G722_1C_24_encinst_t_* _encoderInst24PtrR;
|
||||
G722_1C_32_encinst_t_* _encoderInst32Ptr;
|
||||
G722_1C_32_encinst_t_* _encoderInst32PtrR;
|
||||
G722_1C_48_encinst_t_* _encoderInst48Ptr;
|
||||
G722_1C_48_encinst_t_* _encoderInst48PtrR;
|
||||
G722_1C_24_encinst_t_* encoder_inst24_ptr_;
|
||||
G722_1C_24_encinst_t_* encoder_inst24_ptr_right_;
|
||||
G722_1C_32_encinst_t_* encoder_inst32_ptr_;
|
||||
G722_1C_32_encinst_t_* encoder_inst32_ptr_right_;
|
||||
G722_1C_48_encinst_t_* encoder_inst48_ptr_;
|
||||
G722_1C_48_encinst_t_* encoder_inst48_ptr_right_;
|
||||
|
||||
// Only one of these pointer is valid at any instance
|
||||
G722_1C_24_decinst_t_* _decoderInst24Ptr;
|
||||
G722_1C_32_decinst_t_* _decoderInst32Ptr;
|
||||
G722_1C_48_decinst_t_* _decoderInst48Ptr;
|
||||
G722_1C_24_decinst_t_* decoder_inst24_ptr_;
|
||||
G722_1C_32_decinst_t_* decoder_inst32_ptr_;
|
||||
G722_1C_48_decinst_t_* decoder_inst48_ptr_;
|
||||
};
|
||||
|
||||
} // namespace webrtc;
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_
|
||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7221C_H_
|
||||
|
@ -8,12 +8,13 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_g729.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_g729.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_G729
|
||||
// NOTE! G.729 is not included in the open-source package. Modify this file
|
||||
@ -26,9 +27,9 @@ namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_G729
|
||||
|
||||
ACMG729::ACMG729(WebRtc_Word16 /* codecID */)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL) {
|
||||
ACMG729::ACMG729(WebRtc_Word16 /* codec_id */)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -36,8 +37,9 @@ ACMG729::~ACMG729() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_Word16 ACMG729::InternalEncode(
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -50,35 +52,35 @@ WebRtc_Word16 ACMG729::DisableDTX() {
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG729::ReplaceInternalDTXSafe(
|
||||
const bool /*replaceInternalDTX*/) {
|
||||
const bool /*replace_internal_dtx */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG729::IsInternalDTXReplacedSafe(
|
||||
bool* /* internalDTXReplaced */) {
|
||||
bool* /* internal_dtx_replaced */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -102,63 +104,63 @@ void ACMG729::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMG729::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMG729::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
ACMG729::ACMG729(WebRtc_Word16 codecID)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL) {
|
||||
_codecID = codecID;
|
||||
_hasInternalDTX = true;
|
||||
ACMG729::ACMG729(WebRtc_Word16 codec_id)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL) {
|
||||
codec_id_ = codec_id;
|
||||
has_internal_dtx_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
ACMG729::~ACMG729() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
// Delete encoder memory
|
||||
WebRtcG729_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
WebRtcG729_FreeEnc(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_decoderInstPtr != NULL) {
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
// Delete decoder memory
|
||||
WebRtcG729_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
WebRtcG729_FreeDec(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
// Initialize before entering the loop
|
||||
WebRtc_Word16 noEncodedSamples = 0;
|
||||
WebRtc_Word16 tmpLenByte = 0;
|
||||
WebRtc_Word16 vadDecision = 0;
|
||||
*bitStreamLenByte = 0;
|
||||
while (noEncodedSamples < _frameLenSmpl) {
|
||||
WebRtc_Word16 num_encoded_samples = 0;
|
||||
WebRtc_Word16 tmp_len_byte = 0;
|
||||
WebRtc_Word16 vad_decision = 0;
|
||||
*bitstream_len_byte = 0;
|
||||
while (num_encoded_samples < frame_len_smpl_) {
|
||||
// Call G.729 encoder with pointer to encoder memory, input
|
||||
// audio, number of samples and bitsream
|
||||
tmpLenByte = WebRtcG729_Encode(
|
||||
_encoderInstPtr, &_inAudio[_inAudioIxRead], 80,
|
||||
(WebRtc_Word16*) (&(bitStream[*bitStreamLenByte])));
|
||||
tmp_len_byte = WebRtcG729_Encode(
|
||||
encoder_inst_ptr_, &in_audio_[in_audio_ix_read_], 80,
|
||||
(WebRtc_Word16*)(&(bitstream[*bitstream_len_byte])));
|
||||
|
||||
// increment the read index this tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer
|
||||
_inAudioIxRead += 80;
|
||||
in_audio_ix_read_ += 80;
|
||||
|
||||
// sanity check
|
||||
if (tmpLenByte < 0) {
|
||||
if (tmp_len_byte < 0) {
|
||||
// error has happened
|
||||
*bitStreamLenByte = 0;
|
||||
*bitstream_len_byte = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// increment number of written bytes
|
||||
*bitStreamLenByte += tmpLenByte;
|
||||
switch (tmpLenByte) {
|
||||
*bitstream_len_byte += tmp_len_byte;
|
||||
switch (tmp_len_byte) {
|
||||
case 0: {
|
||||
if (0 == noEncodedSamples) {
|
||||
if (0 == num_encoded_samples) {
|
||||
// this is the first 10 ms in this packet and there is
|
||||
// no data generated, perhaps DTX is enabled and the
|
||||
// codec is not generating any bit-stream for this 10 ms.
|
||||
@ -169,18 +171,18 @@ WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
}
|
||||
case 2: {
|
||||
// check if G.729 internal DTX is enabled
|
||||
if (_hasInternalDTX && _dtxEnabled) {
|
||||
vadDecision = 0;
|
||||
if (has_internal_dtx_ && dtx_enabled_) {
|
||||
vad_decision = 0;
|
||||
for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
|
||||
_vadLabel[n] = vadDecision;
|
||||
vad_label_[n] = vad_decision;
|
||||
}
|
||||
}
|
||||
// we got a SID and have to send out this packet no matter
|
||||
// how much audio we have encoded
|
||||
return *bitStreamLenByte;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
case 10: {
|
||||
vadDecision = 1;
|
||||
vad_decision = 1;
|
||||
// this is a valid length just continue encoding
|
||||
break;
|
||||
}
|
||||
@ -190,30 +192,30 @@ WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
}
|
||||
|
||||
// update number of encoded samples
|
||||
noEncodedSamples += 80;
|
||||
num_encoded_samples += 80;
|
||||
}
|
||||
|
||||
// update VAD decision vector
|
||||
if (_hasInternalDTX && !vadDecision && _dtxEnabled) {
|
||||
if (has_internal_dtx_ && !vad_decision && dtx_enabled_) {
|
||||
for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
|
||||
_vadLabel[n] = vadDecision;
|
||||
vad_label_[n] = vad_decision;
|
||||
}
|
||||
}
|
||||
|
||||
// done encoding, return number of encoded bytes
|
||||
return *bitStreamLenByte;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729::EnableDTX() {
|
||||
if (_dtxEnabled) {
|
||||
if (dtx_enabled_) {
|
||||
// DTX already enabled, do nothing
|
||||
return 0;
|
||||
} else if (_encoderExist) {
|
||||
} else if (encoder_exist_) {
|
||||
// Re-init the G.729 encoder to turn on DTX
|
||||
if (WebRtcG729_EncoderInit(_encoderInstPtr, 1) < 0) {
|
||||
if (WebRtcG729_EncoderInit(encoder_inst_ptr_, 1) < 0) {
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = true;
|
||||
dtx_enabled_ = true;
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
@ -221,15 +223,15 @@ WebRtc_Word16 ACMG729::EnableDTX() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729::DisableDTX() {
|
||||
if (!_dtxEnabled) {
|
||||
if (!dtx_enabled_) {
|
||||
// DTX already dissabled, do nothing
|
||||
return 0;
|
||||
} else if (_encoderExist) {
|
||||
} else if (encoder_exist_) {
|
||||
// Re-init the G.729 decoder to turn off DTX
|
||||
if (WebRtcG729_EncoderInit(_encoderInstPtr, 0) < 0) {
|
||||
if (WebRtcG729_EncoderInit(encoder_inst_ptr_, 0) < 0) {
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = false;
|
||||
dtx_enabled_ = false;
|
||||
return 0;
|
||||
} else {
|
||||
// encoder doesn't exists, therefore disabling is harmless
|
||||
@ -237,67 +239,67 @@ WebRtc_Word16 ACMG729::DisableDTX() {
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG729::ReplaceInternalDTXSafe(const bool replaceInternalDTX) {
|
||||
WebRtc_Word32 ACMG729::ReplaceInternalDTXSafe(const bool replace_internal_dtx) {
|
||||
// This function is used to disable the G.729 built in DTX and use an
|
||||
// external instead.
|
||||
|
||||
if (replaceInternalDTX == _hasInternalDTX) {
|
||||
if (replace_internal_dtx == has_internal_dtx_) {
|
||||
// Make sure we keep the DTX/VAD setting if possible
|
||||
bool oldEnableDTX = _dtxEnabled;
|
||||
bool oldEnableVAD = _vadEnabled;
|
||||
ACMVADMode oldMode = _vadMode;
|
||||
if (replaceInternalDTX) {
|
||||
bool old_enable_dtx = dtx_enabled_;
|
||||
bool old_enable_vad = vad_enabled_;
|
||||
ACMVADMode old_mode = vad_mode_;
|
||||
if (replace_internal_dtx) {
|
||||
// Disable internal DTX before enabling external DTX
|
||||
DisableDTX();
|
||||
} else {
|
||||
// Disable external DTX before enabling internal
|
||||
ACMGenericCodec::DisableDTX();
|
||||
}
|
||||
_hasInternalDTX = !replaceInternalDTX;
|
||||
WebRtc_Word16 status = SetVADSafe(oldEnableDTX, oldEnableVAD, oldMode);
|
||||
has_internal_dtx_ = !replace_internal_dtx;
|
||||
WebRtc_Word16 status = SetVADSafe(old_enable_dtx, old_enable_vad, old_mode);
|
||||
// Check if VAD status has changed from inactive to active, or if error was
|
||||
// reported
|
||||
if (status == 1) {
|
||||
_vadEnabled = true;
|
||||
vad_enabled_ = true;
|
||||
return status;
|
||||
} else if (status < 0) {
|
||||
_hasInternalDTX = replaceInternalDTX;
|
||||
has_internal_dtx_ = replace_internal_dtx;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG729::IsInternalDTXReplacedSafe(bool* internalDTXReplaced) {
|
||||
WebRtc_Word32 ACMG729::IsInternalDTXReplacedSafe(bool* internal_dtx_replaced) {
|
||||
// Get status of wether DTX is replaced or not
|
||||
*internalDTXReplaced = !_hasInternalDTX;
|
||||
*internal_dtx_replaced = !has_internal_dtx_;
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
// This function is not used. G.729 decoder is called from inside NetEQ
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
WebRtc_Word16 ACMG729::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
|
||||
// Init G.729 encoder
|
||||
return WebRtcG729_EncoderInit(_encoderInstPtr,
|
||||
((codecParams->enableDTX) ? 1 : 0));
|
||||
return WebRtcG729_EncoderInit(encoder_inst_ptr_,
|
||||
((codec_params->enable_dtx) ? 1 : 0));
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
// Init G.729 decoder
|
||||
return WebRtcG729_DecoderInit(_decoderInstPtr);
|
||||
return WebRtcG729_DecoderInit(decoder_inst_ptr_);
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
// Todo:
|
||||
// log error
|
||||
return -1;
|
||||
@ -307,9 +309,9 @@ WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// "SET_CODEC_PAR" & "SET_G729_FUNCTION."
|
||||
// Then call NetEQ to add the codec to it's
|
||||
// database.
|
||||
SET_CODEC_PAR((codecDef), kDecoderG729, codecInst.pltype, _decoderInstPtr,
|
||||
SET_CODEC_PAR((codec_def), kDecoderG729, codec_inst.pltype, decoder_inst_ptr_,
|
||||
8000);
|
||||
SET_G729_FUNCTIONS((codecDef));
|
||||
SET_G729_FUNCTIONS((codec_def));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -320,37 +322,37 @@ ACMGenericCodec* ACMG729::CreateInstance(void) {
|
||||
|
||||
WebRtc_Word16 ACMG729::InternalCreateEncoder() {
|
||||
// Create encoder memory
|
||||
return WebRtcG729_CreateEnc(&_encoderInstPtr);
|
||||
return WebRtcG729_CreateEnc(&encoder_inst_ptr_);
|
||||
}
|
||||
|
||||
void ACMG729::DestructEncoderSafe() {
|
||||
// Free encoder memory
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcG729_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcG729_FreeEnc(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729::InternalCreateDecoder() {
|
||||
// Create decoder memory
|
||||
return WebRtcG729_CreateDec(&_decoderInstPtr);
|
||||
return WebRtcG729_CreateDec(&decoder_inst_ptr_);
|
||||
}
|
||||
|
||||
void ACMG729::DestructDecoderSafe() {
|
||||
// Free decoder memory
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcG729_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcG729_FreeDec(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ACMG729::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcG729_FreeEnc((G729_encinst_t_*) ptrInst);
|
||||
void ACMG729::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
WebRtcG729_FreeEnc((G729_encinst_t_*) ptr_inst);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
// forward declaration
|
||||
struct G729_encinst_t_;
|
||||
@ -21,27 +21,28 @@ namespace webrtc {
|
||||
|
||||
class ACMG729 : public ACMGenericCodec {
|
||||
public:
|
||||
ACMG729(WebRtc_Word16 codecID);
|
||||
explicit ACMG729(WebRtc_Word16 codec_id);
|
||||
~ACMG729();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -51,18 +52,18 @@ class ACMG729 : public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
WebRtc_Word16 EnableDTX();
|
||||
|
||||
WebRtc_Word16 DisableDTX();
|
||||
|
||||
WebRtc_Word32 ReplaceInternalDTXSafe(const bool replaceInternalDTX);
|
||||
WebRtc_Word32 ReplaceInternalDTXSafe(const bool replace_internal_dtx);
|
||||
|
||||
WebRtc_Word32 IsInternalDTXReplacedSafe(bool* internalDTXReplaced);
|
||||
WebRtc_Word32 IsInternalDTXReplacedSafe(bool* internal_dtx_replaced);
|
||||
|
||||
G729_encinst_t_* _encoderInstPtr;
|
||||
G729_decinst_t_* _decoderInstPtr;
|
||||
G729_encinst_t_* encoder_inst_ptr_;
|
||||
G729_decinst_t_* decoder_inst_ptr_;
|
||||
|
||||
};
|
||||
|
||||
|
@ -8,13 +8,13 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_g7291.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_g7291.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
#ifdef WEBRTC_CODEC_G729_1
|
||||
// NOTE! G.729.1 is not included in the open-source package. Modify this file
|
||||
// or your codec API to match the function calls and names of used G.729.1 API
|
||||
@ -26,12 +26,12 @@ namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_G729_1
|
||||
|
||||
ACMG729_1::ACMG729_1(WebRtc_Word16 /* codecID */)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL),
|
||||
_myRate(32000),
|
||||
_flag8kHz(0),
|
||||
_flagG729mode(0) {
|
||||
ACMG729_1::ACMG729_1(WebRtc_Word16 /* codec_id */)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
my_rate_(32000),
|
||||
flag_8khz_(0),
|
||||
flag_g729_mode_(0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -39,31 +39,32 @@ ACMG729_1::~ACMG729_1() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729_1::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_Word16 ACMG729_1::InternalEncode(
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729_1::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729_1::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -87,7 +88,7 @@ void ACMG729_1::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMG729_1::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMG729_1::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -99,113 +100,114 @@ WebRtc_Word16 ACMG729_1::SetBitRateSafe(const WebRtc_Word32 /*rate*/) {
|
||||
|
||||
struct G729_1_inst_t_;
|
||||
|
||||
ACMG729_1::ACMG729_1(WebRtc_Word16 codecID)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL),
|
||||
_myRate(32000), // Default rate.
|
||||
_flag8kHz(0),
|
||||
_flagG729mode(0) {
|
||||
// TODO(tlegrand): We should add codecID as a input variable to the
|
||||
ACMG729_1::ACMG729_1(WebRtc_Word16 codec_id)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
my_rate_(32000), // Default rate.
|
||||
flag_8khz_(0),
|
||||
flag_g729_mode_(0) {
|
||||
// TODO(tlegrand): We should add codec_id as a input variable to the
|
||||
// constructor of ACMGenericCodec.
|
||||
_codecID = codecID;
|
||||
codec_id_ = codec_id;
|
||||
return;
|
||||
}
|
||||
|
||||
ACMG729_1::~ACMG729_1() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcG7291_Free(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcG7291_Free(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcG7291_Free(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcG7291_Free(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729_1::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
WebRtc_Word16 ACMG729_1::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
|
||||
// Initialize before entering the loop
|
||||
WebRtc_Word16 noEncodedSamples = 0;
|
||||
*bitStreamLenByte = 0;
|
||||
WebRtc_Word16 num_encoded_samples = 0;
|
||||
*bitstream_len_byte = 0;
|
||||
|
||||
WebRtc_Word16 byteLengthFrame = 0;
|
||||
WebRtc_Word16 byte_length_frame = 0;
|
||||
|
||||
// Derive number of 20ms frames per encoded packet.
|
||||
// [1,2,3] <=> [20,40,60]ms <=> [320,640,960] samples
|
||||
WebRtc_Word16 n20msFrames = (_frameLenSmpl / 320);
|
||||
WebRtc_Word16 num_20ms_frames = (frame_len_smpl_ / 320);
|
||||
// Byte length for the frame. +1 is for rate information.
|
||||
byteLengthFrame = _myRate / (8 * 50) * n20msFrames + (1 - _flagG729mode);
|
||||
byte_length_frame = my_rate_ / (8 * 50) * num_20ms_frames + (1 -
|
||||
flag_g729_mode_);
|
||||
|
||||
// The following might be revised if we have G729.1 Annex C (support for DTX);
|
||||
do {
|
||||
*bitStreamLenByte = WebRtcG7291_Encode(_encoderInstPtr,
|
||||
&_inAudio[_inAudioIxRead],
|
||||
(WebRtc_Word16*) bitStream, _myRate,
|
||||
n20msFrames);
|
||||
*bitstream_len_byte = WebRtcG7291_Encode(encoder_inst_ptr_,
|
||||
&in_audio_[in_audio_ix_read_],
|
||||
(WebRtc_Word16*) bitstream,
|
||||
my_rate_, num_20ms_frames);
|
||||
|
||||
// increment the read index this tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer
|
||||
_inAudioIxRead += 160;
|
||||
in_audio_ix_read_ += 160;
|
||||
|
||||
// sanity check
|
||||
if (*bitStreamLenByte < 0) {
|
||||
if (*bitstream_len_byte < 0) {
|
||||
// error has happened
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalEncode: Encode error for G729_1");
|
||||
*bitStreamLenByte = 0;
|
||||
*bitstream_len_byte = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
noEncodedSamples += 160;
|
||||
} while (*bitStreamLenByte == 0);
|
||||
num_encoded_samples += 160;
|
||||
} while (*bitstream_len_byte == 0);
|
||||
|
||||
// This criteria will change if we have Annex C.
|
||||
if (*bitStreamLenByte != byteLengthFrame) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (*bitstream_len_byte != byte_length_frame) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalEncode: Encode error for G729_1");
|
||||
*bitStreamLenByte = 0;
|
||||
*bitstream_len_byte = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (noEncodedSamples != _frameLenSmpl) {
|
||||
*bitStreamLenByte = 0;
|
||||
if (num_encoded_samples != frame_len_smpl_) {
|
||||
*bitstream_len_byte = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return *bitStreamLenByte;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729_1::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* codecParams) {
|
||||
WebRtcACMCodecParams* codec_params) {
|
||||
//set the bit rate and initialize
|
||||
_myRate = codecParams->codecInstant.rate;
|
||||
return SetBitRateSafe((WebRtc_UWord32) _myRate);
|
||||
my_rate_ = codec_params->codec_inst.rate;
|
||||
return SetBitRateSafe((WebRtc_UWord32) my_rate_);
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729_1::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
if (WebRtcG7291_DecoderInit(_decoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
if (WebRtcG7291_DecoderInit(decoder_inst_ptr_) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalInitDecoder: init decoder failed for G729_1");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"CodeDef: Decoder uninitialized for G729_1");
|
||||
return -1;
|
||||
}
|
||||
@ -214,9 +216,9 @@ WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// "SET_CODEC_PAR" & "SET_G729_FUNCTION."
|
||||
// Then call NetEQ to add the codec to it's
|
||||
// database.
|
||||
SET_CODEC_PAR((codecDef), kDecoderG729_1, codecInst.pltype, _decoderInstPtr,
|
||||
16000);
|
||||
SET_G729_1_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderG729_1, codec_inst.pltype,
|
||||
decoder_inst_ptr_, 16000);
|
||||
SET_G729_1_FUNCTIONS((codec_def));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -225,8 +227,8 @@ ACMGenericCodec* ACMG729_1::CreateInstance(void) {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729_1::InternalCreateEncoder() {
|
||||
if (WebRtcG7291_Create(&_encoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (WebRtcG7291_Create(&encoder_inst_ptr_) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateEncoder: create encoder failed for G729_1");
|
||||
return -1;
|
||||
}
|
||||
@ -234,17 +236,17 @@ WebRtc_Word16 ACMG729_1::InternalCreateEncoder() {
|
||||
}
|
||||
|
||||
void ACMG729_1::DestructEncoderSafe() {
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcG7291_Free(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcG7291_Free(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG729_1::InternalCreateDecoder() {
|
||||
if (WebRtcG7291_Create(&_decoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (WebRtcG7291_Create(&decoder_inst_ptr_) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateDecoder: create decoder failed for G729_1");
|
||||
return -1;
|
||||
}
|
||||
@ -252,16 +254,16 @@ WebRtc_Word16 ACMG729_1::InternalCreateDecoder() {
|
||||
}
|
||||
|
||||
void ACMG729_1::DestructDecoderSafe() {
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcG7291_Free(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcG7291_Free(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ACMG729_1::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
void ACMG729_1::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
// WebRtcG7291_Free((G729_1_inst_t*)ptrInst);
|
||||
}
|
||||
return;
|
||||
@ -274,64 +276,64 @@ WebRtc_Word16 ACMG729_1::SetBitRateSafe(const WebRtc_Word32 rate) {
|
||||
// possible to reuse code.
|
||||
switch (rate) {
|
||||
case 8000: {
|
||||
_myRate = 8000;
|
||||
my_rate_ = 8000;
|
||||
break;
|
||||
}
|
||||
case 12000: {
|
||||
_myRate = 12000;
|
||||
my_rate_ = 12000;
|
||||
break;
|
||||
}
|
||||
case 14000: {
|
||||
_myRate = 14000;
|
||||
my_rate_ = 14000;
|
||||
break;
|
||||
}
|
||||
case 16000: {
|
||||
_myRate = 16000;
|
||||
my_rate_ = 16000;
|
||||
break;
|
||||
}
|
||||
case 18000: {
|
||||
_myRate = 18000;
|
||||
my_rate_ = 18000;
|
||||
break;
|
||||
}
|
||||
case 20000: {
|
||||
_myRate = 20000;
|
||||
my_rate_ = 20000;
|
||||
break;
|
||||
}
|
||||
case 22000: {
|
||||
_myRate = 22000;
|
||||
my_rate_ = 22000;
|
||||
break;
|
||||
}
|
||||
case 24000: {
|
||||
_myRate = 24000;
|
||||
my_rate_ = 24000;
|
||||
break;
|
||||
}
|
||||
case 26000: {
|
||||
_myRate = 26000;
|
||||
my_rate_ = 26000;
|
||||
break;
|
||||
}
|
||||
case 28000: {
|
||||
_myRate = 28000;
|
||||
my_rate_ = 28000;
|
||||
break;
|
||||
}
|
||||
case 30000: {
|
||||
_myRate = 30000;
|
||||
my_rate_ = 30000;
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
_myRate = 32000;
|
||||
my_rate_ = 32000;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"SetBitRateSafe: Invalid rate G729_1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Re-init with new rate
|
||||
if (WebRtcG7291_EncoderInit(_encoderInstPtr, _myRate, _flag8kHz,
|
||||
_flagG729mode) >= 0) {
|
||||
_encoderParams.codecInstant.rate = _myRate;
|
||||
if (WebRtcG7291_EncoderInit(encoder_inst_ptr_, my_rate_, flag_8khz_,
|
||||
flag_g729_mode_) >= 0) {
|
||||
encoder_params_.codec_inst.rate = my_rate_;
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -8,10 +8,10 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7291_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7291_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
// forward declaration
|
||||
struct G729_1_inst_t_;
|
||||
@ -21,27 +21,28 @@ namespace webrtc {
|
||||
|
||||
class ACMG729_1 : public ACMGenericCodec {
|
||||
public:
|
||||
ACMG729_1(WebRtc_Word16 codecID);
|
||||
explicit ACMG729_1(WebRtc_Word16 codec_id);
|
||||
~ACMG729_1();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -51,18 +52,18 @@ class ACMG729_1 : public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
|
||||
|
||||
G729_1_inst_t_* _encoderInstPtr;
|
||||
G729_1_inst_t_* _decoderInstPtr;
|
||||
G729_1_inst_t_* encoder_inst_ptr_;
|
||||
G729_1_inst_t_* decoder_inst_ptr_;
|
||||
|
||||
WebRtc_UWord16 _myRate;
|
||||
WebRtc_Word16 _flag8kHz;
|
||||
WebRtc_Word16 _flagG729mode;
|
||||
WebRtc_UWord16 my_rate_;
|
||||
WebRtc_Word16 flag_8khz_;
|
||||
WebRtc_Word16 flag_g729_mode_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_
|
||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G7291_H_
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -8,13 +8,13 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_gsmfr.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_gsmfr.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
#ifdef WEBRTC_CODEC_GSMFR
|
||||
// NOTE! GSM-FR is not included in the open-source package. Modify this file
|
||||
// or your codec API to match the function calls and names of used GSM-FR API
|
||||
@ -26,9 +26,9 @@ namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_GSMFR
|
||||
|
||||
ACMGSMFR::ACMGSMFR(WebRtc_Word16 /* codecID */)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL) {
|
||||
ACMGSMFR::ACMGSMFR(WebRtc_Word16 /* codec_id */)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -36,16 +36,17 @@ ACMGSMFR::~ACMGSMFR() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMGSMFR::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_Word16 ACMGSMFR::InternalEncode(
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -58,17 +59,17 @@ WebRtc_Word16 ACMGSMFR::DisableDTX() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMGSMFR::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMGSMFR::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -92,62 +93,62 @@ void ACMGSMFR::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMGSMFR::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMGSMFR::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
|
||||
ACMGSMFR::ACMGSMFR(WebRtc_Word16 codecID)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL) {
|
||||
_codecID = codecID;
|
||||
_hasInternalDTX = true;
|
||||
ACMGSMFR::ACMGSMFR(WebRtc_Word16 codec_id)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL) {
|
||||
codec_id_ = codec_id;
|
||||
has_internal_dtx_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
ACMGSMFR::~ACMGSMFR() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcGSMFR_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcGSMFR_FreeEnc(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcGSMFR_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcGSMFR_FreeDec(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMGSMFR::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
*bitStreamLenByte = WebRtcGSMFR_Encode(_encoderInstPtr,
|
||||
&_inAudio[_inAudioIxRead],
|
||||
_frameLenSmpl,
|
||||
(WebRtc_Word16*) bitStream);
|
||||
WebRtc_Word16 ACMGSMFR::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
*bitstream_len_byte = WebRtcGSMFR_Encode(encoder_inst_ptr_,
|
||||
&in_audio_[in_audio_ix_read_],
|
||||
frame_len_smpl_,
|
||||
(WebRtc_Word16*)bitstream);
|
||||
// increment the read index this tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer
|
||||
_inAudioIxRead += _frameLenSmpl;
|
||||
return *bitStreamLenByte;
|
||||
in_audio_ix_read_ += frame_len_smpl_;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMGSMFR::EnableDTX() {
|
||||
if (_dtxEnabled) {
|
||||
if (dtx_enabled_) {
|
||||
return 0;
|
||||
} else if (_encoderExist) {
|
||||
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, 1) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
} else if (encoder_exist_) {
|
||||
if (WebRtcGSMFR_EncoderInit(encoder_inst_ptr_, 1) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"EnableDTX: cannot init encoder for GSMFR");
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = true;
|
||||
dtx_enabled_ = true;
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
@ -155,15 +156,15 @@ WebRtc_Word16 ACMGSMFR::EnableDTX() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMGSMFR::DisableDTX() {
|
||||
if (!_dtxEnabled) {
|
||||
if (!dtx_enabled_) {
|
||||
return 0;
|
||||
} else if (_encoderExist) {
|
||||
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, 0) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
} else if (encoder_exist_) {
|
||||
if (WebRtcGSMFR_EncoderInit(encoder_inst_ptr_, 0) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"DisableDTX: cannot init encoder for GSMFR");
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = false;
|
||||
dtx_enabled_ = false;
|
||||
return 0;
|
||||
} else {
|
||||
// encoder doesn't exists, therefore disabling is harmless
|
||||
@ -171,29 +172,30 @@ WebRtc_Word16 ACMGSMFR::DisableDTX() {
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMGSMFR::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr,
|
||||
((codecParams->enableDTX) ? 1 : 0)) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WebRtc_Word16 ACMGSMFR::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* codec_params) {
|
||||
if (WebRtcGSMFR_EncoderInit(encoder_inst_ptr_,
|
||||
((codec_params->enable_dtx) ? 1 : 0)) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalInitEncoder: cannot init encoder for GSMFR");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMGSMFR::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
if (WebRtcGSMFR_DecoderInit(_decoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
if (WebRtcGSMFR_DecoderInit(decoder_inst_ptr_) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalInitDecoder: cannot init decoder for GSMFR");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"CodecDef: decoder is not initialized for GSMFR");
|
||||
return -1;
|
||||
}
|
||||
@ -201,9 +203,9 @@ WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// "SET_CODEC_PAR" & "SET_GSMFR_FUNCTION."
|
||||
// Then call NetEQ to add the codec to it's
|
||||
// database.
|
||||
SET_CODEC_PAR((codecDef), kDecoderGSMFR, codecInst.pltype, _decoderInstPtr,
|
||||
8000);
|
||||
SET_GSMFR_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderGSMFR, codec_inst.pltype,
|
||||
decoder_inst_ptr_, 8000);
|
||||
SET_GSMFR_FUNCTIONS((codec_def));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -212,44 +214,46 @@ ACMGenericCodec* ACMGSMFR::CreateInstance(void) {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMGSMFR::InternalCreateEncoder() {
|
||||
if (WebRtcGSMFR_CreateEnc(&_encoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalCreateEncoder: cannot create instance for GSMFR encoder");
|
||||
if (WebRtcGSMFR_CreateEnc(&encoder_inst_ptr_) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateEncoder: cannot create instance for GSMFR "
|
||||
"encoder");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMGSMFR::DestructEncoderSafe() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcGSMFR_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcGSMFR_FreeEnc(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMGSMFR::InternalCreateDecoder() {
|
||||
if (WebRtcGSMFR_CreateDec(&_decoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalCreateDecoder: cannot create instance for GSMFR decoder");
|
||||
if (WebRtcGSMFR_CreateDec(&decoder_inst_ptr_) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateDecoder: cannot create instance for GSMFR "
|
||||
"decoder");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMGSMFR::DestructDecoderSafe() {
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcGSMFR_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcGSMFR_FreeDec(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
}
|
||||
|
||||
void ACMGSMFR::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcGSMFR_FreeEnc((GSMFR_encinst_t_*) ptrInst);
|
||||
void ACMGSMFR::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
WebRtcGSMFR_FreeEnc((GSMFR_encinst_t_*) ptr_inst);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
// forward declaration
|
||||
struct GSMFR_encinst_t_;
|
||||
@ -21,27 +21,28 @@ namespace webrtc {
|
||||
|
||||
class ACMGSMFR : public ACMGenericCodec {
|
||||
public:
|
||||
ACMGSMFR(WebRtc_Word16 codecID);
|
||||
explicit ACMGSMFR(WebRtc_Word16 codec_id);
|
||||
~ACMGSMFR();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -51,14 +52,14 @@ class ACMGSMFR : public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
WebRtc_Word16 EnableDTX();
|
||||
|
||||
WebRtc_Word16 DisableDTX();
|
||||
|
||||
GSMFR_encinst_t_* _encoderInstPtr;
|
||||
GSMFR_decinst_t_* _decoderInstPtr;
|
||||
GSMFR_encinst_t_* encoder_inst_ptr_;
|
||||
GSMFR_decinst_t_* decoder_inst_ptr_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -7,25 +7,25 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_ilbc.h"
|
||||
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_ilbc.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_ILBC
|
||||
#include "ilbc.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h"
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_ILBC
|
||||
|
||||
ACMILBC::ACMILBC(WebRtc_Word16 /* codecID */)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL) {
|
||||
ACMILBC::ACMILBC(WebRtc_Word16 /* codec_id */)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -33,31 +33,32 @@ ACMILBC::~ACMILBC() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMILBC::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_Word16 ACMILBC::InternalEncode(
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMILBC::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMILBC::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -81,7 +82,7 @@ void ACMILBC::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMILBC::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMILBC::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -91,88 +92,88 @@ WebRtc_Word16 ACMILBC::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
|
||||
ACMILBC::ACMILBC(WebRtc_Word16 codecID)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL) {
|
||||
_codecID = codecID;
|
||||
ACMILBC::ACMILBC(WebRtc_Word16 codec_id)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL) {
|
||||
codec_id_ = codec_id;
|
||||
return;
|
||||
}
|
||||
|
||||
ACMILBC::~ACMILBC() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcIlbcfix_EncoderFree(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcIlbcfix_EncoderFree(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcIlbcfix_DecoderFree(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcIlbcfix_DecoderFree(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMILBC::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
*bitStreamLenByte = WebRtcIlbcfix_Encode(_encoderInstPtr,
|
||||
&_inAudio[_inAudioIxRead],
|
||||
_frameLenSmpl,
|
||||
(WebRtc_Word16*) bitStream);
|
||||
if (*bitStreamLenByte < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WebRtc_Word16 ACMILBC::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
*bitstream_len_byte = WebRtcIlbcfix_Encode(encoder_inst_ptr_,
|
||||
&in_audio_[in_audio_ix_read_],
|
||||
frame_len_smpl_,
|
||||
(WebRtc_Word16*)bitstream);
|
||||
if (*bitstream_len_byte < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalEncode: error in encode for ILBC");
|
||||
return -1;
|
||||
}
|
||||
// increment the read index this tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer
|
||||
_inAudioIxRead += _frameLenSmpl;
|
||||
return *bitStreamLenByte;
|
||||
in_audio_ix_read_ += frame_len_smpl_;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMILBC::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
WebRtc_Word16 ACMILBC::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
|
||||
// initialize with a correct processing block length
|
||||
if ((160 == (codecParams->codecInstant).pacsize) ||
|
||||
(320 == (codecParams->codecInstant).pacsize)) {
|
||||
if ((160 == (codec_params->codec_inst).pacsize) ||
|
||||
(320 == (codec_params->codec_inst).pacsize)) {
|
||||
// processing block of 20ms
|
||||
return WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20);
|
||||
} else if ((240 == (codecParams->codecInstant).pacsize) ||
|
||||
(480 == (codecParams->codecInstant).pacsize)) {
|
||||
return WebRtcIlbcfix_EncoderInit(encoder_inst_ptr_, 20);
|
||||
} else if ((240 == (codec_params->codec_inst).pacsize) ||
|
||||
(480 == (codec_params->codec_inst).pacsize)) {
|
||||
// processing block of 30ms
|
||||
return WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30);
|
||||
return WebRtcIlbcfix_EncoderInit(encoder_inst_ptr_, 30);
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalInitEncoder: invalid processing block");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMILBC::InternalInitDecoder(WebRtcACMCodecParams* codecParams) {
|
||||
WebRtc_Word16 ACMILBC::InternalInitDecoder(WebRtcACMCodecParams* codec_params) {
|
||||
// initialize with a correct processing block length
|
||||
if ((160 == (codecParams->codecInstant).pacsize) ||
|
||||
(320 == (codecParams->codecInstant).pacsize)) {
|
||||
if ((160 == (codec_params->codec_inst).pacsize) ||
|
||||
(320 == (codec_params->codec_inst).pacsize)) {
|
||||
// processing block of 20ms
|
||||
return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 20);
|
||||
} else if ((240 == (codecParams->codecInstant).pacsize) ||
|
||||
(480 == (codecParams->codecInstant).pacsize)) {
|
||||
return WebRtcIlbcfix_DecoderInit(decoder_inst_ptr_, 20);
|
||||
} else if ((240 == (codec_params->codec_inst).pacsize) ||
|
||||
(480 == (codec_params->codec_inst).pacsize)) {
|
||||
// processing block of 30ms
|
||||
return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 30);
|
||||
return WebRtcIlbcfix_DecoderInit(decoder_inst_ptr_, 30);
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalInitDecoder: invalid processing block");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"CodeDef: decoder not initialized for ILBC");
|
||||
return -1;
|
||||
}
|
||||
@ -180,9 +181,9 @@ WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// "SET_CODEC_PAR" & "SET_ILBC_FUNCTION."
|
||||
// Then return the structure back to NetEQ to add the codec to it's
|
||||
// database.
|
||||
SET_CODEC_PAR((codecDef), kDecoderILBC, codecInst.pltype, _decoderInstPtr,
|
||||
SET_CODEC_PAR((codec_def), kDecoderILBC, codec_inst.pltype, decoder_inst_ptr_,
|
||||
8000);
|
||||
SET_ILBC_FUNCTIONS((codecDef));
|
||||
SET_ILBC_FUNCTIONS((codec_def));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -191,44 +192,46 @@ ACMGenericCodec* ACMILBC::CreateInstance(void) {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMILBC::InternalCreateEncoder() {
|
||||
if (WebRtcIlbcfix_EncoderCreate(&_encoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalCreateEncoder: cannot create instance for ILBC encoder");
|
||||
if (WebRtcIlbcfix_EncoderCreate(&encoder_inst_ptr_) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateEncoder: cannot create instance for ILBC "
|
||||
"encoder");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMILBC::DestructEncoderSafe() {
|
||||
_encoderInitialized = false;
|
||||
_encoderExist = false;
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcIlbcfix_EncoderFree(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
encoder_initialized_ = false;
|
||||
encoder_exist_ = false;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcIlbcfix_EncoderFree(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMILBC::InternalCreateDecoder() {
|
||||
if (WebRtcIlbcfix_DecoderCreate(&_decoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalCreateDecoder: cannot create instance for ILBC decoder");
|
||||
if (WebRtcIlbcfix_DecoderCreate(&decoder_inst_ptr_) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateDecoder: cannot create instance for ILBC "
|
||||
"decoder");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMILBC::DestructDecoderSafe() {
|
||||
_decoderInitialized = false;
|
||||
_decoderExist = false;
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcIlbcfix_DecoderFree(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
decoder_initialized_ = false;
|
||||
decoder_exist_ = false;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcIlbcfix_DecoderFree(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ACMILBC::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcIlbcfix_EncoderFree((iLBC_encinst_t_*) ptrInst);
|
||||
void ACMILBC::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
WebRtcIlbcfix_EncoderFree((iLBC_encinst_t_*) ptr_inst);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -236,13 +239,13 @@ void ACMILBC::InternalDestructEncoderInst(void* ptrInst) {
|
||||
WebRtc_Word16 ACMILBC::SetBitRateSafe(const WebRtc_Word32 rate) {
|
||||
// Check that rate is valid. No need to store the value
|
||||
if (rate == 13300) {
|
||||
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30);
|
||||
WebRtcIlbcfix_EncoderInit(encoder_inst_ptr_, 30);
|
||||
} else if (rate == 15200) {
|
||||
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20);
|
||||
WebRtcIlbcfix_EncoderInit(encoder_inst_ptr_, 20);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
_encoderParams.codecInstant.rate = rate;
|
||||
encoder_params_.codec_inst.rate = rate;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
// forward declaration
|
||||
struct iLBC_encinst_t_;
|
||||
@ -21,27 +21,28 @@ namespace webrtc {
|
||||
|
||||
class ACMILBC : public ACMGenericCodec {
|
||||
public:
|
||||
ACMILBC(WebRtc_Word16 codecID);
|
||||
explicit ACMILBC(WebRtc_Word16 codec_id);
|
||||
~ACMILBC();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
|
||||
|
||||
@ -53,10 +54,10 @@ class ACMILBC : public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
iLBC_encinst_t_* _encoderInstPtr;
|
||||
iLBC_decinst_t_* _decoderInstPtr;
|
||||
iLBC_encinst_t_* encoder_inst_ptr_;
|
||||
iLBC_decinst_t_* decoder_inst_ptr_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,112 +11,118 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
struct ACMISACInst;
|
||||
|
||||
enum iSACCodingMode {
|
||||
enum IsacCodingMode {
|
||||
ADAPTIVE,
|
||||
CHANNEL_INDEPENDENT
|
||||
};
|
||||
|
||||
class ACMISAC : public ACMGenericCodec {
|
||||
public:
|
||||
ACMISAC(WebRtc_Word16 codecID);
|
||||
explicit ACMISAC(WebRtc_Word16 codec_id);
|
||||
~ACMISAC();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 DeliverCachedIsacData(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte,
|
||||
WebRtc_Word16 DeliverCachedIsacData(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte,
|
||||
WebRtc_UWord32* timestamp,
|
||||
WebRtcACMEncodingType* encodingType,
|
||||
const WebRtc_UWord16 isacRate,
|
||||
const WebRtc_UWord8 isacBWestimate);
|
||||
WebRtcACMEncodingType* encoding_type,
|
||||
const WebRtc_UWord16 isac_rate,
|
||||
const WebRtc_UWord8 isac_bwestimate);
|
||||
|
||||
WebRtc_Word16 DeliverCachedData(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */,
|
||||
WebRtc_Word16 DeliverCachedData(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */,
|
||||
WebRtc_UWord32* /* timestamp */,
|
||||
WebRtcACMEncodingType* /* encodingType */) {
|
||||
WebRtcACMEncodingType* /* encoding_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 UpdateDecoderSampFreq(WebRtc_Word16 codecId);
|
||||
WebRtc_Word16 UpdateDecoderSampFreq(WebRtc_Word16 codec_id);
|
||||
|
||||
WebRtc_Word16 UpdateEncoderSampFreq(WebRtc_UWord16 sampFreqHz);
|
||||
WebRtc_Word16 UpdateEncoderSampFreq(WebRtc_UWord16 samp_freq_hz);
|
||||
|
||||
WebRtc_Word16 EncoderSampFreq(WebRtc_UWord16& sampFreqHz);
|
||||
WebRtc_Word16 EncoderSampFreq(WebRtc_UWord16& samp_freq_hz);
|
||||
|
||||
WebRtc_Word32 ConfigISACBandwidthEstimator(
|
||||
const WebRtc_UWord8 initFrameSizeMsec,
|
||||
const WebRtc_UWord16 initRateBitPerSec, const bool enforceFrameSize);
|
||||
const WebRtc_UWord8 init_frame_size_msec,
|
||||
const WebRtc_UWord16 init_rate_bit_per_sec,
|
||||
const bool enforce_frame_size);
|
||||
|
||||
WebRtc_Word32 SetISACMaxPayloadSize(const WebRtc_UWord16 maxPayloadLenBytes);
|
||||
WebRtc_Word32 SetISACMaxPayloadSize(
|
||||
const WebRtc_UWord16 max_payload_len_bytes);
|
||||
|
||||
WebRtc_Word32 SetISACMaxRate(const WebRtc_UWord32 maxRateBitPerSec);
|
||||
WebRtc_Word32 SetISACMaxRate(const WebRtc_UWord32 max_rate_bit_per_sec);
|
||||
|
||||
WebRtc_Word16 REDPayloadISAC(const WebRtc_Word32 isacRate,
|
||||
const WebRtc_Word16 isacBwEstimate,
|
||||
WebRtc_Word16 REDPayloadISAC(const WebRtc_Word32 isac_rate,
|
||||
const WebRtc_Word16 isac_bw_estimate,
|
||||
WebRtc_UWord8* payload,
|
||||
WebRtc_Word16* payloadLenBytes);
|
||||
WebRtc_Word16* payload_len_bytes);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
void DestructDecoderSafe();
|
||||
|
||||
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 bitRate);
|
||||
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 bit_rate);
|
||||
|
||||
WebRtc_Word32 GetEstimatedBandwidthSafe();
|
||||
|
||||
WebRtc_Word32 SetEstimatedBandwidthSafe(WebRtc_Word32 estimatedBandwidth);
|
||||
WebRtc_Word32 SetEstimatedBandwidthSafe(WebRtc_Word32 estimated_bandwidth);
|
||||
|
||||
WebRtc_Word32 GetRedPayloadSafe(WebRtc_UWord8* redPayload,
|
||||
WebRtc_Word16* payloadBytes);
|
||||
WebRtc_Word32 GetRedPayloadSafe(WebRtc_UWord8* red_payload,
|
||||
WebRtc_Word16* payload_bytes);
|
||||
|
||||
WebRtc_Word16 InternalCreateEncoder();
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
WebRtc_Word16 Transcode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte, WebRtc_Word16 qBWE,
|
||||
WebRtc_Word32 rate, bool isRED);
|
||||
WebRtc_Word16 Transcode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte,
|
||||
WebRtc_Word16 q_bwe,
|
||||
WebRtc_Word32 rate,
|
||||
bool is_red);
|
||||
|
||||
void CurrentRate(WebRtc_Word32& rateBitPerSec);
|
||||
void CurrentRate(WebRtc_Word32& rate_bit_per_sec);
|
||||
|
||||
void UpdateFrameLen();
|
||||
|
||||
bool DecoderParamsSafe(WebRtcACMCodecParams *decParams,
|
||||
const WebRtc_UWord8 payloadType);
|
||||
bool DecoderParamsSafe(WebRtcACMCodecParams *dec_params,
|
||||
const WebRtc_UWord8 payload_type);
|
||||
|
||||
void SaveDecoderParamSafe(const WebRtcACMCodecParams* codecParams);
|
||||
void SaveDecoderParamSafe(const WebRtcACMCodecParams* codec_params);
|
||||
|
||||
ACMISACInst* _codecInstPtr;
|
||||
bool _isEncInitialized;
|
||||
iSACCodingMode _isacCodingMode;
|
||||
bool _enforceFrameSize;
|
||||
WebRtc_Word32 _isacCurrentBN;
|
||||
WebRtc_UWord16 _samplesIn10MsAudio;
|
||||
WebRtcACMCodecParams _decoderParams32kHz;
|
||||
ACMISACInst* codec_inst_ptr_;
|
||||
bool is_enc_initialized_;
|
||||
IsacCodingMode isac_coding_mode_;
|
||||
bool enforce_frame_size_;
|
||||
WebRtc_Word32 isac_current_bn_;
|
||||
WebRtc_UWord16 samples_in_10ms_audio_;
|
||||
WebRtcACMCodecParams decoder_params_32khz_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_
|
||||
|
||||
#include "engine_configurations.h"
|
||||
#include "webrtc/engine_configurations.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,26 +11,29 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_
|
||||
|
||||
#include "audio_coding_module.h"
|
||||
#include "audio_coding_module_typedefs.h"
|
||||
#include "engine_configurations.h"
|
||||
#include "module_common_types.h"
|
||||
#include "typedefs.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_vad.h"
|
||||
#include "webrtc/common_audio/vad/include/webrtc_vad.h"
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
|
||||
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/interface/module_common_types.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class CriticalSectionWrapper;
|
||||
class RWLockWrapper;
|
||||
struct CodecInst;
|
||||
enum AudioPlayoutMode;
|
||||
enum ACMSpeechType;
|
||||
|
||||
#define MAX_NUM_SLAVE_NETEQ 1
|
||||
|
||||
class ACMNetEQ {
|
||||
public:
|
||||
enum JitterBuffer {
|
||||
kMasterJb = 0,
|
||||
kSlaveJb = 1
|
||||
};
|
||||
|
||||
// Constructor of the class
|
||||
ACMNetEQ();
|
||||
|
||||
@ -52,72 +55,73 @@ class ACMNetEQ {
|
||||
// Gives the payload to NetEQ.
|
||||
//
|
||||
// Input:
|
||||
// - incomingPayload : Incoming audio payload.
|
||||
// - payloadLength : Length of incoming audio payload.
|
||||
// - rtpInfo : RTP header for the incoming payload containing
|
||||
// - incoming_payload : Incoming audio payload.
|
||||
// - length_payload : Length of incoming audio payload.
|
||||
// - rtp_info : RTP header for the incoming payload containing
|
||||
// information about payload type, sequence number,
|
||||
// timestamp, ssrc and marker bit.
|
||||
// timestamp, SSRC and marker bit.
|
||||
//
|
||||
// Return value : 0 if ok.
|
||||
// <0 if NetEQ returned an error.
|
||||
//
|
||||
WebRtc_Word32 RecIn(const WebRtc_UWord8* incomingPayload,
|
||||
const WebRtc_Word32 payloadLength,
|
||||
const WebRtcRTPHeader& rtpInfo);
|
||||
WebRtc_Word32 RecIn(const WebRtc_UWord8* incoming_payload,
|
||||
const WebRtc_Word32 length_payload,
|
||||
const WebRtcRTPHeader& rtp_info);
|
||||
|
||||
//
|
||||
// RecOut()
|
||||
// Asks NetEQ for 10 ms of decoded audio.
|
||||
//
|
||||
// Input:
|
||||
// -audioFrame : an audio frame were output data and
|
||||
// -audio_frame : an audio frame were output data and
|
||||
// associated parameters are written to.
|
||||
//
|
||||
// Return value : 0 if ok.
|
||||
// -1 if NetEQ returned an error.
|
||||
//
|
||||
WebRtc_Word32 RecOut(AudioFrame& audioFrame);
|
||||
WebRtc_Word32 RecOut(AudioFrame& audio_frame);
|
||||
|
||||
//
|
||||
// AddCodec()
|
||||
// Adds a new codec to the NetEQ codec database.
|
||||
//
|
||||
// Input:
|
||||
// - codecDef : The codec to be added.
|
||||
// - toMaster : true if the codec has to be added to Master
|
||||
// - codec_def : The codec to be added.
|
||||
// - to_master : true if the codec has to be added to Master
|
||||
// NetEq, otherwise will be added to the Slave
|
||||
// NetEQ.
|
||||
//
|
||||
// Return value : 0 if ok.
|
||||
// <0 if NetEQ returned an error.
|
||||
//
|
||||
WebRtc_Word32 AddCodec(WebRtcNetEQ_CodecDef *codecDef, bool toMaster = true);
|
||||
WebRtc_Word32 AddCodec(WebRtcNetEQ_CodecDef *codec_def,
|
||||
bool to_master = true);
|
||||
|
||||
//
|
||||
// AllocatePacketBuffer()
|
||||
// Allocates the NetEQ packet buffer.
|
||||
//
|
||||
// Input:
|
||||
// - usedCodecs : An array of the codecs to be used by NetEQ.
|
||||
// - noOfCodecs : Number of codecs in usedCodecs.
|
||||
// - used_codecs : An array of the codecs to be used by NetEQ.
|
||||
// - num_codecs : Number of codecs in used_codecs.
|
||||
//
|
||||
// Return value : 0 if ok.
|
||||
// <0 if NetEQ returned an error.
|
||||
//
|
||||
WebRtc_Word32 AllocatePacketBuffer(const WebRtcNetEQDecoder* usedCodecs,
|
||||
WebRtc_Word16 noOfCodecs);
|
||||
WebRtc_Word32 AllocatePacketBuffer(const WebRtcNetEQDecoder* used_codecs,
|
||||
WebRtc_Word16 num_codecs);
|
||||
|
||||
//
|
||||
// SetExtraDelay()
|
||||
// Sets an delayInMS milliseconds extra delay in NetEQ.
|
||||
// Sets a |delay_in_ms| milliseconds extra delay in NetEQ.
|
||||
//
|
||||
// Input:
|
||||
// - delayInMS : Extra delay in milliseconds.
|
||||
// - delay_in_ms : Extra delay in milliseconds.
|
||||
//
|
||||
// Return value : 0 if ok.
|
||||
// <0 if NetEQ returned an error.
|
||||
//
|
||||
WebRtc_Word32 SetExtraDelay(const WebRtc_Word32 delayInMS);
|
||||
WebRtc_Word32 SetExtraDelay(const WebRtc_Word32 delay_in_ms);
|
||||
|
||||
//
|
||||
// SetAVTPlayout()
|
||||
@ -138,7 +142,7 @@ class ACMNetEQ {
|
||||
// Return value : True if AVT playout is enabled.
|
||||
// False if AVT playout is disabled.
|
||||
//
|
||||
bool AVTPlayout() const;
|
||||
bool avt_playout() const;
|
||||
|
||||
//
|
||||
// CurrentSampFreqHz()
|
||||
@ -167,7 +171,7 @@ class ACMNetEQ {
|
||||
//
|
||||
// Return value : The current playout mode.
|
||||
//
|
||||
AudioPlayoutMode PlayoutMode() const;
|
||||
AudioPlayoutMode playout_mode() const;
|
||||
|
||||
//
|
||||
// NetworkStatistics()
|
||||
@ -187,7 +191,7 @@ class ACMNetEQ {
|
||||
//
|
||||
// Return value : The current VAD mode.
|
||||
//
|
||||
ACMVADMode VADMode() const;
|
||||
ACMVADMode vad_mode() const;
|
||||
|
||||
//
|
||||
// SetVADMode()
|
||||
@ -208,7 +212,7 @@ class ACMNetEQ {
|
||||
// Return value : Pointer to the decode lock.
|
||||
//
|
||||
RWLockWrapper* DecodeLock() const {
|
||||
return _decodeLock;
|
||||
return decode_lock_;
|
||||
}
|
||||
|
||||
//
|
||||
@ -225,12 +229,13 @@ class ACMNetEQ {
|
||||
// Removes a codec from the NetEQ codec database.
|
||||
//
|
||||
// Input:
|
||||
// - codecIdx : Codec to be removed.
|
||||
// - codec_idx : Codec to be removed.
|
||||
//
|
||||
// Return value : 0 if ok.
|
||||
// -1 if an error occurred.
|
||||
//
|
||||
WebRtc_Word16 RemoveCodec(WebRtcNetEQDecoder codecIdx, bool isStereo = false);
|
||||
WebRtc_Word16 RemoveCodec(WebRtcNetEQDecoder codec_idx,
|
||||
bool is_stereo = false);
|
||||
|
||||
//
|
||||
// SetBackgroundNoiseMode()
|
||||
@ -253,24 +258,19 @@ class ACMNetEQ {
|
||||
//
|
||||
WebRtc_Word16 BackgroundNoiseMode(ACMBackgroundNoiseMode& mode);
|
||||
|
||||
void SetUniqueId(WebRtc_Word32 id);
|
||||
void set_id(WebRtc_Word32 id);
|
||||
|
||||
WebRtc_Word32 PlayoutTimestamp(WebRtc_UWord32& timestamp);
|
||||
|
||||
void SetReceivedStereo(bool receivedStereo);
|
||||
void set_received_stereo(bool received_stereo);
|
||||
|
||||
WebRtc_UWord8 NumSlaves();
|
||||
|
||||
enum JB {
|
||||
masterJB = 0,
|
||||
slaveJB = 1
|
||||
};
|
||||
WebRtc_UWord8 num_slaves();
|
||||
|
||||
// Delete all slaves.
|
||||
void RemoveSlaves();
|
||||
|
||||
WebRtc_Word16 AddSlave(const WebRtcNetEQDecoder* usedCodecs,
|
||||
WebRtc_Word16 noOfCodecs);
|
||||
WebRtc_Word16 AddSlave(const WebRtcNetEQDecoder* used_codecs,
|
||||
WebRtc_Word16 num_codecs);
|
||||
|
||||
private:
|
||||
//
|
||||
@ -280,20 +280,21 @@ class ACMNetEQ {
|
||||
//
|
||||
// Input:
|
||||
// - payload : Payload to be packetized.
|
||||
// - payloadLengthW8 : Length of the payload in bytes.
|
||||
// - rtpInfo : RTP header struct.
|
||||
// - payload_length_bytes : Length of the payload in bytes.
|
||||
// - rtp_info : RTP header structure.
|
||||
//
|
||||
// Output:
|
||||
// - rtpPacket : The RTP packet.
|
||||
// - rtp_packet : The RTP packet.
|
||||
//
|
||||
static void RTPPack(WebRtc_Word16* rtpPacket, const WebRtc_Word8* payload,
|
||||
const WebRtc_Word32 payloadLengthW8,
|
||||
const WebRtcRTPHeader& rtpInfo);
|
||||
static void RTPPack(WebRtc_Word16* rtp_packet, const WebRtc_Word8* payload,
|
||||
const WebRtc_Word32 payload_length_bytes,
|
||||
const WebRtcRTPHeader& rtp_info);
|
||||
|
||||
void LogError(const char* neteqFuncName, const WebRtc_Word16 idx) const;
|
||||
void LogError(const char* neteq_func_name, const WebRtc_Word16 idx) const;
|
||||
|
||||
WebRtc_Word16 InitByIdxSafe(const WebRtc_Word16 idx);
|
||||
|
||||
//
|
||||
// EnableVAD()
|
||||
// Enable VAD.
|
||||
//
|
||||
@ -305,8 +306,8 @@ class ACMNetEQ {
|
||||
WebRtc_Word16 EnableVADByIdxSafe(const WebRtc_Word16 idx);
|
||||
|
||||
WebRtc_Word16 AllocatePacketBufferByIdxSafe(
|
||||
const WebRtcNetEQDecoder* usedCodecs,
|
||||
WebRtc_Word16 noOfCodecs,
|
||||
const WebRtcNetEQDecoder* used_codecs,
|
||||
WebRtc_Word16 num_codecs,
|
||||
const WebRtc_Word16 idx);
|
||||
|
||||
// Delete the NetEQ corresponding to |index|.
|
||||
@ -314,30 +315,30 @@ class ACMNetEQ {
|
||||
|
||||
void RemoveSlavesSafe();
|
||||
|
||||
void* _inst[MAX_NUM_SLAVE_NETEQ + 1];
|
||||
void* _instMem[MAX_NUM_SLAVE_NETEQ + 1];
|
||||
void* inst_[MAX_NUM_SLAVE_NETEQ + 1];
|
||||
void* inst_mem_[MAX_NUM_SLAVE_NETEQ + 1];
|
||||
|
||||
WebRtc_Word16* _netEqPacketBuffer[MAX_NUM_SLAVE_NETEQ + 1];
|
||||
WebRtc_Word16* neteq_packet_buffer_[MAX_NUM_SLAVE_NETEQ + 1];
|
||||
|
||||
WebRtc_Word32 _id;
|
||||
float _currentSampFreqKHz;
|
||||
bool _avtPlayout;
|
||||
AudioPlayoutMode _playoutMode;
|
||||
CriticalSectionWrapper* _netEqCritSect;
|
||||
WebRtc_Word32 id_;
|
||||
float current_samp_freq_khz_;
|
||||
bool avt_playout_;
|
||||
AudioPlayoutMode playout_mode_;
|
||||
CriticalSectionWrapper* neteq_crit_sect_;
|
||||
|
||||
WebRtcVadInst* _ptrVADInst[MAX_NUM_SLAVE_NETEQ + 1];
|
||||
WebRtcVadInst* ptr_vadinst_[MAX_NUM_SLAVE_NETEQ + 1];
|
||||
|
||||
bool _vadStatus;
|
||||
ACMVADMode _vadMode;
|
||||
RWLockWrapper* _decodeLock;
|
||||
bool _isInitialized[MAX_NUM_SLAVE_NETEQ + 1];
|
||||
WebRtc_UWord8 _numSlaves;
|
||||
bool _receivedStereo;
|
||||
void* _masterSlaveInfo;
|
||||
AudioFrame::VADActivity _previousAudioActivity;
|
||||
WebRtc_Word32 _extraDelay;
|
||||
bool vad_status_;
|
||||
ACMVADMode vad_mode_;
|
||||
RWLockWrapper* decode_lock_;
|
||||
bool is_initialized_[MAX_NUM_SLAVE_NETEQ + 1];
|
||||
WebRtc_UWord8 num_slaves_;
|
||||
bool received_stereo_;
|
||||
void* master_slave_info_;
|
||||
AudioFrame::VADActivity previous_audio_activity_;
|
||||
WebRtc_Word32 extra_delay_;
|
||||
|
||||
CriticalSectionWrapper* _callbackCritSect;
|
||||
CriticalSectionWrapper* callback_crit_sect_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -10,16 +10,17 @@
|
||||
|
||||
// This file contains unit tests for ACM's NetEQ wrapper (class ACMNetEQ).
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "modules/audio_coding/codecs/pcm16b/include/pcm16b.h"
|
||||
#include "modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
|
||||
#include "modules/audio_coding/main/source/acm_codec_database.h"
|
||||
#include "modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "modules/interface/module_common_types.h"
|
||||
#include "typedefs.h" // NOLINT(build/include)
|
||||
#include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h"
|
||||
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/interface/module_common_types.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
@ -8,29 +8,29 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_opus.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_opus.h"
|
||||
|
||||
#include "acm_codec_database.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
#include "modules/audio_coding/codecs/opus/interface/opus_interface.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h"
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_OPUS
|
||||
|
||||
ACMOpus::ACMOpus(int16_t /* codecID */)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL),
|
||||
_sampleFreq(0),
|
||||
_bitrate(0),
|
||||
_channels(1) {
|
||||
ACMOpus::ACMOpus(int16_t /* codec_id */)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
sample_freq_(0),
|
||||
bitrate_(0),
|
||||
channels_(1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -38,29 +38,29 @@ ACMOpus::~ACMOpus() {
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t ACMOpus::InternalEncode(uint8_t* /* bitStream */,
|
||||
int16_t* /* bitStreamLenByte */) {
|
||||
int16_t ACMOpus::InternalEncode(uint8_t* /* bitstream */,
|
||||
int16_t* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int16_t ACMOpus::DecodeSafe(uint8_t* /* bitStream */,
|
||||
int16_t /* bitStreamLenByte */,
|
||||
int16_t ACMOpus::DecodeSafe(uint8_t* /* bitstream */,
|
||||
int16_t /* bitstream_len_byte */,
|
||||
int16_t* /* audio */,
|
||||
int16_t* /* audioSamples */,
|
||||
int8_t* /* speechType */) {
|
||||
int16_t* /* audio_samples */,
|
||||
int8_t* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int16_t ACMOpus::InternalInitEncoder(WebRtcACMCodecParams* /* codecParams */) {
|
||||
int16_t ACMOpus::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int16_t ACMOpus::InternalInitDecoder(WebRtcACMCodecParams* /* codecParams */) {
|
||||
int16_t ACMOpus::InternalInitDecoder(WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t ACMOpus::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
int32_t ACMOpus::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ void ACMOpus::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMOpus::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMOpus::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -101,119 +101,120 @@ void ACMOpus::SplitStereoPacket(uint8_t* /*payload*/,
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
|
||||
ACMOpus::ACMOpus(int16_t codecID)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL),
|
||||
_sampleFreq(32000), // Default sampling frequency.
|
||||
_bitrate(20000), // Default bit-rate.
|
||||
_channels(1) { // Default mono
|
||||
_codecID = codecID;
|
||||
ACMOpus::ACMOpus(int16_t codec_id)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
sample_freq_(32000), // Default sampling frequency.
|
||||
bitrate_(20000), // Default bit-rate.
|
||||
channels_(1) { // Default mono
|
||||
codec_id_ = codec_id;
|
||||
// Opus has internal DTX, but we dont use it for now.
|
||||
_hasInternalDTX = false;
|
||||
has_internal_dtx_ = false;
|
||||
|
||||
if (_codecID != ACMCodecDB::kOpus) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (codec_id_ != ACMCodecDB::kOpus) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Wrong codec id for Opus.");
|
||||
_sampleFreq = -1;
|
||||
_bitrate = -1;
|
||||
sample_freq_ = -1;
|
||||
bitrate_ = -1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ACMOpus::~ACMOpus() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcOpus_EncoderFree(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcOpus_EncoderFree(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcOpus_DecoderFree(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcOpus_DecoderFree(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t ACMOpus::InternalEncode(uint8_t* bitStream, int16_t* bitStreamLenByte) {
|
||||
int16_t ACMOpus::InternalEncode(uint8_t* bitstream,
|
||||
int16_t* bitstream_len_byte) {
|
||||
// Call Encoder.
|
||||
*bitStreamLenByte = WebRtcOpus_Encode(_encoderInstPtr,
|
||||
&_inAudio[_inAudioIxRead],
|
||||
_frameLenSmpl,
|
||||
MAX_PAYLOAD_SIZE_BYTE,
|
||||
bitStream);
|
||||
*bitstream_len_byte = WebRtcOpus_Encode(encoder_inst_ptr_,
|
||||
&in_audio_[in_audio_ix_read_],
|
||||
frame_len_smpl_,
|
||||
MAX_PAYLOAD_SIZE_BYTE, bitstream);
|
||||
// Check for error reported from encoder.
|
||||
if (*bitStreamLenByte < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (*bitstream_len_byte < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalEncode: Encode error for Opus");
|
||||
*bitStreamLenByte = 0;
|
||||
*bitstream_len_byte = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Increment the read index. This tells the caller how far
|
||||
// we have gone forward in reading the audio buffer.
|
||||
_inAudioIxRead += _frameLenSmpl * _channels;
|
||||
in_audio_ix_read_ += frame_len_smpl_ * channels_;
|
||||
|
||||
return *bitStreamLenByte;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
int16_t ACMOpus::DecodeSafe(uint8_t* bitStream, int16_t bitStreamLenByte,
|
||||
int16_t* audio, int16_t* audioSamples,
|
||||
int8_t* speechType) {
|
||||
int16_t ACMOpus::DecodeSafe(uint8_t* bitstream, int16_t bitstream_len_byte,
|
||||
int16_t* audio, int16_t* audio_samples,
|
||||
int8_t* speech_type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16_t ACMOpus::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
int16_t ACMOpus::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
|
||||
int16_t ret;
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcOpus_EncoderFree(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcOpus_EncoderFree(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
ret = WebRtcOpus_EncoderCreate(&_encoderInstPtr,
|
||||
codecParams->codecInstant.channels);
|
||||
ret = WebRtcOpus_EncoderCreate(&encoder_inst_ptr_,
|
||||
codec_params->codec_inst.channels);
|
||||
// Store number of channels.
|
||||
_channels = codecParams->codecInstant.channels;
|
||||
channels_ = codec_params->codec_inst.channels;
|
||||
|
||||
if (ret < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Encoder creation failed for Opus");
|
||||
return ret;
|
||||
}
|
||||
ret = WebRtcOpus_SetBitRate(_encoderInstPtr, codecParams->codecInstant.rate);
|
||||
ret = WebRtcOpus_SetBitRate(encoder_inst_ptr_,
|
||||
codec_params->codec_inst.rate);
|
||||
if (ret < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Setting initial bitrate failed for Opus");
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Store bitrate.
|
||||
_bitrate = codecParams->codecInstant.rate;
|
||||
bitrate_ = codec_params->codec_inst.rate;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16_t ACMOpus::InternalInitDecoder(WebRtcACMCodecParams* codecParams) {
|
||||
if(_decoderInstPtr == NULL) {
|
||||
if (WebRtcOpus_DecoderCreate(&_decoderInstPtr,
|
||||
codecParams->codecInstant.channels) < 0) {
|
||||
int16_t ACMOpus::InternalInitDecoder(WebRtcACMCodecParams* codec_params) {
|
||||
if (decoder_inst_ptr_ == NULL) {
|
||||
if (WebRtcOpus_DecoderCreate(&decoder_inst_ptr_,
|
||||
codec_params->codec_inst.channels) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Number of channels in decoder should match the number in |codecParams|.
|
||||
assert(codecParams->codecInstant.channels ==
|
||||
WebRtcOpus_DecoderChannels(_decoderInstPtr));
|
||||
// Number of channels in decoder should match the number in |codec_params|.
|
||||
assert(codec_params->codec_inst.channels ==
|
||||
WebRtcOpus_DecoderChannels(decoder_inst_ptr_));
|
||||
|
||||
if (WebRtcOpus_DecoderInit(_decoderInstPtr) < 0) {
|
||||
if (WebRtcOpus_DecoderInit(decoder_inst_ptr_) < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (WebRtcOpus_DecoderInitSlave(_decoderInstPtr) < 0) {
|
||||
if (WebRtcOpus_DecoderInitSlave(decoder_inst_ptr_) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ACMOpus::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
int32_t ACMOpus::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"CodeDef: Decoder uninitialized for Opus");
|
||||
return -1;
|
||||
}
|
||||
@ -223,21 +224,20 @@ int32_t ACMOpus::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// TODO(tlegrand): Decoder is registered in NetEQ as a 32 kHz decoder, which
|
||||
// is true until we have a full 48 kHz system, and remove the downsampling
|
||||
// in the Opus decoder wrapper.
|
||||
SET_CODEC_PAR(codecDef, kDecoderOpus, codecInst.pltype,
|
||||
_decoderInstPtr, 32000);
|
||||
SET_CODEC_PAR(codec_def, kDecoderOpus, codec_inst.pltype,
|
||||
decoder_inst_ptr_, 32000);
|
||||
|
||||
// If this is the master of NetEQ, regular decoder will be added, otherwise
|
||||
// the slave decoder will be used.
|
||||
if (_isMaster) {
|
||||
SET_OPUS_FUNCTIONS(codecDef);
|
||||
if (is_master_) {
|
||||
SET_OPUS_FUNCTIONS(codec_def);
|
||||
} else {
|
||||
SET_OPUSSLAVE_FUNCTIONS(codecDef);
|
||||
SET_OPUSSLAVE_FUNCTIONS(codec_def);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ACMGenericCodec* ACMOpus::CreateInstance(void) {
|
||||
return NULL;
|
||||
}
|
||||
@ -248,9 +248,9 @@ int16_t ACMOpus::InternalCreateEncoder() {
|
||||
}
|
||||
|
||||
void ACMOpus::DestructEncoderSafe() {
|
||||
if (_encoderInstPtr) {
|
||||
WebRtcOpus_EncoderFree(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_) {
|
||||
WebRtcOpus_EncoderFree(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,32 +260,32 @@ int16_t ACMOpus::InternalCreateDecoder() {
|
||||
}
|
||||
|
||||
void ACMOpus::DestructDecoderSafe() {
|
||||
_decoderInitialized = false;
|
||||
if (_decoderInstPtr) {
|
||||
WebRtcOpus_DecoderFree(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
decoder_initialized_ = false;
|
||||
if (decoder_inst_ptr_) {
|
||||
WebRtcOpus_DecoderFree(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ACMOpus::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcOpus_EncoderFree((OpusEncInst*) ptrInst);
|
||||
void ACMOpus::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
WebRtcOpus_EncoderFree((OpusEncInst*) ptr_inst);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t ACMOpus::SetBitRateSafe(const int32_t rate) {
|
||||
if (rate < 6000 || rate > 510000) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"SetBitRateSafe: Invalid rate Opus");
|
||||
return -1;
|
||||
}
|
||||
|
||||
_bitrate = rate;
|
||||
bitrate_ = rate;
|
||||
|
||||
// Ask the encoder for the new rate.
|
||||
if (WebRtcOpus_SetBitRate(_encoderInstPtr, _bitrate) >= 0) {
|
||||
_encoderParams.codecInstant.rate = _bitrate;
|
||||
if (WebRtcOpus_SetBitRate(encoder_inst_ptr_, bitrate_) >= 0) {
|
||||
encoder_params_.codec_inst.rate = bitrate_;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "resampler.h"
|
||||
#include "webrtc/common_audio/resampler/include/resampler.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
struct WebRtcOpusEncInst;
|
||||
struct WebRtcOpusDecInst;
|
||||
@ -21,22 +21,26 @@ namespace webrtc {
|
||||
|
||||
class ACMOpus : public ACMGenericCodec {
|
||||
public:
|
||||
ACMOpus(int16_t codecID);
|
||||
explicit ACMOpus(int16_t codec_id);
|
||||
~ACMOpus();
|
||||
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
int16_t InternalEncode(uint8_t* bitstream, int16_t* bitStreamLenByte);
|
||||
int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte);
|
||||
|
||||
int16_t InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
int16_t InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
int16_t InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
int16_t InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
int16_t DecodeSafe(uint8_t* bitStream, int16_t bitStreamLenByte,
|
||||
int16_t* audio, int16_t* audioSamples, int8_t* speechType);
|
||||
int16_t DecodeSafe(uint8_t* bitstream,
|
||||
int16_t bitstream_len_byte,
|
||||
int16_t* audio,
|
||||
int16_t* audio_samples,
|
||||
int8_t* speech_type);
|
||||
|
||||
int32_t CodecDef(WebRtcNetEQ_CodecDef& codecDef, const CodecInst& codecInst);
|
||||
int32_t CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -46,7 +50,7 @@ class ACMOpus : public ACMGenericCodec {
|
||||
|
||||
int16_t InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
int16_t SetBitRateSafe(const int32_t rate);
|
||||
|
||||
@ -54,11 +58,11 @@ class ACMOpus : public ACMGenericCodec {
|
||||
|
||||
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
||||
|
||||
WebRtcOpusEncInst* _encoderInstPtr;
|
||||
WebRtcOpusDecInst* _decoderInstPtr;
|
||||
uint16_t _sampleFreq;
|
||||
uint16_t _bitrate;
|
||||
int _channels;
|
||||
WebRtcOpusEncInst* encoder_inst_ptr_;
|
||||
WebRtcOpusDecInst* decoder_inst_ptr_;
|
||||
uint16_t sample_freq_;
|
||||
uint16_t bitrate_;
|
||||
int channels_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,24 +8,24 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_pcm16b.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_pcm16b.h"
|
||||
|
||||
#include "acm_codec_database.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_PCM16
|
||||
#include "pcm16b.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h"
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_PCM16
|
||||
|
||||
ACMPCM16B::ACMPCM16B(WebRtc_Word16 /* codecID */) {
|
||||
ACMPCM16B::ACMPCM16B(WebRtc_Word16 /* codec_id */) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -33,31 +33,32 @@ ACMPCM16B::~ACMPCM16B() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_Word16 ACMPCM16B::InternalEncode(
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMPCM16B::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -73,7 +74,7 @@ WebRtc_Word16 ACMPCM16B::InternalCreateDecoder() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ACMPCM16B::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMPCM16B::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -90,67 +91,67 @@ void ACMPCM16B::SplitStereoPacket(uint8_t* /*payload*/,
|
||||
}
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
ACMPCM16B::ACMPCM16B(WebRtc_Word16 codecID) {
|
||||
_codecID = codecID;
|
||||
_samplingFreqHz = ACMCodecDB::CodecFreq(_codecID);
|
||||
ACMPCM16B::ACMPCM16B(WebRtc_Word16 codec_id) {
|
||||
codec_id_ = codec_id;
|
||||
sampling_freq_hz_ = ACMCodecDB::CodecFreq(codec_id_);
|
||||
}
|
||||
|
||||
ACMPCM16B::~ACMPCM16B() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
*bitStreamLenByte = WebRtcPcm16b_Encode(&_inAudio[_inAudioIxRead],
|
||||
_frameLenSmpl * _noChannels,
|
||||
bitStream);
|
||||
WebRtc_Word16 ACMPCM16B::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
*bitstream_len_byte = WebRtcPcm16b_Encode(&in_audio_[in_audio_ix_read_],
|
||||
frame_len_smpl_ * num_channels_,
|
||||
bitstream);
|
||||
// Increment the read index to tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer.
|
||||
_inAudioIxRead += _frameLenSmpl * _noChannels;
|
||||
return *bitStreamLenByte;
|
||||
in_audio_ix_read_ += frame_len_smpl_ * num_channels_;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMPCM16B::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
// This codec does not need initialization, PCM has no instance.
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
// This codec does not need initialization, PCM has no instance.
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
// Fill up the structure by calling "SET_CODEC_PAR" & "SET_PCMU_FUNCTION".
|
||||
// Then call NetEQ to add the codec to it's database.
|
||||
if (codecInst.channels == 1) {
|
||||
switch(_samplingFreqHz) {
|
||||
if (codec_inst.channels == 1) {
|
||||
switch (sampling_freq_hz_) {
|
||||
case 8000: {
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCM16B, codecInst.pltype, NULL, 8000);
|
||||
SET_PCM16B_FUNCTIONS(codecDef);
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCM16B, codec_inst.pltype, NULL, 8000);
|
||||
SET_PCM16B_FUNCTIONS(codec_def);
|
||||
break;
|
||||
}
|
||||
case 16000: {
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCM16Bwb, codecInst.pltype, NULL,
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCM16Bwb, codec_inst.pltype, NULL,
|
||||
16000);
|
||||
SET_PCM16B_WB_FUNCTIONS(codecDef);
|
||||
SET_PCM16B_WB_FUNCTIONS(codec_def);
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCM16Bswb32kHz, codecInst.pltype,
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCM16Bswb32kHz, codec_inst.pltype,
|
||||
NULL, 32000);
|
||||
SET_PCM16B_SWB32_FUNCTIONS(codecDef);
|
||||
SET_PCM16B_SWB32_FUNCTIONS(codec_def);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -158,23 +159,23 @@ WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch(_samplingFreqHz) {
|
||||
switch (sampling_freq_hz_) {
|
||||
case 8000: {
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCM16B_2ch, codecInst.pltype, NULL,
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCM16B_2ch, codec_inst.pltype, NULL,
|
||||
8000);
|
||||
SET_PCM16B_FUNCTIONS(codecDef);
|
||||
SET_PCM16B_FUNCTIONS(codec_def);
|
||||
break;
|
||||
}
|
||||
case 16000: {
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCM16Bwb_2ch, codecInst.pltype,
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCM16Bwb_2ch, codec_inst.pltype,
|
||||
NULL, 16000);
|
||||
SET_PCM16B_WB_FUNCTIONS(codecDef);
|
||||
SET_PCM16B_WB_FUNCTIONS(codec_def);
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCM16Bswb32kHz_2ch, codecInst.pltype,
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCM16Bswb32kHz_2ch, codec_inst.pltype,
|
||||
NULL, 32000);
|
||||
SET_PCM16B_SWB32_FUNCTIONS(codecDef);
|
||||
SET_PCM16B_SWB32_FUNCTIONS(codec_def);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -199,22 +200,22 @@ WebRtc_Word16 ACMPCM16B::InternalCreateDecoder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMPCM16B::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMPCM16B::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
// PCM has no instance.
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMPCM16B::DestructEncoderSafe() {
|
||||
// PCM has no instance.
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMPCM16B::DestructDecoderSafe() {
|
||||
// PCM has no instance.
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -11,33 +11,34 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class ACMPCM16B : public ACMGenericCodec {
|
||||
public:
|
||||
ACMPCM16B(WebRtc_Word16 codecID);
|
||||
explicit ACMPCM16B(WebRtc_Word16 codec_id);
|
||||
~ACMPCM16B();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -47,11 +48,11 @@ class ACMPCM16B : public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
||||
|
||||
WebRtc_Word32 _samplingFreqHz;
|
||||
WebRtc_Word32 sampling_freq_hz_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,71 +8,71 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_pcma.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_pcma.h"
|
||||
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
// Codec interface
|
||||
#include "g711_interface.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
ACMPCMA::ACMPCMA(WebRtc_Word16 codecID) {
|
||||
_codecID = codecID;
|
||||
ACMPCMA::ACMPCMA(WebRtc_Word16 codec_id) {
|
||||
codec_id_ = codec_id;
|
||||
}
|
||||
|
||||
ACMPCMA::~ACMPCMA() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCMA::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
*bitStreamLenByte = WebRtcG711_EncodeA(NULL, &_inAudio[_inAudioIxRead],
|
||||
_frameLenSmpl * _noChannels,
|
||||
(WebRtc_Word16*) bitStream);
|
||||
WebRtc_Word16 ACMPCMA::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
*bitstream_len_byte = WebRtcG711_EncodeA(NULL, &in_audio_[in_audio_ix_read_],
|
||||
frame_len_smpl_ * num_channels_,
|
||||
(WebRtc_Word16*) bitstream);
|
||||
// Increment the read index this tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer.
|
||||
_inAudioIxRead += _frameLenSmpl * _noChannels;
|
||||
return *bitStreamLenByte;
|
||||
in_audio_ix_read_ += frame_len_smpl_ * num_channels_;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCMA::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMPCMA::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCMA::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
// This codec does not need initialization, PCM has no instance.
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCMA::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
// This codec does not need initialization, PCM has no instance.
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMPCMA::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
WebRtc_Word32 ACMPCMA::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
// Fill up the structure by calling
|
||||
// "SET_CODEC_PAR" & "SET_PCMA_FUNCTION."
|
||||
// Then call NetEQ to add the codec to it's database.
|
||||
if (codecInst.channels == 1) {
|
||||
if (codec_inst.channels == 1) {
|
||||
// Mono mode.
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCMa, codecInst.pltype, NULL, 8000);
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCMa, codec_inst.pltype, NULL, 8000);
|
||||
} else {
|
||||
// Stereo mode.
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCMa_2ch, codecInst.pltype, NULL, 8000);
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCMa_2ch, codec_inst.pltype, NULL, 8000);
|
||||
}
|
||||
SET_PCMA_FUNCTIONS(codecDef);
|
||||
SET_PCMA_FUNCTIONS(codec_def);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ WebRtc_Word16 ACMPCMA::InternalCreateDecoder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMPCMA::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMPCMA::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
// PCM has no instance.
|
||||
return;
|
||||
}
|
||||
@ -102,8 +102,8 @@ void ACMPCMA::DestructEncoderSafe() {
|
||||
|
||||
void ACMPCMA::DestructDecoderSafe() {
|
||||
// PCM has no instance.
|
||||
_decoderInitialized = false;
|
||||
_decoderExist = false;
|
||||
decoder_initialized_ = false;
|
||||
decoder_exist_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -11,33 +11,34 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class ACMPCMA : public ACMGenericCodec {
|
||||
public:
|
||||
ACMPCMA(WebRtc_Word16 codecID);
|
||||
explicit ACMPCMA(WebRtc_Word16 codec_id);
|
||||
~ACMPCMA();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -47,7 +48,7 @@ class ACMPCMA : public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
||||
};
|
||||
|
@ -8,71 +8,71 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_pcmu.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_pcmu.h"
|
||||
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
// Codec interface
|
||||
#include "g711_interface.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
ACMPCMU::ACMPCMU(WebRtc_Word16 codecID) {
|
||||
_codecID = codecID;
|
||||
ACMPCMU::ACMPCMU(WebRtc_Word16 codec_id) {
|
||||
codec_id_ = codec_id;
|
||||
}
|
||||
|
||||
ACMPCMU::~ACMPCMU() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCMU::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
*bitStreamLenByte = WebRtcG711_EncodeU(NULL, &_inAudio[_inAudioIxRead],
|
||||
_frameLenSmpl * _noChannels,
|
||||
(WebRtc_Word16*) bitStream);
|
||||
WebRtc_Word16 ACMPCMU::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
*bitstream_len_byte = WebRtcG711_EncodeU(NULL, &in_audio_[in_audio_ix_read_],
|
||||
frame_len_smpl_ * num_channels_,
|
||||
(WebRtc_Word16*)bitstream);
|
||||
// Increment the read index this tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer.
|
||||
_inAudioIxRead += _frameLenSmpl * _noChannels;
|
||||
return *bitStreamLenByte;
|
||||
in_audio_ix_read_ += frame_len_smpl_ * num_channels_;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCMU::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMPCMU::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCMU::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
// This codec does not need initialization, PCM has no instance.
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCMU::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
// This codec does not need initialization, PCM has no instance.
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMPCMU::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
WebRtc_Word32 ACMPCMU::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
// Fill up the structure by calling
|
||||
// "SET_CODEC_PAR" & "SET_PCMU_FUNCTION."
|
||||
// Then call NetEQ to add the codec to it's database.
|
||||
if (codecInst.channels == 1) {
|
||||
if (codec_inst.channels == 1) {
|
||||
// Mono mode.
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCMu, codecInst.pltype, NULL, 8000);
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCMu, codec_inst.pltype, NULL, 8000);
|
||||
} else {
|
||||
// Stereo mode.
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCMu_2ch, codecInst.pltype, NULL, 8000);
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCMu_2ch, codec_inst.pltype, NULL, 8000);
|
||||
}
|
||||
SET_PCMU_FUNCTIONS(codecDef);
|
||||
SET_PCMU_FUNCTIONS(codec_def);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -90,22 +90,22 @@ WebRtc_Word16 ACMPCMU::InternalCreateDecoder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMPCMU::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMPCMU::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
// PCM has no instance.
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMPCMU::DestructEncoderSafe() {
|
||||
// PCM has no instance.
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMPCMU::DestructDecoderSafe() {
|
||||
// PCM has no instance.
|
||||
_decoderInitialized = false;
|
||||
_decoderExist = false;
|
||||
decoder_initialized_ = false;
|
||||
decoder_exist_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -11,33 +11,34 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class ACMPCMU : public ACMGenericCodec {
|
||||
public:
|
||||
ACMPCMU(WebRtc_Word16 codecID);
|
||||
explicit ACMPCMU(WebRtc_Word16 codec_id);
|
||||
~ACMPCMU();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -47,7 +48,7 @@ class ACMPCMU : public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
||||
};
|
||||
|
@ -8,55 +8,56 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_red.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_red.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
ACMRED::ACMRED(WebRtc_Word16 codecID) {
|
||||
_codecID = codecID;
|
||||
ACMRED::ACMRED(WebRtc_Word16 codec_id) {
|
||||
codec_id_ = codec_id;
|
||||
}
|
||||
|
||||
ACMRED::~ACMRED() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMRED::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_Word16 ACMRED::InternalEncode(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
// RED is never used as an encoder
|
||||
// RED has no instance
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMRED::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMRED::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMRED::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
// This codec does not need initialization,
|
||||
// RED has no instance
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMRED::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
// This codec does not need initialization,
|
||||
// RED has no instance
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMRED::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WebRtc_Word32 ACMRED::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
// Todo:
|
||||
// log error
|
||||
return -1;
|
||||
@ -66,8 +67,8 @@ WebRtc_Word32 ACMRED::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// "SET_CODEC_PAR" & "SET_PCMU_FUNCTION."
|
||||
// Then call NetEQ to add the codec to it's
|
||||
// database.
|
||||
SET_CODEC_PAR((codecDef), kDecoderRED, codecInst.pltype, NULL, 8000);
|
||||
SET_RED_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderRED, codec_inst.pltype, NULL, 8000);
|
||||
SET_RED_FUNCTIONS((codec_def));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -85,7 +86,7 @@ WebRtc_Word16 ACMRED::InternalCreateDecoder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMRED::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMRED::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
// RED has no instance
|
||||
return;
|
||||
}
|
||||
|
@ -11,33 +11,34 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class ACMRED : public ACMGenericCodec {
|
||||
public:
|
||||
ACMRED(WebRtc_Word16 codecID);
|
||||
explicit ACMRED(WebRtc_Word16 codec_id);
|
||||
~ACMRED();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -47,7 +48,7 @@ class ACMRED : public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,65 +8,66 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_resampler.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "acm_resampler.h"
|
||||
|
||||
#include "critical_section_wrapper.h"
|
||||
#include "resampler.h"
|
||||
#include "signal_processing_library.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc/common_audio/resampler/include/resampler.h"
|
||||
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
ACMResampler::ACMResampler()
|
||||
: _resamplerCritSect(CriticalSectionWrapper::CreateCriticalSection()) {
|
||||
: resampler_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()) {
|
||||
}
|
||||
|
||||
ACMResampler::~ACMResampler() {
|
||||
delete _resamplerCritSect;
|
||||
delete resampler_crit_sect_;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMResampler::Resample10Msec(const WebRtc_Word16* inAudio,
|
||||
WebRtc_Word32 inFreqHz,
|
||||
WebRtc_Word16* outAudio,
|
||||
WebRtc_Word32 outFreqHz,
|
||||
WebRtc_UWord8 numAudioChannels) {
|
||||
CriticalSectionScoped cs(_resamplerCritSect);
|
||||
WebRtc_Word16 ACMResampler::Resample10Msec(const WebRtc_Word16* in_audio,
|
||||
WebRtc_Word32 in_freq_hz,
|
||||
WebRtc_Word16* out_audio,
|
||||
WebRtc_Word32 out_freq_hz,
|
||||
WebRtc_UWord8 num_audio_channels) {
|
||||
CriticalSectionScoped cs(resampler_crit_sect_);
|
||||
|
||||
if (inFreqHz == outFreqHz) {
|
||||
size_t length = static_cast<size_t>(inFreqHz * numAudioChannels / 100);
|
||||
memcpy(outAudio, inAudio, length * sizeof(WebRtc_Word16));
|
||||
return static_cast<WebRtc_Word16>(inFreqHz / 100);
|
||||
if (in_freq_hz == out_freq_hz) {
|
||||
size_t length = static_cast<size_t>(in_freq_hz * num_audio_channels / 100);
|
||||
memcpy(out_audio, in_audio, length * sizeof(WebRtc_Word16));
|
||||
return static_cast<WebRtc_Word16>(in_freq_hz / 100);
|
||||
}
|
||||
|
||||
// |maxLen| is maximum number of samples for 10ms at 48kHz.
|
||||
int maxLen = 480 * numAudioChannels;
|
||||
int lengthIn = (WebRtc_Word16)(inFreqHz / 100) * numAudioChannels;
|
||||
int outLen;
|
||||
int max_len = 480 * num_audio_channels;
|
||||
int length_in = (WebRtc_Word16)(in_freq_hz / 100) * num_audio_channels;
|
||||
int out_len;
|
||||
|
||||
WebRtc_Word32 ret;
|
||||
ResamplerType type;
|
||||
type = (numAudioChannels == 1) ? kResamplerSynchronous :
|
||||
type = (num_audio_channels == 1) ? kResamplerSynchronous :
|
||||
kResamplerSynchronousStereo;
|
||||
|
||||
ret = _resampler.ResetIfNeeded(inFreqHz, outFreqHz, type);
|
||||
ret = resampler_.ResetIfNeeded(in_freq_hz, out_freq_hz, type);
|
||||
if (ret < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0,
|
||||
"Error in reset of resampler");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = _resampler.Push(inAudio, lengthIn, outAudio, maxLen, outLen);
|
||||
ret = resampler_.Push(in_audio, length_in, out_audio, max_len, out_len);
|
||||
if (ret < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0,
|
||||
"Error in resampler: resampler.Push");
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 outAudioLenSmpl = (WebRtc_Word16) outLen / numAudioChannels;
|
||||
WebRtc_Word16 out_audio_len_smpl = (WebRtc_Word16) out_len /
|
||||
num_audio_channels;
|
||||
|
||||
return outAudioLenSmpl;
|
||||
return out_audio_len_smpl;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -11,8 +11,8 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_
|
||||
|
||||
#include "resampler.h"
|
||||
#include "typedefs.h"
|
||||
#include "webrtc/common_audio/resampler/include/resampler.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -23,16 +23,16 @@ class ACMResampler {
|
||||
ACMResampler();
|
||||
~ACMResampler();
|
||||
|
||||
WebRtc_Word16 Resample10Msec(const WebRtc_Word16* inAudio,
|
||||
const WebRtc_Word32 inFreqHz,
|
||||
WebRtc_Word16* outAudio,
|
||||
const WebRtc_Word32 outFreqHz,
|
||||
WebRtc_UWord8 numAudioChannels);
|
||||
WebRtc_Word16 Resample10Msec(const WebRtc_Word16* in_audio,
|
||||
const WebRtc_Word32 in_freq_hz,
|
||||
WebRtc_Word16* out_audio,
|
||||
const WebRtc_Word32 out_freq_hz,
|
||||
WebRtc_UWord8 num_audio_channels);
|
||||
|
||||
private:
|
||||
// Use the Resampler class.
|
||||
Resampler _resampler;
|
||||
CriticalSectionWrapper* _resamplerCritSect;
|
||||
Resampler resampler_;
|
||||
CriticalSectionWrapper* resampler_crit_sect_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,13 +8,14 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_speex.h"
|
||||
#include "acm_codec_database.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_speex.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_SPEEX
|
||||
// NOTE! Speex is not included in the open-source package. Modify this file or
|
||||
@ -25,14 +26,14 @@
|
||||
namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_SPEEX
|
||||
ACMSPEEX::ACMSPEEX(WebRtc_Word16 /* codecID */)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL),
|
||||
_complMode(0),
|
||||
_vbrEnabled(false),
|
||||
_encodingRate(-1),
|
||||
_samplingFrequency(-1),
|
||||
_samplesIn20MsAudio(-1) {
|
||||
ACMSPEEX::ACMSPEEX(WebRtc_Word16 /* codec_id */)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
compl_mode_(0),
|
||||
vbr_enabled_(false),
|
||||
encoding_rate_(-1),
|
||||
sampling_frequency_(-1),
|
||||
samples_in_20ms_audio_(-1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -40,16 +41,17 @@ ACMSPEEX::~ACMSPEEX() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMSPEEX::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_Word16 ACMSPEEX::InternalEncode(
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -62,17 +64,17 @@ WebRtc_Word16 ACMSPEEX::DisableDTX() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMSPEEX::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMSPEEX::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -100,7 +102,7 @@ WebRtc_Word16 ACMSPEEX::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ACMSPEEX::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMSPEEX::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -120,111 +122,110 @@ WebRtc_Word16 ACMSPEEX::SetComplMode(WebRtc_Word16 mode) {
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
|
||||
ACMSPEEX::ACMSPEEX(WebRtc_Word16 codecID)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL) {
|
||||
_codecID = codecID;
|
||||
ACMSPEEX::ACMSPEEX(WebRtc_Word16 codec_id)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
decoder_inst_ptr_(NULL) {
|
||||
codec_id_ = codec_id;
|
||||
|
||||
// Set sampling frequency, frame size and rate Speex
|
||||
if (_codecID == ACMCodecDB::kSPEEX8) {
|
||||
_samplingFrequency = 8000;
|
||||
_samplesIn20MsAudio = 160;
|
||||
_encodingRate = 11000;
|
||||
} else if (_codecID == ACMCodecDB::kSPEEX16) {
|
||||
_samplingFrequency = 16000;
|
||||
_samplesIn20MsAudio = 320;
|
||||
_encodingRate = 22000;
|
||||
if (codec_id_ == ACMCodecDB::kSPEEX8) {
|
||||
sampling_frequency_ = 8000;
|
||||
samples_in_20ms_audio_ = 160;
|
||||
encoding_rate_ = 11000;
|
||||
} else if (codec_id_ == ACMCodecDB::kSPEEX16) {
|
||||
sampling_frequency_ = 16000;
|
||||
samples_in_20ms_audio_ = 320;
|
||||
encoding_rate_ = 22000;
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Wrong codec id for Speex.");
|
||||
|
||||
_samplingFrequency = -1;
|
||||
_samplesIn20MsAudio = -1;
|
||||
_encodingRate = -1;
|
||||
sampling_frequency_ = -1;
|
||||
samples_in_20ms_audio_ = -1;
|
||||
encoding_rate_ = -1;
|
||||
}
|
||||
|
||||
_hasInternalDTX = true;
|
||||
_dtxEnabled = false;
|
||||
_vbrEnabled = false;
|
||||
_complMode = 3; // default complexity value
|
||||
has_internal_dtx_ = true;
|
||||
dtx_enabled_ = false;
|
||||
vbr_enabled_ = false;
|
||||
compl_mode_ = 3; // default complexity value
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ACMSPEEX::~ACMSPEEX() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcSpeex_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcSpeex_FreeEnc(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcSpeex_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcSpeex_FreeDec(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMSPEEX::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
WebRtc_Word16 ACMSPEEX::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
WebRtc_Word16 status;
|
||||
WebRtc_Word16 numEncodedSamples = 0;
|
||||
WebRtc_Word16 num_encoded_samples = 0;
|
||||
WebRtc_Word16 n = 0;
|
||||
|
||||
while (numEncodedSamples < _frameLenSmpl) {
|
||||
status = WebRtcSpeex_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead],
|
||||
_encodingRate);
|
||||
while (num_encoded_samples < frame_len_smpl_) {
|
||||
status = WebRtcSpeex_Encode(encoder_inst_ptr_,
|
||||
&in_audio_[in_audio_ix_read_], encoding_rate_);
|
||||
|
||||
// increment the read index this tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer
|
||||
_inAudioIxRead += _samplesIn20MsAudio;
|
||||
numEncodedSamples += _samplesIn20MsAudio;
|
||||
in_audio_ix_read_ += samples_in_20ms_audio_;
|
||||
num_encoded_samples += samples_in_20ms_audio_;
|
||||
|
||||
if (status < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Error in Speex encoder");
|
||||
return status;
|
||||
}
|
||||
|
||||
// Update VAD, if internal DTX is used
|
||||
if (_hasInternalDTX && _dtxEnabled) {
|
||||
_vadLabel[n++] = status;
|
||||
_vadLabel[n++] = status;
|
||||
if (has_internal_dtx_ && dtx_enabled_) {
|
||||
vad_label_[n++] = status;
|
||||
vad_label_[n++] = status;
|
||||
}
|
||||
|
||||
if (status == 0) {
|
||||
// This frame is detected as inactive. We need send whatever
|
||||
// encoded so far.
|
||||
*bitStreamLenByte = WebRtcSpeex_GetBitstream(_encoderInstPtr,
|
||||
(WebRtc_Word16*) bitStream);
|
||||
|
||||
return *bitStreamLenByte;
|
||||
*bitstream_len_byte = WebRtcSpeex_GetBitstream(encoder_inst_ptr_,
|
||||
(WebRtc_Word16*)bitstream);
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
}
|
||||
|
||||
*bitStreamLenByte = WebRtcSpeex_GetBitstream(_encoderInstPtr,
|
||||
(WebRtc_Word16*) bitStream);
|
||||
return *bitStreamLenByte;
|
||||
*bitstream_len_byte = WebRtcSpeex_GetBitstream(encoder_inst_ptr_,
|
||||
(WebRtc_Word16*)bitstream);
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMSPEEX::EnableDTX() {
|
||||
if (_dtxEnabled) {
|
||||
if (dtx_enabled_) {
|
||||
return 0;
|
||||
} else if (_encoderExist) { // check if encoder exist
|
||||
} else if (encoder_exist_) { // check if encoder exist
|
||||
// enable DTX
|
||||
if (WebRtcSpeex_EncoderInit(_encoderInstPtr, (_vbrEnabled ? 1 : 0),
|
||||
_complMode, 1) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, (vbr_enabled_ ? 1 : 0),
|
||||
compl_mode_, 1) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Cannot enable DTX for Speex");
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = true;
|
||||
dtx_enabled_ = true;
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
@ -234,17 +235,17 @@ WebRtc_Word16 ACMSPEEX::EnableDTX() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMSPEEX::DisableDTX() {
|
||||
if (!_dtxEnabled) {
|
||||
if (!dtx_enabled_) {
|
||||
return 0;
|
||||
} else if (_encoderExist) { // check if encoder exist
|
||||
} else if (encoder_exist_) { // check if encoder exist
|
||||
// disable DTX
|
||||
if (WebRtcSpeex_EncoderInit(_encoderInstPtr, (_vbrEnabled ? 1 : 0),
|
||||
_complMode, 0) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, (vbr_enabled_ ? 1 : 0),
|
||||
compl_mode_, 0) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Cannot disable DTX for Speex");
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = false;
|
||||
dtx_enabled_ = false;
|
||||
return 0;
|
||||
} else {
|
||||
// encoder doesn't exists, therefore disabling is harmless
|
||||
@ -254,54 +255,55 @@ WebRtc_Word16 ACMSPEEX::DisableDTX() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMSPEEX::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
WebRtc_Word16 ACMSPEEX::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* codec_params) {
|
||||
// sanity check
|
||||
if (_encoderInstPtr == NULL) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (encoder_inst_ptr_ == NULL) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Cannot initialize Speex encoder, instance does not exist");
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate);
|
||||
WebRtc_Word16 status = SetBitRateSafe((codec_params->codecInstant).rate);
|
||||
status +=
|
||||
(WebRtcSpeex_EncoderInit(_encoderInstPtr, _vbrEnabled, _complMode,
|
||||
((codecParams->enableDTX) ? 1 : 0)) < 0) ?
|
||||
(WebRtcSpeex_EncoderInit(encoder_inst_ptr_, vbr_enabled_, compl_mode_,
|
||||
((codec_params->enable_dtx) ? 1 : 0)) < 0) ?
|
||||
-1 : 0;
|
||||
|
||||
if (status >= 0) {
|
||||
return 0;
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Error in initialization of Speex encoder");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMSPEEX::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
WebRtc_Word16 status;
|
||||
|
||||
// sanity check
|
||||
if (_decoderInstPtr == NULL) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (decoder_inst_ptr_ == NULL) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Cannot initialize Speex decoder, instance does not exist");
|
||||
return -1;
|
||||
}
|
||||
status = ((WebRtcSpeex_DecoderInit(_decoderInstPtr) < 0) ? -1 : 0);
|
||||
status = ((WebRtcSpeex_DecoderInit(decoder_inst_ptr_) < 0) ? -1 : 0);
|
||||
|
||||
if (status >= 0) {
|
||||
return 0;
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Error in initialization of Speex decoder");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Error, Speex decoder is not initialized");
|
||||
return -1;
|
||||
}
|
||||
@ -311,26 +313,26 @@ WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// Then call NetEQ to add the codec to its
|
||||
// database.
|
||||
|
||||
switch (_samplingFrequency) {
|
||||
switch (sampling_frequency_) {
|
||||
case 8000: {
|
||||
SET_CODEC_PAR((codecDef), kDecoderSPEEX_8, codecInst.pltype,
|
||||
_decoderInstPtr, 8000);
|
||||
SET_CODEC_PAR((codec_def), kDecoderSPEEX_8, codec_inst.pltype,
|
||||
decoder_inst_ptr_, 8000);
|
||||
break;
|
||||
}
|
||||
case 16000: {
|
||||
SET_CODEC_PAR((codecDef), kDecoderSPEEX_16, codecInst.pltype,
|
||||
_decoderInstPtr, 16000);
|
||||
SET_CODEC_PAR((codec_def), kDecoderSPEEX_16, codec_inst.pltype,
|
||||
decoder_inst_ptr_, 16000);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Unsupported sampling frequency for Speex");
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
SET_SPEEX_FUNCTIONS((codecDef));
|
||||
SET_SPEEX_FUNCTIONS((codec_def));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -339,43 +341,43 @@ ACMGenericCodec* ACMSPEEX::CreateInstance(void) {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMSPEEX::InternalCreateEncoder() {
|
||||
return WebRtcSpeex_CreateEnc(&_encoderInstPtr, _samplingFrequency);
|
||||
return WebRtcSpeex_CreateEnc(&encoder_inst_ptr_, sampling_frequency_);
|
||||
}
|
||||
|
||||
void ACMSPEEX::DestructEncoderSafe() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcSpeex_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
WebRtcSpeex_FreeEnc(encoder_inst_ptr_);
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
// there is no encoder set the following
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
_encodingRate = 0;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
encoding_rate_ = 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMSPEEX::InternalCreateDecoder() {
|
||||
return WebRtcSpeex_CreateDec(&_decoderInstPtr, _samplingFrequency, 1);
|
||||
return WebRtcSpeex_CreateDec(&decoder_inst_ptr_, sampling_frequency_, 1);
|
||||
}
|
||||
|
||||
void ACMSPEEX::DestructDecoderSafe() {
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcSpeex_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
WebRtcSpeex_FreeDec(decoder_inst_ptr_);
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
// there is no encoder instance set the followings
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMSPEEX::SetBitRateSafe(const WebRtc_Word32 rate) {
|
||||
// Check if changed rate
|
||||
if (rate == _encodingRate) {
|
||||
if (rate == encoding_rate_) {
|
||||
return 0;
|
||||
} else if (rate > 2000) {
|
||||
_encodingRate = rate;
|
||||
_encoderParams.codecInstant.rate = rate;
|
||||
encoding_rate_ = rate;
|
||||
encoder_params_.codecInstant.rate = rate;
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Unsupported encoding rate for Speex");
|
||||
|
||||
return -1;
|
||||
@ -384,31 +386,30 @@ WebRtc_Word16 ACMSPEEX::SetBitRateSafe(const WebRtc_Word32 rate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMSPEEX::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcSpeex_FreeEnc((SPEEX_encinst_t_*) ptrInst);
|
||||
void ACMSPEEX::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
WebRtcSpeex_FreeEnc((SPEEX_encinst_t_*) ptr_inst);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef UNUSEDSPEEX
|
||||
|
||||
// This API is currently not in use. If requested to be able to enable/disable VBR
|
||||
// an ACM API need to be added.
|
||||
// This API is currently not in use. If requested to be able to enable/disable
|
||||
// VBR an ACM API need to be added.
|
||||
WebRtc_Word16 ACMSPEEX::EnableVBR() {
|
||||
if (_vbrEnabled) {
|
||||
if (vbr_enabled_) {
|
||||
return 0;
|
||||
} else if (_encoderExist) // check if encoder exist
|
||||
{
|
||||
} else if (encoder_exist_) { // check if encoder exist
|
||||
// enable Variable Bit Rate (VBR)
|
||||
if (WebRtcSpeex_EncoderInit(_encoderInstPtr, 1, _complMode,
|
||||
(_dtxEnabled ? 1 : 0)) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, 1, compl_mode_,
|
||||
(dtx_enabled_ ? 1 : 0)) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Cannot enable VBR mode for Speex");
|
||||
|
||||
return -1;
|
||||
}
|
||||
_vbrEnabled = true;
|
||||
vbr_enabled_ = true;
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
@ -418,18 +419,18 @@ WebRtc_Word16 ACMSPEEX::EnableVBR() {
|
||||
// This API is currently not in use. If requested to be able to enable/disable
|
||||
// VBR an ACM API need to be added.
|
||||
WebRtc_Word16 ACMSPEEX::DisableVBR() {
|
||||
if (!_vbrEnabled) {
|
||||
if (!vbr_enabled_) {
|
||||
return 0;
|
||||
} else if (_encoderExist) { // check if encoder exist
|
||||
} else if (encoder_exist_) { // check if encoder exist
|
||||
// disable DTX
|
||||
if (WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, _complMode,
|
||||
(_dtxEnabled ? 1 : 0)) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, 0, compl_mode_,
|
||||
(dtx_enabled_ ? 1 : 0)) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Cannot disable DTX for Speex");
|
||||
|
||||
return -1;
|
||||
}
|
||||
_vbrEnabled = false;
|
||||
vbr_enabled_ = false;
|
||||
return 0;
|
||||
} else {
|
||||
// encoder doesn't exists, therefore disabling is harmless
|
||||
@ -441,17 +442,17 @@ WebRtc_Word16 ACMSPEEX::DisableVBR() {
|
||||
// an ACM API need to be added.
|
||||
WebRtc_Word16 ACMSPEEX::SetComplMode(WebRtc_Word16 mode) {
|
||||
// Check if new mode
|
||||
if (mode == _complMode) {
|
||||
if (mode == compl_mode_) {
|
||||
return 0;
|
||||
} else if (_encoderExist) { // check if encoder exist
|
||||
} else if (encoder_exist_) { // check if encoder exist
|
||||
// Set new mode
|
||||
if (WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, mode, (_dtxEnabled ? 1 : 0))
|
||||
< 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, 0, mode,
|
||||
(dtx_enabled_ ? 1 : 0)) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Error in complexity mode for Speex");
|
||||
return -1;
|
||||
}
|
||||
_complMode = mode;
|
||||
compl_mode_ = mode;
|
||||
return 0;
|
||||
} else {
|
||||
// encoder doesn't exists, therefore disabling is harmless
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
|
||||
|
||||
// forward declaration
|
||||
struct SPEEX_encinst_t_;
|
||||
@ -21,27 +21,28 @@ namespace webrtc {
|
||||
|
||||
class ACMSPEEX : public ACMGenericCodec {
|
||||
public:
|
||||
ACMSPEEX(WebRtc_Word16 codecID);
|
||||
explicit ACMSPEEX(WebRtc_Word16 codec_id);
|
||||
~ACMSPEEX();
|
||||
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
WebRtc_Word16* bitstream_len_byte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codec_params);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 bitstream_len_byte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
WebRtc_Word16* audio_samples,
|
||||
WebRtc_Word8* speech_type);
|
||||
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -51,7 +52,7 @@ class ACMSPEEX : public ACMGenericCodec {
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptr_inst);
|
||||
|
||||
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
|
||||
|
||||
@ -67,13 +68,13 @@ class ACMSPEEX : public ACMGenericCodec {
|
||||
WebRtc_Word16 SetComplMode(WebRtc_Word16 mode);
|
||||
#endif
|
||||
|
||||
SPEEX_encinst_t_* _encoderInstPtr;
|
||||
SPEEX_decinst_t_* _decoderInstPtr;
|
||||
WebRtc_Word16 _complMode;
|
||||
bool _vbrEnabled;
|
||||
WebRtc_Word32 _encodingRate;
|
||||
WebRtc_Word16 _samplingFrequency;
|
||||
WebRtc_UWord16 _samplesIn20MsAudio;
|
||||
SPEEX_encinst_t_* encoder_inst_ptr_;
|
||||
SPEEX_decinst_t_* decoder_inst_ptr_;
|
||||
WebRtc_Word16 compl_mode_;
|
||||
bool vbr_enabled_;
|
||||
WebRtc_Word32 encoding_rate_;
|
||||
WebRtc_Word16 sampling_frequency_;
|
||||
WebRtc_UWord16 samples_in_20ms_audio_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,10 +8,13 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_dtmf_detection.h"
|
||||
#include "audio_coding_module.h"
|
||||
#include "audio_coding_module_impl.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_dtmf_detection.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/audio_coding_module_impl.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -31,10 +34,10 @@ WebRtc_UWord8 AudioCodingModule::NumberOfCodecs() {
|
||||
}
|
||||
|
||||
// Get supported codec param with id
|
||||
WebRtc_Word32 AudioCodingModule::Codec(const WebRtc_UWord8 listId,
|
||||
WebRtc_Word32 AudioCodingModule::Codec(const WebRtc_UWord8 list_id,
|
||||
CodecInst& codec) {
|
||||
// Get the codec settings for the codec with the given list ID
|
||||
return ACMCodecDB::Codec(listId, &codec);
|
||||
return ACMCodecDB::Codec(list_id, &codec);
|
||||
}
|
||||
|
||||
// Get supported codec Param with name, frequency and number of channels.
|
||||
@ -74,13 +77,13 @@ WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
|
||||
|
||||
// Checks the validity of the parameters of the given codec
|
||||
bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
|
||||
int mirrorID;
|
||||
char errMsg[500];
|
||||
int mirror_id;
|
||||
char err_msg[500];
|
||||
|
||||
int codecNumber = ACMCodecDB::CodecNumber(&codec, &mirrorID, errMsg, 500);
|
||||
int codec_number = ACMCodecDB::CodecNumber(&codec, &mirror_id, err_msg, 500);
|
||||
|
||||
if (codecNumber < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, errMsg);
|
||||
if (codec_number < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, err_msg);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,11 +11,11 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_
|
||||
|
||||
#include "acm_codec_database.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "acm_resampler.h"
|
||||
#include "common_types.h"
|
||||
#include "engine_configurations.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_resampler.h"
|
||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -25,14 +25,10 @@ class ACMGenericCodec;
|
||||
class CriticalSectionWrapper;
|
||||
class RWLockWrapper;
|
||||
|
||||
#ifdef ACM_QA_TEST
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
class AudioCodingModuleImpl : public AudioCodingModule {
|
||||
public:
|
||||
// Constructor
|
||||
AudioCodingModuleImpl(const WebRtc_Word32 id);
|
||||
explicit AudioCodingModuleImpl(const WebRtc_Word32 id);
|
||||
|
||||
// Destructor
|
||||
~AudioCodingModuleImpl();
|
||||
@ -77,9 +73,9 @@ class AudioCodingModuleImpl : public AudioCodingModule {
|
||||
// Get current send frequency.
|
||||
WebRtc_Word32 SendFrequency() const;
|
||||
|
||||
// Get encode bitrate.
|
||||
// Get encode bit-rate.
|
||||
// Adaptive rate codecs return their current encode target rate, while other
|
||||
// codecs return there longterm avarage or their fixed rate.
|
||||
// codecs return there long-term average or their fixed rate.
|
||||
WebRtc_Word32 SendBitrate() const;
|
||||
|
||||
// Set available bandwidth, inform the encoder about the
|
||||
@ -96,7 +92,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
|
||||
WebRtc_Word32 RegisterIncomingMessagesCallback(
|
||||
AudioCodingFeedback* incoming_message, const ACMCountries cpt);
|
||||
|
||||
// Add 10MS of raw (PCM) audio data to the encoder.
|
||||
// Add 10 ms of raw (PCM) audio data to the encoder.
|
||||
WebRtc_Word32 Add10MsData(const AudioFrame& audio_frame);
|
||||
|
||||
// Set background noise mode for NetEQ, on, off or fade.
|
||||
@ -128,7 +124,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
|
||||
WebRtc_Word32 VAD(bool& dtx_enabled, bool& vad_enabled,
|
||||
ACMVADMode& mode) const;
|
||||
|
||||
WebRtc_Word32 RegisterVADCallback(ACMVADCallback* vadCallback);
|
||||
WebRtc_Word32 RegisterVADCallback(ACMVADCallback* vad_callback);
|
||||
|
||||
// Get VAD aggressiveness on the incoming stream.
|
||||
ACMVADMode ReceiveVADMode() const;
|
||||
@ -152,7 +148,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
|
||||
// Get current playout frequency.
|
||||
WebRtc_Word32 PlayoutFrequency() const;
|
||||
|
||||
// Register possible reveive codecs, can be called multiple times,
|
||||
// Register possible receive codecs, can be called multiple times,
|
||||
// for codecs, CNG, DTMF, RED.
|
||||
WebRtc_Word32 RegisterReceiveCodec(const CodecInst& receive_codec);
|
||||
|
||||
@ -171,7 +167,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
|
||||
const WebRtc_UWord8 payload_type,
|
||||
const WebRtc_UWord32 timestamp = 0);
|
||||
|
||||
// Minimum playout dealy (used for lip-sync).
|
||||
// Minimum playout delay (used for lip-sync).
|
||||
WebRtc_Word32 SetMinimumPlayoutDelay(const WebRtc_Word32 time_ms);
|
||||
|
||||
// Configure Dtmf playout status i.e on/off playout the incoming outband Dtmf
|
||||
@ -258,7 +254,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
|
||||
WebRtc_Word32 RegisterRecCodecMSSafe(const CodecInst& receive_codec,
|
||||
WebRtc_Word16 codec_id,
|
||||
WebRtc_Word16 mirror_id,
|
||||
ACMNetEQ::JB jitter_buffer);
|
||||
ACMNetEQ::JitterBuffer jitter_buffer);
|
||||
|
||||
// Set VAD/DTX status. This function does not acquire a lock, and it is
|
||||
// created to be called only from inside a critical section.
|
||||
@ -273,19 +269,16 @@ class AudioCodingModuleImpl : public AudioCodingModule {
|
||||
int ProcessDualStream();
|
||||
|
||||
// Preprocessing of input audio, including resampling and down-mixing if
|
||||
// required, before pushing audio into encoder'r buffer.
|
||||
// required, before pushing audio into encoder's buffer.
|
||||
//
|
||||
// in_frame: input audio-frame
|
||||
// out_frame: output audio_frame, the output is valid only if a preprocessing
|
||||
// is required.
|
||||
// ptr_out: pointer to output audio_frame. If no preprocessing is required
|
||||
// |ptr_out| will be pointing to |in_frame|, otherwise pointing to
|
||||
// |preprocess_frame_|.
|
||||
//
|
||||
// Return value:
|
||||
// -1: if encountering an error.
|
||||
// kPreprocessingSuccessful: if a preprocessing successfully performed.
|
||||
// kNoPreprocessingRequired: if there was no need for preprocessing. In
|
||||
// this case |out_frame| is not updated and
|
||||
// |in_frame| has to be used for further
|
||||
// operations.
|
||||
// 0: otherwise.
|
||||
int PreprocessToAddData(const AudioFrame& in_frame,
|
||||
const AudioFrame** ptr_out);
|
||||
|
||||
@ -304,89 +297,84 @@ class AudioCodingModuleImpl : public AudioCodingModule {
|
||||
|
||||
int EncodeFragmentation(int fragmentation_index, int payload_type,
|
||||
uint32_t current_timestamp,
|
||||
ACMGenericCodec* _secondary_encoder,
|
||||
ACMGenericCodec* encoder,
|
||||
uint8_t* stream);
|
||||
|
||||
void ResetFragmentation(int vector_size);
|
||||
|
||||
AudioPacketizationCallback* _packetizationCallback;
|
||||
WebRtc_Word32 _id;
|
||||
WebRtc_UWord32 _lastTimestamp;
|
||||
WebRtc_UWord32 _lastInTimestamp;
|
||||
CodecInst _sendCodecInst;
|
||||
uint8_t _cng_nb_pltype;
|
||||
uint8_t _cng_wb_pltype;
|
||||
uint8_t _cng_swb_pltype;
|
||||
uint8_t _cng_fb_pltype;
|
||||
uint8_t _red_pltype;
|
||||
bool _vadEnabled;
|
||||
bool _dtxEnabled;
|
||||
ACMVADMode _vadMode;
|
||||
ACMGenericCodec* _codecs[ACMCodecDB::kMaxNumCodecs];
|
||||
ACMGenericCodec* _slaveCodecs[ACMCodecDB::kMaxNumCodecs];
|
||||
WebRtc_Word16 _mirrorCodecIdx[ACMCodecDB::kMaxNumCodecs];
|
||||
bool _stereoReceive[ACMCodecDB::kMaxNumCodecs];
|
||||
bool _stereoReceiveRegistered;
|
||||
bool _stereoSend;
|
||||
int _prev_received_channel;
|
||||
int _expected_channels;
|
||||
WebRtc_Word32 _currentSendCodecIdx;
|
||||
int _current_receive_codec_idx;
|
||||
bool _sendCodecRegistered;
|
||||
ACMResampler _inputResampler;
|
||||
ACMResampler _outputResampler;
|
||||
ACMNetEQ _netEq;
|
||||
CriticalSectionWrapper* _acmCritSect;
|
||||
ACMVADCallback* _vadCallback;
|
||||
WebRtc_UWord8 _lastRecvAudioCodecPlType;
|
||||
AudioPacketizationCallback* packetization_callback_;
|
||||
WebRtc_Word32 id_;
|
||||
WebRtc_UWord32 last_timestamp_;
|
||||
WebRtc_UWord32 last_in_timestamp_;
|
||||
CodecInst send_codec_inst_;
|
||||
uint8_t cng_nb_pltype_;
|
||||
uint8_t cng_wb_pltype_;
|
||||
uint8_t cng_swb_pltype_;
|
||||
uint8_t cng_fb_pltype_;
|
||||
uint8_t red_pltype_;
|
||||
bool vad_enabled_;
|
||||
bool dtx_enabled_;
|
||||
ACMVADMode vad_mode_;
|
||||
ACMGenericCodec* codecs_[ACMCodecDB::kMaxNumCodecs];
|
||||
ACMGenericCodec* slave_codecs_[ACMCodecDB::kMaxNumCodecs];
|
||||
WebRtc_Word16 mirror_codec_idx_[ACMCodecDB::kMaxNumCodecs];
|
||||
bool stereo_receive_[ACMCodecDB::kMaxNumCodecs];
|
||||
bool stereo_receive_registered_;
|
||||
bool stereo_send_;
|
||||
int prev_received_channel_;
|
||||
int expected_channels_;
|
||||
WebRtc_Word32 current_send_codec_idx_;
|
||||
int current_receive_codec_idx_;
|
||||
bool send_codec_registered_;
|
||||
ACMResampler input_resampler_;
|
||||
ACMResampler output_resampler_;
|
||||
ACMNetEQ neteq_;
|
||||
CriticalSectionWrapper* acm_crit_sect_;
|
||||
ACMVADCallback* vad_callback_;
|
||||
WebRtc_UWord8 last_recv_audio_codec_pltype_;
|
||||
|
||||
// RED/FEC.
|
||||
bool _isFirstRED;
|
||||
bool _fecEnabled;
|
||||
// TODO(turajs): |_redBuffer| is allocated in constructor, why having them
|
||||
bool is_first_red_;
|
||||
bool fec_enabled_;
|
||||
// TODO(turajs): |red_buffer_| is allocated in constructor, why having them
|
||||
// as pointers and not an array. If concerned about the memory, then make a
|
||||
// set-up function to allocate them only when they are going to be used, i.e.
|
||||
// FEC or Dual-streaming is enabled.
|
||||
WebRtc_UWord8* _redBuffer;
|
||||
// TODO(turajs): we actually don't need |_fragmentation| as a member variable.
|
||||
WebRtc_UWord8* red_buffer_;
|
||||
// TODO(turajs): we actually don't need |fragmentation_| as a member variable.
|
||||
// It is sufficient to keep the length & payload type of previous payload in
|
||||
// member variables.
|
||||
RTPFragmentationHeader _fragmentation;
|
||||
WebRtc_UWord32 _lastFECTimestamp;
|
||||
RTPFragmentationHeader fragmentation_;
|
||||
WebRtc_UWord32 last_fec_timestamp_;
|
||||
// If no RED is registered as receive codec this
|
||||
// will have an invalid value.
|
||||
WebRtc_UWord8 _receiveREDPayloadType;
|
||||
WebRtc_UWord8 receive_red_pltype_;
|
||||
|
||||
// This is to keep track of CN instances where we can send DTMFs.
|
||||
WebRtc_UWord8 _previousPayloadType;
|
||||
WebRtc_UWord8 previous_pltype_;
|
||||
|
||||
// This keeps track of payload types associated with _codecs[].
|
||||
// This keeps track of payload types associated with codecs_[].
|
||||
// We define it as signed variable and initialize with -1 to indicate
|
||||
// unused elements.
|
||||
WebRtc_Word16 _registeredPlTypes[ACMCodecDB::kMaxNumCodecs];
|
||||
WebRtc_Word16 registered_pltypes_[ACMCodecDB::kMaxNumCodecs];
|
||||
|
||||
// Used when payloads are pushed into ACM without any RTP info
|
||||
// One example is when pre-encoded bit-stream is pushed from
|
||||
// a file.
|
||||
WebRtcRTPHeader* _dummyRTPHeader;
|
||||
WebRtc_UWord16 _recvPlFrameSizeSmpls;
|
||||
WebRtcRTPHeader* dummy_rtp_header_;
|
||||
WebRtc_UWord16 recv_pl_frame_size_smpls_;
|
||||
|
||||
bool _receiverInitialized;
|
||||
ACMDTMFDetection* _dtmfDetector;
|
||||
bool receiver_initialized_;
|
||||
ACMDTMFDetection* dtmf_detector_;
|
||||
|
||||
AudioCodingFeedback* _dtmfCallback;
|
||||
WebRtc_Word16 _lastDetectedTone;
|
||||
CriticalSectionWrapper* _callbackCritSect;
|
||||
|
||||
AudioFrame _audioFrame;
|
||||
AudioFrame _preprocess_frame;
|
||||
CodecInst _secondarySendCodecInst;
|
||||
scoped_ptr<ACMGenericCodec> _secondaryEncoder;
|
||||
#ifdef ACM_QA_TEST
|
||||
FILE* _outgoingPL;
|
||||
FILE* _incomingPL;
|
||||
#endif
|
||||
AudioCodingFeedback* dtmf_callback_;
|
||||
WebRtc_Word16 last_detected_tone_;
|
||||
CriticalSectionWrapper* callback_crit_sect_;
|
||||
|
||||
AudioFrame audio_frame_;
|
||||
AudioFrame preprocess_frame_;
|
||||
CodecInst secondary_send_codec_inst_;
|
||||
scoped_ptr<ACMGenericCodec> secondary_encoder_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "audio_coding_module.h"
|
||||
#include "critical_section_wrapper.h"
|
||||
#include "rw_lock_wrapper.h"
|
||||
#include "webrtc/modules/interface/module_common_types.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user