Commit f0531d5b authored by Clément Stenac's avatar Clément Stenac

Convert the new libvlc API (so, the one that is in src/control) not to use the...

Convert the new libvlc API (so, the one that is in src/control) not to use the old libVLC API (the one that is in libvlc.c, er, no, was... ah... maybe it's the internal one... err .... well, it's about vlc for sure...)
parent e9947bec
......@@ -49,9 +49,7 @@ int libvlc_InternalAddIntf( libvlc_int_t *, char const *, vlc_bool_t,
struct libvlc_instance_t
{
libvlc_int_t *p_libvlc_int;
playlist_t *p_playlist;
vlm_t *p_vlm;
int i_vlc_id;
};
struct libvlc_input_t
......
......@@ -4,7 +4,7 @@
* Copyright (C) 2005 the VideoLAN team
* $Id$
*
* Authors: Clent Stenac <zorglub@videolan.org>
* Authors: Clément Stenac <zorglub@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -82,13 +82,9 @@ inline void libvlc_exception_raise( libvlc_exception_t *p_exception,
libvlc_instance_t * libvlc_new( int argc, char **argv,
libvlc_exception_t *p_e )
{
int i_vlc_id;
libvlc_instance_t *p_new;
libvlc_int_t *p_libvlc_int;
i_vlc_id = VLC_Create();
p_libvlc_int = (libvlc_int_t* ) vlc_current_object( i_vlc_id );
libvlc_int_t *p_libvlc_int = libvlc_InternalCreate();
if( !p_libvlc_int ) RAISENULL( "VLC initialization failed" );
p_new = (libvlc_instance_t *)malloc( sizeof( libvlc_instance_t ) );
......@@ -97,30 +93,21 @@ libvlc_instance_t * libvlc_new( int argc, char **argv,
/** \todo Look for interface settings. If we don't have any, add -I dummy */
/* Because we probably don't want a GUI by default */
VLC_Init( i_vlc_id, argc, argv );
if( libvlc_InternalInit( p_libvlc_int, argc, argv ) )
RAISENULL( "VLC initialization failed" );
p_new->p_libvlc_int = p_libvlc_int;
p_new->p_playlist = (playlist_t *)vlc_object_find( p_new->p_libvlc_int,
VLC_OBJECT_PLAYLIST, FIND_CHILD );
p_new->p_vlm = NULL;
if( !p_new->p_playlist ) RAISENULL( "Playlist creation failed" );
p_new->i_vlc_id = i_vlc_id;
return p_new;
}
void libvlc_destroy( libvlc_instance_t *p_instance )
{
if( p_instance->p_playlist )
vlc_object_release( p_instance->p_playlist );
vlc_object_release( p_instance->p_libvlc_int );
VLC_CleanUp( p_instance->i_vlc_id );
VLC_Destroy( p_instance->i_vlc_id );
libvlc_InternalCleanup( p_instance->p_libvlc_int );
libvlc_InternalDestroy( p_instance->p_libvlc_int, VLC_FALSE );
}
int libvlc_get_vlc_id( libvlc_instance_t *p_instance )
{
return p_instance->i_vlc_id;
return p_instance->p_libvlc_int->i_object_id;
}
......@@ -28,34 +28,36 @@
#include <assert.h>
#define PL p_instance->p_libvlc_int->p_playlist
void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
int i_options, char **ppsz_options,
libvlc_exception_t *p_e )
{
assert( p_instance->p_playlist );
assert( PL );
///\todo Handle additionnal options
if( p_instance->p_playlist->i_size == 0 ) RAISEVOID( "Empty playlist" );
if( PL->i_size == 0 ) RAISEVOID( "Empty playlist" );
if( i_id > 0 )
{
playlist_item_t *p_item = playlist_ItemGetById( p_instance->p_playlist,
playlist_item_t *p_item = playlist_ItemGetById( PL,
i_id );
if( !p_item ) RAISEVOID( "Unable to find item" );
playlist_LockControl( p_instance->p_playlist, PLAYLIST_VIEWPLAY,
p_instance->p_playlist->status.p_node, p_item );
playlist_LockControl( PL, PLAYLIST_VIEWPLAY,
PL->status.p_node, p_item );
}
else
{
playlist_Play( p_instance->p_playlist );
playlist_Play( PL );
}
}
void libvlc_playlist_pause( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
assert( p_instance->p_playlist );
if( playlist_Pause( p_instance->p_playlist ) != VLC_SUCCESS )
assert( PL );
if( playlist_Pause( PL ) != VLC_SUCCESS )
RAISEVOID( "Empty playlist" );
}
......@@ -63,30 +65,30 @@ void libvlc_playlist_pause( libvlc_instance_t *p_instance,
void libvlc_playlist_stop( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
assert( p_instance->p_playlist );
if( playlist_Stop( p_instance->p_playlist ) != VLC_SUCCESS )
assert( PL );
if( playlist_Stop( PL ) != VLC_SUCCESS )
RAISEVOID( "Empty playlist" );
}
void libvlc_playlist_clear( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
assert( p_instance->p_playlist );
playlist_Clear( p_instance->p_playlist );
assert( PL );
playlist_Clear( PL );
}
void libvlc_playlist_next( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
assert( p_instance->p_playlist );
if( playlist_Next( p_instance->p_playlist ) != VLC_SUCCESS )
assert( PL );
if( playlist_Next( PL ) != VLC_SUCCESS )
RAISEVOID( "Empty playlist" );
}
void libvlc_playlist_prev( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
if( playlist_Prev( p_instance->p_playlist ) != VLC_SUCCESS )
if( playlist_Prev( PL ) != VLC_SUCCESS )
RAISEVOID( "Empty playlist" );
}
......@@ -102,8 +104,8 @@ int libvlc_playlist_add_extended( libvlc_instance_t *p_instance,
int i_options, const char **ppsz_options,
libvlc_exception_t *p_e )
{
assert( p_instance->p_playlist );
return playlist_PlaylistAddExt( p_instance->p_playlist, psz_uri, psz_name,
assert( PL );
return playlist_PlaylistAddExt( PL, psz_uri, psz_name,
PLAYLIST_INSERT, PLAYLIST_END, -1, ppsz_options,
i_options );
}
......@@ -111,43 +113,43 @@ int libvlc_playlist_add_extended( libvlc_instance_t *p_instance,
int libvlc_playlist_delete_item( libvlc_instance_t *p_instance, int i_id,
libvlc_exception_t *p_e )
{
assert( p_instance->p_playlist );
return playlist_DeleteFromItemId( p_instance->p_playlist, i_id );
assert( PL );
return playlist_DeleteFromItemId( PL, i_id );
}
int libvlc_playlist_isplaying( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
assert( p_instance->p_playlist );
return playlist_IsPlaying( p_instance->p_playlist );
assert( PL );
return playlist_IsPlaying( PL );
}
int libvlc_playlist_items_count( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
assert( p_instance->p_playlist );
return p_instance->p_playlist->i_size;
assert( PL );
return PL->i_size;
}
libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
libvlc_input_t *p_input;
assert( p_instance->p_playlist );
assert( PL );
vlc_mutex_lock( &p_instance->p_playlist->object_lock );
if( p_instance->p_playlist->p_input == NULL )
vlc_mutex_lock( &PL->object_lock );
if( PL->p_input == NULL )
{
libvlc_exception_raise( p_e, "No active input" );
vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
vlc_mutex_unlock( &PL->object_lock );
return NULL;
}
p_input = (libvlc_input_t *)malloc( sizeof( libvlc_input_t ) );
p_input->i_input_id = p_instance->p_playlist->p_input->i_object_id;
p_input->i_input_id = PL->p_input->i_object_id;
p_input->p_instance = p_instance;
vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
vlc_mutex_unlock( &PL->object_lock );
return p_input;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment