[vlc-devel] [PATCH 1/4] avformat mux: Propagate seekable status into avformat.
Steinar H. Gunderson
steinar+vlc at gunderson.no
Sun Aug 18 19:36:37 CEST 2013
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.
---
include/vlc_sout.h | 1 +
modules/access_output/file.c | 7 +++++++
modules/demux/avformat/mux.c | 5 ++++-
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/include/vlc_sout.h b/include/vlc_sout.h
index 87d8229..e480325 100644
--- a/include/vlc_sout.h
+++ b/include/vlc_sout.h
@@ -81,6 +81,7 @@ struct sout_access_out_t
enum access_out_query_e
{
ACCESS_OUT_CONTROLS_PACE, /* arg1=bool *, can fail (assume true) */
+ ACCESS_OUT_CAN_SEEK, /* arg1=bool *, can fail (assume true) */
};
VLC_API sout_access_out_t * sout_AccessOutNew( vlc_object_t *, const char *psz_access, const char *psz_name ) VLC_USED;
diff --git a/modules/access_output/file.c b/modules/access_output/file.c
index 8bc2b6f..8bf0d05 100644
--- a/modules/access_output/file.c
+++ b/modules/access_output/file.c
@@ -243,6 +243,13 @@ 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 * );
+ *pb = ( lseek( (intptr_t)p_access->p_sys, 0, SEEK_CUR ) != -1 );
+ break;
+ }
+
default:
return VLC_EGENERIC;
}
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 97f5fb3..990489c 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -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;
--
1.7.10.4
More information about the vlc-devel
mailing list