]> git.sesse.net Git - vlc/blob - bindings/python/vlc_input.c
Rename bindings/mediacontrol-python to bindings/python
[vlc] / bindings / python / vlc_input.c
1 /*****************************************************************************
2  * vlc_input.c: vlc.Input binding
3  *****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id: $
6  *
7  * Authors: Olivier Aubert <oaubert at bat710.univ-lyon1.fr>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23 #include "vlcglue.h"
24
25 /***********************************************************************
26  * vlc.Input
27  ***********************************************************************/
28
29 static PyObject *
30 vlcInput_get_length( PyObject *self, PyObject *args )
31 {
32     libvlc_exception_t ex;
33     vlc_int64_t i_ret;
34     LIBVLC_TRY;
35     i_ret = libvlc_input_get_length( LIBVLC_INPUT->p_input, &ex);
36     LIBVLC_EXCEPT;
37     return Py_BuildValue( "L", i_ret );
38 }
39
40 static PyObject *
41 vlcInput_get_time( PyObject *self, PyObject *args )
42 {
43     libvlc_exception_t ex;
44     vlc_int64_t i_ret;
45     LIBVLC_TRY;
46     i_ret = libvlc_input_get_time( LIBVLC_INPUT->p_input, &ex);
47     LIBVLC_EXCEPT;
48     return Py_BuildValue( "L", i_ret );
49 }
50
51 static PyObject *
52 vlcInput_set_time( PyObject *self, PyObject *args )
53 {
54     libvlc_exception_t ex;
55     vlc_int64_t i_time;
56
57     if( !PyArg_ParseTuple( args, "L", &i_time ) )
58         return NULL;
59
60     LIBVLC_TRY;
61     libvlc_input_set_time( LIBVLC_INPUT->p_input, i_time, &ex);
62     LIBVLC_EXCEPT;
63     Py_INCREF( Py_None );
64     return Py_None;
65 }
66
67 static PyObject *
68 vlcInput_get_position( PyObject *self, PyObject *args )
69 {
70     libvlc_exception_t ex;
71     float f_ret;
72     LIBVLC_TRY;
73     f_ret = libvlc_input_get_position( LIBVLC_INPUT->p_input, &ex);
74     LIBVLC_EXCEPT;
75     return Py_BuildValue( "f", f_ret );
76 }
77
78 static PyObject *
79 vlcInput_set_position( PyObject *self, PyObject *args )
80 {
81     libvlc_exception_t ex;
82     float f_pos;
83
84     if( !PyArg_ParseTuple( args, "f", &f_pos ) )
85         return NULL;
86
87     LIBVLC_TRY;
88     libvlc_input_set_position( LIBVLC_INPUT->p_input, f_pos, &ex);
89     LIBVLC_EXCEPT;
90     Py_INCREF( Py_None );
91     return Py_None;
92 }
93
94 static PyObject *
95 vlcInput_will_play( PyObject *self, PyObject *args )
96 {
97     libvlc_exception_t ex;
98     int i_ret;
99     LIBVLC_TRY;
100     i_ret = libvlc_input_will_play( LIBVLC_INPUT->p_input, &ex);
101     LIBVLC_EXCEPT;
102     return Py_BuildValue( "i", i_ret );
103 }
104
105 static PyObject *
106 vlcInput_get_rate( PyObject *self, PyObject *args )
107 {
108     libvlc_exception_t ex;
109     float f_ret;
110     LIBVLC_TRY;
111     f_ret = libvlc_input_get_rate( LIBVLC_INPUT->p_input, &ex);
112     LIBVLC_EXCEPT;
113     return Py_BuildValue( "f", f_ret );
114 }
115
116 static PyObject *
117 vlcInput_set_rate( PyObject *self, PyObject *args )
118 {
119     libvlc_exception_t ex;
120     float f_rate;
121
122     if( !PyArg_ParseTuple( args, "f", &f_rate ) )
123         return NULL;
124
125     LIBVLC_TRY;
126     libvlc_input_set_rate( LIBVLC_INPUT->p_input, f_rate, &ex);
127     LIBVLC_EXCEPT;
128     Py_INCREF( Py_None );
129     return Py_None;
130 }
131
132 static PyObject *
133 vlcInput_get_state( PyObject *self, PyObject *args )
134 {
135     libvlc_exception_t ex;
136     int i_ret;
137     LIBVLC_TRY;
138     i_ret = libvlc_input_get_state( LIBVLC_INPUT->p_input, &ex);
139     LIBVLC_EXCEPT;
140     return Py_BuildValue( "i", i_ret );
141 }
142
143 static PyObject *
144 vlcInput_has_vout( PyObject *self, PyObject *args )
145 {
146     libvlc_exception_t ex;
147     int i_ret;
148     LIBVLC_TRY;
149     i_ret = libvlc_input_has_vout( LIBVLC_INPUT->p_input, &ex);
150     LIBVLC_EXCEPT;
151     return Py_BuildValue( "i", i_ret );
152 }
153
154 static PyObject *
155 vlcInput_get_fps( PyObject *self, PyObject *args )
156 {
157     libvlc_exception_t ex;
158     float f_ret;
159     LIBVLC_TRY;
160     f_ret = libvlc_input_get_fps( LIBVLC_INPUT->p_input, &ex);
161     LIBVLC_EXCEPT;
162     return Py_BuildValue( "f", f_ret );
163 }
164
165 static PyMethodDef vlcInput_methods[] =
166 {
167     { "get_length", vlcInput_get_length, METH_VARARGS,
168       "get_length() -> long" },
169     { "get_time", vlcInput_get_time, METH_VARARGS,
170       "get_time() -> long" },
171     { "set_time", vlcInput_set_time, METH_VARARGS,
172       "set_time(long)" },
173     { "get_position", vlcInput_get_position, METH_VARARGS,
174       "get_position() -> float" },
175     { "set_position", vlcInput_set_position, METH_VARARGS,
176       "set_position(float)" },
177     { "will_play", vlcInput_will_play, METH_VARARGS,
178       "will_play() -> int" },
179     { "get_rate", vlcInput_get_rate, METH_VARARGS,
180       "get_rate() -> float" },
181     { "set_rate", vlcInput_set_rate, METH_VARARGS,
182       "set_rate(float)" },
183     { "get_state", vlcInput_get_state, METH_VARARGS,
184       "get_state() -> int" },
185     { "has_vout", vlcInput_has_vout, METH_VARARGS,
186       "has_vout() -> int" },
187     { "get_fps", vlcInput_get_fps, METH_VARARGS,
188       "get_fps() -> float" },
189     { NULL }  /* Sentinel */
190 };
191
192 static PyTypeObject vlcInput_Type =
193 {
194     PyObject_HEAD_INIT( NULL )
195     0,                         /*ob_size*/
196     "vlc.Input",            /*tp_name*/
197     sizeof( vlcInput_Type ),   /*tp_basicsize*/
198     0,                         /*tp_itemsize*/
199     0,                         /*tp_dealloc*/
200     0,                         /*tp_print*/
201     0,                         /*tp_getattr*/
202     0,                         /*tp_setattr*/
203     0,                         /*tp_compare*/
204     0,                         /*tp_repr*/
205     0,                         /*tp_as_number*/
206     0,                         /*tp_as_sequence*/
207     0,                         /*tp_as_mapping*/
208     0,                         /*tp_hash */
209     0,                         /*tp_call*/
210     0,                         /*tp_str*/
211     0,                         /*tp_getattro*/
212     0,                         /*tp_setattro*/
213     0,                         /*tp_as_buffer*/
214     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
215     "vlc.Input object",  /* tp_doc */
216     0,                        /* tp_traverse */
217     0,                        /* tp_clear */
218     0,                         /* tp_richcompare */
219     0,                         /* tp_weaklistoffset */
220     0,                         /* tp_iter */
221     0,                          /* tp_iternext */
222     vlcInput_methods,          /* tp_methods */
223     0,                         /* tp_members */
224     0,                         /* tp_getset */
225     0,                         /* tp_base */
226     0,                         /* tp_dict */
227     0,                         /* tp_descr_get */
228     0,                         /* tp_descr_set */
229     0,                         /* tp_dictoffset */
230     0,                         /* tp_init */
231     0,                         /* tp_alloc */
232     0,                         /* tp_new */
233 };
234