changeset 37106:1b9907dfe2f4

demux_real: always select a stream to play if available. Nowadays this should not hurt, MPlayer should be able to able if a stream is selected that never has any data, and it allows us to play the stream if some data actually appears later at some point.
author reimar
date Tue, 13 May 2014 21:06:40 +0000
parents f05b151463ca
children 3c5c93a30fb7
files libmpdemux/demux_real.c
diffstat 1 files changed, 27 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_real.c	Tue May 13 21:06:39 2014 +0000
+++ b/libmpdemux/demux_real.c	Tue May 13 21:06:40 2014 +0000
@@ -1832,9 +1832,7 @@
     // detect streams:
     if(demuxer->video->id==-1 && v_streams>0){
 	// find the valid video stream:
-	if(!ds_fill_buffer(demuxer->video)){
-          mp_msg(MSGT_DEMUXER,MSGL_INFO,"RM: " MSGTR_MissingVideoStream);
-	}
+	ds_fill_buffer(demuxer->video);
     }
     if(demuxer->audio->id==-1 && a_streams>0){
 	// find the valid audio stream:
@@ -1842,6 +1840,32 @@
           mp_msg(MSGT_DEMUXER,MSGL_INFO,"RM: " MSGTR_MissingAudioStream);
 	}
     }
+    if(demuxer->video->id==-1 && v_streams>0){
+	// try video once more in case there were too many audio packets first.
+	demuxer->video->eof = 0;
+	demuxer->video->fill_count = 0;
+	if(!ds_fill_buffer(demuxer->video)){
+          mp_msg(MSGT_DEMUXER,MSGL_INFO,"RM: " MSGTR_MissingVideoStream);
+	}
+    }
+    if(demuxer->video->id==-1 && v_streams>0){
+        // worst case just select the first
+        int i;
+        for (i = 0; i < MAX_V_STREAMS; i++)
+            if (demuxer->v_streams[i]) {
+                demuxer->video->id = i;
+                demuxer->video->sh = demuxer->v_streams[i];
+            }
+    }
+    if(demuxer->audio->id==-1 && a_streams>0){
+        // worst case just select the first
+        int i;
+        for (i = 0; i < MAX_A_STREAMS; i++)
+            if (demuxer->a_streams[i]) {
+                demuxer->audio->id = i;
+                demuxer->audio->sh = demuxer->a_streams[i];
+            }
+    }
 
     if(demuxer->video->sh){
 	sh_video_t *sh=demuxer->video->sh;