]> git.sesse.net Git - vlc/blobdiff - modules/services_discovery/mediadirs.c
Use var_Inherit* instead of var_CreateGet*.
[vlc] / modules / services_discovery / mediadirs.c
index b644fb6883373d4e782c12e1cf3b3f5fd683cc8b..63f9cb7110e9fdf9b3ae1234d16d80b154a5dfcb 100644 (file)
@@ -190,7 +190,7 @@ static void *Run( void *data )
             !S_ISDIR( st.st_mode ) )
             continue;
 
-        char* psz_uri = make_URI( psz_dir );
+        char* psz_uri = make_URI( psz_dir, "file" );
 
         input_item_t* p_root = input_item_New( p_sd, psz_uri, NULL );
         if( p_sys->i_type == Picture )
@@ -258,34 +258,47 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
 static int onNewFileAdded( vlc_object_t *p_this, char const *psz_var,
                      vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    (void)p_this;
+
     services_discovery_t *p_sd = p_data;
+    services_discovery_sys_t *p_sys = p_sd->p_sys;
 
-    (void)p_this; (void)psz_var; (void)oldval;
+    (void)psz_var; (void)oldval;
     char* psz_file = newval.psz_string;
     if( !psz_file || !*psz_file )
         return VLC_EGENERIC;
 
-    char* psz_uri = make_URI( psz_file );
+    char* psz_uri = make_URI( psz_file, "file" );
     input_item_t* p_item = input_item_New( p_sd, psz_uri, NULL );
 
-    if( fileType( p_sd, psz_file ) == Picture )
+    if( p_sys->i_type == Picture )
     {
-        formatSnapshotItem( p_item );
-        services_discovery_AddItem( p_sd, p_item, NULL );
+        if( fileType( p_sd, psz_file ) == Picture )
+        {
+            formatSnapshotItem( p_item );
+            services_discovery_AddItem( p_sd, p_item, NULL );
 
-        msg_Dbg( p_sd, "New snapshot added : %s", psz_file );
+            msg_Dbg( p_sd, "New snapshot added : %s", psz_file );
+        }
     }
-    else if( fileType( p_sd, psz_file ) == Audio )
+    else if( p_sys->i_type == Audio )
     {
-        services_discovery_AddItem( p_sd, p_item, NULL );
+        if( fileType( p_sd, psz_file ) == Audio )
+        {
+            services_discovery_AddItem( p_sd, p_item, NULL );
 
-        msg_Dbg( p_sd, "New recorded audio added : %s", psz_file );
+            msg_Dbg( p_sd, "New recorded audio added : %s", psz_file );
+        }
     }
-    else if( fileType( p_sd, psz_file ) == Video )
+    else if( p_sys->i_type == Video )
     {
-        services_discovery_AddItem( p_sd, p_item, NULL );
+        if( fileType( p_sd, psz_file ) == Video ||
+            fileType( p_sd, psz_file ) == Unknown )
+        {
+            services_discovery_AddItem( p_sd, p_item, NULL );
 
-        msg_Dbg( p_sd, "New recorded video added : %s", psz_file );
+            msg_Dbg( p_sd, "New recorded video added : %s", psz_file );
+        }
     }
 
     vlc_gc_decref( p_item );
@@ -299,28 +312,13 @@ void formatSnapshotItem( input_item_t *p_item )
     if( !p_item )
         return;
 
-    if( !p_item->p_meta )
-        p_item->p_meta = vlc_meta_New();
+    char* psz_uri = input_item_GetURI( p_item );
 
     /* copy the snapshot mrl as a ArtURL */
-    if( p_item->p_meta )
-    {
-        char* psz_uri = NULL;
-        psz_uri = input_item_GetURI( p_item );
-        if( psz_uri )
-            input_item_SetArtURL( p_item, psz_uri );
-        free( psz_uri );
-    }
+    if( psz_uri )
+        input_item_SetArtURL( p_item, psz_uri );
 
-    /**
-     * TODO: select the best mrl for displaying snapshots
-     *   - vlc://pause:10  => snapshot are displayed as Art
-     *   - file:///path/image.ext  => snapshot are displayed as videos
-     **/
-    input_item_SetURI( p_item, "vlc://pause:10" );
-
-    // input_item_AddOption( p_item, "fake-duration=10000",
-    //                       VLC_INPUT_OPTION_TRUSTED );
+    free( psz_uri );
 }