X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bindings%2Fpython%2Fvlcglue.h;h=8c857c687a801dc57d1ef85476eed40c3ff06e11;hb=658686029ee756fbf4beb8e0cdcc4b0bc5dd18ed;hp=f2b719774f4004f09eba13cbe65979ae97fe8ac7;hpb=68aa3ca3202b0f2c7e3b10db9dbe46b436b17bbd;p=vlc diff --git a/bindings/python/vlcglue.h b/bindings/python/vlcglue.h index f2b719774f..8c857c687a 100644 --- a/bindings/python/vlcglue.h +++ b/bindings/python/vlcglue.h @@ -5,7 +5,7 @@ * $Id$ * * Authors: Olivier Aubert - * Clément Stenac + * Clément Stenac * * 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 @@ -19,29 +19,36 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ +#ifndef _VLCGLUE_H +#define _VLCGLUE_H 1 #include #include "structmember.h" -#define __VLC__ - #include #include +#include #include #include -#define SELF ((MediaControl*)self) +/* Python 2.5 64-bit support compatibility define */ +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +#define PY_SSIZE_T_MAX INT_MAX +#define PY_SSIZE_T_MIN INT_MIN +#endif + /********************************************************************** * Exceptions handling **********************************************************************/ -#define MC_TRY exception=mediacontrol_exception_init(exception) +#define MC_TRY exception=mediacontrol_exception_create( ) #define MC_EXCEPT \ - if( exception->code ) { \ + if( exception && exception->code ) { \ PyObject *py_exc = MediaControl_InternalException; \ switch( exception->code ) { \ case mediacontrol_InternalException: \ @@ -63,30 +70,23 @@ PyErr_SetString( py_exc, exception->message ); \ mediacontrol_exception_free( exception ); \ return NULL; \ - } else { mediacontrol_exception_free( exception ); } + } else if( exception ) { mediacontrol_exception_free( exception ); } PyObject *MediaControl_InternalException; PyObject *MediaControl_PositionKeyNotSupported; PyObject *MediaControl_PositionOriginNotSupported; PyObject *MediaControl_InvalidPosition; PyObject *MediaControl_PlaylistException; +PyObject *vlc_Exception; /********************************************************************** - * VLC Object - **********************************************************************/ -#define VLCSELF ( ( vlcObject* )self ) - -/********************************************************************** - * VLCObject Object + * vlc.Instance Object **********************************************************************/ typedef struct { PyObject_HEAD - vlc_object_t* p_object; - int b_released; -} vlcObject; - -staticforward PyTypeObject vlcObject_Type; + libvlc_instance_t* p_instance; +} vlcInstance; /********************************************************************** * MediaControl Object @@ -95,9 +95,8 @@ typedef struct { PyObject_HEAD mediacontrol_Instance* mc; -}MediaControl; - -staticforward PyTypeObject MediaControl_Type; + vlcInstance *vlc_instance; +} MediaControl; /********************************************************************** * Position Object @@ -107,12 +106,57 @@ typedef struct PyObject_HEAD int origin; int key; - long long value; + PY_LONG_LONG value; } PyPosition; +/********************************************************************** + * vlc.MediaPlayer Object + **********************************************************************/ +typedef struct +{ + PyObject_HEAD + libvlc_media_player_t* p_mp; +} vlcMediaPlayer; + +/********************************************************************** + * vlc.Media Object + **********************************************************************/ +typedef struct +{ + PyObject_HEAD + libvlc_media_t* p_media; +} vlcMedia; + +/* Forward declarations */ +staticforward PyTypeObject MediaControl_Type; staticforward PyTypeObject PyPosition_Type; +staticforward PyTypeObject vlcInstance_Type; +staticforward PyTypeObject vlcMediaPlayer_Type; +staticforward PyTypeObject vlcMedia_Type; + +#define LIBVLC_INSTANCE(self) (((vlcInstance*)self)->p_instance) +#define LIBVLC_MEDIAPLAYER(self) (((vlcMediaPlayer*)self)->p_mp) +#define LIBVLC_MEDIA(self) (((vlcMedia*)self)->p_media) +#define LIBVLC_MC(self) (((MediaControl*)self)->mc) + +#define LIBVLC_TRY libvlc_exception_init( &ex ); + +#define LIBVLC_EXCEPT if( libvlc_exception_raised( &ex ) ) { \ + PyObject *py_exc = vlc_Exception; \ + PyErr_SetString( py_exc, libvlc_exception_get_message( &ex ) ); \ + return NULL; \ + } mediacontrol_PositionKey positionKey_py_to_c( PyObject * py_key ); mediacontrol_PositionOrigin positionOrigin_py_to_c( PyObject * py_origin ); mediacontrol_Position * position_py_to_c( PyObject * py_position ); PyPosition * position_c_to_py( mediacontrol_Position * position ); + +/* Long long conversion on Mac os X/ppc */ +#if defined (__ppc__) || defined(__ppc64__) +#define ntohll(x) ((long long) x >> 64) +#else +#define ntohll(x) (x) +#endif + +#endif