mirror of
https://github.com/videolan/vlc.git
synced 2024-12-04 15:26:23 +08:00
libvlc_media_new_path: create a media from a file path
Also rename libvlc_media_new to libvlc_media_new_location to remove the ambiguity.
This commit is contained in:
parent
501f845fee
commit
7eccf3a2cf
@ -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 );
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
**************************************************************************/
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user