2005-11-02 19:32:39 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* vlcglue.h: Main header for the Python binding
|
|
|
|
*****************************************************************************
|
|
|
|
* Copyright (C) 1998-2004 the VideoLAN team
|
2007-10-17 15:30:02 +02:00
|
|
|
* $Id$
|
2005-11-02 19:32:39 +01:00
|
|
|
*
|
|
|
|
* Authors: Olivier Aubert <oaubert at bat710.univ-lyon1.fr>
|
2006-02-01 20:52:29 +01:00
|
|
|
* Clément Stenac <zorglub@videolan.org>
|
2005-11-02 19:32:39 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-01-13 00:10:04 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
2005-11-02 19:32:39 +01:00
|
|
|
*****************************************************************************/
|
2006-09-20 13:10:44 +02:00
|
|
|
#ifndef _VLCGLUE_H
|
|
|
|
#define _VLCGLUE_H 1
|
2005-11-02 19:32:39 +01:00
|
|
|
|
|
|
|
#include <Python.h>
|
|
|
|
#include "structmember.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2005-12-14 18:52:33 +01:00
|
|
|
#include <vlc/vlc.h>
|
2006-09-20 13:10:44 +02:00
|
|
|
#include <vlc/libvlc.h>
|
2006-01-08 17:32:33 +01:00
|
|
|
#include <vlc/mediacontrol_structures.h>
|
|
|
|
#include <vlc/mediacontrol.h>
|
2005-11-02 19:32:39 +01:00
|
|
|
|
2007-03-06 15:44:54 +01:00
|
|
|
/* 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
|
|
|
|
|
2005-11-02 19:32:39 +01:00
|
|
|
#define SELF ((MediaControl*)self)
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* Exceptions handling
|
|
|
|
**********************************************************************/
|
|
|
|
|
2007-05-03 22:03:09 +02:00
|
|
|
#define MC_TRY exception=mediacontrol_exception_create( )
|
2005-11-02 19:32:39 +01:00
|
|
|
|
|
|
|
#define MC_EXCEPT \
|
2007-05-03 22:03:09 +02:00
|
|
|
if( exception && exception->code ) { \
|
2005-11-02 19:32:39 +01:00
|
|
|
PyObject *py_exc = MediaControl_InternalException; \
|
2005-12-15 11:14:42 +01:00
|
|
|
switch( exception->code ) { \
|
2005-11-02 19:32:39 +01:00
|
|
|
case mediacontrol_InternalException: \
|
|
|
|
py_exc = MediaControl_InternalException; \
|
|
|
|
break; \
|
|
|
|
case mediacontrol_PlaylistException: \
|
|
|
|
py_exc = MediaControl_PlaylistException; \
|
|
|
|
break; \
|
|
|
|
case mediacontrol_InvalidPosition: \
|
|
|
|
py_exc = MediaControl_InvalidPosition; \
|
|
|
|
break; \
|
|
|
|
case mediacontrol_PositionKeyNotSupported: \
|
|
|
|
py_exc = MediaControl_PositionKeyNotSupported; \
|
|
|
|
break; \
|
|
|
|
case mediacontrol_PositionOriginNotSupported: \
|
|
|
|
py_exc = MediaControl_PositionOriginNotSupported; \
|
|
|
|
break; \
|
|
|
|
} \
|
2005-12-15 11:14:42 +01:00
|
|
|
PyErr_SetString( py_exc, exception->message ); \
|
|
|
|
mediacontrol_exception_free( exception ); \
|
2005-11-02 19:32:39 +01:00
|
|
|
return NULL; \
|
2007-05-03 22:03:09 +02:00
|
|
|
} else if( exception ) { mediacontrol_exception_free( exception ); }
|
2005-11-02 19:32:39 +01:00
|
|
|
|
|
|
|
PyObject *MediaControl_InternalException;
|
|
|
|
PyObject *MediaControl_PositionKeyNotSupported;
|
|
|
|
PyObject *MediaControl_PositionOriginNotSupported;
|
|
|
|
PyObject *MediaControl_InvalidPosition;
|
|
|
|
PyObject *MediaControl_PlaylistException;
|
2008-04-23 15:25:44 +02:00
|
|
|
PyObject *vlc_Exception;
|
2005-11-02 19:32:39 +01:00
|
|
|
|
2007-05-29 11:47:10 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* vlc.Instance Object
|
|
|
|
**********************************************************************/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
PyObject_HEAD
|
|
|
|
libvlc_instance_t* p_instance;
|
|
|
|
} vlcInstance;
|
|
|
|
|
2005-11-02 19:32:39 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* MediaControl Object
|
|
|
|
**********************************************************************/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
PyObject_HEAD
|
|
|
|
mediacontrol_Instance* mc;
|
2007-05-29 11:47:10 +02:00
|
|
|
vlcInstance *vlc_instance;
|
2006-09-20 13:10:44 +02:00
|
|
|
} MediaControl;
|
2005-11-02 19:32:39 +01:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* Position Object
|
|
|
|
**********************************************************************/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
PyObject_HEAD
|
|
|
|
int origin;
|
|
|
|
int key;
|
2006-02-15 15:11:16 +01:00
|
|
|
PY_LONG_LONG value;
|
2005-11-02 19:32:39 +01:00
|
|
|
} PyPosition;
|
|
|
|
|
2006-09-20 13:10:44 +02:00
|
|
|
/**********************************************************************
|
2008-04-23 15:25:44 +02:00
|
|
|
* vlc.MediaPlayer Object
|
2006-09-20 13:10:44 +02:00
|
|
|
**********************************************************************/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
PyObject_HEAD
|
2008-04-23 15:25:44 +02:00
|
|
|
libvlc_media_player_t* p_mp;
|
|
|
|
} vlcMediaPlayer;
|
2008-01-14 23:17:07 +01:00
|
|
|
|
|
|
|
/**********************************************************************
|
2008-04-23 15:25:44 +02:00
|
|
|
* vlc.Media Object
|
2008-01-14 23:17:07 +01:00
|
|
|
**********************************************************************/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
PyObject_HEAD
|
2008-04-23 15:25:44 +02:00
|
|
|
libvlc_media_t* p_media;
|
|
|
|
} vlcMedia;
|
2006-09-20 13:10:44 +02:00
|
|
|
|
|
|
|
/* Forward declarations */
|
|
|
|
staticforward PyTypeObject MediaControl_Type;
|
2005-11-02 19:32:39 +01:00
|
|
|
staticforward PyTypeObject PyPosition_Type;
|
2006-09-20 13:10:44 +02:00
|
|
|
staticforward PyTypeObject vlcInstance_Type;
|
2008-04-23 15:25:44 +02:00
|
|
|
staticforward PyTypeObject vlcMediaPlayer_Type;
|
|
|
|
staticforward PyTypeObject vlcMedia_Type;
|
2006-09-20 13:10:44 +02:00
|
|
|
|
2009-03-02 14:29:33 +01:00
|
|
|
#define LIBVLC_INSTANCE(self) (((vlcInstance*)self)->p_instance)
|
|
|
|
#define LIBVLC_MEDIAPLAYER(self) (((vlcMediaPlayer*)self)->p_mp)
|
|
|
|
#define LIBVLC_MEDIA(self) (((vlcMedia*)self)->p_media)
|
2006-09-20 13:10:44 +02:00
|
|
|
|
|
|
|
#define LIBVLC_TRY libvlc_exception_init( &ex );
|
|
|
|
|
|
|
|
#define LIBVLC_EXCEPT if( libvlc_exception_raised( &ex ) ) { \
|
2008-04-23 15:25:44 +02:00
|
|
|
PyObject *py_exc = vlc_Exception; \
|
2006-09-20 13:10:44 +02:00
|
|
|
PyErr_SetString( py_exc, libvlc_exception_get_message( &ex ) ); \
|
|
|
|
return NULL; \
|
|
|
|
}
|
2005-11-02 19:32:39 +01:00
|
|
|
|
|
|
|
mediacontrol_PositionKey positionKey_py_to_c( PyObject * py_key );
|
|
|
|
mediacontrol_PositionOrigin positionOrigin_py_to_c( PyObject * py_origin );
|
2005-12-15 11:14:42 +01:00
|
|
|
mediacontrol_Position * position_py_to_c( PyObject * py_position );
|
|
|
|
PyPosition * position_c_to_py( mediacontrol_Position * position );
|
2006-02-15 15:11:16 +01:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
2006-09-20 13:10:44 +02:00
|
|
|
#endif
|