[Live-devel] pause issue

Gilles Chanteperdrix gilles.chanteperdrix at xenomai.org
Mon Feb 23 22:27:09 PST 2015


On Mon, Feb 23, 2015 at 11:03:24AM +0100, Gilles Chanteperdrix wrote:
> Another source of bad RTP timestamps (but which does not seem to
> cause any issue in live555) is when MultiFramedRTPSink starts
> sending packets immediately with (a correct presentation time or
> not) as a consequence of StreamState::startPlaying before
> RTPSInk::presetNextTimestamp has been called in the following
> sequence of OnDemandServerMediaSubsession.cpp:
> 
> 
>   if (streamState != NULL) {
>     streamState->startPlaying(destinations,
> 			      rtcpRRHandler, rtcpRRHandlerClientData,
> 			      serverRequestAlternativeByteHandler, serverRequestAlternativeByteHandlerClientData);
>     RTPSink* rtpSink = streamState->rtpSink(); // alias
>     if (rtpSink != NULL) {
>       rtpSeqNum = rtpSink->currentSeqNo();
>       rtpTimestamp = rtpSink->presetNextTimestamp();
>     }
>   }

The following patch avoids this issue:

diff --git a/liveMedia/MultiFramedRTPSink.cpp b/liveMedia/MultiFramedRTPSink.cpp
index 4e36719..162e1be 100644
--- a/liveMedia/MultiFramedRTPSink.cpp
+++ b/liveMedia/MultiFramedRTPSink.cpp
@@ -151,7 +151,7 @@ void MultiFramedRTPSink::setFramePadding(unsigned numPaddingBytes) {
 Boolean MultiFramedRTPSink::continuePlaying() {
   // Send the first packet.
   // (This will also schedule any future sends.)
-  buildAndSendPacket(True);
+  nextTask() = envir().taskScheduler().scheduleDelayedTask(0, (TaskFunc*)sendFirst, this);
   return True;
 }
 
@@ -442,6 +442,11 @@ void MultiFramedRTPSink::sendNext(void* firstArg) {
   sink->buildAndSendPacket(False);
 }
 
+void MultiFramedRTPSink::sendFirst(void* firstArg) {
+  MultiFramedRTPSink* sink = (MultiFramedRTPSink*)firstArg;
+  sink->buildAndSendPacket(True);
+}
+
 void MultiFramedRTPSink::ourHandleClosure(void* clientData) {
   MultiFramedRTPSink* sink = (MultiFramedRTPSink*)clientData;
   // There are no frames left, but we may have a partially built packet
diff --git a/liveMedia/include/MultiFramedRTPSink.hh b/liveMedia/include/MultiFramedRTPSink.hh
index 61a9c34..4e0fb0a 100644
--- a/liveMedia/include/MultiFramedRTPSink.hh
+++ b/liveMedia/include/MultiFramedRTPSink.hh
@@ -103,6 +103,8 @@ private:
   void sendPacketIfNecessary();
   static void sendNext(void* firstArg);
   friend void sendNext(void*);
+  static void sendFirst(void* firstArg);
+  friend void sendFirst(void*);
 
   static void afterGettingFrame(void* clientData,
                                unsigned numBytesRead, unsigned numTruncatedBytes,


-- 
					    Gilles.


More information about the live-devel mailing list