[vlc-devel] [RFC PATCH 1/2] vlc_stream: Allow fetching the underlying item type

Hugo Beauzée-Luyssen hugo at beauzee.fr
Thu Sep 10 15:17:58 CEST 2020


---
 include/vlc_demux.h  | 6 ++++++
 include/vlc_stream.h | 1 +
 src/input/input.c    | 8 ++++++++
 3 files changed, 15 insertions(+)

diff --git a/include/vlc_demux.h b/include/vlc_demux.h
index 5d67813fc0..af7f766c1d 100644
--- a/include/vlc_demux.h
+++ b/include/vlc_demux.h
@@ -119,6 +119,12 @@ enum demux_query_e
      * arg1=double *quality, arg2=double *strength */
     DEMUX_GET_SIGNAL = 0x107,
 
+    /** Retrieves the demuxed content type
+     * Can fail if the control is not implemented
+     *
+     * arg1= enum input_item_type_e* */
+    DEMUX_GET_TYPE = 0x109,
+
     /** Sets the paused or playing/resumed state.
      *
      * Streams are initially in playing state. The control always specifies a
diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index bc6c0d30b7..85055a8a35 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -168,6 +168,7 @@ enum stream_query_e
     STREAM_GET_CONTENT_TYPE,    /**< arg1= char **         res=can fail */
     STREAM_GET_SIGNAL,      /**< arg1=double *pf_quality, arg2=double *pf_strength   res=can fail */
     STREAM_GET_TAGS,        /**< arg1=const block_t ** res=can fail */
+    STREAM_GET_TYPE,        /**< arg1=input_item_type_e*    res=can fail */
 
     STREAM_SET_PAUSE_STATE = 0x200, /**< arg1= bool        res=can fail */
     STREAM_SET_TITLE,       /**< arg1= int          res=can fail */
diff --git a/src/input/input.c b/src/input/input.c
index 28de738f8a..c31b1d3060 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -2791,6 +2791,14 @@ static int InputSourceInit( input_source_t *in, input_thread_t *p_input,
     if( demux_Control( in->p_demux, DEMUX_GET_FPS, &in->f_fps ) )
         in->f_fps = 0.f;
 
+    enum input_item_type_e type;
+    if( !demux_Control( in->p_demux, DEMUX_GET_TYPE, &type ) )
+    {
+        vlc_mutex_lock( &input_priv(p_input)->p_item->lock );
+        input_priv(p_input)->p_item->i_type = type;
+        vlc_mutex_unlock( &input_priv(p_input)->p_item->lock );
+    }
+
     if( var_GetInteger( p_input, "clock-synchro" ) != -1 )
         in->b_can_pace_control = !var_GetInteger( p_input, "clock-synchro" );
 
-- 
2.20.1



More information about the vlc-devel mailing list