[Opalvoip-svn] SF.net SVN: opalvoip: [18728] opal/branches/csoutheren/devel
Brought to you by:
csoutheren,
rjongbloed
From: <cso...@us...> - 2007-10-22 12:18:43
|
Revision: 18728 http://opalvoip.svn.sourceforge.net/opalvoip/?rev=18728&view=rev Author: csoutheren Date: 2007-10-22 05:18:47 -0700 (Mon, 22 Oct 2007) Log Message: ----------- Applied OpenH323 1799686 - Fix RTP Aggregation handling in Jitter Buffer Thanks to Simon Zwahlen Modified Paths: -------------- opal/branches/csoutheren/devel/include/rtp/jitter.h opal/branches/csoutheren/devel/src/rtp/jitter.cxx Modified: opal/branches/csoutheren/devel/include/rtp/jitter.h =================================================================== --- opal/branches/csoutheren/devel/include/rtp/jitter.h 2007-10-22 12:16:41 UTC (rev 18727) +++ opal/branches/csoutheren/devel/include/rtp/jitter.h 2007-10-22 12:18:47 UTC (rev 18728) @@ -136,9 +136,6 @@ PCLASSINFO(OpalJitterBuffer, PObject); public: -#if OPAL_RTP_AGGREGATE - friend class RTP_AggregatedHandle; -#endif /**Constructor for this jitter buffer. The size of this buffer can be altered later with the SetDelay method */ OpalJitterBuffer( @@ -149,7 +146,7 @@ ); /**Destructor, which closes this down and deletes the internal list of frames */ - ~OpalJitterBuffer(); + virtual ~OpalJitterBuffer(); /**Report the statistics for this jitter instance */ void PrintOn(ostream & strm ) const; @@ -210,7 +207,7 @@ /**Start jitter thread */ - void Resume(PHandleAggregator * aggregator = NULL); + virtual void Resume(PHandleAggregator * aggregator = NULL); PDECLARE_NOTIFIER(PThread, OpalJitterBuffer, JitterThreadMain); @@ -262,8 +259,6 @@ PThread * jitterThread; PINDEX jitterStackSize; - RTP_AggregatedHandle * aggregratedHandle; - BOOL Init(Entry * & currentReadFrame, BOOL & markerWarning); BOOL PreRead(Entry * & currentReadFrame, BOOL & markerWarning); BOOL OnRead(Entry * & currentReadFrame, BOOL & markerWarning, BOOL loop); @@ -278,6 +273,9 @@ PCLASSINFO(RTP_JitterBuffer, OpalJitterBuffer); public: +#if OPAL_RTP_AGGREGATE + friend class RTP_AggregatedHandle; +#endif RTP_JitterBuffer( RTP_Session & session, ///< Associated RTP session tor ead data from unsigned minJitterDelay, ///< Minimum delay in RTP timestamp units @@ -285,8 +283,8 @@ unsigned timeUnits = 8, ///< Time units, usually 8 or 16 PINDEX stackSize = 30000 ///< Stack size for jitter thread ); + virtual ~RTP_JitterBuffer(); - /**This class instance collects data from the outside world in this method. @@ -296,9 +294,14 @@ BOOL loop ///< If TRUE, loop as long as data is available, if FALSE, only process once ) ; + /**Start jitter thread + */ + virtual void Resume(PHandleAggregator * aggregator = NULL); + protected: /**This class extracts data from the outside world by reading from this session variable */ RTP_Session & session; + RTP_AggregatedHandle * aggregatedHandle; }; Modified: opal/branches/csoutheren/devel/src/rtp/jitter.cxx =================================================================== --- opal/branches/csoutheren/devel/src/rtp/jitter.cxx 2007-10-22 12:16:41 UTC (rev 18727) +++ opal/branches/csoutheren/devel/src/rtp/jitter.cxx 2007-10-22 12:18:47 UTC (rev 18728) @@ -385,10 +385,6 @@ #else analyser = NULL; #endif - -#if OPAL_RTP_AGGREGATE - aggregratedHandle = NULL; -#endif } @@ -396,24 +392,13 @@ { shuttingDown = TRUE; -#if OPAL_RTP_AGGREGATE - if (jitterThread == NULL) { - if (aggregatedHandle != NULL) { - aggregratedHandle->Remove(); - delete aggregratedHandle; - aggregratedHandle = NULL; - } - } else -#endif - { - if (jitterThread != NULL) { - PTRACE(3, "RTP\tRemoving jitter buffer " << this << ' ' << jitterThread->GetThreadName()); - PAssert(jitterThread->WaitForTermination(10000), "Jitter buffer thread did not terminate"); - delete jitterThread; - jitterThread = NULL; - } else { - PTRACE(1, "RTP\tJitter buffer thread is null, when the OpalJitterBuffer destructor runs"); - } + if (jitterThread != NULL) { + PTRACE(3, "RTP\tRemoving jitter buffer " << this << ' ' << jitterThread->GetThreadName()); + PAssert(jitterThread->WaitForTermination(10000), "Jitter buffer thread did not terminate"); + delete jitterThread; + jitterThread = NULL; + } else { + PTRACE(1, "RTP\tJitter buffer thread is null, when the OpalJitterBuffer destructor runs"); } bufferMutex.Wait(); @@ -510,21 +495,8 @@ bufferMutex.Signal(); } -void OpalJitterBuffer::Resume(PHandleAggregator * -#if OPAL_RTP_AGGREGATE - aggregator -#endif - ) +void OpalJitterBuffer::Resume(PHandleAggregator * /*aggregator */) { -#if OPAL_RTP_AGGREGATE - // if we are aggregating RTP threads, add the socket to the RTP aggregator - if (aggregator != NULL) { - aggregratedHandle = new RTP_AggregatedHandle(aggregator, *this); - aggregator->AddHandle(aggregratedHandle); - return; - } -#endif - // otherwise create a seperate thread as per the old design jitterThread = PThread::Create(PCREATE_NOTIFIER(JitterThreadMain), 0, PThread::NoAutoDeleteThread, PThread::HighestPriority, "RTP Jitter:%x", jitterStackSize); jitterThread->Resume(); @@ -1019,10 +991,24 @@ PINDEX stackSize) : OpalJitterBuffer(minJitterDelay, maxJitterDelay, time, stackSize), session(sess) +#if OPAL_RTP_AGGREGATE + , aggregatedHandle(NULL) +#endif { PTRACE(6, "RTP_JitterBuffer\tConstructor" << *this); } +RTP_JitterBuffer::~RTP_JitterBuffer() +{ +#if OPAL_RTP_AGGREGATE + if (aggregatedHandle != NULL) { + aggregatedHandle->Remove(); + delete aggregatedHandle; + aggregatedHandle = NULL; + } +#endif +} + BOOL RTP_JitterBuffer::OnReadPacket(RTP_DataFrame & frame, BOOL loop) { @@ -1031,8 +1017,22 @@ return success; } +void RTP_JitterBuffer::Resume(PHandleAggregator * aggregator) +{ +#if OPAL_RTP_AGGREGATE + // if we are aggregating RTP threads, add the socket to the RTP aggregator + if (aggregator != NULL) { + aggregatedHandle = new RTP_AggregatedHandle(aggregator, *this); + aggregator->AddHandle(aggregatedHandle); + return; + } +#endif + OpalJitterBuffer::Resume(aggregator); +} + + ///////////////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |