Commit ac99cee9 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

upnp: Don't drop potential options from the control URL

parent f6f309af
...@@ -324,7 +324,9 @@ bool MediaServerList::addServer( MediaServerDesc* desc ) ...@@ -324,7 +324,9 @@ bool MediaServerList::addServer( MediaServerDesc* desc )
ITEM_NET ); ITEM_NET );
} else { } else {
char* psz_mrl; char* psz_mrl;
if( asprintf(&psz_mrl, "upnp://%s?ObjectID=0", desc->location.c_str() ) < 0 ) // We might already have some options specified in the location.
char opt_delim = desc->location.find( '?' ) == 0 ? '?' : '&';
if( asprintf( &psz_mrl, "upnp://%s%cObjectID=0", desc->location.c_str(), opt_delim ) < 0 )
return false; return false;
p_input_item = input_item_NewDirectory( psz_mrl, p_input_item = input_item_NewDirectory( psz_mrl,
...@@ -760,20 +762,19 @@ MediaServer::MediaServer( access_t *p_access, input_item_node_t *node ) ...@@ -760,20 +762,19 @@ MediaServer::MediaServer( access_t *p_access, input_item_node_t *node )
, node_( node ) , node_( node )
{ {
vlc_url_t url; psz_root_ = strdup( p_access->psz_location );
vlc_UrlParse( &url, p_access->psz_location ); char* psz_objectid = strstr( psz_root_, "ObjectID=" );
if ( asprintf( &psz_root_, "%s://%s:%u%s", url.psz_protocol, if ( psz_objectid != NULL )
url.psz_host, url.i_port ? url.i_port : 80, url.psz_path ) < 0 ) {
psz_root_ = NULL; // Remove this parameter from the URL, since it might cause some servers to fail
// Keep in mind that we added a '&' or a '?' to the URL, so remove it as well
if ( url.psz_option && !strncmp( url.psz_option, "ObjectID=", strlen( "ObjectID=" ) ) ) *( psz_objectid - 1) = 0;
psz_objectId_ = strdup( &url.psz_option[strlen( "ObjectID=" )] ); psz_objectId_ = &psz_objectid[strlen( "ObjectID=" )];
vlc_UrlClean( &url ); }
} }
MediaServer::~MediaServer() MediaServer::~MediaServer()
{ {
free( psz_objectId_ );
free( psz_root_ ); free( psz_root_ );
} }
......
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