⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 control.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** * control.c ***************************************************************************** * Copyright (C) 1999-2004 the VideoLAN team * $Id: 123c9f908faa8c8f1a7d0ab4cc927757c6c9cb3d $ * * Authors: Gildas Bazin <gbazin@videolan.org> * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/#ifdef HAVE_CONFIG_H# include "config.h"#endif#include <vlc_common.h>#include <stdio.h>#include <stdlib.h>#include "input_internal.h"static void UpdateBookmarksOption( input_thread_t * );/**************************************************************************** * input_Control ****************************************************************************//** * Control function for inputs. * \param p_input input handle * \param i_query query type * \return VLC_SUCCESS 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 ){    seekpoint_t *p_bkmk, ***ppp_bkmk;    int i_bkmk = 0;    int *pi_bkmk;    int i_int, *pi_int;    double f, *pf;    int64_t i_64, *pi_64;    char *psz;    vlc_value_t val;    switch( i_query )    {        case INPUT_GET_POSITION:            pf = (double*)va_arg( args, double * );            *pf = var_GetFloat( p_input, "position" );            return VLC_SUCCESS;        case INPUT_SET_POSITION:            f = (double)va_arg( args, double );            return var_SetFloat( p_input, "position", f );        case INPUT_GET_LENGTH:            pi_64 = (int64_t*)va_arg( args, int64_t * );            *pi_64 = var_GetTime( p_input, "length" );            return VLC_SUCCESS;        case INPUT_GET_TIME:            pi_64 = (int64_t*)va_arg( args, int64_t * );            *pi_64 = var_GetTime( p_input, "time" );            return VLC_SUCCESS;        case INPUT_SET_TIME:            i_64 = (int64_t)va_arg( args, int64_t );            return var_SetTime( p_input, "time", i_64 );        case INPUT_GET_RATE:            pi_int = (int*)va_arg( args, int * );            *pi_int = var_GetInteger( 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 );        case INPUT_GET_STATE:            pi_int = (int*)va_arg( args, int * );            *pi_int = var_GetInteger( p_input, "state" );            return VLC_SUCCESS;        case INPUT_SET_STATE:            i_int = (int)va_arg( args, int );            return var_SetInteger( p_input, "state", i_int );        case INPUT_GET_AUDIO_DELAY:            pi_64 = (int64_t*)va_arg( args, int64_t * );            *pi_64 = var_GetTime( p_input, "audio-delay" );            return VLC_SUCCESS;        case INPUT_GET_SPU_DELAY:            pi_64 = (int64_t*)va_arg( args, int64_t * );            *pi_64 = var_GetTime( p_input, "spu-delay" );            return VLC_SUCCESS;        case INPUT_SET_AUDIO_DELAY:            i_64 = (int64_t)va_arg( args, int64_t );            return var_SetTime( p_input, "audio-delay", i_64 );        case INPUT_SET_SPU_DELAY:            i_64 = (int64_t)va_arg( args, int64_t );            return var_SetTime( p_input, "spu-delay", i_64 );        case INPUT_ADD_INFO:        {            /* FIXME : Impossible to use input_item_AddInfo because of             * the ... problem ? */            char *psz_cat = (char *)va_arg( args, char * );            char *psz_name = (char *)va_arg( args, char * );            char *psz_format = (char *)va_arg( args, char * );            info_category_t *p_cat;            info_t *p_info;            int i;            vlc_mutex_lock( &p_input->p->input.p_item->lock );            for( i = 0; i < p_input->p->input.p_item->i_categories; i++ )            {                if( !strcmp( p_input->p->input.p_item->pp_categories[i]->psz_name,                             psz_cat ) ) break;            }            if( i == p_input->p->input.p_item->i_categories )            {                p_cat = malloc( sizeof( info_category_t ) );                if( !p_cat )                {                    vlc_mutex_unlock( &p_input->p->input.p_item->lock );                    return VLC_EGENERIC;                }                p_cat->psz_name = strdup( psz_cat );                p_cat->i_infos = 0;                p_cat->pp_infos = NULL;                INSERT_ELEM( p_input->p->input.p_item->pp_categories,                             p_input->p->input.p_item->i_categories,                             p_input->p->input.p_item->i_categories, p_cat );            }            p_cat = p_input->p->input.p_item->pp_categories[i];            for( i = 0; i < p_cat->i_infos; i++ )            {                if( !strcmp( p_cat->pp_infos[i]->psz_name, psz_name ) )                {                    if( p_cat->pp_infos[i]->psz_value )                        free( p_cat->pp_infos[i]->psz_value );                    break;                }            }            if( i == p_cat->i_infos )            {                p_info = malloc( sizeof( info_t ) );                if( !p_info )                {                    vlc_mutex_unlock( &p_input->p->input.p_item->lock );                    return VLC_EGENERIC;                }                INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos,                             p_cat->i_infos, p_info );                p_info->psz_name = strdup( psz_name );            }            p_info = p_cat->pp_infos[i];            if( vasprintf( &p_info->psz_value, psz_format, args ) == -1 )                p_info->psz_value = NULL;            vlc_mutex_unlock( &p_input->p->input.p_item->lock );            if( !p_input->b_preparsing )            {                vlc_event_t event;                event.type = vlc_InputItemInfoChanged;                vlc_event_send( &p_input->p->input.p_item->event_manager, &event );            }        }        return VLC_SUCCESS;        case INPUT_DEL_INFO:        {            char *psz_cat = (char *)va_arg( args, char * );            char *psz_name = (char *)va_arg( args, char * );            info_category_t *p_cat = NULL;            int i_cat;            int i;            vlc_mutex_lock( &p_input->p->input.p_item->lock );            for( i_cat = 0; i_cat < p_input->p->input.p_item->i_categories; i_cat++ )            {                if( !strcmp( p_input->p->input.p_item->pp_categories[i_cat]->psz_name,                             psz_cat ) )                {                    p_cat = p_input->p->input.p_item->pp_categories[i_cat];                    break;                }            }            if( p_cat == NULL )            {                vlc_mutex_unlock( &p_input->p->input.p_item->lock );                return VLC_EGENERIC;            }            if( psz_name )            {                /* Remove a specific info */                for( i = 0; i < p_cat->i_infos; i++ )                {                    if( !strcmp( p_cat->pp_infos[i]->psz_name, psz_name ) )                    {                        free( p_cat->pp_infos[i]->psz_name );                        if( p_cat->pp_infos[i]->psz_value )                            free( p_cat->pp_infos[i]->psz_value );                        free( p_cat->pp_infos[i] );                        REMOVE_ELEM( p_cat->pp_infos, p_cat->i_infos, i );                        break;                    }                }                if( i >= p_cat->i_infos )                {                    vlc_mutex_unlock( &p_input->p->input.p_item->lock );                    return VLC_EGENERIC;                }            }            else            {                /* Remove the complete categorie */                for( i = 0; i < p_cat->i_infos; i++ )                {                    free( p_cat->pp_infos[i]->psz_name );                    if( p_cat->pp_infos[i]->psz_value )                        free( p_cat->pp_infos[i]->psz_value );                    free( p_cat->pp_infos[i] );                }                if( p_cat->pp_infos )                    free( p_cat->pp_infos );                REMOVE_ELEM( p_input->p->input.p_item->pp_categories, p_input->p->input.p_item->i_categories, i_cat );            }            vlc_mutex_unlock( &p_input->p->input.p_item->lock );            if( !p_input->b_preparsing )            {                vlc_event_t event;                event.type = vlc_InputItemInfoChanged;                vlc_event_send( &p_input->p->input.p_item->event_manager, &event );            }            return VLC_SUCCESS;        }        case INPUT_GET_INFO:        {            char *psz_cat = (char *)va_arg( args, char * );            char *psz_name = (char *)va_arg( args, char * );            char **ppsz_value = (char **)va_arg( args, char ** );            int i_ret = VLC_EGENERIC;            *ppsz_value = NULL;            *ppsz_value = input_item_GetInfo( p_input->p->input.p_item,                                                  psz_cat, psz_name );            return i_ret;        }        case INPUT_SET_NAME:        {            char *psz_name = (char *)va_arg( args, char * );            if( !psz_name ) return VLC_EGENERIC;            vlc_mutex_lock( &p_input->p->input.p_item->lock );            if( p_input->p->input.p_item->psz_name )                free( p_input->p->input.p_item->psz_name );            p_input->p->input.p_item->psz_name = strdup( psz_name );            vlc_mutex_unlock( &p_input->p->input.p_item->lock );            if( !p_input->b_preparsing )            {                vlc_event_t event;                event.type = vlc_InputItemNameChanged;                event.u.input_item_name_changed.new_name = psz_name;                vlc_event_send( &p_input->p->input.p_item->event_manager, &event );            }            return VLC_SUCCESS;        }        case INPUT_ADD_BOOKMARK:            p_bkmk = (seekpoint_t *)va_arg( args, seekpoint_t * );            p_bkmk = vlc_seekpoint_Duplicate( p_bkmk );            vlc_mutex_lock( &p_input->p->input.p_item->lock );            if( !p_bkmk->psz_name )            {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -