]> git.sesse.net Git - vlc/commitdiff
libvlc_media_new_path: create a media from a file path
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 18 Feb 2010 17:56:15 +0000 (19:56 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 18 Feb 2010 17:56:15 +0000 (19:56 +0200)
Also rename libvlc_media_new to libvlc_media_new_location to remove
the ambiguity.

12 files changed:
bindings/mediacontrol/mediacontrol_core.c
include/vlc/libvlc_media.h
projects/activex/plugin.cpp
projects/macosx/framework/Sources/VLCMedia.m
projects/mozilla/vlcplugin.cpp
src/control/media.c
src/libvlc.sym
test/libvlc/libvlc_additions.h
test/libvlc/media_list.c
test/libvlc/media_list_player.c
test/libvlc/media_player.c
test/libvlc/meta.c

index f721ec874549ad1300355c2ad8c0bb82af5c9921..d52d8cd801c899b6dd956129645255a742be1a04 100644 (file)
@@ -196,7 +196,7 @@ mediacontrol_start( mediacontrol_Instance *self,
         HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
 
         /* Create a new media */
-        p_media = libvlc_media_new( self->p_instance, psz_name, &ex );
+        p_media = libvlc_media_new_location( self->p_instance, psz_name, &ex );
         HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
 
         if( a_position->value )
@@ -257,7 +257,7 @@ mediacontrol_set_mrl( mediacontrol_Instance *self,
     mediacontrol_exception_init( exception );
     libvlc_exception_init( &ex );
 
-    p_media = libvlc_media_new( self->p_instance, psz_file, &ex );
+    p_media = libvlc_media_new_location( self->p_instance, psz_file, &ex );
     HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
 
     libvlc_media_player_set_media( self->p_media_player, p_media );
index 409a521372d980a05f7d037ebd6ca1c85d31f145..a2222864c9c7ec6e6aff3a4e913a7ffd16502509 100644 (file)
@@ -170,16 +170,27 @@ typedef struct libvlc_media_es_t
 
 
 /**
- * Create a media with the given MRL.
+ * Create a media with a certain given media resource location.
  *
  * \param p_instance the instance
  * \param psz_mrl the MRL to read
  * \return the newly created media or NULL on error
  */
-VLC_PUBLIC_API libvlc_media_t * libvlc_media_new(
+VLC_PUBLIC_API libvlc_media_t *libvlc_media_new_location(
                                    libvlc_instance_t *p_instance,
                                    const char * psz_mrl );
 
+/**
+ * Create a media with a certain file path.
+ *
+ * \param p_instance the instance
+ * \param path local filesystem path
+ * \return the newly created media or NULL on error
+ */
+VLC_PUBLIC_API libvlc_media_t *libvlc_media_new_path(
+                                   libvlc_instance_t *p_instance,
+                                   const char *path );
+
 /**
  * Create a media as an empty node with a given name.
  *
index 1b3efdd43aa14babe1a0759c8eef5f6f6dd651dd..434f582e09e5ccf50d4a1554bee344a895294624 100644 (file)
@@ -1398,7 +1398,7 @@ void VLCPlugin::player_unregister_events()
 int  VLCPlugin::playlist_add_extended_untrusted(const char *mrl, int optc, const char **optv)
 {
     int item = -1;
-    libvlc_media_t *p_m = libvlc_media_new(_p_libvlc,mrl);
+    libvlc_media_t *p_m = libvlc_media_new_location(_p_libvlc,mrl);
     if( !p_m )
         return -1;
 
index 9da84096497ac9c7a4d5aff69940da282ab08052..e4cbef933876fe34e2cc0f19448bc2400343be27 100644 (file)
@@ -177,7 +177,7 @@ static void HandleMediaSubItemAdded(const libvlc_event_t * event, void * self)
 {
     if (self = [super init])
     {
-        p_md = libvlc_media_new([VLCLibrary sharedInstance],
+        p_md = libvlc_media_new_location([VLCLibrary sharedInstance],
                                            [[anURL absoluteString] UTF8String]);
 
         delegate = nil;
index c0d7dd1e92f836763d7a71f6db4bb7fae2391964..76316d14ea0aee63bcc8230a144cb7a3ed96a81a 100644 (file)
@@ -452,7 +452,7 @@ void VlcPlugin::set_player_window()
 int VlcPlugin::playlist_add( const char *mrl )
 {
     int item = -1;
-    libvlc_media_t *p_m = libvlc_media_new(libvlc_instance,mrl);
+    libvlc_media_t *p_m = libvlc_media_new_location(libvlc_instance,mrl);
     if( !p_m )
         return -1;
     assert( libvlc_media_list );
@@ -474,7 +474,7 @@ int VlcPlugin::playlist_add_extended_untrusted( const char *mrl, const char *nam
 
     assert( libvlc_media_list );
 
-    p_m = libvlc_media_new(libvlc_instance, mrl);
+    p_m = libvlc_media_new_location(libvlc_instance, mrl);
     if( !p_m )
         return -1;
 
index 0b6147ef0680cc8f07598530c70dd54d41585072..bdb0ce310dbd186480205cec848f03da8409e954 100644 (file)
@@ -36,6 +36,7 @@
 #include <vlc_input.h>
 #include <vlc_meta.h>
 #include <vlc_playlist.h> /* For the preparser */
+#include <vlc_url.h>
 
 #include "libvlc.h"
 
@@ -294,8 +295,8 @@ libvlc_media_t * libvlc_media_new_from_input_item(
 /**************************************************************************
  * Create a new media descriptor object
  **************************************************************************/
-libvlc_media_t * libvlc_media_new( libvlc_instance_t *p_instance,
-                                   const char * psz_mrl )
+libvlc_media_t *libvlc_media_new_location( libvlc_instance_t *p_instance,
+                                           const char * psz_mrl )
 {
     input_item_t * p_input_item;
     libvlc_media_t * p_md;
@@ -316,6 +317,21 @@ libvlc_media_t * libvlc_media_new( libvlc_instance_t *p_instance,
     return p_md;
 }
 
+libvlc_media_t *libvlc_media_new_path( libvlc_instance_t *p_instance,
+                                       const char *path )
+{
+    char *mrl = make_URI( path );
+    if( unlikely(mrl == NULL) )
+    {
+        libvlc_printerr( "Not enough memory" );
+        return NULL;
+    }
+
+    libvlc_media_t *m = libvlc_media_new_location( p_instance, mrl );
+    free( mrl );
+    return m;
+}
+
 /**************************************************************************
  * Create a new media descriptor object
  **************************************************************************/
index 6f8820ec87b0b9ae233180296b02861413a17b57..b38ec0175502da797971e9cb902c0850456a19bf 100644 (file)
@@ -98,7 +98,8 @@ libvlc_media_list_remove_index
 libvlc_media_list_retain
 libvlc_media_list_set_media
 libvlc_media_list_unlock
-libvlc_media_new
+libvlc_media_new_location
+libvlc_media_new_path
 libvlc_media_new_as_node
 libvlc_media_new_from_input_item
 libvlc_media_player_can_pause
index c3f33dd0b2977fe36d70dcdd0a2784f06aa25859..a81787e4f24e5ddb58ae153d2cfb25213a635508 100644 (file)
@@ -21,7 +21,7 @@
 
 static void* media_list_add_file_path(libvlc_instance_t *vlc, libvlc_media_list_t *ml, const char * file_path)
 {
-    libvlc_media_t *md = libvlc_media_new (vlc, file_path);
+    libvlc_media_t *md = libvlc_media_new_location (vlc, file_path);
     libvlc_media_list_add_media (ml, md);
     libvlc_media_release (md);
     return md;
index 9d1399c1b262934342bed48beb207dc6e0a90ad6..7eab6b9f48dd4f6912e49f0abd89ece90b7e3369 100644 (file)
@@ -38,11 +38,11 @@ static void test_media_list (const char ** argv, int argc)
     ml = libvlc_media_list_new (vlc);
     assert (ml != NULL);
 
-    md1 = libvlc_media_new (vlc, "/dev/null");
+    md1 = libvlc_media_new_path (vlc, "/dev/null");
     assert (md1 != NULL);
-    md2 = libvlc_media_new (vlc, "/dev/null");
+    md2 = libvlc_media_new_path (vlc, "/dev/null");
     assert (md2 != NULL);
-    md3 = libvlc_media_new (vlc, "/dev/null");
+    md3 = libvlc_media_new_path (vlc, "/dev/null");
     assert (md3 != NULL);
 
     ret = libvlc_media_list_add_media (ml, md1);
@@ -103,7 +103,7 @@ static void test_media_list (const char ** argv, int argc)
     p_non_exist = libvlc_media_list_item_at_index (ml, -1);
     assert (p_non_exist == NULL);
 
-    md4 = libvlc_media_new (vlc, "/dev/null");
+    md4 = libvlc_media_new_path (vlc, "/dev/null");
     assert (md4 != NULL);
 
     /* try to find non inserted item */
index cebaefc6857c7668be4bd26d948b6ac0fda3438f..36543ebe3a7b911cad7269107a417b3a54179a68 100644 (file)
@@ -103,7 +103,7 @@ static void test_media_list_player_items_queue(const char** argv, int argc)
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
-    md = libvlc_media_new (vlc, file, &ex);
+    md = libvlc_media_new_path (vlc, file, &ex);
     catch ();
 
     ml = libvlc_media_list_new (vlc);
@@ -173,7 +173,7 @@ static void test_media_list_player_previous(const char** argv, int argc)
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
-    md = libvlc_media_new (vlc, file, &ex);
+    md = libvlc_media_new_path (vlc, file, &ex);
     catch ();
 
     ml = libvlc_media_list_new (vlc);
@@ -249,7 +249,7 @@ static void test_media_list_player_next(const char** argv, int argc)
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
-    md = libvlc_media_new (vlc, file, &ex);
+    md = libvlc_media_new_path (vlc, file, &ex);
     catch ();
 
     ml = libvlc_media_list_new (vlc);
@@ -324,7 +324,7 @@ static void test_media_list_player_pause_stop(const char** argv, int argc)
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
-    md = libvlc_media_new (vlc, file, &ex);
+    md = libvlc_media_new_path (vlc, file, &ex);
     catch ();
 
     ml = libvlc_media_list_new (vlc);
@@ -370,7 +370,7 @@ static void test_media_list_player_play_item_at_index(const char** argv, int arg
     vlc = libvlc_new (argc, argv, &ex);
     assert (vlc != NULL);
 
-    md = libvlc_media_new (vlc, file, &ex);
+    md = libvlc_media_new_path (vlc, file, &ex);
     catch ();
 
     ml = libvlc_media_list_new (vlc);
@@ -437,19 +437,19 @@ static void test_media_list_player_playback_options (const char** argv, int argc
      *  ml5&6:            0                 0 -- 1
      */
 
-    md = libvlc_media_new (vlc, file, &ex);
+    md = libvlc_media_new_path (vlc, file, &ex);
     catch ();
 
-    md2 = libvlc_media_new (vlc, file, &ex);
+    md2 = libvlc_media_new_path (vlc, file, &ex);
     catch ();
 
-    md3 = libvlc_media_new (vlc, file, &ex);
+    md3 = libvlc_media_new_path (vlc, file, &ex);
     catch ();
 
-    md4 = libvlc_media_new (vlc, file, &ex);
+    md4 = libvlc_media_new_path (vlc, file, &ex);
     catch ();
 
-    md5 = libvlc_media_new (vlc, file, &ex);
+    md5 = libvlc_media_new_path (vlc, file, &ex);
     catch ();
 
     ml = libvlc_media_list_new (vlc);
index a843b65d5727f995271c2262c9a1a820a01ee747..cba2a90fb2b915e9f5c0dda37592d769a0fbf014 100644 (file)
@@ -32,7 +32,7 @@ static void test_media_player_set_media(const char** argv, int argc)
     libvlc_instance_t *vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
-    libvlc_media_t *md = libvlc_media_new (vlc, file);
+    libvlc_media_t *md = libvlc_media_new_path (vlc, file);
     assert (md != NULL);
 
     libvlc_media_player_t *mp = libvlc_media_player_new (vlc);
@@ -71,7 +71,7 @@ static void test_media_player_play_stop(const char** argv, int argc)
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
-    md = libvlc_media_new (vlc, file);
+    md = libvlc_media_new_path (vlc, file);
     assert (md != NULL);
 
     mi = libvlc_media_player_new_from_media (md);
@@ -108,7 +108,7 @@ static void test_media_player_pause_stop(const char** argv, int argc)
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
-    md = libvlc_media_new (vlc, file);
+    md = libvlc_media_new_path (vlc, file);
     assert (md != NULL);
 
     mi = libvlc_media_player_new_from_media (md);
index 2b621c054ba432021399aa19a8d2285bb6a35887..690578d7ae33b485392a594534320aa773ea788b 100644 (file)
@@ -37,7 +37,7 @@ static void test_meta (const char ** argv, int argc)
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
-    media = libvlc_media_new (vlc, "samples/meta.sample");
+    media = libvlc_media_new_path (vlc, "samples/meta.sample");
     assert( media );
 
     /* Tell that we are interested in this precise meta data