From 02f60487e26191b02b8d33c50323f5c1c1fffc4b Mon Sep 17 00:00:00 2001 From: Chris Clayton Date: Sat, 17 Dec 2011 23:30:08 +0000 Subject: [PATCH] upnp: Support UPnP A/V MediaServer:2 devices * Accept any version of the MediaServer service * Browse the advertised ContentDirectory service version Signed-off-by: Mirsal Ennaime --- modules/services_discovery/upnp.cpp | 15 ++++++++++++--- modules/services_discovery/upnp.hpp | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp index cc61e1da9e..00750f5905 100644 --- a/modules/services_discovery/upnp.cpp +++ b/modules/services_discovery/upnp.cpp @@ -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", diff --git a/modules/services_discovery/upnp.hpp b/modules/services_discovery/upnp.hpp index 8e45fe8795..935317ffb0 100644 --- a/modules/services_discovery/upnp.hpp +++ b/modules/services_discovery/upnp.hpp @@ -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; }; -- 2.39.2