changeset 23554:046d7b14d7f1

Stop playing at eof or if no data arrives for ten seconds.
author cehoyos
date Mon, 18 Jun 2007 08:53:53 +0000
parents d890d68a92dc
children 2237e232cc15
files libmpdemux/demux_rtp.cpp
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_rtp.cpp	Mon Jun 18 08:02:37 2007 +0000
+++ b/libmpdemux/demux_rtp.cpp	Mon Jun 18 08:53:53 2007 +0000
@@ -448,6 +448,10 @@
   RTPState* rtpState = (RTPState*)(demuxer->priv);
   ReadBufferQueue* bufferQueue = NULL;
   int headersize = 0;
+  TaskToken task;
+
+  if (demuxer->stream->eof) return NULL;
+
   if (ds == demuxer->video) {
     bufferQueue = rtpState->videoBufferQueue;
     if (((sh_video_t*)ds->sh)->format == mmioFOURCC('H','2','6','4'))
@@ -500,7 +504,15 @@
   // Block ourselves until data becomes available:
   TaskScheduler& scheduler
     = bufferQueue->readSource()->envir().taskScheduler();
+  int delay = bufferQueue->prevPacketPTS * 1.05 >
+      rtpState->mediaSession->playEndTime() ? 1000000 : 10000000;
+  task = scheduler.scheduleDelayedTask(delay, onSourceClosure, bufferQueue);
   scheduler.doEventLoop(&bufferQueue->blockingFlag);
+  scheduler.unscheduleDelayedTask(task);
+  if (demuxer->stream->eof) {
+    free_demux_packet(dp);
+    return NULL;
+  }
 
   if (headersize == 1) // amr
     dp->buffer[0] =