Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

UPnP services discovery: Add support for IPv6 and use the pupnp 1.8 API

 * 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...
commit d569739b60283000faae5a1e44c5af3ed713df52 1 parent bc2987f
Mirsal Ennaime authored committed

Showing 2 changed files with 35 additions and 21 deletions. Show diff stats Hide diff stats

  1. +2 0  configure.ac
  2. +33 21 modules/services_discovery/upnp.cpp
2  configure.ac
@@ -3558,6 +3558,8 @@ dnl
3558 3558 dnl libsamplerate plugin
3559 3559 dnl
3560 3560 PKG_ENABLE_MODULES_VLC([SAMPLERATE], [], [samplerate], [Resampler with libsamplerate], [auto])
  3561 +PKG_ENABLE_MODULES_VLC([UPNP], [upnp], [libupnp >= 1.8.0], [Intel UPnP SDK],[auto])
  3562 +VLC_ADD_CXXFLAGS([upnp],[${UPNP_CFLAGS}])
3561 3563
3562 3564 dnl
3563 3565 dnl OS/2 KAI plugin
54 modules/services_discovery/upnp.cpp
@@ -6,7 +6,7 @@
6 6 *
7 7 * Authors: Rémi Denis-Courmont <rem # videolan.org> (original plugin)
8 8 * Christian Henz <henz # c-lab.de>
9   - * Mirsal Ennaime <mirsal dot ennaime at gmail dot com>
  9 + * Mirsal Ennaime <mirsal at mirsal fr>
10 10 *
11 11 * UPnP Plugin using the Intel SDK (libupnp) instead of CyberLink
12 12 *
@@ -105,12 +105,13 @@ static int Open( vlc_object_t *p_this )
105 105 return VLC_ENOMEM;
106 106
107 107 /* Initialize on first IPv4-capable adapter and first open port
108   - * TODO: use UpnpInit2() to utilize IPv6.
109 108 */
110   - i_res = UpnpInit( 0, 0 );
  109 + i_res = UpnpInit2( NULL, 0 );
111 110 if( i_res != UPNP_E_SUCCESS )
112 111 {
113   - msg_Err( p_sd, "Initialization failed: %s", UpnpGetErrorMessage( i_res ) );
  112 + msg_Err( p_sd, "Initialization failed: %s",
  113 + UpnpGetErrorMessage( i_res ) );
  114 +
114 115 free( p_sys );
115 116 return VLC_EGENERIC;
116 117 }
@@ -122,7 +123,9 @@ static int Open( vlc_object_t *p_this )
122 123 i_res = UpnpRegisterClient( Callback, p_sd, &p_sys->client_handle );
123 124 if( i_res != UPNP_E_SUCCESS )
124 125 {
125   - msg_Err( p_sd, "Client registration failed: %s", UpnpGetErrorMessage( i_res ) );
  126 + msg_Err( p_sd, "Client registration failed: %s",
  127 + UpnpGetErrorMessage( i_res ) );
  128 +
126 129 Close( (vlc_object_t*) p_sd );
127 130 return VLC_EGENERIC;
128 131 }
@@ -130,9 +133,12 @@ static int Open( vlc_object_t *p_this )
130 133 /* Search for media servers */
131 134 i_res = UpnpSearchAsync( p_sys->client_handle, 5,
132 135 MEDIA_SERVER_DEVICE_TYPE, p_sd );
  136 +
133 137 if( i_res != UPNP_E_SUCCESS )
134 138 {
135   - msg_Err( p_sd, "Error sending search request: %s", UpnpGetErrorMessage( i_res ) );
  139 + msg_Err( p_sd, "Error sending search request: %s",
  140 + UpnpGetErrorMessage( i_res ) );
  141 +
136 142 Close( (vlc_object_t*) p_sd );
137 143 return VLC_EGENERIC;
138 144 }
@@ -143,7 +149,7 @@ static int Open( vlc_object_t *p_this )
143 149 if( (i_res = UpnpSetMaxContentLength( INT_MAX )) != UPNP_E_SUCCESS )
144 150 {
145 151 msg_Err( p_sd, "Failed to set maximum content length: %s",
146   - UpnpGetErrorMessage( i_res ));
  152 + UpnpGetErrorMessage( i_res ) );
