Skip to content
Browse files

UPnP services discovery: Add support for IPv6

 * Switch to the pupnp 1.8.0 API and bump the required pupnp version
 * Use the new initialization routines which add IPv6 support
 * Update my e-mail address in the header comments

TODO: update the contribs
  • Loading branch information...
1 parent 22e5015 commit 580fbcee2473c04c338702ea407f639f9dc4fec5 @mirsal committed Sep 4, 2011
Showing with 36 additions and 22 deletions.
  1. +1 −1 configure.ac
  2. +35 −21 modules/services_discovery/upnp.cpp
View
2 configure.ac
@@ -3617,7 +3617,7 @@ fi
dnl
dnl UPnP Plugin (Intel SDK)
dnl
-PKG_ENABLE_MODULES_VLC([UPNP], [upnp], [libupnp], [Intel UPnp SDK],[auto])
+PKG_ENABLE_MODULES_VLC([UPNP], [upnp], [libupnp >= 1.8.0], [Intel UPnP SDK],[auto])
VLC_ADD_CXXFLAGS([upnp],[${UPNP_CFLAGS}])
dnl
View
56 modules/services_discovery/upnp.cpp
@@ -6,7 +6,7 @@
*
* Authors: Rémi Denis-Courmont <rem # videolan.org> (original plugin)
* Christian Henz <henz # c-lab.de>
- * Mirsal Ennaime <mirsal dot ennaime at gmail dot com>
+ * Mirsal Ennaime <mirsal at mirsal fr>
*
* UPnP Plugin using the Intel SDK (libupnp) instead of CyberLink
*
@@ -104,12 +104,13 @@ static int Open( vlc_object_t *p_this )
return VLC_ENOMEM;
/* Initialize on first IPv4-capable adapter and first open port
- * TODO: use UpnpInit2() to utilize IPv6.
*/
- i_res = UpnpInit( 0, 0 );
+ i_res = UpnpInit2( NULL, 0 );
if( i_res != UPNP_E_SUCCESS )
{
- msg_Err( p_sd, "Initialization failed: %s", UpnpGetErrorMessage( i_res ) );
+ msg_Err( p_sd, "Initialization failed: %s",
+ UpnpGetErrorMessage( i_res ) );
+
free( p_sys );
return VLC_EGENERIC;
}
@@ -121,25 +122,32 @@ static int Open( vlc_object_t *p_this )
i_res = UpnpRegisterClient( Callback, p_sd, &p_sys->client_handle );
if( i_res != UPNP_E_SUCCESS )
{
- msg_Err( p_sd, "Client registration failed: %s", UpnpGetErrorMessage( i_res ) );
+ msg_Err( p_sd, "Client registration failed: %s",
+ UpnpGetErrorMessage( i_res ) );
+
Close( (vlc_object_t*) p_sd );
return VLC_EGENERIC;
}
/* Search for media servers */
i_res = UpnpSearchAsync( p_sys->client_handle, 5,
MEDIA_SERVER_DEVICE_TYPE, p_sd );
+
if( i_res != UPNP_E_SUCCESS )
{
- msg_Err( p_sd, "Error sending search request: %s", UpnpGetErrorMessage( i_res ) );
+ msg_Err( p_sd, "Error sending search request: %s",
+ UpnpGetErrorMessage( i_res ) );
+
Close( (vlc_object_t*) p_sd );
return VLC_EGENERIC;
}
i_res = UpnpSetMaxContentLength( 0 );
if( i_res != UPNP_E_SUCCESS )
{
- msg_Err( p_sd, "Failed to set maximum content length: %s", UpnpGetErrorMessage( i_res ) );
+ msg_Err( p_sd, "Failed to set maximum content length: %s",
+ UpnpGetErrorMessage( i_res ) );
+
Close( (vlc_object_t*) p_sd );
return VLC_EGENERIC;
}
@@ -253,41 +261,45 @@ static int Callback( Upnp_EventType event_type, void* p_event, void* p_user_data
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT:
{
- struct Upnp_Discovery* p_discovery = ( struct Upnp_Discovery* )p_event;
+ const UpnpString *p_location = NULL;
+ const char *psz_location = NULL;
+ UpnpDiscovery* p_discovery = ( UpnpDiscovery* )p_event;
+ IXML_Document *p_description_doc = NULL;
- IXML_Document *p_description_doc = 0;
+ p_location = UpnpDiscovery_get_Location( p_discovery );
+ psz_location = UpnpString_get_String( p_location );
+ int i_res = UpnpDownloadXmlDoc( psz_location, &p_description_doc );
- int i_res;
- i_res = UpnpDownloadXmlDoc( p_discovery->Location, &p_description_doc );
if ( i_res != UPNP_E_SUCCESS )
{
msg_Warn( p_sd, "Could not download device description! "
"Fetching data from %s failed: %s",
- p_discovery->Location, UpnpGetErrorMessage( i_res ) );
+ psz_location, UpnpGetErrorMessage( i_res ) );
return i_res;
}
MediaServer::parseDeviceDescription( p_description_doc,
- p_discovery->Location, p_sd );
+ psz_location, p_sd );
ixmlDocument_free( p_description_doc );
}
break;
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
{
- struct Upnp_Discovery* p_discovery = ( struct Upnp_Discovery* )p_event;
-
- p_sys->p_server_list->removeServer( p_discovery->DeviceId );
-
+ UpnpDiscovery* p_discovery = ( UpnpDiscovery* )p_event;
+ const UpnpString *p_id = UpnpDiscovery_get_DeviceID( p_discovery );
+ p_sys->p_server_list->removeServer( UpnpString_get_String( p_id ) );
}
break;
case UPNP_EVENT_RECEIVED:
{
- Upnp_Event* p_e = ( Upnp_Event* )p_event;
+ UpnpEvent* p_e = ( UpnpEvent* )p_event;
+ const UpnpString *p_sid = UpnpEvent_get_SID( p_e );
+ const char *psz_sid = UpnpString_get_String( p_sid );
- MediaServer* p_server = p_sys->p_server_list->getServerBySID( p_e->Sid );
+ MediaServer* p_server = p_sys->p_server_list->getServerBySID( psz_sid );
if ( p_server ) p_server->fetchContents();
}
break;
@@ -297,9 +309,11 @@ static int Callback( Upnp_EventType event_type, void* p_event, void* p_user_data
{
/* Re-subscribe. */
- Upnp_Event_Subscribe* p_s = ( Upnp_Event_Subscribe* )p_event;
+ UpnpEventSubscribe* p_s = ( UpnpEventSubscribe* )p_event;
+ const UpnpString *p_sid = UpnpEventSubscribe_get_SID( p_s );
+ const char *psz_sid = UpnpString_get_String( p_sid );
- MediaServer* p_server = p_sys->p_server_list->getServerBySID( p_s->Sid );
+ MediaServer* p_server = p_sys->p_server_list->getServerBySID( psz_sid );
if ( p_server ) p_server->subscribeToContentDirectory();
}
break;

0 comments on commit 580fbce

Please sign in to comment.
Something went wrong with that request. Please try again.