changeset 33705:db1b1a1ecba8

Add a hack to receive audio while probing video FPS. Otherwise newer live555 versions would just hang. Fixes bug #1874.
author reimar
date Fri, 01 Jul 2011 20:54:57 +0000
parents 22093568b553
children 489f118781b7
files libmpdemux/demux_rtp.cpp
diffstat 1 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_rtp.cpp	Fri Jul 01 19:08:13 2011 +0000
+++ b/libmpdemux/demux_rtp.cpp	Fri Jul 01 20:54:57 2011 +0000
@@ -496,11 +496,32 @@
   RTPState* rtpState = (RTPState*)(demuxer->priv);
   ReadBufferQueue* bufferQueue = NULL;
   int headersize = 0;
-  TaskToken task;
+  int waitboth = 0;
+  TaskToken task, task2;
 
   if (demuxer->stream->eof) return NULL;
 
   if (ds == demuxer->video) {
+    bufferQueue = rtpState->audioBufferQueue;
+    // HACK: for the latest versions we must also receive audio
+    // when probing for video FPS, otherwise the stream just hangs
+    // and times out
+    if (mustGetNewData &&
+        bufferQueue &&
+        bufferQueue->readSource() &&
+        !bufferQueue->nextpacket) {
+      headersize = bufferQueue->readSource()->isAMRAudioSource() ? 1 : 0;
+      demux_packet_t *dp = new_demux_packet(MAX_RTP_FRAME_SIZE);
+      bufferQueue->dp = dp;
+      bufferQueue->blockingFlag = 0;
+      bufferQueue->readSource()->getNextFrame(
+          &dp->buffer[headersize], MAX_RTP_FRAME_SIZE - headersize,
+          afterReading, bufferQueue,
+          onSourceClosure, bufferQueue);
+      task2 = bufferQueue->readSource()->envir().taskScheduler().
+        scheduleDelayedTask(10000000, onSourceClosure, bufferQueue);
+      waitboth = 1;
+    }
     bufferQueue = rtpState->videoBufferQueue;
     if (((sh_video_t*)ds->sh)->format == mmioFOURCC('H','2','6','4'))
       headersize = 3;
@@ -558,6 +579,10 @@
   task = scheduler.scheduleDelayedTask(delay, onSourceClosure, bufferQueue);
   scheduler.doEventLoop(&bufferQueue->blockingFlag);
   scheduler.unscheduleDelayedTask(task);
+  if (waitboth) {
+    scheduler.doEventLoop(&rtpState->audioBufferQueue->blockingFlag);
+    scheduler.unscheduleDelayedTask(task2);
+  }
   if (demuxer->stream->eof) {
     free_demux_packet(dp);
     return NULL;