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>
43 #include "libvlc_internal.h"
44 #include "media_player_internal.h"
49 * Remember to release the returned vout_thread_t.
51 static vout_thread_t
**GetVouts( libvlc_media_player_t
*p_mi
, size_t *n
)
53 input_thread_t
*p_input
= libvlc_get_input_thread( p_mi
);
60 vout_thread_t
**pp_vouts
;
61 if (input_Control( p_input
, INPUT_GET_VOUTS
, &pp_vouts
, n
))
66 vlc_object_release (p_input
);
70 static vout_thread_t
*GetVout (libvlc_media_player_t
*mp
, size_t num
)
72 vout_thread_t
*p_vout
= NULL
;
74 vout_thread_t
**pp_vouts
= GetVouts (mp
, &n
);
79 p_vout
= pp_vouts
[num
];
81 for (size_t i
= 0; i
< n
; i
++)
83 vlc_object_release (pp_vouts
[i
]);
88 libvlc_printerr ("Video output not active");
92 /**********************************************************************
94 **********************************************************************/
96 void libvlc_set_fullscreen( libvlc_media_player_t
*p_mi
, int b_fullscreen
)
98 /* This will work even if the video is not currently active */
99 var_SetBool (p_mi
, "fullscreen", !!b_fullscreen
);
101 /* Apply to current video outputs (if any) */
103 vout_thread_t
**pp_vouts
= GetVouts (p_mi
, &n
);
104 for (size_t i
= 0; i
< n
; i
++)
106 var_SetBool (pp_vouts
[i
], "fullscreen", b_fullscreen
);
107 vlc_object_release (pp_vouts
[i
]);
112 int libvlc_get_fullscreen( libvlc_media_player_t
*p_mi
)
114 return var_GetBool (p_mi
, "fullscreen");
117 void libvlc_toggle_fullscreen( libvlc_media_player_t
*p_mi
)
119 bool b_fullscreen
= var_ToggleBool (p_mi
, "fullscreen");
121 /* Apply to current video outputs (if any) */
123 vout_thread_t
**pp_vouts
= GetVouts (p_mi
, &n
);
124 for (size_t i
= 0; i
< n
; i
++)
126 vout_thread_t
*p_vout
= pp_vouts
[i
];
128 var_SetBool (p_vout
, "fullscreen", b_fullscreen
);
129 vlc_object_release (p_vout
);
134 void libvlc_video_set_key_input( libvlc_media_player_t
*p_mi
, unsigned on
)
136 var_SetBool (p_mi
, "keyboard-events", !!on
);
139 void libvlc_video_set_mouse_input( libvlc_media_player_t
*p_mi
, unsigned on
)
141 var_SetBool (p_mi
, "mouse-events", !!on
);
145 libvlc_video_take_snapshot( libvlc_media_player_t
*p_mi
, unsigned num
,
146 const char *psz_filepath
,
147 unsigned int i_width
, unsigned int i_height
)
149 assert( psz_filepath
);
151 vout_thread_t
*p_vout
= GetVout (p_mi
, num
);
155 /* FIXME: This is not atomic. All parameters should be passed at once
156 * (obviously _not_ with var_*()). Also, the libvlc object should not be
157 * used for the callbacks: that breaks badly if there are concurrent
158 * media players in the instance. */
159 var_Create( p_vout
, "snapshot-width", VLC_VAR_INTEGER
);
160 var_SetInteger( p_vout
, "snapshot-width", i_width
);
161 var_Create( p_vout
, "snapshot-height", VLC_VAR_INTEGER
);
162 var_SetInteger( p_vout
, "snapshot-height", i_height
);
163 var_Create( p_vout
, "snapshot-path", VLC_VAR_STRING
);
164 var_SetString( p_vout
, "snapshot-path", psz_filepath
);
165 var_Create( p_vout
, "snapshot-format", VLC_VAR_STRING
);
166 var_SetString( p_vout
, "snapshot-format", "png" );
167 var_TriggerCallback( p_vout
, "video-snapshot" );
168 vlc_object_release( p_vout
);
172 int libvlc_video_get_size( libvlc_media_player_t
*p_mi
, unsigned num
,
173 unsigned *restrict px
, unsigned *restrict py
)
175 libvlc_media_track_info_t
*info
;
179 int infos
= libvlc_media_get_tracks_info(p_mi
->p_md
, &info
);
183 for (int i
= 0; i
< infos
; i
++)
184 if (info
[i
].i_type
== libvlc_track_video
&& num
-- == 0) {
185 *px
= info
[i
].u
.video
.i_width
;
186 *py
= info
[i
].u
.video
.i_height
;
195 int libvlc_video_get_height( libvlc_media_player_t
*p_mi
)
197 unsigned width
, height
;
199 if (libvlc_video_get_size (p_mi
, 0, &width
, &height
))
204 int libvlc_video_get_width( libvlc_media_player_t
*p_mi
)
206 unsigned width
, height
;
208 if (libvlc_video_get_size (p_mi
, 0, &width
, &height
))
213 int libvlc_video_get_cursor( libvlc_media_player_t
*mp
, unsigned num
,
214 int *restrict px
, int *restrict py
)
216 vout_thread_t
*p_vout
= GetVout (mp
, num
);
220 var_GetCoords (p_vout
, "mouse-moved", px
, py
);
221 vlc_object_release (p_vout
);
225 unsigned libvlc_media_player_has_vout( libvlc_media_player_t
*p_mi
)
228 vout_thread_t
**pp_vouts
= GetVouts (p_mi
, &n
);
229 for (size_t i
= 0; i
< n
; i
++)
230 vlc_object_release (pp_vouts
[i
]);
235 float libvlc_video_get_scale( libvlc_media_player_t
*mp
)
237 float f_scale
= var_GetFloat (mp
, "zoom");
238 if (var_GetBool (mp
, "autoscale"))
243 void libvlc_video_set_scale( libvlc_media_player_t
*p_mp
, float f_scale
)
245 if (isfinite(f_scale
) && f_scale
!= 0.f
)
246 var_SetFloat (p_mp
, "zoom", f_scale
);
247 var_SetBool (p_mp
, "autoscale", f_scale
== 0.f
);
249 /* Apply to current video outputs (if any) */
251 vout_thread_t
**pp_vouts
= GetVouts (p_mp
, &n
);
252 for (size_t i
= 0; i
< n
; i
++)
254 vout_thread_t
*p_vout
= pp_vouts
[i
];
256 if (isfinite(f_scale
) && f_scale
!= 0.f
)
257 var_SetFloat (p_vout
, "zoom", f_scale
);
258 var_SetBool (p_vout
, "autoscale", f_scale
== 0.f
);
259 vlc_object_release (p_vout
);
264 char *libvlc_video_get_aspect_ratio( libvlc_media_player_t
*p_mi
)
266 return var_GetNonEmptyString (p_mi
, "aspect-ratio");
269 void libvlc_video_set_aspect_ratio( libvlc_media_player_t
*p_mi
,
270 const char *psz_aspect
)
272 if (psz_aspect
== NULL
)
274 var_SetString (p_mi
, "aspect-ratio", psz_aspect
);
277 vout_thread_t
**pp_vouts
= GetVouts (p_mi
, &n
);
278 for (size_t i
= 0; i
< n
; i
++)
280 vout_thread_t
*p_vout
= pp_vouts
[i
];
282 var_SetString (p_vout
, "aspect-ratio", psz_aspect
);
283 vlc_object_release (p_vout
);
288 libvlc_video_viewpoint_t
*libvlc_video_new_viewpoint(void)
290 libvlc_video_viewpoint_t
*p_vp
= malloc(sizeof *p_vp
);
291 if (unlikely(p_vp
== NULL
))
293 p_vp
->f_yaw
= p_vp
->f_pitch
= p_vp
->f_roll
= p_vp
->f_field_of_view
= 0.0f
;
297 int libvlc_video_update_viewpoint( libvlc_media_player_t
*p_mi
,
298 const libvlc_video_viewpoint_t
*p_viewpoint
,
301 vlc_viewpoint_t update
= {
302 .yaw
= p_viewpoint
->f_yaw
,
303 .pitch
= p_viewpoint
->f_pitch
,
304 .roll
= p_viewpoint
->f_roll
,
305 .fov
= p_viewpoint
->f_field_of_view
,
308 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
309 if( p_input_thread
!= NULL
)
311 if( input_UpdateViewpoint( p_input_thread
, &update
,
312 b_absolute
) != VLC_SUCCESS
)
314 vlc_object_release( p_input_thread
);
317 vlc_object_release( p_input_thread
);
321 /* Save the viewpoint in case the input is not created yet */
324 p_mi
->viewpoint
.yaw
+= update
.yaw
;
325 p_mi
->viewpoint
.pitch
+= update
.pitch
;
326 p_mi
->viewpoint
.roll
+= update
.roll
;
327 p_mi
->viewpoint
.fov
+= update
.fov
;
330 p_mi
->viewpoint
= update
;
332 vlc_viewpoint_clip( &p_mi
->viewpoint
);
337 int libvlc_video_get_spu( libvlc_media_player_t
*p_mi
)
339 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
341 if( !p_input_thread
)
343 libvlc_printerr( "No active input" );
347 int i_spu
= var_GetInteger( p_input_thread
, "spu-es" );
348 vlc_object_release( p_input_thread
);
352 int libvlc_video_get_spu_count( libvlc_media_player_t
*p_mi
)
354 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
357 if( !p_input_thread
)
360 i_spu_count
= var_CountChoices( p_input_thread
, "spu-es" );
361 vlc_object_release( p_input_thread
);
365 libvlc_track_description_t
*
366 libvlc_video_get_spu_description( libvlc_media_player_t
*p_mi
)
368 return libvlc_get_track_description( p_mi
, "spu-es" );
371 int libvlc_video_set_spu( libvlc_media_player_t
*p_mi
, int i_spu
)
373 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
377 if( !p_input_thread
)
380 var_Change (p_input_thread
, "spu-es", VLC_VAR_GETCHOICES
, &list
, NULL
);
381 for (int i
= 0; i
< list
.p_list
->i_count
; i
++)
383 if( i_spu
== list
.p_list
->p_values
[i
].i_int
)
385 if( var_SetInteger( p_input_thread
, "spu-es", i_spu
) < 0 )
391 libvlc_printerr( "Track identifier not found" );
393 vlc_object_release (p_input_thread
);
394 var_FreeList (&list
, NULL
);
398 int libvlc_video_set_subtitle_file( libvlc_media_player_t
*p_mi
,
399 const char *psz_subtitle
)
401 input_thread_t
*p_input_thread
= libvlc_get_input_thread ( p_mi
);
406 char* psz_mrl
= vlc_path2uri( psz_subtitle
, NULL
);
409 if( !input_AddSlave( p_input_thread
, SLAVE_TYPE_SPU
, psz_mrl
,
410 true, false, false ) )
414 vlc_object_release( p_input_thread
);
419 int64_t libvlc_video_get_spu_delay( libvlc_media_player_t
*p_mi
)
421 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
426 val
= var_GetInteger( p_input_thread
, "spu-delay" );
427 vlc_object_release( p_input_thread
);
431 libvlc_printerr( "No active input" );
437 int libvlc_video_set_spu_delay( libvlc_media_player_t
*p_mi
,
440 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
445 var_SetInteger( p_input_thread
, "spu-delay", i_delay
);
446 vlc_object_release( p_input_thread
);
451 libvlc_printerr( "No active input" );
457 libvlc_track_description_t
*
458 libvlc_video_get_title_description( libvlc_media_player_t
*p_mi
)
460 return libvlc_get_track_description( p_mi
, "title" );
463 libvlc_track_description_t
*
464 libvlc_video_get_chapter_description( libvlc_media_player_t
*p_mi
,
467 char psz_title
[sizeof ("title ") + 3 * sizeof (int)];
468 sprintf( psz_title
, "title %2u", i_title
);
469 return libvlc_get_track_description( p_mi
, psz_title
);
472 char *libvlc_video_get_crop_geometry (libvlc_media_player_t
*p_mi
)
474 return var_GetNonEmptyString (p_mi
, "crop");
477 void libvlc_video_set_crop_geometry( libvlc_media_player_t
*p_mi
,
478 const char *psz_geometry
)
480 if (psz_geometry
== NULL
)
483 var_SetString (p_mi
, "crop", psz_geometry
);
486 vout_thread_t
**pp_vouts
= GetVouts (p_mi
, &n
);
488 for (size_t i
= 0; i
< n
; i
++)
490 vout_thread_t
*p_vout
= pp_vouts
[i
];
492 var_SetString (p_vout
, "crop", psz_geometry
);
493 vlc_object_release (p_vout
);
498 int libvlc_video_get_teletext( libvlc_media_player_t
*p_mi
)
500 return var_GetInteger (p_mi
, "vbi-page");
503 static void teletext_enable( input_thread_t
*p_input_thread
, bool b_enable
)
508 if( !var_Change( p_input_thread
, "teletext-es", VLC_VAR_GETCHOICES
,
511 if( list
.p_list
->i_count
> 0 )
512 var_SetInteger( p_input_thread
, "spu-es",
513 list
.p_list
->p_values
[0].i_int
);
515 var_FreeList( &list
, NULL
);
519 var_SetInteger( p_input_thread
, "spu-es", -1 );
522 void libvlc_video_set_teletext( libvlc_media_player_t
*p_mi
, int i_page
)
524 input_thread_t
*p_input_thread
;
525 vlc_object_t
*p_zvbi
= NULL
;
529 if( i_page
>= 0 && i_page
< 1000 )
530 var_SetInteger( p_mi
, "vbi-page", i_page
);
531 else if( i_page
>= 1000 )
535 case libvlc_teletext_key_red
:
536 case libvlc_teletext_key_green
:
537 case libvlc_teletext_key_yellow
:
538 case libvlc_teletext_key_blue
:
539 case libvlc_teletext_key_index
:
543 libvlc_printerr("Invalid key action");
549 libvlc_printerr("Invalid page number");
553 p_input_thread
= libvlc_get_input_thread( p_mi
);
554 if( !p_input_thread
) return;
556 if( var_CountChoices( p_input_thread
, "teletext-es" ) <= 0 )
558 vlc_object_release( p_input_thread
);
564 teletext_enable( p_input_thread
, false );
568 telx
= var_GetInteger( p_input_thread
, "teletext-es" );
571 if( input_GetEsObjects( p_input_thread
, telx
, &p_zvbi
, NULL
, NULL
)
574 var_SetInteger( p_zvbi
, "vbi-page", i_page
);
575 vlc_object_release( p_zvbi
);
580 /* the "vbi-page" will be selected on es creation */
581 teletext_enable( p_input_thread
, true );
584 libvlc_printerr("Key action sent while the teletext is disabled");
586 vlc_object_release( p_input_thread
);
589 void libvlc_toggle_teletext( libvlc_media_player_t
*p_mi
)
591 input_thread_t
*p_input_thread
;
593 p_input_thread
= libvlc_get_input_thread(p_mi
);
594 if( !p_input_thread
) return;
596 if( var_CountChoices( p_input_thread
, "teletext-es" ) <= 0 )
598 vlc_object_release( p_input_thread
);
601 const bool b_selected
= var_GetInteger( p_input_thread
, "teletext-es" ) >= 0;
602 teletext_enable( p_input_thread
, !b_selected
);
603 vlc_object_release( p_input_thread
);
606 int libvlc_video_get_track_count( libvlc_media_player_t
*p_mi
)
608 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
611 if( !p_input_thread
)
614 i_track_count
= var_CountChoices( p_input_thread
, "video-es" );
616 vlc_object_release( p_input_thread
);
617 return i_track_count
;
620 libvlc_track_description_t
*
621 libvlc_video_get_track_description( libvlc_media_player_t
*p_mi
)
623 return libvlc_get_track_description( p_mi
, "video-es" );
626 int libvlc_video_get_track( libvlc_media_player_t
*p_mi
)
628 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
630 if( !p_input_thread
)
633 int id
= var_GetInteger( p_input_thread
, "video-es" );
634 vlc_object_release( p_input_thread
);
638 int libvlc_video_set_track( libvlc_media_player_t
*p_mi
, int i_track
)
640 input_thread_t
*p_input_thread
= libvlc_get_input_thread( p_mi
);
641 vlc_value_t val_list
;
644 if( !p_input_thread
)
647 var_Change( p_input_thread
, "video-es", VLC_VAR_GETCHOICES
, &val_list
, NULL
);
648 for( int i
= 0; i
< val_list
.p_list
->i_count
; i
++ )
650 if( i_track
== val_list
.p_list
->p_values
[i
].i_int
)
652 if( var_SetInteger( p_input_thread
, "video-es", i_track
) < 0 )
658 libvlc_printerr( "Track identifier not found" );
660 var_FreeList( &val_list
, NULL
);
661 vlc_object_release( p_input_thread
);
665 /******************************************************************************
666 * libvlc_video_set_deinterlace : enable deinterlace
667 *****************************************************************************/
668 void libvlc_video_set_deinterlace( libvlc_media_player_t
*p_mi
,
669 const char *psz_mode
)
671 if (psz_mode
== NULL
)
674 && strcmp (psz_mode
, "blend") && strcmp (psz_mode
, "bob")
675 && strcmp (psz_mode
, "discard") && strcmp (psz_mode
, "linear")
676 && strcmp (psz_mode
, "mean") && strcmp (psz_mode
, "x")
677 && strcmp (psz_mode
, "yadif") && strcmp (psz_mode
, "yadif2x")
678 && strcmp (psz_mode
, "phosphor") && strcmp (psz_mode
, "ivtc"))
683 var_SetString (p_mi
, "deinterlace-mode", psz_mode
);
684 var_SetInteger (p_mi
, "deinterlace", 1);
687 var_SetInteger (p_mi
, "deinterlace", 0);
690 vout_thread_t
**pp_vouts
= GetVouts (p_mi
, &n
);
691 for (size_t i
= 0; i
< n
; i
++)
693 vout_thread_t
*p_vout
= pp_vouts
[i
];
697 var_SetString (p_vout
, "deinterlace-mode", psz_mode
);
698 var_SetInteger (p_vout
, "deinterlace", 1);
701 var_SetInteger (p_vout
, "deinterlace", 0);
702 vlc_object_release (p_vout
);
711 static int get_filter_str( vlc_object_t
*p_parent
, const char *psz_name
,
712 bool b_add
, const char **ppsz_filter_type
,
713 char **ppsz_filter_value
)
717 const char *psz_filter_type
;
719 module_t
*p_obj
= module_find( psz_name
);
722 msg_Err( p_parent
, "Unable to find filter module \"%s\".", psz_name
);
726 if( module_provides( p_obj
, "video filter" ) )
728 psz_filter_type
= "video-filter";
730 else if( module_provides( p_obj
, "sub source" ) )
732 psz_filter_type
= "sub-source";
734 else if( module_provides( p_obj
, "sub filter" ) )
736 psz_filter_type
= "sub-filter";
740 msg_Err( p_parent
, "Unknown video filter type." );
744 psz_string
= var_GetString( p_parent
, psz_filter_type
);
746 /* Todo : Use some generic chain manipulation functions */
747 if( !psz_string
) psz_string
= strdup("");
749 psz_parser
= strstr( psz_string
, psz_name
);
754 psz_parser
= psz_string
;
755 if( asprintf( &psz_string
, (*psz_string
) ? "%s:%s" : "%s%s",
756 psz_string
, psz_name
) == -1 )
773 memmove( psz_parser
, psz_parser
+ strlen(psz_name
) +
774 (*(psz_parser
+ strlen(psz_name
)) == ':' ? 1 : 0 ),
775 strlen(psz_parser
+ strlen(psz_name
)) + 1 );
777 /* Remove trailing : : */
778 if( *(psz_string
+strlen(psz_string
) -1 ) == ':' )
779 *(psz_string
+strlen(psz_string
) -1 ) = '\0';
788 *ppsz_filter_type
= psz_filter_type
;
789 *ppsz_filter_value
= psz_string
;
793 static bool find_sub_source_by_name( libvlc_media_player_t
*p_mi
, const char *restrict name
)
795 vout_thread_t
*vout
= GetVout( p_mi
, 0 );
799 char *psz_sources
= var_GetString( vout
, "sub-source" );
802 libvlc_printerr( "%s not enabled", name
);
803 vlc_object_release( vout
);
808 char *p
= strstr( psz_sources
, name
);
810 vlc_object_release( vout
);
814 typedef const struct {
820 set_value( libvlc_media_player_t
*p_mi
, const char *restrict name
,
821 const opt_t
*restrict opt
, unsigned i_expected_type
,
822 const vlc_value_t
*val
, bool b_sub_source
)
826 int i_type
= opt
->type
;
827 vlc_value_t new_val
= *val
;
828 const char *psz_opt_name
= opt
->name
;
831 case 0: /* the enabler */
833 int i_ret
= get_filter_str( VLC_OBJECT( p_mi
), opt
->name
, val
->i_int
,
834 &psz_opt_name
, &new_val
.psz_string
);
835 if( i_ret
!= VLC_SUCCESS
)
837 i_type
= VLC_VAR_STRING
;
840 case VLC_VAR_INTEGER
:
843 if( i_expected_type
!= opt
->type
)
845 libvlc_printerr( "Invalid argument to %s", name
);
850 libvlc_printerr( "Invalid argument to %s", name
);
854 /* Set the new value to the media player. Next vouts created from this
855 * media player will inherit this new value */
856 var_SetChecked( p_mi
, psz_opt_name
, i_type
, new_val
);
858 /* Set the new value to every loaded vouts */
860 vout_thread_t
**pp_vouts
= GetVouts( p_mi
, &i_vout_count
);
861 for( size_t i
= 0; i
< i_vout_count
; ++i
)
863 var_SetChecked( pp_vouts
[i
], psz_opt_name
, i_type
, new_val
);
865 var_TriggerCallback( pp_vouts
[i
], "sub-source" );
866 vlc_object_release( pp_vouts
[i
] );
870 free( new_val
.psz_string
);
874 get_int( libvlc_media_player_t
*p_mi
, const char *restrict name
,
875 const opt_t
*restrict opt
)
881 case 0: /* the enabler */
883 bool b_enabled
= find_sub_source_by_name( p_mi
, name
);
884 return b_enabled
? 1 : 0;
886 case VLC_VAR_INTEGER
:
887 return var_GetInteger(p_mi
, opt
->name
);
889 return lroundf(var_GetFloat(p_mi
, opt
->name
));
891 libvlc_printerr( "Invalid argument to %s in %s", name
, "get int" );
897 get_float( libvlc_media_player_t
*p_mi
, const char *restrict name
,
898 const opt_t
*restrict opt
)
900 if( !opt
) return 0.0;
902 if( opt
->type
!= VLC_VAR_FLOAT
)
904 libvlc_printerr( "Invalid argument to %s in %s", name
, "get float" );
908 return var_GetFloat( p_mi
, opt
->name
);
912 get_string( libvlc_media_player_t
*p_mi
, const char *restrict name
,
913 const opt_t
*restrict opt
)
915 if( !opt
) return NULL
;
917 if( opt
->type
!= VLC_VAR_STRING
)
919 libvlc_printerr( "Invalid argument to %s in %s", name
, "get string" );
923 return var_GetString( p_mi
, opt
->name
);
927 marq_option_bynumber(unsigned option
)
929 static const opt_t optlist
[] =
932 { "marq-marquee", VLC_VAR_STRING
},
933 { "marq-color", VLC_VAR_INTEGER
},
934 { "marq-opacity", VLC_VAR_INTEGER
},
935 { "marq-position", VLC_VAR_INTEGER
},
936 { "marq-refresh", VLC_VAR_INTEGER
},
937 { "marq-size", VLC_VAR_INTEGER
},
938 { "marq-timeout", VLC_VAR_INTEGER
},
939 { "marq-x", VLC_VAR_INTEGER
},
940 { "marq-y", VLC_VAR_INTEGER
},
942 enum { num_opts
= sizeof(optlist
) / sizeof(*optlist
) };
944 const opt_t
*r
= option
< num_opts
? optlist
+option
: NULL
;
946 libvlc_printerr( "Unknown marquee option" );
950 /*****************************************************************************
951 * libvlc_video_get_marquee_int : get a marq option value
952 *****************************************************************************/
953 int libvlc_video_get_marquee_int( libvlc_media_player_t
*p_mi
,
956 return get_int( p_mi
, "marq", marq_option_bynumber(option
) );
959 /*****************************************************************************
960 * libvlc_video_get_marquee_string : get a marq option value
961 *****************************************************************************/
962 char * libvlc_video_get_marquee_string( libvlc_media_player_t
*p_mi
,
965 return get_string( p_mi
, "marq", marq_option_bynumber(option
) );
968 /*****************************************************************************
969 * libvlc_video_set_marquee_int: enable, disable or set an int option
970 *****************************************************************************/
971 void libvlc_video_set_marquee_int( libvlc_media_player_t
*p_mi
,
972 unsigned option
, int value
)
974 set_value( p_mi
, "marq", marq_option_bynumber(option
), VLC_VAR_INTEGER
,
975 &(vlc_value_t
) { .i_int
= value
}, true );
978 /*****************************************************************************
979 * libvlc_video_set_marquee_string: set a string option
980 *****************************************************************************/
981 void libvlc_video_set_marquee_string( libvlc_media_player_t
*p_mi
,
982 unsigned option
, const char * value
)
984 set_value( p_mi
, "marq", marq_option_bynumber(option
), VLC_VAR_STRING
,
985 &(vlc_value_t
){ .psz_string
= (char *)value
}, true );
989 /* logo module support */
992 logo_option_bynumber( unsigned option
)
994 static const opt_t vlogo_optlist
[] =
995 /* depends on libvlc_video_logo_option_t */
998 { "logo-file", VLC_VAR_STRING
},
999 { "logo-x", VLC_VAR_INTEGER
},
1000 { "logo-y", VLC_VAR_INTEGER
},
1001 { "logo-delay", VLC_VAR_INTEGER
},
1002 { "logo-repeat", VLC_VAR_INTEGER
},
1003 { "logo-opacity", VLC_VAR_INTEGER
},
1004 { "logo-position", VLC_VAR_INTEGER
},
1006 enum { num_vlogo_opts
= sizeof(vlogo_optlist
) / sizeof(*vlogo_optlist
) };
1008 const opt_t
*r
= option
< num_vlogo_opts
? vlogo_optlist
+option
: NULL
;
1010 libvlc_printerr( "Unknown logo option" );
1014 void libvlc_video_set_logo_string( libvlc_media_player_t
*p_mi
,
1015 unsigned option
, const char *psz_value
)
1017 set_value( p_mi
,"logo",logo_option_bynumber(option
), VLC_VAR_STRING
,
1018 &(vlc_value_t
){ .psz_string
= (char *)psz_value
}, true );
1022 void libvlc_video_set_logo_int( libvlc_media_player_t
*p_mi
,
1023 unsigned option
, int value
)
1025 set_value( p_mi
, "logo", logo_option_bynumber(option
), VLC_VAR_INTEGER
,
1026 &(vlc_value_t
) { .i_int
= value
}, true );
1030 int libvlc_video_get_logo_int( libvlc_media_player_t
*p_mi
,
1033 return get_int( p_mi
, "logo", logo_option_bynumber(option
) );
1037 /* adjust module support */
1040 static const opt_t
*
1041 adjust_option_bynumber( unsigned option
)
1043 static const opt_t optlist
[] =
1046 { "contrast", VLC_VAR_FLOAT
},
1047 { "brightness", VLC_VAR_FLOAT
},
1048 { "hue", VLC_VAR_FLOAT
},
1049 { "saturation", VLC_VAR_FLOAT
},
1050 { "gamma", VLC_VAR_FLOAT
},
1052 enum { num_opts
= sizeof(optlist
) / sizeof(*optlist
) };
1054 const opt_t
*r
= option
< num_opts
? optlist
+option
: NULL
;
1056 libvlc_printerr( "Unknown adjust option" );
1061 void libvlc_video_set_adjust_int( libvlc_media_player_t
*p_mi
,
1062 unsigned option
, int value
)
1064 set_value( p_mi
, "adjust", adjust_option_bynumber(option
), VLC_VAR_INTEGER
,
1065 &(vlc_value_t
) { .i_int
= value
}, false );
1069 int libvlc_video_get_adjust_int( libvlc_media_player_t
*p_mi
,
1072 return get_int( p_mi
, "adjust", adjust_option_bynumber(option
) );
1076 void libvlc_video_set_adjust_float( libvlc_media_player_t
*p_mi
,
1077 unsigned option
, float value
)
1079 set_value( p_mi
, "adjust", adjust_option_bynumber(option
), VLC_VAR_FLOAT
,
1080 &(vlc_value_t
) { .f_float
= value
}, false );
1084 float libvlc_video_get_adjust_float( libvlc_media_player_t
*p_mi
,
1087 return get_float( p_mi
, "adjust", adjust_option_bynumber(option
) );