1 /*****************************************************************************
2 * video.c: libvlc new API video functions
3 *****************************************************************************
4 * Copyright (C) 2005-2010 VLC authors and VideoLAN
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>
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU Lesser General Public License as published by
15 * the Free Software Foundation; either version 2.1 of the License, or
16 * (at your option) any later version.
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 Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public License
24 * along with this program; if not, write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 *****************************************************************************/
32 #include <vlc/libvlc.h>
33 #include <vlc/libvlc_renderer_discoverer.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_input.h>
42 #include "libvlc_internal.h"
43 #include "media_player_internal.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 input_thread_t
*p_input
= libvlc_get_input_thread( p_mi
);
59 vout_thread_t
**pp_vouts
;
60 if (input_Control( p_input
, INPUT_GET_VOUTS
, &pp_vouts
, n
))
65 vlc_object_release (p_input
);
69 static vout_thread_t
*GetVout (libvlc_media_player_t
*mp
, size_t num
)
71 vout_thread_t
*p_vout
= NULL
;
73 vout_thread_t
**pp_vouts
= GetVouts (mp
, &n
);
78 p_vout
= pp_vouts
[num
];
80 for (size_t i
= 0; i
< n
; i
++)
82 vlc_object_release (pp_vouts
[i
]);
87 libvlc_printerr ("Video output not active");
91 /**********************************************************************
93 **********************************************************************/
95 void libvlc_set_fullscreen( libvlc_media_player_t
*p_mi
, int b_fullscreen
)
97 /* This will work even if the video is not currently active */
98 var_SetBool (p_mi
, "fullscreen", !!b_fullscreen
);
100 /* Apply to current video outputs (if any) */
102 vout_thread_t
**pp_vouts
= GetVouts (p_mi
, &n
);
103 for (size_t i
= 0; i
< n
; i
++)
105 var_SetBool (pp_vouts
[i
], "fullscreen", b_fullscreen
);
106 vlc_object_release (pp_vouts
[i
]);
111 int libvlc_get_fullscreen( libvlc_media_player_t
*p_mi
)
113 return var_GetBool (p_mi
, "fullscreen");
116 void libvlc_toggle_fullscreen( libvlc_media_player_t
*p_mi
)
118 bool b_fullscreen
= var_ToggleBool (p_mi
, "fullscreen");
120 /* Apply to current video outputs (if any) */
122 vout_thread_t
**pp_vouts
= GetVouts (p_mi
, &n
);
123 for (size_t i
= 0; i
< n
; i
++)
125 vout_thread_t
*p_vout
= pp_vouts
[i
];
127 var_SetBool (p_vout
, "fullscreen", b_fullscreen
);
128 vlc_object_release (p_vout
);
133 void libvlc_video_set_key_input( libvlc_media_player_t
*p_mi
, unsigned on
)
135 var_SetBool (p_mi
, "keyboard-events", !!on
);
138 void libvlc_video_set_mouse_input( libvlc_media_player_t
*p_mi
, unsigned on
)
140 var_SetBool (p_mi
, "mouse-events", !!on
);
144 libvlc_video_take_snapshot( libvlc_media_player_t
*p_mi
, unsigned num
,
145 const char *psz_filepath
,
146 unsigned int i_width
, unsigned int i_height
)
148 assert( psz_filepath
);
150 vout_thread_t
*p_vout
= GetVout (p_mi
, num
);
154 /* FIXME: This is not atomic. All parameters should be passed at once
155 * (obviously _not_ with var_*()). Also, the libvlc object should not be
156 * used for the callbacks: that breaks badly if there are concurrent
157 * media players in the instance. */
158 var_Create( p_vout
, "snapshot-width", VLC_VAR_INTEGER
);
159 var_SetInteger( p_vout
, "snapshot-width", i_width
);
160 var_Create( p_vout
, "snapshot-height", VLC_VAR_INTEGER
);
161 var_SetInteger( p_vout
, "snapshot-height", i_height
);
162 var_Create( p_vout
, "snapshot-path", VLC_VAR_STRING
);
163 var_SetString( p_vout
, "snapshot-path", psz_filepath
);
164 var_Create( p_vout
, "snapshot-format", VLC_VAR_STRING
);
165 var_SetString( p_vout
, "snapshot-format", "png" );
166 var_TriggerCallback( p_vout
, "video-snapshot" );
167 vlc_object_release( p_vout
);
171 int libvlc_video_get_size( libvlc_media_player_t
*p_mi
, unsigned num
,
172 unsigned *restrict px
, unsigned *restrict py
)
174 libvlc_media_track_info_t
*info
;
178 int infos
= libvlc_media_get_tracks_info(p_mi
->p_md
, &info
);
182 for (int i
= 0; i
< infos
; i
++)
183 if (info
[i
].i_type
== libvlc_track_video
&& num
-- == 0) {
184 *px
= info
[i
].u
.video
.i_width
;
185 *py
= info
[i
].u
.video
.i_height
;
194 int libvlc_video_get_height( libvlc_media_player_t
*p_mi
)
196 unsigned width
, height
;
198 if (libvlc_video_get_size (p_mi
, 0, &width
, &height
))
203 int libvlc_video_get_width( libvlc_media_player_t
*p_mi
)
205 unsigned width
, height
;
207 if (libvlc_video_get_size (p_mi
, 0, &width
, &height
))
212 int libvlc_video_get_cursor( libvlc_media_player_t
*mp
, unsigned num
,
213 int *restrict px
, int *restrict py
)
215 vout_thread_t
*p_vout
= GetVout (mp
, num
);
219 var_GetCoords (p_vout
, "mouse-moved", px
, py
);
220 vlc_object_release (p_vout
);
224 unsigned libvlc_media_player_has_vout( libvlc_media_player_t
*p_mi
)
227 vout_thread_t
**pp_vouts
= GetVouts (p_mi
, &n
);
228 for (size_t i
= 0; i
< n
; i
++)
229 vlc_object_release (pp_vouts
[i
]);
234 float libvlc_video_get_scale( libvlc_media_player_t
*mp
)
236 float f_scale
= var_GetFloat (mp
, "zoom");
237 if (var_GetBool (mp
, "autoscale"))
242 void libvlc_video_set_scale( libvlc_media_player_t
*p_mp
, float f_scale
)
244 if (isfinite(f_scale
) && f_scale
!= 0.f
)
245 var_SetFloat (p_mp
, "zoom", f_scale
);
246 var_SetBool (p_mp
, "autoscale", f_scale
== 0.f
);
248 /* Apply to current video outputs (if any) */
250 vout_thread_t
**pp_vouts
= GetVouts (p_mp
, &n
);
251 for (size_t i
= 0; i
< n
; i
++)
253 vout_thread_t
*p_vout
= pp_vouts
[i
];
255 if (isfinite(f_scale
) && f_scale
!= 0.f
)
256 var_SetFloat (p_vout
, "zoom", f_scale
);
257 var_SetBool (p_vout
, "autoscale", f_scale
== 0.f
);
258 vlc_object_release (p_vout
);
263 char *libvlc_video_get_aspect_ratio( libvlc_media_player_t
*p_mi
)
265 return var_GetNonEmptyString (p_mi
, "aspect-ratio");
268 void libvlc_video_set_aspect_ratio( libvlc_media_player_t
*p_mi
,
269 const char *psz_aspect
)
271 if (psz_aspect
== NULL
)
273 var_SetString (p_mi
, "aspect-ratio", psz_aspect
);
276 vout_thread_t
**pp_vouts
= GetVouts (p_mi
, &n
);
277 for (size_t i
= 0; i
< n
; i
++)
279 vout_thread_t
*p_vout
= pp_vouts
[i
];
281 var_SetString (p_vout
, "aspect-ratio", psz_aspect
);
282 vlc_object_release (p_vout
);
287 libvlc_video_viewpoint_t
*libvlc_video_new_viewpoint(void)
289 libvlc_video_viewpoint_t
*p_vp
= malloc(sizeof *p_vp
);
290 if (unlikely(p_vp
== NULL
))
292 p_vp
->f_yaw
= p_vp
->f_pitch
= p_vp
->f_roll
= p_vp
->f_field_of_view
= 0.0f
;
296 int libvlc_video_update_viewpoint( libvlc_media_player_t
*p_mi
,
297 const libvlc_video_viewpoint_t
*p_viewpoint
,
300 vlc_viewpoint_t update
= {
301 .yaw
= p_viewpoint
->f_yaw
,
302 .pitch
= p_viewpoint
->f_pitch
,
303 .roll
= p_viewpoint
->f_roll
,
304 .fov
= p_viewpoint
->f_field_of_view
,
307 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
308 if( p_input_thread
!= NULL
)
310 if( input_UpdateViewpoint( p_input_thread
, &update
,
311 b_absolute
) != VLC_SUCCESS
)
313 vlc_object_release( p_input_thread
);
316 vlc_object_release( p_input_thread
);
320 /* Save the viewpoint in case the input is not created yet */
323 p_mi
->viewpoint
.yaw
+= update
.yaw
;
324 p_mi
->viewpoint
.pitch
+= update
.pitch
;
325 p_mi
->viewpoint
.roll
+= update
.roll
;
326 p_mi
->viewpoint
.fov
+= update
.fov
;
329 p_mi
->viewpoint
= update
;
334 int libvlc_video_get_spu( libvlc_media_player_t
*p_mi
)
336 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
338 if( !p_input_thread
)
340 libvlc_printerr( "No active input" );
344 int i_spu
= var_GetInteger( p_input_thread
, "spu-es" );
345 vlc_object_release( p_input_thread
);
349 int libvlc_video_get_spu_count( libvlc_media_player_t
*p_mi
)
351 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
354 if( !p_input_thread
)
357 i_spu_count
= var_CountChoices( p_input_thread
, "spu-es" );
358 vlc_object_release( p_input_thread
);
362 libvlc_track_description_t
*
363 libvlc_video_get_spu_description( libvlc_media_player_t
*p_mi
)
365 return libvlc_get_track_description( p_mi
, "spu-es" );
368 int libvlc_video_set_spu( libvlc_media_player_t
*p_mi
, int i_spu
)
370 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
374 if( !p_input_thread
)
377 var_Change (p_input_thread
, "spu-es", VLC_VAR_GETCHOICES
, &list
, NULL
);
378 for (int i
= 0; i
< list
.p_list
->i_count
; i
++)
380 if( i_spu
== list
.p_list
->p_values
[i
].i_int
)
382 if( var_SetInteger( p_input_thread
, "spu-es", i_spu
) < 0 )
388 libvlc_printerr( "Track identifier not found" );
390 vlc_object_release (p_input_thread
);
391 var_FreeList (&list
, NULL
);
395 int libvlc_video_set_subtitle_file( libvlc_media_player_t
*p_mi
,
396 const char *psz_subtitle
)
398 input_thread_t
*p_input_thread
= libvlc_get_input_thread ( p_mi
);
403 if( !input_AddSubtitle( p_input_thread
, psz_subtitle
, true ) )
405 vlc_object_release( p_input_thread
);
410 int64_t libvlc_video_get_spu_delay( libvlc_media_player_t
*p_mi
)
412 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
417 val
= var_GetInteger( p_input_thread
, "spu-delay" );
418 vlc_object_release( p_input_thread
);
422 libvlc_printerr( "No active input" );
428 int libvlc_video_set_spu_delay( libvlc_media_player_t
*p_mi
,
431 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
436 var_SetInteger( p_input_thread
, "spu-delay", i_delay
);
437 vlc_object_release( p_input_thread
);
442 libvlc_printerr( "No active input" );
448 libvlc_track_description_t
*
449 libvlc_video_get_title_description( libvlc_media_player_t
*p_mi
)
451 return libvlc_get_track_description( p_mi
, "title" );
454 libvlc_track_description_t
*
455 libvlc_video_get_chapter_description( libvlc_media_player_t
*p_mi
,
458 char psz_title
[sizeof ("title ") + 3 * sizeof (int)];
459 sprintf( psz_title
, "title %2u", i_title
);
460 return libvlc_get_track_description( p_mi
, psz_title
);
463 char *libvlc_video_get_crop_geometry (libvlc_media_player_t
*p_mi
)
465 return var_GetNonEmptyString (p_mi
, "crop");
468 void libvlc_video_set_crop_geometry( libvlc_media_player_t
*p_mi
,
469 const char *psz_geometry
)
471 if (psz_geometry
== NULL
)
474 var_SetString (p_mi
, "crop", psz_geometry
);
477 vout_thread_t
**pp_vouts
= GetVouts (p_mi
, &n
);
479 for (size_t i
= 0; i
< n
; i
++)
481 vout_thread_t
*p_vout
= pp_vouts
[i
];
483 var_SetString (p_vout
, "crop", psz_geometry
);
484 vlc_object_release (p_vout
);
489 int libvlc_video_get_teletext( libvlc_media_player_t
*p_mi
)
491 return var_GetInteger (p_mi
, "vbi-page");
494 static void teletext_enable( input_thread_t
*p_input_thread
, bool b_enable
)
499 if( !var_Change( p_input_thread
, "teletext-es", VLC_VAR_GETCHOICES
,
502 if( list
.p_list
->i_count
> 0 )
503 var_SetInteger( p_input_thread
, "spu-es",
504 list
.p_list
->p_values
[0].i_int
);
506 var_FreeList( &list
, NULL
);
510 var_SetInteger( p_input_thread
, "spu-es", -1 );
513 void libvlc_video_set_teletext( libvlc_media_player_t
*p_mi
, int i_page
)
515 input_thread_t
*p_input_thread
;
516 vlc_object_t
*p_zvbi
= NULL
;
520 if( i_page
>= 0 && i_page
< 1000 )
521 var_SetInteger( p_mi
, "vbi-page", i_page
);
522 else if( i_page
>= 1000 )
526 case libvlc_teletext_key_red
:
527 case libvlc_teletext_key_green
:
528 case libvlc_teletext_key_yellow
:
529 case libvlc_teletext_key_blue
:
530 case libvlc_teletext_key_index
:
534 libvlc_printerr("Invalid key action");
540 libvlc_printerr("Invalid page number");
544 p_input_thread
= libvlc_get_input_thread( p_mi
);
545 if( !p_input_thread
) return;
547 if( var_CountChoices( p_input_thread
, "teletext-es" ) <= 0 )
549 vlc_object_release( p_input_thread
);
555 teletext_enable( p_input_thread
, false );
559 telx
= var_GetInteger( p_input_thread
, "teletext-es" );
562 if( input_GetEsObjects( p_input_thread
, telx
, &p_zvbi
, NULL
, NULL
)
565 var_SetInteger( p_zvbi
, "vbi-page", i_page
);
566 vlc_object_release( p_zvbi
);
571 /* the "vbi-page" will be selected on es creation */
572 teletext_enable( p_input_thread
, true );
575 libvlc_printerr("Key action sent while the teletext is disabled");
577 vlc_object_release( p_input_thread
);
580 void libvlc_toggle_teletext( libvlc_media_player_t
*p_mi
)
582 input_thread_t
*p_input_thread
;
584 p_input_thread
= libvlc_get_input_thread(p_mi
);
585 if( !p_input_thread
) return;
587 if( var_CountChoices( p_input_thread
, "teletext-es" ) <= 0 )
589 vlc_object_release( p_input_thread
);
592 const bool b_selected
= var_GetInteger( p_input_thread
, "teletext-es" ) >= 0;
593 teletext_enable( p_input_thread
, !b_selected
);
594 vlc_object_release( p_input_thread
);
597 int libvlc_video_get_track_count( libvlc_media_player_t
*p_mi
)
599 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
602 if( !p_input_thread
)
605 i_track_count
= var_CountChoices( p_input_thread
, "video-es" );
607 vlc_object_release( p_input_thread
);
608 return i_track_count
;
611 libvlc_track_description_t
*
612 libvlc_video_get_track_description( libvlc_media_player_t
*p_mi
)
614 return libvlc_get_track_description( p_mi
, "video-es" );
617 int libvlc_video_get_track( libvlc_media_player_t
*p_mi
)
619 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
621 if( !p_input_thread
)
624 int id
= var_GetInteger( p_input_thread
, "video-es" );
625 vlc_object_release( p_input_thread
);
629 int libvlc_video_set_track( libvlc_media_player_t
*p_mi
, int i_track
)
631 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
632 vlc_value_t val_list
;
635 if( !p_input_thread
)
638 var_Change( p_input_thread
, "video-es", VLC_VAR_GETCHOICES
, &val_list
, NULL
);
639 for( int i
= 0; i
< val_list
.p_list
->i_count
; i
++ )
641 if( i_track
== val_list
.p_list
->p_values
[i
].i_int
)
643 if( var_SetInteger( p_input_thread
, "video-es", i_track
) < 0 )
649 libvlc_printerr( "Track identifier not found" );
651 var_FreeList( &val_list
, NULL
);
652 vlc_object_release( p_input_thread
);
656 /******************************************************************************
657 * libvlc_video_set_deinterlace : enable deinterlace
658 *****************************************************************************/
659 void libvlc_video_set_deinterlace( libvlc_media_player_t
*p_mi
,
660 const char *psz_mode
)
662 if (psz_mode
== NULL
)
665 && strcmp (psz_mode
, "blend") && strcmp (psz_mode
, "bob")
666 && strcmp (psz_mode
, "discard") && strcmp (psz_mode
, "linear")
667 && strcmp (psz_mode
, "mean") && strcmp (psz_mode
, "x")
668 && strcmp (psz_mode
, "yadif") && strcmp (psz_mode
, "yadif2x")
669 && strcmp (psz_mode
, "phosphor") && strcmp (psz_mode
, "ivtc"))
674 var_SetString (p_mi
, "deinterlace-mode", psz_mode
);
675 var_SetInteger (p_mi
, "deinterlace", 1);
678 var_SetInteger (p_mi
, "deinterlace", 0);
681 vout_thread_t
**pp_vouts
= GetVouts (p_mi
, &n
);
682 for (size_t i
= 0; i
< n
; i
++)
684 vout_thread_t
*p_vout
= pp_vouts
[i
];
688 var_SetString (p_vout
, "deinterlace-mode", psz_mode
);
689 var_SetInteger (p_vout
, "deinterlace", 1);
692 var_SetInteger (p_vout
, "deinterlace", 0);
693 vlc_object_release (p_vout
);
702 static int get_filter_str( vlc_object_t
*p_parent
, const char *psz_name
,
703 bool b_add
, const char **ppsz_filter_type
,
704 char **ppsz_filter_value
)
708 const char *psz_filter_type
;
710 module_t
*p_obj
= module_find( psz_name
);
713 msg_Err( p_parent
, "Unable to find filter module \"%s\".", psz_name
);
717 if( module_provides( p_obj
, "video filter" ) )
719 psz_filter_type
= "video-filter";
721 else if( module_provides( p_obj
, "sub source" ) )
723 psz_filter_type
= "sub-source";
725 else if( module_provides( p_obj
, "sub filter" ) )
727 psz_filter_type
= "sub-filter";
731 msg_Err( p_parent
, "Unknown video filter type." );
735 psz_string
= var_GetString( p_parent
, psz_filter_type
);
737 /* Todo : Use some generic chain manipulation functions */
738 if( !psz_string
) psz_string
= strdup("");
740 psz_parser
= strstr( psz_string
, psz_name
);
745 psz_parser
= psz_string
;
746 if( asprintf( &psz_string
, (*psz_string
) ? "%s:%s" : "%s%s",
747 psz_string
, psz_name
) == -1 )
764 memmove( psz_parser
, psz_parser
+ strlen(psz_name
) +
765 (*(psz_parser
+ strlen(psz_name
)) == ':' ? 1 : 0 ),
766 strlen(psz_parser
+ strlen(psz_name
)) + 1 );
768 /* Remove trailing : : */
769 if( *(psz_string
+strlen(psz_string
) -1 ) == ':' )
770 *(psz_string
+strlen(psz_string
) -1 ) = '\0';
779 *ppsz_filter_type
= psz_filter_type
;
780 *ppsz_filter_value
= psz_string
;
784 static bool find_sub_source_by_name( libvlc_media_player_t
*p_mi
, const char *restrict name
)
786 vout_thread_t
*vout
= GetVout( p_mi
, 0 );
790 char *psz_sources
= var_GetString( vout
, "sub-source" );
793 libvlc_printerr( "%s not enabled", name
);
794 vlc_object_release( vout
);
799 char *p
= strstr( psz_sources
, name
);
801 vlc_object_release( vout
);
805 typedef const struct {
811 set_value( libvlc_media_player_t
*p_mi
, const char *restrict name
,
812 const opt_t
*restrict opt
, unsigned i_expected_type
,
813 const vlc_value_t
*val
, bool b_sub_source
)
817 int i_type
= opt
->type
;
818 vlc_value_t new_val
= *val
;
819 const char *psz_opt_name
= opt
->name
;
822 case 0: /* the enabler */
824 int i_ret
= get_filter_str( VLC_OBJECT( p_mi
), opt
->name
, val
->i_int
,
825 &psz_opt_name
, &new_val
.psz_string
);
826 if( i_ret
!= VLC_SUCCESS
)
828 i_type
= VLC_VAR_STRING
;
831 case VLC_VAR_INTEGER
:
834 if( i_expected_type
!= opt
->type
)
836 libvlc_printerr( "Invalid argument to %s", name
);
841 libvlc_printerr( "Invalid argument to %s", name
);
845 /* Set the new value to the media player. Next vouts created from this
846 * media player will inherit this new value */
847 var_SetChecked( p_mi
, psz_opt_name
, i_type
, new_val
);
849 /* Set the new value to every loaded vouts */
851 vout_thread_t
**pp_vouts
= GetVouts( p_mi
, &i_vout_count
);
852 for( size_t i
= 0; i
< i_vout_count
; ++i
)
854 var_SetChecked( pp_vouts
[i
], psz_opt_name
, i_type
, new_val
);
856 var_TriggerCallback( pp_vouts
[i
], "sub-source" );
857 vlc_object_release( pp_vouts
[i
] );
861 free( new_val
.psz_string
);
865 get_int( libvlc_media_player_t
*p_mi
, const char *restrict name
,
866 const opt_t
*restrict opt
)
872 case 0: /* the enabler */
874 bool b_enabled
= find_sub_source_by_name( p_mi
, name
);
875 return b_enabled
? 1 : 0;
877 case VLC_VAR_INTEGER
:
878 return var_GetInteger(p_mi
, opt
->name
);
880 return lroundf(var_GetFloat(p_mi
, opt
->name
));
882 libvlc_printerr( "Invalid argument to %s in %s", name
, "get int" );
888 get_float( libvlc_media_player_t
*p_mi
, const char *restrict name
,
889 const opt_t
*restrict opt
)
891 if( !opt
) return 0.0;
893 if( opt
->type
!= VLC_VAR_FLOAT
)
895 libvlc_printerr( "Invalid argument to %s in %s", name
, "get float" );
899 return var_GetFloat( p_mi
, opt
->name
);
903 get_string( libvlc_media_player_t
*p_mi
, const char *restrict name
,
904 const opt_t
*restrict opt
)
906 if( !opt
) return NULL
;
908 if( opt
->type
!= VLC_VAR_STRING
)
910 libvlc_printerr( "Invalid argument to %s in %s", name
, "get string" );
914 return var_GetString( p_mi
, opt
->name
);
918 marq_option_bynumber(unsigned option
)
920 static const opt_t optlist
[] =
923 { "marq-marquee", VLC_VAR_STRING
},
924 { "marq-color", VLC_VAR_INTEGER
},
925 { "marq-opacity", VLC_VAR_INTEGER
},
926 { "marq-position", VLC_VAR_INTEGER
},
927 { "marq-refresh", VLC_VAR_INTEGER
},
928 { "marq-size", VLC_VAR_INTEGER
},
929 { "marq-timeout", VLC_VAR_INTEGER
},
930 { "marq-x", VLC_VAR_INTEGER
},
931 { "marq-y", VLC_VAR_INTEGER
},
933 enum { num_opts
= sizeof(optlist
) / sizeof(*optlist
) };
935 const opt_t
*r
= option
< num_opts
? optlist
+option
: NULL
;
937 libvlc_printerr( "Unknown marquee option" );
941 /*****************************************************************************
942 * libvlc_video_get_marquee_int : get a marq option value
943 *****************************************************************************/
944 int libvlc_video_get_marquee_int( libvlc_media_player_t
*p_mi
,
947 return get_int( p_mi
, "marq", marq_option_bynumber(option
) );
950 /*****************************************************************************
951 * libvlc_video_get_marquee_string : get a marq option value
952 *****************************************************************************/
953 char * libvlc_video_get_marquee_string( libvlc_media_player_t
*p_mi
,
956 return get_string( p_mi
, "marq", marq_option_bynumber(option
) );
959 /*****************************************************************************
960 * libvlc_video_set_marquee_int: enable, disable or set an int option
961 *****************************************************************************/
962 void libvlc_video_set_marquee_int( libvlc_media_player_t
*p_mi
,
963 unsigned option
, int value
)
965 set_value( p_mi
, "marq", marq_option_bynumber(option
), VLC_VAR_INTEGER
,
966 &(vlc_value_t
) { .i_int
= value
}, true );
969 /*****************************************************************************
970 * libvlc_video_set_marquee_string: set a string option
971 *****************************************************************************/
972 void libvlc_video_set_marquee_string( libvlc_media_player_t
*p_mi
,
973 unsigned option
, const char * value
)
975 set_value( p_mi
, "marq", marq_option_bynumber(option
), VLC_VAR_STRING
,
976 &(vlc_value_t
){ .psz_string
= (char *)value
}, true );
980 /* logo module support */
983 logo_option_bynumber( unsigned option
)
985 static const opt_t vlogo_optlist
[] =
986 /* depends on libvlc_video_logo_option_t */
989 { "logo-file", VLC_VAR_STRING
},
990 { "logo-x", VLC_VAR_INTEGER
},
991 { "logo-y", VLC_VAR_INTEGER
},
992 { "logo-delay", VLC_VAR_INTEGER
},
993 { "logo-repeat", VLC_VAR_INTEGER
},
994 { "logo-opacity", VLC_VAR_INTEGER
},
995 { "logo-position", VLC_VAR_INTEGER
},
997 enum { num_vlogo_opts
= sizeof(vlogo_optlist
) / sizeof(*vlogo_optlist
) };
999 const opt_t
*r
= option
< num_vlogo_opts
? vlogo_optlist
+option
: NULL
;
1001 libvlc_printerr( "Unknown logo option" );
1005 void libvlc_video_set_logo_string( libvlc_media_player_t
*p_mi
,
1006 unsigned option
, const char *psz_value
)
1008 set_value( p_mi
,"logo",logo_option_bynumber(option
), VLC_VAR_STRING
,
1009 &(vlc_value_t
){ .psz_string
= (char *)psz_value
}, true );
1013 void libvlc_video_set_logo_int( libvlc_media_player_t
*p_mi
,
1014 unsigned option
, int value
)
1016 set_value( p_mi
, "logo", logo_option_bynumber(option
), VLC_VAR_INTEGER
,
1017 &(vlc_value_t
) { .i_int
= value
}, true );
1021 int libvlc_video_get_logo_int( libvlc_media_player_t
*p_mi
,
1024 return get_int( p_mi
, "logo", logo_option_bynumber(option
) );
1028 /* adjust module support */
1031 static const opt_t
*
1032 adjust_option_bynumber( unsigned option
)
1034 static const opt_t optlist
[] =
1037 { "contrast", VLC_VAR_FLOAT
},
1038 { "brightness", VLC_VAR_FLOAT
},
1039 { "hue", VLC_VAR_FLOAT
},
1040 { "saturation", VLC_VAR_FLOAT
},
1041 { "gamma", VLC_VAR_FLOAT
},
1043 enum { num_opts
= sizeof(optlist
) / sizeof(*optlist
) };
1045 const opt_t
*r
= option
< num_opts
? optlist
+option
: NULL
;
1047 libvlc_printerr( "Unknown adjust option" );
1052 void libvlc_video_set_adjust_int( libvlc_media_player_t
*p_mi
,
1053 unsigned option
, int value
)
1055 set_value( p_mi
, "adjust", adjust_option_bynumber(option
), VLC_VAR_INTEGER
,
1056 &(vlc_value_t
) { .i_int
= value
}, false );
1060 int libvlc_video_get_adjust_int( libvlc_media_player_t
*p_mi
,
1063 return get_int( p_mi
, "adjust", adjust_option_bynumber(option
) );
1067 void libvlc_video_set_adjust_float( libvlc_media_player_t
*p_mi
,
1068 unsigned option
, float value
)
1070 set_value( p_mi
, "adjust", adjust_option_bynumber(option
), VLC_VAR_FLOAT
,
1071 &(vlc_value_t
) { .f_float
= value
}, false );
1075 float libvlc_video_get_adjust_float( libvlc_media_player_t
*p_mi
,
1078 return get_float( p_mi
, "adjust", adjust_option_bynumber(option
) );