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

📄 vlm.c

📁 uclinux 下的vlc播放器源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
               else if( i_msec >= 0               && i_msec < var_GetTime( p_instance->p_input, "length" ) )               {                  var_SetTime( p_instance->p_input, "time", i_msec );               }            }            else if( strchr( psz_args, 's' ) )            {               /* seconds */               int64_t i_sec = 1000000 * (int64_t)atoi( psz_args );               if( i_rel )               {                  var_SetTime( p_instance->p_input, "time-offset", i_sec );               }               else if( i_sec >= 0                     && i_sec < var_GetTime( p_instance->p_input, "length" ) )               {                  var_SetTime( p_instance->p_input, "time", i_sec );               }            }            else            {               /* percentage */               f_value /= 100.;               if( i_rel )               {                  float f_orig = var_GetFloat( p_instance->p_input, "position" );                  f_value += f_orig;               }               if( f_value >= 0.0 && f_value <= 1.0 )               {                  var_SetFloat( p_instance->p_input, "position", f_value );                  return VLC_SUCCESS;               }            }        }    }    else if( !strcmp( psz_command, "stop" ) )    {        TAB_REMOVE( media->i_instance, media->instance, p_instance );        if( p_instance->p_input )        {            input_StopThread( p_instance->p_input );            input_DestroyThread( p_instance->p_input );            vlc_object_detach( p_instance->p_input );            vlc_object_destroy( p_instance->p_input );        }        vlc_input_item_Clean( &p_instance->item );        if( p_instance->psz_name ) free( p_instance->psz_name );        free( p_instance );        return VLC_SUCCESS;    }    else if( !strcmp( psz_command, "pause" ) )    {        vlc_value_t val;        if( !p_instance->p_input ) return VLC_SUCCESS;        var_Get( p_instance->p_input, "state", &val );        if( val.i_int == PAUSE_S ) val.i_int = PLAYING_S;        else val.i_int = PAUSE_S;        var_Set( p_instance->p_input, "state", val );        return VLC_SUCCESS;    }    return VLC_EGENERIC;}/***************************************************************************** * Schedule handling *****************************************************************************/static int64_t vlm_Date( void ){#ifdef WIN32    struct timeb tm;    ftime( &tm );    return ((int64_t)tm.time) * 1000000 + ((int64_t)tm.millitm) * 1000;#else    return mdate();#endif}vlm_schedule_t *vlm_ScheduleNew( vlm_t *vlm, const char *psz_name ){    vlm_schedule_t *p_sched = malloc( sizeof( vlm_schedule_t ) );    if( !p_sched )    {        return NULL;    }    if( !psz_name )    {        return NULL;    }    p_sched->psz_name = strdup( psz_name );    p_sched->b_enabled = VLC_FALSE;    p_sched->i_command = 0;    p_sched->command = NULL;    p_sched->i_date = 0;    p_sched->i_period = 0;    p_sched->i_repeat = -1;    TAB_APPEND( vlm->i_schedule, vlm->schedule, p_sched );    return p_sched;}/* for now, simple delete. After, del with options (last arg) */void vlm_ScheduleDelete( vlm_t *vlm, vlm_schedule_t *sched,                         const char *psz_name ){    if( sched == NULL ) return;    TAB_REMOVE( vlm->i_schedule, vlm->schedule, sched );    if( vlm->i_schedule == 0 && vlm->schedule ) free( vlm->schedule );    free( sched->psz_name );    while( sched->i_command )    {        char *psz_cmd = sched->command[0];        TAB_REMOVE( sched->i_command, sched->command, psz_cmd );        free( psz_cmd );    }    free( sched );}static vlm_schedule_t *vlm_ScheduleSearch( vlm_t *vlm, const char *psz_name ){    int i;    for( i = 0; i < vlm->i_schedule; i++ )    {        if( strcmp( psz_name, vlm->schedule[i]->psz_name ) == 0 )        {            return vlm->schedule[i];        }    }    return NULL;}/* Ok, setup schedule command will be able to support only one (argument value) at a time  */int vlm_ScheduleSetup( vlm_schedule_t *schedule, const char *psz_cmd,                       const char *psz_value ){    if( !strcmp( psz_cmd, "enabled" ) )    {        schedule->b_enabled = VLC_TRUE;    }    else if( !strcmp( psz_cmd, "disabled" ) )    {        schedule->b_enabled = VLC_FALSE;    }#if !defined( UNDER_CE )    else if( !strcmp( psz_cmd, "date" ) )    {        struct tm time;        const char *p;        time_t date;        time.tm_sec = 0;         /* seconds */        time.tm_min = 0;         /* minutes */        time.tm_hour = 0;        /* hours */        time.tm_mday = 0;        /* day of the month */        time.tm_mon = 0;         /* month */        time.tm_year = 0;        /* year */        time.tm_wday = 0;        /* day of the week */        time.tm_yday = 0;        /* day in the year */        time.tm_isdst = -1;       /* daylight saving time */        /* date should be year/month/day-hour:minutes:seconds */        p = strchr( psz_value, '-' );        if( !strcmp( psz_value, "now" ) )        {            schedule->i_date = 0;        }        else if( (p == NULL) && sscanf( psz_value, "%d:%d:%d", &time.tm_hour,                                        &time.tm_min, &time.tm_sec ) != 3 )                                        /* it must be a hour:minutes:seconds */        {            return 1;        }        else        {            unsigned i,j,k;            switch( sscanf( p + 1, "%u:%u:%u", &i, &j, &k ) )            {                case 1:                    time.tm_sec = i;                    break;                case 2:                    time.tm_min = i;                    time.tm_sec = j;                    break;                case 3:                    time.tm_hour = i;                    time.tm_min = j;                    time.tm_sec = k;                    break;                default:                    return 1;            }            switch( sscanf( psz_value, "%d/%d/%d", &i, &j, &k ) )            {                case 1:                    time.tm_mday = i;                    break;                case 2:                    time.tm_mon = i - 1;                    time.tm_mday = j;                    break;                case 3:                    time.tm_year = i - 1900;                    time.tm_mon = j - 1;                    time.tm_mday = k;                    break;                default:                    return 1;            }            date = mktime( &time );            schedule->i_date = ((mtime_t) date) * 1000000;        }    }    else if( !strcmp( psz_cmd, "period" ) )    {        struct tm time;        const char *p;        const char *psz_time = NULL, *psz_date = NULL;        time_t date;        unsigned i,j,k;        /* First, if date or period are modified, repeat should be equal to -1 */        schedule->i_repeat = -1;        time.tm_sec = 0;         /* seconds */        time.tm_min = 0;         /* minutes */        time.tm_hour = 0;        /* hours */        time.tm_mday = 0;        /* day of the month */        time.tm_mon = 0;         /* month */        time.tm_year = 0;        /* year */        time.tm_wday = 0;        /* day of the week */        time.tm_yday = 0;        /* day in the year */        time.tm_isdst = -1;       /* daylight saving time */        /* date should be year/month/day-hour:minutes:seconds */        p = strchr( psz_value, '-' );        if( p )        {            psz_date = psz_value;            psz_time = p + 1;        }        else        {            psz_time = psz_value;        }        switch( sscanf( psz_time, "%u:%u:%u", &i, &j, &k ) )        {            case 1:                time.tm_sec = i;                break;            case 2:                time.tm_min = i;                time.tm_sec = j;                break;            case 3:                time.tm_hour = i;                time.tm_min = j;                time.tm_sec = k;                break;            default:                return 1;        }        if( psz_date )        {            switch( sscanf( psz_date, "%u/%u/%u", &i, &j, &k ) )            {                case 1:                    time.tm_mday = i;                    break;                case 2:                    time.tm_mon = i;                    time.tm_mday = j;                    break;                case 3:                    time.tm_year = i;                    time.tm_mon = j;                    time.tm_mday = k;                    break;                default:                    return 1;            }        }        /* ok, that's stupid... who is going to schedule streams every 42 years ? */        date = (((( time.tm_year * 12 + time.tm_mon ) * 30 + time.tm_mday ) * 24 + time.tm_hour ) * 60 + time.tm_min ) * 60 + time.tm_sec ;        schedule->i_period = ((mtime_t) date) * 1000000;    }#endif /* UNDER_CE */    else if( !strcmp( psz_cmd, "repeat" ) )    {        int i;        if( sscanf( psz_value, "%d", &i ) == 1 )        {            schedule->i_repeat = i;        }        else        {            return 1;        }    }    else if( !strcmp( psz_cmd, "append" ) )    {        char *command = strdup( psz_value );        TAB_APPEND( schedule->i_command, schedule->command, command );    }    else    {        return 1;    }    return 0;}/***************************************************************************** * Message handling functions *****************************************************************************/static vlm_message_t *vlm_MessageNew( const char *psz_name,                                      const char *psz_format, ... ){    vlm_message_t *p_message;    va_list args;    if( !psz_name ) return 0;    p_message = malloc( sizeof(vlm_message_t) );    if( !p_message)    {        return NULL;    }    p_message->psz_value = 0;    if( psz_format )    {        va_start( args, psz_format );        if( vasprintf( &p_message->psz_value, psz_format, args ) < 0 )        {            va_end( args );            free( p_message );            return 0;        }        va_end( args );    }    p_message->psz_name = strdup( psz_name );    p_message->i_child = 0;    p_message->child = NULL;    return p_message;}void vlm_MessageDelete( vlm_message_t *p_message ){    if( p_message->psz_name ) free( p_message->psz_name );    if( p_message->psz_value ) free( p_message->psz_value );    while( p_message->i_child-- )        vlm_MessageDelete( p_message->child[p_message->i_child] );    if( p_message->child ) free( p_message->child );    free( p_message );}/* Add a child */static vlm_message_t *vlm_MessageAdd( vlm_message_t *p_message,                                      vlm_message_t *p_child ){    if( p_message == NULL ) return NULL;    if( p_child )    {        TAB_APPEND( p_message->i_child, p_message->child, p_child );    }    return p_child;}/***************************************************************************** * Misc utility functions *****************************************************************************/static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media,                                vlm_schedule_t *schedule, const char *psz_filter ){    if( media != NULL )    {        int i;        vlm_message_t *msg;        vlm_message_t *msg_media;        vlm_message_t *msg_child;        msg = vlm_MessageNew( "show", NULL );        msg_media = vlm_MessageAdd( msg, vlm_MessageNew( media->psz_name, 0 ));        vlm_MessageAdd( msg_media,                        vlm_MessageNew( "type", media->i_type == VOD_TYPE ?                                        "vod" : "broadcast" ) );        vlm_MessageAdd( msg_media,                        vlm_MessageNew( "enabled", media->b_enabled ?                                        "yes" : "no" ) );        vlm_MessageAdd( msg_media,                        vlm_MessageNew( "loop", media->b_loop ?                                        "yes" : "no" ) );        if( media->i_type == VOD_TYPE && media->psz_mux )            vlm_MessageAdd( msg_media,

⌨️ 快捷键说明

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