From 584bf4f6414daf73adba01fd10f7b0aafdc1330d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= Date: Wed, 12 Jan 2022 19:48:59 +0100 Subject: [PATCH] upnp: fix browsing of certain servers This is a partial revert of 785c6dfe. Some servers (notably PLEX, UMS, and some TV sets) amend the exposed media type with additional subtypes for further differentiation not relevant to VLC, so it is actually correct to compare the beginning of the string only. For instance "object.container" can turn into "object.container.storageFolder" or "object.container.person.musicArtist" so the plain strcmp will fail to recognize the container nature. Fixes vlc-ios#1239 (cherry picked from commit 741f1f90cdb1f972d4552c4f45eafd24b3092621) --- modules/services_discovery/upnp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp index b862e256bd..fe69422fb0 100644 --- a/modules/services_discovery/upnp.cpp +++ b/modules/services_discovery/upnp.cpp @@ -874,13 +874,13 @@ namespace psz_album_artist = xml_getChildElementValue( itemElement, "upnp:albumArtist" ); psz_albumArt = xml_getChildElementValue( itemElement, "upnp:albumArtURI" ); const char *psz_media_type = xml_getChildElementValue( itemElement, "upnp:class" ); - if (strcmp(psz_media_type, "object.item.videoItem") == 0) + if (strncmp(psz_media_type, "object.item.videoItem", 21) == 0) media_type = VIDEO; - else if (strcmp(psz_media_type, "object.item.audioItem") == 0) + else if (strncmp(psz_media_type, "object.item.audioItem", 21) == 0) media_type = AUDIO; - else if (strcmp(psz_media_type, "object.item.imageItem") == 0) + else if (strncmp(psz_media_type, "object.item.imageItem", 21) == 0) media_type = IMAGE; - else if (strcmp(psz_media_type, "object.container") == 0) + else if (strncmp(psz_media_type, "object.container", 16 ) == 0) media_type = CONTAINER; else return false;