]> git.sesse.net Git - vlc/commitdiff
upnp: Support UPnP A/V MediaServer:2 devices
authorChris Clayton <chris2553@googlemail.com>
Sat, 17 Dec 2011 23:30:08 +0000 (23:30 +0000)
committerMirsal Ennaime <mirsal@videolan.org>
Mon, 19 Dec 2011 03:07:42 +0000 (04:07 +0100)
* Accept any version of the MediaServer service
* Browse the advertised ContentDirectory service version

Signed-off-by: Mirsal Ennaime <mirsal@videolan.org>
modules/services_discovery/upnp.cpp
modules/services_discovery/upnp.hpp

index cc61e1da9e9582d20dfcacc29b4bc3a47175d89e..00750f5905d3497d2c0da92ec37a5e2c9247727b 100644 (file)
@@ -380,7 +380,8 @@ void MediaServer::parseDeviceDescription( IXML_Document* p_doc,
                 continue;
             }
 
-            if ( strcmp( MEDIA_SERVER_DEVICE_TYPE, psz_device_type ) != 0 )
+            if ( strncmp( MEDIA_SERVER_DEVICE_TYPE, psz_device_type,
+                    strlen( MEDIA_SERVER_DEVICE_TYPE ) - 1 ) != 0 )
                 continue;
 
             const char* psz_udn = xml_getChildElementValue( p_device_element, "UDN" );
@@ -437,10 +438,14 @@ void MediaServer::parseDeviceDescription( IXML_Document* p_doc,
                         continue;
                     }
 
-                    if ( strcmp( CONTENT_DIRECTORY_SERVICE_TYPE,
-                                psz_service_type ) != 0 )
+                    int k = strlen( CONTENT_DIRECTORY_SERVICE_TYPE ) - 1;
+                    if ( strncmp( CONTENT_DIRECTORY_SERVICE_TYPE,
+                                psz_service_type, k ) != 0 )
                         continue;
 
+                   p_server->_i_content_directory_service_version =
+                       psz_service_type[k];
+
                     const char* psz_event_sub_url =
                         xml_getChildElementValue( p_service_element,
                                                   "eventSubURL" );
@@ -509,6 +514,7 @@ MediaServer::MediaServer( const char* psz_udn,
 
     _p_contents = NULL;
     _p_input_item = NULL;
+    _i_content_directory_service_version = 1;
 }
 
 MediaServer::~MediaServer()
@@ -597,6 +603,9 @@ IXML_Document* MediaServer::_browseAction( const char* psz_object_id_,
 
     char* psz_service_type = strdup( CONTENT_DIRECTORY_SERVICE_TYPE );
 
+    psz_service_type[strlen( psz_service_type ) - 1] =
+       _i_content_directory_service_version;
+
     int i_res;
 
     i_res = UpnpAddToAction( &p_action, "Browse",
index 8e45fe8795efabbf797ed5d77be7f61914100236..935317ffb0c9b9c922a606c6c19d50b6e240b5b0 100644 (file)
@@ -87,6 +87,7 @@ private:
     std::string _content_directory_control_url;
 
     int _i_subscription_timeout;
+    int _i_content_directory_service_version;
     Upnp_SID _subscription_id;
 };