[vlc-devel] [PATCH 21/21] access/live555: do not depend on demux_t::s during initialization

Filip Roséen filip at atch.se
Sun Jul 31 22:42:30 CEST 2016


Given that modules with "demux" and "demux_access" now always have an
associated source stream, this module shall not depend on the value of
demux_t::s during initialization.

Instead this patch introduces two different entry points, one for each
type of demuxer, and adds an argument to the original callback to
conditionally enable functionality associated with one, but no the
other.
---
 modules/access/live555.cpp | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/modules/access/live555.cpp b/modules/access/live555.cpp
index 12c505a..6906a12 100644
--- a/modules/access/live555.cpp
+++ b/modules/access/live555.cpp
@@ -67,7 +67,15 @@ extern "C" {
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-static int  Open ( vlc_object_t * );
+
+typedef enum {
+    DEMUX_TYPE_REGULAR,
+    DEMUX_TYPE_ACCESS
+} demux_type_e;
+
+static int OpenDemux( vlc_object_t* );
+static int OpenAccessDemux( vlc_object_t* );
+static int Open( vlc_object_t *, demux_type_e );
 static void Close( vlc_object_t * );
 
 #define KASENNA_TEXT N_( "Kasenna RTSP dialect")
@@ -96,7 +104,7 @@ vlc_module_begin ()
     set_description( N_("RTP/RTSP/SDP demuxer (using Live555)" ) )
     set_capability( "demux", 50 )
     set_shortname( "RTP/RTSP")
-    set_callbacks( Open, Close )
+    set_callbacks( OpenDemux, Close )
     add_shortcut( "live", "livedotcom" )
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_DEMUX )
@@ -105,7 +113,7 @@ vlc_module_begin ()
         set_description( N_("RTSP/RTP access and demux") )
         add_shortcut( "rtsp", "pnm", "live", "livedotcom" )
         set_capability( "access_demux", 0 )
-        set_callbacks( Open, Close )
+        set_callbacks( OpenAccessDemux, Close )
         add_bool( "rtsp-tcp", false,
                   N_("Use RTP over RTSP (TCP)"),
                   N_("Use RTP over RTSP (TCP)"), true )
@@ -145,7 +153,6 @@ vlc_module_end ()
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-
 typedef struct
 {
     demux_t         *p_demux;
@@ -272,10 +279,20 @@ static unsigned char* parseH264ConfigStr( char const* configStr,
 static unsigned char* parseVorbisConfigStr( char const* configStr,
                                             unsigned int& configSize );
 
+static int OpenDemux( vlc_object_t *p_this )
+{
+    return Open( p_this, DEMUX_TYPE_REGULAR );
+}
+
+static int OpenAccessDemux( vlc_object_t *p_this )
+{
+    return Open( p_this, DEMUX_TYPE_REGULAR );
+}
+
 /*****************************************************************************
- * DemuxOpen:
+ * Open
  *****************************************************************************/
-static int  Open ( vlc_object_t *p_this )
+static int Open ( vlc_object_t *p_this, demux_type_e e_type )
 {
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys = NULL;
@@ -283,7 +300,7 @@ static int  Open ( vlc_object_t *p_this )
     int i_return;
     int i_error = VLC_EGENERIC;
 
-    if( p_demux->s )
+    if( e_type == DEMUX_TYPE_REGULAR )
     {
         /* See if it looks like a SDP
            v, o, s fields are mandatory and in this order */
@@ -337,7 +354,7 @@ static int  Open ( vlc_object_t *p_this )
         while( (p = strchr( p, ' ' )) != NULL ) *p = '+';
     }
 
-    if( p_demux->s != NULL )
+    if( e_type == DEMUX_TYPE_ACCESS )
     {
         /* Gather the complete sdp file */
         int     i_sdp       = 0;
-- 
2.9.2



More information about the vlc-devel mailing list