1 /*****************************************************************************
2 * vlc_input.c: vlc.Input binding
3 *****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Olivier Aubert <oaubert at bat710.univ-lyon1.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 *****************************************************************************/
25 /***********************************************************************
27 ***********************************************************************/
30 vlcInput_get_length( PyObject *self, PyObject *args )
32 libvlc_exception_t ex;
35 i_ret = libvlc_media_instance_get_length( libvlc_media_instance->p_md, &ex);
37 return Py_BuildValue( "L", i_ret );
41 vlcInput_get_time( PyObject *self, PyObject *args )
43 libvlc_exception_t ex;
46 i_ret = libvlc_media_instance_get_time( libvlc_media_instance->p_md, &ex);
48 return Py_BuildValue( "L", i_ret );
52 vlcInput_set_time( PyObject *self, PyObject *args )
54 libvlc_exception_t ex;
57 if( !PyArg_ParseTuple( args, "L", &i_time ) )
61 libvlc_media_instance_set_time( libvlc_media_instance->p_md, i_time, &ex);
68 vlcInput_get_position( PyObject *self, PyObject *args )
70 libvlc_exception_t ex;
73 f_ret = libvlc_media_instance_get_position( libvlc_media_instance->p_md, &ex);
75 return Py_BuildValue( "f", f_ret );
79 vlcInput_set_position( PyObject *self, PyObject *args )
81 libvlc_exception_t ex;
84 if( !PyArg_ParseTuple( args, "f", &f_pos ) )
88 libvlc_media_instance_set_position( libvlc_media_instance->p_md, f_pos, &ex);
95 vlcInput_will_play( PyObject *self, PyObject *args )
97 libvlc_exception_t ex;
100 i_ret = libvlc_media_instance_will_play( libvlc_media_instance->p_md, &ex);
102 return Py_BuildValue( "i", i_ret );
106 vlcInput_get_rate( PyObject *self, PyObject *args )
108 libvlc_exception_t ex;
111 f_ret = libvlc_media_instance_get_rate( libvlc_media_instance->p_md, &ex);
113 return Py_BuildValue( "f", f_ret );
117 vlcInput_set_rate( PyObject *self, PyObject *args )
119 libvlc_exception_t ex;
122 if( !PyArg_ParseTuple( args, "f", &f_rate ) )
126 libvlc_media_instance_set_rate( libvlc_media_instance->p_md, f_rate, &ex);
128 Py_INCREF( Py_None );
133 vlcInput_get_state( PyObject *self, PyObject *args )
135 libvlc_exception_t ex;
138 i_ret = libvlc_media_instance_get_state( libvlc_media_instance->p_md, &ex);
140 return Py_BuildValue( "i", i_ret );
144 vlcInput_has_vout( PyObject *self, PyObject *args )
146 libvlc_exception_t ex;
149 i_ret = libvlc_media_instance_has_vout( libvlc_media_instance->p_md, &ex);
151 return Py_BuildValue( "i", i_ret );
155 vlcInput_get_fps( PyObject *self, PyObject *args )
157 libvlc_exception_t ex;
160 f_ret = libvlc_media_instance_get_fps( libvlc_media_instance->p_md, &ex);
162 return Py_BuildValue( "f", f_ret );
166 vlcInput_audio_get_track( PyObject *self, PyObject *args )
168 libvlc_exception_t ex;
172 i_ret = libvlc_audio_get_track( libvlc_media_instance->p_md, &ex );
174 return Py_BuildValue( "i", i_ret );
178 vlcInput_audio_set_track( PyObject *self, PyObject *args )
180 libvlc_exception_t ex;
183 if( !PyArg_ParseTuple( args, "i", &i_track ) )
187 libvlc_audio_set_track( libvlc_media_instance->p_md, i_track, &ex );
189 Py_INCREF( Py_None );
194 vlcInput_toggle_fullscreen( PyObject *self, PyObject *args )
196 libvlc_exception_t ex;
199 libvlc_toggle_fullscreen( libvlc_media_instance->p_md, &ex);
201 Py_INCREF( Py_None );
206 vlcInput_set_fullscreen( PyObject *self, PyObject *args )
208 libvlc_exception_t ex;
211 if( !PyArg_ParseTuple( args, "i", &i_fullscreen ) )
215 libvlc_set_fullscreen( libvlc_media_instance->p_md, i_fullscreen, &ex);
217 Py_INCREF( Py_None );
222 vlcInput_get_fullscreen( PyObject *self, PyObject *args )
224 libvlc_exception_t ex;
228 i_ret = libvlc_get_fullscreen( libvlc_media_instance->p_md, &ex);
230 return Py_BuildValue( "i", i_ret );
234 vlcInput_get_height( PyObject *self, PyObject *args )
236 libvlc_exception_t ex;
240 i_ret = libvlc_video_get_height( libvlc_media_instance->p_md, &ex);
242 return Py_BuildValue( "i", i_ret );
246 vlcInput_get_width( PyObject *self, PyObject *args )
248 libvlc_exception_t ex;
252 i_ret = libvlc_video_get_width( libvlc_media_instance->p_md, &ex);
254 return Py_BuildValue( "i", i_ret );
258 vlcInput_get_aspect_ratio( PyObject *self, PyObject *args )
260 libvlc_exception_t ex;
265 psz_ret = libvlc_video_get_aspect_ratio( libvlc_media_instance->p_md, &ex);
267 o_ret=Py_BuildValue( "s", psz_ret );
273 vlcInput_set_aspect_ratio( PyObject *self, PyObject *args )
275 libvlc_exception_t ex;
278 if( !PyArg_ParseTuple( args, "s", &psz_ratio ) )
282 libvlc_video_set_aspect_ratio( libvlc_media_instance->p_md, psz_ratio, &ex);
285 Py_INCREF( Py_None );
290 vlcInput_video_take_snapshot( PyObject *self, PyObject *args )
292 libvlc_exception_t ex;
295 if( !PyArg_ParseTuple( args, "s", &psz_filename ) )
299 libvlc_video_take_snapshot( libvlc_media_instance->p_md, psz_filename, &ex);
301 Py_INCREF( Py_None );
306 vlcInput_video_resize( PyObject *self, PyObject *args )
308 libvlc_exception_t ex;
312 if( !PyArg_ParseTuple( args, "ii", &i_width, &i_height ) )
316 libvlc_video_resize( libvlc_media_instance->p_md, i_width, i_height, &ex);
318 Py_INCREF( Py_None );
323 vlcInput_video_reparent( PyObject *self, PyObject *args )
325 libvlc_exception_t ex;
326 WINDOWHANDLE i_visual;
329 if( !PyArg_ParseTuple( args, "i", &i_visual ) )
333 i_ret = libvlc_video_reparent( libvlc_media_instance->p_md, i_visual, &ex);
335 return Py_BuildValue( "i", i_ret );
338 static PyMethodDef vlcInput_methods[] =
340 { "get_length", vlcInput_get_length, METH_VARARGS,
341 "get_length() -> long " },
342 { "get_time", vlcInput_get_time, METH_VARARGS,
343 "get_time() -> long" },
344 { "set_time", vlcInput_set_time, METH_VARARGS,
346 { "get_position", vlcInput_get_position, METH_VARARGS,
347 "get_position() -> float" },
348 { "set_position", vlcInput_set_position, METH_VARARGS,
349 "set_position(float)" },
350 { "will_play", vlcInput_will_play, METH_VARARGS,
351 "will_play() -> int" },
352 { "get_rate", vlcInput_get_rate, METH_VARARGS,
353 "get_rate() -> float" },
354 { "set_rate", vlcInput_set_rate, METH_VARARGS,
356 { "get_state", vlcInput_get_state, METH_VARARGS,
357 "get_state() -> int" },
358 { "has_vout", vlcInput_has_vout, METH_VARARGS,
359 "has_vout() -> int" },
360 { "get_fps", vlcInput_get_fps, METH_VARARGS,
361 "get_fps() -> float" },
362 { "audio_get_track", vlcInput_audio_get_track, METH_VARARGS,
363 "audio_get_track() -> int Get current audio track" },
364 { "audio_set_track", vlcInput_audio_set_track, METH_VARARGS,
365 "audio_set_track(int) Set current audio track" },
366 { "toggle_fullscreen", vlcInput_toggle_fullscreen, METH_VARARGS,
367 "toggle_fullscreen() Toggle fullscreen status on video output" },
368 { "set_fullscreen", vlcInput_set_fullscreen, METH_VARARGS,
369 "set_fullscreen(bool) Enable or disable fullscreen on a video output" },
370 { "get_fullscreen", vlcInput_get_fullscreen, METH_VARARGS,
371 "get_fullscreen() -> bool Get current fullscreen status" },
372 { "get_height", vlcInput_get_height, METH_VARARGS,
373 "get_height() -> int Get current video height" },
374 { "get_width", vlcInput_get_width, METH_VARARGS,
375 "get_width() -> int Get current video width" },
376 { "get_aspect_ratio", vlcInput_get_aspect_ratio, METH_VARARGS,
377 "get_aspect_ratio() -> str Get current video aspect ratio" },
378 { "set_aspect_ratio", vlcInput_set_aspect_ratio, METH_VARARGS,
379 "set_aspect_ratio(str) Set new video aspect ratio" },
380 { "video_take_snapshot", vlcInput_video_take_snapshot, METH_VARARGS,
381 "video_take_snapshot(filename=str) Take a snapshot of the current video window" },
382 { "video_resize", vlcInput_video_resize, METH_VARARGS,
383 "video_resize(width=int, height=int) Resize the current video output window" },
384 { "video_reparent", vlcInput_video_reparent, METH_VARARGS,
385 "video_reparent(visual=int) change the parent for the current video output" },
387 { NULL } /* Sentinel */
390 static PyTypeObject vlcInput_Type =
392 PyObject_HEAD_INIT( NULL )
394 "vlc.Input", /*tp_name*/
395 sizeof( vlcInput_Type ), /*tp_basicsize*/
404 0, /*tp_as_sequence*/
412 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
413 "vlc.Input object\n\nIt cannot be instanciated standalone, it must be obtained from an existing vlc.Instance object", /* tp_doc */
416 0, /* tp_richcompare */
417 0, /* tp_weaklistoffset */
420 vlcInput_methods, /* tp_methods */
425 0, /* tp_descr_get */
426 0, /* tp_descr_set */
427 0, /* tp_dictoffset */