[vlc-devel] [V3 4/5] demux: support force select a module with demux_PacketizerNew

Zhao Zhili quinkblack at foxmail.com
Fri Jun 1 17:20:18 CEST 2018


Most use cases of demux_PacketizerNew need force select a packetizer. If
the select is not strict, it may fallback to another one (e.g. copy)
which doesn't work.
---
 include/vlc_demux.h                    | 3 ++-
 modules/demux/flac.c                   | 2 +-
 modules/demux/mkv/matroska_segment.cpp | 2 +-
 modules/demux/mpeg/es.c                | 2 +-
 modules/demux/mpeg/h26x.c              | 3 ++-
 modules/demux/mpeg/mpgv.c              | 2 +-
 modules/demux/vc1.c                    | 2 +-
 src/input/demux.c                      | 8 +++++---
 8 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/include/vlc_demux.h b/include/vlc_demux.h
index 3888ac57ce..4eed22fd9b 100644
--- a/include/vlc_demux.h
+++ b/include/vlc_demux.h
@@ -372,7 +372,8 @@ static inline bool demux_IsForced( demux_t *p_demux, const char *psz_name )
  * The provided es_format_t will be cleaned on error or by
  * demux_PacketizerDestroy.
  */
-VLC_API decoder_t * demux_PacketizerNew( demux_t *p_demux, es_format_t *p_fmt, const char *psz_msg ) VLC_USED;
+VLC_API decoder_t * demux_PacketizerNew( demux_t *p_demux, es_format_t *p_fmt,
+        const char *name, bool strict ) VLC_USED;
 
 /**
  * This function will destroy a packetizer create by demux_PacketizerNew.
diff --git a/modules/demux/flac.c b/modules/demux/flac.c
index 0373e10403..2b30fe0593 100644
--- a/modules/demux/flac.c
+++ b/modules/demux/flac.c
@@ -161,7 +161,7 @@ static int Open( vlc_object_t * p_this )
         goto error;
 
     /* Load the FLAC packetizer */
-    p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt, "flac" );
+    p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt, "flac", true );
     if( !p_sys->p_packetizer )
         goto error;
 
diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index c469ec7ab4..4bdc500cb7 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -1115,7 +1115,7 @@ bool matroska_segment_c::ESCreate()
             {
                 es_format_t fmt;
                 es_format_Copy( &fmt, &track.fmt );
-                track.p_packetizer = demux_PacketizerNew( &sys.demuxer, &fmt, "RV30/RV40" );
+                track.p_packetizer = demux_PacketizerNew( &sys.demuxer, &fmt, "rv34_parser", true );
             }
         }
 
diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
index 7d2e01ed65..3b26346d28 100644
--- a/modules/demux/mpeg/es.c
+++ b/modules/demux/mpeg/es.c
@@ -240,7 +240,7 @@ static int OpenCommon( demux_t *p_demux,
     /* Load the audio packetizer */
     es_format_Init( &fmt, i_cat, p_sys->codec.i_codec );
     fmt.i_original_fourcc = p_sys->i_original;
-    p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt, p_sys->codec.psz_name );
+    p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt, NULL, false );
     if( !p_sys->p_packetizer )
     {
         free( p_sys );
diff --git a/modules/demux/mpeg/h26x.c b/modules/demux/mpeg/h26x.c
index 6c1c45951c..6acc2f4624 100644
--- a/modules/demux/mpeg/h26x.c
+++ b/modules/demux/mpeg/h26x.c
@@ -356,7 +356,8 @@ static int GenericOpen( demux_t *p_demux, const char *psz_module,
     es_format_Init( &fmt, VIDEO_ES, i_codec );
     fmt.video.i_frame_rate = p_sys->dts.i_divider_num;
     fmt.video.i_frame_rate_base = p_sys->dts.i_divider_den;
-    p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt, psz_module );
+    p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt, psz_module, true );
+
     if( !p_sys->p_packetizer )
     {
         free( p_sys );
diff --git a/modules/demux/mpeg/mpgv.c b/modules/demux/mpeg/mpgv.c
index 3fc7ee724b..8202c3deca 100644
--- a/modules/demux/mpeg/mpgv.c
+++ b/modules/demux/mpeg/mpgv.c
@@ -121,7 +121,7 @@ static int Open( vlc_object_t * p_this )
 
     /* Load the mpegvideo packetizer */
     es_format_Init( &fmt, VIDEO_ES, VLC_CODEC_MPGV );
-    p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt, "mpeg video" );
+    p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt, "mpegvideo", true );
     if( !p_sys->p_packetizer )
     {
         free( p_sys );
diff --git a/modules/demux/vc1.c b/modules/demux/vc1.c
index 08be4ebf38..b0ebc1a8e4 100644
--- a/modules/demux/vc1.c
+++ b/modules/demux/vc1.c
@@ -111,7 +111,7 @@ static int Open( vlc_object_t * p_this )
 
     /* Load the packetizer */
     es_format_Init( &fmt, VIDEO_ES, VLC_CODEC_VC1 );
-    p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt, "VC-1" );
+    p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt, "vc1", true );
     if( !p_sys->p_packetizer )
     {
         free( p_sys );
diff --git a/src/input/demux.c b/src/input/demux.c
index 8d3d33c02e..63907f87b7 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -404,7 +404,8 @@ int demux_vaControlHelper( stream_t *s,
 /****************************************************************************
  * Utility functions
  ****************************************************************************/
-decoder_t *demux_PacketizerNew( demux_t *p_demux, es_format_t *p_fmt, const char *psz_msg )
+decoder_t *demux_PacketizerNew( demux_t *p_demux, es_format_t *p_fmt,
+        const char *name, bool strict )
 {
     decoder_t *p_packetizer;
     p_packetizer = vlc_custom_create( p_demux, sizeof( *p_packetizer ),
@@ -422,12 +423,13 @@ decoder_t *demux_PacketizerNew( demux_t *p_demux, es_format_t *p_fmt, const char
     p_packetizer->fmt_in = *p_fmt;
     es_format_Init( &p_packetizer->fmt_out, p_fmt->i_cat, 0 );
 
-    p_packetizer->p_module = module_need( p_packetizer, "packetizer", NULL, false );
+    p_packetizer->p_module = module_need( p_packetizer, "packetizer", name, strict );
     if( !p_packetizer->p_module )
     {
         es_format_Clean( p_fmt );
         vlc_object_release( p_packetizer );
-        msg_Err( p_demux, "cannot find packetizer for %s", psz_msg );
+        if( name )
+            msg_Err( p_demux, "cannot find packetizer %s", name );
         return NULL;
     }
 
-- 
2.15.1 (Apple Git-101)





More information about the vlc-devel mailing list