[vlc-devel] Patch/request for comment and testing - constructing the upNp playlist

Chris Clayton chris2553 at gmail.com
Mon Oct 21 11:55:42 CEST 2013


Hi again.

On 10/15/13 07:20, Chris Clayton wrote:
> Thanks Mirsal.
> 
> On 10/14/13 11:17, Mirsal Ennaime wrote:
>> Hi Chris,
>>

[snip]

>> However, your hack is probably better than nothing in the meantime,
>> so could you resend your patch properly ?
>>
> 
> Well, I was thinking of allowing the user to pass the friendly names of
> servers for which no playlist was being constructed to vlc as arguments.
> For those devices, MediaServer::ParseDeviceDescription() would make the
> call to ->fetchContents(). I accept that's just a "better hack" rather
> than the elegant solution you have in mind.
> 

Below is a patch that implements the idea above. I've tested it with MiniDLNA on OpenWrt, bubbleupnp on Samsung Galaxy
S3, the server in my Panasonic Bluray player, all of which still work as they did with my first patch. The nearby
devices function on my phone doesn't work with or without either patch (djmount seems to get the contents list, so I'll
see if I can work out later how it does that). The ushare server which, with my original patch, only worked if it was
configured for xbox compatibility works without that configuration if its friendly name is given with the (new)
--fetch-content-servers command line argument. Unfortunately, ushare is the only server I have access to that stopped
working with my first patch, so I am unable to test it more widely.

>> * Use git to format your patch and provide authorship information *
>> Do not comment lines out, just remove them. * Read
>> https://wiki.videolan.org/Sending_Patches/
>>
> 
> I'm afraid I don't use git. I just used the source from the downloaded
> tarball to do the analysis. It may take me a while to figure out how to
> do that. I don't seem to be able to attach the patch to this mail
> without thunderbird wrapping the text. I'll figure that out before
> re-sending my original patch, but with the ->fetchContents call deleted
> instead of commented out.
> 

Here's my latest patch. (Like I said, I don't use git (other than to do a periodic pull of the development kernel) and I
haven't had the time to teach myself. I'll look for a tutorial when I have more time. I think the patch is formatted OK,
however). I'm not sure of the protocol, so I've provided a S-o-B even though I expect (and will welcome) comments that
will lead to changes and I need to prepare a full changelog description. The presence of the S-o-B does not signify that
I expect the patch to be applied as is. It merely shows that it is original work by me.


Signed-off-by: Chris Clayton <chris2553 at googlemail.com>

--- vlc-2.1.0/modules/services_discovery/upnp.cpp.upnp-fetch	2013-06-24 19:00:38.000000000 +0100
+++ vlc-2.1.0/modules/services_discovery/upnp.cpp	2013-10-20 11:05:10.307843895 +0100
@@ -54,6 +54,7 @@ struct services_discovery_sys_t
     UpnpClient_Handle client_handle;
     MediaServerList* p_server_list;
     vlc_mutex_t callback_lock;
+    char *psz_fetch_servers;
 };

 /*
@@ -63,6 +64,11 @@ static int Open( vlc_object_t* );
 static void Close( vlc_object_t* );
 VLC_SD_PROBE_HELPER( "upnp", "Universal Plug'n'Play", SD_CAT_LAN )

+#define FETCH_SERVERS_TEXT "Fetch-content servers list"
+#define FETCH_SERVERS_LONGTEXT "Enter a list of the names of upnp servers" \
+				  " for which it is necessary to request the" \
+				  " contents, separated by '|' (pipe)."
+
 /*
  * Module descriptor
  */
@@ -73,6 +79,8 @@ vlc_module_begin();
     set_subcategory( SUBCAT_PLAYLIST_SD );
     set_capability( "services_discovery", 0 );
     set_callbacks( Open, Close );
+    add_string( "fetch-content-servers", NULL, FETCH_SERVERS_TEXT,
+		FETCH_SERVERS_LONGTEXT, false );

     VLC_SD_PROBE_SUBMODULE
 vlc_module_end();
@@ -80,6 +88,7 @@ vlc_module_end();
 /*
  * Local prototypes
  */
+static bool is_fetch_server( char *psz_server_list, const char *psz_server );
 static int Callback( Upnp_EventType event_type, void* p_event, void* p_user_data );

 const char* xml_getChildElementValue( IXML_Element* p_parent,
@@ -110,6 +119,9 @@ static int Open( vlc_object_t *p_this )
     if( !( p_sd->p_sys = p_sys ) )
         return VLC_ENOMEM;

+    /* Read settings */
+    p_sys->psz_fetch_servers = var_InheritString( p_sd, "fetch-content-servers" );
+
 #ifdef UPNP_ENABLE_IPV6
     char* psz_miface;
     psz_miface = var_InheritString( p_sd, "miface" );
@@ -403,6 +415,35 @@ static int Callback( Upnp_EventType even
     return UPNP_E_SUCCESS;
 }

+/*
+ * Many upnp servers send a contents list to a client when the client subscribes
+ * to the content directory service. A command line argument can provide a list
+ * of the friendly names of servers that don't and for which it is necessary to
+ * fetch the contents list. This function checks whether a discovered server is
+ * in that list.
+*/
+
+static bool is_fetch_server(char *psz_server_list, const char *psz_server )
+{
+    char *psz_pos;
+    int i_len;
+
+    if( psz_server_list == NULL || psz_server == NULL )
+	return false;
+
+    psz_pos = psz_server_list;
+    i_len = strlen( psz_server );
+
+    while( ( psz_pos = strstr( psz_pos, psz_server ) ) ) {
+
+	if( psz_pos[i_len]  == '|' || psz_pos[i_len] == '\0' )
+	    if( psz_pos == psz_server_list || psz_pos[-1] == '|' )
+		return true;
+	psz_pos++;
+    }
+
+    return false;
+}

 /*
  * Local class implementations.
@@ -579,7 +620,14 @@ void MediaServer::parseDeviceDescription
                                 UPNP_E_SUCCESS )
                         {
                             p_server->setContentDirectoryControlURL( psz_url );
-                            p_server->fetchContents();
+			    /*
+			     * Only fetch content list if server doesn't send it
+			     * automatically in response to the earlier content
+			     * directory service subscription.
+			    */
+			    if( is_fetch_server( p_sd->p_sys->psz_fetch_servers,
+						 psz_friendly_name ) )
+                        	p_server->fetchContents();
                         }

                         free( psz_url );




More information about the vlc-devel mailing list