]> git.sesse.net Git - vlc/blob - src/control/video.c
11b3fdf96818cdaa9ca2dd212cd17172093d6a1f
[vlc] / src / control / video.c
1 /*****************************************************************************
2  * video.c: libvlc new API video functions
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
5  *
6  * $Id$
7  *
8  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
9  *          Filippo Carone <littlejohn@videolan.org>
10  *          Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
11  *          Damien Fouilleul <damienf a_t videolan dot org>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26  *****************************************************************************/
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc/libvlc.h>
33 #include <vlc/libvlc_media.h>
34 #include <vlc/libvlc_media_player.h>
35
36 #include <vlc_common.h>
37 #include <vlc_input.h>
38 #include <vlc_vout.h>
39
40 #include "media_player_internal.h"
41 #include <vlc_osd.h>
42 #include <assert.h>
43
44 /*
45  * Remember to release the returned vout_thread_t.
46  */
47 static vout_thread_t *GetVout( libvlc_media_player_t *p_mi,
48                                libvlc_exception_t *p_exception )
49 {
50     input_thread_t *p_input = libvlc_get_input_thread( p_mi, p_exception );
51     vout_thread_t *p_vout = NULL;
52
53     if( p_input )
54     {
55         p_vout = input_GetVout( p_input );
56         if( !p_vout )
57         {
58             libvlc_exception_raise( p_exception );
59             libvlc_printerr( "No active video output" );
60         }
61         vlc_object_release( p_input );
62     }
63     return p_vout;
64 }
65
66 /**********************************************************************
67  * Exported functions
68  **********************************************************************/
69
70 void libvlc_set_fullscreen( libvlc_media_player_t *p_mi, int b_fullscreen,
71                             libvlc_exception_t *p_e )
72 {
73     /* We only work on the first vout */
74     vout_thread_t *p_vout = GetVout( p_mi, p_e );
75
76     /* GetVout will raise the exception for us */
77     if( !p_vout ) return;
78
79     var_SetBool( p_vout, "fullscreen", b_fullscreen );
80
81     vlc_object_release( p_vout );
82 }
83
84 int libvlc_get_fullscreen( libvlc_media_player_t *p_mi,
85                             libvlc_exception_t *p_e )
86 {
87     /* We only work on the first vout */
88     vout_thread_t *p_vout = GetVout( p_mi, p_e );
89     int i_ret;
90
91     /* GetVout will raise the exception for us */
92     if( !p_vout ) return 0;
93
94     i_ret = var_GetBool( p_vout, "fullscreen" );
95
96     vlc_object_release( p_vout );
97
98     return i_ret;
99 }
100
101 void libvlc_toggle_fullscreen( libvlc_media_player_t *p_mi,
102                                libvlc_exception_t *p_e )
103 {
104     /* We only work on the first vout */
105     vout_thread_t *p_vout = GetVout( p_mi, p_e );
106
107     /* GetVout will raise the exception for us */
108     if( !p_vout ) return;
109
110     var_ToggleBool( p_vout, "fullscreen" );
111
112     vlc_object_release( p_vout );
113 }
114
115 void
116 libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, const char *psz_filepath,
117         unsigned int i_width, unsigned int i_height, libvlc_exception_t *p_e )
118 {
119     vout_thread_t *p_vout;
120
121     assert( psz_filepath );
122
123     /* We must have an input */
124     if( !p_mi->p_input_thread )
125     {
126         libvlc_exception_raise( p_e );
127         libvlc_printerr( "Input does not exist" );
128         return;
129     }
130
131     /* GetVout will raise the exception for us */
132     p_vout = GetVout( p_mi, p_e );
133     if( !p_vout ) return;
134
135     var_SetInteger( p_vout, "snapshot-width", i_width );
136     var_SetInteger( p_vout, "snapshot-height", i_height );
137
138     var_SetString( p_vout, "snapshot-path", psz_filepath );
139     var_SetString( p_vout, "snapshot-format", "png" );
140
141     var_TriggerCallback( p_vout, "video-snapshot" );
142     vlc_object_release( p_vout );
143 }
144
145 int libvlc_video_get_height( libvlc_media_player_t *p_mi,
146                              libvlc_exception_t *p_e )
147 {
148     int height;
149
150     vout_thread_t *p_vout = GetVout( p_mi, p_e );
151     if( !p_vout ) return 0;
152
153     height = p_vout->i_window_height;
154
155     vlc_object_release( p_vout );
156
157     return height;
158 }
159
160 int libvlc_video_get_width( libvlc_media_player_t *p_mi,
161                             libvlc_exception_t *p_e )
162 {
163     int width;
164
165     vout_thread_t *p_vout = GetVout( p_mi, p_e );
166     if( !p_vout ) return 0;
167
168     width = p_vout->i_window_width;
169
170     vlc_object_release( p_vout );
171
172     return width;
173 }
174
175 int libvlc_media_player_has_vout( libvlc_media_player_t *p_mi,
176                                      libvlc_exception_t *p_e )
177 {
178     input_thread_t *p_input_thread = libvlc_get_input_thread(p_mi, p_e);
179     bool has_vout = false;
180
181     if( p_input_thread )
182     {
183         vout_thread_t *p_vout;
184
185         p_vout = input_GetVout( p_input_thread );
186         if( p_vout )
187         {
188             has_vout = true;
189             vlc_object_release( p_vout );
190         }
191         vlc_object_release( p_input_thread );
192     }
193     return has_vout;
194 }
195
196 float libvlc_video_get_scale( libvlc_media_player_t *p_mp,
197                               libvlc_exception_t *p_e )
198 {
199     vout_thread_t *p_vout = GetVout( p_mp, p_e );
200     if( !p_vout )
201         return 0.;
202
203     float f_scale = var_GetFloat( p_vout, "scale" );
204     if( var_GetBool( p_vout, "autoscale" ) )
205         f_scale = 0.;
206     vlc_object_release( p_vout );
207     return f_scale;
208 }
209
210 void libvlc_video_set_scale( libvlc_media_player_t *p_mp, float f_scale,
211                              libvlc_exception_t *p_e )
212 {
213     vout_thread_t *p_vout = GetVout( p_mp, p_e );
214     if( !p_vout )
215         return;
216
217     if( f_scale != 0. )
218         var_SetFloat( p_vout, "scale", f_scale );
219     var_SetBool( p_vout, "autoscale", f_scale != 0. );
220     vlc_object_release( p_vout );
221 }
222
223 char *libvlc_video_get_aspect_ratio( libvlc_media_player_t *p_mi,
224                                      libvlc_exception_t *p_e )
225 {
226     char *psz_aspect = NULL;
227     vout_thread_t *p_vout = GetVout( p_mi, p_e );
228
229     if( !p_vout ) return NULL;
230
231     psz_aspect = var_GetNonEmptyString( p_vout, "aspect-ratio" );
232     vlc_object_release( p_vout );
233     return psz_aspect ? psz_aspect : strdup("");
234 }
235
236 void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi,
237                                     const char *psz_aspect, libvlc_exception_t *p_e )
238 {
239     vout_thread_t *p_vout = GetVout( p_mi, p_e );
240     int i_ret = -1;
241
242     if( !p_vout ) return;
243
244     i_ret = var_SetString( p_vout, "aspect-ratio", psz_aspect );
245     vlc_object_release( p_vout );
246     if( i_ret )
247     {
248         libvlc_exception_raise( p_e );
249         libvlc_printerr( "Bad or unsupported aspect ratio" );
250     }
251 }
252
253 int libvlc_video_get_spu( libvlc_media_player_t *p_mi,
254                           libvlc_exception_t *p_e )
255 {
256     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
257     vlc_value_t val_list;
258     vlc_value_t val;
259     int i_spu = -1;
260     int i_ret = -1;
261     int i;
262
263     if( !p_input_thread ) return -1;
264
265     i_ret = var_Get( p_input_thread, "spu-es", &val );
266     if( i_ret < 0 )
267     {
268         vlc_object_release( p_input_thread );
269         libvlc_exception_raise( p_e );
270         libvlc_printerr( "Subtitle informations not found" );
271         return i_ret;
272     }
273
274     var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL );
275     for( i = 0; i < val_list.p_list->i_count; i++ )
276     {
277         if( val.i_int == val_list.p_list->p_values[i].i_int )
278         {
279             i_spu = i;
280             break;
281         }
282     }
283     var_FreeList( &val_list, NULL );
284     vlc_object_release( p_input_thread );
285     return i_spu;
286 }
287
288 int libvlc_video_get_spu_count( libvlc_media_player_t *p_mi,
289                                 libvlc_exception_t *p_e )
290 {
291     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
292     int i_spu_count;
293
294     if( !p_input_thread )
295         return -1;
296
297     i_spu_count = var_CountChoices( p_input_thread, "spu-es" );
298
299     vlc_object_release( p_input_thread );
300     return i_spu_count;
301 }
302
303 libvlc_track_description_t *
304         libvlc_video_get_spu_description( libvlc_media_player_t *p_mi,
305                                           libvlc_exception_t *p_e )
306 {
307     return libvlc_get_track_description( p_mi, "spu-es", p_e);
308 }
309
310 void libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu,
311                            libvlc_exception_t *p_e )
312 {
313     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
314     vlc_value_t val_list;
315     vlc_value_t newval;
316     int i_ret = -1;
317
318     if( !p_input_thread ) return;
319
320     var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL );
321
322     if( ( val_list.p_list->i_count == 0 )
323      || (i_spu < 0) || (i_spu > val_list.p_list->i_count) )
324     {
325         libvlc_exception_raise( p_e );
326         libvlc_printerr( "Subtitle number out of range" );
327         goto end;
328     }
329
330     newval = val_list.p_list->p_values[i_spu];
331     i_ret = var_Set( p_input_thread, "spu-es", newval );
332     if( i_ret < 0 )
333     {
334         libvlc_exception_raise( p_e );
335         libvlc_printerr( "Subtitle selection error" );
336     }
337
338 end:
339     var_FreeList( &val_list, NULL );
340     vlc_object_release( p_input_thread );
341 }
342
343 int libvlc_video_set_subtitle_file( libvlc_media_player_t *p_mi,
344                                     const char *psz_subtitle,
345                                     libvlc_exception_t *p_e )
346 {
347     input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi, p_e );
348     bool b_ret = false;
349
350     if( p_input_thread )
351     {
352         if( !input_AddSubtitle( p_input_thread, psz_subtitle, true ) )
353             b_ret = true;
354         vlc_object_release( p_input_thread );
355     }
356     return b_ret;
357 }
358
359 libvlc_track_description_t *
360         libvlc_video_get_title_description( libvlc_media_player_t *p_mi,
361                                             libvlc_exception_t * p_e )
362 {
363     return libvlc_get_track_description( p_mi, "title", p_e);
364 }
365
366 libvlc_track_description_t *
367         libvlc_video_get_chapter_description( libvlc_media_player_t *p_mi,
368                                               int i_title,
369                                               libvlc_exception_t *p_e )
370 {
371     char psz_title[12];
372     sprintf( psz_title,  "title %2i", i_title );
373     return libvlc_get_track_description( p_mi, psz_title, p_e);
374 }
375
376 char *libvlc_video_get_crop_geometry( libvlc_media_player_t *p_mi,
377                                    libvlc_exception_t *p_e )
378 {
379     char *psz_geometry = 0;
380     vout_thread_t *p_vout = GetVout( p_mi, p_e );
381
382     if( !p_vout ) return 0;
383
384     psz_geometry = var_GetNonEmptyString( p_vout, "crop" );
385     vlc_object_release( p_vout );
386     return psz_geometry ? psz_geometry : strdup("");
387 }
388
389 void libvlc_video_set_crop_geometry( libvlc_media_player_t *p_mi,
390                                      const char *psz_geometry, libvlc_exception_t *p_e )
391 {
392     vout_thread_t *p_vout = GetVout( p_mi, p_e );
393     int i_ret = -1;
394
395     if( !p_vout ) return;
396
397     i_ret = var_SetString( p_vout, "crop", psz_geometry );
398     vlc_object_release( p_vout );
399
400     if( i_ret )
401     {
402         libvlc_exception_raise( p_e );
403         libvlc_printerr( "Bad or unsupported cropping geometry" );
404     }
405 }
406
407 int libvlc_video_get_teletext( libvlc_media_player_t *p_mi,
408                                libvlc_exception_t *p_e )
409 {
410 #if 0
411     vout_thread_t *p_vout = GetVout( p_mi, p_e );
412     vlc_object_t *p_vbi;
413     int i_ret = -1;
414
415     if( !p_vout ) return i_ret;
416
417     p_vbi = (vlc_object_t *) vlc_object_find_name( p_vout, "zvbi",
418                                                    FIND_CHILD );
419     if( p_vbi )
420     {
421         i_ret = var_GetInteger( p_vbi, "vbi-page" );
422         vlc_object_release( p_vbi );
423     }
424
425     vlc_object_release( p_vout );
426     return i_ret;
427 #else
428     VLC_UNUSED( p_mi );
429     VLC_UNUSED( p_e );
430     return -1;
431 #endif
432 }
433
434 void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page,
435                                 libvlc_exception_t *p_e )
436 {
437 #if 0
438     vout_thread_t *p_vout = GetVout( p_mi, p_e );
439     vlc_object_t *p_vbi;
440     int i_ret = -1;
441
442     if( !p_vout ) return;
443
444     p_vbi = (vlc_object_t *) vlc_object_find_name( p_vout, "zvbi",
445                                                    FIND_CHILD );
446     if( p_vbi )
447     {
448         i_ret = var_SetInteger( p_vbi, "vbi-page", i_page );
449         vlc_object_release( p_vbi );
450         if( i_ret )
451             libvlc_exception_raise( p_e,
452                             "Unexpected error while setting teletext page" );
453     }
454     vlc_object_release( p_vout );
455 #else
456     VLC_UNUSED( p_mi );
457     VLC_UNUSED( p_e );
458     VLC_UNUSED( i_page );
459 #endif
460 }
461
462 void libvlc_toggle_teletext( libvlc_media_player_t *p_mi,
463                              libvlc_exception_t *p_e )
464 {
465     input_thread_t *p_input_thread;
466
467     p_input_thread = libvlc_get_input_thread(p_mi, p_e);
468     if( !p_input_thread ) return;
469
470     if( var_CountChoices( p_input_thread, "teletext-es" ) <= 0 )
471     {
472         vlc_object_release( p_input_thread );
473         return;
474     }
475     const bool b_selected = var_GetInteger( p_input_thread, "teletext-es" ) >= 0;
476 #if 0
477     int i_ret;
478     vlc_object_t *p_vbi;
479     p_vbi = (vlc_object_t *)vlc_object_find_name( p_input_thread, "zvbi",
480                                                   FIND_CHILD );
481     if( p_vbi )
482     {
483         if( b_selected )
484         {
485             /* FIXME Gni, why that ? */
486             i_ret = var_SetInteger( p_vbi, "vbi-page",
487                                     var_GetInteger( p_vbi, "vbi-page" ) );
488             if( i_ret )
489                 libvlc_exception_raise( p_e,
490                                 "Unexpected error while setting teletext page" );
491         }
492         else
493         {
494             /* FIXME Gni^2 */
495             i_ret = var_SetBool( p_vbi, "vbi-opaque",
496                                  !var_GetBool( p_vbi, "vbi-opaque" ) );
497             if( i_ret )
498                 libvlc_exception_raise( p_e,
499                                 "Unexpected error while setting teletext transparency" );
500         }
501         vlc_object_release( p_vbi );
502     }
503     else
504 #endif
505     if( b_selected )
506     {
507         var_SetInteger( p_input_thread, "spu-es", -1 );
508     }
509     else
510     {
511         vlc_value_t list;
512         if( !var_Change( p_input_thread, "teletext-es", VLC_VAR_GETLIST, &list, NULL ) )
513         {
514             if( list.p_list->i_count > 0 )
515                 var_SetInteger( p_input_thread, "spu-es", list.p_list->p_values[0].i_int );
516
517             var_FreeList( &list, NULL );
518         }
519     }
520     vlc_object_release( p_input_thread );
521 }
522
523 int libvlc_video_get_track_count( libvlc_media_player_t *p_mi,
524                                   libvlc_exception_t *p_e )
525 {
526     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
527     int i_track_count;
528
529     if( !p_input_thread )
530         return -1;
531
532     i_track_count = var_CountChoices( p_input_thread, "video-es" );
533
534     vlc_object_release( p_input_thread );
535     return i_track_count;
536 }
537
538 libvlc_track_description_t *
539         libvlc_video_get_track_description( libvlc_media_player_t *p_mi,
540                                             libvlc_exception_t *p_e )
541 {
542     return libvlc_get_track_description( p_mi, "video-es", p_e);
543 }
544
545 int libvlc_video_get_track( libvlc_media_player_t *p_mi,
546                             libvlc_exception_t *p_e )
547 {
548     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
549     vlc_value_t val_list;
550     vlc_value_t val;
551     int i_track = -1;
552     int i_ret = -1;
553     int i;
554
555     if( !p_input_thread )
556         return -1;
557
558     i_ret = var_Get( p_input_thread, "video-es", &val );
559     if( i_ret < 0 )
560     {
561         libvlc_exception_raise( p_e );
562         libvlc_printerr( "Video track information not found" );
563         vlc_object_release( p_input_thread );
564         return i_ret;
565     }
566
567     var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
568     for( i = 0; i < val_list.p_list->i_count; i++ )
569     {
570         if( val_list.p_list->p_values[i].i_int == val.i_int )
571         {
572             i_track = i;
573             break;
574         }
575     }
576     var_FreeList( &val_list, NULL );
577     vlc_object_release( p_input_thread );
578     return i_track;
579 }
580
581 void libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track,
582                              libvlc_exception_t *p_e )
583 {
584     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
585     vlc_value_t val_list;
586     int i_ret = -1;
587     int i;
588
589     if( !p_input_thread )
590         return;
591
592     var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
593     for( i = 0; i < val_list.p_list->i_count; i++ )
594     {
595         if( i_track == val_list.p_list->p_values[i].i_int )
596         {
597             i_ret = var_SetInteger( p_input_thread, "video-es", i_track );
598             if( i_ret < 0 )
599                 break;
600             goto end;
601         }
602     }
603     libvlc_exception_raise( p_e );
604     libvlc_printerr( "Video track number out of range" );
605 end:
606     var_FreeList( &val_list, NULL );
607     vlc_object_release( p_input_thread );
608 }
609
610 /******************************************************************************
611  * libvlc_video_set_deinterlace : enable deinterlace
612  *****************************************************************************/
613 void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi, int b_enable,
614                                    const char *psz_mode,
615                                    libvlc_exception_t *p_e )
616 {
617     vout_thread_t *p_vout = GetVout( p_mi, p_e );
618
619     if( !p_vout )
620         return;
621
622     if( b_enable )
623     {
624         /* be sure that the filter name given is supported */
625         if( !strcmp(psz_mode, "blend")   || !strcmp(psz_mode, "bob")
626          || !strcmp(psz_mode, "discard") || !strcmp(psz_mode, "linear")
627          || !strcmp(psz_mode, "mean")    || !strcmp(psz_mode, "x")
628          || !strcmp(psz_mode, "yadif")   || !strcmp(psz_mode, "yadif2x") )
629         {
630             /* set deinterlace filter chosen */
631             var_SetString( p_vout, "deinterlace-mode", psz_mode );
632             var_SetInteger( p_vout, "deinterlace", 1 );
633         }
634         else
635         {
636             libvlc_exception_raise( p_e );
637             libvlc_printerr( "Bad or unsupported deinterlacing mode" );
638         }
639     }
640     else
641     {
642         /* disable deinterlace filter */
643         var_SetInteger( p_vout, "deinterlace", 0 );
644     }
645
646     vlc_object_release( p_vout );
647 }
648
649 /*****************************************************************************
650  * Marquee: FIXME: That implementation has no persistent state and requires
651  * a vout
652  *****************************************************************************/
653
654 static const char *get_marquee_int_option_identifier(unsigned option)
655 {
656     static const char tab[][16] =
657     {
658         "marq",
659         "marq-color",
660         "marq-opacity",
661         "marq-position",
662         "marq-refresh",
663         "marq-size",
664         "marq-timeout",
665         "marq-x",
666         "marq-y",
667     };
668     if( option >= sizeof( tab ) / sizeof( tab[0] ) )
669         return NULL;
670     return tab[option];
671 }
672
673 static const char *get_marquee_string_option_identifier(unsigned option)
674 {
675     static const char tab[][16] =
676     {
677         "marq-marquee",
678     };
679     if( option >= sizeof( tab ) / sizeof( tab[0] ) )
680         return NULL;
681     return tab[option];
682 }
683
684
685 static vlc_object_t *get_marquee_object( libvlc_media_player_t * p_mi )
686 {
687     libvlc_exception_t e;
688     libvlc_exception_init(&e);
689     vout_thread_t * vout = GetVout( p_mi, &e );
690     libvlc_exception_clear(&e);
691     if( !vout )
692         return NULL;
693     vlc_object_t * object = vlc_object_find_name( vout, "marq", FIND_CHILD );
694     vlc_object_release(vout);
695     return object;
696 }
697
698 /*****************************************************************************
699  * libvlc_video_get_marquee_option_as_int : get a marq option value
700  *****************************************************************************/
701 int libvlc_video_get_marquee_option_as_int( libvlc_media_player_t *p_mi,
702                                             libvlc_video_marquee_int_option_t option,
703                                             libvlc_exception_t *p_e )
704 {
705     const char * identifier = get_marquee_int_option_identifier(option);
706     if(!identifier)
707     {
708         libvlc_exception_raise( p_e );
709         libvlc_printerr( "Unknown marquee option" );
710         return 0;
711     }
712     vlc_object_t * marquee = get_marquee_object(p_mi);
713
714     /* Handle the libvlc_marquee_Enabled separately */
715     if(option == libvlc_marquee_Enabled)
716     {
717         bool isEnabled = marquee != NULL;
718         vlc_object_release(marquee);
719         return isEnabled;
720     }
721
722     /* Generic case */
723     if(!identifier)
724     {
725         libvlc_exception_raise( p_e );
726         libvlc_printerr( "Marquee not enabled" );
727         return 0;
728     }
729 #warning This and the next function may crash due to type checking!
730     int ret = var_GetInteger(marquee, identifier);
731     vlc_object_release(marquee);
732     return ret;
733 }
734
735 /*****************************************************************************
736  * libvlc_video_get_marquee_option_as_string : get a marq option value
737  *****************************************************************************/
738 char * libvlc_video_get_marquee_option_as_string( libvlc_media_player_t *p_mi,
739                                                   libvlc_video_marquee_string_option_t option,
740                                                   libvlc_exception_t *p_e )
741 {
742     const char * identifier = get_marquee_string_option_identifier(option);
743     if(!identifier)
744     {
745         libvlc_exception_raise( p_e );
746         libvlc_printerr( "Unknown marquee option" );
747         return NULL;
748     }
749
750     vlc_object_t * marquee = get_marquee_object(p_mi);
751     if(!marquee)
752     {
753         libvlc_exception_raise( p_e );
754         libvlc_printerr( "Marquee not enabled" );
755         return NULL;
756     }
757     char *ret = var_GetString(marquee, identifier);
758     vlc_object_release(marquee);
759     return ret;
760 }
761
762 /*****************************************************************************
763  * libvlc_video_set_marquee_option_as_int: enable, disable or set an int option
764  *****************************************************************************/
765 void libvlc_video_set_marquee_option_as_int( libvlc_media_player_t *p_mi,
766                                           libvlc_video_marquee_int_option_t option,
767                                           int value, libvlc_exception_t *p_e )
768 {
769     const char * identifier = get_marquee_int_option_identifier(option);
770     if(!identifier)
771     {
772         libvlc_exception_raise( p_e );
773         libvlc_printerr( "Unknown marquee option" );
774         return;
775     }
776
777     /* Handle the libvlc_marquee_Enabled separately */
778     if(option == libvlc_marquee_Enabled)
779     {
780         libvlc_exception_t e;
781         libvlc_exception_init(&e);
782         vout_thread_t * vout = GetVout( p_mi, &e );
783         libvlc_exception_clear(&e);
784         if (vout)
785         {
786             vout_EnableFilter(vout, identifier, value, false);
787             vlc_object_release(vout);
788         }
789         return;
790     }
791
792     vlc_object_t * marquee = get_marquee_object(p_mi);
793     if(!marquee)
794     {
795         libvlc_exception_raise( p_e );
796         libvlc_printerr( "Marquee not enabled" );
797         return;
798     }
799     var_SetInteger(marquee, identifier, value);
800     vlc_object_release(marquee);
801 }
802
803 /*****************************************************************************
804  * libvlc_video_set_marquee_option_as_string: set a string option
805  *****************************************************************************/
806 void libvlc_video_set_marquee_option_as_string( libvlc_media_player_t *p_mi,
807                                              libvlc_video_marquee_string_option_t option,
808                                              const char * value,
809                                              libvlc_exception_t *p_e )
810 {
811     const char * identifier = get_marquee_string_option_identifier(option);
812     if(!identifier)
813     {
814         libvlc_exception_raise( p_e );
815         libvlc_printerr( "Unknown marquee option" );
816         return;
817     }
818     vlc_object_t * marquee = get_marquee_object(p_mi);
819     if(!marquee)
820     {
821         libvlc_exception_raise( p_e );
822         libvlc_printerr( "Marquee not enabled" );
823         return;
824     }
825     var_SetString(marquee, identifier, value);
826     vlc_object_release(marquee);
827 }