1 /*****************************************************************************
2 * vlc_module.c: vlc python binding module
3 *****************************************************************************
4 * Copyright (C) 2006,2007,2008,2009 the VideoLAN team
7 * Authors: Olivier Aubert <olivier.aubert at liris.cnrs.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
26 /**************************************************************************
28 **************************************************************************/
30 #ifndef vlcMODINIT_FUNC /* declarations for DLL import/export */
31 #define vlcMODINIT_FUNC void
34 static PyMethodDef vlc_methods
[] = {
35 { NULL
} /* Sentinel */
39 PyObject
* MediaControl_InternalException
= NULL
;
40 PyObject
* MediaControl_PositionKeyNotSupported
= NULL
;
41 PyObject
*MediaControl_PositionOriginNotSupported
= NULL
;
42 PyObject
* MediaControl_InvalidPosition
= NULL
;
43 PyObject
*MediaControl_PlaylistException
= NULL
;
50 /* vlcMediaPlayer_Type.tp_new = PyType_GenericNew; */
51 vlcMediaPlayer_Type
.tp_alloc
= PyType_GenericAlloc
;
52 /* vlcMedia_Type.tp_new = PyType_GenericNew; */
53 vlcMedia_Type
.tp_alloc
= PyType_GenericAlloc
;
55 vlcInstance_Type
.tp_alloc
= PyType_GenericAlloc
;
56 MediaControl_Type
.tp_alloc
= PyType_GenericAlloc
;
58 p_module
= Py_InitModule3( "vlc", vlc_methods
,
59 "VLC media player embedding module." );
64 if( PyType_Ready( &PyPosition_Type
) < 0 )
66 if( PyType_Ready( &MediaControl_Type
) < 0 )
68 if( PyType_Ready( &vlcInstance_Type
) < 0 )
70 if( PyType_Ready( &vlcMediaPlayer_Type
) < 0 )
72 if( PyType_Ready( &vlcMedia_Type
) < 0 )
76 MediaControl_InternalException
=
77 PyErr_NewException( "vlc.InternalException", NULL
, NULL
);
78 Py_INCREF( MediaControl_InternalException
);
79 PyModule_AddObject( p_module
, "InternalException",
80 MediaControl_InternalException
);
82 MediaControl_PositionKeyNotSupported
=
83 PyErr_NewException( "vlc.PositionKeyNotSupported", NULL
, NULL
);
84 Py_INCREF( MediaControl_PositionKeyNotSupported
);
85 PyModule_AddObject( p_module
, "PositionKeyNotSupported",
86 MediaControl_PositionKeyNotSupported
);
88 MediaControl_PositionOriginNotSupported
=
89 PyErr_NewException( "vlc.InvalidPosition", NULL
, NULL
);
90 Py_INCREF( MediaControl_PositionOriginNotSupported
);
91 PyModule_AddObject( p_module
, "PositionOriginNotSupported",
92 MediaControl_PositionOriginNotSupported
);
94 MediaControl_InvalidPosition
=
95 PyErr_NewException( "vlc.InvalidPosition", NULL
, NULL
);
96 Py_INCREF( MediaControl_InvalidPosition
);
97 PyModule_AddObject( p_module
, "InvalidPosition",
98 MediaControl_InvalidPosition
);
100 MediaControl_PlaylistException
=
101 PyErr_NewException( "vlc.PlaylistException", NULL
, NULL
);
102 Py_INCREF( MediaControl_PlaylistException
);
103 PyModule_AddObject( p_module
, "PlaylistException",
104 MediaControl_PlaylistException
);
108 PyErr_NewException( "vlc.InstanceException", NULL
, NULL
);
109 Py_INCREF( vlc_Exception
);
110 PyModule_AddObject( p_module
, "InstanceException",
114 Py_INCREF( &PyPosition_Type
);
115 PyModule_AddObject( p_module
, "Position",
116 ( PyObject
* )&PyPosition_Type
);
118 Py_INCREF( &MediaControl_Type
);
119 PyModule_AddObject( p_module
, "MediaControl",
120 ( PyObject
* )&MediaControl_Type
);
122 Py_INCREF( &vlcInstance_Type
);
123 PyModule_AddObject( p_module
, "Instance",
124 ( PyObject
* )&vlcInstance_Type
);
126 Py_INCREF( &vlcMediaPlayer_Type
);
127 PyModule_AddObject( p_module
, "MediaPlayer",
128 ( PyObject
* )&vlcMediaPlayer_Type
);
130 Py_INCREF( &vlcMedia_Type
);
131 PyModule_AddObject( p_module
, "Media",
132 ( PyObject
* )&vlcMedia_Type
);
135 PyModule_AddIntConstant( p_module
, "AbsolutePosition",
136 mediacontrol_AbsolutePosition
);
137 PyModule_AddIntConstant( p_module
, "RelativePosition",
138 mediacontrol_RelativePosition
);
139 PyModule_AddIntConstant( p_module
, "ModuloPosition",
140 mediacontrol_ModuloPosition
);
142 PyModule_AddIntConstant( p_module
, "ByteCount",
143 mediacontrol_ByteCount
);
144 PyModule_AddIntConstant( p_module
, "SampleCount",
145 mediacontrol_SampleCount
);
146 PyModule_AddIntConstant( p_module
, "MediaTime",
147 mediacontrol_MediaTime
);
149 PyModule_AddIntConstant( p_module
, "PlayingStatus",
150 mediacontrol_PlayingStatus
);
151 PyModule_AddIntConstant( p_module
, "PauseStatus",
152 mediacontrol_PauseStatus
);
153 PyModule_AddIntConstant( p_module
, "InitStatus",
154 mediacontrol_InitStatus
);
155 PyModule_AddIntConstant( p_module
, "EndStatus",
156 mediacontrol_EndStatus
);
157 PyModule_AddIntConstant( p_module
, "UndefinedStatus",
158 mediacontrol_UndefinedStatus
);
162 /* Horrible hack... Please do not look. Temporary workaround for the
163 forward declaration mess of python types (cf vlcglue.h). If we do a
164 separate compilation, we have to declare some types as extern. But
165 the recommended way to forward declared types in python is
166 static... I am sorting the mess but in the meantime, this will
167 produce a working python module.
169 #include "vlc_mediacontrol.c"
170 #include "vlc_position.c"
171 #include "vlc_instance.c"
172 #include "vlc_mediaplayer.c"
173 #include "vlc_media.c"