| 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 | |
|---|
| 20 | import sys, ctypes |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | try: |
|---|
| 24 | _xinelib = ctypes.cdll.LoadLibrary('libxine.so.1') |
|---|
| 25 | except (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 | |
|---|
| 116 | class 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 |
|---|
| 129 | xine_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 |
|---|
| 135 | xine_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 | |
|---|
| 142 | class 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 | |
|---|
| 150 | class 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 |
|---|
| 163 | xine_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 |
|---|
| 267 | module = sys.modules[__name__] |
|---|
| 268 | for 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 |
|---|