]> git.sesse.net Git - vlc/blobdiff - src/input/item.c
libvlc: Split public headers by object and layers.
[vlc] / src / input / item.c
index 864e84ae577bb555aa96e7836f21b746983494cf..2397c13c55c4ce397afa406cf9b56a7499a2acaa 100644 (file)
@@ -16,9 +16,9 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -27,6 +27,7 @@
 #include <assert.h>
 
 #include <vlc_common.h>
+#include <vlc_url.h>
 #include "vlc_playlist.h"
 #include "vlc_interface.h"
 
@@ -306,13 +307,14 @@ char *input_item_GetTitleFbName( input_item_t *p_item )
 
     if( !p_item->p_meta )
     {
+        psz_ret = p_item->psz_name ? strdup( p_item->psz_name ) : NULL;
         vlc_mutex_unlock( &p_item->lock );
-        return NULL;
+        return psz_ret;
     }
 
-    const char *psz_meta = vlc_meta_Get( p_item->p_meta, vlc_meta_Title );
-    if( !EMPTY_STR( psz_meta ) )
-        psz_ret = strdup( psz_meta );
+    const char *psz_title = vlc_meta_Get( p_item->p_meta, vlc_meta_Title );
+    if( !EMPTY_STR( psz_title ) )
+        psz_ret = strdup( psz_title );
     else
         psz_ret = p_item->psz_name ? strdup( p_item->psz_name ) : NULL;
 
@@ -366,8 +368,36 @@ void input_item_SetURI( input_item_t *p_i, const char *psz_uri )
             p_i->psz_name = strdup( psz_filename );
     }
 
+    /* The name is NULL: fill it with everything except login and password */
     if( !p_i->psz_name )
-        p_i->psz_name = strdup( p_i->psz_uri );
+    {
+        int r;
+        vlc_url_t url;
+        vlc_UrlParse( &url, psz_uri, 0 );
+        if( url.psz_protocol )
+        {
+            if( url.i_port > 0 )
+                r=asprintf( &p_i->psz_name, "%s://%s:%d%s", url.psz_protocol,
+                          url.psz_host, url.i_port,
+                          url.psz_path ? url.psz_path : "" );
+            else
+                r=asprintf( &p_i->psz_name, "%s://%s%s", url.psz_protocol,
+                          url.psz_host ? url.psz_host : "",
+                          url.psz_path ? url.psz_path : "" );
+        }
+        else
+        {
+            if( url.i_port > 0 )
+                r=asprintf( &p_i->psz_name, "%s:%d%s", url.psz_host, url.i_port,
+                          url.psz_path ? url.psz_path : "" );
+            else
+                r=asprintf( &p_i->psz_name, "%s%s", url.psz_host,
+                          url.psz_path ? url.psz_path : "" );
+        }
+        vlc_UrlClean( &url );
+        if( -1==r )
+            p_i->psz_name=NULL; /* recover from undefined value */
+    }
 
     vlc_mutex_unlock( &p_i->lock );
 }
@@ -787,10 +817,12 @@ static void GuessType( input_item_t *p_item)
         { "dvb", ITEM_TYPE_CARD },
         { "qpsk", ITEM_TYPE_CARD },
         { "sdp", ITEM_TYPE_NET },
+        { "ftp", ITEM_TYPE_NET },
+        { "smb", ITEM_TYPE_NET },
         { NULL, 0 }
     };
 
-    if( !p_item->psz_uri )
+    if( !p_item->psz_uri || !strstr( p_item->psz_uri, "://" ) )
     {
         p_item->i_type = ITEM_TYPE_FILE;
         return;