]> git.sesse.net Git - vlc/blob - bindings/python/vlcglue.h
FSF address change.
[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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #include <Python.h>
26 #include "structmember.h"
27
28 #define __VLC__
29
30 #include <stdio.h>
31 #include <vlc/vlc.h>
32 #include <vlc/mediacontrol_structures.h>
33 #include <vlc/mediacontrol.h>
34
35 #define SELF ((MediaControl*)self)
36
37 /**********************************************************************
38  * Exceptions handling
39  **********************************************************************/
40
41 #define MC_TRY exception=mediacontrol_exception_init(exception)
42
43 #define MC_EXCEPT  \
44   if( exception->code ) { \
45     PyObject *py_exc = MediaControl_InternalException; \
46     switch( exception->code ) { \
47     case mediacontrol_InternalException: \
48       py_exc = MediaControl_InternalException; \
49       break; \
50     case mediacontrol_PlaylistException: \
51       py_exc = MediaControl_PlaylistException; \
52       break; \
53     case mediacontrol_InvalidPosition: \
54       py_exc = MediaControl_InvalidPosition; \
55       break; \
56     case mediacontrol_PositionKeyNotSupported: \
57       py_exc = MediaControl_PositionKeyNotSupported; \
58       break; \
59     case mediacontrol_PositionOriginNotSupported: \
60       py_exc = MediaControl_PositionOriginNotSupported; \
61       break; \
62     } \
63     PyErr_SetString( py_exc, exception->message ); \
64     mediacontrol_exception_free( exception ); \
65     return NULL; \
66   } else { mediacontrol_exception_free( exception ); }
67
68 PyObject *MediaControl_InternalException;
69 PyObject *MediaControl_PositionKeyNotSupported;
70 PyObject *MediaControl_PositionOriginNotSupported;
71 PyObject *MediaControl_InvalidPosition;
72 PyObject *MediaControl_PlaylistException;
73
74 /**********************************************************************
75  * VLC Object
76  **********************************************************************/
77 #define VLCSELF ( ( vlcObject* )self )
78
79 /**********************************************************************
80  * VLCObject Object
81  **********************************************************************/
82 typedef struct
83 {
84     PyObject_HEAD
85     vlc_object_t* p_object;
86     int b_released;
87 } vlcObject;
88
89 staticforward PyTypeObject vlcObject_Type;
90
91 /**********************************************************************
92  * MediaControl Object
93  **********************************************************************/
94 typedef struct
95 {
96     PyObject_HEAD
97     mediacontrol_Instance* mc;
98 }MediaControl;
99
100 staticforward PyTypeObject MediaControl_Type;
101
102 /**********************************************************************
103  * Position Object
104  **********************************************************************/
105 typedef struct
106 {
107     PyObject_HEAD
108     int origin;
109     int key;
110     long long value;
111 } PyPosition;
112
113 staticforward PyTypeObject PyPosition_Type;
114
115 mediacontrol_PositionKey positionKey_py_to_c( PyObject * py_key );
116 mediacontrol_PositionOrigin positionOrigin_py_to_c( PyObject * py_origin );
117 mediacontrol_Position * position_py_to_c( PyObject * py_position );
118 PyPosition * position_c_to_py( mediacontrol_Position * position );