qt: playlist: use item title if available
[vlc.git] / lib / video.c
blobd3cba035d8da1e5f33489063ac3ec14528d34f7c
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 ignored,
159 unsigned *restrict px, unsigned *restrict py )
161 (void) ignored;
162 if (p_mi->p_md == NULL)
163 return -1;
165 int ret = -1;
166 libvlc_media_track_t *track =
167 libvlc_media_player_get_selected_track( p_mi, libvlc_track_video );
169 if (track)
171 *px = track->video->i_width;
172 *py = track->video->i_height;
173 ret = 0;
174 libvlc_media_track_release(track);
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;
278 vlc_player_t *player = p_mi->player;
279 vlc_player_Lock(player);
281 vlc_player_UpdateViewpoint(player, &update, whence);
283 vlc_player_Unlock(player);
285 /* may not fail anymore, keep int not to break the API */
286 return 0;
289 int libvlc_video_get_spu( libvlc_media_player_t *p_mi )
291 vlc_player_t *player = p_mi->player;
292 vlc_player_Lock(player);
294 const struct vlc_player_track *track =
295 vlc_player_GetSelectedTrack(player, SPU_ES);
296 int i_spu = track ? vlc_es_id_GetInputId(track->es_id) : -1;
298 vlc_player_Unlock(player);
299 return i_spu;
302 int libvlc_video_get_spu_count( libvlc_media_player_t *p_mi )
304 vlc_player_t *player = p_mi->player;
305 vlc_player_Lock(player);
307 int ret = vlc_player_GetTrackCount(p_mi->player, SPU_ES);
309 vlc_player_Unlock(player);
310 return ret;
313 libvlc_track_description_t *
314 libvlc_video_get_spu_description( libvlc_media_player_t *p_mi )
316 return libvlc_get_track_description( p_mi, SPU_ES );
319 int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu )
321 int i_ret = -1;
323 vlc_player_t *player = p_mi->player;
324 vlc_player_Lock(player);
326 size_t count = vlc_player_GetSubtitleTrackCount(player);
327 for (size_t i = 0; i < count; i++)
329 const struct vlc_player_track *track =
330 vlc_player_GetSubtitleTrackAt(player, i);
331 if (i_spu == vlc_es_id_GetInputId(track->es_id))
333 /* found */
334 vlc_player_SelectTrack(player, track, VLC_PLAYER_SELECT_EXCLUSIVE);
335 i_ret = 0;
336 goto end;
339 libvlc_printerr( "Track identifier not found" );
340 end:
341 vlc_player_Unlock(player);
342 return i_ret;
345 int64_t libvlc_video_get_spu_delay( libvlc_media_player_t *p_mi )
347 vlc_player_t *player = p_mi->player;
348 vlc_player_Lock(player);
350 vlc_tick_t delay = vlc_player_GetSubtitleDelay(player);
352 vlc_player_Unlock(player);
354 return US_FROM_VLC_TICK(delay);
357 int libvlc_video_set_spu_delay( libvlc_media_player_t *p_mi,
358 int64_t i_delay )
360 vlc_player_t *player = p_mi->player;
361 vlc_player_Lock(player);
363 vlc_player_SetSubtitleDelay(player, VLC_TICK_FROM_US(i_delay),
364 VLC_PLAYER_WHENCE_ABSOLUTE);
366 vlc_player_Unlock(player);
367 /* may not fail anymore, keep int not to break the API */
368 return 0;
371 float libvlc_video_get_spu_text_scale( libvlc_media_player_t *p_mi )
373 vlc_player_t *player = p_mi->player;
374 vlc_player_Lock(player);
376 unsigned scale = vlc_player_GetSubtitleTextScale(player);
378 vlc_player_Unlock(player);
380 return scale / 100.f;
383 void libvlc_video_set_spu_text_scale( libvlc_media_player_t *p_mi,
384 float f_scale )
386 vlc_player_t *player = p_mi->player;
387 vlc_player_Lock(player);
389 vlc_player_SetSubtitleTextScale(player, lroundf(f_scale * 100.f));
391 vlc_player_Unlock(player);
394 static void libvlc_video_set_crop(libvlc_media_player_t *mp,
395 const char *geometry)
397 var_SetString(mp, "crop", geometry);
399 size_t n;
400 vout_thread_t **vouts = GetVouts(mp, &n);
402 for (size_t i = 0; i < n; i++)
404 var_SetString(vouts[i], "crop", geometry);
405 vout_Release(vouts[i]);
407 free(vouts);
410 void libvlc_video_set_crop_ratio(libvlc_media_player_t *mp,
411 unsigned num, unsigned den)
413 char geometry[2 * (3 * sizeof (unsigned) + 1)];
415 if (den == 0)
416 geometry[0] = '\0';
417 else
418 sprintf(geometry, "%u:%u", num, den);
420 libvlc_video_set_crop(mp, geometry);
423 void libvlc_video_set_crop_window(libvlc_media_player_t *mp,
424 unsigned x, unsigned y,
425 unsigned width, unsigned height)
427 char geometry[4 * (3 * sizeof (unsigned) + 1)];
429 assert(width != 0 && height != 0);
430 sprintf(geometry, "%ux%u+%u+%u", x, y, width, height);
431 libvlc_video_set_crop(mp, geometry);
434 void libvlc_video_set_crop_border(libvlc_media_player_t *mp,
435 unsigned left, unsigned right,
436 unsigned top, unsigned bottom)
438 char geometry[4 * (3 * sizeof (unsigned) + 1)];
440 sprintf(geometry, "%u+%u+%u+%u", left, top, right, bottom);
441 libvlc_video_set_crop(mp, geometry);
444 int libvlc_video_get_teletext( libvlc_media_player_t *p_mi )
446 return var_GetInteger (p_mi, "vbi-page");
449 void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
451 vlc_player_t *player = p_mi->player;
452 vlc_player_Lock(player);
454 if (i_page == 0)
455 vlc_player_SetTeletextEnabled(player, false);
456 else if (i_page > 0)
458 if (i_page >= 1000)
460 bool is_key = i_page == libvlc_teletext_key_red
461 || i_page == libvlc_teletext_key_green
462 || i_page == libvlc_teletext_key_yellow
463 || i_page == libvlc_teletext_key_blue
464 || i_page == libvlc_teletext_key_index;
465 if (!is_key)
467 libvlc_printerr("Invalid key action");
468 return;
471 vlc_player_SetTeletextEnabled(player, true);
472 vlc_player_SelectTeletextPage(player, i_page);
474 else
476 libvlc_printerr("Invalid page number");
477 return;
480 vlc_player_Unlock(player);
483 int libvlc_video_get_track_count( libvlc_media_player_t *p_mi )
485 vlc_player_t *player = p_mi->player;
486 vlc_player_Lock(player);
488 int ret = vlc_player_GetTrackCount(p_mi->player, VIDEO_ES);
490 vlc_player_Unlock(player);
491 return ret;
494 libvlc_track_description_t *
495 libvlc_video_get_track_description( libvlc_media_player_t *p_mi )
497 return libvlc_get_track_description( p_mi, VIDEO_ES );
500 int libvlc_video_get_track( libvlc_media_player_t *p_mi )
502 vlc_player_t *player = p_mi->player;
503 vlc_player_Lock(player);
505 const struct vlc_player_track * track =
506 vlc_player_GetSelectedTrack(player, VIDEO_ES);
507 int id = track ? vlc_es_id_GetInputId(track->es_id) : -1;
509 vlc_player_Unlock(player);
510 return id;
513 int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track )
515 int i_ret = -1;
517 vlc_player_t *player = p_mi->player;
518 vlc_player_Lock(player);
520 size_t count = vlc_player_GetVideoTrackCount(player);
521 for( size_t i = 0; i < count; i++ )
523 const struct vlc_player_track *track =
524 vlc_player_GetVideoTrackAt(player, i);
525 if (i_track == vlc_es_id_GetInputId(track->es_id))
527 /* found */
528 vlc_player_SelectTrack(player, track, VLC_PLAYER_SELECT_EXCLUSIVE);
529 i_ret = 0;
530 goto end;
533 libvlc_printerr( "Track identifier not found" );
534 end:
535 vlc_player_Unlock(player);
536 return i_ret;
539 /******************************************************************************
540 * libvlc_video_set_deinterlace : enable/disable/auto deinterlace and filter
541 *****************************************************************************/
542 void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi, int deinterlace,
543 const char *psz_mode )
545 if (deinterlace != 0 && deinterlace != 1)
546 deinterlace = -1;
548 if (psz_mode
549 && strcmp (psz_mode, "blend") && strcmp (psz_mode, "bob")
550 && strcmp (psz_mode, "discard") && strcmp (psz_mode, "linear")
551 && strcmp (psz_mode, "mean") && strcmp (psz_mode, "x")
552 && strcmp (psz_mode, "yadif") && strcmp (psz_mode, "yadif2x")
553 && strcmp (psz_mode, "phosphor") && strcmp (psz_mode, "ivtc")
554 && strcmp (psz_mode, "auto"))
555 return;
557 if (psz_mode && deinterlace != 0)
558 var_SetString (p_mi, "deinterlace-mode", psz_mode);
560 var_SetInteger (p_mi, "deinterlace", deinterlace);
562 size_t n;
563 vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
564 for (size_t i = 0; i < n; i++)
566 vout_thread_t *p_vout = pp_vouts[i];
568 if (psz_mode && deinterlace != 0)
569 var_SetString (p_vout, "deinterlace-mode", psz_mode);
571 var_SetInteger (p_vout, "deinterlace", deinterlace);
572 vout_Release(p_vout);
574 free (pp_vouts);
577 /* ************** */
578 /* module helpers */
579 /* ************** */
581 static int get_filter_str( vlc_object_t *p_parent, const char *psz_name,
582 bool b_add, const char **ppsz_filter_type,
583 char **ppsz_filter_value)
585 char *psz_parser;
586 char *psz_string;
587 const char *psz_filter_type;
589 module_t *p_obj = module_find( psz_name );
590 if( !p_obj )
592 msg_Err( p_parent, "Unable to find filter module \"%s\".", psz_name );
593 return VLC_EGENERIC;
596 if( module_provides( p_obj, "video filter" ) )
598 psz_filter_type = "video-filter";
600 else if( module_provides( p_obj, "sub source" ) )
602 psz_filter_type = "sub-source";
604 else if( module_provides( p_obj, "sub filter" ) )
606 psz_filter_type = "sub-filter";
608 else
610 msg_Err( p_parent, "Unknown video filter type." );
611 return VLC_EGENERIC;
614 psz_string = var_GetString( p_parent, psz_filter_type );
616 /* Todo : Use some generic chain manipulation functions */
617 if( !psz_string ) psz_string = strdup("");
619 psz_parser = strstr( psz_string, psz_name );
620 if( b_add )
622 if( !psz_parser )
624 psz_parser = psz_string;
625 if( asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
626 psz_string, psz_name ) == -1 )
628 free( psz_parser );
629 return VLC_EGENERIC;
631 free( psz_parser );
633 else
635 free( psz_string );
636 return VLC_EGENERIC;
639 else
641 if( psz_parser )
643 memmove( psz_parser, psz_parser + strlen(psz_name) +
644 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
645 strlen(psz_parser + strlen(psz_name)) + 1 );
647 /* Remove trailing : : */
648 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
649 *(psz_string+strlen(psz_string ) -1 ) = '\0';
651 else
653 free( psz_string );
654 return VLC_EGENERIC;
658 *ppsz_filter_type = psz_filter_type;
659 *ppsz_filter_value = psz_string;
660 return VLC_SUCCESS;
663 static bool find_sub_source_by_name( libvlc_media_player_t *p_mi, const char *restrict name )
665 vout_thread_t *vout = GetVout( p_mi, 0 );
666 if (!vout)
667 return false;
669 char *psz_sources = var_GetString( vout, "sub-source" );
670 if( !psz_sources )
672 libvlc_printerr( "%s not enabled", name );
673 vout_Release(vout);
674 return false;
677 /* Find 'name' */
678 char *p = strstr( psz_sources, name );
679 free( psz_sources );
680 vout_Release(vout);
681 return (p != NULL);
684 typedef const struct {
685 const char name[20];
686 unsigned type;
687 } opt_t;
689 static void
690 set_value( libvlc_media_player_t *p_mi, const char *restrict name,
691 const opt_t *restrict opt, unsigned i_expected_type,
692 const vlc_value_t *val, bool b_sub_source )
694 if( !opt ) return;
696 int i_type = opt->type;
697 vlc_value_t new_val = *val;
698 const char *psz_opt_name = opt->name;
699 switch( i_type )
701 case 0: /* the enabler */
703 int i_ret = get_filter_str( VLC_OBJECT( p_mi ), opt->name, val->i_int,
704 &psz_opt_name, &new_val.psz_string );
705 if( i_ret != VLC_SUCCESS )
706 return;
707 i_type = VLC_VAR_STRING;
708 break;
710 case VLC_VAR_INTEGER:
711 case VLC_VAR_FLOAT:
712 case VLC_VAR_STRING:
713 if( i_expected_type != opt->type )
715 libvlc_printerr( "Invalid argument to %s", name );
716 return;
718 break;
719 default:
720 libvlc_printerr( "Invalid argument to %s", name );
721 return;
724 /* Set the new value to the media player. Next vouts created from this
725 * media player will inherit this new value */
726 var_SetChecked( p_mi, psz_opt_name, i_type, new_val );
728 /* Set the new value to every loaded vouts */
729 size_t i_vout_count;
730 vout_thread_t **pp_vouts = GetVouts( p_mi, &i_vout_count );
731 for( size_t i = 0; i < i_vout_count; ++i )
733 var_SetChecked( pp_vouts[i], psz_opt_name, i_type, new_val );
734 if( b_sub_source )
735 var_TriggerCallback( pp_vouts[i], "sub-source" );
736 vout_Release(pp_vouts[i]);
739 if( opt->type == 0 )
740 free( new_val.psz_string );
743 static int
744 get_int( libvlc_media_player_t *p_mi, const char *restrict name,
745 const opt_t *restrict opt )
747 if( !opt ) return 0;
749 switch( opt->type )
751 case 0: /* the enabler */
753 bool b_enabled = find_sub_source_by_name( p_mi, name );
754 return b_enabled ? 1 : 0;
756 case VLC_VAR_INTEGER:
757 return var_GetInteger(p_mi, opt->name);
758 case VLC_VAR_FLOAT:
759 return lroundf(var_GetFloat(p_mi, opt->name));
760 default:
761 libvlc_printerr( "Invalid argument to %s in %s", name, "get int" );
762 return 0;
766 static float
767 get_float( libvlc_media_player_t *p_mi, const char *restrict name,
768 const opt_t *restrict opt )
770 if( !opt ) return 0.0;
772 if( opt->type != VLC_VAR_FLOAT )
774 libvlc_printerr( "Invalid argument to %s in %s", name, "get float" );
775 return 0.0;
778 return var_GetFloat( p_mi, opt->name );
781 static const opt_t *
782 marq_option_bynumber(unsigned option)
784 static const opt_t optlist[] =
786 { "marq", 0 },
787 { "marq-marquee", VLC_VAR_STRING },
788 { "marq-color", VLC_VAR_INTEGER },
789 { "marq-opacity", VLC_VAR_INTEGER },
790 { "marq-position", VLC_VAR_INTEGER },
791 { "marq-refresh", VLC_VAR_INTEGER },
792 { "marq-size", VLC_VAR_INTEGER },
793 { "marq-timeout", VLC_VAR_INTEGER },
794 { "marq-x", VLC_VAR_INTEGER },
795 { "marq-y", VLC_VAR_INTEGER },
797 enum { num_opts = sizeof(optlist) / sizeof(*optlist) };
799 const opt_t *r = option < num_opts ? optlist+option : NULL;
800 if( !r )
801 libvlc_printerr( "Unknown marquee option" );
802 return r;
805 /*****************************************************************************
806 * libvlc_video_get_marquee_int : get a marq option value
807 *****************************************************************************/
808 int libvlc_video_get_marquee_int( libvlc_media_player_t *p_mi,
809 unsigned option )
811 return get_int( p_mi, "marq", marq_option_bynumber(option) );
814 /*****************************************************************************
815 * libvlc_video_set_marquee_int: enable, disable or set an int option
816 *****************************************************************************/
817 void libvlc_video_set_marquee_int( libvlc_media_player_t *p_mi,
818 unsigned option, int value )
820 set_value( p_mi, "marq", marq_option_bynumber(option), VLC_VAR_INTEGER,
821 &(vlc_value_t) { .i_int = value }, true );
824 /*****************************************************************************
825 * libvlc_video_set_marquee_string: set a string option
826 *****************************************************************************/
827 void libvlc_video_set_marquee_string( libvlc_media_player_t *p_mi,
828 unsigned option, const char * value )
830 set_value( p_mi, "marq", marq_option_bynumber(option), VLC_VAR_STRING,
831 &(vlc_value_t){ .psz_string = (char *)value }, true );
835 /* logo module support */
837 static const opt_t *
838 logo_option_bynumber( unsigned option )
840 static const opt_t vlogo_optlist[] =
841 /* depends on libvlc_video_logo_option_t */
843 { "logo", 0 },
844 { "logo-file", VLC_VAR_STRING },
845 { "logo-x", VLC_VAR_INTEGER },
846 { "logo-y", VLC_VAR_INTEGER },
847 { "logo-delay", VLC_VAR_INTEGER },
848 { "logo-repeat", VLC_VAR_INTEGER },
849 { "logo-opacity", VLC_VAR_INTEGER },
850 { "logo-position", VLC_VAR_INTEGER },
852 enum { num_vlogo_opts = sizeof(vlogo_optlist) / sizeof(*vlogo_optlist) };
854 const opt_t *r = option < num_vlogo_opts ? vlogo_optlist+option : NULL;
855 if( !r )
856 libvlc_printerr( "Unknown logo option" );
857 return r;
860 void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi,
861 unsigned option, const char *psz_value )
863 set_value( p_mi,"logo",logo_option_bynumber(option), VLC_VAR_STRING,
864 &(vlc_value_t){ .psz_string = (char *)psz_value }, true );
868 void libvlc_video_set_logo_int( libvlc_media_player_t *p_mi,
869 unsigned option, int value )
871 set_value( p_mi, "logo", logo_option_bynumber(option), VLC_VAR_INTEGER,
872 &(vlc_value_t) { .i_int = value }, true );
876 int libvlc_video_get_logo_int( libvlc_media_player_t *p_mi,
877 unsigned option )
879 return get_int( p_mi, "logo", logo_option_bynumber(option) );
883 /* adjust module support */
886 static const opt_t *
887 adjust_option_bynumber( unsigned option )
889 static const opt_t optlist[] =
891 { "adjust", 0 },
892 { "contrast", VLC_VAR_FLOAT },
893 { "brightness", VLC_VAR_FLOAT },
894 { "hue", VLC_VAR_FLOAT },
895 { "saturation", VLC_VAR_FLOAT },
896 { "gamma", VLC_VAR_FLOAT },
898 enum { num_opts = sizeof(optlist) / sizeof(*optlist) };
900 const opt_t *r = option < num_opts ? optlist+option : NULL;
901 if( !r )
902 libvlc_printerr( "Unknown adjust option" );
903 return r;
907 void libvlc_video_set_adjust_int( libvlc_media_player_t *p_mi,
908 unsigned option, int value )
910 set_value( p_mi, "adjust", adjust_option_bynumber(option), VLC_VAR_INTEGER,
911 &(vlc_value_t) { .i_int = value }, false );
915 int libvlc_video_get_adjust_int( libvlc_media_player_t *p_mi,
916 unsigned option )
918 return get_int( p_mi, "adjust", adjust_option_bynumber(option) );
922 void libvlc_video_set_adjust_float( libvlc_media_player_t *p_mi,
923 unsigned option, float value )
925 set_value( p_mi, "adjust", adjust_option_bynumber(option), VLC_VAR_FLOAT,
926 &(vlc_value_t) { .f_float = value }, false );
930 float libvlc_video_get_adjust_float( libvlc_media_player_t *p_mi,
931 unsigned option )
933 return get_float( p_mi, "adjust", adjust_option_bynumber(option) );