]> git.sesse.net Git - vlc/commitdiff
avformat mux: Propagate seekable status into avformat.
authorSteinar H. Gunderson <steinar+vlc@gunderson.no>
Fri, 16 Aug 2013 14:42:11 +0000 (16:42 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 25 Aug 2013 10:10:41 +0000 (13:10 +0300)
Some muxes, in particular mkv/webm, behave very differently depending on
whether we say that the stream is seekable or not (by providing the IOSeek
function). It does not help that the seek function itself returns an error.

Thus, add a new access_out control called ACCESS_OUT_CAN_SEEK, set to true
for seekable files in the file output only, and propagate the status of that
into avformat at initialization time.

Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
modules/access_output/file.c
modules/demux/avformat/mux.c

index 8bc2b6ffdc4778fa240e28a44489f3f8e1c8934e..61192c22e827b38ffcfda929c2fbe669eede329e 100644 (file)
@@ -34,6 +34,9 @@
 #include <time.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
@@ -243,6 +246,17 @@ static int Control( sout_access_out_t *p_access, int i_query, va_list args )
             break;
         }
 
+        case ACCESS_OUT_CAN_SEEK:
+        {
+            bool *pb = va_arg( args, bool * );
+            struct stat st;
+            if( fstat( (intptr_t)p_access->p_sys, &st ) == -1 )
+                *pb = false;
+            else
+                *pb = S_ISREG( st.st_mode ) || S_ISBLK( st.st_mode );
+            break;
+        }
+
         default:
             return VLC_EGENERIC;
     }
index 97f5fb37d87075cb0c925534d4ea6a806c3711f3..990489cc13717f628c246858e5757d8bf8641365 100644 (file)
@@ -118,9 +118,12 @@ int OpenMux( vlc_object_t *p_this )
     p_sys->io_buffer_size = 32768;  /* FIXME */
     p_sys->io_buffer = malloc( p_sys->io_buffer_size );
 
+    bool b_can_seek;
+    if( sout_AccessOutControl( p_mux->p_access, ACCESS_OUT_CAN_SEEK, &b_can_seek ) )
+        b_can_seek = false;
     p_sys->io = avio_alloc_context(
         p_sys->io_buffer, p_sys->io_buffer_size,
-        1, p_mux, NULL, IOWrite, IOSeek );
+        1, p_mux, NULL, IOWrite, b_can_seek ? IOSeek : NULL );
 
     p_sys->oc->pb = p_sys->io;
     p_sys->oc->nb_streams = 0;