]> git.sesse.net Git - vlc/blob - src/control/video.c
Move LibVLC error messages to libvlc_printerr().
[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     return -1;
429 #endif
430 }
431
432 void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page,
433                                 libvlc_exception_t *p_e )
434 {
435 #if 0
436     vout_thread_t *p_vout = GetVout( p_mi, p_e );
437     vlc_object_t *p_vbi;
438     int i_ret = -1;
439
440     if( !p_vout ) return;
441
442     p_vbi = (vlc_object_t *) vlc_object_find_name( p_vout, "zvbi",
443                                                    FIND_CHILD );
444     if( p_vbi )
445     {
446         i_ret = var_SetInteger( p_vbi, "vbi-page", i_page );
447         vlc_object_release( p_vbi );
448         if( i_ret )
449             libvlc_exception_raise( p_e,
450                             "Unexpected error while setting teletext page" );
451     }
452     vlc_object_release( p_vout );
453 #endif
454 }
455
456 void libvlc_toggle_teletext( libvlc_media_player_t *p_mi,
457                              libvlc_exception_t *p_e )
458 {
459     input_thread_t *p_input_thread;
460     int i_ret;
461
462     p_input_thread = libvlc_get_input_thread(p_mi, p_e);
463     if( !p_input_thread ) return;
464
465     if( var_CountChoices( p_input_thread, "teletext-es" ) <= 0 )
466     {
467         vlc_object_release( p_input_thread );
468         return;
469     }
470     const bool b_selected = var_GetInteger( p_input_thread, "teletext-es" ) >= 0;
471 #if 0
472     vlc_object_t *p_vbi;
473     p_vbi = (vlc_object_t *)vlc_object_find_name( p_input_thread, "zvbi",
474                                                   FIND_CHILD );
475     if( p_vbi )
476     {
477         if( b_selected )
478         {
479             /* FIXME Gni, why that ? */
480             i_ret = var_SetInteger( p_vbi, "vbi-page",
481                                     var_GetInteger( p_vbi, "vbi-page" ) );
482             if( i_ret )
483                 libvlc_exception_raise( p_e,
484                                 "Unexpected error while setting teletext page" );
485         }
486         else
487         {
488             /* FIXME Gni^2 */
489             i_ret = var_SetBool( p_vbi, "vbi-opaque",
490                                  !var_GetBool( p_vbi, "vbi-opaque" ) );
491             if( i_ret )
492                 libvlc_exception_raise( p_e,
493                                 "Unexpected error while setting teletext transparency" );
494         }
495         vlc_object_release( p_vbi );
496     }
497     else
498 #endif
499     if( b_selected )
500     {
501         var_SetInteger( p_input_thread, "spu-es", -1 );
502     }
503     else
504     {
505         vlc_value_t list;
506         if( !var_Change( p_input_thread, "teletext-es", VLC_VAR_GETLIST, &list, NULL ) )
507         {
508             if( list.p_list->i_count > 0 )
509                 var_SetInteger( p_input_thread, "spu-es", list.p_list->p_values[0].i_int );
510
511             var_FreeList( &list, NULL );
512         }
513     }
514     vlc_object_release( p_input_thread );
515 }
516
517 int libvlc_video_get_track_count( libvlc_media_player_t *p_mi,
518                                   libvlc_exception_t *p_e )
519 {
520     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
521     int i_track_count;
522
523     if( !p_input_thread )
524         return -1;
525
526     i_track_count = var_CountChoices( p_input_thread, "video-es" );
527
528     vlc_object_release( p_input_thread );
529     return i_track_count;
530 }
531
532 libvlc_track_description_t *
533         libvlc_video_get_track_description( libvlc_media_player_t *p_mi,
534                                             libvlc_exception_t *p_e )
535 {
536     return libvlc_get_track_description( p_mi, "video-es", p_e);
537 }
538
539 int libvlc_video_get_track( libvlc_media_player_t *p_mi,
540                             libvlc_exception_t *p_e )
541 {
542     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
543     vlc_value_t val_list;
544     vlc_value_t val;
545     int i_track = -1;
546     int i_ret = -1;
547     int i;
548
549     if( !p_input_thread )
550         return -1;
551
552     i_ret = var_Get( p_input_thread, "video-es", &val );
553     if( i_ret < 0 )
554     {
555         libvlc_exception_raise( p_e );
556         libvlc_printerr( "Video track information not found" );
557         vlc_object_release( p_input_thread );
558         return i_ret;
559     }
560
561     var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
562     for( i = 0; i < val_list.p_list->i_count; i++ )
563     {
564         if( val_list.p_list->p_values[i].i_int == val.i_int )
565         {
566             i_track = i;
567             break;
568         }
569     }
570     var_FreeList( &val_list, NULL );
571     vlc_object_release( p_input_thread );
572     return i_track;
573 }
574
575 void libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track,
576                              libvlc_exception_t *p_e )
577 {
578     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
579     vlc_value_t val_list;
580     int i_ret = -1;
581     int i;
582
583     if( !p_input_thread )
584         return;
585
586     var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
587     for( i = 0; i < val_list.p_list->i_count; i++ )
588     {
589         if( i_track == val_list.p_list->p_values[i].i_int )
590         {
591             i_ret = var_SetInteger( p_input_thread, "video-es", i_track );
592             if( i_ret < 0 )
593                 break;
594             goto end;
595         }
596     }
597     libvlc_exception_raise( p_e );
598     libvlc_printerr( "Video track number out of range" );
599 end:
600     var_FreeList( &val_list, NULL );
601     vlc_object_release( p_input_thread );
602 }
603
604 /******************************************************************************
605  * libvlc_video_set_deinterlace : enable deinterlace
606  *****************************************************************************/
607 void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi, int b_enable,
608                                    const char *psz_mode,
609                                    libvlc_exception_t *p_e )
610 {
611     vout_thread_t *p_vout = GetVout( p_mi, p_e );
612
613     if( !p_vout )
614         return;
615
616     if( b_enable )
617     {
618         /* be sure that the filter name given is supported */
619         if( !strcmp(psz_mode, "blend")   || !strcmp(psz_mode, "bob")
620          || !strcmp(psz_mode, "discard") || !strcmp(psz_mode, "linear")
621          || !strcmp(psz_mode, "mean")    || !strcmp(psz_mode, "x") )
622         {
623             /* set deinterlace filter chosen */
624             var_SetString( p_vout, "deinterlace", psz_mode );
625         }
626         else
627         {
628             libvlc_exception_raise( p_e );
629             libvlc_printerr( "Bad or unsuported deinterlacing mode" );
630         }
631     }
632     else
633     {
634         /* disable deinterlace filter */
635         var_SetString( p_vout, "deinterlace", "" );
636     }
637
638     vlc_object_release( p_vout );
639 }
640
641 /*****************************************************************************
642  * Marquee: FIXME: That implementation has no persistent state and requires
643  * a vout
644  *****************************************************************************/
645
646 static const char *get_marquee_int_option_identifier(unsigned option)
647 {
648     static const char tab[][16] =
649     {
650         "marq",
651         "marq-color",
652         "marq-opacity",
653         "marq-position",
654         "marq-refresh",
655         "marq-size",
656         "marq-timeout",
657         "marq-x",
658         "marq-y",
659     };
660     if( option >= sizeof( tab ) / sizeof( tab[0] ) )
661         return NULL;
662     return tab[option];
663 }
664
665 static const char *get_marquee_string_option_identifier(unsigned option)
666 {
667     static const char tab[][16] =
668     {
669         "marq-marquee",
670     };
671     if( option >= sizeof( tab ) / sizeof( tab[0] ) )
672         return NULL;
673     return tab[option];
674 }
675
676
677 static vlc_object_t *get_marquee_object( libvlc_media_player_t * p_mi )
678 {
679     libvlc_exception_t e;
680     libvlc_exception_init(&e);
681     vout_thread_t * vout = GetVout( p_mi, &e );
682     libvlc_exception_clear(&e);
683     if( !vout )
684         return NULL;
685     vlc_object_t * object = vlc_object_find_name( vout, "marq", FIND_CHILD );
686     vlc_object_release(vout);
687     return object;
688 }
689
690 /*****************************************************************************
691  * libvlc_video_get_marquee_option_as_int : get a marq option value
692  *****************************************************************************/
693 int libvlc_video_get_marquee_option_as_int( libvlc_media_player_t *p_mi,
694                                             libvlc_video_marquee_int_option_t option,
695                                             libvlc_exception_t *p_e )
696 {
697     const char * identifier = get_marquee_int_option_identifier(option);
698     if(!identifier)
699     {
700         libvlc_exception_raise( p_e );
701         libvlc_printerr( "Unknown marquee option" );
702         return 0;
703     }
704     vlc_object_t * marquee = get_marquee_object(p_mi);
705
706     /* Handle the libvlc_marquee_Enabled separately */
707     if(option == libvlc_marquee_Enabled)
708     {
709         bool isEnabled = marquee != NULL;
710         vlc_object_release(marquee);
711         return isEnabled;
712     }
713
714     /* Generic case */
715     if(!identifier)
716     {
717         libvlc_exception_raise( p_e );
718         libvlc_printerr( "Marquee not enabled" );
719         return 0;
720     }
721 #warning This and the next function may crash due to type checking!
722     int ret = var_GetInteger(marquee, identifier);
723     vlc_object_release(marquee);
724     return ret;
725 }
726
727 /*****************************************************************************
728  * libvlc_video_get_marquee_option_as_string : get a marq option value
729  *****************************************************************************/
730 char * libvlc_video_get_marquee_option_as_string( libvlc_media_player_t *p_mi,
731                                                   libvlc_video_marquee_string_option_t option,
732                                                   libvlc_exception_t *p_e )
733 {
734     const char * identifier = get_marquee_string_option_identifier(option);
735     if(!identifier)
736     {
737         libvlc_exception_raise( p_e );
738         libvlc_printerr( "Unknown marquee option" );
739         return NULL;
740     }
741
742     vlc_object_t * marquee = get_marquee_object(p_mi);
743     if(!marquee)
744     {
745         libvlc_exception_raise( p_e );
746         libvlc_printerr( "Marquee not enabled" );
747         return NULL;
748     }
749     char *ret = var_GetString(marquee, identifier);
750     vlc_object_release(marquee);
751     return ret;
752 }
753
754 /*****************************************************************************
755  * libvlc_video_set_marquee_option_as_int: enable, disable or set an int option
756  *****************************************************************************/
757 void libvlc_video_set_marquee_option_as_int( libvlc_media_player_t *p_mi,
758                                           libvlc_video_marquee_int_option_t option,
759                                           int value, libvlc_exception_t *p_e )
760 {
761     const char * identifier = get_marquee_int_option_identifier(option);
762     if(!identifier)
763     {
764         libvlc_exception_raise( p_e );
765         libvlc_printerr( "Unknown marquee option" );
766         return;
767     }
768
769     /* Handle the libvlc_marquee_Enabled separately */
770     if(option == libvlc_marquee_Enabled)
771     {
772         libvlc_exception_t e;
773         libvlc_exception_init(&e);
774         vout_thread_t * vout = GetVout( p_mi, &e );
775         libvlc_exception_clear(&e);
776         if (vout)
777         {
778             vout_EnableFilter(vout, identifier, value, false);
779             vlc_object_release(vout);
780         }
781         return;
782     }
783
784     vlc_object_t * marquee = get_marquee_object(p_mi);
785     if(!marquee)
786     {
787         libvlc_exception_raise( p_e );
788         libvlc_printerr( "Marquee not enabled" );
789         return;
790     }
791     var_SetInteger(marquee, identifier, value);
792     vlc_object_release(marquee);
793 }
794
795 /*****************************************************************************
796  * libvlc_video_set_marquee_option_as_string: set a string option
797  *****************************************************************************/
798 void libvlc_video_set_marquee_option_as_string( libvlc_media_player_t *p_mi,
799                                              libvlc_video_marquee_string_option_t option,
800                                              const char * value,
801                                              libvlc_exception_t *p_e )
802 {
803     const char * identifier = get_marquee_string_option_identifier(option);
804     if(!identifier)
805     {
806         libvlc_exception_raise( p_e );
807         libvlc_printerr( "Unknown marquee option" );
808         return;
809     }
810     vlc_object_t * marquee = get_marquee_object(p_mi);
811     if(!marquee)
812     {
813         libvlc_exception_raise( p_e );
814         libvlc_printerr( "Marquee not enabled" );
815         return;
816     }
817     var_SetString(marquee, identifier, value);
818     vlc_object_release(marquee);
819 }