opengl: apply subpictures alpha
[vlc.git] / lib / video.c
blob6f8e6d7f59a8d09bae7eb411273c75fac0758f7f
1 /*****************************************************************************
2 * video.c: libvlc new API video functions
3 *****************************************************************************
4 * Copyright (C) 2005-2010 VLC authors and VideoLAN
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Filippo Carone <littlejohn@videolan.org>
9 * Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
10 * Damien Fouilleul <damienf a_t videolan dot org>
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation; either version 2.1 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this program; if not, write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
31 #include <vlc/libvlc.h>
32 #include <vlc/libvlc_renderer_discoverer.h>
33 #include <vlc/libvlc_picture.h>
34 #include <vlc/libvlc_media.h>
35 #include <vlc/libvlc_media_player.h>
37 #include <vlc_common.h>
38 #include <vlc_modules.h>
39 #include <vlc_vout.h>
40 #include <vlc_url.h>
42 #include "libvlc_internal.h"
43 #include "media_player_internal.h"
44 #include <math.h>
45 #include <assert.h>
48 * Remember to release the returned vout_thread_t.
50 static vout_thread_t **GetVouts( libvlc_media_player_t *p_mi, size_t *n )
52 vlc_player_t *player = p_mi->player;
53 return vlc_player_vout_HoldAll(player, n);
56 static vout_thread_t *GetVout (libvlc_media_player_t *mp, size_t num)
58 vout_thread_t *p_vout = NULL;
59 size_t n;
60 vout_thread_t **pp_vouts = GetVouts (mp, &n);
61 if (pp_vouts == NULL)
62 goto err;
64 if (num < n)
65 p_vout = pp_vouts[num];
67 for (size_t i = 0; i < n; i++)
68 if (i != num)
69 vout_Release(pp_vouts[i]);
70 free (pp_vouts);
72 if (p_vout == NULL)
73 err:
74 libvlc_printerr ("Video output not active");
75 return p_vout;
78 /**********************************************************************
79 * Exported functions
80 **********************************************************************/
82 void libvlc_set_fullscreen(libvlc_media_player_t *p_mi, bool b_fullscreen)
84 /* This will work even if the video is not currently active */
85 var_SetBool(p_mi, "fullscreen", b_fullscreen);
87 /* Apply to current video outputs (if any) */
88 size_t n;
89 vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
90 for (size_t i = 0; i < n; i++)
92 var_SetBool (pp_vouts[i], "fullscreen", b_fullscreen);
93 vout_Release(pp_vouts[i]);
95 free (pp_vouts);
98 bool libvlc_get_fullscreen( libvlc_media_player_t *p_mi )
100 return var_GetBool (p_mi, "fullscreen");
103 void libvlc_toggle_fullscreen( libvlc_media_player_t *p_mi )
105 bool b_fullscreen = var_ToggleBool (p_mi, "fullscreen");
107 /* Apply to current video outputs (if any) */
108 size_t n;
109 vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
110 for (size_t i = 0; i < n; i++)
112 vout_thread_t *p_vout = pp_vouts[i];
114 var_SetBool (p_vout, "fullscreen", b_fullscreen);
115 vout_Release(p_vout);
117 free (pp_vouts);
120 void libvlc_video_set_key_input( libvlc_media_player_t *p_mi, unsigned on )
122 var_SetBool (p_mi, "keyboard-events", !!on);
125 void libvlc_video_set_mouse_input( libvlc_media_player_t *p_mi, unsigned on )
127 var_SetBool (p_mi, "mouse-events", !!on);
131 libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, unsigned num,
132 const char *psz_filepath,
133 unsigned int i_width, unsigned int i_height )
135 assert( psz_filepath );
137 vout_thread_t *p_vout = GetVout (p_mi, num);
138 if (p_vout == NULL)
139 return -1;
141 /* FIXME: This is not atomic. All parameters should be passed at once
142 * (obviously _not_ with var_*()). Also, the libvlc object should not be
143 * used for the callbacks: that breaks badly if there are concurrent
144 * media players in the instance. */
145 var_Create( p_vout, "snapshot-width", VLC_VAR_INTEGER );
146 var_SetInteger( p_vout, "snapshot-width", i_width);
147 var_Create( p_vout, "snapshot-height", VLC_VAR_INTEGER );
148 var_SetInteger( p_vout, "snapshot-height", i_height );
149 var_Create( p_vout, "snapshot-path", VLC_VAR_STRING );
150 var_SetString( p_vout, "snapshot-path", psz_filepath );
151 var_Create( p_vout, "snapshot-format", VLC_VAR_STRING );
152 var_SetString( p_vout, "snapshot-format", "png" );
153 var_TriggerCallback( p_vout, "video-snapshot" );
154 vout_Release(p_vout);
155 return 0;
158 int libvlc_video_get_size( libvlc_media_player_t *p_mi, unsigned num,
159 unsigned *restrict px, unsigned *restrict py )
161 if (p_mi->p_md == NULL)
162 return -1;
164 libvlc_media_track_t **tracks;
165 unsigned count = libvlc_media_tracks_get(p_mi->p_md, &tracks);
166 int ret = -1;
168 for (unsigned i = 0; i < count; i++)
169 if (tracks[i]->i_type == libvlc_track_video && num-- == 0) {
170 *px = tracks[i]->video->i_width;
171 *py = tracks[i]->video->i_height;
172 ret = 0;
173 break;
176 libvlc_media_tracks_release(tracks, count);
177 return ret;
180 int libvlc_video_get_cursor( libvlc_media_player_t *mp, unsigned num,
181 int *restrict px, int *restrict py )
183 vout_thread_t *p_vout = GetVout (mp, num);
184 if (p_vout == NULL)
185 return -1;
187 var_GetCoords (p_vout, "mouse-moved", px, py);
188 vout_Release(p_vout);
189 return 0;
192 unsigned libvlc_media_player_has_vout( libvlc_media_player_t *p_mi )
194 size_t n;
195 vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
196 for (size_t i = 0; i < n; i++)
197 vout_Release(pp_vouts[i]);
198 free (pp_vouts);
199 return n;
202 float libvlc_video_get_scale( libvlc_media_player_t *mp )
204 float f_scale = var_GetFloat (mp, "zoom");
205 if (var_GetBool (mp, "autoscale"))
206 f_scale = 0.f;
207 return f_scale;
210 void libvlc_video_set_scale( libvlc_media_player_t *p_mp, float f_scale )
212 if (isfinite(f_scale) && f_scale != 0.f)
213 var_SetFloat (p_mp, "zoom", f_scale);
214 var_SetBool (p_mp, "autoscale", f_scale == 0.f);
216 /* Apply to current video outputs (if any) */
217 size_t n;
218 vout_thread_t **pp_vouts = GetVouts (p_mp, &n);
219 for (size_t i = 0; i < n; i++)
221 vout_thread_t *p_vout = pp_vouts[i];
223 if (isfinite(f_scale) && f_scale != 0.f)
224 var_SetFloat (p_vout, "zoom", f_scale);
225 var_SetBool (p_vout, "autoscale", f_scale == 0.f);
226 vout_Release(p_vout);
228 free (pp_vouts);
231 char *libvlc_video_get_aspect_ratio( libvlc_media_player_t *p_mi )
233 return var_GetNonEmptyString (p_mi, "aspect-ratio");
236 void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi,
237 const char *psz_aspect )
239 if (psz_aspect == NULL)
240 psz_aspect = "";
241 var_SetString (p_mi, "aspect-ratio", psz_aspect);
243 size_t n;
244 vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
245 for (size_t i = 0; i < n; i++)
247 vout_thread_t *p_vout = pp_vouts[i];
249 var_SetString (p_vout, "aspect-ratio", psz_aspect);
250 vout_Release(p_vout);
252 free (pp_vouts);
255 libvlc_video_viewpoint_t *libvlc_video_new_viewpoint(void)
257 libvlc_video_viewpoint_t *p_vp = malloc(sizeof *p_vp);
258 if (unlikely(p_vp == NULL))
259 return NULL;
260 p_vp->f_yaw = p_vp->f_pitch = p_vp->f_roll = p_vp->f_field_of_view = 0.0f;
261 return p_vp;
264 int libvlc_video_update_viewpoint( libvlc_media_player_t *p_mi,
265 const libvlc_video_viewpoint_t *p_viewpoint,
266 bool b_absolute )
268 vlc_viewpoint_t update = {
269 .yaw = p_viewpoint->f_yaw,
270 .pitch = p_viewpoint->f_pitch,
271 .roll = p_viewpoint->f_roll,
272 .fov = p_viewpoint->f_field_of_view,
275 enum vlc_player_whence whence = b_absolute ? VLC_PLAYER_WHENCE_ABSOLUTE
276 : VLC_PLAYER_WHENCE_RELATIVE;
277 vlc_player_UpdateViewpoint(p_mi->player, &update, whence);
279 /* may not fail anymore, keep int not to break the API */
280 return 0;
283 int libvlc_video_get_spu( libvlc_media_player_t *p_mi )
285 vlc_player_t *player = p_mi->player;
286 vlc_player_Lock(player);
288 const struct vlc_player_track *track =
289 vlc_player_GetSelectedTrack(player, SPU_ES);
290 int i_spu = track ? vlc_es_id_GetInputId(track->es_id) : -1;
292 vlc_player_Unlock(player);
293 return i_spu;
296 int libvlc_video_get_spu_count( libvlc_media_player_t *p_mi )
298 vlc_player_t *player = p_mi->player;
299 vlc_player_Lock(player);
301 int ret = vlc_player_GetTrackCount(p_mi->player, SPU_ES);
303 vlc_player_Unlock(player);
304 return ret;
307 libvlc_track_description_t *
308 libvlc_video_get_spu_description( libvlc_media_player_t *p_mi )
310 return libvlc_get_track_description( p_mi, SPU_ES );
313 int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu )
315 int i_ret = -1;
317 vlc_player_t *player = p_mi->player;
318 vlc_player_Lock(player);
320 size_t count = vlc_player_GetSubtitleTrackCount(player);
321 for (size_t i = 0; i < count; i++)
323 const struct vlc_player_track *track =
324 vlc_player_GetSubtitleTrackAt(player, i);
325 if (i_spu == vlc_es_id_GetInputId(track->es_id))
327 /* found */
328 vlc_player_SelectTrack(player, track, VLC_PLAYER_SELECT_EXCLUSIVE);
329 i_ret = 0;
330 goto end;
333 libvlc_printerr( "Track identifier not found" );
334 end:
335 vlc_player_Unlock(player);
336 return i_ret;
339 int64_t libvlc_video_get_spu_delay( libvlc_media_player_t *p_mi )
341 vlc_player_t *player = p_mi->player;
342 vlc_player_Lock(player);
344 vlc_tick_t delay = vlc_player_GetSubtitleDelay(player);
346 vlc_player_Unlock(player);
348 return US_FROM_VLC_TICK(delay);
351 int libvlc_video_set_spu_delay( libvlc_media_player_t *p_mi,
352 int64_t i_delay )
354 vlc_player_t *player = p_mi->player;
355 vlc_player_Lock(player);
357 vlc_player_SetSubtitleDelay(player, VLC_TICK_FROM_US(i_delay),
358 VLC_PLAYER_WHENCE_ABSOLUTE);
360 vlc_player_Unlock(player);
361 /* may not fail anymore, keep int not to break the API */
362 return 0;
365 static void libvlc_video_set_crop(libvlc_media_player_t *mp,
366 const char *geometry)
368 var_SetString(mp, "crop", geometry);
370 size_t n;
371 vout_thread_t **vouts = GetVouts(mp, &n);
373 for (size_t i = 0; i < n; i++)
375 var_SetString(vouts[i], "crop", geometry);
376 vout_Release(vouts[i]);
378 free(vouts);
381 void libvlc_video_set_crop_ratio(libvlc_media_player_t *mp,
382 unsigned num, unsigned den)
384 char geometry[2 * (3 * sizeof (unsigned) + 1)];
386 if (den == 0)
387 geometry[0] = '\0';
388 else
389 sprintf(geometry, "%u:%u", num, den);
391 libvlc_video_set_crop(mp, geometry);
394 void libvlc_video_set_crop_window(libvlc_media_player_t *mp,
395 unsigned x, unsigned y,
396 unsigned width, unsigned height)
398 char geometry[4 * (3 * sizeof (unsigned) + 1)];
400 assert(width != 0 && height != 0);
401 sprintf(geometry, "%ux%u+%u+%u", x, y, width, height);
402 libvlc_video_set_crop(mp, geometry);
405 void libvlc_video_set_crop_border(libvlc_media_player_t *mp,
406 unsigned left, unsigned right,
407 unsigned top, unsigned bottom)
409 char geometry[4 * (3 * sizeof (unsigned) + 1)];
411 sprintf(geometry, "%u+%u+%u+%u", left, top, right, bottom);
412 libvlc_video_set_crop(mp, geometry);
415 int libvlc_video_get_teletext( libvlc_media_player_t *p_mi )
417 return var_GetInteger (p_mi, "vbi-page");
420 void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
422 vlc_player_t *player = p_mi->player;
423 vlc_player_Lock(player);
425 if (i_page == 0)
426 vlc_player_SetTeletextEnabled(player, false);
427 else if (i_page > 0)
429 if (i_page >= 1000)
431 bool is_key = i_page == libvlc_teletext_key_red
432 || i_page == libvlc_teletext_key_green
433 || i_page == libvlc_teletext_key_yellow
434 || i_page == libvlc_teletext_key_blue
435 || i_page == libvlc_teletext_key_index;
436 if (!is_key)
438 libvlc_printerr("Invalid key action");
439 return;
442 vlc_player_SetTeletextEnabled(player, true);
443 vlc_player_SelectTeletextPage(player, i_page);
445 else
447 libvlc_printerr("Invalid page number");
448 return;
451 vlc_player_Unlock(player);
454 int libvlc_video_get_track_count( libvlc_media_player_t *p_mi )
456 vlc_player_t *player = p_mi->player;
457 vlc_player_Lock(player);
459 int ret = vlc_player_GetTrackCount(p_mi->player, VIDEO_ES);
461 vlc_player_Unlock(player);
462 return ret;
465 libvlc_track_description_t *
466 libvlc_video_get_track_description( libvlc_media_player_t *p_mi )
468 return libvlc_get_track_description( p_mi, VIDEO_ES );
471 int libvlc_video_get_track( libvlc_media_player_t *p_mi )
473 vlc_player_t *player = p_mi->player;
474 vlc_player_Lock(player);
476 const struct vlc_player_track * track =
477 vlc_player_GetSelectedTrack(player, VIDEO_ES);
478 int id = track ? vlc_es_id_GetInputId(track->es_id) : -1;
480 vlc_player_Unlock(player);
481 return id;
484 int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track )
486 int i_ret = -1;
488 vlc_player_t *player = p_mi->player;
489 vlc_player_Lock(player);
491 size_t count = vlc_player_GetVideoTrackCount(player);
492 for( size_t i = 0; i < count; i++ )
494 const struct vlc_player_track *track =
495 vlc_player_GetVideoTrackAt(player, i);
496 if (i_track == vlc_es_id_GetInputId(track->es_id))
498 /* found */
499 vlc_player_SelectTrack(player, track, VLC_PLAYER_SELECT_EXCLUSIVE);
500 i_ret = 0;
501 goto end;
504 libvlc_printerr( "Track identifier not found" );
505 end:
506 vlc_player_Unlock(player);
507 return i_ret;
510 /******************************************************************************
511 * libvlc_video_set_deinterlace : enable/disable/auto deinterlace and filter
512 *****************************************************************************/
513 void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi, int deinterlace,
514 const char *psz_mode )
516 if (deinterlace != 0 && deinterlace != 1)
517 deinterlace = -1;
519 if (psz_mode
520 && strcmp (psz_mode, "blend") && strcmp (psz_mode, "bob")
521 && strcmp (psz_mode, "discard") && strcmp (psz_mode, "linear")
522 && strcmp (psz_mode, "mean") && strcmp (psz_mode, "x")
523 && strcmp (psz_mode, "yadif") && strcmp (psz_mode, "yadif2x")
524 && strcmp (psz_mode, "phosphor") && strcmp (psz_mode, "ivtc")
525 && strcmp (psz_mode, "auto"))
526 return;
528 if (psz_mode && deinterlace != 0)
529 var_SetString (p_mi, "deinterlace-mode", psz_mode);
531 var_SetInteger (p_mi, "deinterlace", deinterlace);
533 size_t n;
534 vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
535 for (size_t i = 0; i < n; i++)
537 vout_thread_t *p_vout = pp_vouts[i];
539 if (psz_mode && deinterlace != 0)
540 var_SetString (p_vout, "deinterlace-mode", psz_mode);
542 var_SetInteger (p_vout, "deinterlace", deinterlace);
543 vout_Release(p_vout);
545 free (pp_vouts);
548 /* ************** */
549 /* module helpers */
550 /* ************** */
552 static int get_filter_str( vlc_object_t *p_parent, const char *psz_name,
553 bool b_add, const char **ppsz_filter_type,
554 char **ppsz_filter_value)
556 char *psz_parser;
557 char *psz_string;
558 const char *psz_filter_type;
560 module_t *p_obj = module_find( psz_name );
561 if( !p_obj )
563 msg_Err( p_parent, "Unable to find filter module \"%s\".", psz_name );
564 return VLC_EGENERIC;
567 if( module_provides( p_obj, "video filter" ) )
569 psz_filter_type = "video-filter";
571 else if( module_provides( p_obj, "sub source" ) )
573 psz_filter_type = "sub-source";
575 else if( module_provides( p_obj, "sub filter" ) )
577 psz_filter_type = "sub-filter";
579 else
581 msg_Err( p_parent, "Unknown video filter type." );
582 return VLC_EGENERIC;
585 psz_string = var_GetString( p_parent, psz_filter_type );
587 /* Todo : Use some generic chain manipulation functions */
588 if( !psz_string ) psz_string = strdup("");
590 psz_parser = strstr( psz_string, psz_name );
591 if( b_add )
593 if( !psz_parser )
595 psz_parser = psz_string;
596 if( asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
597 psz_string, psz_name ) == -1 )
599 free( psz_parser );
600 return VLC_EGENERIC;
602 free( psz_parser );
604 else
606 free( psz_string );
607 return VLC_EGENERIC;
610 else
612 if( psz_parser )
614 memmove( psz_parser, psz_parser + strlen(psz_name) +
615 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
616 strlen(psz_parser + strlen(psz_name)) + 1 );
618 /* Remove trailing : : */
619 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
620 *(psz_string+strlen(psz_string ) -1 ) = '\0';
622 else
624 free( psz_string );
625 return VLC_EGENERIC;
629 *ppsz_filter_type = psz_filter_type;
630 *ppsz_filter_value = psz_string;
631 return VLC_SUCCESS;
634 static bool find_sub_source_by_name( libvlc_media_player_t *p_mi, const char *restrict name )
636 vout_thread_t *vout = GetVout( p_mi, 0 );
637 if (!vout)
638 return false;
640 char *psz_sources = var_GetString( vout, "sub-source" );
641 if( !psz_sources )
643 libvlc_printerr( "%s not enabled", name );
644 vout_Release(vout);
645 return false;
648 /* Find 'name' */
649 char *p = strstr( psz_sources, name );
650 free( psz_sources );
651 vout_Release(vout);
652 return (p != NULL);
655 typedef const struct {
656 const char name[20];
657 unsigned type;
658 } opt_t;
660 static void
661 set_value( libvlc_media_player_t *p_mi, const char *restrict name,
662 const opt_t *restrict opt, unsigned i_expected_type,
663 const vlc_value_t *val, bool b_sub_source )
665 if( !opt ) return;
667 int i_type = opt->type;
668 vlc_value_t new_val = *val;
669 const char *psz_opt_name = opt->name;
670 switch( i_type )
672 case 0: /* the enabler */
674 int i_ret = get_filter_str( VLC_OBJECT( p_mi ), opt->name, val->i_int,
675 &psz_opt_name, &new_val.psz_string );
676 if( i_ret != VLC_SUCCESS )
677 return;
678 i_type = VLC_VAR_STRING;
679 break;
681 case VLC_VAR_INTEGER:
682 case VLC_VAR_FLOAT:
683 case VLC_VAR_STRING:
684 if( i_expected_type != opt->type )
686 libvlc_printerr( "Invalid argument to %s", name );
687 return;
689 break;
690 default:
691 libvlc_printerr( "Invalid argument to %s", name );
692 return;
695 /* Set the new value to the media player. Next vouts created from this
696 * media player will inherit this new value */
697 var_SetChecked( p_mi, psz_opt_name, i_type, new_val );
699 /* Set the new value to every loaded vouts */
700 size_t i_vout_count;
701 vout_thread_t **pp_vouts = GetVouts( p_mi, &i_vout_count );
702 for( size_t i = 0; i < i_vout_count; ++i )
704 var_SetChecked( pp_vouts[i], psz_opt_name, i_type, new_val );
705 if( b_sub_source )
706 var_TriggerCallback( pp_vouts[i], "sub-source" );
707 vout_Release(pp_vouts[i]);
710 if( opt->type == 0 )
711 free( new_val.psz_string );
714 static int
715 get_int( libvlc_media_player_t *p_mi, const char *restrict name,
716 const opt_t *restrict opt )
718 if( !opt ) return 0;
720 switch( opt->type )
722 case 0: /* the enabler */
724 bool b_enabled = find_sub_source_by_name( p_mi, name );
725 return b_enabled ? 1 : 0;
727 case VLC_VAR_INTEGER:
728 return var_GetInteger(p_mi, opt->name);
729 case VLC_VAR_FLOAT:
730 return lroundf(var_GetFloat(p_mi, opt->name));
731 default:
732 libvlc_printerr( "Invalid argument to %s in %s", name, "get int" );
733 return 0;
737 static float
738 get_float( libvlc_media_player_t *p_mi, const char *restrict name,
739 const opt_t *restrict opt )
741 if( !opt ) return 0.0;
743 if( opt->type != VLC_VAR_FLOAT )
745 libvlc_printerr( "Invalid argument to %s in %s", name, "get float" );
746 return 0.0;
749 return var_GetFloat( p_mi, opt->name );
752 static const opt_t *
753 marq_option_bynumber(unsigned option)
755 static const opt_t optlist[] =
757 { "marq", 0 },
758 { "marq-marquee", VLC_VAR_STRING },
759 { "marq-color", VLC_VAR_INTEGER },
760 { "marq-opacity", VLC_VAR_INTEGER },
761 { "marq-position", VLC_VAR_INTEGER },
762 { "marq-refresh", VLC_VAR_INTEGER },
763 { "marq-size", VLC_VAR_INTEGER },
764 { "marq-timeout", VLC_VAR_INTEGER },
765 { "marq-x", VLC_VAR_INTEGER },
766 { "marq-y", VLC_VAR_INTEGER },
768 enum { num_opts = sizeof(optlist) / sizeof(*optlist) };
770 const opt_t *r = option < num_opts ? optlist+option : NULL;
771 if( !r )
772 libvlc_printerr( "Unknown marquee option" );
773 return r;
776 /*****************************************************************************
777 * libvlc_video_get_marquee_int : get a marq option value
778 *****************************************************************************/
779 int libvlc_video_get_marquee_int( libvlc_media_player_t *p_mi,
780 unsigned option )
782 return get_int( p_mi, "marq", marq_option_bynumber(option) );
785 /*****************************************************************************
786 * libvlc_video_set_marquee_int: enable, disable or set an int option
787 *****************************************************************************/
788 void libvlc_video_set_marquee_int( libvlc_media_player_t *p_mi,
789 unsigned option, int value )
791 set_value( p_mi, "marq", marq_option_bynumber(option), VLC_VAR_INTEGER,
792 &(vlc_value_t) { .i_int = value }, true );
795 /*****************************************************************************
796 * libvlc_video_set_marquee_string: set a string option
797 *****************************************************************************/
798 void libvlc_video_set_marquee_string( libvlc_media_player_t *p_mi,
799 unsigned option, const char * value )
801 set_value( p_mi, "marq", marq_option_bynumber(option), VLC_VAR_STRING,
802 &(vlc_value_t){ .psz_string = (char *)value }, true );
806 /* logo module support */
808 static const opt_t *
809 logo_option_bynumber( unsigned option )
811 static const opt_t vlogo_optlist[] =
812 /* depends on libvlc_video_logo_option_t */
814 { "logo", 0 },
815 { "logo-file", VLC_VAR_STRING },
816 { "logo-x", VLC_VAR_INTEGER },
817 { "logo-y", VLC_VAR_INTEGER },
818 { "logo-delay", VLC_VAR_INTEGER },
819 { "logo-repeat", VLC_VAR_INTEGER },
820 { "logo-opacity", VLC_VAR_INTEGER },
821 { "logo-position", VLC_VAR_INTEGER },
823 enum { num_vlogo_opts = sizeof(vlogo_optlist) / sizeof(*vlogo_optlist) };
825 const opt_t *r = option < num_vlogo_opts ? vlogo_optlist+option : NULL;
826 if( !r )
827 libvlc_printerr( "Unknown logo option" );
828 return r;
831 void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi,
832 unsigned option, const char *psz_value )
834 set_value( p_mi,"logo",logo_option_bynumber(option), VLC_VAR_STRING,
835 &(vlc_value_t){ .psz_string = (char *)psz_value }, true );
839 void libvlc_video_set_logo_int( libvlc_media_player_t *p_mi,
840 unsigned option, int value )
842 set_value( p_mi, "logo", logo_option_bynumber(option), VLC_VAR_INTEGER,
843 &(vlc_value_t) { .i_int = value }, true );
847 int libvlc_video_get_logo_int( libvlc_media_player_t *p_mi,
848 unsigned option )
850 return get_int( p_mi, "logo", logo_option_bynumber(option) );
854 /* adjust module support */
857 static const opt_t *
858 adjust_option_bynumber( unsigned option )
860 static const opt_t optlist[] =
862 { "adjust", 0 },
863 { "contrast", VLC_VAR_FLOAT },
864 { "brightness", VLC_VAR_FLOAT },
865 { "hue", VLC_VAR_FLOAT },
866 { "saturation", VLC_VAR_FLOAT },
867 { "gamma", VLC_VAR_FLOAT },
869 enum { num_opts = sizeof(optlist) / sizeof(*optlist) };
871 const opt_t *r = option < num_opts ? optlist+option : NULL;
872 if( !r )
873 libvlc_printerr( "Unknown adjust option" );
874 return r;
878 void libvlc_video_set_adjust_int( libvlc_media_player_t *p_mi,
879 unsigned option, int value )
881 set_value( p_mi, "adjust", adjust_option_bynumber(option), VLC_VAR_INTEGER,
882 &(vlc_value_t) { .i_int = value }, false );
886 int libvlc_video_get_adjust_int( libvlc_media_player_t *p_mi,
887 unsigned option )
889 return get_int( p_mi, "adjust", adjust_option_bynumber(option) );
893 void libvlc_video_set_adjust_float( libvlc_media_player_t *p_mi,
894 unsigned option, float value )
896 set_value( p_mi, "adjust", adjust_option_bynumber(option), VLC_VAR_FLOAT,
897 &(vlc_value_t) { .f_float = value }, false );
901 float libvlc_video_get_adjust_float( libvlc_media_player_t *p_mi,
902 unsigned option )
904 return get_float( p_mi, "adjust", adjust_option_bynumber(option) );