Commit 8f6ff46b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

demux: provide full URL instead of access name (refs #18504)

parent afe9ede8
......@@ -48,9 +48,9 @@ struct demux_t
module_t *p_module;
/* eg informative but needed (we can have access+demux) */
char *psz_access;
char *psz_demux;
char *psz_location;
char *psz_url;
const char *psz_location;
char *psz_filepath;
union {
......
......@@ -188,8 +188,8 @@ enum vlc_module_properties
/**
* Current plugin ABI version
*/
# define MODULE_SYMBOL 3_0_0f
# define MODULE_SUFFIX "__3_0_0f"
# define MODULE_SYMBOL 4_0_0
# define MODULE_SUFFIX "__4_0_0"
/*****************************************************************************
* Add a few defines. You do not want to read this section. Really.
......
......@@ -630,10 +630,10 @@ static int blurayOpen(vlc_object_t *object)
if (unlikely(!p_demux->p_input))
return VLC_EGENERIC;
forced = !strcasecmp(p_demux->psz_access, "bluray");
forced = !strncasecmp(p_demux->psz_url, "bluray:", 7);
if (p_demux->s) {
if (!strcasecmp(p_demux->psz_access, "file")) {
if (!strncasecmp(p_demux->psz_url, "file:", 5)) {
/* use access_demux for local files */
return VLC_EGENERIC;
}
......
......@@ -344,7 +344,7 @@ static int AccessDemuxOpen ( vlc_object_t *p_this )
int i_ret = VLC_EGENERIC;
bool forced = false;
if( !strncmp(p_demux->psz_access, "dvd", 3) )
if( !strncasecmp(p_demux->psz_url, "dvd", 3) )
forced = true;
if( !p_demux->psz_filepath || !*p_demux->psz_filepath )
......
......@@ -141,7 +141,7 @@ static int ControlPause( demux_t *demux, int query, va_list args )
static int OpenDemux( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t*)p_this;
char * psz_name = p_demux->psz_location;
const char *psz_name = p_demux->psz_location;
p_demux->p_sys = NULL;
......
......@@ -297,7 +297,6 @@ static int Open ( vlc_object_t *p_this )
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = NULL;
char *psz_url;
int i_return;
int i_error = VLC_EGENERIC;
......@@ -359,13 +358,7 @@ static int Open ( vlc_object_t *p_this )
vlc_mutex_init(&p_sys->timeout_mutex);
/* parse URL for rtsp://[user:[passwd]@]serverip:port/options */
if( asprintf( &psz_url, "%s://%s", p_demux->psz_access, p_demux->psz_location ) == -1 )
{
i_error = VLC_ENOMEM;
goto error;
}
vlc_UrlParse( &p_sys->url, psz_url );
free( psz_url );
vlc_UrlParse( &p_sys->url, p_demux->psz_url );
if( ( p_sys->psz_pl_url = passwordLessURL( &p_sys->url ) ) == NULL )
{
......
......@@ -492,11 +492,6 @@ static void stream_decode (demux_t *demux, void *data, block_t *block)
(void)demux;
}
static void *demux_init (demux_t *demux)
{
return stream_init (demux, demux->psz_demux);
}
/*
* Static payload types handler
*/
......
......@@ -853,7 +853,7 @@ static int DemuxInit( demux_t *p_demux )
ASF_fillup_es_bitrate_priorities_ex( p_sys, p_hdr_ext, &fmt_priorities_bitrate_ex );
}
const bool b_mms = !strncmp( p_demux->psz_access, "mms", 3 );
const bool b_mms = !strncasecmp( p_demux->psz_url, "mms:", 4 );
bool b_dvrms = false;
if( b_mms )
......
......@@ -156,7 +156,7 @@ int avformat_OpenDemux( vlc_object_t *p_this )
AVInputFormat *fmt = NULL;
int64_t i_start_time = -1;
bool b_can_seek;
char *psz_url;
const char *psz_url;
const uint8_t *peek;
int error;
......@@ -176,13 +176,9 @@ int avformat_OpenDemux( vlc_object_t *p_this )
memset( pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE );
if( p_demux->psz_filepath )
psz_url = strdup( p_demux->psz_filepath );
psz_url = p_demux->psz_filepath;
else
{
if( asprintf( &psz_url, "%s://%s", p_demux->psz_access,
p_demux->psz_location ) == -1)
psz_url = NULL;
}
psz_url = p_demux->psz_url;
if( psz_url != NULL )
msg_Dbg( p_demux, "trying url: %s", psz_url );
......@@ -210,7 +206,6 @@ int avformat_OpenDemux( vlc_object_t *p_this )
if( fmt == NULL )
{
msg_Dbg( p_demux, "couldn't guess format" );
free( psz_url );
return VLC_EGENERIC;
}
......@@ -231,10 +226,7 @@ int avformat_OpenDemux( vlc_object_t *p_this )
for( int i = 0; *ppsz_blacklist[i]; i++ )
{
if( !strcmp( fmt->name, ppsz_blacklist[i] ) )
{
free( psz_url );
return VLC_EGENERIC;
}
}
}
......@@ -244,23 +236,16 @@ int avformat_OpenDemux( vlc_object_t *p_this )
int i_len;
if( !p_demux->psz_filepath )
{
free( psz_url );
return VLC_EGENERIC;
}
i_len = strlen( p_demux->psz_filepath );
if( i_len < 4 )
{
free( psz_url );
return VLC_EGENERIC;
}
if( strcasecmp( &p_demux->psz_filepath[i_len - 4], ".str" ) &&
strcasecmp( &p_demux->psz_filepath[i_len - 4], ".xai" ) &&
strcasecmp( &p_demux->psz_filepath[i_len - 3], ".xa" ) )
{
free( psz_url );
return VLC_EGENERIC;
}
}
......@@ -272,10 +257,8 @@ int avformat_OpenDemux( vlc_object_t *p_this )
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
if( !p_sys )
{
free( psz_url );
return VLC_ENOMEM;
}
p_sys->ic = 0;
p_sys->fmt = fmt;
p_sys->tracks = NULL;
......@@ -287,7 +270,6 @@ int avformat_OpenDemux( vlc_object_t *p_this )
unsigned char * p_io_buffer = av_malloc( AVFORMAT_IOBUFFER_SIZE );
if( !p_io_buffer )
{
free( psz_url );
avformat_CloseDemux( p_this );
return VLC_ENOMEM;
}
......@@ -296,7 +278,6 @@ int avformat_OpenDemux( vlc_object_t *p_this )
if( !p_sys->ic )
{
av_free( p_io_buffer );
free( psz_url );
avformat_CloseDemux( p_this );
return VLC_ENOMEM;
}
......@@ -306,7 +287,6 @@ int avformat_OpenDemux( vlc_object_t *p_this )
if( !pb )
{
av_free( p_io_buffer );
free( psz_url );
avformat_CloseDemux( p_this );
return VLC_ENOMEM;
}
......@@ -321,11 +301,9 @@ int avformat_OpenDemux( vlc_object_t *p_this )
av_free( pb->buffer );
av_free( pb );
p_sys->ic = NULL;
free( psz_url );
avformat_CloseDemux( p_this );
return VLC_EGENERIC;
}
free( psz_url );
char *psz_opts = var_InheritString( p_demux, "avformat-options" );
unsigned nb_streams = p_sys->ic->nb_streams;
......
......@@ -101,9 +101,7 @@ bool DASHManager::updatePlaylist()
/* do update */
if(nextPlaylistupdate)
{
std::string url(p_demux->psz_access);
url.append("://");
url.append(p_demux->psz_location);
std::string url(p_demux->psz_url);
block_t *p_block = Retrieve::HTTP(VLC_OBJECT(p_demux), authStorage, url);
if(!p_block)
......
......@@ -157,7 +157,7 @@ static int Open( vlc_object_t * p_this )
{
msg_Dbg( p_demux, "Preloading local dir" );
/* get the files from the same dir from the same family (based on p_demux->psz_path) */
if ( p_demux->psz_filepath && !strcmp( p_demux->psz_access, "file" ) )
if ( p_demux->psz_filepath && !strncasecmp( p_demux->psz_url, "file:", 5 ) )
{
// assume it's a regular file
// get the directory path
......
......@@ -803,17 +803,8 @@ static int Open( vlc_object_t * p_this )
}
else
{
char *psz_url;
if( asprintf( &psz_url, "%s://%s", p_demux->psz_access,
p_demux->psz_location ) < 0 )
{
free( psz_ref );
input_item_node_Delete( p_subitems );
return VLC_ENOMEM;
}
char *psz_absolute = vlc_uri_resolve( psz_url, psz_ref );
free( psz_url );
char *psz_absolute = vlc_uri_resolve( p_demux->psz_url,
psz_ref );
free( psz_ref );
if( psz_absolute == NULL )
{
......
......@@ -501,8 +501,8 @@ static int Open( vlc_object_t *p_this )
}
if( p_sys->standard == TS_STANDARD_AUTO &&
( !strcmp( p_demux->psz_access, "atsc" ) ||
!strcmp( p_demux->psz_access, "usdigital" ) ) )
( !strncasecmp( p_demux->psz_url, "atsc", 4 ) ||
!strncasecmp( p_demux->psz_url, "usdigital", 9 ) ) )
{
TsChangeStandard( p_sys, TS_STANDARD_ATSC );
}
......
......@@ -54,9 +54,7 @@ SmoothManager::~SmoothManager()
Manifest * SmoothManager::fetchManifest()
{
std::string playlisturl(p_demux->psz_access);
playlisturl.append("://");
playlisturl.append(p_demux->psz_location);
std::string playlisturl(p_demux->psz_url);
block_t *p_block = Retrieve::HTTP(VLC_OBJECT(p_demux), authStorage, playlisturl);
if(!p_block)
......
......@@ -179,7 +179,8 @@ static int Open ( vlc_object_t *p_this )
}
}
if( asprintf( &psz_vobname, "%s://%s", p_demux->psz_access, p_demux->psz_location ) == -1 )
psz_vobname = strdup( p_demux->psz_url );
if( psz_vobname == NULL )
goto error;
i_len = strlen( psz_vobname );
......
......@@ -217,21 +217,23 @@ demux_t *demux_NewAdvanced( vlc_object_t *p_obj, input_thread_t *p_parent_input,
}
}
size_t schemelen = strlen(psz_access);
p_demux->p_input = p_parent_input;
p_demux->psz_access = strdup( psz_access );
p_demux->psz_demux = strdup( psz_demux );
p_demux->psz_location = strdup( psz_location );
p_demux->psz_filepath = get_path( psz_location ); /* parse URL */
if (unlikely(p_demux->psz_demux == NULL))
goto error;
if( unlikely(p_demux->psz_access == NULL
|| p_demux->psz_demux == NULL
|| p_demux->psz_location == NULL) )
if (unlikely(asprintf(&p_demux->psz_url, "%s://%s", psz_access,
psz_location) == -1))
goto error;
p_demux->psz_location = p_demux->psz_url + schemelen + 3;
p_demux->psz_filepath = get_path( psz_location ); /* parse URL */
if( !b_preparsing )
msg_Dbg( p_obj, "creating demux: access='%s' demux='%s' "
"location='%s' file='%s'",
p_demux->psz_access, p_demux->psz_demux,
"location='%s' file='%s'", psz_access, p_demux->psz_demux,
p_demux->psz_location, p_demux->psz_filepath );
p_demux->s = s;
......@@ -267,18 +269,19 @@ demux_t *demux_NewAdvanced( vlc_object_t *p_obj, input_thread_t *p_parent_input,
else
{
p_demux->p_module =
module_need( p_demux, "access_demux", p_demux->psz_access, true );
module_need( p_demux, "access_demux", psz_access, true );
}
if( p_demux->p_module == NULL )
{
free( p_demux->psz_filepath );
free( p_demux->psz_url );
goto error;
}
return p_demux;
error:
free( p_demux->psz_filepath );
free( p_demux->psz_location );
free( p_demux->psz_demux );
free( p_demux->psz_access );
vlc_object_release( p_demux );
return NULL;
}
......@@ -294,9 +297,8 @@ void demux_Delete( demux_t *p_demux )
priv->destroy(p_demux);
free( p_demux->psz_filepath );
free( p_demux->psz_location );
free( p_demux->psz_url );
free( p_demux->psz_demux );
free( p_demux->psz_access );
vlc_object_release( p_demux );
}
......@@ -585,8 +587,8 @@ static demux_t *demux_FilterNew( demux_t *p_next, const char *p_name )
p_demux->p_next = p_next;
p_demux->p_input = NULL;
p_demux->p_sys = NULL;
p_demux->psz_access = NULL;
p_demux->psz_demux = NULL;
p_demux->psz_url = NULL;
p_demux->psz_location = NULL;
p_demux->psz_filepath = NULL;
p_demux->out = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment