]> git.sesse.net Git - vlc/blob - bindings/python/vlc_instance.c
python bindings: svn propset svn:keywords
[vlc] / bindings / python / vlc_instance.c
1 /*****************************************************************************
2  * vlc_instance.c: vlc.Instance 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 /* Helper functions */
26 static int
27 pyoptions_to_args(PyObject *py_options, char*** pppsz_args)
28 {
29     int i_size;
30     int i_index;
31     char** ppsz_args = *pppsz_args;
32     
33     ppsz_args = NULL;
34
35     Py_INCREF( py_options );
36     if( ! PySequence_Check( py_options ) )
37     {
38         PyErr_SetString( PyExc_TypeError, "Parameter must be a sequence." );
39         return -1;
40     }
41     i_size = PySequence_Size( py_options );
42     ppsz_args = malloc( ( i_size + 1 ) * sizeof( char * ) );
43     if( ! ppsz_args )
44     {
45         PyErr_SetString( PyExc_MemoryError, "Out of memory" );
46         return -1;
47     }
48
49     for ( i_index = 0; i_index < i_size; i_index++ )
50     {
51         ppsz_args[i_index] =
52             strdup( PyString_AsString( PyObject_Str(
53                                            PySequence_GetItem( py_options,
54                                                                i_index ) ) ) );
55     }
56     ppsz_args[i_size] = NULL;
57     Py_DECREF( py_options );
58     return i_size;
59 }
60
61 static void
62 free_args(int i_size, char** ppsz_args)
63 {
64     int i_index;
65
66     for ( i_index = 0; i_index < i_size; i_index++ )
67         if( ppsz_args[i_index] )
68             free(ppsz_args[i_index]);
69     free( ppsz_args );
70 }
71
72 /*****************************************************************************
73  * Instance object implementation
74  *****************************************************************************/
75
76 static PyObject *
77 vlcInstance_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
78 {
79     vlcInstance *self;
80     libvlc_exception_t ex;
81     PyObject* py_list = NULL;
82     char** ppsz_args = NULL;
83     int i_size = 0;
84
85     self = PyObject_New( vlcInstance, &vlcInstance_Type );
86
87
88     if( PyArg_ParseTuple( args, "O", &py_list ) )
89     {
90         i_size = pyoptions_to_args( py_list, &ppsz_args );
91         if( i_size < 0 )
92             return NULL;
93     }
94     else
95     {
96         /* No arguments were given. Clear the exception raised
97            by PyArg_ParseTuple. */
98         PyErr_Clear( );
99     }
100
101     Py_BEGIN_ALLOW_THREADS
102     LIBVLC_TRY
103     LIBVLC_INSTANCE->p_instance = libvlc_new( i_size, ppsz_args, &ex );
104     free_args( i_size, ppsz_args );
105     LIBVLC_EXCEPT
106     Py_END_ALLOW_THREADS
107
108     Py_INCREF( self );
109     return ( PyObject * )self;
110 }
111
112 static void
113 vlcInstance_dealloc( PyObject *self )
114 {
115     libvlc_exception_t ex;
116     libvlc_destroy( LIBVLC_INSTANCE->p_instance, &ex );
117     PyMem_DEL( self );
118 }
119
120 static PyObject *
121 vlcInstance_get_vlc_id( PyObject *self, PyObject *args )
122 {
123     return Py_BuildValue( "i", libvlc_get_vlc_id( LIBVLC_INSTANCE->p_instance ) );
124 }
125
126 /* Set loop variable */
127 static PyObject *
128 vlcInstance_playlist_loop( PyObject *self, PyObject *args )
129 {
130     libvlc_exception_t ex;
131     int i_loop = 0;
132
133     if( !PyArg_ParseTuple( args, "i", &i_loop ) )
134         return NULL;
135
136     LIBVLC_TRY;
137     libvlc_playlist_loop( LIBVLC_INSTANCE->p_instance, i_loop, &ex );
138     LIBVLC_EXCEPT;
139
140     Py_INCREF( Py_None );
141     return Py_None;
142 }
143
144 /* Playlist play. 2 parameters: i_id, the id to play
145    l_options: a list of options */
146 static PyObject *
147 vlcInstance_playlist_play( PyObject *self, PyObject *args )
148 {
149     libvlc_exception_t ex;
150     int i_id = -1;
151     PyObject *py_options = NULL;
152     int i_size = 0;
153     char** ppsz_args = NULL;
154
155     if( !PyArg_ParseTuple( args, "|iO", &i_id, &py_options ) )
156         return NULL;
157
158     if( py_options )
159     {        
160         i_size = pyoptions_to_args( py_options, &ppsz_args );
161     }
162
163     LIBVLC_TRY;
164     libvlc_playlist_play( LIBVLC_INSTANCE->p_instance, i_id, i_size, ppsz_args, &ex );
165     free_args( i_size, ppsz_args );
166     LIBVLC_EXCEPT;
167
168     Py_INCREF( Py_None );
169     return Py_None;
170 }
171
172 static PyObject *
173 vlcInstance_playlist_pause( PyObject *self, PyObject *args )
174 {
175     libvlc_exception_t ex;
176     LIBVLC_TRY;
177     libvlc_playlist_pause( LIBVLC_INSTANCE->p_instance, &ex );
178     LIBVLC_EXCEPT;
179     Py_INCREF( Py_None );
180     return Py_None;
181 }
182
183 static PyObject *
184 vlcInstance_playlist_isplaying( PyObject *self, PyObject *args )
185 {
186     libvlc_exception_t ex;
187     int i_ret;
188
189     LIBVLC_TRY;
190     i_ret = libvlc_playlist_isplaying( LIBVLC_INSTANCE->p_instance, &ex );
191     LIBVLC_EXCEPT;
192     return Py_BuildValue( "i", i_ret );
193 }
194
195 static PyObject *
196 vlcInstance_playlist_items_count( PyObject *self, PyObject *args )
197 {
198     libvlc_exception_t ex;
199     int i_ret;
200
201     LIBVLC_TRY;
202     i_ret = libvlc_playlist_items_count( LIBVLC_INSTANCE->p_instance, &ex );
203     LIBVLC_EXCEPT;
204     return Py_BuildValue( "i", i_ret );
205 }
206
207 static PyObject *
208 vlcInstance_playlist_stop( PyObject *self, PyObject *args )
209 {
210     libvlc_exception_t ex;
211     LIBVLC_TRY;
212     libvlc_playlist_stop( LIBVLC_INSTANCE->p_instance, &ex );
213     LIBVLC_EXCEPT;
214     Py_INCREF( Py_None );
215     return Py_None;
216 }
217
218 static PyObject *
219 vlcInstance_playlist_next( PyObject *self, PyObject *args )
220 {
221     libvlc_exception_t ex;
222     LIBVLC_TRY;
223     libvlc_playlist_next( LIBVLC_INSTANCE->p_instance, &ex );
224     LIBVLC_EXCEPT;
225     Py_INCREF( Py_None );
226     return Py_None;
227 }
228
229 static PyObject *
230 vlcInstance_playlist_prev( PyObject *self, PyObject *args )
231 {
232     libvlc_exception_t ex;
233     LIBVLC_TRY;
234     libvlc_playlist_prev( LIBVLC_INSTANCE->p_instance, &ex );
235     LIBVLC_EXCEPT;
236     Py_INCREF( Py_None );
237     return Py_None;
238 }
239
240 static PyObject *
241 vlcInstance_playlist_clear( PyObject *self, PyObject *args )
242 {
243     libvlc_exception_t ex;
244     LIBVLC_TRY;
245     libvlc_playlist_clear( LIBVLC_INSTANCE->p_instance, &ex );
246     LIBVLC_EXCEPT;
247     Py_INCREF( Py_None );
248     return Py_None;
249 }
250
251 /* Add a playlist item. Main parameter: URI.
252    Optional parameters: name, options */
253 static PyObject *
254 vlcInstance_playlist_add( PyObject *self, PyObject *args)
255 {
256     libvlc_exception_t ex;
257     int i_ret;
258     char* psz_uri = NULL;
259     char* psz_name = NULL;
260     PyObject *py_options = NULL;
261     int i_size = 0;
262     char** ppsz_args = NULL;
263
264     if( !PyArg_ParseTuple( args, "s|sO", &psz_uri, &psz_name, &py_options ) )
265         return NULL;
266
267     if( !psz_name )
268     {
269         /* Set a default name */
270         psz_name = strdup( psz_uri );
271     }
272
273     if( py_options )
274     {        
275         i_size = pyoptions_to_args( py_options, &ppsz_args );
276     }
277
278     LIBVLC_TRY;
279     if( ppsz_args )
280     {
281         i_ret = libvlc_playlist_add_extended( LIBVLC_INSTANCE->p_instance,
282                                               psz_uri,
283                                               psz_name,
284                                               i_size,
285                                               ppsz_args,
286                                               &ex );
287         free_args( i_size, ppsz_args );
288     }
289     else
290     {
291         i_ret = libvlc_playlist_add( LIBVLC_INSTANCE->p_instance,
292                                      psz_uri,
293                                      psz_name,
294                                      &ex );
295     }
296     LIBVLC_EXCEPT;
297
298     return Py_BuildValue( "i", i_ret );
299 }
300
301 static PyObject *
302 vlcInstance_playlist_delete_item( PyObject *self, PyObject *args )
303 {
304     libvlc_exception_t ex;
305     int i_id;
306     int i_ret;
307
308     if( !PyArg_ParseTuple( args, "i", &i_id ) )
309         return NULL;
310
311     LIBVLC_TRY;
312     i_ret = libvlc_playlist_delete_item( LIBVLC_INSTANCE->p_instance, i_id, &ex );
313     LIBVLC_EXCEPT;
314
315     return Py_BuildValue( "i", i_ret );
316 }
317
318 static PyObject *
319 vlcInstance_playlist_get_input( PyObject *self, PyObject *args )
320 {
321     libvlc_exception_t ex;
322     libvlc_input_t *p_input;
323     vlcInput *p_ret;
324
325     LIBVLC_TRY;
326     p_input = libvlc_playlist_get_input( LIBVLC_INSTANCE->p_instance, &ex );
327     LIBVLC_EXCEPT;
328
329     p_ret = PyObject_New( vlcInput, &vlcInput_Type );
330     p_ret->p_input = p_input;
331     Py_INCREF( p_ret ); /* Ah bon ? */
332     return ( PyObject * )p_ret;
333 }
334
335 static PyObject *
336 vlcInstance_video_set_parent( PyObject *self, PyObject *args )
337 {
338     libvlc_exception_t ex;
339     int i_drawable;
340
341     if( !PyArg_ParseTuple( args, "i", &i_drawable ) )
342         return NULL;
343
344     LIBVLC_TRY;
345     libvlc_video_set_parent( LIBVLC_INSTANCE->p_instance, (libvlc_drawable_t) i_drawable, &ex );
346     LIBVLC_EXCEPT;
347
348     Py_INCREF( Py_None );
349     return Py_None;
350 }
351
352 static PyObject *
353 vlcInstance_video_set_size( PyObject *self, PyObject *args )
354 {
355     libvlc_exception_t ex;
356     int i_width;
357     int i_height;
358
359     if( !PyArg_ParseTuple( args, "ii", &i_width, &i_height ) )
360         return NULL;
361
362     LIBVLC_TRY;
363     libvlc_video_set_size( LIBVLC_INSTANCE->p_instance, i_width, i_height, &ex );
364     LIBVLC_EXCEPT;
365
366     Py_INCREF( Py_None );
367     return Py_None;
368 }
369
370 static PyObject *
371 vlcInstance_audio_toggle_mute( PyObject *self, PyObject *args )
372 {
373     libvlc_exception_t ex;
374     LIBVLC_TRY;
375     libvlc_audio_toggle_mute( LIBVLC_INSTANCE->p_instance, &ex );
376     LIBVLC_EXCEPT;
377     Py_INCREF( Py_None );
378     return Py_None;
379 }
380
381 static PyObject *
382 vlcInstance_audio_get_mute( PyObject *self, PyObject *args )
383 {
384     libvlc_exception_t ex;
385     int i_ret;
386
387     LIBVLC_TRY;
388     i_ret = libvlc_audio_get_mute( LIBVLC_INSTANCE->p_instance, &ex );
389     LIBVLC_EXCEPT;
390     return Py_BuildValue( "i", i_ret );
391 }
392
393 static PyObject *
394 vlcInstance_audio_set_mute( PyObject *self, PyObject *args )
395 {
396     libvlc_exception_t ex;
397     int i_mute;
398
399     if( !PyArg_ParseTuple( args, "i", &i_mute ) )
400         return NULL;
401
402     LIBVLC_TRY;
403     libvlc_audio_set_mute( LIBVLC_INSTANCE->p_instance, i_mute, &ex );
404     LIBVLC_EXCEPT;
405     Py_INCREF( Py_None );
406     return Py_None;
407 }
408
409 static PyObject *
410 vlcInstance_audio_get_volume( PyObject *self, PyObject *args )
411 {
412     libvlc_exception_t ex;
413     int i_ret;
414
415     LIBVLC_TRY;
416     i_ret = libvlc_audio_get_volume( LIBVLC_INSTANCE->p_instance, &ex );
417     LIBVLC_EXCEPT;
418     return Py_BuildValue( "i", i_ret );
419 }
420
421 static PyObject *
422 vlcInstance_audio_set_volume( PyObject *self, PyObject *args )
423 {
424     libvlc_exception_t ex;
425     int i_volume;
426
427     if( !PyArg_ParseTuple( args, "i", &i_volume ) )
428         return NULL;
429
430     LIBVLC_TRY;
431     libvlc_audio_set_mute( LIBVLC_INSTANCE->p_instance, i_volume, &ex );
432     LIBVLC_EXCEPT;
433     Py_INCREF( Py_None );
434     return Py_None;
435 }
436
437 static PyObject *
438 vlcInstance_audio_get_channel( PyObject *self, PyObject *args )
439 {
440     libvlc_exception_t ex;
441     char* psz_ret;
442     PyObject* o_ret;
443
444     LIBVLC_TRY;
445     psz_ret = libvlc_audio_get_channel( LIBVLC_INSTANCE->p_instance, &ex );
446     LIBVLC_EXCEPT;
447     o_ret=Py_BuildValue( "s", psz_ret );
448     free( psz_ret );
449     return o_ret;
450 }
451
452 static PyObject *
453 vlcInstance_audio_set_channel( PyObject *self, PyObject *args )
454 {
455     libvlc_exception_t ex;
456     char* psz_channel;
457
458     if( !PyArg_ParseTuple( args, "s", &psz_channel ) )
459         return NULL;
460
461     LIBVLC_TRY;
462     libvlc_audio_set_channel( LIBVLC_INSTANCE->p_instance, psz_channel, &ex );
463     LIBVLC_EXCEPT;
464     Py_INCREF( Py_None );
465     return Py_None;
466 }
467
468 /* vlm_add_broadcast : name, input MRL, output MRL
469    Keywords: options, enable, loop */
470 static PyObject *
471 vlcInstance_vlm_add_broadcast( PyObject *self, PyObject *args, PyObject *kwds )
472 {
473     libvlc_exception_t ex;
474     static char *kwlist[] = { "name", "input", "output", 
475                               "options", "enable", "loop", NULL};
476     char* psz_name = NULL;
477     char* psz_input = NULL;
478     char* psz_output = NULL;
479     PyObject* py_options = NULL;
480     int i_enable = 1;
481     int i_loop = 0;
482     int i_size = 0;
483     char** ppsz_args = NULL;
484
485     if( !PyArg_ParseTupleAndKeywords( args, kwds, "sss|Oii", kwlist, 
486                                       &psz_name,
487                                       &psz_input, &psz_output,
488                                       &py_options, &i_enable, &i_loop ) )
489         return NULL;
490     
491     if( py_options )
492     {
493         i_size = pyoptions_to_args( py_options, &ppsz_args );
494     }
495    
496     LIBVLC_TRY;
497     libvlc_vlm_add_broadcast( LIBVLC_INSTANCE->p_instance, 
498                               psz_name, psz_input, psz_output,
499                               i_size, ppsz_args, i_enable, i_loop, &ex);
500     free_args( i_size, ppsz_args );
501     LIBVLC_EXCEPT;
502     Py_INCREF( Py_None );
503     return Py_None;
504 }
505
506 static PyObject *
507 vlcInstance_vlm_del_media( PyObject *self, PyObject *args )
508 {
509     libvlc_exception_t ex;
510     char* psz_name;
511
512     if( !PyArg_ParseTuple( args, "s", &psz_name ) )
513         return NULL;
514
515     LIBVLC_TRY;
516     libvlc_vlm_del_media( LIBVLC_INSTANCE->p_instance, psz_name, &ex);
517     LIBVLC_EXCEPT;
518     Py_INCREF( Py_None );
519     return Py_None;
520 }
521
522 static PyObject *
523 vlcInstance_vlm_set_enabled( PyObject *self, PyObject *args )
524 {
525     libvlc_exception_t ex;
526     char* psz_name;
527     int i_enabled;
528     
529     if( !PyArg_ParseTuple( args, "si", &psz_name, &i_enabled ) )
530         return NULL;
531
532     LIBVLC_TRY;
533     libvlc_vlm_set_enabled( LIBVLC_INSTANCE->p_instance, psz_name, i_enabled, &ex);
534     LIBVLC_EXCEPT;
535     Py_INCREF( Py_None );
536     return Py_None;
537 }
538
539 static PyObject *
540 vlcInstance_vlm_set_output( PyObject *self, PyObject *args )
541 {
542     libvlc_exception_t ex;
543     char* psz_name;
544     char* psz_output;
545     
546     if( !PyArg_ParseTuple( args, "ss", &psz_name, &psz_output ) )
547         return NULL;
548
549     LIBVLC_TRY;
550     libvlc_vlm_set_output( LIBVLC_INSTANCE->p_instance, psz_name, psz_output, &ex);
551     LIBVLC_EXCEPT;
552     Py_INCREF( Py_None );
553     return Py_None;
554 }
555
556 static PyObject *
557 vlcInstance_vlm_set_input( PyObject *self, PyObject *args )
558 {
559     libvlc_exception_t ex;
560     char* psz_name;
561     char* psz_input;
562     
563     if( !PyArg_ParseTuple( args, "ss", &psz_name, &psz_input ) )
564         return NULL;
565
566     LIBVLC_TRY;
567     libvlc_vlm_set_input( LIBVLC_INSTANCE->p_instance, psz_name, psz_input, &ex);
568     LIBVLC_EXCEPT;
569     Py_INCREF( Py_None );
570     return Py_None;
571 }
572
573 static PyObject *
574 vlcInstance_vlm_set_loop( PyObject *self, PyObject *args )
575 {
576     libvlc_exception_t ex;
577     char* psz_name;
578     int i_loop;
579     
580     if( !PyArg_ParseTuple( args, "si", &psz_name, &i_loop ) )
581         return NULL;
582
583     LIBVLC_TRY;
584     libvlc_vlm_set_loop( LIBVLC_INSTANCE->p_instance, psz_name, i_loop, &ex);
585     LIBVLC_EXCEPT;
586     Py_INCREF( Py_None );
587     return Py_None;
588 }
589
590 static PyObject *
591 vlcInstance_vlm_change_media( PyObject *self, PyObject *args, PyObject *kwds )
592 {
593     libvlc_exception_t ex;
594     static char *kwlist[] = { "name", "input", "output", 
595                               "options", "enable", "loop", NULL};
596     char* psz_name = NULL;
597     char* psz_input = NULL;
598     char* psz_output = NULL;
599     PyObject* py_options = NULL;
600     int i_enable = 1;
601     int i_loop = 0;
602     int i_size = 0;
603     char** ppsz_args = NULL;
604
605     if( !PyArg_ParseTupleAndKeywords( args, kwds, "sss|Oii", kwlist, 
606                                       &psz_name,
607                                       &psz_input, &psz_output,
608                                       &py_options, &i_enable, &i_loop ) )
609         return NULL;
610     
611     if( py_options )
612     {
613         i_size = pyoptions_to_args( py_options, &ppsz_args );
614     }
615    
616     LIBVLC_TRY;
617     libvlc_vlm_change_media( LIBVLC_INSTANCE->p_instance, 
618                               psz_name, psz_input, psz_output,
619                               i_size, ppsz_args, i_enable, i_loop, &ex);
620     free_args( i_size, ppsz_args );
621     LIBVLC_EXCEPT;
622     Py_INCREF( Py_None );
623     return Py_None;
624 }
625
626 static PyObject *
627 vlcInstance_vlm_play_media( PyObject *self, PyObject *args )
628 {
629     libvlc_exception_t ex;
630     char* psz_name;
631     
632     if( !PyArg_ParseTuple( args, "s", &psz_name ) )
633         return NULL;
634
635     LIBVLC_TRY;
636     libvlc_vlm_play_media( LIBVLC_INSTANCE->p_instance, psz_name, &ex);
637     LIBVLC_EXCEPT;
638     Py_INCREF( Py_None );
639     return Py_None;
640 }
641
642 static PyObject *
643 vlcInstance_vlm_stop_media( PyObject *self, PyObject *args )
644 {
645     libvlc_exception_t ex;
646     char* psz_name;
647
648     if( !PyArg_ParseTuple( args, "s", &psz_name ) )
649         return NULL;
650
651     LIBVLC_TRY;
652     libvlc_vlm_stop_media( LIBVLC_INSTANCE->p_instance, psz_name, &ex);
653     LIBVLC_EXCEPT;
654     Py_INCREF( Py_None );
655     return Py_None;
656 }
657
658 static PyObject *
659 vlcInstance_vlm_pause_media( PyObject *self, PyObject *args )
660 {
661     libvlc_exception_t ex;
662     char* psz_name;
663     
664     if( !PyArg_ParseTuple( args, "s", &psz_name ) )
665         return NULL;
666
667     LIBVLC_TRY;
668     libvlc_vlm_pause_media( LIBVLC_INSTANCE->p_instance, psz_name, &ex);
669     LIBVLC_EXCEPT;
670     Py_INCREF( Py_None );
671     return Py_None;
672 }
673
674 static PyObject *
675 vlcInstance_vlm_seek_media( PyObject *self, PyObject *args )
676 {
677     libvlc_exception_t ex;
678     char* psz_name;
679     float f_percentage;
680     
681     if( !PyArg_ParseTuple( args, "sf", &psz_name, &f_percentage ) )
682         return NULL;
683
684     LIBVLC_TRY;
685     libvlc_vlm_seek_media( LIBVLC_INSTANCE->p_instance, psz_name, f_percentage, &ex);
686     LIBVLC_EXCEPT;
687     Py_INCREF( Py_None );
688     return Py_None;
689 }
690
691 static PyObject *
692 vlcInstance_vlm_show_media( PyObject *self, PyObject *args )
693 {
694     libvlc_exception_t ex;
695     char* psz_name;
696     char* psz_ret;
697     PyObject* o_ret;
698
699     if( !PyArg_ParseTuple( args, "s", &psz_name ) )
700         return NULL;
701     LIBVLC_TRY;
702     psz_ret = libvlc_vlm_show_media( LIBVLC_INSTANCE->p_instance, psz_name, &ex );
703     LIBVLC_EXCEPT;
704     o_ret = Py_BuildValue( "s", psz_ret );
705     free( psz_ret );
706     return o_ret;
707 }
708
709 /* Method table */
710 static PyMethodDef vlcInstance_methods[] =
711 {
712     { "get_vlc_id", vlcInstance_get_vlc_id, METH_VARARGS,
713       "get_vlc_id( ) -> int        Get the instance id."},
714     { "playlist_loop", vlcInstance_playlist_loop, METH_VARARGS,
715       "playlist_loop(bool)         Set loop variable" },
716     { "playlist_play", vlcInstance_playlist_play, METH_VARARGS,
717       "playlist_play(id=int, options=list)   Play the given playlist item (-1 for current item) with optional options (a list of strings)" },
718     { "playlist_pause", vlcInstance_playlist_pause, METH_VARARGS,
719       "playlist_pause()            Pause the current stream"},
720     { "playlist_isplaying", vlcInstance_playlist_isplaying, METH_VARARGS,
721       "playlist_isplaying() -> int     Return True if the playlist if playing"},
722     { "playlist_items_count", vlcInstance_playlist_items_count, METH_VARARGS,
723       "playlist_items_count() -> int   Return the number of items in the playlist"},
724     { "playlist_stop", vlcInstance_playlist_stop, METH_VARARGS,
725       "playlist_stop()             Stop the current stream"},
726     { "playlist_next", vlcInstance_playlist_next, METH_VARARGS,
727       "playlist_next()             Play the next item"},
728     { "playlist_prev", vlcInstance_playlist_prev, METH_VARARGS,
729       "playlist_prev()             Play the previous item"},
730     { "playlist_clear", vlcInstance_playlist_clear, METH_VARARGS,
731       "playlist_clear()            Clear the playlist"},
732     { "playlist_add", vlcInstance_playlist_add, METH_VARARGS,
733       "playlist_add(mrl=str, name=str, options=list) -> int  Add a new item to the playlist. options is a list of strings."},
734     { "playlist_delete_item", vlcInstance_playlist_delete_item, METH_VARARGS,
735       "playlist_delete_item(id=int)   Delete the given item"},
736     { "playlist_get_input", vlcInstance_playlist_get_input, METH_VARARGS,
737       "playlist_get_input() -> object   Return the current input"},
738     { "video_set_parent", vlcInstance_video_set_parent, METH_VARARGS,
739       "video_set_parent(xid=int)       Set the parent xid or HWND"},
740     { "video_set_size", vlcInstance_video_set_size, METH_VARARGS,
741       "video_set_size(width=int, height=int)    Set the video width and height"},
742     { "audio_toggle_mute", vlcInstance_audio_toggle_mute, METH_VARARGS,
743       "audio_toggle_mute()         Toggle the mute state"},
744     { "audio_get_mute", vlcInstance_audio_get_mute, METH_VARARGS,
745       "audio_get_mute() -> int     Get the mute state"},
746     { "audio_set_mute", vlcInstance_audio_set_mute, METH_VARARGS,
747       "audio_set_mute(state=int)         Set the mute state"},
748     { "audio_get_volume", vlcInstance_audio_get_volume, METH_VARARGS,
749       "audio_get_volume() -> int   Get the audio volume"},
750     { "audio_set_volume", vlcInstance_audio_set_volume, METH_VARARGS,
751       "audio_set_volume(volume=int)       Set the audio volume"},
752     { "audio_get_channel", vlcInstance_audio_get_channel, METH_VARARGS,
753       "audio_get_channel() -> int  Get current audio channel" },
754     { "audio_set_channel", vlcInstance_audio_set_channel, METH_VARARGS,
755       "audio_set_channel(int)      Set current audio channel" },
756     { "vlm_add_broadcast", vlcInstance_vlm_add_broadcast, METH_VARARGS | METH_KEYWORDS,
757       "vlm_add_broadcast(name=str, input=str, output=str, options=list, enable=int, loop=int)   Add a new broadcast" },
758     { "vlm_del_media", vlcInstance_vlm_del_media, METH_VARARGS,
759       "vlm_del_media(name=str)    Delete a media" },
760     { "vlm_set_enabled", vlcInstance_vlm_set_enabled, METH_VARARGS,
761       "vlm_set_enabled(name=str, enabled=int)    Enable/disable a media" },
762     { "vlm_set_output", vlcInstance_vlm_set_output, METH_VARARGS,
763       "vlm_set_output(name=str, output=str)      Set the output" },
764     { "vlm_set_input", vlcInstance_vlm_set_input, METH_VARARGS,
765       "vlm_set_input(name=str, output=str)       Set the input" },
766     { "vlm_set_loop", vlcInstance_vlm_set_loop, METH_VARARGS,
767       "vlm_set_loop(name=str, loop=int)          Change the looping value" },
768     { "vlm_change_media", vlcInstance_vlm_change_media, METH_VARARGS | METH_KEYWORDS,
769       "vlm_change_media(name=str, input=str, output=str, options=list, enable=int, loop=int)   Change the broadcast parameters" },
770     { "vlm_play_media", vlcInstance_vlm_play_media, METH_VARARGS,
771       "vlm_play_media(name=str)       Plays the named broadcast." },
772     { "vlm_stop_media", vlcInstance_vlm_stop_media, METH_VARARGS,
773       "vlm_stop_media(name=str)       Stops the named broadcast." },
774     { "vlm_pause_media", vlcInstance_vlm_pause_media, METH_VARARGS,
775       "vlm_pause_media(name=str)      Pauses the named broadcast." },
776     { "vlm_seek_media", vlcInstance_vlm_seek_media, METH_VARARGS,
777       "vlm_seek_media(name=str, percentage=float)  Seeks in the named broadcast." },
778     { "vlm_show_media", vlcInstance_vlm_show_media, METH_VARARGS,
779       "vlm_show_media(name=str)       Return information of the named broadcast." },
780
781     { NULL, NULL, 0, NULL },
782 };
783
784 static PyTypeObject vlcInstance_Type =
785 {
786     PyObject_HEAD_INIT( NULL )
787     0,                          /*ob_size*/
788     "vlc.Instance",             /*tp_name*/
789     sizeof( vlcInstance_Type ), /*tp_basicsize*/
790     0,                          /*tp_itemsize*/
791     ( destructor )vlcInstance_dealloc,      /*tp_dealloc*/
792     0,                         /*tp_print*/
793     0,                         /*tp_getattr*/
794     0,                         /*tp_setattr*/
795     0,                         /*tp_compare*/
796     0,                         /*tp_repr*/
797     0,                         /*tp_as_number*/
798     0,                         /*tp_as_sequence*/
799     0,                         /*tp_as_mapping*/
800     0,                         /*tp_hash */
801     0,                         /*tp_call*/
802     0,                         /*tp_str*/
803     0,                         /*tp_getattro*/
804     0,                         /*tp_setattro*/
805     0,                         /*tp_as_buffer*/
806     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
807     "VLC Instance(args)\n\nNote: if args is specified, the first arg is interpreted as an executable name to get the directory of the VLC plugins.",  /* tp_doc */
808     0,                     /* tp_traverse */
809     0,                     /* tp_clear */
810     0,                     /* tp_richcompare */
811     0,                     /* tp_weaklistoffset */
812     0,                     /* tp_iter */
813     0,                     /* tp_iternext */
814     vlcInstance_methods,             /* tp_methods */
815     0,             /* tp_members */
816     0,                         /* tp_getset */
817     0,                         /* tp_base */
818     0,                         /* tp_dict */
819     0,                         /* tp_descr_get */
820     0,                         /* tp_descr_set */
821     0,                         /* tp_dictoffset */
822     0,                         /* tp_init */
823     0,                         /* tp_alloc */
824     vlcInstance_new,          /* tp_new */
825 };