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

stream: fold psz_access and psz_path into psz_url

parent f5375e68
......@@ -51,9 +51,7 @@ struct stream_t
/* Module properties for stream filter */
module_t *p_module;
char *psz_access;
/* Real or virtual path (it can only be changed during stream_t opening) */
char *psz_path;
char *psz_url;
/* Stream source for stream filter */
stream_t *p_source;
......
......@@ -142,8 +142,8 @@ static input_item_t *Browse(stream_t *p_stream)
{
char *psz_uri = NULL;
char *psz_access_uri = NULL;
int i_ret = asprintf(&psz_access_uri, "%s://%s%c%s", p_stream->psz_access,
p_stream->psz_path, ARCHIVE_SEP_CHAR, archive_entry_pathname(p_entry));
int i_ret = asprintf(&psz_access_uri, "%s%c%s", p_stream->psz_url,
ARCHIVE_SEP_CHAR, archive_entry_pathname(p_entry));
if (i_ret == -1)
return NULL;
i_ret = asprintf(&psz_uri, "archive://%s", psz_access_uri);
......
......@@ -317,12 +317,11 @@ int RarParse(stream_t *s, int *count, rar_file_t ***file, unsigned int *pi_nbvol
*file = NULL;
*pi_nbvols = 1;
const rar_pattern_t *pattern = FindVolumePattern(s->psz_path, b_extonly);
const rar_pattern_t *pattern = FindVolumePattern(s->psz_url, b_extonly);
int volume_offset = 0;
char *volume_mrl;
if (asprintf(&volume_mrl, "%s://%s",
s->psz_access, s->psz_path) < 0)
char *volume_mrl = strdup(s->psz_url);
if (volume_mrl == NULL)
return VLC_EGENERIC;
stream_t *vol = s;
......@@ -374,10 +373,9 @@ int RarParse(stream_t *s, int *count, rar_file_t ***file, unsigned int *pi_nbvol
if (volume_index > pattern->stop)
return VLC_SUCCESS;
char *volume_base;
if (asprintf(&volume_base, "%s://%.*s",
s->psz_access,
(int)(strlen(s->psz_path) - strlen(pattern->match)), s->psz_path) < 0)
char *volume_base = strndup(s->psz_url,
strlen(s->psz_url) - strlen(pattern->match));
if (volume_base == NULL)
return VLC_SUCCESS;
if (pattern->start) {
......
......@@ -104,13 +104,8 @@ int RarStreamOpen(vlc_object_t *object)
* Reusing WriteXSPF from the zip access is probably a good idea
* (becareful about '\' and '/'.
*/
char *mrl;
if (asprintf(&mrl, "%s://%s", s->psz_access, s->psz_path)< 0)
mrl = NULL;
char *base;
char *encoded = mrl ? encode_URI_component(mrl) : NULL;
free(mrl);
char *encoded = encode_URI_component(s->psz_url);
if (!encoded || asprintf(&base, "rar://%s", encoded) < 0)
base = NULL;
free(encoded);
......@@ -150,12 +145,12 @@ int RarStreamOpen(vlc_object_t *object)
sys->payload = payload;
char *tmp;
if (asprintf(&tmp, "%s.m3u", s->psz_path) < 0) {
if (asprintf(&tmp, "%s.m3u", s->psz_url) < 0) {
RarStreamClose(object);
return VLC_ENOMEM;
}
free(s->psz_path);
s->psz_path = tmp;
free(s->psz_url);
s->psz_url = tmp;
return VLC_SUCCESS;
}
......
......@@ -185,10 +185,7 @@ int StreamOpen( vlc_object_t *p_this )
p_sys->fileFunctions = ( zlib_filefunc_def * )
calloc( 1, sizeof( zlib_filefunc_def ) );
if( !p_sys->fileFunctions )
{
free( p_sys );
return VLC_ENOMEM;
}
goto error;
p_sys->fileFunctions->zopen_file = ZipIO_Open;
p_sys->fileFunctions->zread_file = ZipIO_Read;
p_sys->fileFunctions->zwrite_file = ZipIO_Write;
......@@ -202,23 +199,31 @@ int StreamOpen( vlc_object_t *p_this )
{
msg_Warn( s, "unable to open file" );
free( p_sys->fileFunctions );
free( p_sys );
return VLC_EGENERIC;
goto error;
}
/* Find the stream uri */
const char *p = strstr(s->psz_url, "://");
p_sys->psz_path = strdup(p ? p + 3 : "");
char *psz_tmp;
if( asprintf( &psz_tmp, "%s.xspf", s->psz_path ) == -1 )
if( asprintf( &psz_tmp, "%s.xspf", s->psz_url ) == -1 )
psz_tmp = NULL;
if( p_sys->psz_path == NULL || psz_tmp == NULL )
{
free( psz_tmp );
free( p_sys->psz_path );
free( p_sys->fileFunctions );
free( p_sys );
return VLC_ENOMEM;
}
p_sys->psz_path = s->psz_path;
s->psz_path = psz_tmp;
free(s->psz_url);
s->psz_url = psz_tmp;
s->pf_read = Read;
s->pf_control = Control;
return VLC_SUCCESS;
error:
free( p_sys );
return VLC_ENOMEM;
}
/** *************************************************************************
......
......@@ -78,7 +78,7 @@ Url AbstractPlaylist::getUrlSegment() const
else
{
std::stringstream ss;
ss << stream->psz_access << "://" << Helper::getDirectoryPath(stream->psz_path) << "/";
ss << Helper::getDirectoryPath(stream->psz_url) << "/";
return Url(ss.str());
}
}
......
......@@ -437,7 +437,7 @@ static bool FindSVGmarker(int *position, const uint8_t *data, const int size, co
static bool IsSVG(stream_t *s)
{
char *ext = strstr(s->psz_path, ".svg");
char *ext = strstr(s->psz_url, ".svg");
if (!ext) return false;
const uint8_t *header;
......
......@@ -1631,17 +1631,15 @@ static int Open( vlc_object_t *p_this )
if( !isHDS( s ) )
return VLC_EGENERIC;
msg_Info( p_this, "HTTP Dynamic Streaming (%s)", s->psz_path );
msg_Info( p_this, "HTTP Dynamic Streaming (%s)", s->psz_url );
s->p_sys = p_sys = calloc( 1, sizeof(*p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
char *uri_without_query = NULL;
size_t pathlen = strcspn( s->psz_path, "?" );
if( unlikely( ( pathlen > INT_MAX ) ||
( asprintf( &uri_without_query, "%s://%.*s", s->psz_access,
(int)pathlen, s->psz_path ) < 0 ) ) )
char *uri_without_query = strndup( s->psz_url,
strcspn( s->psz_url, "?" ) );
if( uri_without_query == NULL )
{
free( p_sys );
return VLC_ENOMEM;
......
......@@ -462,14 +462,14 @@ static int Open( vlc_object_t *p_this )
if( !isSmoothStreaming( s ) )
return VLC_EGENERIC;
msg_Info( p_this, "Smooth Streaming (%s)", s->psz_path );
msg_Info( p_this, "Smooth Streaming (%s)", s->psz_url );
s->p_sys = p_sys = calloc( 1, sizeof(*p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
char *uri = NULL;
if( unlikely( asprintf( &uri, "%s://%s", s->psz_access, s->psz_path ) < 0 ) )
char *uri = strdup( s->psz_url );
if( unlikely( uri == NULL ) )
{
free( p_sys );
return VLC_ENOMEM;
......
......@@ -2341,10 +2341,14 @@ static int InputSourceInit( input_thread_t *p_input,
stream_Control( p_stream, STREAM_GET_PTS_DELAY, &i_pts_delay );
}
if( p_stream->psz_url != NULL )
/* Take access/stream redirections into account: */
psz_path = strstr( p_stream->psz_url, "://" );
if( psz_path == NULL )
psz_path = "";
in->p_demux = demux_New( p_input, p_input, psz_access, psz_demux,
/* Take access/stream redirections into account: */
p_stream->psz_path ? p_stream->psz_path : psz_path,
p_stream, p_input->p->p_es_out,
psz_path, p_stream, p_input->p->p_es_out,
p_input->b_preparsing );
if( in->p_demux == NULL )
......
......@@ -63,8 +63,7 @@ stream_t *stream_CommonNew(vlc_object_t *parent)
stream_t *s = &priv->stream;
s->psz_access = NULL;
s->psz_path = NULL;
s->psz_url = NULL;
priv->peek = NULL;
/* UTF16 and UTF32 text file conversion */
......@@ -88,8 +87,7 @@ void stream_CommonDelete( stream_t *s )
if (priv->peek != NULL)
block_Release(priv->peek);
free( s->psz_access );
free( s->psz_path );
free(s->psz_url);
vlc_object_release( s );
}
......
......@@ -194,10 +194,11 @@ stream_t *stream_AccessNew( access_t *p_access )
return NULL;
s->p_input = p_access->p_input;
s->psz_access = strdup( p_access->psz_access );
s->psz_path = strdup( p_access->psz_location );
if( asprintf( &s->psz_url, "%s://%s", p_access->psz_access,
p_access->psz_location ) == -1 )
s->psz_url = NULL;
s->p_sys = p_sys = malloc( sizeof( *p_sys ) );
if( !s->psz_access || !s->psz_path || !s->p_sys )
if( !s->psz_url || !s->p_sys )
{
stream_CommonDelete( s );
return NULL;
......
......@@ -74,13 +74,13 @@ stream_t *stream_DemuxNew( demux_t *p_demux, const char *psz_demux, es_out_t *ou
if( s == NULL )
return NULL;
s->p_input = p_demux->p_input;
s->psz_path = strdup(""); /* N/A */
s->psz_url = strdup(""); /* N/A */
s->pf_read = DStreamRead;
s->pf_control= DStreamControl;
s->pf_destroy= DStreamDelete;
s->p_sys = p_sys = malloc( sizeof( *p_sys) );
if( !s->psz_path || !s->p_sys )
if( !s->psz_url || !s->p_sys )
{
free( p_sys );
stream_CommonDelete( s );
......
......@@ -49,9 +49,8 @@ stream_t *stream_FilterNew( stream_t *p_source,
s->p_input = p_source->p_input;
/* */
s->psz_access = strdup( p_source->psz_access );
s->psz_path = strdup( p_source->psz_path );
if( !s->psz_path )
s->psz_url = strdup( p_source->psz_url );
if( unlikely(s->psz_url == NULL) )
{
stream_CommonDelete( s );
return NULL;
......
......@@ -59,9 +59,9 @@ stream_t *stream_MemoryNew( vlc_object_t *p_this, uint8_t *p_buffer,
if( !s )
return NULL;
s->psz_path = strdup( "" ); /* N/A */
s->psz_url = strdup( "" ); /* N/A */
s->p_sys = p_sys = malloc( sizeof( stream_sys_t ) );
if( !s->psz_path || !s->p_sys )
if( !s->psz_url || !s->p_sys )
{
stream_CommonDelete( s );
free( p_sys );
......
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