root/pytyxi/_xinelib.py

Revision 1291:6ccb627906d6, 11.3 kB (checked in by Alexandre Rossi <alexandre.rossi@…>, 11 months ago)

move back all source files at the repo root and leave the maemosrc dir as a subdir

Ignore-this: d6e7e591750f702dfa6607d71c6e67e9

darcs-hash:20090410215117-85ee7-5375e859c24f660e6a7c31cc84d371bc69f650b8.gz

committer: Alexandre Rossi <alexandre.rossi@…>

Line 
1# Deejayd, a media player daemon
2# Copyright (C) 2007-2009 Mickael Royer <mickael.royer@gmail.com>
3#                         Alexandre Rossi <alexandre.rossi@gmail.com>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19
20import sys, ctypes
21
22
23try:
24    _xinelib = ctypes.cdll.LoadLibrary('libxine.so.1')
25except (ImportError, OSError), e:
26    raise ImportError, e
27
28
29# void xine_get_version (int *major, int *minor, int *sub)
30_xinelib.xine_get_version.argstype = (ctypes.POINTER(ctypes.c_int),
31                                      ctypes.POINTER(ctypes.c_int),
32                                      ctypes.POINTER(ctypes.c_int),)
33
34# int  xine_check_version (int major, int minor, int sub)
35_xinelib.xine_check_version.argtypes = (ctypes.c_int, ctypes.c_int,
36                                        ctypes.c_int)
37_xinelib.xine_check_version.restype = ctypes.c_int
38
39# char *xine_get_file_extensions (xine_t *self)
40_xinelib.xine_get_file_extensions.argtypes = (ctypes.c_void_p, )
41_xinelib.xine_get_file_extensions.restype = ctypes.c_char_p
42
43# char *const *xine_list_input_plugins(xine_t *self)
44_xinelib.xine_list_input_plugins.argtypes = (ctypes.c_void_p, )
45_xinelib.xine_list_input_plugins.restype = ctypes.POINTER(ctypes.c_char_p)
46
47# xine_t *xine_new (void)
48_xinelib.xine_new.restype = ctypes.c_void_p
49
50# void xine_config_load  (xine_t *self, const char *cfg_filename)
51_xinelib.xine_config_load.argstype = (ctypes.c_void_p, ctypes.c_char_p)
52
53# const char *xine_get_homedir(void)
54_xinelib.xine_get_homedir.restype = ctypes.c_char_p
55
56# void xine_init (xine_t *self)
57_xinelib.xine_init.argstype = (ctypes.c_void_p, )
58
59# void xine_exit (xine_t *self)
60_xinelib.xine_exit.argstype = (ctypes.c_void_p, )
61
62# void xine_engine_set_param(xine_t *self, int param, int value)
63_xinelib.xine_engine_set_param.argstype = (ctypes.c_void_p,
64                                           ctypes.c_int, ctypes.c_int, )
65
66# xine_audio_port_t *xine_open_audio_driver (xine_t *self, const char *id,
67#                       void *data)
68_xinelib.xine_open_audio_driver.argstype = (ctypes.c_void_p,
69                                            ctypes.c_char_p, ctypes.c_void_p, )
70_xinelib.xine_open_audio_driver.restype = ctypes.c_void_p
71
72# xine_video_port_t *xine_open_video_driver (xine_t *self, const char *id,
73#                       int visual, void *data)
74_xinelib.xine_open_video_driver.argstype = (ctypes.c_void_p,
75                                            ctypes.c_char_p,
76                                            ctypes.c_int, ctypes.c_void_p, )
77_xinelib.xine_open_video_driver.restype = ctypes.c_void_p
78
79# void xine_close_audio_driver (xine_t *self, xine_audio_port_t  *driver)
80_xinelib.xine_close_audio_driver.argstype = (ctypes.c_void_p, ctypes.c_void_p, )
81
82# void xine_close_video_driver (xine_t *self, xine_video_port_t  *driver)
83_xinelib.xine_close_video_driver.argstype = (ctypes.c_void_p, ctypes.c_void_p, )
84
85# int    xine_port_send_gui_data (xine_video_port_t *vo,
86#                    int type, void *data)
87_xinelib.xine_port_send_gui_data.argstype = (ctypes.c_void_p,
88                                             ctypes.c_int, ctypes.c_void_p, )
89_xinelib.xine_port_send_gui_data.restype = ctypes.c_int
90
91# xine_stream_t *xine_stream_new (xine_t *self,
92#                xine_audio_port_t *ao, xine_video_port_t *vo)
93_xinelib.xine_stream_new.argstype = (ctypes.c_void_p,
94                                     ctypes.c_void_p, ctypes.c_void_p,)
95_xinelib.xine_stream_new.restype = ctypes.c_void_p
96
97# int xine_open (xine_stream_t *stream, const char *mrl)
98_xinelib.xine_open.argstype = (ctypes.c_void_p, ctypes.c_char_p, )
99_xinelib.xine_open.restype = ctypes.c_int
100
101# int  xine_play (xine_stream_t *stream, int start_pos, int start_time)
102_xinelib.xine_play.argstype = (ctypes.c_void_p, ctypes.c_int, ctypes.c_int, )
103_xinelib.xine_play.restype = ctypes.c_int
104
105# void xine_stop (xine_stream_t *stream)
106_xinelib.xine_stop.argstype = (ctypes.c_void_p, )
107
108_xinelib.xine_usec_sleep.argtypes = (ctypes.c_int, )
109
110# void xine_close (xine_stream_t *stream)
111_xinelib.xine_close.argstype = (ctypes.c_void_p, )
112
113# void xine_dispose (xine_stream_t *stream)
114_xinelib.xine_dispose.argstype = (ctypes.c_void_p, )
115
116class x11_visual_t(ctypes.Structure):
117    _fields_ = (
118        ('display', ctypes.c_void_p),
119        ('screen', ctypes.c_int),
120        ('d', ctypes.c_ulong), # Drawable
121        ('user_data', ctypes.c_void_p),
122        ('dest_size_cb', ctypes.c_void_p),
123        ('frame_output_cb', ctypes.c_void_p),
124        ('lock_display', ctypes.c_void_p),
125        ('unlock_display', ctypes.c_void_p),
126    )
127
128# dest size callback
129xine_dest_size_cb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p,
130                     ctypes.c_int, ctypes.c_int, ctypes.c_double,
131                     ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int),
132                     ctypes.POINTER(ctypes.c_double))
133
134# frame output callback
135xine_frame_output_cb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p,
136                  ctypes.c_int, ctypes.c_int, ctypes.c_double,
137                  ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int),
138                  ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int),
139                  ctypes.POINTER(ctypes.c_double),
140                  ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
141
142class xine_event_t(ctypes.Structure):
143    _fields_ = (
144        ('type', ctypes.c_int),
145        ('stream', ctypes.c_void_p),
146        ('data', ctypes.c_void_p),
147        ('data_length', ctypes.c_int),
148    )
149
150class xine_ui_message_data_t(ctypes.Structure):
151    _fields_ = (
152        ('compatibility_num_buttons', ctypes.c_int),
153        ('compatibility_str_len', ctypes.c_int),
154        ('compatibility_str', 256 * ctypes.c_char),
155        ('type', ctypes.c_int),
156        ('explanation', ctypes.c_int),
157        ('num_parameters', ctypes.c_int),
158        ('parameters', ctypes.c_void_p),
159        ('messages', ctypes.c_char),
160    )
161
162# event listener callback type
163xine_event_listener_cb_t = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p,
164                                            ctypes.POINTER(xine_event_t))
165
166# void xine_event_create_listener_thread(xine_event_queue_t *queue,
167#    xine_event_listener_cb_t callback,
168#    void *user_data)
169_xinelib.xine_event_create_listener_thread.argtypes = (ctypes.c_void_p,
170                                                       ctypes.c_void_p,
171                                                       ctypes.c_void_p)
172
173# xine_event_queue_t *xine_event_new_queue(xine_stream_t *stream)
174_xinelib.xine_event_new_queue.argtypes = (ctypes.c_void_p, )
175_xinelib.xine_event_new_queue.restype = ctypes.c_void_p
176
177# void xine_event_dispose_queue(xine_event_queue_t *queue)
178_xinelib.xine_event_dispose_queue.argtypes = (ctypes.c_void_p, )
179
180# void xine_set_param (xine_stream_t *stream, int param, int value)
181_xinelib.xine_set_param.argtypes = (ctypes.c_void_p, ctypes.c_int, ctypes.c_int)
182
183# int xine_get_param (xine_stream_t *stream, int param)
184_xinelib.xine_get_param.argtypes = (ctypes.c_void_p, ctypes.c_int)
185_xinelib.xine_get_param.restype = ctypes.c_int
186
187# char *xine_get_meta_info(xine_stream_t *stream, int info)
188_xinelib.xine_get_meta_info.argtypes = (ctypes.c_void_p, ctypes.c_int)
189_xinelib.xine_get_meta_info.restype = ctypes.c_char_p
190
191# int xine_get_stream_info(xine_stream_t *stream, int info)
192_xinelib.xine_get_stream_info.argtypes = (ctypes.c_void_p, ctypes.c_int)
193_xinelib.xine_get_stream_info.restype = ctypes.c_int
194
195# int xine_get_status (xine_stream_t *stream)
196_xinelib.xine_get_status.argtypes = (ctypes.c_void_p, )
197_xinelib.xine_get_status.restype = ctypes.c_int
198
199# int xine_get_pos_length (xine_stream_t *stream, int *pos_stream,
200#                          int *pos_time, int *length_time)
201_xinelib.xine_get_pos_length.argtypes = (ctypes.c_void_p,
202                                         ctypes.POINTER(ctypes.c_int),
203                                         ctypes.POINTER(ctypes.c_int),
204                                         ctypes.POINTER(ctypes.c_int))
205
206# int xine_get_status (xine_stream_t *stream)
207_xinelib.xine_get_status.argtypes = (ctypes.c_void_p, )
208_xinelib.xine_get_status.restype = ctypes.c_int
209
210# int xine_get_audio_lang(xine_stream_t *stream, int channel, char *lang)
211_xinelib.xine_get_audio_lang.restype = ctypes.c_int
212_xinelib.xine_get_audio_lang.argtypes = (ctypes.c_void_p, ctypes.c_int,
213                                         ctypes.c_char_p)
214
215# int xine_get_spu_lang(xine_stream_t *stream, int channel, char *lang)
216_xinelib.xine_get_spu_lang.restype = ctypes.c_int
217_xinelib.xine_get_spu_lang.argtypes = (ctypes.c_void_p, ctypes.c_int,
218                                       ctypes.c_char_p)
219
220# xine_osd_t *xine_osd_new(xine_stream_t *self, int x, int y,
221#                          int width, int height)
222_xinelib.xine_osd_new.argtypes = (ctypes.c_void_p, ctypes.c_int, ctypes.c_int,
223                                  ctypes.c_int, ctypes.c_int)
224_xinelib.xine_osd_new.restype = ctypes.c_void_p
225
226# void xine_osd_free(xine_osd_t *self)
227_xinelib.xine_osd_free.argtypes = (ctypes.c_void_p, )
228
229# uint32_t xine_osd_get_capabilities(xine_osd_t *self)
230_xinelib.xine_osd_get_capabilities.restype = ctypes.c_int
231_xinelib.xine_osd_get_capabilities.argtypes = (ctypes.c_void_p, )
232
233# void xine_osd_set_text_palette(xine_osd_t *self,int palette_number,
234#                                int color_base )
235_xinelib.xine_osd_set_text_palette.argtypes = (ctypes.c_void_p, ctypes.c_int,
236                                               ctypes.c_int)
237
238# int xine_osd_set_font(xine_osd_t *self, const char *fontname, int size)
239_xinelib.xine_osd_set_font.restype = ctypes.c_int
240_xinelib.xine_osd_set_font.argtypes = (ctypes.c_void_p, ctypes.c_char_p,
241                                       ctypes.c_int)
242
243# void xine_osd_set_position(xine_osd_t *self, int x, int y)
244_xinelib.xine_osd_set_position.argtypes = (ctypes.c_void_p, ctypes.c_int,
245                                        ctypes.c_int)
246
247# void xine_osd_draw_text(xine_osd_t *self, int x1, int y1, char *text,
248#                         int color_base)
249_xinelib.xine_osd_draw_text.argtypes = (ctypes.c_void_p, ctypes.c_int,
250                                        ctypes.c_int, ctypes.c_char_p,
251                                        ctypes.c_int)
252
253# void xine_osd_show(xine_osd_t *self, int64_t vpts)
254_xinelib.xine_osd_show.argtypes = (ctypes.c_void_p, ctypes.c_int)
255
256# void  xine_osd_show_unscaled (xine_osd_t *self, int64_t vpts)
257_xinelib.xine_osd_show_unscaled.argtypes = (ctypes.c_void_p, ctypes.c_int)
258
259# void  xine_osd_hide(xine_osd_t *self, int64_t vpts)
260_xinelib.xine_osd_hide.argtypes = (ctypes.c_void_p, ctypes.c_int)
261
262# void  xine_osd_clear(xine_osd_t *self)
263_xinelib.xine_osd_clear.argtypes = (ctypes.c_void_p, )
264
265
266# copy functions from the library
267module = sys.modules[__name__]
268for name in dir(_xinelib):
269    if name.startswith('xine_'):
270        setattr(module, name, getattr(_xinelib, name))
271
272
273# vim: ts=4 sw=4 expandtab
Note: See TracBrowser for help on using the browser.