X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Finput%2Fcontrol.c;h=2e4633ff689f575e6ef90e7e29274f79b1e4a6a4;hb=ea86f2792a3ede61b5794c9e70233e135c82b62b;hp=450905b90bd2f445b3180c493cc037196740c7aa;hpb=55c960749e8f91763e720ac610d5dd56f90fcde1;p=vlc diff --git a/src/input/control.c b/src/input/control.c index 450905b90b..2e4633ff68 100644 --- a/src/input/control.c +++ b/src/input/control.c @@ -1,24 +1,24 @@ /***************************************************************************** * control.c ***************************************************************************** - * Copyright (C) 1999-2004 the VideoLAN team + * Copyright (C) 1999-2004 VLC authors and VideoLAN * $Id$ * * 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 + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifdef HAVE_CONFIG_H @@ -29,10 +29,12 @@ #include #include +#include #include "input_internal.h" #include "event.h" #include "resource.h" +#include "es_out.h" static void UpdateBookmarksOption( input_thread_t * ); @@ -99,12 +101,13 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) case INPUT_GET_RATE: pi_int = (int*)va_arg( args, int * ); - *pi_int = var_GetInteger( p_input, "rate" ); + *pi_int = INPUT_RATE_DEFAULT / var_GetFloat( p_input, "rate" ); return VLC_SUCCESS; case INPUT_SET_RATE: i_int = (int)va_arg( args, int ); - return var_SetInteger( p_input, "rate", i_int ); + return var_SetFloat( p_input, "rate", + (float)INPUT_RATE_DEFAULT / (float)i_int ); case INPUT_GET_STATE: pi_int = (int*)va_arg( args, int * ); @@ -133,6 +136,15 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) i_64 = (int64_t)va_arg( args, int64_t ); return var_SetTime( p_input, "spu-delay", i_64 ); + case INPUT_NAV_ACTIVATE: + case INPUT_NAV_UP: + case INPUT_NAV_DOWN: + case INPUT_NAV_LEFT: + case INPUT_NAV_RIGHT: + input_ControlPush( p_input, i_query - INPUT_NAV_ACTIVATE + + INPUT_CONTROL_NAV_ACTIVATE, NULL ); + return VLC_SUCCESS; + case INPUT_ADD_INFO: { char *psz_cat = (char *)va_arg( args, char * ); @@ -152,6 +164,20 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) input_SendEventMetaInfo( p_input ); return i_ret; } + case INPUT_REPLACE_INFOS: + case INPUT_MERGE_INFOS: + { + info_category_t *p_cat = va_arg( args, info_category_t * ); + + if( i_query == INPUT_REPLACE_INFOS ) + input_item_ReplaceInfos( p_input->p->p_item, p_cat ); + else + input_item_MergeInfos( p_input->p->p_item, p_cat ); + + if( !p_input->b_preparsing ) + input_SendEventMetaInfo( p_input ); + return VLC_SUCCESS; + } case INPUT_DEL_INFO: { char *psz_cat = (char *)va_arg( args, char * ); @@ -308,20 +334,28 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) vlc_mutex_unlock( &p_input->p->p_item->lock ); return VLC_SUCCESS; - case INPUT_ADD_OPTION: + case INPUT_GET_TITLE_INFO: { - const char *psz_option = va_arg( args, const char * ); - const char *psz_value = va_arg( args, const char * ); - char *str; - int i; + input_title_t **p_title = (input_title_t **)va_arg( args, input_title_t ** ); + int *pi_req_title_offset = (int *) va_arg( args, int * ); - if( asprintf( &str, "%s=%s", psz_option, psz_value ) == -1 ) - return VLC_ENOMEM; + vlc_mutex_lock( &p_input->p->p_item->lock ); + + int i_current_title = var_GetInteger( p_input, "title" ); + if ( *pi_req_title_offset < 0 ) /* return current title if -1 */ + *pi_req_title_offset = i_current_title; - i = input_item_AddOption( p_input->p->p_item, str, - VLC_INPUT_OPTION_UNIQUE ); - free( str ); - return i; + if( p_input->p->i_title && p_input->p->i_title > *pi_req_title_offset ) + { + *p_title = vlc_input_title_Duplicate( p_input->p->title[*pi_req_title_offset] ); + vlc_mutex_unlock( &p_input->p->p_item->lock ); + return VLC_SUCCESS; + } + else + { + vlc_mutex_unlock( &p_input->p->p_item->lock ); + return VLC_EGENERIC; + } } case INPUT_GET_VIDEO_FPS: @@ -369,7 +403,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) return VLC_EGENERIC; } *pi_attachment = p_input->p->i_attachment; - *ppp_attachment = malloc( sizeof(input_attachment_t**) * p_input->p->i_attachment ); + *ppp_attachment = malloc( sizeof(input_attachment_t*) * p_input->p->i_attachment ); for( i = 0; i < p_input->p->i_attachment; i++ ) (*ppp_attachment)[i] = vlc_input_attachment_Duplicate( p_input->p->attachment[i] ); @@ -415,11 +449,11 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) case INPUT_GET_AOUT: { - aout_instance_t *p_aout = input_resource_HoldAout( p_input->p->p_resource ); + audio_output_t *p_aout = input_resource_HoldAout( p_input->p->p_resource ); if( !p_aout ) return VLC_EGENERIC; - aout_instance_t **pp_aout = (aout_instance_t**)va_arg( args, aout_instance_t** ); + audio_output_t **pp_aout = (audio_output_t**)va_arg( args, audio_output_t** ); *pp_aout = p_aout; return VLC_SUCCESS; } @@ -427,7 +461,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) case INPUT_GET_VOUTS: { vout_thread_t ***ppp_vout = (vout_thread_t***)va_arg( args, vout_thread_t*** ); - int *pi_vout = (int*)va_arg( args, int* ); + size_t *pi_vout = va_arg( args, size_t * ); input_resource_HoldVouts( p_input->p->p_resource, ppp_vout, pi_vout ); if( *pi_vout <= 0 ) @@ -435,6 +469,31 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) return VLC_SUCCESS; } + case INPUT_GET_ES_OBJECTS: + { + const int i_id = va_arg( args, int ); + vlc_object_t **pp_decoder = va_arg( args, vlc_object_t ** ); + vout_thread_t **pp_vout = va_arg( args, vout_thread_t ** ); + audio_output_t **pp_aout = va_arg( args, audio_output_t ** ); + + return es_out_Control( p_input->p->p_es_out_display, ES_OUT_GET_ES_OBJECTS_BY_ID, i_id, + pp_decoder, pp_vout, pp_aout ); + } + + case INPUT_GET_PCR_SYSTEM: + { + mtime_t *pi_system = va_arg( args, mtime_t * ); + mtime_t *pi_delay = va_arg( args, mtime_t * ); + return es_out_ControlGetPcrSystem( p_input->p->p_es_out_display, pi_system, pi_delay ); + } + + case INPUT_MODIFY_PCR_SYSTEM: + { + bool b_absolute = va_arg( args, int ); + mtime_t i_system = va_arg( args, mtime_t ); + return es_out_ControlModifyPcrSystem( p_input->p->p_es_out_display, b_absolute, i_system ); + } + default: msg_Err( p_input, "unknown query in input_vaControl" ); return VLC_EGENERIC; @@ -471,28 +530,34 @@ static void UpdateBookmarksOption( input_thread_t *p_input ) } char *psz_value = malloc( i_len + p_input->p->i_bookmark + 1 ); - char *psz_next = psz_value; - psz_next += sprintf( psz_next, "bookmarks=" ); - for( int i = 0; i < p_input->p->i_bookmark && psz_value != NULL; i++ ) + if( psz_value != NULL ) { - const seekpoint_t *p_bookmark = p_input->p->pp_bookmark[i]; + strcpy( psz_value, "bookmarks=" ); - psz_next += sprintf( psz_next, psz_format, - p_bookmark->psz_name, - p_bookmark->i_byte_offset, - p_bookmark->i_time_offset/1000000 ); + char *psz_next = psz_value + strlen( "bookmarks=" ); - if( i < p_input->p->i_bookmark - 1) - *psz_next++ = ','; - } - vlc_mutex_unlock( &p_input->p->p_item->lock ); + for( int i = 0; i < p_input->p->i_bookmark && psz_value != NULL; i++ ) + { + const seekpoint_t *p_bookmark = p_input->p->pp_bookmark[i]; - if( psz_value ) - input_item_AddOption( p_input->p->p_item, psz_value, VLC_INPUT_OPTION_UNIQUE ); + psz_next += sprintf( psz_next, psz_format, + p_bookmark->psz_name, + p_bookmark->i_byte_offset, + p_bookmark->i_time_offset/1000000 ); - free( psz_value ); + if( i < p_input->p->i_bookmark - 1) + *psz_next++ = ','; + } + } + vlc_mutex_unlock( &p_input->p->p_item->lock ); + if( psz_value != NULL ) + { + input_item_AddOption( p_input->p->p_item, psz_value, + VLC_INPUT_OPTION_UNIQUE ); + free( psz_value ); + } input_SendEventBookmark( p_input ); }