147 153
148 154 Close( (vlc_object_t*) p_sd );
149 155 return VLC_EGENERIC;
@@ -258,22 +264,25 @@ static int Callback( Upnp_EventType event_type, void* p_event, void* p_user_data
258 264 case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
259 265 case UPNP_DISCOVERY_SEARCH_RESULT:
260 266 {
261   - struct Upnp_Discovery* p_discovery = ( struct Upnp_Discovery* )p_event;
  267 + const UpnpString *p_location = NULL;
  268 + const char *psz_location = NULL;
  269 + UpnpDiscovery* p_discovery = ( UpnpDiscovery* )p_event;
  270 + IXML_Document *p_description_doc = NULL;
262 271
263   - IXML_Document *p_description_doc = 0;
  272 + p_location = UpnpDiscovery_get_Location( p_discovery );
  273 + psz_location = UpnpString_get_String( p_location );
  274 + int i_res = UpnpDownloadXmlDoc( psz_location, &p_description_doc );
264 275
265   - int i_res;
266   - i_res = UpnpDownloadXmlDoc( p_discovery->Location, &p_description_doc );
267 276 if ( i_res != UPNP_E_SUCCESS )
268 277 {
269 278 msg_Warn( p_sd, "Could not download device description! "
270 279 "Fetching data from %s failed: %s",
271   - p_discovery->Location, UpnpGetErrorMessage( i_res ) );
  280 + psz_location, UpnpGetErrorMessage( i_res ) );
272 281 return i_res;
273 282 }
274 283
275 284 MediaServer::parseDeviceDescription( p_description_doc,
276   - p_discovery->Location, p_sd );
  285 + psz_location, p_sd );
277 286
278 287 ixmlDocument_free( p_description_doc );
279 288 }
@@ -281,18 +290,19 @@ static int Callback( Upnp_EventType event_type, void* p_event, void* p_user_data
281 290
282 291 case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
283 292 {
284   - struct Upnp_Discovery* p_discovery = ( struct Upnp_Discovery* )p_event;
285   -
286   - p_sys->p_server_list->removeServer( p_discovery->DeviceId );
287   -
  293 + UpnpDiscovery* p_discovery = ( UpnpDiscovery* )p_event;
  294 + const UpnpString *p_id = UpnpDiscovery_get_DeviceID( p_discovery );
  295 + p_sys->p_server_list->removeServer( UpnpString_get_String( p_id ) );
288 296 }
289 297 break;
290 298
291 299 case UPNP_EVENT_RECEIVED:
292 300 {
293   - Upnp_Event* p_e = ( Upnp_Event* )p_event;
  301 + UpnpEvent* p_e = ( UpnpEvent* )p_event;
  302 + const UpnpString *p_sid = UpnpEvent_get_SID( p_e );
  303 + const char *psz_sid = UpnpString_get_String( p_sid );
294 304
295   - MediaServer* p_server = p_sys->p_server_list->getServerBySID( p_e->Sid );
  305 + MediaServer* p_server = p_sys->p_server_list->getServerBySID( psz_sid );
296 306 if ( p_server ) p_server->fetchContents();
297 307 }
298 308 break;
@@ -302,9 +312,11 @@ static int Callback( Upnp_EventType event_type, void* p_event, void* p_user_data
302 312 {
303 313 /* Re-subscribe. */
304 314
305   - Upnp_Event_Subscribe* p_s = ( Upnp_Event_Subscribe* )p_event;
  315 + UpnpEventSubscribe* p_s = ( UpnpEventSubscribe* )p_event;
  316 + const UpnpString *p_sid = UpnpEventSubscribe_get_SID( p_s );
  317 + const char *psz_sid = UpnpString_get_String( p_sid );
306 318
307   - MediaServer* p_server = p_sys->p_server_list->getServerBySID( p_s->Sid );
  319 + MediaServer* p_server = p_sys->p_server_list->getServerBySID( psz_sid );
308 320 if ( p_server ) p_server->subscribeToContentDirectory();
309 321 }
310 322 break;

0 comments on commit d569739

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