Commit 241b2280 authored by Olivier Aubert's avatar Olivier Aubert

python bindings: update to the new libvlc and mediacontrol API.

Objects have been renamed (vlc.MediaPlayer/vlc.Media) to match the current API.
parent 66fc0016
API not yet implemented (from svn rev. 24237)
---------------------------------------------
VLC_PUBLIC_API libvlc_media_descriptor_t * libvlc_media_descriptor_new_as_node(
libvlc_instance_t *p_instance,
const char * psz_name,
libvlc_exception_t *p_e );
VLC_PUBLIC_API libvlc_tag_t
libvlc_media_descriptor_tag_at_index_for_key( libvlc_media_descriptor_t *p_md,
int i,
const char * key,
libvlc_exception_t *p_e );
VLC_PUBLIC_API libvlc_media_list_t *
libvlc_media_descriptor_subitems( libvlc_media_descriptor_t *p_md,
libvlc_exception_t *p_e );
VLC_PUBLIC_API libvlc_event_manager_t *
libvlc_media_descriptor_event_manager( libvlc_media_descriptor_t * p_md,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_descriptor_set_user_data( libvlc_media_descriptor_t * p_md,
void * p_new_user_data,
libvlc_exception_t * p_e);
VLC_PUBLIC_API void *
libvlc_media_descriptor_get_user_data( libvlc_media_descriptor_t * p_md,
libvlc_exception_t * p_e);
/** Get the Event Manager from which the media instance send event.
* \param p_mi the Media Instance
*/
VLC_PUBLIC_API libvlc_event_manager_t * libvlc_media_instance_event_manager ( libvlc_media_instance_t *, libvlc_exception_t * );
/*****************************************************************************
* Tag Query
*****************************************************************************/
/** defgroup libvlc_tag_query Tag Query
* \ingroup libvlc
* LibVLC Tag query
* @{
*/
VLC_PUBLIC_API libvlc_tag_query_t *
libvlc_tag_query_new( libvlc_instance_t *, libvlc_exception_t * );
VLC_PUBLIC_API void
libvlc_tag_query_release( libvlc_tag_query_t * );
VLC_PUBLIC_API void
libvlc_tag_query_retain( libvlc_tag_query_t * );
VLC_PUBLIC_API void
libvlc_tag_query_set_match_tag_and_key( libvlc_tag_query_t * p_q,
libvlc_tag_t tag,
char * psz_tag_key,
libvlc_exception_t * );
VLC_PUBLIC_API vlc_bool_t
libvlc_tag_query_match( libvlc_tag_query_t *, libvlc_media_descriptor_t *,
libvlc_exception_t * );
/** @} */
/*****************************************************************************
* Media List
*****************************************************************************/
/** defgroup libvlc_media_list MediaList
* \ingroup libvlc
* LibVLC Media List
* @{
*/
VLC_PUBLIC_API libvlc_media_list_t *
libvlc_media_list_new( libvlc_instance_t *, libvlc_exception_t * );
VLC_PUBLIC_API void
libvlc_media_list_release( libvlc_media_list_t * );
VLC_PUBLIC_API void
libvlc_media_list_retain( libvlc_media_list_t * );
VLC_PUBLIC_API void
libvlc_media_list_add_file_content( libvlc_media_list_t * p_mlist,
const char * psz_uri,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_set_media_descriptor( libvlc_media_list_t *,
libvlc_media_descriptor_t *,
libvlc_exception_t *);
VLC_PUBLIC_API libvlc_media_descriptor_t *
libvlc_media_list_media_descriptor( libvlc_media_list_t *,
libvlc_exception_t *);
VLC_PUBLIC_API void
libvlc_media_list_add_media_descriptor( libvlc_media_list_t *,
libvlc_media_descriptor_t *,
libvlc_exception_t * );
VLC_PUBLIC_API void
libvlc_media_list_insert_media_descriptor( libvlc_media_list_t *,
libvlc_media_descriptor_t *,
int,
libvlc_exception_t * );
VLC_PUBLIC_API void
libvlc_media_list_remove_index( libvlc_media_list_t *, int,
libvlc_exception_t * );
VLC_PUBLIC_API int
libvlc_media_list_count( libvlc_media_list_t * p_mlist,
libvlc_exception_t * p_e );
VLC_PUBLIC_API libvlc_media_descriptor_t *
libvlc_media_list_item_at_index( libvlc_media_list_t *, int,
libvlc_exception_t * );
VLC_PUBLIC_API int
libvlc_media_list_index_of_item( libvlc_media_list_t *,
libvlc_media_descriptor_t *,
libvlc_exception_t * );
/* This indicates if this media list is read-only from a user point of view */
VLC_PUBLIC_API vlc_bool_t
libvlc_media_list_is_readonly( libvlc_media_list_t * p_mlist );
VLC_PUBLIC_API void
libvlc_media_list_lock( libvlc_media_list_t * );
VLC_PUBLIC_API void
libvlc_media_list_unlock( libvlc_media_list_t * );
VLC_PUBLIC_API libvlc_media_list_view_t *
libvlc_media_list_flat_view( libvlc_media_list_t *,
libvlc_exception_t * );
VLC_PUBLIC_API libvlc_media_list_view_t *
libvlc_media_list_hierarchical_view( libvlc_media_list_t *,
libvlc_exception_t * );
VLC_PUBLIC_API libvlc_media_list_view_t *
libvlc_media_list_hierarchical_node_view( libvlc_media_list_t *,
libvlc_exception_t * );
VLC_PUBLIC_API libvlc_event_manager_t *
libvlc_media_list_event_manager( libvlc_media_list_t *,
libvlc_exception_t * );
/** @} */
/*****************************************************************************
* Media List View
*****************************************************************************/
/** defgroup libvlc_media_list_view MediaListView
* \ingroup libvlc
* LibVLC Media List View
* @{ */
VLC_PUBLIC_API void
libvlc_media_list_view_retain( libvlc_media_list_view_t * p_mlv );
VLC_PUBLIC_API void
libvlc_media_list_view_release( libvlc_media_list_view_t * p_mlv );
VLC_PUBLIC_API libvlc_event_manager_t *
libvlc_media_list_view_event_manager( libvlc_media_list_view_t * p_mlv );
VLC_PUBLIC_API int
libvlc_media_list_view_count( libvlc_media_list_view_t * p_mlv,
libvlc_exception_t * p_e );
VLC_PUBLIC_API libvlc_media_descriptor_t *
libvlc_media_list_view_item_at_index( libvlc_media_list_view_t * p_mlv,
int index,
libvlc_exception_t * p_e );
VLC_PUBLIC_API libvlc_media_list_view_t *
libvlc_media_list_view_children_at_index( libvlc_media_list_view_t * p_mlv,
int index,
libvlc_exception_t * p_e );
VLC_PUBLIC_API int
libvlc_media_list_view_index_of_item( libvlc_media_list_view_t * p_mlv,
libvlc_media_descriptor_t * p_md,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_view_insert_at_index( libvlc_media_list_view_t * p_mlv,
libvlc_media_descriptor_t * p_md,
int index,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_view_remove_at_index( libvlc_media_list_view_t * p_mlv,
int index,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_view_add_item( libvlc_media_list_view_t * p_mlv,
libvlc_media_descriptor_t * p_md,
libvlc_exception_t * p_e );
VLC_PUBLIC_API libvlc_media_list_t *
libvlc_media_list_view_parent_media_list( libvlc_media_list_view_t * p_mlv,
libvlc_exception_t * p_e );
/** @} */
/*****************************************************************************
* Dynamic Media List (Deprecated)
*****************************************************************************/
/** defgroup libvlc_media_list MediaList
* \ingroup libvlc
* LibVLC Media List
* @{ */
VLC_PUBLIC_API libvlc_dynamic_media_list_t *
libvlc_dynamic_media_list_new( libvlc_media_list_t * p_mlist,
libvlc_tag_query_t * p_query,
libvlc_tag_t tag,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_dynamic_media_list_release( libvlc_dynamic_media_list_t * p_dmlist );
VLC_PUBLIC_API void
libvlc_dynamic_media_list_retain( libvlc_dynamic_media_list_t * p_dmlist );
libvlc_media_list_t *
libvlc_dynamic_media_list_media_list( libvlc_dynamic_media_list_t * p_dmlist,
libvlc_exception_t * p_e );
/** @} */
/*****************************************************************************
* Media Library
*****************************************************************************/
/** defgroup libvlc_media_library Media Library
* \ingroup libvlc
* LibVLC Media Library
* @{
*/
VLC_PUBLIC_API libvlc_media_library_t *
libvlc_media_library_new( libvlc_instance_t * p_inst,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_library_release( libvlc_media_library_t * p_mlib );
VLC_PUBLIC_API void
libvlc_media_library_retain( libvlc_media_library_t * p_mlib );
VLC_PUBLIC_API void
libvlc_media_library_load( libvlc_media_library_t * p_mlib,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_library_save( libvlc_media_library_t * p_mlib,
libvlc_exception_t * p_e );
VLC_PUBLIC_API libvlc_media_list_t *
libvlc_media_library_media_list( libvlc_media_library_t * p_mlib,
libvlc_exception_t * p_e );
/** @} */
/*****************************************************************************
* Media List Player
*****************************************************************************/
/** defgroup libvlc_media_list_player MediaListPlayer
* \ingroup libvlc
* LibVLC Media List Player
* @{
*/
VLC_PUBLIC_API libvlc_media_list_player_t *
libvlc_media_list_player_new( libvlc_instance_t * p_instance,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_player_release( libvlc_media_list_player_t * p_mlp );
VLC_PUBLIC_API void
libvlc_media_list_player_set_media_instance(
libvlc_media_list_player_t * p_mlp,
libvlc_media_instance_t * p_mi,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_player_set_media_list(
libvlc_media_list_player_t * p_mlp,
libvlc_media_list_t * p_mlist,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_player_play( libvlc_media_list_player_t * p_mlp,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_player_pause( libvlc_media_list_player_t * p_mlp,
libvlc_exception_t * p_e );
VLC_PUBLIC_API vlc_bool_t
libvlc_media_list_player_is_playing( libvlc_media_list_player_t * p_mlp,
libvlc_exception_t * p_e );
VLC_PUBLIC_API libvlc_state_t
libvlc_media_list_player_get_state( libvlc_media_list_player_t * p_mlp,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_player_play_item_at_index(
libvlc_media_list_player_t * p_mlp,
int i_index,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_player_play_item(
libvlc_media_list_player_t * p_mlp,
libvlc_media_descriptor_t * p_md,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_player_stop( libvlc_media_list_player_t * p_mlp,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_player_next( libvlc_media_list_player_t * p_mlp,
libvlc_exception_t * p_e );
/** @} */
/**
* Get current crop filter geometry
* \param p_input the input
* \param p_exception an initialized exception
* \return the crop filter geometry
*/
VLC_PUBLIC_API char *libvlc_video_get_crop_geometry( libvlc_media_instance_t *, libvlc_exception_t * );
/**
* Set new crop filter geometry
* \param p_input the input
* \param psz_geometry new crop filter geometry
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_video_set_crop_geometry( libvlc_media_instance_t *, char *, libvlc_exception_t * );
/**
* Toggle teletext transparent status on video output
* \param p_input the input
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_toggle_teletext( libvlc_media_instance_t *, libvlc_exception_t * );
/**
* Get current teletext page requested.
* \param p_input the input
* \param p_exception an initialized exception
* \return the current teletext page requested.
*/
VLC_PUBLIC_API int libvlc_video_get_teletext( libvlc_media_instance_t *, libvlc_exception_t * );
/**
* Set new teletext page to retrieve
* \param p_input the input
* \param i_page teletex page number requested
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_video_set_teletext( libvlc_media_instance_t *, int, libvlc_exception_t * );
/**
* Take a snapshot of the current video window
* If i_width AND i_height is 0, original size is used
* if i_width XOR i_height is 0, original aspect-ratio is preserved
* \param p_input the input
* \param psz_filepath the path where to save the screenshot to
* \param i_width the snapshot's width
* \param i_height the snapshot's height
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_video_take_snapshot( libvlc_media_instance_t *, char *,unsigned int, unsigned int, libvlc_exception_t * );
/**
* Tell windowless video output to redraw rectangular area (MacOS X only)
* \param p_instance libvlc instance
* \param area coordinates within video drawable
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_video_redraw_rectangle( libvlc_media_instance_t *, const libvlc_rectangle_t *, libvlc_exception_t * );
* Set the default video output viewport for a windowless video output (MacOS X only)
* this settings will be used as default for all video outputs
* \param p_instance libvlc instance
* \param view coordinates within video drawable
* \param clip coordinates within video drawable
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_video_set_viewport( libvlc_instance_t *, const libvlc_rectangle_t *, const libvlc_rectangle_t *, libvlc_exception_t * );
/** @} */
/**
* Get number of available audio tracks
* \param p_mi media instance
* \param p_e an initialized exception
* \return the number of available audio tracks (int)
*/
VLC_PUBLIC_API int libvlc_audio_get_track_count( libvlc_media_instance_t *, libvlc_exception_t * );
/**
+ * Get current audio track
+ * \param p_input input instance
+ * \param p_exception an initialized exception
+ * \return the audio track (int)
+ */
VLC_PUBLIC_API int libvlc_audio_get_track( libvlc_media_instance_t *, libvlc_exception_t * );
/**
* Set current audio track
* \param p_input input instance
* \param i_track the track (int)
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_audio_set_track( libvlc_media_instance_t *, int, libvlc_exception_t * );
/*****************************************************************************
* Services/Media Discovery
*****************************************************************************/
/** defgroup libvlc_media_discoverer Media Discoverer
* \ingroup libvlc
* LibVLC Media Discoverer
* @{
*/
VLC_PUBLIC_API libvlc_media_discoverer_t *
libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
const char * psz_name,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void libvlc_media_discoverer_release( libvlc_media_discoverer_t * p_mdis );
VLC_PUBLIC_API char * libvlc_media_discoverer_localized_name( libvlc_media_discoverer_t * p_mdis );
VLC_PUBLIC_API libvlc_media_list_t * libvlc_media_discoverer_media_list( libvlc_media_discoverer_t * p_mdis );
VLC_PUBLIC_API libvlc_event_manager_t *
libvlc_media_discoverer_event_manager( libvlc_media_discoverer_t * p_mdis );
VLC_PUBLIC_API vlc_bool_t
libvlc_media_discoverer_is_running( libvlc_media_discoverer_t * p_mdis );
/*****************************************************************************
* Message log handling
*****************************************************************************/
/** defgroup libvlc_log Log
* \ingroup libvlc
* LibVLC Message Logging
* @{
*/
/**
* Returns the VLC messaging verbosity level
* \param p_instance libvlc instance
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API unsigned libvlc_get_log_verbosity( const libvlc_instance_t *p_instance,
libvlc_exception_t *p_e );
/**
* Set the VLC messaging verbosity level
* \param p_log libvlc log instance
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, unsigned level,
libvlc_exception_t *p_e );
/**
* Open an instance to VLC message log
* \param p_instance libvlc instance
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API libvlc_log_t *libvlc_log_open( libvlc_instance_t *, libvlc_exception_t *);
/**
* Close an instance of VLC message log
* \param p_log libvlc log instance
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API void libvlc_log_close( libvlc_log_t *, libvlc_exception_t *);
/**
* Returns the number of messages in log
* \param p_log libvlc log instance
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API unsigned libvlc_log_count( const libvlc_log_t *, libvlc_exception_t *);
/**
* Clear all messages in log
* the log should be cleared on a regular basis to avoid clogging
* \param p_log libvlc log instance
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API void libvlc_log_clear( libvlc_log_t *, libvlc_exception_t *);
/**
* Allocate and returns a new iterator to messages in log
* \param p_log libvlc log instance
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *, libvlc_exception_t *);
/**
* Releases a previoulsy allocated iterator
* \param p_log libvlc log iterator
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API void libvlc_log_iterator_free( libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e );
/**
* Returns whether log iterator has more messages
* \param p_log libvlc log iterator
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e );
/**
* Returns next log message
* the content of message must not be freed
* \param p_log libvlc log iterator
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
struct libvlc_log_message_t *buffer,
libvlc_exception_t *p_e );
/** @} */
/*****************************************************************************
* Event handling
*****************************************************************************/
/** defgroup libvlc_callbacks Callbacks
* \ingroup libvlc
* LibVLC Events
* @{
*/
/**
* Register for an event notification
* \param p_event_manager the event manager to which you want to attach to
* Generally it is obtained by vlc_my_object_event_manager() where my_object
* Is the object you want to listen to.
* \param i_event_type the desired event to which we want to listen
* \param f_callback the function to call when i_event_type occurs
* \param user_data user provided data to carry with the event
* \param p_e an initialized exception pointer
*/
VLC_PUBLIC_API void libvlc_event_attach( libvlc_event_manager_t *p_event_manager,
libvlc_event_type_t i_event_type,
libvlc_callback_t f_callback,
void *user_data,
libvlc_exception_t *p_e );
/**
* Unregister an event notification
* \param p_event_manager the event manager
* \param i_event_type the desired event to which we want to unregister
* \param f_callback the function to call when i_event_type occurs
* \param p_e an initialized exception pointer
*/
VLC_PUBLIC_API void libvlc_event_detach( libvlc_event_manager_t *p_event_manager,
libvlc_event_type_t i_event_type,
libvlc_callback_t f_callback,
void *p_user_data,
libvlc_exception_t *p_e );
/**
* Get an event type name
* \param i_event_type the desired event
*/
VLC_PUBLIC_API const char * libvlc_event_type_name( libvlc_event_type_t event_type );
...@@ -80,7 +80,8 @@ vlcInstance_new( PyTypeObject *type, PyObject *args, PyObject *kwds ) ...@@ -80,7 +80,8 @@ vlcInstance_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
char** ppsz_args = NULL; char** ppsz_args = NULL;
int i_size = 0; int i_size = 0;
if( PyArg_ParseTuple( args, "O", &py_list ) ) fprintf(stderr, "Instancianting\n");
if( PyArg_ParseTuple( args, "|O", &py_list ) )
{ {
i_size = pyoptions_to_args( py_list, &ppsz_args ); i_size = pyoptions_to_args( py_list, &ppsz_args );
if( i_size < 0 ) if( i_size < 0 )
...@@ -119,211 +120,19 @@ vlcInstance_get_vlc_id( PyObject *self, PyObject *args ) ...@@ -119,211 +120,19 @@ vlcInstance_get_vlc_id( PyObject *self, PyObject *args )
return Py_BuildValue( "i", libvlc_get_vlc_id( LIBVLC_INSTANCE->p_instance ) ); return Py_BuildValue( "i", libvlc_get_vlc_id( LIBVLC_INSTANCE->p_instance ) );
} }
/* Set loop variable */
static PyObject * static PyObject *
vlcInstance_playlist_loop( PyObject *self, PyObject *args ) vlcInstance_new_media_player( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_loop = 0; libvlc_media_player_t *p_mp;
vlcMediaPlayer *p_ret;
if( !PyArg_ParseTuple( args, "i", &i_loop ) )
return NULL;
LIBVLC_TRY;
libvlc_playlist_loop( LIBVLC_INSTANCE->p_instance, i_loop, &ex );
LIBVLC_EXCEPT;
Py_INCREF( Py_None );
return Py_None;
}
/* Playlist play. 2 parameters: i_id, the id to play
l_options: a list of options */
static PyObject *
vlcInstance_playlist_play( PyObject *self, PyObject *args )
{
libvlc_exception_t ex;
int i_id = -1;
PyObject *py_options = NULL;
int i_size = 0;
char** ppsz_args = NULL;
if( !PyArg_ParseTuple( args, "|iO", &i_id, &py_options ) )
return NULL;
if( py_options )
{
i_size = pyoptions_to_args( py_options, &ppsz_args );
}
LIBVLC_TRY;
libvlc_playlist_play( LIBVLC_INSTANCE->p_instance, i_id, i_size, ppsz_args, &ex );
free_args( i_size, ppsz_args );
LIBVLC_EXCEPT;
Py_INCREF( Py_None );
return Py_None;
}
static PyObject *
vlcInstance_playlist_pause( PyObject *self, PyObject *args )
{
libvlc_exception_t ex;
LIBVLC_TRY;
libvlc_playlist_pause( LIBVLC_INSTANCE->p_instance, &ex );
LIBVLC_EXCEPT;
Py_INCREF( Py_None );
return Py_None;
}
static PyObject *
vlcInstance_playlist_isplaying( PyObject *self, PyObject *args )
{
libvlc_exception_t ex;
int i_ret;
LIBVLC_TRY;
i_ret = libvlc_playlist_isplaying( LIBVLC_INSTANCE->p_instance, &ex );
LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret );
}
static PyObject *
vlcInstance_playlist_items_count( PyObject *self, PyObject *args )
{
libvlc_exception_t ex;
int i_ret;
LIBVLC_TRY;
i_ret = libvlc_playlist_items_count( LIBVLC_INSTANCE->p_instance, &ex );
LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret );
}
static PyObject *
vlcInstance_playlist_stop( PyObject *self, PyObject *args )
{
libvlc_exception_t ex;
LIBVLC_TRY;
libvlc_playlist_stop( LIBVLC_INSTANCE->p_instance, &ex );
LIBVLC_EXCEPT;
Py_INCREF( Py_None );
return Py_None;
}
static PyObject *
vlcInstance_playlist_next( PyObject *self, PyObject *args )
{
libvlc_exception_t ex;
LIBVLC_TRY;
libvlc_playlist_next( LIBVLC_INSTANCE->p_instance, &ex );
LIBVLC_EXCEPT;
Py_INCREF( Py_None );
return Py_None;
}
static PyObject *
vlcInstance_playlist_prev( PyObject *self, PyObject *args )
{
libvlc_exception_t ex;
LIBVLC_TRY;
libvlc_playlist_prev( LIBVLC_INSTANCE->p_instance, &ex );
LIBVLC_EXCEPT;
Py_INCREF( Py_None );
return Py_None;
}
static PyObject *
vlcInstance_playlist_clear( PyObject *self, PyObject *args )
{
libvlc_exception_t ex;
LIBVLC_TRY;
libvlc_playlist_clear( LIBVLC_INSTANCE->p_instance, &ex );
LIBVLC_EXCEPT;
Py_INCREF( Py_None );
return Py_None;
}
/* Add a playlist item. Main parameter: URI.
Optional parameters: name, options */
static PyObject *
vlcInstance_playlist_add( PyObject *self, PyObject *args)
{
libvlc_exception_t ex;
int i_ret;
char* psz_uri = NULL;
char* psz_name = NULL;
PyObject *py_options = NULL;
int i_size = 0;
char** ppsz_args = NULL;
if( !PyArg_ParseTuple( args, "s|sO", &psz_uri, &psz_name, &py_options ) )
return NULL;
if( !psz_name )
{
/* Set a default name */
psz_name = strdup( psz_uri );
}
if( py_options )
{
i_size = pyoptions_to_args( py_options, &ppsz_args );
}
LIBVLC_TRY;
if( ppsz_args )
{
i_ret = libvlc_playlist_add_extended( LIBVLC_INSTANCE->p_instance,
psz_uri,
psz_name,
i_size,
ppsz_args,
&ex );
free_args( i_size, ppsz_args );
}
else
{
i_ret = libvlc_playlist_add( LIBVLC_INSTANCE->p_instance,
psz_uri,
psz_name,
&ex );
}
LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret );
}
static PyObject *
vlcInstance_playlist_delete_item( PyObject *self, PyObject *args )
{
libvlc_exception_t ex;
int i_id;
int i_ret;
if( !PyArg_ParseTuple( args, "i", &i_id ) )
return NULL;
LIBVLC_TRY;
i_ret = libvlc_playlist_delete_item( LIBVLC_INSTANCE->p_instance, i_id, &ex );
LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret );
}
static PyObject *
vlcInstance_playlist_get_media_player( PyObject *self, PyObject *args )
{
libvlc_exception_t ex;
libvlc_media_player_t *p_mi;
vlcMediaInstance *p_ret;
LIBVLC_TRY; LIBVLC_TRY;
p_mi = libvlc_playlist_get_media_player( LIBVLC_INSTANCE->p_instance, &ex ); p_mp = libvlc_media_player_new( LIBVLC_INSTANCE->p_instance, &ex );
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
p_ret = PyObject_New( vlcMediaInstance, &vlcMediaInstance_Type ); p_ret = PyObject_New( vlcMediaPlayer, &vlcMediaPlayer_Type );
p_ret->p_mi = p_mi; p_ret->p_mp = p_mp;
Py_INCREF( p_ret ); /* Ah bon ? */ Py_INCREF( p_ret ); /* Ah bon ? */
return ( PyObject * )p_ret; return ( PyObject * )p_ret;
} }
...@@ -733,19 +542,19 @@ static PyObject * ...@@ -733,19 +542,19 @@ static PyObject *
vlcInstance_media_new( PyObject *self, PyObject *args ) vlcInstance_media_new( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_media_t *p_md; libvlc_media_t *p_media;
char* psz_mrl = NULL; char* psz_mrl = NULL;
vlcMediaDescriptor *p_ret; vlcMedia *p_ret;
if( !PyArg_ParseTuple( args, "s", &psz_mrl ) ) if( !PyArg_ParseTuple( args, "s", &psz_mrl ) )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
p_md = libvlc_media_new( LIBVLC_INSTANCE->p_instance, psz_mrl, &ex ); p_media = libvlc_media_new( LIBVLC_INSTANCE->p_instance, psz_mrl, &ex );
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
p_ret = PyObject_New( vlcMediaDescriptor, &vlcMediaDescriptor_Type ); p_ret = PyObject_New( vlcMedia, &vlcMedia_Type );
p_ret->p_md = p_md; p_ret->p_media = p_media;
Py_INCREF( p_ret ); /* Ah bon ? */ Py_INCREF( p_ret ); /* Ah bon ? */
return ( PyObject * )p_ret; return ( PyObject * )p_ret;
} }
...@@ -753,55 +562,34 @@ vlcInstance_media_new( PyObject *self, PyObject *args ) ...@@ -753,55 +562,34 @@ vlcInstance_media_new( PyObject *self, PyObject *args )
/* Method table */ /* Method table */
static PyMethodDef vlcInstance_methods[] = static PyMethodDef vlcInstance_methods[] =
{ {
{ "get_vlc_id", vlcInstance_get_vlc_id, METH_VARARGS, { "get_vlc_id", vlcInstance_get_vlc_id, METH_NOARGS,
"get_vlc_id( ) -> int Get the instance id."}, "get_vlc_id( ) -> int Get the instance id."},
{ "playlist_loop", vlcInstance_playlist_loop, METH_VARARGS,
"playlist_loop(bool) Set loop variable" },
{ "playlist_play", vlcInstance_playlist_play, METH_VARARGS,
"playlist_play(id=int, options=list) Play the given playlist item (-1 for current item) with optional options (a list of strings)" },
{ "playlist_pause", vlcInstance_playlist_pause, METH_VARARGS,
"playlist_pause() Pause the current stream"},
{ "playlist_isplaying", vlcInstance_playlist_isplaying, METH_VARARGS,
"playlist_isplaying() -> int Return True if the playlist if playing"},
{ "playlist_items_count", vlcInstance_playlist_items_count, METH_VARARGS,
"playlist_items_count() -> int Return the number of items in the playlist"},
{ "playlist_stop", vlcInstance_playlist_stop, METH_VARARGS,
"playlist_stop() Stop the current stream"},
{ "playlist_next", vlcInstance_playlist_next, METH_VARARGS,
"playlist_next() Play the next item"},
{ "playlist_prev", vlcInstance_playlist_prev, METH_VARARGS,
"playlist_prev() Play the previous item"},
{ "playlist_clear", vlcInstance_playlist_clear, METH_VARARGS,
"playlist_clear() Clear the playlist"},
{ "playlist_add", vlcInstance_playlist_add, METH_VARARGS,
"playlist_add(mrl=str, name=str, options=list) -> int Add a new item to the playlist. options is a list of strings."},
{ "playlist_delete_item", vlcInstance_playlist_delete_item, METH_VARARGS,
"playlist_delete_item(id=int) Delete the given item"},
{ "playlist_get_media_player", vlcInstance_playlist_get_media_player, METH_VARARGS,
"playlist_get_media_player() -> object Return the current media instance"},
{ "video_set_parent", vlcInstance_video_set_parent, METH_VARARGS, { "video_set_parent", vlcInstance_video_set_parent, METH_VARARGS,
"video_set_parent(xid=int) Set the parent xid/HWND/CGrafPort"}, "video_set_parent(xid=int) Set the parent xid/HWND/CGrafPort"},
{ "video_get_parent", vlcInstance_video_get_parent, METH_VARARGS, { "video_get_parent", vlcInstance_video_get_parent, METH_NOARGS,
"video_get_parent(xid=int) Get the parent xid/HWND/CGrafPort"}, "video_get_parent() -> int Get the parent xid/HWND/CGrafPort"},
{ "video_set_size", vlcInstance_video_set_size, METH_VARARGS, { "video_set_size", vlcInstance_video_set_size, METH_VARARGS,
"video_set_size(width=int, height=int) Set the video width and height"}, "video_set_size(width=int, height=int) Set the video width and height"},
{ "audio_toggle_mute", vlcInstance_audio_toggle_mute, METH_VARARGS, { "audio_toggle_mute", vlcInstance_audio_toggle_mute, METH_NOARGS,
"audio_toggle_mute() Toggle the mute state"}, "audio_toggle_mute() Toggle the mute state"},
{ "audio_get_mute", vlcInstance_audio_get_mute, METH_VARARGS, { "audio_get_mute", vlcInstance_audio_get_mute, METH_NOARGS,
"audio_get_mute() -> int Get the mute state"}, "audio_get_mute() -> int Get the mute state"},
{ "audio_set_mute", vlcInstance_audio_set_mute, METH_VARARGS, { "audio_set_mute", vlcInstance_audio_set_mute, METH_VARARGS,
"audio_set_mute(state=int) Set the mute state"}, "audio_set_mute(state=int) Set the mute state"},
{ "audio_get_volume", vlcInstance_audio_get_volume, METH_VARARGS, { "audio_get_volume", vlcInstance_audio_get_volume, METH_NOARGS,
"audio_get_volume() -> int Get the audio volume"}, "audio_get_volume() -> int Get the audio volume"},
{ "audio_set_volume", vlcInstance_audio_set_volume, METH_VARARGS, { "audio_set_volume", vlcInstance_audio_set_volume, METH_VARARGS,
"audio_set_volume(volume=int) Set the audio volume"}, "audio_set_volume(volume=int) Set the audio volume"},
{ "audio_get_channel", vlcInstance_audio_get_channel, METH_VARARGS, { "audio_get_channel", vlcInstance_audio_get_channel, METH_NOARGS,
"audio_get_channel() -> int Get current audio channel" }, "audio_get_channel() -> int Get current audio channel" },
{ "audio_set_channel", vlcInstance_audio_set_channel, METH_VARARGS, { "audio_set_channel", vlcInstance_audio_set_channel, METH_VARARGS,
"audio_set_channel(int) Set current audio channel" }, "audio_set_channel(int) Set current audio channel" },
{ "media_new", vlcInstance_media_new, METH_VARARGS, { "media_new", vlcInstance_media_new, METH_VARARGS,
"media_new(str) -> object Create a media descriptor with the given mrl."}, "media_new(str) -> object Create a media object with the given mrl."},
{ "mediaplayer_new", vlcInstance_new_media_player, METH_NOARGS,
"mediaplayer_new() -> object Create a media player."},
{ "vlm_add_broadcast", vlcInstance_vlm_add_broadcast, METH_VARARGS | METH_KEYWORDS, { "vlm_add_broadcast", vlcInstance_vlm_add_broadcast, METH_VARARGS | METH_KEYWORDS,
"vlm_add_broadcast(name=str, input=str, output=str, options=list, enable=int, loop=int) Add a new broadcast" }, "vlm_add_broadcast(name=str, input=str, output=str, options=list, enable=int, loop=int) Add a new broadcast" },
...@@ -856,7 +644,7 @@ static PyTypeObject vlcInstance_Type = ...@@ -856,7 +644,7 @@ static PyTypeObject vlcInstance_Type =
0, /*tp_setattro*/ 0, /*tp_setattro*/
0, /*tp_as_buffer*/ 0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
"VLC Instance(args)\n\nNote: if args is specified, the first arg is interpreted as an executable name to get the directory of the VLC plugins.", /* tp_doc */ "VLC Instance(args)", /* tp_doc */
0, /* tp_traverse */ 0, /* tp_traverse */
0, /* tp_clear */ 0, /* tp_clear */
0, /* tp_richcompare */ 0, /* tp_richcompare */
......
/***************************************************************************** /*****************************************************************************
* vlc_mediadescriptor.c: vlc.MediaDescriptor binding * vlc_media.c: vlc.Media binding
***************************************************************************** *****************************************************************************
* Copyright (C) 2007 the VideoLAN team * Copyright (C) 2007 the VideoLAN team
* $Id$ * $Id$
...@@ -23,18 +23,26 @@ ...@@ -23,18 +23,26 @@
#include "vlcglue.h" #include "vlcglue.h"
/*********************************************************************** /***********************************************************************
* vlc.MediaDescriptor * vlc.Media
***********************************************************************/ ***********************************************************************/
static PyObject *
vlcMedia_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
{
fprintf(stderr, "vlcMedia_new called\n");
PyErr_SetString( PyExc_TypeError, "vlc.Media can be instanciated by itself. You should use vlc.Instance().media_new(mrl)." );
return NULL;
}
static void static void
vlcMediaDescriptor_dealloc( PyObject *self ) vlcMedia_dealloc( PyObject *self )
{ {
libvlc_media_release( LIBVLC_MEDIADESCRIPTOR->p_md ); libvlc_media_release( LIBVLC_MEDIA->p_media );
PyObject_DEL( self ); PyObject_DEL( self );
} }
static PyObject * static PyObject *
vlcMediaDescriptor_add_option( PyObject *self, PyObject *args ) vlcMedia_add_option( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
char* psz_options = NULL; char* psz_options = NULL;
...@@ -43,21 +51,21 @@ vlcMediaDescriptor_add_option( PyObject *self, PyObject *args ) ...@@ -43,21 +51,21 @@ vlcMediaDescriptor_add_option( PyObject *self, PyObject *args )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_media_add_option( LIBVLC_MEDIADESCRIPTOR->p_md, psz_options, &ex); libvlc_media_add_option( LIBVLC_MEDIA->p_media, psz_options, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
vlcMediaDescriptor_get_mrl( PyObject *self, PyObject *args ) vlcMedia_get_mrl( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
char * psz_mrl; char * psz_mrl;
PyObject * o_ret; PyObject * o_ret;
LIBVLC_TRY; LIBVLC_TRY;
psz_mrl = libvlc_media_get_mrl( LIBVLC_MEDIADESCRIPTOR->p_md, &ex); psz_mrl = libvlc_media_get_mrl( LIBVLC_MEDIA->p_media, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
o_ret = Py_BuildValue( "s", psz_mrl ); o_ret = Py_BuildValue( "s", psz_mrl );
...@@ -66,109 +74,59 @@ vlcMediaDescriptor_get_mrl( PyObject *self, PyObject *args ) ...@@ -66,109 +74,59 @@ vlcMediaDescriptor_get_mrl( PyObject *self, PyObject *args )
} }
static PyObject * static PyObject *
vlcMediaDescriptor_get_state( PyObject *self, PyObject *args ) vlcMedia_get_state( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_state_t i_state; libvlc_state_t i_state;
LIBVLC_TRY; LIBVLC_TRY;
i_state = libvlc_media_get_state( LIBVLC_MEDIADESCRIPTOR->p_md, &ex); i_state = libvlc_media_get_state( LIBVLC_MEDIA->p_media, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
/* FIXME: return the defined state constant */ /* FIXME: return the defined state constant */
return Py_BuildValue( "i", i_state ); return Py_BuildValue( "i", i_state );
} }
static PyObject * static PyObject *
vlcMediaDescriptor_add_tag( PyObject *self, PyObject *args ) vlcMedia_get_duration( PyObject *self, PyObject *args )
{
libvlc_exception_t ex;
char* psz_key;
char* psz_tag;
if( !PyArg_ParseTuple( args, "ss", &psz_key, &psz_tag ) )
return NULL;
LIBVLC_TRY;
libvlc_media_add_tag( LIBVLC_MEDIADESCRIPTOR->p_md, psz_key, ( libvlc_tag_t )psz_tag, &ex );
LIBVLC_EXCEPT;
Py_INCREF( Py_None );
return Py_None;
}
static PyObject *
vlcMediaDescriptor_remove_tag( PyObject *self, PyObject *args )
{
libvlc_exception_t ex;
char* psz_key;
char* psz_tag;
if( !PyArg_ParseTuple( args, "ss", &psz_key, &psz_tag ) )
return NULL;
LIBVLC_TRY;
libvlc_media_remove_tag( LIBVLC_MEDIADESCRIPTOR->p_md, psz_key, ( libvlc_tag_t )psz_tag, &ex );
LIBVLC_EXCEPT;
Py_INCREF( Py_None );
return Py_None;
}
static PyObject *
vlcMediaDescriptor_tags_count_for_key( PyObject *self, PyObject *args )
{
libvlc_exception_t ex;
char* psz_tag;
int i_ret;
if( !PyArg_ParseTuple( args, "s", &psz_tag ) )
return NULL;
LIBVLC_TRY;
i_ret=libvlc_media_tags_count_for_key( LIBVLC_MEDIADESCRIPTOR->p_md, psz_tag, &ex );
LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret );
}
static PyObject *
vlcMediaDescriptor_get_duration( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_time_t i_ret; libvlc_time_t i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_media_get_duration( LIBVLC_MEDIADESCRIPTOR->p_md, &ex); i_ret = libvlc_media_get_duration( LIBVLC_MEDIA->p_media, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "L", i_ret ); return Py_BuildValue( "L", i_ret );
} }
static PyObject * static PyObject *
vlcMediaDescriptor_media_player_new( PyObject *self, PyObject *args ) vlcMedia_media_player_new( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_media_player_t *p_mi; libvlc_media_player_t *p_mp;
vlcMediaInstance *p_ret; vlcMediaPlayer *p_ret;
LIBVLC_TRY; LIBVLC_TRY;
p_mi = libvlc_media_player_new_from_media( LIBVLC_MEDIADESCRIPTOR->p_md, &ex); p_mp = libvlc_media_player_new_from_media( LIBVLC_MEDIA->p_media, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
p_ret = PyObject_New( vlcMediaInstance, &vlcMediaInstance_Type ); p_ret = PyObject_New( vlcMediaPlayer, &vlcMediaPlayer_Type );
p_ret->p_mi = p_mi; p_ret->p_mp = p_mp;
Py_INCREF( p_ret ); /* Ah bon ? */ Py_INCREF( p_ret ); /* Ah bon ? */
return ( PyObject * )p_ret; return ( PyObject * )p_ret;
} }
static PyObject * static PyObject *
vlcMediaDescriptor_is_preparsed( PyObject *self, PyObject *args ) vlcMedia_is_preparsed( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_ret; int i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_media_is_preparsed( LIBVLC_MEDIADESCRIPTOR->p_md, &ex); i_ret = libvlc_media_is_preparsed( LIBVLC_MEDIA->p_media, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "L", i_ret ); return Py_BuildValue( "L", i_ret );
} }
static PyObject * static PyObject *
vlcMediaDescriptor_get_meta( PyObject *self, PyObject *args ) vlcMedia_get_meta( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
char * psz_meta = NULL; char * psz_meta = NULL;
...@@ -197,7 +155,7 @@ vlcMediaDescriptor_get_meta( PyObject *self, PyObject *args ) ...@@ -197,7 +155,7 @@ vlcMediaDescriptor_get_meta( PyObject *self, PyObject *args )
} }
LIBVLC_TRY; LIBVLC_TRY;
psz_ret = libvlc_media_get_meta( LIBVLC_MEDIADESCRIPTOR->p_md, i_index, &ex); psz_ret = libvlc_media_get_meta( LIBVLC_MEDIA->p_media, i_index, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
o_ret = Py_BuildValue( "s", psz_ret ); o_ret = Py_BuildValue( "s", psz_ret );
...@@ -205,40 +163,34 @@ vlcMediaDescriptor_get_meta( PyObject *self, PyObject *args ) ...@@ -205,40 +163,34 @@ vlcMediaDescriptor_get_meta( PyObject *self, PyObject *args )
return o_ret; return o_ret;
} }
static PyMethodDef vlcMediaDescriptor_methods[] = static PyMethodDef vlcMedia_methods[] =
{ {
{ "add_option", vlcMediaDescriptor_add_option, METH_VARARGS, { "add_option", vlcMedia_add_option, METH_VARARGS,
"add_option(str) Add an option to the media descriptor." }, "add_option(str) Add an option to the media." },
{ "get_mrl", vlcMediaDescriptor_get_mrl, METH_VARARGS, { "get_mrl", vlcMedia_get_mrl, METH_VARARGS,
"get_mrl() -> str" }, "get_mrl() -> str" },
{ "get_state", vlcMediaDescriptor_get_state, METH_VARARGS, { "get_state", vlcMedia_get_state, METH_VARARGS,
"get_state() -> int" }, "get_state() -> int" },
{ "add_tag", vlcMediaDescriptor_add_tag, METH_VARARGS, { "get_duration", vlcMedia_get_duration, METH_VARARGS,
"add_tag(key=str, tag=str) Add tag to the media descriptor." },
{ "remove_tag", vlcMediaDescriptor_remove_tag, METH_VARARGS,
"remove_tag(key=str, tag=str) Remove tag from the media descriptor." },
{ "tags_count_for_key", vlcMediaDescriptor_tags_count_for_key, METH_VARARGS,
"tags_count_for_key(str) ." },
{ "get_duration", vlcMediaDescriptor_get_duration, METH_VARARGS,
"get_duration() -> int" }, "get_duration() -> int" },
{ "mediainstance_new", vlcMediaDescriptor_media_player_new, METH_VARARGS, { "mediaplayer_new", vlcMedia_media_player_new, METH_VARARGS,
"mediainstance_new() -> vlc.MediaInstance Create a Media Instance object from a Media Descriptor" }, "mediaplayer_new() -> vlc.MediaPlayer Create a MediaPlayer object from a Media" },
{ "is_preparsed", vlcMediaDescriptor_is_preparsed, METH_VARARGS, { "is_preparsed", vlcMedia_is_preparsed, METH_VARARGS,
"is_preparsed() -> int" }, "is_preparsed() -> int" },
{ "get_meta", vlcMediaDescriptor_get_meta, METH_VARARGS, { "get_meta", vlcMedia_get_meta, METH_VARARGS,
"get_meta(str) -> str Read the meta of the media descriptor." }, "get_meta(str) -> str Read the meta of the media." },
{ NULL } /* Sentinel */ { NULL } /* Sentinel */
}; };
static PyTypeObject vlcMediaDescriptor_Type = static PyTypeObject vlcMedia_Type =
{ {
PyObject_HEAD_INIT( NULL ) PyObject_HEAD_INIT( NULL )
0, /*ob_size*/ 0, /*ob_size*/
"vlc.MediaDescriptor", /*tp_name*/ "vlc.Media", /*tp_name*/
sizeof( vlcMediaDescriptor_Type ), /*tp_basicsize*/ sizeof( vlcMedia_Type ), /*tp_basicsize*/
0, /*tp_itemsize*/ 0, /*tp_itemsize*/
vlcMediaDescriptor_dealloc, /*tp_dealloc*/ vlcMedia_dealloc, /*tp_dealloc*/
0, /*tp_print*/ 0, /*tp_print*/
0, /*tp_getattr*/ 0, /*tp_getattr*/
0, /*tp_setattr*/ 0, /*tp_setattr*/
...@@ -254,14 +206,14 @@ static PyTypeObject vlcMediaDescriptor_Type = ...@@ -254,14 +206,14 @@ static PyTypeObject vlcMediaDescriptor_Type =
0, /*tp_setattro*/ 0, /*tp_setattro*/
0, /*tp_as_buffer*/ 0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
"vlc.MediaDescriptor object.", /* tp_doc */ "vlc.Media object.", /* tp_doc */
0, /* tp_traverse */ 0, /* tp_traverse */
0, /* tp_clear */ 0, /* tp_clear */
0, /* tp_richcompare */ 0, /* tp_richcompare */
0, /* tp_weaklistoffset */ 0, /* tp_weaklistoffset */
0, /* tp_iter */ 0, /* tp_iter */
0, /* tp_iternext */ 0, /* tp_iternext */
vlcMediaDescriptor_methods, /* tp_methods */ vlcMedia_methods, /* tp_methods */
0, /* tp_members */ 0, /* tp_members */
0, /* tp_getset */ 0, /* tp_getset */
0, /* tp_base */ 0, /* tp_base */
...@@ -271,6 +223,6 @@ static PyTypeObject vlcMediaDescriptor_Type = ...@@ -271,6 +223,6 @@ static PyTypeObject vlcMediaDescriptor_Type =
0, /* tp_dictoffset */ 0, /* tp_dictoffset */
0, /* tp_init */ 0, /* tp_init */
0, /* tp_alloc */ 0, /* tp_alloc */
0, /* tp_new */ vlcMedia_new, /* tp_new */
}; };
...@@ -40,6 +40,7 @@ MediaControl_new( PyTypeObject *type, PyObject *args, PyObject *kwds ) ...@@ -40,6 +40,7 @@ MediaControl_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
self = PyObject_New( MediaControl, &MediaControl_Type ); self = PyObject_New( MediaControl, &MediaControl_Type );
fprintf (stderr, "Instanciating mediacontrol\n");
if( PyArg_ParseTuple( args, "O", &py_param ) ) if( PyArg_ParseTuple( args, "O", &py_param ) )
{ {
if( PyObject_TypeCheck( py_param, &vlcInstance_Type ) == 1 ) if( PyObject_TypeCheck( py_param, &vlcInstance_Type ) == 1 )
...@@ -108,6 +109,7 @@ MediaControl_new( PyTypeObject *type, PyObject *args, PyObject *kwds ) ...@@ -108,6 +109,7 @@ MediaControl_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
static void static void
MediaControl_dealloc( PyObject *self ) MediaControl_dealloc( PyObject *self )
{ {
fprintf(stderr, "MC dealloc\n");
Py_DECREF( SELF->vlc_instance ); Py_DECREF( SELF->vlc_instance );
PyObject_DEL( self ); PyObject_DEL( self );
} }
...@@ -122,6 +124,17 @@ MediaControl_get_vlc_instance( PyObject *self, PyObject *args ) ...@@ -122,6 +124,17 @@ MediaControl_get_vlc_instance( PyObject *self, PyObject *args )
return ( PyObject * )p_ret; return ( PyObject * )p_ret;
} }
static PyObject *
MediaControl_get_mediaplayer( PyObject *self, PyObject *args )
{
vlcMediaPlayer *p_ret;
p_ret = PyObject_New( vlcMediaPlayer, &vlcMediaPlayer_Type );
p_ret->p_mp = mediacontrol_get_media_player( SELF->mc );
Py_INCREF( p_ret );
return ( PyObject * )p_ret;
}
/** /**
* Return the current position in the stream. The returned value can * Return the current position in the stream. The returned value can
be relative or absolute ( according to PositionOrigin ) and the unit be relative or absolute ( according to PositionOrigin ) and the unit
...@@ -215,24 +228,11 @@ MediaControl_start( PyObject *self, PyObject *args ) ...@@ -215,24 +228,11 @@ MediaControl_start( PyObject *self, PyObject *args )
static PyObject * static PyObject *
MediaControl_pause( PyObject *self, PyObject *args ) MediaControl_pause( PyObject *self, PyObject *args )
{ {
mediacontrol_Position *a_position;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
PyObject *py_pos;
if( !PyArg_ParseTuple( args, "O", &py_pos ) )
{
/* No argument. Use a default 0 value. */
PyErr_Clear( );
py_pos = NULL;
}
a_position = position_py_to_c( py_pos );
if( !a_position )
return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
MC_TRY; MC_TRY;
mediacontrol_pause( SELF->mc, a_position, exception ); mediacontrol_pause( SELF->mc, exception );
free( a_position );
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
MC_EXCEPT; MC_EXCEPT;
...@@ -243,24 +243,11 @@ MediaControl_pause( PyObject *self, PyObject *args ) ...@@ -243,24 +243,11 @@ MediaControl_pause( PyObject *self, PyObject *args )
static PyObject * static PyObject *
MediaControl_resume( PyObject *self, PyObject *args ) MediaControl_resume( PyObject *self, PyObject *args )
{ {
mediacontrol_Position *a_position;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
PyObject *py_pos;
if( !PyArg_ParseTuple( args, "O", &py_pos ) )
{
/* No argument. Use a default 0 value. */
PyErr_Clear( );
py_pos = NULL;
}
a_position = position_py_to_c( py_pos );
if( !a_position )
return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
MC_TRY; MC_TRY;
mediacontrol_start( SELF->mc, a_position, exception ); mediacontrol_resume( SELF->mc, exception );
free( a_position );
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
MC_EXCEPT; MC_EXCEPT;
...@@ -271,24 +258,11 @@ MediaControl_resume( PyObject *self, PyObject *args ) ...@@ -271,24 +258,11 @@ MediaControl_resume( PyObject *self, PyObject *args )
static PyObject * static PyObject *
MediaControl_stop( PyObject *self, PyObject *args ) MediaControl_stop( PyObject *self, PyObject *args )
{ {
mediacontrol_Position *a_position;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
PyObject *py_pos;
if( !PyArg_ParseTuple( args, "O", &py_pos ) )
{
/* No argument. Use a default 0 value. */
PyErr_Clear( );
py_pos = NULL;
}
a_position = position_py_to_c( py_pos );
if( !a_position )
return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
MC_TRY; MC_TRY;
mediacontrol_stop( SELF->mc, a_position, exception ); mediacontrol_stop( SELF->mc, exception );
free( a_position );
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
MC_EXCEPT; MC_EXCEPT;
...@@ -305,7 +279,7 @@ MediaControl_exit( PyObject *self, PyObject *args ) ...@@ -305,7 +279,7 @@ MediaControl_exit( PyObject *self, PyObject *args )
} }
static PyObject * static PyObject *
MediaControl_playlist_add_item( PyObject *self, PyObject *args ) MediaControl_set_mrl( PyObject *self, PyObject *args )
{ {
char *psz_file; char *psz_file;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
...@@ -315,7 +289,7 @@ MediaControl_playlist_add_item( PyObject *self, PyObject *args ) ...@@ -315,7 +289,7 @@ MediaControl_playlist_add_item( PyObject *self, PyObject *args )
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
MC_TRY; MC_TRY;
mediacontrol_playlist_add_item( SELF->mc, psz_file, exception ); mediacontrol_set_mrl( SELF->mc, psz_file, exception );
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
MC_EXCEPT; MC_EXCEPT;
...@@ -324,50 +298,23 @@ MediaControl_playlist_add_item( PyObject *self, PyObject *args ) ...@@ -324,50 +298,23 @@ MediaControl_playlist_add_item( PyObject *self, PyObject *args )
} }
static PyObject * static PyObject *
MediaControl_playlist_clear( PyObject *self, PyObject *args ) MediaControl_get_mrl( PyObject *self, PyObject *args )
{
mediacontrol_Exception *exception = NULL;
Py_BEGIN_ALLOW_THREADS
MC_TRY;
mediacontrol_playlist_clear( SELF->mc, exception );
Py_END_ALLOW_THREADS
MC_EXCEPT;
Py_INCREF( Py_None );
return Py_None;
}
static PyObject *
MediaControl_playlist_get_list( PyObject *self, PyObject *args )
{ {
PyObject *py_retval; PyObject *py_retval;
char* psz_file;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
mediacontrol_PlaylistSeq* pl;
Py_ssize_t i_index;
Py_ssize_t i_playlist_size;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
MC_TRY; MC_TRY;
pl = mediacontrol_playlist_get_list( SELF->mc, exception ); psz_file = mediacontrol_get_mrl( SELF->mc, exception );
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
MC_EXCEPT; MC_EXCEPT;
i_playlist_size = pl->size; py_retval = Py_BuildValue( "s", psz_file );
free( psz_file );
py_retval = PyList_New( i_playlist_size );
for ( i_index = 0 ; i_index < i_playlist_size ; i_index++ )
{
PyList_SetItem( py_retval, i_index,
Py_BuildValue( "s", pl->data[i_index] ) );
}
mediacontrol_PlaylistSeq__free( pl );
return py_retval; return py_retval;
} }
static PyObject * static PyObject *
MediaControl_snapshot( PyObject *self, PyObject *args ) MediaControl_snapshot( PyObject *self, PyObject *args )
{ {
...@@ -603,7 +550,9 @@ MediaControl_set_visual( PyObject *self, PyObject *args ) ...@@ -603,7 +550,9 @@ MediaControl_set_visual( PyObject *self, PyObject *args )
static PyMethodDef MediaControl_methods[] = static PyMethodDef MediaControl_methods[] =
{ {
{ "get_vlc_instance", MediaControl_get_vlc_instance, METH_VARARGS, { "get_vlc_instance", MediaControl_get_vlc_instance, METH_VARARGS,
"get_vlc_instance( ) -> Instance Get matching vlc.Instance." }, "get_vlc_instance( ) -> Instance Get embedded vlc.Instance." },
{ "get_mediaplayer", MediaControl_get_mediaplayer, METH_VARARGS,
"get_mediaplayer( ) -> MediaPlayer Get embedded vlc.MediaPlayer." },
{ "get_media_position", MediaControl_get_media_position, METH_VARARGS, { "get_media_position", MediaControl_get_media_position, METH_VARARGS,
"get_media_position( origin, key ) -> Position Get current media position." }, "get_media_position( origin, key ) -> Position Get current media position." },
{ "set_media_position", MediaControl_set_media_position, METH_VARARGS, { "set_media_position", MediaControl_set_media_position, METH_VARARGS,
...@@ -618,12 +567,10 @@ static PyMethodDef MediaControl_methods[] = ...@@ -618,12 +567,10 @@ static PyMethodDef MediaControl_methods[] =
"stop( Position ) Stop the player" }, "stop( Position ) Stop the player" },
{ "exit", MediaControl_exit, METH_VARARGS, { "exit", MediaControl_exit, METH_VARARGS,
"exit( ) Exit the player" }, "exit( ) Exit the player" },
{ "playlist_add_item", MediaControl_playlist_add_item, METH_VARARGS, { "set_mrl", MediaControl_set_mrl, METH_VARARGS,
"playlist_add_item( str ) Add an item to the playlist" }, "set_mrl( str ) Set the file to be played" },
{ "playlist_get_list", MediaControl_playlist_get_list, METH_VARARGS, { "get_mrl", MediaControl_get_mrl, METH_VARARGS,
"playlist_get_list( ) -> list Get the contents of the playlist" }, "get_mrl( ) -> str Get the played file" },
{ "playlist_clear", MediaControl_playlist_clear, METH_VARARGS,
"clear( ) Clear the playlist." },
{ "snapshot", MediaControl_snapshot, METH_VARARGS, { "snapshot", MediaControl_snapshot, METH_VARARGS,
"snapshot( Position ) -> dict Take a snapshot" }, "snapshot( Position ) -> dict Take a snapshot" },
{ "display_text", MediaControl_display_text, METH_VARARGS, { "display_text", MediaControl_display_text, METH_VARARGS,
......
/***************************************************************************** /*****************************************************************************
* vlc_input.c: vlc.Input binding * vlc_mediaplayer.c: vlc.MediaPlayer binding
***************************************************************************** *****************************************************************************
* Copyright (C) 2006 the VideoLAN team * Copyright (C) 2006 the VideoLAN team
* $Id$ * $Id$
...@@ -27,29 +27,29 @@ ...@@ -27,29 +27,29 @@
***********************************************************************/ ***********************************************************************/
static PyObject * static PyObject *
vlcMediaInstance_get_length( PyObject *self, PyObject *args ) vlcMediaPlayer_get_length( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
vlc_int64_t i_ret; vlc_int64_t i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_media_player_get_length( LIBVLC_MEDIAINSTANCE->p_mi, &ex); i_ret = libvlc_media_player_get_length( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "L", i_ret ); return Py_BuildValue( "L", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_get_time( PyObject *self, PyObject *args ) vlcMediaPlayer_get_time( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
vlc_int64_t i_ret; vlc_int64_t i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_media_player_get_time( LIBVLC_MEDIAINSTANCE->p_mi, &ex); i_ret = libvlc_media_player_get_time( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "L", i_ret ); return Py_BuildValue( "L", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_set_time( PyObject *self, PyObject *args ) vlcMediaPlayer_set_time( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
vlc_int64_t i_time; vlc_int64_t i_time;
...@@ -58,25 +58,25 @@ vlcMediaInstance_set_time( PyObject *self, PyObject *args ) ...@@ -58,25 +58,25 @@ vlcMediaInstance_set_time( PyObject *self, PyObject *args )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_media_player_set_time( LIBVLC_MEDIAINSTANCE->p_mi, i_time, &ex); libvlc_media_player_set_time( LIBVLC_MEDIAPLAYER->p_mp, i_time, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
vlcMediaInstance_get_position( PyObject *self, PyObject *args ) vlcMediaPlayer_get_position( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
float f_ret; float f_ret;
LIBVLC_TRY; LIBVLC_TRY;
f_ret = libvlc_media_player_get_position( LIBVLC_MEDIAINSTANCE->p_mi, &ex); f_ret = libvlc_media_player_get_position( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "f", f_ret ); return Py_BuildValue( "f", f_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_set_position( PyObject *self, PyObject *args ) vlcMediaPlayer_set_position( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
float f_pos; float f_pos;
...@@ -85,36 +85,36 @@ vlcMediaInstance_set_position( PyObject *self, PyObject *args ) ...@@ -85,36 +85,36 @@ vlcMediaInstance_set_position( PyObject *self, PyObject *args )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_media_player_set_position( LIBVLC_MEDIAINSTANCE->p_mi, f_pos, &ex); libvlc_media_player_set_position( LIBVLC_MEDIAPLAYER->p_mp, f_pos, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
vlcMediaInstance_will_play( PyObject *self, PyObject *args ) vlcMediaPlayer_will_play( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_ret; int i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_media_player_will_play( LIBVLC_MEDIAINSTANCE->p_mi, &ex); i_ret = libvlc_media_player_will_play( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret ); return Py_BuildValue( "i", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_get_rate( PyObject *self, PyObject *args ) vlcMediaPlayer_get_rate( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
float f_ret; float f_ret;
LIBVLC_TRY; LIBVLC_TRY;
f_ret = libvlc_media_player_get_rate( LIBVLC_MEDIAINSTANCE->p_mi, &ex); f_ret = libvlc_media_player_get_rate( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "f", f_ret ); return Py_BuildValue( "f", f_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_set_rate( PyObject *self, PyObject *args ) vlcMediaPlayer_set_rate( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
float f_rate; float f_rate;
...@@ -123,59 +123,59 @@ vlcMediaInstance_set_rate( PyObject *self, PyObject *args ) ...@@ -123,59 +123,59 @@ vlcMediaInstance_set_rate( PyObject *self, PyObject *args )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_media_player_set_rate( LIBVLC_MEDIAINSTANCE->p_mi, f_rate, &ex); libvlc_media_player_set_rate( LIBVLC_MEDIAPLAYER->p_mp, f_rate, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
vlcMediaInstance_get_state( PyObject *self, PyObject *args ) vlcMediaPlayer_get_state( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_ret; int i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_media_player_get_state( LIBVLC_MEDIAINSTANCE->p_mi, &ex); i_ret = libvlc_media_player_get_state( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret ); return Py_BuildValue( "i", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_has_vout( PyObject *self, PyObject *args ) vlcMediaPlayer_has_vout( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_ret; int i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_media_player_has_vout( LIBVLC_MEDIAINSTANCE->p_mi, &ex); i_ret = libvlc_media_player_has_vout( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret ); return Py_BuildValue( "i", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_get_fps( PyObject *self, PyObject *args ) vlcMediaPlayer_get_fps( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
float f_ret; float f_ret;
LIBVLC_TRY; LIBVLC_TRY;
f_ret = libvlc_media_player_get_fps( LIBVLC_MEDIAINSTANCE->p_mi, &ex); f_ret = libvlc_media_player_get_fps( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "f", f_ret ); return Py_BuildValue( "f", f_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_audio_get_track( PyObject *self, PyObject *args ) vlcMediaPlayer_audio_get_track( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_ret; int i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_audio_get_track( LIBVLC_MEDIAINSTANCE->p_mi, &ex ); i_ret = libvlc_audio_get_track( LIBVLC_MEDIAPLAYER->p_mp, &ex );
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret ); return Py_BuildValue( "i", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_audio_set_track( PyObject *self, PyObject *args ) vlcMediaPlayer_audio_set_track( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_track; int i_track;
...@@ -184,38 +184,38 @@ vlcMediaInstance_audio_set_track( PyObject *self, PyObject *args ) ...@@ -184,38 +184,38 @@ vlcMediaInstance_audio_set_track( PyObject *self, PyObject *args )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_audio_set_track( LIBVLC_MEDIAINSTANCE->p_mi, i_track, &ex ); libvlc_audio_set_track( LIBVLC_MEDIAPLAYER->p_mp, i_track, &ex );
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
vlcMediaInstance_get_chapter( PyObject *self, PyObject *args ) vlcMediaPlayer_get_chapter( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_ret; int i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_media_player_get_chapter( LIBVLC_MEDIAINSTANCE->p_mi, &ex ); i_ret = libvlc_media_player_get_chapter( LIBVLC_MEDIAPLAYER->p_mp, &ex );
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret ); return Py_BuildValue( "i", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_get_chapter_count( PyObject *self, PyObject *args ) vlcMediaPlayer_get_chapter_count( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_ret; int i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_media_player_get_chapter_count( LIBVLC_MEDIAINSTANCE->p_mi, &ex ); i_ret = libvlc_media_player_get_chapter_count( LIBVLC_MEDIAPLAYER->p_mp, &ex );
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret ); return Py_BuildValue( "i", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_set_chapter( PyObject *self, PyObject *args ) vlcMediaPlayer_set_chapter( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_chapter; int i_chapter;
...@@ -224,7 +224,7 @@ vlcMediaInstance_set_chapter( PyObject *self, PyObject *args ) ...@@ -224,7 +224,7 @@ vlcMediaInstance_set_chapter( PyObject *self, PyObject *args )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_media_player_set_chapter( LIBVLC_MEDIAINSTANCE->p_mi, i_chapter, &ex ); libvlc_media_player_set_chapter( LIBVLC_MEDIAPLAYER->p_mp, i_chapter, &ex );
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
...@@ -232,19 +232,19 @@ vlcMediaInstance_set_chapter( PyObject *self, PyObject *args ) ...@@ -232,19 +232,19 @@ vlcMediaInstance_set_chapter( PyObject *self, PyObject *args )
static PyObject * static PyObject *
vlcMediaInstance_toggle_fullscreen( PyObject *self, PyObject *args ) vlcMediaPlayer_toggle_fullscreen( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_toggle_fullscreen( LIBVLC_MEDIAINSTANCE->p_mi, &ex); libvlc_toggle_fullscreen( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
vlcMediaInstance_set_fullscreen( PyObject *self, PyObject *args ) vlcMediaPlayer_set_fullscreen( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_fullscreen; int i_fullscreen;
...@@ -253,57 +253,57 @@ vlcMediaInstance_set_fullscreen( PyObject *self, PyObject *args ) ...@@ -253,57 +253,57 @@ vlcMediaInstance_set_fullscreen( PyObject *self, PyObject *args )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_set_fullscreen( LIBVLC_MEDIAINSTANCE->p_mi, i_fullscreen, &ex); libvlc_set_fullscreen( LIBVLC_MEDIAPLAYER->p_mp, i_fullscreen, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
vlcMediaInstance_get_fullscreen( PyObject *self, PyObject *args ) vlcMediaPlayer_get_fullscreen( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_ret; int i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_get_fullscreen( LIBVLC_MEDIAINSTANCE->p_mi, &ex); i_ret = libvlc_get_fullscreen( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret ); return Py_BuildValue( "i", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_get_height( PyObject *self, PyObject *args ) vlcMediaPlayer_get_height( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_ret; int i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_video_get_height( LIBVLC_MEDIAINSTANCE->p_mi, &ex); i_ret = libvlc_video_get_height( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret ); return Py_BuildValue( "i", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_get_width( PyObject *self, PyObject *args ) vlcMediaPlayer_get_width( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_ret; int i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_video_get_width( LIBVLC_MEDIAINSTANCE->p_mi, &ex); i_ret = libvlc_video_get_width( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret ); return Py_BuildValue( "i", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_get_aspect_ratio( PyObject *self, PyObject *args ) vlcMediaPlayer_get_aspect_ratio( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
char* psz_ret; char* psz_ret;
PyObject* o_ret; PyObject* o_ret;
LIBVLC_TRY; LIBVLC_TRY;
psz_ret = libvlc_video_get_aspect_ratio( LIBVLC_MEDIAINSTANCE->p_mi, &ex); psz_ret = libvlc_video_get_aspect_ratio( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
o_ret=Py_BuildValue( "s", psz_ret ); o_ret=Py_BuildValue( "s", psz_ret );
free( psz_ret ); free( psz_ret );
...@@ -311,7 +311,7 @@ vlcMediaInstance_get_aspect_ratio( PyObject *self, PyObject *args ) ...@@ -311,7 +311,7 @@ vlcMediaInstance_get_aspect_ratio( PyObject *self, PyObject *args )
} }
static PyObject * static PyObject *
vlcMediaInstance_set_aspect_ratio( PyObject *self, PyObject *args ) vlcMediaPlayer_set_aspect_ratio( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
char* psz_ratio; char* psz_ratio;
...@@ -320,7 +320,7 @@ vlcMediaInstance_set_aspect_ratio( PyObject *self, PyObject *args ) ...@@ -320,7 +320,7 @@ vlcMediaInstance_set_aspect_ratio( PyObject *self, PyObject *args )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_video_set_aspect_ratio( LIBVLC_MEDIAINSTANCE->p_mi, psz_ratio, &ex); libvlc_video_set_aspect_ratio( LIBVLC_MEDIAPLAYER->p_mp, psz_ratio, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
free( psz_ratio ); free( psz_ratio );
Py_INCREF( Py_None ); Py_INCREF( Py_None );
...@@ -328,7 +328,7 @@ vlcMediaInstance_set_aspect_ratio( PyObject *self, PyObject *args ) ...@@ -328,7 +328,7 @@ vlcMediaInstance_set_aspect_ratio( PyObject *self, PyObject *args )
} }
static PyObject * static PyObject *
vlcMediaInstance_video_take_snapshot( PyObject *self, PyObject *args ) vlcMediaPlayer_video_take_snapshot( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
char* psz_filename; char* psz_filename;
...@@ -337,14 +337,14 @@ vlcMediaInstance_video_take_snapshot( PyObject *self, PyObject *args ) ...@@ -337,14 +337,14 @@ vlcMediaInstance_video_take_snapshot( PyObject *self, PyObject *args )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_video_take_snapshot( LIBVLC_MEDIAINSTANCE->p_mi, psz_filename, 0, 0, &ex); libvlc_video_take_snapshot( LIBVLC_MEDIAPLAYER->p_mp, psz_filename, 0, 0, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
vlcMediaInstance_video_resize( PyObject *self, PyObject *args ) vlcMediaPlayer_video_resize( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_width; int i_width;
...@@ -354,14 +354,14 @@ vlcMediaInstance_video_resize( PyObject *self, PyObject *args ) ...@@ -354,14 +354,14 @@ vlcMediaInstance_video_resize( PyObject *self, PyObject *args )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_video_resize( LIBVLC_MEDIAINSTANCE->p_mi, i_width, i_height, &ex); libvlc_video_resize( LIBVLC_MEDIAPLAYER->p_mp, i_width, i_height, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
vlcMediaInstance_video_reparent( PyObject *self, PyObject *args ) vlcMediaPlayer_video_reparent( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
WINDOWHANDLE i_visual; WINDOWHANDLE i_visual;
...@@ -371,71 +371,71 @@ vlcMediaInstance_video_reparent( PyObject *self, PyObject *args ) ...@@ -371,71 +371,71 @@ vlcMediaInstance_video_reparent( PyObject *self, PyObject *args )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_video_reparent( LIBVLC_MEDIAINSTANCE->p_mi, i_visual, &ex); i_ret = libvlc_video_reparent( LIBVLC_MEDIAPLAYER->p_mp, i_visual, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret ); return Py_BuildValue( "i", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_is_seekable( PyObject *self, PyObject *args ) vlcMediaPlayer_is_seekable( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_ret; int i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_media_player_is_seekable( LIBVLC_MEDIAINSTANCE->p_mi, &ex); i_ret = libvlc_media_player_is_seekable( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret ); return Py_BuildValue( "i", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_can_pause( PyObject *self, PyObject *args ) vlcMediaPlayer_can_pause( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_ret; int i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_media_player_can_pause( LIBVLC_MEDIAINSTANCE->p_mi, &ex); i_ret = libvlc_media_player_can_pause( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret ); return Py_BuildValue( "i", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_play( PyObject *self, PyObject *args ) vlcMediaPlayer_play( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_media_player_play( LIBVLC_MEDIAINSTANCE->p_mi, &ex); libvlc_media_player_play( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
vlcMediaInstance_pause( PyObject *self, PyObject *args ) vlcMediaPlayer_pause( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_media_player_pause( LIBVLC_MEDIAINSTANCE->p_mi, &ex); libvlc_media_player_pause( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
vlcMediaInstance_stop( PyObject *self, PyObject *args ) vlcMediaPlayer_stop( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_media_player_stop( LIBVLC_MEDIAINSTANCE->p_mi, &ex); libvlc_media_player_stop( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
vlcMediaInstance_set_drawable( PyObject *self, PyObject *args ) vlcMediaPlayer_set_drawable( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_drawable; int i_drawable;
...@@ -444,7 +444,7 @@ vlcMediaInstance_set_drawable( PyObject *self, PyObject *args ) ...@@ -444,7 +444,7 @@ vlcMediaInstance_set_drawable( PyObject *self, PyObject *args )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_media_player_set_drawable( LIBVLC_MEDIAINSTANCE->p_mi, (libvlc_drawable_t) i_drawable, &ex ); libvlc_media_player_set_drawable( LIBVLC_MEDIAPLAYER->p_mp, (libvlc_drawable_t) i_drawable, &ex );
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
...@@ -452,66 +452,66 @@ vlcMediaInstance_set_drawable( PyObject *self, PyObject *args ) ...@@ -452,66 +452,66 @@ vlcMediaInstance_set_drawable( PyObject *self, PyObject *args )
} }
static PyObject * static PyObject *
vlcMediaInstance_set_media( PyObject *self, PyObject *args ) vlcMediaPlayer_set_media( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
PyObject* py_param = NULL; PyObject* py_param = NULL;
if( !PyArg_ParseTuple( args, "O", &py_param ) ) if( !PyArg_ParseTuple( args, "O", &py_param ) )
return NULL; return NULL;
if( PyObject_TypeCheck( py_param, &vlcMediaDescriptor_Type ) == 1 ) if( PyObject_TypeCheck( py_param, &vlcMedia_Type ) == 1 )
{ {
LIBVLC_TRY; LIBVLC_TRY;
libvlc_media_player_set_media( LIBVLC_MEDIAINSTANCE->p_mi, ((vlcMediaDescriptor*)py_param)->p_md, &ex ); libvlc_media_player_set_media( LIBVLC_MEDIAPLAYER->p_mp, ((vlcMedia*)py_param)->p_media, &ex );
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
} }
else else
{ {
PyObject *py_exc = vlc_Exception; PyObject *py_exc = vlc_Exception;
PyErr_SetString( py_exc, "vlc.MediaDescriptor parameter needed" ); PyErr_SetString( py_exc, "vlc.Media parameter needed" );
return NULL; return NULL;
} }
return NULL; return NULL;
} }
static PyObject * static PyObject *
vlcMediaInstance_get_media( PyObject *self, PyObject *args ) vlcMediaPlayer_get_media( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_media_t *p_md; libvlc_media_t *p_media;
vlcMediaDescriptor *p_ret; vlcMedia *p_ret;
LIBVLC_TRY; LIBVLC_TRY;
p_md = libvlc_media_player_get_media( LIBVLC_MEDIAINSTANCE->p_mi, &ex ); p_media = libvlc_media_player_get_media( LIBVLC_MEDIAPLAYER->p_mp, &ex );
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
if( !p_md ) if( !p_media )
{ {
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
else else
{ {
p_ret = PyObject_New( vlcMediaDescriptor, &vlcMediaDescriptor_Type ); p_ret = PyObject_New( vlcMedia, &vlcMedia_Type );
p_ret->p_md = p_md; p_ret->p_media = p_media;
Py_INCREF( p_ret ); /* Ah bon ? */ Py_INCREF( p_ret ); /* Ah bon ? */
return ( PyObject * )p_ret; return ( PyObject * )p_ret;
} }
} }
static PyObject * static PyObject *
vlcMediaInstance_get_spu( PyObject *self, PyObject *args ) vlcMediaPlayer_get_spu( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_ret; int i_ret;
LIBVLC_TRY; LIBVLC_TRY;
i_ret = libvlc_video_get_spu( LIBVLC_MEDIAINSTANCE->p_mi, &ex); i_ret = libvlc_video_get_spu( LIBVLC_MEDIAPLAYER->p_mp, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
return Py_BuildValue( "i", i_ret ); return Py_BuildValue( "i", i_ret );
} }
static PyObject * static PyObject *
vlcMediaInstance_set_spu( PyObject *self, PyObject *args ) vlcMediaPlayer_set_spu( PyObject *self, PyObject *args )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
int i_spu; int i_spu;
...@@ -520,101 +520,101 @@ vlcMediaInstance_set_spu( PyObject *self, PyObject *args ) ...@@ -520,101 +520,101 @@ vlcMediaInstance_set_spu( PyObject *self, PyObject *args )
return NULL; return NULL;
LIBVLC_TRY; LIBVLC_TRY;
libvlc_video_set_spu( LIBVLC_MEDIAINSTANCE->p_mi, i_spu, &ex); libvlc_video_set_spu( LIBVLC_MEDIAPLAYER->p_mp, i_spu, &ex);
LIBVLC_EXCEPT; LIBVLC_EXCEPT;
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyMethodDef vlcMediaInstance_methods[] = static PyMethodDef vlcMediaPlayer_methods[] =
{ {
{ "get_length", vlcMediaInstance_get_length, METH_VARARGS, { "get_length", vlcMediaPlayer_get_length, METH_VARARGS,
"get_length() -> long " }, "get_length() -> long " },
{ "get_time", vlcMediaInstance_get_time, METH_VARARGS, { "get_time", vlcMediaPlayer_get_time, METH_VARARGS,
"get_time() -> long" }, "get_time() -> long" },
{ "set_time", vlcMediaInstance_set_time, METH_VARARGS, { "set_time", vlcMediaPlayer_set_time, METH_VARARGS,
"set_time(long)" }, "set_time(long)" },
{ "get_position", vlcMediaInstance_get_position, METH_VARARGS, { "get_position", vlcMediaPlayer_get_position, METH_VARARGS,
"get_position() -> float" }, "get_position() -> float" },
{ "set_position", vlcMediaInstance_set_position, METH_VARARGS, { "set_position", vlcMediaPlayer_set_position, METH_VARARGS,
"set_position(float)" }, "set_position(float)" },
{ "will_play", vlcMediaInstance_will_play, METH_VARARGS, { "will_play", vlcMediaPlayer_will_play, METH_VARARGS,
"will_play() -> int" }, "will_play() -> int" },
{ "is_seekable", vlcMediaInstance_is_seekable, METH_VARARGS, { "is_seekable", vlcMediaPlayer_is_seekable, METH_VARARGS,
"is_seekable() -> int" }, "is_seekable() -> int" },
{ "can_pause", vlcMediaInstance_can_pause, METH_VARARGS, { "can_pause", vlcMediaPlayer_can_pause, METH_VARARGS,
"can_pause() -> int" }, "can_pause() -> int" },
{ "get_rate", vlcMediaInstance_get_rate, METH_VARARGS, { "get_rate", vlcMediaPlayer_get_rate, METH_VARARGS,
"get_rate() -> float" }, "get_rate() -> float" },
{ "set_rate", vlcMediaInstance_set_rate, METH_VARARGS, { "set_rate", vlcMediaPlayer_set_rate, METH_VARARGS,
"set_rate(float)" }, "set_rate(float)" },
{ "get_state", vlcMediaInstance_get_state, METH_VARARGS, { "get_state", vlcMediaPlayer_get_state, METH_VARARGS,
"get_state() -> int" }, "get_state() -> int" },
{ "has_vout", vlcMediaInstance_has_vout, METH_VARARGS, { "has_vout", vlcMediaPlayer_has_vout, METH_VARARGS,
"has_vout() -> int" }, "has_vout() -> int" },
{ "get_fps", vlcMediaInstance_get_fps, METH_VARARGS, { "get_fps", vlcMediaPlayer_get_fps, METH_VARARGS,
"get_fps() -> float" }, "get_fps() -> float" },
{ "audio_get_track", vlcMediaInstance_audio_get_track, METH_VARARGS, { "audio_get_track", vlcMediaPlayer_audio_get_track, METH_VARARGS,
"audio_get_track() -> int Get current audio track" }, "audio_get_track() -> int Get current audio track" },
{ "audio_set_track", vlcMediaInstance_audio_set_track, METH_VARARGS, { "audio_set_track", vlcMediaPlayer_audio_set_track, METH_VARARGS,
"audio_set_track(int) Set current audio track" }, "audio_set_track(int) Set current audio track" },
{ "toggle_fullscreen", vlcMediaInstance_toggle_fullscreen, METH_VARARGS, { "toggle_fullscreen", vlcMediaPlayer_toggle_fullscreen, METH_VARARGS,
"toggle_fullscreen() Toggle fullscreen status on video output" }, "toggle_fullscreen() Toggle fullscreen status on video output" },
{ "set_fullscreen", vlcMediaInstance_set_fullscreen, METH_VARARGS, { "set_fullscreen", vlcMediaPlayer_set_fullscreen, METH_VARARGS,
"set_fullscreen(bool) Enable or disable fullscreen on a video output" }, "set_fullscreen(bool) Enable or disable fullscreen on a video output" },
{ "get_fullscreen", vlcMediaInstance_get_fullscreen, METH_VARARGS, { "get_fullscreen", vlcMediaPlayer_get_fullscreen, METH_VARARGS,
"get_fullscreen() -> bool Get current fullscreen status" }, "get_fullscreen() -> bool Get current fullscreen status" },
{ "get_height", vlcMediaInstance_get_height, METH_VARARGS, { "get_height", vlcMediaPlayer_get_height, METH_VARARGS,
"get_height() -> int Get current video height" }, "get_height() -> int Get current video height" },
{ "get_width", vlcMediaInstance_get_width, METH_VARARGS, { "get_width", vlcMediaPlayer_get_width, METH_VARARGS,
"get_width() -> int Get current video width" }, "get_width() -> int Get current video width" },
{ "get_aspect_ratio", vlcMediaInstance_get_aspect_ratio, METH_VARARGS, { "get_aspect_ratio", vlcMediaPlayer_get_aspect_ratio, METH_VARARGS,
"get_aspect_ratio() -> str Get current video aspect ratio" }, "get_aspect_ratio() -> str Get current video aspect ratio" },
{ "set_aspect_ratio", vlcMediaInstance_set_aspect_ratio, METH_VARARGS, { "set_aspect_ratio", vlcMediaPlayer_set_aspect_ratio, METH_VARARGS,
"set_aspect_ratio(str) Set new video aspect ratio" }, "set_aspect_ratio(str) Set new video aspect ratio" },
{ "video_take_snapshot", vlcMediaInstance_video_take_snapshot, METH_VARARGS, { "video_take_snapshot", vlcMediaPlayer_video_take_snapshot, METH_VARARGS,
"video_take_snapshot(filename=str) Take a snapshot of the current video window" }, "video_take_snapshot(filename=str) Take a snapshot of the current video window" },
{ "video_resize", vlcMediaInstance_video_resize, METH_VARARGS, { "video_resize", vlcMediaPlayer_video_resize, METH_VARARGS,
"video_resize(width=int, height=int) Resize the current video output window" }, "video_resize(width=int, height=int) Resize the current video output window" },
{ "video_reparent", vlcMediaInstance_video_reparent, METH_VARARGS, { "video_reparent", vlcMediaPlayer_video_reparent, METH_VARARGS,
"video_reparent(visual=int) change the parent for the current video output" }, "video_reparent(visual=int) change the parent for the current video output" },
{ "play", vlcMediaInstance_play, METH_VARARGS, { "play", vlcMediaPlayer_play, METH_VARARGS,
"play() Play the media instance" }, "play() Play the media instance" },
{ "pause", vlcMediaInstance_pause, METH_VARARGS, { "pause", vlcMediaPlayer_pause, METH_VARARGS,
"pause() Pause the media instance" }, "pause() Pause the media instance" },
{ "stop", vlcMediaInstance_stop, METH_VARARGS, { "stop", vlcMediaPlayer_stop, METH_VARARGS,
"stop() Stop the media instance" }, "stop() Stop the media instance" },
{ "set_drawable", vlcMediaInstance_set_drawable, METH_VARARGS, { "set_drawable", vlcMediaPlayer_set_drawable, METH_VARARGS,
"set_drawable() Set the drawable id" }, "set_drawable() Set the drawable id" },
{ "get_chapter", vlcMediaInstance_get_chapter, METH_VARARGS, { "get_chapter", vlcMediaPlayer_get_chapter, METH_VARARGS,
"get_chapter() -> int Get current chapter" }, "get_chapter() -> int Get current chapter" },
{ "set_chapter", vlcMediaInstance_set_chapter, METH_VARARGS, { "set_chapter", vlcMediaPlayer_set_chapter, METH_VARARGS,
"set_chapter(int) Set current chapter" }, "set_chapter(int) Set current chapter" },
{ "get_chapter_count", vlcMediaInstance_get_chapter_count, METH_VARARGS, { "get_chapter_count", vlcMediaPlayer_get_chapter_count, METH_VARARGS,
"get_chapter_count() -> int Get current chapter count" }, "get_chapter_count() -> int Get current chapter count" },
{ "set_mediadescriptor", vlcMediaInstance_set_media, METH_VARARGS, { "set_media", vlcMediaPlayer_set_media, METH_VARARGS,
"set_mediadescriptor(vlc.MediaDescriptor) Set the media descriptor that will be used by the media_player" }, "set_media(vlc.Media) Set the media that will be used by the media_player" },
{ "get_mediadescriptor", vlcMediaInstance_get_media, METH_VARARGS, { "get_media", vlcMediaPlayer_get_media, METH_VARARGS,
"get_mediadescriptor() -> vlc.MediaDescriptor Get the media descriptor used by the media_player (if any)." }, "get_media() -> vlc.Media Get the media used by the media_player (if any)." },
{ "get_spu", vlcMediaInstance_get_spu, METH_VARARGS, { "get_spu", vlcMediaPlayer_get_spu, METH_VARARGS,
"get_spu() -> int Get current video subtitle" }, "get_spu() -> int Get current video subtitle" },
{ "set_spu", vlcMediaInstance_set_spu, METH_VARARGS, { "set_spu", vlcMediaPlayer_set_spu, METH_VARARGS,
"set_spu(int) Set new video subtitle" }, "set_spu(int) Set new video subtitle" },
{ NULL } /* Sentinel */ { NULL } /* Sentinel */
}; };
static PyTypeObject vlcMediaInstance_Type = static PyTypeObject vlcMediaPlayer_Type =
{ {
PyObject_HEAD_INIT( NULL ) PyObject_HEAD_INIT( NULL )
0, /*ob_size*/ 0, /*ob_size*/
"vlc.MediaInstance", /*tp_name*/ "vlc.MediaPlayer", /*tp_name*/
sizeof( vlcMediaInstance_Type ), /*tp_basicsize*/ sizeof( vlcMediaPlayer_Type ), /*tp_basicsize*/
0, /*tp_itemsize*/ 0, /*tp_itemsize*/
0, /*tp_dealloc*/ 0, /*tp_dealloc*/
0, /*tp_print*/ 0, /*tp_print*/
...@@ -632,14 +632,14 @@ static PyTypeObject vlcMediaInstance_Type = ...@@ -632,14 +632,14 @@ static PyTypeObject vlcMediaInstance_Type =
0, /*tp_setattro*/ 0, /*tp_setattro*/
0, /*tp_as_buffer*/ 0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
"vlc.MediaInstance object\n\nIt cannot be instanciated standalone, it must be obtained from an existing vlc.Instance object", /* tp_doc */ "vlc.MediaPlayer object\n\nIt cannot be instanciated standalone, it must be obtained from an existing vlc.Instance object", /* tp_doc */
0, /* tp_traverse */ 0, /* tp_traverse */
0, /* tp_clear */ 0, /* tp_clear */
0, /* tp_richcompare */ 0, /* tp_richcompare */
0, /* tp_weaklistoffset */ 0, /* tp_weaklistoffset */
0, /* tp_iter */ 0, /* tp_iter */
0, /* tp_iternext */ 0, /* tp_iternext */
vlcMediaInstance_methods, /* tp_methods */ vlcMediaPlayer_methods, /* tp_methods */
0, /* tp_members */ 0, /* tp_members */
0, /* tp_getset */ 0, /* tp_getset */
0, /* tp_base */ 0, /* tp_base */
......
...@@ -47,10 +47,13 @@ initvlc( void ) ...@@ -47,10 +47,13 @@ initvlc( void )
{ {
PyObject* p_module; PyObject* p_module;
vlcMediaInstance_Type.tp_new = PyType_GenericNew; /* vlcMediaPlayer_Type.tp_new = PyType_GenericNew; */
vlcMediaInstance_Type.tp_alloc = PyType_GenericAlloc; vlcMediaPlayer_Type.tp_alloc = PyType_GenericAlloc;
vlcMediaDescriptor_Type.tp_new = PyType_GenericNew; /* vlcMedia_Type.tp_new = PyType_GenericNew; */
vlcMediaDescriptor_Type.tp_alloc = PyType_GenericAlloc; vlcMedia_Type.tp_alloc = PyType_GenericAlloc;
vlcInstance_Type.tp_alloc = PyType_GenericAlloc;
MediaControl_Type.tp_alloc = PyType_GenericAlloc;
p_module = Py_InitModule3( "vlc", vlc_methods, p_module = Py_InitModule3( "vlc", vlc_methods,
"VLC media player embedding module." ); "VLC media player embedding module." );
...@@ -64,9 +67,9 @@ initvlc( void ) ...@@ -64,9 +67,9 @@ initvlc( void )
return; return;
if( PyType_Ready( &vlcInstance_Type ) < 0 ) if( PyType_Ready( &vlcInstance_Type ) < 0 )
return; return;
if( PyType_Ready( &vlcMediaInstance_Type ) < 0 ) if( PyType_Ready( &vlcMediaPlayer_Type ) < 0 )
return; return;
if( PyType_Ready( &vlcMediaDescriptor_Type ) < 0 ) if( PyType_Ready( &vlcMedia_Type ) < 0 )
return; return;
/* Exceptions */ /* Exceptions */
...@@ -101,11 +104,11 @@ initvlc( void ) ...@@ -101,11 +104,11 @@ initvlc( void )
MediaControl_PlaylistException ); MediaControl_PlaylistException );
/* Exceptions */ /* Exceptions */
vlcInstance_Exception = vlc_Exception =
PyErr_NewException( "vlc.InstanceException", NULL, NULL ); PyErr_NewException( "vlc.InstanceException", NULL, NULL );
Py_INCREF( vlcInstance_Exception ); Py_INCREF( vlc_Exception );
PyModule_AddObject( p_module, "InstanceException", PyModule_AddObject( p_module, "InstanceException",
vlcInstance_Exception ); vlc_Exception );
/* Types */ /* Types */
Py_INCREF( &PyPosition_Type ); Py_INCREF( &PyPosition_Type );
...@@ -119,12 +122,14 @@ initvlc( void ) ...@@ -119,12 +122,14 @@ initvlc( void )
Py_INCREF( &vlcInstance_Type ); Py_INCREF( &vlcInstance_Type );
PyModule_AddObject( p_module, "Instance", PyModule_AddObject( p_module, "Instance",
( PyObject * )&vlcInstance_Type ); ( PyObject * )&vlcInstance_Type );
Py_INCREF( &vlcMediaInstance_Type );
PyModule_AddObject( p_module, "MediaInstance", Py_INCREF( &vlcMediaPlayer_Type );
( PyObject * )&vlcMediaInstance_Type ); PyModule_AddObject( p_module, "MediaPlayer",
Py_INCREF( &vlcMediaDescriptor_Type ); ( PyObject * )&vlcMediaPlayer_Type );
PyModule_AddObject( p_module, "MediaDescriptor",
( PyObject * )&vlcMediaDescriptor_Type ); Py_INCREF( &vlcMedia_Type );
PyModule_AddObject( p_module, "Media",
( PyObject * )&vlcMedia_Type );
/* Constants */ /* Constants */
PyModule_AddIntConstant( p_module, "AbsolutePosition", PyModule_AddIntConstant( p_module, "AbsolutePosition",
...@@ -158,13 +163,6 @@ initvlc( void ) ...@@ -158,13 +163,6 @@ initvlc( void )
} }
/* Make libpostproc happy... */
void * fast_memcpy( void * to, const void * from, size_t len )
{
return memcpy( to, from, len );
}
/* Horrible hack... Please do not look. Temporary workaround for the /* Horrible hack... Please do not look. Temporary workaround for the
forward declaration mess of python types (cf vlcglue.h). If we do a forward declaration mess of python types (cf vlcglue.h). If we do a
separate compilation, we have to declare some types as extern. But separate compilation, we have to declare some types as extern. But
...@@ -175,5 +173,5 @@ void * fast_memcpy( void * to, const void * from, size_t len ) ...@@ -175,5 +173,5 @@ void * fast_memcpy( void * to, const void * from, size_t len )
#include "vlc_mediacontrol.c" #include "vlc_mediacontrol.c"
#include "vlc_position.c" #include "vlc_position.c"
#include "vlc_instance.c" #include "vlc_instance.c"
#include "vlc_input.c" #include "vlc_mediaplayer.c"
#include "vlc_mediadescriptor.c" #include "vlc_media.c"
...@@ -78,7 +78,7 @@ PyObject *MediaControl_PositionKeyNotSupported; ...@@ -78,7 +78,7 @@ PyObject *MediaControl_PositionKeyNotSupported;
PyObject *MediaControl_PositionOriginNotSupported; PyObject *MediaControl_PositionOriginNotSupported;
PyObject *MediaControl_InvalidPosition; PyObject *MediaControl_InvalidPosition;
PyObject *MediaControl_PlaylistException; PyObject *MediaControl_PlaylistException;
PyObject *vlcInstance_Exception; PyObject *vlc_Exception;
/********************************************************************** /**********************************************************************
* vlc.Instance Object * vlc.Instance Object
...@@ -113,38 +113,38 @@ typedef struct ...@@ -113,38 +113,38 @@ typedef struct
} PyPosition; } PyPosition;
/********************************************************************** /**********************************************************************
* vlc.MediaInstance Object * vlc.MediaPlayer Object
**********************************************************************/ **********************************************************************/
typedef struct typedef struct
{ {
PyObject_HEAD PyObject_HEAD
libvlc_media_player_t* p_mi; libvlc_media_player_t* p_mp;
} vlcMediaInstance; } vlcMediaPlayer;
/********************************************************************** /**********************************************************************
* vlc.MediaDescriptor Object * vlc.Media Object
**********************************************************************/ **********************************************************************/
typedef struct typedef struct
{ {
PyObject_HEAD PyObject_HEAD
libvlc_media_t* p_md; libvlc_media_t* p_media;
} vlcMediaDescriptor; } vlcMedia;
/* Forward declarations */ /* Forward declarations */
staticforward PyTypeObject MediaControl_Type; staticforward PyTypeObject MediaControl_Type;
staticforward PyTypeObject PyPosition_Type; staticforward PyTypeObject PyPosition_Type;
staticforward PyTypeObject vlcInstance_Type; staticforward PyTypeObject vlcInstance_Type;
staticforward PyTypeObject vlcMediaInstance_Type; staticforward PyTypeObject vlcMediaPlayer_Type;
staticforward PyTypeObject vlcMediaDescriptor_Type; staticforward PyTypeObject vlcMedia_Type;
#define LIBVLC_INSTANCE ((vlcInstance*)self) #define LIBVLC_INSTANCE ((vlcInstance*)self)
#define LIBVLC_MEDIAINSTANCE ((vlcMediaInstance*)self) #define LIBVLC_MEDIAPLAYER ((vlcMediaPlayer*)self)
#define LIBVLC_MEDIADESCRIPTOR ((vlcMediaDescriptor*)self) #define LIBVLC_MEDIA ((vlcMedia*)self)
#define LIBVLC_TRY libvlc_exception_init( &ex ); #define LIBVLC_TRY libvlc_exception_init( &ex );
#define LIBVLC_EXCEPT if( libvlc_exception_raised( &ex ) ) { \ #define LIBVLC_EXCEPT if( libvlc_exception_raised( &ex ) ) { \
PyObject *py_exc = vlcInstance_Exception; \ PyObject *py_exc = vlc_Exception; \
PyErr_SetString( py_exc, libvlc_exception_get_message( &ex ) ); \ PyErr_SetString( py_exc, libvlc_exception_get_message( &ex ) ); \
return NULL; \ return NULL; \
} }
......
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