X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fcontrol%2Fvideo.c;h=d07a69284b6ff4ce53212ecfccb65859ae4cb612;hb=03b85ce331b532799827bea23dbe3237f5818733;hp=9e846ba302c999e50cf45e5057d45d54e03bb3af;hpb=ab044cf5fc48be7d74097b7855558875b50e991c;p=vlc diff --git a/src/control/video.c b/src/control/video.c index 9e846ba302..d07a69284b 100644 --- a/src/control/video.c +++ b/src/control/video.c @@ -5,7 +5,7 @@ * * $Id$ * - * Authors: Cl�ent Stenac + * Authors: Clément Stenac * Filippo Carone * Jean-Paul Saman * Damien Fouilleul @@ -42,7 +42,7 @@ static vout_thread_t *GetVout( libvlc_media_player_t *p_mi, if( p_input_thread ) { - p_vout = vlc_object_find( p_input_thread, VLC_OBJECT_VOUT, FIND_CHILD ); + p_vout = input_GetVout( p_input_thread ); if( !p_vout ) { libvlc_exception_raise( p_exception, "No active video output" ); @@ -104,7 +104,7 @@ void libvlc_toggle_fullscreen( libvlc_media_player_t *p_mi, } void -libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, char *psz_filepath, +libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, const char *psz_filepath, unsigned int i_width, unsigned int i_height, libvlc_exception_t *p_e ) { vout_thread_t *p_vout = GetVout( p_mi, p_e ); @@ -132,7 +132,7 @@ libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, char *psz_filepath, var_SetString( p_vout, "snapshot-path", psz_filepath ); var_SetString( p_vout, "snapshot-format", "png" ); - vout_Control( p_vout, VOUT_SNAPSHOT ); + var_TriggerCallback( p_vout, "video-snapshot" ); vlc_object_release( p_vout ); } @@ -176,7 +176,7 @@ int libvlc_media_player_has_vout( libvlc_media_player_t *p_mi, { vout_thread_t *p_vout; - p_vout = vlc_object_find( p_input_thread, VLC_OBJECT_VOUT, FIND_CHILD ); + p_vout = input_GetVout( p_input_thread ); if( p_vout ) { has_vout = true; @@ -187,153 +187,6 @@ int libvlc_media_player_has_vout( libvlc_media_player_t *p_mi, return has_vout; } -int libvlc_video_reparent( libvlc_media_player_t *p_mi, libvlc_drawable_t d, - libvlc_exception_t *p_e ) -{ - vout_thread_t *p_vout = GetVout( p_mi, p_e ); - - if( p_vout ) - { - vout_Control( p_vout , VOUT_REPARENT, d); - vlc_object_release( p_vout ); - } - return 0; -} - -void libvlc_video_resize( libvlc_media_player_t *p_mi, int width, int height, libvlc_exception_t *p_e ) -{ - vout_thread_t *p_vout = GetVout( p_mi, p_e ); - if( p_vout ) - { - vout_Control( p_vout, VOUT_SET_SIZE, width, height ); - vlc_object_release( p_vout ); - } -} - -void libvlc_video_redraw_rectangle( libvlc_media_player_t *p_mi, - const libvlc_rectangle_t *area, - libvlc_exception_t *p_e ) -{ - if( (NULL != area) - && ((area->bottom - area->top) > 0) - && ((area->right - area->left) > 0) ) - { - vout_thread_t *p_vout = GetVout( p_mi, p_e ); - if( p_vout ) - { - /* tell running vout to redraw area */ - vout_Control( p_vout , VOUT_REDRAW_RECT, - area->top, area->left, area->bottom, area->right ); - vlc_object_release( p_vout ); - } - } -} - -/* global video settings */ - -/* Deprecated use libvlc_media_player_set_drawable() */ -void libvlc_video_set_parent( libvlc_instance_t *p_instance, libvlc_drawable_t d, - libvlc_exception_t *p_e ) -{ - /* set as default for future vout instances */ -#ifdef WIN32 - vlc_value_t val; - - if( sizeof(HWND) > sizeof(libvlc_drawable_t) ) - return; /* BOOM! we told you not to use this function! */ - val.p_address = (void *)(uintptr_t)d; - var_Set( p_instance->p_libvlc_int, "drawable-hwnd", val ); -#else - var_SetInteger( p_instance->p_libvlc_int, "drawable-xid", d ); -#endif - - libvlc_media_player_t *p_mi = libvlc_playlist_get_media_player(p_instance, p_e); - if( p_mi ) - { - libvlc_media_player_set_drawable( p_mi, d, p_e ); - libvlc_media_player_release(p_mi); - } -} - -/* Deprecated use libvlc_media_player_get_drawable() */ -libvlc_drawable_t libvlc_video_get_parent( libvlc_instance_t *p_instance, libvlc_exception_t *p_e ) -{ - VLC_UNUSED(p_e); - -#ifdef WIN32 - vlc_value_t val; - - if( sizeof(HWND) > sizeof(libvlc_drawable_t) ) - return 0; - var_Get( p_instance->p_libvlc_int, "drawable-hwnd", &val ); - return (uintptr_t)val.p_address; -#else - return var_GetInteger( p_instance->p_libvlc_int, "drawable-xid" ); -#endif -} - - -void libvlc_video_set_size( libvlc_instance_t *p_instance, int width, int height, - libvlc_exception_t *p_e ) -{ - /* set as default for future vout instances */ - config_PutInt(p_instance->p_libvlc_int, "width", width); - config_PutInt(p_instance->p_libvlc_int, "height", height); - - libvlc_media_player_t *p_mi = libvlc_playlist_get_media_player(p_instance, p_e); - if( p_mi ) - { - vout_thread_t *p_vout = GetVout( p_mi, p_e ); - if( p_vout ) - { - /* tell running vout to re-size */ - vout_Control( p_vout , VOUT_SET_SIZE, width, height); - vlc_object_release( p_vout ); - } - libvlc_media_player_release(p_mi); - } -} - -void libvlc_video_set_viewport( libvlc_instance_t *p_instance, - const libvlc_rectangle_t *view, const libvlc_rectangle_t *clip, - libvlc_exception_t *p_e ) -{ - if( !view ) - { - libvlc_exception_raise( p_e, "viewport is NULL" ); - return; - } - - /* if clip is NULL, then use view rectangle as clip */ - if( !clip ) - clip = view; - - /* set as default for future vout instances */ - var_SetInteger( p_instance->p_libvlc_int, "drawable-view-top", view->top ); - var_SetInteger( p_instance->p_libvlc_int, "drawable-view-left", view->left ); - var_SetInteger( p_instance->p_libvlc_int, "drawable-view-bottom", view->bottom ); - var_SetInteger( p_instance->p_libvlc_int, "drawable-view-right", view->right ); - var_SetInteger( p_instance->p_libvlc_int, "drawable-clip-top", clip->top ); - var_SetInteger( p_instance->p_libvlc_int, "drawable-clip-left", clip->left ); - var_SetInteger( p_instance->p_libvlc_int, "drawable-clip-bottom", clip->bottom ); - var_SetInteger( p_instance->p_libvlc_int, "drawable-clip-right", clip->right ); - - libvlc_media_player_t *p_mi = libvlc_playlist_get_media_player(p_instance, p_e); - if( p_mi ) - { - vout_thread_t *p_vout = GetVout( p_mi, p_e ); - if( p_vout ) - { - /* change viewport for running vout */ - vout_Control( p_vout , VOUT_SET_VIEWPORT, - view->top, view->left, view->bottom, view->right, - clip->top, clip->left, clip->bottom, clip->right ); - vlc_object_release( p_vout ); - } - libvlc_media_player_release(p_mi); - } -} - char *libvlc_video_get_aspect_ratio( libvlc_media_player_t *p_mi, libvlc_exception_t *p_e ) { @@ -429,6 +282,14 @@ void libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu, if( !p_input_thread ) return; var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL ); + + if( val_list.p_list->i_count == 0 ) + { + libvlc_exception_raise( p_e, "Subtitle value out of range" ); + vlc_object_release( p_input_thread ); + return; + } + if( (i_spu < 0) && (i_spu > val_list.p_list->i_count) ) { libvlc_exception_raise( p_e, "Subtitle value out of range" ); @@ -517,7 +378,7 @@ int libvlc_video_get_teletext( libvlc_media_player_t *p_mi, if( !p_vout ) return i_ret; p_vbi = (vlc_object_t *) vlc_object_find_name( p_vout, "zvbi", - FIND_ANYWHERE ); + FIND_CHILD ); if( p_vbi ) { i_ret = var_GetInteger( p_vbi, "vbi-page" ); @@ -538,7 +399,7 @@ void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page, if( !p_vout ) return; p_vbi = (vlc_object_t *) vlc_object_find_name( p_vout, "zvbi", - FIND_ANYWHERE ); + FIND_CHILD ); if( p_vbi ) { i_ret = var_SetInteger( p_vbi, "vbi-page", i_page ); @@ -560,52 +421,50 @@ void libvlc_toggle_teletext( libvlc_media_player_t *p_mi, p_input_thread = libvlc_get_input_thread(p_mi, p_e); if( !p_input_thread ) return; - p_vbi = (vlc_object_t *) vlc_object_find_name( p_input_thread, "zvbi", - FIND_ANYWHERE ); - if( p_vbi ) + if( var_CountChoices( p_input_thread, "teletext-es" ) <= 0 ) { - const int i_teletext_es = var_GetInteger( p_input_thread, "teletext-es" ); - const int i_spu_es = var_GetInteger( p_input_thread, "spu-es" ); + vlc_object_release( p_input_thread ); + return; + } + const bool b_selected = var_GetInteger( p_input_thread, "teletext-es" ) >= 0; - if( (i_teletext_es >= 0) && (i_teletext_es == i_spu_es) ) + p_vbi = (vlc_object_t *)vlc_object_find_name( p_input_thread, "zvbi", + FIND_CHILD ); + if( p_vbi ) + { + if( b_selected ) { - int i_page = 100; - - i_page = var_GetInteger( p_vbi, "vbi-page" ); - i_page = (i_teletext_es >= 0) ? i_page : 0; - - i_ret = var_SetInteger( p_vbi, "vbi-page", i_page ); + /* FIXME Gni, why that ? */ + i_ret = var_SetInteger( p_vbi, "vbi-page", + var_GetInteger( p_vbi, "vbi-page" ) ); if( i_ret ) libvlc_exception_raise( p_e, "Unexpected error while setting teletext page" ); } - else if( i_teletext_es >= 0 ) + else { - bool opaque = true; - - opaque = var_GetBool( p_vbi, "vbi-opaque" ); - i_ret = var_SetBool( p_vbi, "vbi-opaque", !opaque ); + /* FIXME Gni^2 */ + i_ret = var_SetBool( p_vbi, "vbi-opaque", + !var_GetBool( p_vbi, "vbi-opaque" ) ); if( i_ret ) libvlc_exception_raise( p_e, "Unexpected error while setting teletext transparency" ); } vlc_object_release( p_vbi ); } + else if( b_selected ) + { + var_SetInteger( p_input_thread, "spu-es", -1 ); + } else { - /* Teletext is not enabled yet, so enable it. - * Only after it is enable it is possible to view teletext pages - */ - const int i_teletext_es = var_GetInteger( p_input_thread, "teletext-es" ); - - if( i_teletext_es >= 0 ) + vlc_value_t list; + if( !var_Change( p_input_thread, "teletext-es", VLC_VAR_GETLIST, &list, NULL ) ) { - const int i_spu_es = var_GetInteger( p_input_thread, "spu-es" ); + if( list.p_list->i_count > 0 ) + var_SetInteger( p_input_thread, "spu-es", list.p_list->p_values[0].i_int ); - if( i_teletext_es == i_spu_es ) - var_SetInteger( p_input_thread, "spu-es", -1 ); - else - var_SetInteger( p_input_thread, "spu-es", i_teletext_es ); + var_Change( p_input_thread, "teletext-es", VLC_VAR_FREELIST, &list, NULL ); } } vlc_object_release( p_input_thread ); @@ -694,14 +553,3 @@ void libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track, libvlc_exception_raise( p_e, "Video track out of range" ); vlc_object_release( p_input_thread ); } - -int libvlc_video_destroy( libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) -{ - vout_thread_t *p_vout = GetVout( p_mi, p_e ); - vlc_object_detach( p_vout ); - vlc_object_release( p_vout ); - vlc_object_release( p_vout ); - - return 0; -}