From 36b86f5b99933b478403e8231325e2392178a1f5 Mon Sep 17 00:00:00 2001 From: Gildas Bazin Date: Tue, 23 Mar 2004 23:44:49 +0000 Subject: [PATCH] * src/input/*: + new input_Control() function (doesn't do much for now). + started bookmarks support through input_Control(). + new --bookmarks={name=foo,bytes=foo,time=foo},{...} config option. * src/video_output/*: + started support for embeddable vouts (vout_RequestWindow()/vout_ReleaseWindow()) + new --video-x/y config options --- Makefile.am | 2 + include/input_ext-intf.h | 4 + include/ninput.h | 66 +++++++++- include/video_output.h | 5 +- include/vlc_common.h | 1 + include/vlc_interface.h | 6 + src/input/control.c | 205 ++++++++++++++++++++++++++++++++ src/input/input.c | 71 ++++++++++- src/interface/interface.c | 16 +-- src/libvlc.h | 19 +++ src/video_output/video_output.c | 4 +- src/video_output/vout_intf.c | 102 ++++++++++++++++ 12 files changed, 482 insertions(+), 19 deletions(-) create mode 100644 src/input/control.c create mode 100644 src/video_output/vout_intf.c diff --git a/Makefile.am b/Makefile.am index 7142bb17b4..3c053b4df2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -323,6 +323,7 @@ SOURCES_libvlc_common = \ src/playlist/item-ext.c \ src/playlist/info.c \ src/input/input.c \ + src/input/control.c \ src/input/es_out.c \ src/input/stream.c \ src/input/demux.c \ @@ -339,6 +340,7 @@ SOURCES_libvlc_common = \ src/video_output/video_text.c \ src/video_output/vout_subpictures.c \ src/video_output/vout_synchro.c \ + src/video_output/vout_intf.c \ src/audio_output/common.c \ src/audio_output/dec.c \ src/audio_output/filters.c \ diff --git a/include/input_ext-intf.h b/include/input_ext-intf.h index 95bca3c996..09b32b2bbc 100644 --- a/include/input_ext-intf.h +++ b/include/input_ext-intf.h @@ -344,6 +344,10 @@ struct input_thread_t count_t c_loops; + /* User bookmarks */ + int i_bookmarks; + seekpoint_t **pp_bookmarks; + /* private, do not touch it */ input_thread_sys_t *p_sys; }; diff --git a/include/ninput.h b/include/ninput.h index c4a30b90f6..71a521ed49 100644 --- a/include/ninput.h +++ b/include/ninput.h @@ -2,7 +2,7 @@ * ninput.h ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: ninput.h,v 1.29 2004/03/03 12:01:17 fenrir Exp $ + * $Id$ * * Authors: Laurent Aimar * @@ -283,7 +283,36 @@ enum demux_query_e DEMUX_GET_META /* arg1= vlc_meta_t ** res=can fail */ }; +struct seekpoint_t +{ + int64_t i_byte_offset; + int64_t i_time_offset; + char *psz_name; +}; + +static inline seekpoint_t *vlc_seekpoint_New( void ) +{ + seekpoint_t *point = (seekpoint_t*)malloc( sizeof( seekpoint_t ) ); + point->i_byte_offset = point->i_time_offset; + point->psz_name = NULL; + return point; +} + +static inline void vlc_seekpoint_Delete( seekpoint_t *point ) +{ + if( !point ) return; + if( point->psz_name ) free( point->psz_name ); + free( point ); +} +static inline seekpoint_t *vlc_seekpoint_Duplicate( seekpoint_t *src ) +{ + seekpoint_t *point = vlc_seekpoint_New(); + if( src->psz_name ) point->psz_name = strdup( src->psz_name ); + point->i_time_offset = src->i_time_offset; + point->i_byte_offset = src->i_byte_offset; + return point; +} /* Demux */ VLC_EXPORT( int, demux_vaControl, ( input_thread_t *, int i_query, va_list ) ); @@ -318,10 +347,43 @@ static inline int demux2_Control( demux_t *p_demux, int i_query, ... ) return i_result; } - /* Subtitles */ VLC_EXPORT( char **, subtitles_Detect, ( input_thread_t *, char* path, char *fname ) ); +/** + * @} + */ + + +/** + * \defgroup input Input + * @{ + */ +enum input_query_e +{ + INPUT_GET_POSITION, /* arg1= double * res= */ + INPUT_SET_POSITION, /* arg1= double res=can fail */ + + INPUT_GET_TIME, /* arg1= int64_t * res= */ + INPUT_SET_TIME, /* arg1= int64_t res=can fail */ + + INPUT_GET_LENGTH, /* arg1= int64_t * res=can fail */ + + INPUT_GET_FPS, /* arg1= float * res=can fail */ + INPUT_GET_META, /* arg1= vlc_meta_t ** res=can fail */ + + INPUT_GET_BOOKMARKS, /* arg1= seekpoint_t *** arg2= int * res=can fail */ + INPUT_CLEAR_BOOKMARKS, /* res=can fail */ + INPUT_ADD_BOOKMARK, /* arg1= seekpoint_t * res=can fail */ + INPUT_DEL_BOOKMARK, /* arg1= seekpoint_t * res=can fail */ + INPUT_SET_BOOKMARK, /* arg1= int res=can fail */ + + INPUT_GET_DIVISIONS +}; + +VLC_EXPORT( int, input_vaControl,( input_thread_t *, int i_query, va_list ) ); +VLC_EXPORT( int, input_Control, ( input_thread_t *, int i_query, ... ) ); + /** * @} */ diff --git a/include/video_output.h b/include/video_output.h index 981792de21..a0972e24ea 100644 --- a/include/video_output.h +++ b/include/video_output.h @@ -2,7 +2,7 @@ * video_output.h : video output thread ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: video_output.h,v 1.108 2004/02/22 00:15:33 gbazin Exp $ + * $Id$ * * Authors: Vincent Seguin * Samuel Hocevar @@ -215,6 +215,9 @@ VLC_EXPORT( void, vout_UnlinkPicture, ( vout_thread_t *, picture_t * VLC_EXPORT( void, vout_PlacePicture, ( vout_thread_t *, unsigned int, unsigned int, unsigned int *, unsigned int *, unsigned int *, unsigned int * ) ); picture_t * vout_RenderPicture ( vout_thread_t *, picture_t *, subpicture_t * ); +VLC_EXPORT( void *, vout_RequestWindow, ( vout_thread_t *, int *, int *, unsigned int *, unsigned int * ) ); +VLC_EXPORT( void, vout_ReleaseWindow, ( vout_thread_t *, void * ) ); + /** * \addtogroup subpicture * @{ diff --git a/include/vlc_common.h b/include/vlc_common.h index 4d3f2f9bf4..3ef809f2c2 100644 --- a/include/vlc_common.h +++ b/include/vlc_common.h @@ -224,6 +224,7 @@ typedef struct es_sys_t es_sys_t; typedef struct pgrm_descriptor_t pgrm_descriptor_t; typedef struct pgrm_sys_t pgrm_sys_t; typedef struct stream_descriptor_t stream_descriptor_t; +typedef struct seekpoint_t seekpoint_t; /* Format */ typedef struct audio_format_t audio_format_t; diff --git a/include/vlc_interface.h b/include/vlc_interface.h index fa1c5019a3..25182af21f 100644 --- a/include/vlc_interface.h +++ b/include/vlc_interface.h @@ -63,6 +63,11 @@ struct intf_thread_t void ( *pf_show_dialog ) ( intf_thread_t *, int, int, intf_dialog_args_t * ); + /** Video window callbacks */ + void * ( *pf_request_window ) ( intf_thread_t *, int *, int *, + unsigned int *, unsigned int * ); + void ( *pf_release_window ) ( intf_thread_t *, void * ); + /* XXX: new message passing stuff will go here */ vlc_mutex_t change_lock; vlc_bool_t b_menu_change; @@ -142,6 +147,7 @@ VLC_EXPORT( void, intf_Destroy, ( intf_thread_t * ) ); #define INTF_DIALOG_MESSAGES 11 #define INTF_DIALOG_FILEINFO 12 #define INTF_DIALOG_PREFS 13 +#define INTF_DIALOG_BOOKMARKS 14 #define INTF_DIALOG_POPUPMENU 20 diff --git a/src/input/control.c b/src/input/control.c new file mode 100644 index 0000000000..3cb0551db4 --- /dev/null +++ b/src/input/control.c @@ -0,0 +1,205 @@ +/***************************************************************************** + * control.c + ***************************************************************************** + * Copyright (C) 1999-2004 VideoLAN + * $Id: stream.c 7041 2004-03-11 16:48:27Z gbazin $ + * + * Authors: Gildas Bazin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include +#include +#include + +#include "ninput.h" + +/**************************************************************************** + * input_Control + ****************************************************************************/ +/** + * Control function for inputs. + * \param p_input input handle + * \param i_query query type + * \return VLC_SUCESS if ok + */ +int input_Control( input_thread_t *p_input, int i_query, ... ) +{ + va_list args; + int i_result; + + va_start( args, i_query ); + i_result = input_vaControl( p_input, i_query, args ); + va_end( args ); + + return i_result; +} + +int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) +{ + int i_ret; + seekpoint_t *p_bkmk, ***ppp_bkmk; + int i_bkmk, *pi_bkmk; + vlc_value_t val, text; + + vlc_mutex_lock( &p_input->stream.stream_lock ); + switch( i_query ) + { + case INPUT_ADD_BOOKMARK: + p_bkmk = (seekpoint_t *)va_arg( args, seekpoint_t * ); + p_bkmk = vlc_seekpoint_Duplicate( p_bkmk ); + if( !p_bkmk->psz_name ) + { + asprintf( &p_bkmk->psz_name, _("Bookmark %i"), + p_input->i_bookmarks ); + } + TAB_APPEND( p_input->i_bookmarks, p_input->pp_bookmarks, p_bkmk ); + + /* Reflect the changes on the object var */ + var_Change( p_input, "bookmark", VLC_VAR_CLEARCHOICES, 0, 0 ); + { + int i; + for( i = 0; i < p_input->i_bookmarks; i++ ) + { + val.i_int = i; + text.psz_string = p_input->pp_bookmarks[i]->psz_name; + var_Change( p_input, "bookmark", VLC_VAR_ADDCHOICE, + &val, &text ); + } + } + + i_ret = VLC_SUCCESS; + break; + + case INPUT_DEL_BOOKMARK: + p_bkmk = (seekpoint_t *)va_arg( args, seekpoint_t * ); + if( p_input->i_bookmarks ) + { + int i; + for( i = 0; i < p_input->i_bookmarks; i++ ) + { + if( ( p_bkmk->i_byte_offset && + p_input->pp_bookmarks[i]->i_byte_offset == + p_bkmk->i_byte_offset ) || + ( p_bkmk->i_time_offset && + p_input->pp_bookmarks[i]->i_time_offset == + p_bkmk->i_time_offset ) || + ( !p_bkmk->i_byte_offset && !p_bkmk->i_time_offset && + p_input->pp_bookmarks[i]->i_byte_offset == + p_bkmk->i_byte_offset ) ) + { + p_bkmk = p_input->pp_bookmarks[i]; + break; + } + } + if( i < p_input->i_bookmarks ) + { + TAB_REMOVE( p_input->i_bookmarks, p_input->pp_bookmarks, + p_bkmk ); + vlc_seekpoint_Delete( p_bkmk ); + + /* Reflect the changes on the object var */ + var_Change( p_input, "bookmark", VLC_VAR_CLEARCHOICES, + 0, 0 ); + for( i = 0; i < p_input->i_bookmarks; i++ ) + { + val.i_int = i; + text.psz_string = p_input->pp_bookmarks[i]->psz_name; + var_Change( p_input, "bookmark", VLC_VAR_ADDCHOICE, + &val, &text ); + } + } + } + i_ret = VLC_SUCCESS; + break; + + case INPUT_GET_BOOKMARKS: + ppp_bkmk = (seekpoint_t ***)va_arg( args, seekpoint_t *** ); + pi_bkmk = (int *)va_arg( args, int * ); + if( p_input->i_bookmarks ) + { + int i; + + *pi_bkmk = p_input->i_bookmarks; + *ppp_bkmk = malloc( sizeof(seekpoint_t *) * + p_input->i_bookmarks ); + for( i = 0; i < p_input->i_bookmarks; i++ ) + { + (*ppp_bkmk)[i] = + vlc_seekpoint_Duplicate(p_input->pp_bookmarks[i]); + } + i_ret = VLC_SUCCESS; + } + else + { + *ppp_bkmk = NULL; + *pi_bkmk = 0; + i_ret = VLC_EGENERIC; + } + break; + + case INPUT_CLEAR_BOOKMARKS: + if( p_input->i_bookmarks ) + { + int i; + + for( i = p_input->i_bookmarks - 1; i >= 0; i-- ) + { + p_bkmk = p_input->pp_bookmarks[i]; + TAB_REMOVE( p_input->i_bookmarks, p_input->pp_bookmarks, + p_bkmk ); + vlc_seekpoint_Delete( p_bkmk ); + } + } + i_ret = VLC_SUCCESS; + break; + + case INPUT_SET_BOOKMARK: + i_bkmk = (int)va_arg( args, int ); + if( i_bkmk >= 0 && i_bkmk < p_input->i_bookmarks ) + { + vlc_value_t pos; + vlc_mutex_unlock( &p_input->stream.stream_lock ); + if( p_input->pp_bookmarks[i_bkmk]->i_byte_offset || + ( !p_input->pp_bookmarks[i_bkmk]->i_byte_offset && + !p_input->pp_bookmarks[i_bkmk]->i_time_offset ) ) + { + pos.f_float = p_input->pp_bookmarks[i_bkmk]->i_byte_offset/ + (double)p_input->stream.p_selected_area->i_size; + i_ret = var_Set( p_input, "position", pos ); + } + else if( p_input->pp_bookmarks[i_bkmk]->i_time_offset ) + { + pos.i_time = p_input->pp_bookmarks[i_bkmk]->i_time_offset; + i_ret = var_Set( p_input, "time", pos ); + } + vlc_mutex_lock( &p_input->stream.stream_lock ); + } + else + { + i_ret = VLC_EGENERIC; + } + break; + + default: + msg_Err( p_input, "unknown query in input_vaControl" ); + i_ret = VLC_EGENERIC; + break; + } + vlc_mutex_unlock( &p_input->stream.stream_lock ); + + return i_ret; +} diff --git a/src/input/input.c b/src/input/input.c index 61154947f5..185d6dac4a 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -77,6 +77,8 @@ static int StateCallback ( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ); static int RateCallback ( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ); +static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd, + vlc_value_t oldval, vlc_value_t newval, void *p_data ); /***************************************************************************** * input_CreateThread: creates a new input thread @@ -130,7 +132,7 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, char *psz_uri, var_Create( p_input, "stop-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); /* decoders */ - var_Create( p_input, "minimize-threads", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); + var_Create( p_input, "minimize-threads", VLC_VAR_BOOL|VLC_VAR_DOINHERIT ); /* play status */ @@ -194,7 +196,7 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, char *psz_uri, p_input->p_demux = NULL; p_input->pf_demux = NULL; p_input->pf_rewind = NULL; - p_input->pf_demux_control = NULL; + p_input->pf_demux_control = demux_vaControlDefault; p_input->i_cr_average = config_GetInt( p_input, "cr-average" ); /* Access */ @@ -249,6 +251,64 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, char *psz_uri, msg_Info( p_input, "playlist item `%s'", p_input->psz_source ); + /* Bookmarks */ + var_Create( p_input, "bookmarks", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); + var_Create( p_input, "bookmark", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE | + VLC_VAR_ISCOMMAND ); + val.psz_string = _("Bookmark"); + var_Change( p_input, "bookmark", VLC_VAR_SETTEXT, &val, NULL ); + var_AddCallback( p_input, "bookmark", BookmarkCallback, NULL ); + + p_input->i_bookmarks = 0; + p_input->pp_bookmarks = NULL; + + var_Get( p_input, "bookmarks", &val ); + if( val.psz_string ) + { + /* FIXME: have a common cfg parsing routine used by sout and others */ + char *psz_parser, *psz_start, *psz_end; + psz_parser = val.psz_string; + while( (psz_start = strchr( psz_parser, '{' ) ) ) + { + seekpoint_t seekpoint; + char backup; + psz_start++; + psz_end = strchr( psz_start, '}' ); + if( !psz_end ) break; + psz_parser = psz_end + 1; + backup = *psz_parser; + *psz_parser = 0; + *psz_end = ','; + + seekpoint.psz_name = 0; + seekpoint.i_byte_offset = 0; + seekpoint.i_time_offset = 0; + while( (psz_end = strchr( psz_start, ',' ) ) ) + { + *psz_end = 0; + if( !strncmp( psz_start, "name=", 5 ) ) + { + seekpoint.psz_name = psz_start + 5; + } + else if( !strncmp( psz_start, "bytes=", 6 ) ) + { + seekpoint.i_byte_offset = atol(psz_start + 6); + } + else if( !strncmp( psz_start, "time=", 5 ) ) + { + seekpoint.i_time_offset = atol(psz_start + 5) * 1000000; + } + psz_start = psz_end + 1; + } + msg_Dbg( p_input, "adding bookmark: %s, bytes="I64Fd", time="I64Fd, + seekpoint.psz_name, seekpoint.i_byte_offset, + seekpoint.i_time_offset ); + input_Control( p_input, INPUT_ADD_BOOKMARK, &seekpoint ); + *psz_parser = backup; + } + free( val.psz_string ); + } + /* Initialize input info */ p_input->stream.p_info = NULL; p_input->stream.p_info = input_InfoCategory( p_input, _("General") ); @@ -1420,3 +1480,10 @@ static int RateCallback( vlc_object_t *p_this, char const *psz_cmd, } return VLC_SUCCESS; } + +static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd, + vlc_value_t oldval, vlc_value_t newval, void *p_data ) +{ + input_thread_t *p_input = (input_thread_t *)p_this; + return input_Control( p_input, INPUT_SET_BOOKMARK, newval ); +} diff --git a/src/interface/interface.c b/src/interface/interface.c index 1344a4c1c6..e42f1a86a9 100644 --- a/src/interface/interface.c +++ b/src/interface/interface.c @@ -4,7 +4,7 @@ * interface, such as command line. ***************************************************************************** * Copyright (C) 1998-2004 VideoLAN - * $Id: interface.c,v 1.114 2004/03/03 20:39:53 gbazin Exp $ + * $Id$ * * Authors: Vincent Seguin * @@ -84,18 +84,8 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module ) msg_Err( p_this, "out of memory" ); return NULL; } - - /* XXX: workaround for a bug in VLC 0.5.0 where the dvdplay plugin was - * registering itself in $interface, which we do not want to happen. */ - psz_intf = config_GetPsz( p_intf, "intf" ); - if( psz_intf ) - { - if( !strcasecmp( psz_intf, "dvdplay" ) ) - { - config_PutPsz( p_intf, "intf", "" ); - } - free( psz_intf ); - } + p_intf->pf_request_window = NULL; + p_intf->pf_release_window = NULL; /* Choose the best module */ p_intf->p_module = module_Need( p_intf, "interface", psz_module, 0 ); diff --git a/src/libvlc.h b/src/libvlc.h index 8f14331b46..225004a67d 100644 --- a/src/libvlc.h +++ b/src/libvlc.h @@ -195,6 +195,16 @@ static char *ppsz_language_text[] = "You can enforce the video height here. By default (-1) VLC will " \ "adapt to the video characteristics.") +#define VIDEOX_TEXT N_("Video x coordinate") +#define VIDEOX_LONGTEXT N_( \ + "You can enforce the position of the top left corner of the video window "\ + "here (x coordinate).") + +#define VIDEOY_TEXT N_("Video y coordinate") +#define VIDEOY_LONGTEXT N_( \ + "You can enforce the position of the top left corner of the video window "\ + "here (y coordinate).") + #define ALIGN_TEXT N_("Video alignment") #define ALIGN_LONGTEXT N_( \ "You can enforce the video alignement in its window. By default (0) it " \ @@ -311,6 +321,11 @@ static char *ppsz_align_descriptions[] = #define STOP_TIME_TEXT N_("Input stop time (second)") #define STOP_TIME_LONGTEXT N_("Input stop time (second)") +#define BOOKMARKS_TEXT N_("Bookmarks list for a stream") +#define BOOKMARKS_LONGTEXT N_("You can specify a list of bookmarks for a stream in " \ + "the form \"{name=bookmark-name,time=optional-time-offset," \ + "bytes=optional-byte-offset},{etc...}\"") + #define SUB_AUTO_TEXT N_("Autodetect subtitle files") #define SUB_AUTO_LONGTEXT \ N_("Automatically detect a subtitle file, if no subtitle filename is " \ @@ -757,6 +772,8 @@ vlc_module_begin(); add_bool( "video", 1, NULL, VIDEO_TEXT, VIDEO_LONGTEXT, VLC_TRUE ); add_integer( "width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE ); add_integer( "height", -1, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, VLC_TRUE ); + add_integer( "video-x", -1, NULL, VIDEOX_TEXT, VIDEOX_LONGTEXT, VLC_TRUE ); + add_integer( "video-y", -1, NULL, VIDEOY_TEXT, VIDEOY_LONGTEXT, VLC_TRUE ); add_integer( "align", 0, NULL, ALIGN_TEXT, ALIGN_LONGTEXT, VLC_TRUE ); change_integer_list( pi_align_values, ppsz_align_descriptions, 0 ); add_float( "zoom", 1, NULL, ZOOM_TEXT, ZOOM_LONGTEXT, VLC_TRUE ); @@ -808,6 +825,8 @@ vlc_module_begin(); START_TIME_TEXT, START_TIME_LONGTEXT, VLC_TRUE ); add_integer( "stop-time", 0, NULL, STOP_TIME_TEXT, STOP_TIME_LONGTEXT, VLC_TRUE ); + add_string( "bookmarks", NULL, NULL, + BOOKMARKS_TEXT, BOOKMARKS_LONGTEXT, VLC_TRUE ); add_file( "dvd", DVD_DEVICE, NULL, DVD_DEV_TEXT, DVD_DEV_LONGTEXT, VLC_FALSE ); diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index 13847492eb..d7b4fc3d5d 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -5,7 +5,7 @@ * thread, and destroy a previously oppened video output thread. ***************************************************************************** * Copyright (C) 2000-2004 VideoLAN - * $Id: video_output.c,v 1.246 2004/03/03 20:39:53 gbazin Exp $ + * $Id$ * * Authors: Vincent Seguin * @@ -316,6 +316,8 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "zoom", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); var_Create( p_vout, "align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); + var_Create( p_vout, "video-x", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); + var_Create( p_vout, "video-y", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); p_vout->b_override_aspect = VLC_FALSE; diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c new file mode 100644 index 0000000000..73f4ff93cb --- /dev/null +++ b/src/video_output/vout_intf.c @@ -0,0 +1,102 @@ +/***************************************************************************** + * vout_intf.c : video output interface + ***************************************************************************** + * Copyright (C) 2000-2004 VideoLAN + * $Id: video_output.c 6961 2004-03-05 17:34:23Z sam $ + * + * Authors: Gildas Bazin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +/***************************************************************************** + * Preamble + *****************************************************************************/ +#include /* free() */ + +#include + +#include "vlc_video.h" +#include "video_output.h" +#include "vlc_interface.h" + +/***************************************************************************** + * Local prototypes + *****************************************************************************/ + +/***************************************************************************** + * vout_RequestWindow: Create/Get a video window if possible. + ***************************************************************************** + * This function looks for the main interface and tries to request + * a new video window. If it fails then the vout will still need to create the + * window by itself. + *****************************************************************************/ +void *vout_RequestWindow( vout_thread_t *p_vout, + int *pi_x_hint, int *pi_y_hint, + unsigned int *pi_width_hint, + unsigned int *pi_height_hint ) +{ + intf_thread_t *p_intf; + void *p_window; + vlc_value_t val; + + /* Get requested coordinates */ + var_Get( p_vout, "video-x", &val ); + *pi_x_hint = val.i_int ; + var_Get( p_vout, "video-y", &val ); + *pi_y_hint = val.i_int; + + *pi_width_hint = p_vout->i_window_width; + *pi_height_hint = p_vout->i_window_height; + + /* Check whether someone provided us with a window ID */ + var_Get( p_vout->p_vlc, "drawable", &val ); + if( val.i_int ) return (void *)val.i_int; + + /* Find the main interface */ + p_intf = vlc_object_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE ); + if( !p_intf ) return NULL; + + if( !p_intf->pf_request_window ) + { + vlc_object_release( p_intf ); + return NULL; + } + + p_window = p_intf->pf_request_window( p_intf, pi_x_hint, pi_y_hint, + pi_width_hint, pi_height_hint ); + vlc_object_release( p_intf ); + + return p_window; +} + +void vout_ReleaseWindow( vout_thread_t *p_vout, void *p_window ) +{ + intf_thread_t *p_intf; + + /* Find the main interface */ + p_intf = vlc_object_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE ); + if( !p_intf ) return; + + if( !p_intf->pf_release_window ) + { + msg_Err( p_vout, "no pf_release_window"); + vlc_object_release( p_intf ); + return; + } + + p_intf->pf_release_window( p_intf, p_window ); + vlc_object_release( p_intf ); +} -- 2.39.2