"better" is in the eye of the beholder. :-)
Here is what I am currently using. It's a mix of the patches plus one
other issue I found.
I am also experiencing memory corruptions that were not there in older
sipXtapi versions. I don't know if they are related to the new Jitter Buffer.
I am getting a Signal 8 Floating Point Exception or Signal 11 Segfault.
The Segfault often totally corrupts the stack and GDB can not give a backtrace.
Here are some Signal 8 GDB traces.
Notice the 33554432 (0x2000000) moved from samplesPerFrame to outBufsSize.
Also in the first bt the MprBridge::doProcessFrame() is already corrupted,
while in the second one it's only MpBridgeAlgLinear::doMix()
This leads me to suspect that the problem may be outside of these functions.
(gdb) bt
#0 0x006a0f9b in MpBridgeAlgLinear::doMix (this=0xf2827a0, inBufs=0xf2b8ad4,
inBufsSize=11, outBufs=0xab9c82c, outBufsSize=11, samplesPerFrame=33554432) at
mp/MpBridgeAlgLinear.cpp:669
#1 0x006c2846 in MprBridge::doMix (this=0xab6f468, inBufs=0x2000000,
inBufsSize=33554432, outBufs=0x2000000, outBufsSize=33554432,
samplesPerFrame=33554432) at mp/MprBridge.cpp:296
#2 0x006c2bd4 in MprBridge::doProcessFrame (this=0x2000000, inBufs=0x2000000,
outBufs=0x2000000, inBufsSize=11, outBufsSize=11, isEnabled=1,
samplesPerFrame=33554432, samplesPerSecond=8000)
at mp/MprBridge.cpp:427
#3 0x0069cc52 in MpAudioResource::processFrame (this=0xab6f468) at
mp/MpAudioResource.cpp:97
#4 0x006b4c0c in MpFlowGraphBase::processNextFrame (this=0xf281a38) at
mp/MpFlowGraphBase.cpp:456
#5 0x006baad3 in MpMediaTask::handleWaitForSignal (this=0xa9c3868,
pMsg=0xa9f1918) at mp/MpMediaTask.cpp:868
#6 0x006bbf61 in MpMediaTask::handleMessage (this=0xa9c3868, [EMAIL
PROTECTED]) at mp/MpMediaTask.cpp:625
#7 0x009c393b in OsServerTask::run (this=0xa9c3868, pArg=0x0) at
os/OsServerTask.cpp:163
#8 0x009de37d in OsTaskLinux::taskEntry (arg=0xa9c3868) at
os/linux/OsTaskLinux.cpp:713
#9 0x0051c3cc in start_thread () from /lib/tls/libpthread.so.0
#10 0x038b51ae in clone () from /lib/tls/libc.so.6
Current language: auto; currently c++
(gdb) bt
#0 0x0036469c in MpBridgeAlgLinear::doMix (this=0xaa151b0, inBufs=0xa9c8ce4,
inBufsSize=11, outBufs=0xa9c90bc, outBufsSize=33554432, samplesPerFrame=80) at
mp/MpBridgeAlgLinear.cpp:664
#1 0x0038511b in MprBridge::doMix (this=0x0, inBufs=0xa9c8ce4, inBufsSize=11,
outBufs=0xa9c90bc, outBufsSize=11, samplesPerFrame=80) at mp/MprBridge.cpp:296
#2 0x0038546e in MprBridge::doProcessFrame (this=0xaa13ae0, inBufs=0xa9c8ce4,
outBufs=0xa9c90bc, inBufsSize=11, outBufsSize=11, isEnabled=33554432,
samplesPerFrame=80, samplesPerSecond=8000)
at mp/MprBridge.cpp:430
#3 0x0035fba2 in MpAudioResource::processFrame (this=0xaa13ae0) at
mp/MpAudioResource.cpp:97
#4 0x003755f3 in MpFlowGraphBase::processNextFrame (this=0xaa13618) at
mp/MpFlowGraphBase.cpp:461
#5 0x0037d213 in MpMediaTask::handleWaitForSignal (this=0xb262bcc0,
pMsg=0xa9c8c58) at mp/MpMediaTask.cpp:868
#6 0x0037e6a1 in MpMediaTask::handleMessage (this=0xb262bcc0, [EMAIL
PROTECTED]) at mp/MpMediaTask.cpp:625
#7 0x00e6d93b in OsServerTask::run (this=0xb262bcc0, pArg=0x0) at
os/OsServerTask.cpp:163
#8 0x00e8837d in OsTaskLinux::taskEntry (arg=0xb262bcc0) at
os/linux/OsTaskLinux.cpp:713
Alexander Chemeris wrote:
Hi,
Am I correct, that this is a better version of the patch, offered
by Paulo?
On Sat, Nov 15, 2008 at 3:07 AM, Carsten Avenhaus <[EMAIL PROTECTED]> wrote:
Here is a patch that re-initializes the RTP session and jitter buffer
after new RTP streams are negotiated, for instance after a supervised
transfer etc.
...Carsten
Index: sipXtapi-3.2/sipXsdpLib/src/sdp/SdpCodecList.cpp
===================================================================
--- sipXtapi-3.2/sipXsdpLib/src/sdp/SdpCodecList.cpp (revision 10954)
+++ sipXtapi-3.2/sipXsdpLib/src/sdp/SdpCodecList.cpp (working copy)
@@ -349,7 +349,7 @@
if( (foundMimeSubType.compareTo(mimeSubTypeString,
UtlString::ignoreCase) == 0)
&& (sampleRate == -1 || codecFound->getSampleRate() ==
sampleRate)
&& (numChannels == -1 || codecFound->getNumChannels() ==
numChannels)
- && (fmtp == foundFmtp)
+ && (*foundFmtp.data() == 0 || fmtp == foundFmtp)
&& (codecFound->getCPUCost() <= mCodecCPULimit))
{
// we found a match
Index: sipXtapi-3.2/sipXmediaLib/include/mp/MprDecode.h
===================================================================
--- sipXtapi-3.2/sipXmediaLib/include/mp/MprDecode.h (revision 10954)
+++ sipXtapi-3.2/sipXmediaLib/include/mp/MprDecode.h (working copy)
@@ -99,6 +99,10 @@
void setMyDejitter(MprDejitter* newDJ);
+ /// Reset RTP Decoder (SSRC change)
+ void reset();
+
+
/// Add incoming RTP packet to the decoding queue
OsStatus pushPacket(const MpRtpBufPtr &pRtp);
/**<
Index: sipXtapi-3.2/sipXmediaLib/include/mp/MprDejitter.h
===================================================================
--- sipXtapi-3.2/sipXmediaLib/include/mp/MprDejitter.h (revision 10954)
+++ sipXtapi-3.2/sipXmediaLib/include/mp/MprDejitter.h (working copy)
@@ -41,7 +41,15 @@
public:
enum {
- MAX_RTP_PACKETS = 512 ///< Could be any value, power of 2 is desired.
+ /// The jitter buffer must not be too long to prevent delays.
+ /// http://www.voiptroubleshooter.com/problems/jbconfig.html
+ /// A typical jitter buffer configuration is 30 milliseconds to 50
milliseconds in depth.
+ /// In the case of an adaptive jitter buffer then the maximum size may
be set to 100-200 milliseconds.
+ /// Note that if the jitter buffer size exceeds 100 milliseconds then
the additional delay introduced
+ /// can lead to conversational difficulty.
+ ///
+ /// Normal RTP packet have a size of 20ms. 16 x 20ms = 320ms
+ MAX_RTP_PACKETS = 16 ///< Could be any value, power of 2 is desired.
};
/* ============================ CREATORS ================================== */
@@ -109,6 +117,9 @@
* amount of time, possible forever.
*/
+ /// Reset dejitter to initial state and prepare for new stream.
+ void reset();
+
//@}
/* ============================ ACCESSORS ================================= */
@@ -148,8 +159,6 @@
/// we can distinguish out-of-order packets.
RtpSeq mMaxPulledSeqNo;
- /// Reset dejitter to initial state and prepare for new stream.
- void reset();
/* //////////////////////////// PRIVATE /////////////////////////////////// */
private:
Index: sipXtapi-3.2/sipXmediaLib/include/mp/MpJitterBuffer.h
===================================================================
--- sipXtapi-3.2/sipXmediaLib/include/mp/MpJitterBuffer.h (revision 10954)
+++ sipXtapi-3.2/sipXmediaLib/include/mp/MpJitterBuffer.h (working copy)
@@ -66,6 +66,9 @@
///@name Manipulators
//@{
+ /// Reset Jitter Buffer (for SSRC change)
+ void reset();
+
/// Push packet into decoder buffer.
OsStatus pushPacket(const MpRtpBufPtr &rtpPacket,
int minBufferSamples,
Index: sipXtapi-3.2/sipXmediaLib/src/mp/MpJitterBuffer.cpp
===================================================================
--- sipXtapi-3.2/sipXmediaLib/src/mp/MpJitterBuffer.cpp (revision 10954)
+++ sipXtapi-3.2/sipXmediaLib/src/mp/MpJitterBuffer.cpp (working copy)
@@ -18,6 +18,7 @@
// APPLICATION INCLUDES
#include "os/OsDefs.h" // for min macro
+#include "os/OsSysLog.h"
#include "mp/MpJitterBuffer.h"
#include "mp/MpDecoderPayloadMap.h"
#include "mp/MpDecoderBase.h"
@@ -111,6 +112,13 @@
/* ============================ MANIPULATORS ============================== */
+// Reset Jitter Buffer (for SSRC change)
+void MpJitterBuffer::reset()
+{
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MpJitterBuffer::reset()");
+ mIsFirstPacket = TRUE;
+}
+
OsStatus MpJitterBuffer::pushPacket(const MpRtpBufPtr &rtpPacket,
int minBufferSamples,
int wantedBufferSamples,
Index: sipXtapi-3.2/sipXmediaLib/src/mp/MpJbeFixed.cpp
===================================================================
--- sipXtapi-3.2/sipXmediaLib/src/mp/MpJbeFixed.cpp (revision 10954)
+++ sipXtapi-3.2/sipXmediaLib/src/mp/MpJbeFixed.cpp (working copy)
@@ -47,8 +47,13 @@
OsStatus MpJbeFixed::init(int samplerate)
{
mSamplerate = samplerate;
- // Set JB length to 1/3sec = 333ms
- mJbLength = mSamplerate/3;
+ // Set JB length to 1/4sec = 200ms
+ // http://www.voiptroubleshooter.com/problems/jbconfig.html
+ // A typical jitter buffer configuration is 30 milliseconds to 50
milliseconds in depth.
+ // In the case of an adaptive jitter buffer then the maximum size may be
set to 100-200 milliseconds.
+ // Note that if the jitter buffer size exceeds 100 milliseconds then the
additional delay
+ // introduced can lead to conversational difficulty.
+ mJbLength = mSamplerate/4;
mDelay = 0;
RTL_EVENT("JbUpdate_first_offset", 0);
Index: sipXtapi-3.2/sipXmediaLib/src/mp/MprDejitter.cpp
===================================================================
--- sipXtapi-3.2/sipXmediaLib/src/mp/MprDejitter.cpp (revision 10954)
+++ sipXtapi-3.2/sipXmediaLib/src/mp/MprDejitter.cpp (working copy)
@@ -17,6 +17,7 @@
// APPLICATION INCLUDES
#include "os/OsDefs.h"
#include "os/OsLock.h"
+#include "os/OsSysLog.h"
#include "mp/MpBuf.h"
#include "mp/MprDejitter.h"
#include "mp/MpMisc.h"
@@ -223,6 +224,7 @@
void MprDejitter::reset()
{
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MprDejitter::reset()");
for (int i=0; i<MAX_RTP_PACKETS; i++)
{
if (mpPackets[i].isValid())
Index: sipXtapi-3.2/sipXmediaLib/src/mp/MprDecode.cpp
===================================================================
--- sipXtapi-3.2/sipXmediaLib/src/mp/MprDecode.cpp (revision 10954)
+++ sipXtapi-3.2/sipXmediaLib/src/mp/MprDecode.cpp (working copy)
@@ -178,6 +178,15 @@
mpMyDJ = pDJ;
}
+// Reset Decoder and Jitter Buffer
+void MprDecode::reset()
+{
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MprDecode::reset()");
+ mIsStreamInitialized = FALSE;
+ mpMyDJ->reset();
+ mpJB->reset();
+}
+
OsStatus MprDecode::pushPacket(const MpRtpBufPtr &pRtp)
{
// Lock access to dejitter and m*Codecs data
@@ -201,6 +210,17 @@
}
const MpCodecInfo* pDecoderInfo = pDecoder->getInfo();
+ // Decode DTMFs right away instead of sending them to the jitter buffer.
+ // DTMF events confuse the jitter buffer timing calculations
(wantedBufferSamples etc.).
+ // This aldo prevents DTMFs from being lost if the RTP packets are not
pulled
+ // fast enough and are thus overwritten. Downside: DTMFs may overtake audio
in the JB.
+ if (pDecoderInfo->isSignalingCodec())
+ {
+ ((MpDecoderBase*)pDecoder)->decode(pRtp, 0, NULL);
+ tryDecodeAsSignalling(pRtp);
+ return OS_SUCCESS;
+ }
+
// Initialize stream, if not initialized yet.
if (mIsStreamInitialized == FALSE)
{
@@ -454,6 +474,7 @@
if (sigRes == OS_SUCCESS && isStarted)
{
// Post DTMF notification message to indicate key down.
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MprDecode::tryDecodeAsSignalling()
RtpSequenceNumber=%d DTMF key %d down",rtp->getRtpSequenceNumber(), event);
MprnDTMFMsg dtmfMsg(getName(), mConnectionId,
(MprnDTMFMsg::KeyCode)event,
MprnDTMFMsg::KEY_DOWN);
@@ -471,6 +492,7 @@
if (sigRes == OS_SUCCESS && isStopped)
{
// Post DTMF notification message to indicate key up.
+ OsSysLog::add(FAC_MP, PRI_DEBUG, "MprDecode::tryDecodeAsSignalling()
RtpSequenceNumber=%d DTMF key %d up",rtp->getRtpSequenceNumber(), event);
MprnDTMFMsg dtmfMsg(getName(), mConnectionId,
(MprnDTMFMsg::KeyCode)event,
MprnDTMFMsg::KEY_UP, duration);
@@ -555,6 +577,12 @@
osPrintf("MprDecode::handleSelectCodecs(%d codec%s):\n",
numCodecs, ((1 == numCodecs) ? "" : "s"));
#endif
+
+ // The RTP decoder and jitter buffer need to be reset
+ // when new RTP streams are negotiated, for instance after a
+ // supervised transfer
+ reset();
+
if (OsSysLog::willLog(FAC_MP, PRI_DEBUG))
{
for (i=0; i<numCodecs; i++) {
Index: sipXtapi-3.2/sipXmediaLib/src/mp/MprFromNet.cpp
===================================================================
--- sipXtapi-3.2/sipXmediaLib/src/mp/MprFromNet.cpp (revision 10954)
+++ sipXtapi-3.2/sipXmediaLib/src/mp/MprFromNet.cpp (working copy)
@@ -40,6 +40,7 @@
#endif /* INCLUDE_RTCP ] */
#include "os/OsEvent.h"
#include "os/OsMutex.h"
+#include "os/OsSysLog.h"
// EXTERNAL FUNCTIONS
// EXTERNAL VARIABLES
@@ -343,6 +344,9 @@
if (SSRC_SWITCH_MISMATCH_COUNT <= mNumNonPrefPackets) {
setPrefSsrc(mRtpDestMatchIpOnlySsrcValid ?
mRtpDestMatchIpOnlySsrc : mRtpOtherSsrc);
+ // SSRC change is committed and the RTP decoder needs to
be reset
+ OsSysLog::add(FAC_MP, PRI_DEBUG,
"MprFromNet::pushPacket(%d) SSRC has changed to %d mNumNonPrefPackets=%d",
rtpBuf->getRtpSequenceNumber(), thisSsrc, mNumNonPrefPackets);
+ getMyDecoder()->reset();
}
}
return ret;
_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/