This patch was written by Paul Yago, who has since left
our company, but gave me permission to post it.
It is for the svn trunk 8978.
Index:
sipx/sipXmediaAdapterLib/sipXmediaMediaProcessing/include/CpPhoneMediaInterface.h
===================================================================
---
sipx/sipXmediaAdapterLib/sipXmediaMediaProcessing/include/CpPhoneMediaInterface.h
(revision 8978)
+++
sipx/sipXmediaAdapterLib/sipXmediaMediaProcessing/include/CpPhoneMediaInterface.h
(working copy)
@@ -85,7 +85,7 @@
//:Assignment operator
- virtual OsStatus createConnection(int& connectionId, void*
videoWindowHandle) ;
+ virtual OsStatus createConnection(int& connectionId, void*
videoWindowHandle, int nSpecifiedLocalPort = 0) ;
virtual OsStatus getCapabilities(int connectionId,
UtlString& rtpHostAddress,
Index:
sipx/sipXmediaAdapterLib/sipXmediaMediaProcessing/src/CpPhoneMediaInterface.cpp
===================================================================
---
sipx/sipXmediaAdapterLib/sipXmediaMediaProcessing/src/CpPhoneMediaInterface.cpp
(revision 8978)
+++
sipx/sipXmediaAdapterLib/sipXmediaMediaProcessing/src/CpPhoneMediaInterface.cpp
(working copy)
@@ -171,6 +171,8 @@
OsSocket::getHostIp(&mLocalAddress);
}
+ OsSysLog::add(FAC_CP, PRI_INFO,
"CpPhoneMediaInterface::CpPhoneMediaInterface sdpCodecArray:%p numCodecs:%d",
sdpCodecArray, numCodecs);
+
if(sdpCodecArray && numCodecs > 0)
{
UtlString codecList("");
@@ -191,6 +193,11 @@
case SdpCodec::SDP_CODEC_GIPS_PCMA:
codecList.append("pcma ");
break;
+ // adomo PCY
+ case SdpCodec::SDP_CODEC_G729AB:
+ codecList.append("G729AB ");
+ break;
+
#ifdef HAVE_GIPS
case SdpCodec::SDP_CODEC_GIPS_IPCMU:
codecList.append("eg711u ");
@@ -296,15 +303,23 @@
}
-OsStatus CpPhoneMediaInterface::createConnection(int& connectionId, void*
videoWindowHandle)
+OsStatus CpPhoneMediaInterface::createConnection(int& connectionId, void*
videoWindowHandle, int nSpecifiedLocalPort) // pcy, added optional local port
parameter.
{
- int localPort ;
+ int localPort;
+ int iNextRtpPort;
OsStatus returnCode;
{
connectionId = mpFlowGraph->createConnection();
- mpFactoryImpl->getNextRtpPort(localPort);
- int iNextRtpPort = localPort ;
+ if (0 == nSpecifiedLocalPort)
+ {
+ mpFactoryImpl->getNextRtpPort(localPort);
+ iNextRtpPort = localPort;
+ }
+ else
+ {
+ localPort = nSpecifiedLocalPort;
+ }
CpPhoneMediaConnection* mediaConnection = new CpPhoneMediaConnection();
OsSysLog::add(FAC_CP, PRI_DEBUG,
"CpPhoneMediaInterface::createConnection creating a new connection %p",
@@ -324,7 +339,7 @@
// Validate local port is not auto-selecting.
- if (localPort != 0)
+ if (nSpecifiedLocalPort == 0 && localPort != 0)
{
// If either of the sockets are bad (e.g. already in use) or
// if either have stuff on them to read (e.g. someone is
@@ -500,7 +515,7 @@
}
else
{
- OsSysLog::add(FAC_CP, PRI_ERR, "ERROR: no rtp socket in
setConnectionDestination\n");
+ OsSysLog::add(FAC_CP, PRI_ERR, "ERROR: no rtcp socket in
setConnectionDestination\n");
}
}
else
Index: sipx/sipXmediaAdapterLib/interface/mi/CpMediaInterface.h
===================================================================
--- sipx/sipXmediaAdapterLib/interface/mi/CpMediaInterface.h (revision 8978)
+++ sipx/sipXmediaAdapterLib/interface/mi/CpMediaInterface.h (working copy)
@@ -95,7 +95,7 @@
* a window handle of NULL to disable video for this call/
* connection.
*/
- virtual OsStatus createConnection(int& connectionId, void*
videoWindowHandle) = 0 ;
+ virtual OsStatus createConnection(int& connectionId, void*
videoWindowHandle, int explicitLocalPort = 0) = 0 ;
/**
* Get the port, address, and codec capabilities for the specified media
Index: sipx/sipXmediaLib/include/Makefile.am
===================================================================
--- sipx/sipXmediaLib/include/Makefile.am (revision 8978)
+++ sipx/sipXmediaLib/include/Makefile.am (working copy)
@@ -49,6 +49,7 @@
mp/MpdPtAVT.h \
mp/MpdSipxPcma.h \
mp/MpdSipxPcmu.h \
+ mp/MpdVAG729ab.h \
mp/MpeGIPSG729ab.h \
mp/MpeGIPSiLBC.h \
mp/MpeGIPSiPCMA.h \
@@ -58,6 +59,7 @@
mp/MpeGIPSPCMU.h \
mp/MpeSipxPcma.h \
mp/MpeSipxPcmu.h \
+ mp/MpeVAG729ab.h \
mp/MpEncoderBase.h \
mp/MpePtAVT.h \
mp/MpFlowGraphBase.h \
Index: sipx/sipXmediaLib/include/mp/MpeVAG729ab.h
===================================================================
--- sipx/sipXmediaLib/include/mp/MpeVAG729ab.h (revision 0)
+++ sipx/sipXmediaLib/include/mp/MpeVAG729ab.h (revision 0)
@@ -0,0 +1,75 @@
+//
+// MpeVAG729ab
+// yago: Adomo
+//
+// $$
+////////////////////////////////////////////////////////////////////////
+//////
+
+
+#ifndef _MpeVAG729ab_h_
+#define _MpeVAG729ab_h_
+
+// APPLICATION INCLUDES
+#include "mp/MpEncoderBase.h"
+
+//:Derived class for G.711 u-Law (PCMU) encoder.
+class MpeVAG729ab: public MpEncoderBase
+{
+/* //////////////////////////// PUBLIC //////////////////////////////////// */
+public:
+
+ MpeVAG729ab(int payloadType);
+ //:Constructor
+ // Returns a new decoder object.
+ //!param: payloadType - (in) RTP payload type associated with this decoder
+
+ virtual ~MpeVAG729ab(void);
+ //:Destructor
+
+ virtual OsStatus initEncode(void);
+ //:Initializes a codec data structure for use as an encoder
+ //!retcode: OS_SUCCESS - Success
+ //!retcode: OS_NO_MEMORY - Memory allocation failure
+
+ virtual OsStatus freeEncode(void);
+ //:Frees all memory allocated to the encoder by <i>initEncode</i>
+ //!retcode: OS_SUCCESS - Success
+ //!retcode: OS_DELETED - Object has already been deleted
+
+/* ============================ MANIPULATORS ============================== */
+
+ virtual OsStatus encode(const short* pAudioSamples,
+ const int numSamples,
+ int& rSamplesConsumed,
+ unsigned char* pCodeBuf,
+ const int bytesLeft,
+ int& rSizeInBytes,
+ UtlBoolean& sendNow,
+ MpBufSpeech& rAudioCategory);
+ //:Encode audio samples
+ // Processes the array of audio samples. If sufficient samples to encode
+ // a frame are now available, the encoded data will be written to the
+ // <i>pCodeBuf</i> array. The number of bytes written to the
+ // <i>pCodeBuf</i> array is returned in <i>rSizeInBytes</i>.
+ //!param: pAudioSamples - (in) Pointer to array of PCM samples
+ //!param: numSamples - (in) number of samples at pAudioSamples
+ //!param: rSamplesConsumed - (out) Number of samples encoded
+ //!param: pCodeBuf - (out) Pointer to array for encoded data
+ //!param: bytesLeft - (in) number of bytes available at pCodeBuf
+ //!param: rSizeInBytes - (out) Number of bytes written to the
<i>pCodeBuf</i> array
+ //!param: sendNow - (out) if true, the packet is complete, send it.
+ //!param: rAudioCategory - (out) Audio type (e.g., unknown, silence,
comfort noise)
+ //!retcode: OS_SUCCESS - Success
+
+/* ============================ ACCESSORS ================================= */
+
+/* //////////////////////////// PRIVATE /////////////////////////////////// */
+private:
+ static const MpCodecInfo smCodecInfo; // static information about the codec
+ void* m_hCodec;
+
+};
+
+#endif
+// _MpeVAG729ab_h_
Index: sipx/sipXmediaLib/include/mp/MpdVAG729ab.h
===================================================================
--- sipx/sipXmediaLib/include/mp/MpdVAG729ab.h (revision 0)
+++ sipx/sipXmediaLib/include/mp/MpdVAG729ab.h (revision 0)
@@ -0,0 +1,74 @@
+//
+// MpdVAG729ab decoder stub for Voiceage G729
+// [EMAIL PROTECTED]
+//
+// $$
+////////////////////////////////////////////////////////////////////////
+//////
+
+//#ifdef HAVE_G729
+
+#ifndef _MpdVAG729ab_h_
+#define _MpdVAG729ab_h_
+
+// SYSTEM INCLUDES
+
+// APPLICATION INCLUDES
+#include "mp/MpDecoderBase.h"
+
+// DEFINES
+// MACROS
+// EXTERNAL FUNCTIONS
+// EXTERNAL VARIABLES
+// CONSTANTS
+// STRUCTS
+// TYPEDEFS
+
+//:Derived class for VA G.729 decoder.
+class MpdVAG729ab: public MpDecoderBase
+{
+/* //////////////////////////// PUBLIC //////////////////////////////////// */
+public:
+
+/* ============================ CREATORS ================================== */
+ MpdVAG729ab(int payloadType);
+ //:Constructor
+ // Returns a new decoder object.
+ //!param: payloadType - (in) RTP payload type associated with this decoder
+
+ virtual ~MpdVAG729ab(void);
+ //:Destructor
+
+ virtual OsStatus initDecode(MpConnection* pConnection);
+ //:Initializes a codec data structure for use as a decoder
+ //!param: pConnection - (in) Pointer to the MpConnection container
+ //!retcode: OS_SUCCESS - Success
+ //!retcode: OS_NO_MEMORY - Memory allocation failure
+
+ virtual OsStatus freeDecode(void);
+ //:Frees all memory allocated to the decoder by <i>initDecode</i>
+ //!retcode: OS_SUCCESS - Success
+ //!retcode: OS_DELETED - Object has already been deleted
+
+/* ============================ MANIPULATORS ============================== */
+
+ virtual int decodeIn(MpBufPtr pPacket);
+ //:Receive a packet of RTP data
+ //!param: pPacket - (in) Pointer to a media buffer
+ //!retcode: length of packet to hand to jitter buffer, 0 means don't.
+
+ virtual int MpdVAG729ab::decode(u_char *encoded, int inSamples, Sample
*decoded);
+
+
+/* ============================ ACCESSORS ================================= */
+
+/* ============================ INQUIRY =================================== */
+
+/* //////////////////////////// PRIVATE /////////////////////////////////// */
+private:
+ static const MpCodecInfo smCodecInfo; // static information about the codec
+ void* m_hCodec;
+};
+
+#endif // _MpdVAG729ab_h_
+//#endif /* HAVE_G729 */
Index: sipx/sipXmediaLib/src/Makefile.am
===================================================================
--- sipx/sipXmediaLib/src/Makefile.am (revision 8978)
+++ sipx/sipXmediaLib/src/Makefile.am (working copy)
@@ -68,6 +68,7 @@
mp/MpdPtAVT.cpp \
mp/MpdSipxPcma.cpp \
mp/MpdSipxPcmu.cpp \
+ mp/MpdVAG729ab.cpp \
mp/MpeGIPSG729ab.cpp \
mp/MpeGIPSiLBC.cpp \
mp/MpeGIPSiPCMA.cpp \
@@ -77,6 +78,7 @@
mp/MpeGIPSPCMU.cpp \
mp/MpeSipxPcma.cpp \
mp/MpeSipxPcmu.cpp \
+ mp/MpeVAG729ab.cpp \
mp/MpEncoderBase.cpp \
mp/MpePtAVT.cpp \
mp/MpFlowGraphBase.cpp \
@@ -141,3 +143,84 @@
rtcp/RTPHeader.cpp \
rtcp/SenderReport.cpp \
rtcp/SourceDescription.cpp
+
+LIBDIR_VA=$(INSTALLPATH)/lib/voiceage/
+CODECLIB_TARGET =$(LIBDIR_VA)codecLib.a
+AMRWBPLUSLIB_TARGET =$(LIBDIR_VA)amrwbplus.a
+COMMONWBLIB_TARGET =$(LIBDIR_VA)commonwb.a
+G711LIB_TARGET =$(LIBDIR_VA)g711.a
+G722LIB_TARGET =$(LIBDIR_VA)g722.a
+G723LIB_TARGET =$(LIBDIR_VA)g723.a
+G726LIB_TARGET =$(LIBDIR_VA)g726.a
+G728LIB_TARGET =$(LIBDIR_VA)g728.a
+G729OPT_TARGET =$(LIBDIR_VA)g729Opt.a
+G729AOPT_TARGET =$(LIBDIR_VA)g729aOpt.a
+G729BOPT_TARGET =$(LIBDIR_VA)g729bOpt.a
+G729ABOPT_TARGET =$(LIBDIR_VA)g729abOpt.a
+G729EOPT_TARGET =$(LIBDIR_VA)g729eOpt.a
+AMRNBIOPT_TARGET =$(LIBDIR_VA)amrnbIOpt.a
+AMRWBOPT_TARGET =$(LIBDIR_VA)amrwbOpt.a
+G729DLIB_TARGET =$(LIBDIR_VA)g729d.a
+EVRCLIB_TARGET =$(LIBDIR_VA)evrc.a
+UTIL_TARGET =$(LIBDIR_VA)utilities.a
+GSMFRLIB_TARGET =$(LIBDIR_VA)gsmfr.a
+GSMHRLIB_TARGET =$(LIBDIR_VA)gsmhr.a
+MSGSM_TARGET =$(LIBDIR_VA)msgsm.a
+LIN16_8_TARGET =$(LIBDIR_VA)lin16_8.a
+QCELP13LIB_TARGET =$(LIBDIR_VA)qcelp13.a
+RESAMPLER_TARGET =$(LIBDIR_VA)resampler.a
+VMRWB_TARGET =$(LIBDIR_VA)vmrwb.a
+OS_DEPEND_TARGET =$(LIBDIR_VA)osdepend.a
+FILEACCESSTOOLS_TARGET =$(LIBDIR_VA)FileAccessTools.a
+DEMO_TARGET= \
+ $(CODECLIB_TARGET) \
+ $(AMRNBIOPT_TARGET) \
+ $(AMRWBOPT_TARGET) \
+ $(AMRWBPLUSLIB_TARGET) \
+ $(COMMONWBLIB_TARGET) \
+ $(G711LIB_TARGET) \
+ $(G722LIB_TARGET) \
+ $(G723LIB_TARGET) \
+ $(G726LIB_TARGET) \
+ $(G728LIB_TARGET) \
+ $(G729OPT_TARGET) \
+ $(G729AOPT_TARGET) \
+ $(G729ABOPT_TARGET) \
+ $(G729BOPT_TARGET) \
+ $(G729EOPT_TARGET) \
+ $(G729DLIB_TARGET) \
+ $(EVRCLIB_TARGET) \
+ $(GSMHRLIB_TARGET) \
+ $(GSMFRLIB_TARGET) \
+ $(MSGSM_TARGET) \
+ $(LIN16_8_TARGET) \
+ $(QCELP13LIB_TARGET) \
+ $(RESAMPLER_TARGET) \
+ $(UTIL_TARGET) \
+ $(VMRWB_TARGET) \
+ $(FILEACCESSTOOLS_TARGET) \
+ $(OS_DEPEND_TARGET)
+
+LIBDIRS_OPT_VA = -L$(LIBDIR_VA)opt-lib -L$(LIBDIR_VA)opt-lib/amrnb
-L$(LIBDIR_VA)opt-lib/amrwb -L$(LIBDIR_VA)opt-lib/g729
+
+LIBS_CORE_VA=\
+ -lcorel
+LIBS_AMRNB=\
+ -lscemerged_amrnb \
+ -lscmerged_amrnb \
+ -lsemerged_amrnb \
+ -lsmerged_amrnb
+LIBS_AMRWB=\
+ -lscemerged_amrwb \
+ -lscmerged_amrwb \
+ -lsemerged_amrwb \
+ -lsmerged_amrwb
+LIBS_G729=\
+ -lscemerged_g729 \
+ -lscmerged_g729 \
+ -lsemerged_g729 \
+ -lsmerged_g729
+
+LDFLAGS_VA = $(LIBDIRS_OPT_VA) $(LIBS_AMRNB) $(LIBS_AMRWB) $(LIBS_G729)
$(LIBS_CORE_VA)
+LIBS = -lpthread -lm $(DEMO_TARGET) $(LDFLAGS_VA)
+
Index: sipx/sipXmediaLib/src/mp/MpdVAG729ab.cpp
===================================================================
--- sipx/sipXmediaLib/src/mp/MpdVAG729ab.cpp (revision 0)
+++ sipx/sipXmediaLib/src/mp/MpdVAG729ab.cpp (revision 0)
@@ -0,0 +1,158 @@
+//
+// Copyright (C) 2005 Pingtel Corp.
+// Licensed to SIPfoundry under a Contributor Agreement.
+//
+// Adomo:[EMAIL PROTECTED]
+//
+// $$
+////////////////////////////////////////////////////////////////////////
+//////// MpdVAG729.cpp
+
+
+#include "os/OsSysLog.h"
+#include "mp/MprDejitter.h"
+#include "mp/MpdVAG729ab.h"
+#include <voiceage/codecLib_if.h>
+#include <wchar.h>
+
+
+#define FRAMES_PER_PACKET 2
+const MpCodecInfo MpdVAG729ab::smCodecInfo(SdpCodec::SDP_CODEC_G729,
+ "1.0", // codec
version
+ true, //
numSamples
+ 8000, //
samplingRate
+ 1, //
numBitsPerSample
+ 1, //
numChannels
+ FRAMES_PER_PACKET * 80, //
interleaveBlockSize
+ 8000, //
bitRate
+ FRAMES_PER_PACKET * 80, //
minPacketBits
+ FRAMES_PER_PACKET * 80, //
avgPacketBits
+ FRAMES_PER_PACKET * 80, //
maxPacketBits
+ FRAMES_PER_PACKET * 80) ;//
numSamplesPerFrame
+ //
preCodecJitterBufferSize
+ //
signalingCodec
+ //
doesVadCng
+
+
+MpdVAG729ab::MpdVAG729ab(int payloadType) : MpDecoderBase(payloadType,
&smCodecInfo)
+{
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab ctor() enter");
+ m_hCodec = NULL;
+}
+
+MpdVAG729ab::~MpdVAG729ab()
+{
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab dtor() enter");
+ freeDecode();
+ m_hCodec = NULL;
+}
+
+OsStatus MpdVAG729ab::freeDecode(void)
+{
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab freeDecode() enter.
m_hCodec:%p\n", m_hCodec);
+ if (m_hCodec)
+ {
+ codecLibClose(&m_hCodec, 0);
+ m_hCodec = NULL;
+ }
+ return OS_SUCCESS;
+}
+
+OsStatus MpdVAG729ab::initDecode(MpConnection* pConnection)
+{
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab initDecode() enter.
pConnection:%p", pConnection);
+
+ codec codecType = G729;
+ codecLibOpen(&m_hCodec, codecType, DEC, VB_A);
+ codecOption option;
+ codecProperties properties;
+
+ Word32 rc = codecLibQuery(&m_hCodec, codecType, DEC, &properties, &option,
VB_A);
+
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecName;%s", properties.codecName);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.modeName;%s", *properties.modeName);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.memorySizeRequired;%d", properties.memorySizeRequired);
+
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecInput.numberOfChannels:%d",
properties.codecInput.numberOfChannels);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecInput.bytesPerSecond:%d", properties.codecInput.bytesPerSecond);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecInput.bytesPerBlock:%d", properties.codecInput.bytesPerBlock);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecInput.samplesPerSecond:%d",
properties.codecInput.samplesPerSecond);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecInput.bitsPerSamples:%d", properties.codecInput.bitsPerSamples);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecInput.samplesPerFrame;%d",
properties.codecInput.samplesPerFrame);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecInput.frameDuration;%d", properties.codecInput.frameDuration);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecInput.bufferSize;%d", properties.codecInput.bufferSize);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecInput.maxBufferSize;%d", properties.codecInput.maxBufferSize);
+
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecOutput.numberOfChannels:%d",
properties.codecOutput.numberOfChannels);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecOutput.bytesPerSecond:%d",
properties.codecOutput.bytesPerSecond);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecOutput.bytesPerBlock:%d", properties.codecOutput.bytesPerBlock);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecOutput.samplesPerSecond:%d",
properties.codecOutput.samplesPerSecond);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecOutput.bitsPerSamples:%d",
properties.codecOutput.bitsPerSamples);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecOutput.samplesPerFrame;%d",
properties.codecOutput.samplesPerFrame);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecOutput.frameDuration;%d", properties.codecOutput.frameDuration);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecOutput.bufferSize;%d", properties.codecOutput.bufferSize);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode:
properties.codecOutput.maxBufferSize;%d", properties.codecOutput.maxBufferSize);
+
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode: option.dtx
: %d", option.DTX_mode);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: initDecode: option.mode
: %d", option.mode);
+
+ return OS_SUCCESS;
+}
+
+// called by the MprJitterBuffer. only MprJitterBuffer calls decode().
+// *encoded is the address of the first byte of the rtp payload.
+// inSamples is the size of the payload is bytes.
+// decoded is the
+int MpdVAG729ab::decode(u_char *encoded, int inSamples, Sample *decoded)
+{
+ #define MAX_BUFFER_SIZE 256
+
+ codecOption option;
+ Word32 inputSize = inSamples;
+ Word8 inputBuffer[MAX_BUFFER_SIZE];
+ Word16 outputBuffer[MAX_BUFFER_SIZE];
+ Word32 outputSize = MAX_BUFFER_SIZE;
+
+ // Decode the input buffer (Word8*) to an output buffer (Word16)
+ Word32 rc = codecLibDecode(&m_hCodec, (Word8*)encoded, &inputSize,
outputBuffer, &outputSize, &option, 0);
+
+ // Copy to the output buffer contents to the decoded samples buffer.
+ // !! memcpy() had issues with voice quality
+ for (int i = 0; i < outputSize; i++)
+ {
+ decoded[i] = outputBuffer[i];
+ }
+
+ while (rc == WAR_CM_DEC_OUT_FULL)
+ {
+ // OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdVAG729ab: WAR_CM_DEC_OUT_FULL
before codecLibDecode(). inputSize:%d. outputSize:%d", (long)inputSize,
(long)outputSize);
+
+ // If the output decode buffer is full, then call codecLibDecode with no
input buffer.
+ inputSize = 0;
+ rc = codecLibDecode(&m_hCodec, (Word8*)encoded, &inputSize, outputBuffer,
&outputSize, &option, 0);
+ for (int i = 0; i < outputSize; i++)
+ {
+ decoded[i] = outputBuffer[i];
+ }
+ }
+ return outputSize;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////
+// decodeIn() is called only by MprDecode
+//
+// :Receive a packet of RTP data. Determine whether or not it's eligable for
decode.
+// !param: pPacket - (in) Pointer to a media buffer
+// !retcode: length of packet to hand to jitter buffer, 0 means don't.
+///////////////////////////////////////////////////////////////////////////////////////////
+int MpdVAG729ab::decodeIn(MpBufPtr pPacket)
+{
+ // THIS METHOD CAN BE CALLED MORE THAN ONE TIME PER FRAME INTERVAL
+ // This method figures out if we want this packet or not. If no, return a 0,
else return the packet size
+ unsigned int rtpTimestamp = MprDejitter::getTimestamp(pPacket);
+
+ // !! For now just return the packet length, later determine whether or not
to keep the packet. (out of order, late, etc).
+ return MpBuf_getContentLen(pPacket);
+}
+
Index: sipx/sipXmediaLib/src/mp/MpeVAG729ab.cpp
===================================================================
--- sipx/sipXmediaLib/src/mp/MpeVAG729ab.cpp (revision 0)
+++ sipx/sipXmediaLib/src/mp/MpeVAG729ab.cpp (revision 0)
@@ -0,0 +1,137 @@
+//
+// Copyright (C) 2005 Pingtel Corp.
+// Licensed to SIPfoundry under a Contributor Agreement.
+//
+// Author: [EMAIL PROTECTED]
+//
+// $$
+////////////////////////////////////////////////////////////////////////
+////// MpeVAG729ab.cpp
+
+
+#include "assert.h"
+// APPLICATION INCLUDES
+
+#include "mp/MpeVAG729ab.h"
+#include "os/OsSysLog.h"
+#include "mp/JB/JB_API.h"
+#include <voiceage/codecLib_if.h>
+
+#define FRAMES_PER_PACKET 2
+const MpCodecInfo MpeVAG729ab::smCodecInfo(SdpCodec::SDP_CODEC_G729AB,
+ "1.0", // codec
version
+ true, //
numSamples
+ 8000, //
samplingRate
+ 1, //
numBitsPerSample
+ 1, //
numChannels
+ FRAMES_PER_PACKET * 80, //
interleaveBlockSize
+ 8000, //
bitRate
+ FRAMES_PER_PACKET * 80, //
minPacketBits
+ FRAMES_PER_PACKET * 80, //
avgPacketBits
+ FRAMES_PER_PACKET * 80, //
maxPacketBits
+ FRAMES_PER_PACKET * 80);//
numSamplesPerFrame
+ //
preCodecJitterBufferSize
+ //
signalingCodec
+ //
doesVadCng
+
+
+MpeVAG729ab::MpeVAG729ab(int payloadType) : MpEncoderBase(payloadType,
&smCodecInfo)
+{
+ OsSysLog::add(FAC_MP, PRI_DEBUG,
"MpeVAG729ab::MpeVAG729ab(payloadType=%d)\n", payloadType);
+ m_hCodec = NULL;
+}
+
+MpeVAG729ab::~MpeVAG729ab()
+{
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab::~MpeVAG729ab() enter\n");
+ freeEncode();
+}
+
+OsStatus MpeVAG729ab::initEncode(void)
+{
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab::initEncode enter\n");
+
+ // *** voiceage ***
+ // codec is an enum type of codec IDs.
+ // VB_A is verbosity level
+ // ENC is encode (DEC is decode).
+ codec codecType = G729;
+ codecLibOpen(&m_hCodec, codecType, ENC, VB_A);
+ codecOption option;
+ codecProperties properties;
+
+ Word32 rc = codecLibQuery(&m_hCodec, codecType, ENC, &properties, &option,
VB_A);
+
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecName;%s", properties.codecName);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.modeName;%s", *properties.modeName);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.memorySizeRequired;%d", properties.memorySizeRequired);
+
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecInput.numberOfChannels:%d",
properties.codecInput.numberOfChannels);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecInput.bytesPerSecond:%d", properties.codecInput.bytesPerSecond);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecInput.bytesPerBlock:%d", properties.codecInput.bytesPerBlock);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecInput.samplesPerSecond:%d",
properties.codecInput.samplesPerSecond);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecInput.bitsPerSamples:%d", properties.codecInput.bitsPerSamples);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecInput.samplesPerFrame;%d",
properties.codecInput.samplesPerFrame);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecInput.frameDuration;%d", properties.codecInput.frameDuration);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecInput.bufferSize;%d", properties.codecInput.bufferSize);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecInput.maxBufferSize;%d", properties.codecInput.maxBufferSize);
+
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecOutput.numberOfChannels:%d",
properties.codecOutput.numberOfChannels);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecOutput.bytesPerSecond:%d",
properties.codecOutput.bytesPerSecond);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecOutput.bytesPerBlock:%d", properties.codecOutput.bytesPerBlock);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecOutput.samplesPerSecond:%d",
properties.codecOutput.samplesPerSecond);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecOutput.bitsPerSamples:%d",
properties.codecOutput.bitsPerSamples);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecOutput.samplesPerFrame;%d",
properties.codecOutput.samplesPerFrame);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecOutput.frameDuration;%d", properties.codecOutput.frameDuration);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecOutput.bufferSize;%d", properties.codecOutput.bufferSize);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode:
properties.codecOutput.maxBufferSize;%d", properties.codecOutput.maxBufferSize);
+
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode: dtx :
%d", option.DTX_mode);
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab: initEncode: mode :
%d", option.mode);
+
+ return OS_SUCCESS;
+}
+
+OsStatus MpeVAG729ab::freeEncode(void)
+{
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpeVAG729ab::freeEncode enter.
m_hCodec:%p\n", m_hCodec);
+ if (m_hCodec)
+ {
+ codecLibClose(&m_hCodec, 0);
+ m_hCodec = NULL;
+ }
+ return OS_SUCCESS;
+}
+
+
+
+// What if there are too many samples to process? what is the max/min?
+// the samples consumed will be determined by the output buffer size specified
in codecLibEncode's outputSize
+// rc = codecLibEncode(&m_hCodec, buf16, &inputSize, buf8, &outputSize,
&option, 0);
+OsStatus MpeVAG729ab::encode(const short* pAudioSamples,
+ const int numSamples, // number of samples
+ int& rSamplesConsumed, // number of encoded
samples
+ unsigned char* pCodeBuf, // array of proocessed
samples
+ const int bytesLeft, // bytes available to
write to pCodeBuf
+ int& rSizeInBytes, // number of bytes
written to pCodeBuf
+ UtlBoolean& sendNow,
+ MpBufSpeech& rAudioCategory)
+{
+ // !! make sure pcodebuf has enough room.
+ assert(10 <= bytesLeft);
+ Word32 outputSize = 80;
+
+ long rc = codecLibEncode(&m_hCodec, (Word16*)pAudioSamples,
(Word32*)&numSamples, (Word8*)pCodeBuf, &outputSize, NULL, 0);
+
+ // why? why are packets still sent.
+ sendNow = FALSE;
+
+ // refers to the number of bytes of output after processing.
+ rSizeInBytes = (int)outputSize;
+
+ // set the samples consumed to be the number of samples sent.
+ rSamplesConsumed = numSamples;
+
+ return OS_SUCCESS;
+}
+
Index: sipx/sipXmediaLib/src/mp/MpCodecFactory.cpp
===================================================================
--- sipx/sipXmediaLib/src/mp/MpCodecFactory.cpp (revision 8978)
+++ sipx/sipXmediaLib/src/mp/MpCodecFactory.cpp (working copy)
@@ -26,6 +26,11 @@
// all encoder child classes
#include "mp/MpePtAVT.h"
+
+// pcy : adomo - encase these in directives.
+#include "mp/MpdVAG729ab.h"
+#include "mp/MpeVAG729ab.h"
+
#ifdef HAVE_GIPS /* [ */
#include "mp/MpeGIPSPCMA.h"
#include "mp/MpeGIPSPCMU.h"
@@ -160,6 +165,11 @@
#endif /* HAVE_GIPS ] */
+ case (SdpCodec::SDP_CODEC_G729AB):
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpCodecFactory.
SdpCodec::SDP_CODEC_G729AB. creating MpdVAG729ab\n");
+ rpDecoder = new MpdVAG729ab(payloadType);
+ break;
+
case (SdpCodec::SDP_CODEC_GIPS_PCMA):
rpDecoder = new MpdSipxPcma(payloadType);
break;
@@ -197,6 +207,8 @@
OsStatus MpCodecFactory::createEncoder(SdpCodec::SdpCodecTypes internalCodecId,
int payloadType, MpEncoderBase*& rpEncoder)
{
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpCodecFactory::createEncoder. enter
internalCodecId:%d. payloadType:%d", internalCodecId, payloadType);
+
rpEncoder=NULL;
switch (internalCodecId) {
@@ -242,6 +254,7 @@
break;
#endif /* PLATFORM_SUPPORTS_G729 ] */
#else /* HAVE_GIPS ] [ */
+
case (SdpCodec::SDP_CODEC_GIPS_PCMA):
rpEncoder = new MpeSipxPcma(payloadType);
break;
@@ -249,7 +262,16 @@
case (SdpCodec::SDP_CODEC_GIPS_PCMU):
rpEncoder = new MpeSipxPcmu(payloadType);
break;
+
+ // adomo:pcy - temporary, use directives
+ case (SdpCodec::SDP_CODEC_G729AB):
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpCodecFactory.
SdpCodec::SDP_CODEC_G729AB. creating MpeVAG729ab");
+ rpEncoder = new MpeVAG729ab(payloadType);
+// ((MpeVAG729ab*)rpEncoder)->setVad(TRUE);
+ break;
+
#endif /* HAVE_GIPS*/
+
default:
OsSysLog::add(FAC_MP, PRI_WARNING,
"MpCodecFactory::createEncoder unknown codec type "
_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/