]> git.sesse.net Git - vlc/blob - bindings/python/vlcglue.h
Python bindings fixed for the new mediacontrol headers
[vlc] / bindings / python / vlcglue.h
1 /*****************************************************************************
2  * vlcglue.h: Main header for the Python binding
3  *****************************************************************************
4  * Copyright (C) 1998-2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Olivier Aubert <oaubert at bat710.univ-lyon1.fr>
8  *          ClĂ©ment Stenac <zorglub@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #include <Python.h>
26 #include "structmember.h"
27
28 /* Undefine the following define to disable low-level vlc Object support */
29 #define VLCOBJECT_SUPPORT 0
30
31 #define __VLC__
32
33 #include <stdio.h>
34 #include <vlc/vlc.h>
35 #include <vlc/control_structures.h>
36 #include <vlc/control.h>
37
38 #define SELF ((MediaControl*)self)
39
40 /**********************************************************************
41  * Exceptions handling
42  **********************************************************************/
43
44 #define MC_TRY exception=mediacontrol_exception_init(exception)
45
46 #define MC_EXCEPT  \
47   if (exception->code) { \
48     PyObject *py_exc = MediaControl_InternalException; \
49     switch (exception->code) { \
50     case mediacontrol_InternalException: \
51       py_exc = MediaControl_InternalException; \
52       break; \
53     case mediacontrol_PlaylistException: \
54       py_exc = MediaControl_PlaylistException; \
55       break; \
56     case mediacontrol_InvalidPosition: \
57       py_exc = MediaControl_InvalidPosition; \
58       break; \
59     case mediacontrol_PositionKeyNotSupported: \
60       py_exc = MediaControl_PositionKeyNotSupported; \
61       break; \
62     case mediacontrol_PositionOriginNotSupported: \
63       py_exc = MediaControl_PositionOriginNotSupported; \
64       break; \
65     } \
66     PyErr_SetString(py_exc, exception->message); \
67     mediacontrol_exception_free(exception); \
68     return NULL; \
69   } else { mediacontrol_exception_free(exception); }
70
71 PyObject *MediaControl_InternalException;
72 PyObject *MediaControl_PositionKeyNotSupported;
73 PyObject *MediaControl_PositionOriginNotSupported;
74 PyObject *MediaControl_InvalidPosition;
75 PyObject *MediaControl_PlaylistException;
76
77 /**********************************************************************
78  * VLC Object
79  **********************************************************************/
80 #ifdef VLCOBJECT_SUPPORT
81
82 #define VLCSELF ((vlcObject*)self)
83
84 /**********************************************************************
85  * VLCObject Object
86  **********************************************************************/
87 typedef struct
88 {
89     PyObject_HEAD
90     vlc_object_t* p_object;
91     int b_released;
92 } vlcObject;
93
94 staticforward PyTypeObject vlcObject_Type;
95
96 #endif
97
98 /**********************************************************************
99  * MediaControl Object
100  **********************************************************************/
101 typedef struct
102 {
103     PyObject_HEAD
104     mediacontrol_Instance* mc;
105 }MediaControl;
106
107 staticforward PyTypeObject MediaControl_Type;
108
109 /**********************************************************************
110  * Position Object
111  **********************************************************************/
112 typedef struct
113 {
114     PyObject_HEAD
115     int origin;
116     int key;
117     long long value;
118 } PyPosition;
119
120 staticforward PyTypeObject PyPosition_Type;
121
122 mediacontrol_PositionKey positionKey_py_to_c( PyObject * py_key );
123 mediacontrol_PositionOrigin positionOrigin_py_to_c( PyObject * py_origin );
124 mediacontrol_Position* position_py_to_c( PyObject * py_position );
125 PyPosition* position_c_to_py(mediacontrol_Position *position);