]> git.sesse.net Git - vlc/blob - src/control/video.c
ea10304fb7a02342e3a3a3531812557f446ca4f5
[vlc] / src / control / video.c
1 /*****************************************************************************
2  * video.c: libvlc new API video functions
3  *****************************************************************************
4  * Copyright (C) 2005-2010 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 <assert.h>
42
43 /*
44  * Remember to release the returned vout_thread_t.
45  */
46 static vout_thread_t **GetVouts( libvlc_media_player_t *p_mi, size_t *n )
47 {
48     input_thread_t *p_input = libvlc_get_input_thread( p_mi );
49     if( !p_input )
50         return NULL;
51
52     vout_thread_t **pp_vouts;
53     if (input_Control( p_input, INPUT_GET_VOUTS, &pp_vouts, n))
54     {
55         *n = 0;
56         pp_vouts = NULL;
57     }
58     vlc_object_release (p_input);
59     return pp_vouts;
60 }
61
62 static vout_thread_t *GetVout (libvlc_media_player_t *mp, size_t num)
63 {
64     vout_thread_t *p_vout = NULL;
65     size_t n;
66     vout_thread_t **pp_vouts = GetVouts (mp, &n);
67     if (pp_vouts == NULL)
68         goto err;
69
70     if (num < n)
71         p_vout = pp_vouts[num];
72
73     for (size_t i = 0; i < n; i++)
74         if (i != num)
75             vlc_object_release (pp_vouts[i]);
76     free (pp_vouts);
77
78     if (p_vout == NULL)
79 err:
80         libvlc_printerr ("Video output not active");
81     return p_vout;
82 }
83
84 /**********************************************************************
85  * Exported functions
86  **********************************************************************/
87
88 void libvlc_set_fullscreen( libvlc_media_player_t *p_mi, int b_fullscreen )
89 {
90     /* This will work even if the video is not currently active */
91     var_SetBool (p_mi, "fullscreen", !!b_fullscreen);
92
93     /* Apply to current video outputs (if any) */
94     size_t n;
95     vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
96     for (size_t i = 0; i < n; i++)
97     {
98         var_SetBool (pp_vouts[i], "fullscreen", b_fullscreen);
99         vlc_object_release (pp_vouts[i]);
100     }
101     free (pp_vouts);
102 }
103
104 int libvlc_get_fullscreen( libvlc_media_player_t *p_mi )
105 {
106     return var_GetBool (p_mi, "fullscreen");
107 }
108
109 void libvlc_toggle_fullscreen( libvlc_media_player_t *p_mi )
110 {
111     bool b_fullscreen = var_ToggleBool (p_mi, "fullscreen");
112
113     /* Apply to current video outputs (if any) */
114     size_t n;
115     vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
116     for (size_t i = 0; i < n; i++)
117     {
118         vout_thread_t *p_vout = pp_vouts[i];
119
120         var_SetBool (p_vout, "fullscreen", b_fullscreen);
121         vlc_object_release (p_vout);
122     }
123     free (pp_vouts);
124 }
125
126 void libvlc_video_set_key_input( libvlc_media_player_t *p_mi, unsigned on )
127 {
128     var_SetBool (p_mi, "keyboard-events", !!on);
129 }
130
131 void libvlc_video_set_mouse_input( libvlc_media_player_t *p_mi, unsigned on )
132 {
133     var_SetBool (p_mi, "mouse-events", !!on);
134 }
135
136 int
137 libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, unsigned num,
138                             const char *psz_filepath,
139                             unsigned int i_width, unsigned int i_height )
140 {
141     assert( psz_filepath );
142
143     vout_thread_t *p_vout = GetVout (p_mi, num);
144     if (p_vout == NULL)
145         return -1;
146
147     /* FIXME: This is not atomic. Someone else could change the values,
148      * at least in theory. */
149     var_SetInteger( p_vout, "snapshot-width", i_width);
150     var_SetInteger( p_vout, "snapshot-height", i_height );
151     var_SetString( p_vout, "snapshot-path", psz_filepath );
152     var_SetString( p_vout, "snapshot-format", "png" );
153     var_TriggerCallback (p_vout, "video-snapshot" );
154     return 0;
155 }
156
157 int libvlc_video_get_size( libvlc_media_player_t *p_mi, unsigned num,
158                            unsigned *restrict px, unsigned *restrict py )
159 {
160 #if 0
161     vout_thread_t *p_vout = GetVout (p_mi, num);
162     if (p_vout == NULL)
163         return -1;
164
165     *px = p_vout->i_window_height;
166     *py = p_vout->i_window_width;
167     vlc_object_release (p_vout);
168     return 0;
169 #else
170     return -1;
171 #endif
172 }
173
174 int libvlc_video_get_height( libvlc_media_player_t *p_mi )
175 {
176     unsigned height, width;
177
178     if (libvlc_video_get_size (p_mi, 0, &height, &width))
179         return 0;
180     return height;
181 }
182
183 int libvlc_video_get_width( libvlc_media_player_t *p_mi )
184 {
185     unsigned height, width;
186
187     if (libvlc_video_get_size (p_mi, 0, &height, &width))
188         return 0;
189     return width;
190 }
191
192 int libvlc_video_get_cursor( libvlc_media_player_t *mp, unsigned num,
193                              int *restrict px, int *restrict py )
194 {
195     vout_thread_t *p_vout = GetVout (mp, num);
196     if (p_vout == NULL)
197         return -1;
198
199     var_GetCoords (p_vout, "mouse-moved", px, py);
200     vlc_object_release (p_vout);
201     return 0;
202 }
203
204 unsigned libvlc_media_player_has_vout( libvlc_media_player_t *p_mi )
205 {
206     size_t n;
207     vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
208     for (size_t i = 0; i < n; i++)
209         vlc_object_release (pp_vouts[i]);
210     free (pp_vouts);
211     return n;
212 }
213
214 float libvlc_video_get_scale( libvlc_media_player_t *mp )
215 {
216     float f_scale = var_GetFloat (mp, "scale");
217     if (var_GetBool (mp, "autoscale"))
218         f_scale = 0.;
219     return f_scale;
220 }
221
222 void libvlc_video_set_scale( libvlc_media_player_t *p_mp, float f_scale )
223 {
224     if (f_scale != 0.)
225         var_SetFloat (p_mp, "scale", f_scale);
226     var_SetBool (p_mp, "autoscale", f_scale == 0.);
227
228     /* Apply to current video outputs (if any) */
229     size_t n;
230     vout_thread_t **pp_vouts = GetVouts (p_mp, &n);
231     for (size_t i = 0; i < n; i++)
232     {
233         vout_thread_t *p_vout = pp_vouts[i];
234
235         if (f_scale != 0.)
236             var_SetFloat (p_vout, "scale", f_scale);
237         var_SetBool (p_vout, "autoscale", f_scale == 0.);
238         vlc_object_release (p_vout);
239     }
240     free (pp_vouts);
241 }
242
243 char *libvlc_video_get_aspect_ratio( libvlc_media_player_t *p_mi )
244 {
245     return var_GetNonEmptyString (p_mi, "aspect-ratio");
246 }
247
248 void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi,
249                                     const char *psz_aspect )
250 {
251     if (psz_aspect == NULL)
252         psz_aspect = "";
253     var_SetString (p_mi, "aspect-ratio", psz_aspect);
254
255     size_t n;
256     vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
257     for (size_t i = 0; i < n; i++)
258     {
259         vout_thread_t *p_vout = pp_vouts[i];
260
261         var_SetString (p_vout, "aspect-ratio", psz_aspect);
262         vlc_object_release (p_vout);
263     }
264     free (pp_vouts);
265 }
266
267 int libvlc_video_get_spu( libvlc_media_player_t *p_mi )
268 {
269     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
270     vlc_value_t val_list;
271     vlc_value_t val;
272     int i_spu = -1;
273     int i_ret = -1;
274     int i;
275
276     if( !p_input_thread )
277     {
278         libvlc_printerr( "No active input" );
279         return -1;
280     }
281
282     i_ret = var_Get( p_input_thread, "spu-es", &val );
283     if( i_ret < 0 )
284     {
285         vlc_object_release( p_input_thread );
286         libvlc_printerr( "Subtitle informations not found" );
287         return -1;
288     }
289
290     var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL );
291     for( i = 0; i < val_list.p_list->i_count; i++ )
292     {
293         if( val.i_int == val_list.p_list->p_values[i].i_int )
294         {
295             i_spu = i;
296             break;
297         }
298     }
299     var_FreeList( &val_list, NULL );
300     vlc_object_release( p_input_thread );
301     return i_spu;
302 }
303
304 int libvlc_video_get_spu_count( libvlc_media_player_t *p_mi )
305 {
306     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
307     int i_spu_count;
308
309     if( !p_input_thread )
310         return 0;
311
312     i_spu_count = var_CountChoices( p_input_thread, "spu-es" );
313     vlc_object_release( p_input_thread );
314     return i_spu_count;
315 }
316
317 libvlc_track_description_t *
318         libvlc_video_get_spu_description( libvlc_media_player_t *p_mi )
319 {
320     return libvlc_get_track_description( p_mi, "spu-es" );
321 }
322
323 int libvlc_video_set_spu( libvlc_media_player_t *p_mi, unsigned i_spu )
324 {
325     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
326     vlc_value_t list;
327     int i_ret = 0;
328
329     if( !p_input_thread )
330         return -1;
331
332     var_Change (p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &list, NULL);
333
334     if (i_spu > (unsigned)list.p_list->i_count)
335     {
336         libvlc_printerr( "Subtitle number out of range (%u/%u)",
337                          i_spu, list.p_list->i_count );
338         i_ret = -1;
339         goto end;
340     }
341     var_SetInteger (p_input_thread, "spu-es",
342                     list.p_list->p_values[i_spu].i_int);
343 end:
344     vlc_object_release (p_input_thread);
345     var_FreeList (&list, NULL);
346     return i_ret;
347 }
348
349 int libvlc_video_set_subtitle_file( libvlc_media_player_t *p_mi,
350                                     const char *psz_subtitle )
351 {
352     input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi );
353     bool b_ret = false;
354
355     if( p_input_thread )
356     {
357         if( !input_AddSubtitle( p_input_thread, psz_subtitle, true ) )
358             b_ret = true;
359         vlc_object_release( p_input_thread );
360     }
361     return b_ret;
362 }
363
364 libvlc_track_description_t *
365         libvlc_video_get_title_description( libvlc_media_player_t *p_mi )
366 {
367     return libvlc_get_track_description( p_mi, "title" );
368 }
369
370 libvlc_track_description_t *
371         libvlc_video_get_chapter_description( libvlc_media_player_t *p_mi,
372                                               int i_title )
373 {
374     char psz_title[12];
375     sprintf( psz_title,  "title %2i", i_title );
376     return libvlc_get_track_description( p_mi, psz_title );
377 }
378
379 char *libvlc_video_get_crop_geometry (libvlc_media_player_t *p_mi)
380 {
381     return var_GetNonEmptyString (p_mi, "crop");
382 }
383
384 void libvlc_video_set_crop_geometry( libvlc_media_player_t *p_mi,
385                                      const char *psz_geometry )
386 {
387     if (psz_geometry == NULL)
388         psz_geometry = "";
389
390     var_SetString (p_mi, "crop", psz_geometry);
391
392     size_t n;
393     vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
394
395     for (size_t i = 0; i < n; i++)
396     {
397         vout_thread_t *p_vout = pp_vouts[i];
398
399         var_SetString (p_vout, "crop", psz_geometry);
400         vlc_object_release (p_vout);
401     }
402     free (pp_vouts);
403 }
404
405 int libvlc_video_get_teletext( libvlc_media_player_t *p_mi )
406 {
407     return var_GetInteger (p_mi, "vbi-page");
408 }
409
410 void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
411 {
412     input_thread_t *p_input_thread;
413     vlc_object_t *p_zvbi = NULL;
414     int telx;
415
416     var_SetInteger (p_mi, "vbi-page", i_page);
417
418     p_input_thread = libvlc_get_input_thread( p_mi );
419     if( !p_input_thread ) return;
420
421     if( var_CountChoices( p_input_thread, "teletext-es" ) <= 0 )
422     {
423         vlc_object_release( p_input_thread );
424         return;
425     }
426
427     telx = var_GetInteger( p_input_thread, "teletext-es" );
428     if( input_GetEsObjects( p_input_thread, telx, &p_zvbi, NULL, NULL )
429         == VLC_SUCCESS )
430     {
431         var_SetInteger( p_zvbi, "vbi-page", i_page );
432         vlc_object_release( p_zvbi );
433     }
434     vlc_object_release( p_input_thread );
435 }
436
437 void libvlc_toggle_teletext( libvlc_media_player_t *p_mi )
438 {
439     input_thread_t *p_input_thread;
440
441     p_input_thread = libvlc_get_input_thread(p_mi);
442     if( !p_input_thread ) return;
443
444     if( var_CountChoices( p_input_thread, "teletext-es" ) <= 0 )
445     {
446         vlc_object_release( p_input_thread );
447         return;
448     }
449     const bool b_selected = var_GetInteger( p_input_thread, "teletext-es" ) >= 0;
450     if( b_selected )
451     {
452         var_SetInteger( p_input_thread, "spu-es", -1 );
453     }
454     else
455     {
456         vlc_value_t list;
457         if( !var_Change( p_input_thread, "teletext-es", VLC_VAR_GETLIST, &list, NULL ) )
458         {
459             if( list.p_list->i_count > 0 )
460                 var_SetInteger( p_input_thread, "spu-es", list.p_list->p_values[0].i_int );
461
462             var_FreeList( &list, NULL );
463         }
464     }
465     vlc_object_release( p_input_thread );
466 }
467
468 int libvlc_video_get_track_count( libvlc_media_player_t *p_mi )
469 {
470     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
471     int i_track_count;
472
473     if( !p_input_thread )
474         return -1;
475
476     i_track_count = var_CountChoices( p_input_thread, "video-es" );
477
478     vlc_object_release( p_input_thread );
479     return i_track_count;
480 }
481
482 libvlc_track_description_t *
483         libvlc_video_get_track_description( libvlc_media_player_t *p_mi )
484 {
485     return libvlc_get_track_description( p_mi, "video-es" );
486 }
487
488 int libvlc_video_get_track( libvlc_media_player_t *p_mi )
489 {
490     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
491     vlc_value_t val_list;
492     vlc_value_t val;
493     int i_track = -1;
494
495     if( !p_input_thread )
496         return -1;
497
498     if( var_Get( p_input_thread, "video-es", &val ) < 0 )
499     {
500         libvlc_printerr( "Video track information not found" );
501         vlc_object_release( p_input_thread );
502         return -1;
503     }
504
505     var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
506     for( int i = 0; i < val_list.p_list->i_count; i++ )
507     {
508         if( val_list.p_list->p_values[i].i_int == val.i_int )
509         {
510             i_track = i;
511             break;
512         }
513     }
514     var_FreeList( &val_list, NULL );
515     vlc_object_release( p_input_thread );
516     return i_track;
517 }
518
519 int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track )
520 {
521     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
522     vlc_value_t val_list;
523     int i_ret = -1;
524
525     if( !p_input_thread )
526         return -1;
527
528     var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
529     for( int i = 0; i < val_list.p_list->i_count; i++ )
530     {
531         if( i_track == val_list.p_list->p_values[i].i_int )
532         {
533             if( var_SetInteger( p_input_thread, "video-es", i_track ) < 0 )
534                 break;
535             i_ret = 0;
536             goto end;
537         }
538     }
539     libvlc_printerr( "Video track number out of range" );
540 end:
541     var_FreeList( &val_list, NULL );
542     vlc_object_release( p_input_thread );
543     return i_ret;
544 }
545
546 /******************************************************************************
547  * libvlc_video_set_deinterlace : enable deinterlace
548  *****************************************************************************/
549 void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi,
550                                    const char *psz_mode )
551 {
552     if (psz_mode == NULL)
553         psz_mode = "";
554     if (*psz_mode
555      && strcmp (psz_mode, "blend")   && strcmp (psz_mode, "bob")
556      && strcmp (psz_mode, "discard") && strcmp (psz_mode, "linear")
557      && strcmp (psz_mode, "mean")    && strcmp (psz_mode, "x")
558      && strcmp (psz_mode, "yadif")   && strcmp (psz_mode, "yadif2x"))
559         return;
560
561     if (*psz_mode)
562     {
563         var_SetString (p_mi, "deinterlace-mode", psz_mode);
564         var_SetInteger (p_mi, "deinterlace", 1);
565     }
566     else
567         var_SetInteger (p_mi, "deinterlace", 0);
568
569     size_t n;
570     vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
571     for (size_t i = 0; i < n; i++)
572     {
573         vout_thread_t *p_vout = pp_vouts[i];
574
575         if (*psz_mode)
576         {
577             var_SetString (p_vout, "deinterlace-mode", psz_mode);
578             var_SetInteger (p_vout, "deinterlace", 1);
579         }
580         else
581             var_SetInteger (p_vout, "deinterlace", 0);
582         vlc_object_release (p_vout);
583     }
584     free (pp_vouts);
585 }
586
587 /* ************** */
588 /* module helpers */
589 /* ************** */
590
591
592 static vlc_object_t *get_object( libvlc_media_player_t * p_mi,
593                                  const char *name )
594 {
595     vlc_object_t *object;
596     vout_thread_t *vout = GetVout( p_mi, 0 );
597
598     if( vout )
599     {
600         object = vlc_object_find_name( vout, name, FIND_CHILD );
601         vlc_object_release(vout);
602     }
603     else
604         object = NULL;
605
606     if( !object )
607         libvlc_printerr( "%s not enabled", name );
608     return object;
609 }
610
611
612 typedef const struct {
613     const char name[20];
614     unsigned type;
615 } opt_t;
616
617
618 static void
619 set_int( libvlc_media_player_t *p_mi, const char *restrict name,
620          const opt_t *restrict opt, int value )
621 {
622     if( !opt ) return;
623
624     if( !opt->type ) /* the enabler */
625     {
626         vout_thread_t *vout = GetVout( p_mi, 0 );
627         if (vout)
628         {
629             vout_EnableFilter( vout, opt->name, value, false );
630             vlc_object_release( vout );
631         }
632         return;
633     }
634
635     if( opt->type != VLC_VAR_INTEGER )
636     {
637         libvlc_printerr( "Invalid argument to %s in %s", name, "set int" );
638         return;
639     }
640
641     var_SetInteger(p_mi, opt->name, value);
642     vlc_object_t *object = get_object( p_mi, name );
643     if( object )
644     {
645         var_SetInteger(object, opt->name, value);
646         vlc_object_release( object );
647     }
648 }
649
650
651 static int
652 get_int( libvlc_media_player_t *p_mi, const char *restrict name,
653          const opt_t *restrict opt )
654 {
655     if( !opt ) return 0;
656
657     switch( opt->type )
658     {
659         case 0: /* the enabler */
660         {
661             vlc_object_t *object = get_object( p_mi, name );
662             vlc_object_release( object );
663             return object != NULL;
664         }
665     case VLC_VAR_INTEGER:
666         return var_GetInteger(p_mi, opt->name);
667     default:
668         libvlc_printerr( "Invalid argument to %s in %s", name, "get int" );
669         return 0;
670     }
671 }
672
673
674 static void
675 set_float( libvlc_media_player_t *p_mi, const char *restrict name,
676             const opt_t *restrict opt, float value )
677 {
678     if( !opt ) return;
679
680     if( opt->type != VLC_VAR_FLOAT )
681     {
682         libvlc_printerr( "Invalid argument to %s in %s", name, "set float" );
683         return;
684     }
685
686     var_SetFloat( p_mi, opt->name, value );
687
688     vlc_object_t *object = get_object( p_mi, name );
689     if( object )
690     {
691         var_SetFloat(object, opt->name, value );
692         vlc_object_release( object );
693     }
694 }
695
696
697 static float
698 get_float( libvlc_media_player_t *p_mi, const char *restrict name,
699             const opt_t *restrict opt )
700 {
701     if( !opt ) return 0.0;
702
703
704     if( opt->type != VLC_VAR_FLOAT )
705     {
706         libvlc_printerr( "Invalid argument to %s in %s", name, "get float" );
707         return 0.0;
708     }
709
710     return var_GetFloat( p_mi, opt->name );
711 }
712
713
714 static void
715 set_string( libvlc_media_player_t *p_mi, const char *restrict name,
716             const opt_t *restrict opt, const char *restrict psz_value )
717 {
718     if( !opt ) return;
719
720     if( opt->type != VLC_VAR_STRING )
721     {
722         libvlc_printerr( "Invalid argument to %s in %s", name, "set string" );
723         return;
724     }
725
726     var_SetString( p_mi, opt->name, psz_value );
727
728     vlc_object_t *object = get_object( p_mi, name );
729     if( object )
730     {
731         var_SetString(object, opt->name, psz_value );
732         vlc_object_release( object );
733     }
734 }
735
736
737 static char *
738 get_string( libvlc_media_player_t *p_mi, const char *restrict name,
739             const opt_t *restrict opt )
740 {
741     if( !opt ) return NULL;
742
743     if( opt->type != VLC_VAR_STRING )
744     {
745         libvlc_printerr( "Invalid argument to %s in %s", name, "get string" );
746         return NULL;
747     }
748
749     return var_GetString( p_mi, opt->name );
750 }
751
752
753 static const opt_t *
754 marq_option_bynumber(unsigned option)
755 {
756     static const opt_t optlist[] =
757     {
758         { "marq",          0 },
759         { "marq-marquee",  VLC_VAR_STRING },
760         { "marq-color",    VLC_VAR_INTEGER },
761         { "marq-opacity",  VLC_VAR_INTEGER },
762         { "marq-position", VLC_VAR_INTEGER },
763         { "marq-refresh",  VLC_VAR_INTEGER },
764         { "marq-size",     VLC_VAR_INTEGER },
765         { "marq-timeout",  VLC_VAR_INTEGER },
766         { "marq-x",        VLC_VAR_INTEGER },
767         { "marq-y",        VLC_VAR_INTEGER },
768     };
769     enum { num_opts = sizeof(optlist) / sizeof(*optlist) };
770
771     const opt_t *r = option < num_opts ? optlist+option : NULL;
772     if( !r )
773         libvlc_printerr( "Unknown marquee option" );
774     return r;
775 }
776
777 static vlc_object_t *get_object( libvlc_media_player_t *, const char *);
778
779 /*****************************************************************************
780  * libvlc_video_get_marquee_int : get a marq option value
781  *****************************************************************************/
782 int libvlc_video_get_marquee_int( libvlc_media_player_t *p_mi,
783                                   unsigned option )
784 {
785     return get_int( p_mi, "marq", marq_option_bynumber(option) );
786 }
787
788 /*****************************************************************************
789  * libvlc_video_get_marquee_string : get a marq option value
790  *****************************************************************************/
791 char * libvlc_video_get_marquee_string( libvlc_media_player_t *p_mi,
792                                         unsigned option )
793 {
794     return get_string( p_mi, "marq", marq_option_bynumber(option) );
795 }
796
797 /*****************************************************************************
798  * libvlc_video_set_marquee_int: enable, disable or set an int option
799  *****************************************************************************/
800 void libvlc_video_set_marquee_int( libvlc_media_player_t *p_mi,
801                          unsigned option, int value )
802 {
803     set_int( p_mi, "marq", marq_option_bynumber(option), value );
804 }
805
806 /*****************************************************************************
807  * libvlc_video_set_marquee_string: set a string option
808  *****************************************************************************/
809 void libvlc_video_set_marquee_string( libvlc_media_player_t *p_mi,
810                 unsigned option, const char * value )
811 {
812     set_string( p_mi, "marq", marq_option_bynumber(option), value );
813 }
814
815
816 /* logo module support */
817
818
819 static const opt_t *
820 logo_option_bynumber( unsigned option )
821 {
822     static const opt_t vlogo_optlist[] =
823     /* depends on libvlc_video_logo_option_t */
824     {
825         { "logo",          0 },
826         { "logo-file",     VLC_VAR_STRING },
827         { "logo-x",        VLC_VAR_INTEGER },
828         { "logo-y",        VLC_VAR_INTEGER },
829         { "logo-delay",    VLC_VAR_INTEGER },
830         { "logo-repeat",   VLC_VAR_INTEGER },
831         { "logo-opacity",  VLC_VAR_INTEGER },
832         { "logo-position", VLC_VAR_INTEGER },
833     };
834     enum { num_vlogo_opts = sizeof(vlogo_optlist) / sizeof(*vlogo_optlist) };
835
836     const opt_t *r = option < num_vlogo_opts ? vlogo_optlist+option : NULL;
837     if( !r )
838         libvlc_printerr( "Unknown logo option" );
839     return r;
840 }
841
842
843 void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi,
844                                    unsigned option, const char *psz_value )
845 {
846     set_string( p_mi,"logo",logo_option_bynumber(option),psz_value );
847 }
848
849
850 void libvlc_video_set_logo_int( libvlc_media_player_t *p_mi,
851                                 unsigned option, int value )
852 {
853     set_int( p_mi, "logo", logo_option_bynumber(option), value );
854 }
855
856
857 int libvlc_video_get_logo_int( libvlc_media_player_t *p_mi,
858                                unsigned option )
859 {
860     return get_int( p_mi, "logo", logo_option_bynumber(option) );
861 }
862
863
864 /* adjust module support */
865
866
867 static const opt_t *
868 adjust_option_bynumber( unsigned option )
869 {
870     static const opt_t optlist[] =
871     {
872         { "adjust",               0 },
873         { "contrast",             VLC_VAR_FLOAT },
874         { "brightness",           VLC_VAR_FLOAT },
875         { "hue",                  VLC_VAR_INTEGER },
876         { "saturation",           VLC_VAR_FLOAT },
877         { "gamma",                VLC_VAR_FLOAT },
878     };
879     enum { num_opts = sizeof(optlist) / sizeof(*optlist) };
880
881     const opt_t *r = option < num_opts ? optlist+option : NULL;
882     if( !r )
883         libvlc_printerr( "Unknown adjust option" );
884     return r;
885 }
886
887
888 void libvlc_video_set_adjust_int( libvlc_media_player_t *p_mi,
889                                   unsigned option, int value )
890 {
891     set_int( p_mi, "adjust", adjust_option_bynumber(option), value );
892 }
893
894
895 int libvlc_video_get_adjust_int( libvlc_media_player_t *p_mi,
896                                  unsigned option )
897 {
898     return get_int( p_mi, "adjust", adjust_option_bynumber(option) );
899 }
900
901
902 void libvlc_video_set_adjust_float( libvlc_media_player_t *p_mi,
903                                     unsigned option, float value )
904 {
905     set_float( p_mi, "adjust", adjust_option_bynumber(option), value );
906 }
907
908
909 float libvlc_video_get_adjust_float( libvlc_media_player_t *p_mi,
910                                      unsigned option )
911 {
912     return get_float( p_mi, "adjust", adjust_option_bynumber(option) );
913 }