[vlc-devel] [PATCH 3/6] playlists: m3u: Handle satip MRL
Felix Paul Kühne
fkuehne at videolan.org
Wed Jul 20 17:25:19 CEST 2016
From: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
---
modules/demux/playlist/m3u.c | 60 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/modules/demux/playlist/m3u.c b/modules/demux/playlist/m3u.c
index e6b2a58..aa163ac 100644
--- a/modules/demux/playlist/m3u.c
+++ b/modules/demux/playlist/m3u.c
@@ -40,6 +40,8 @@ struct demux_sys_t
{
char *psz_prefix;
char *(*pf_dup) (const char *);
+ // Potential satip server parameter, from the playlist MRL
+ char *psz_satip_device;
};
/*****************************************************************************
@@ -68,6 +70,7 @@ int Import_M3U( vlc_object_t *p_this )
const uint8_t *p_peek;
char *(*pf_dup) (const char *) = GuessEncoding;
int offset = 0;
+ const char* psz_server_param = NULL;
CHECK_FILE();
if( stream_Peek( p_demux->s, &p_peek, 3 ) == 3
@@ -107,6 +110,32 @@ int Import_M3U( vlc_object_t *p_this )
stream_Seek( p_demux->s, offset );
STANDARD_DEMUX_INIT_MSG( "found valid M3U playlist" );
+
+ // Handle a potential satip-device extra parameter for playlist we fetch over http
+ if ( !strncasecmp( p_demux->psz_access, "http", 4 ) )
+ {
+ psz_server_param = strstr( p_demux->psz_location, "?satip-device=" );
+ if( psz_server_param )
+ {
+ char* psz_end_param;
+ p_demux->p_sys->psz_satip_device = strdup( psz_server_param + strlen( "?satip-device=" ) );
+ if ( p_demux->p_sys->psz_satip_device == NULL )
+ {
+ free( p_demux->p_sys );
+ return VLC_ENOMEM;
+ }
+ psz_end_param = strchr( p_demux->p_sys->psz_satip_device, '&' );
+ if( psz_end_param )
+ *psz_end_param = 0;
+ else
+ {
+ psz_end_param = strchr( p_demux->p_sys->psz_satip_device, '?' );
+ if( psz_end_param )
+ *psz_end_param = 0;
+ }
+ }
+ }
+
p_demux->p_sys->psz_prefix = FindPrefix( p_demux );
p_demux->p_sys->pf_dup = pf_dup;
@@ -156,6 +185,7 @@ void Close_M3U( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
free( p_demux->p_sys->psz_prefix );
+ free( p_demux->p_sys->psz_satip_device );
free( p_demux->p_sys );
}
@@ -254,6 +284,36 @@ static int Demux( demux_t *p_demux )
free( psz_parse );
goto error;
}
+ if( p_demux->p_sys->psz_satip_device )
+ {
+ // Substitute "sat.ip" with an IP that was fetched during device discovery
+ const char* psz_sat_ip = strstr( psz_mrl, "sat.ip" );
+ if( psz_sat_ip )
+ {
+ char* psz_new_mrl;
+ if( asprintf( &psz_new_mrl, "%.*s%s%s", (int)(psz_sat_ip - psz_mrl), psz_mrl,
+ p_demux->p_sys->psz_satip_device, psz_sat_ip + strlen( "sat.ip" ) ) < 0 )
+ {
+ free( psz_mrl );
+ free( psz_parse );
+ goto error;
+ }
+ free( psz_mrl );
+ psz_mrl = psz_new_mrl;
+ }
+ if( !strncasecmp( psz_mrl, "rtsp://", 7 ) )
+ {
+ char* psz_new_mrl;
+ if( asprintf( &psz_new_mrl, "satip://%s", psz_mrl + 7 ) < 0 )
+ {
+ free( psz_mrl );
+ free( psz_parse );
+ goto error;
+ }
+ free( psz_mrl );
+ psz_mrl = psz_new_mrl;
+ }
+ }
p_input = input_item_NewExt( psz_mrl, psz_name, i_duration,
ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN );
--
2.9.2
More information about the vlc-devel
mailing list