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

📄 http.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 5 页
字号:
                                    break;                                }                                case '0': case '1': case '2': case '3': case '4':                                case '5': case '6': case '7': case '8': case '9':                                {                                    i_stock = strtol( p_value , &p_value , 10 );                                    break;                                }                                case '%': /* for percentage ie position */                                {                                    i_relative += POSITION_ABSOLUTE;                                    i_value = i_stock;                                    i_stock = 0;                                    p_value[0] = '\0';                                    break;                                }                                case ':':                                {                                    i_value = 60 * (i_value + i_stock) ;                                    i_stock = 0;                                    p_value++;                                    break;                                }                                case 'h': case 'H': /* hours */                                {                                    i_value += 3600 * i_stock;                                    i_stock = 0;                                    /* other characters which are not numbers are not important */                                    while( ((p_value[0] < '0') || (p_value[0] > '9')) && (p_value[0] != '\0') )                                    {                                        p_value++;                                    }                                    break;                                }                                case 'm': case 'M': case '\'': /* minutes */                                {                                    i_value += 60 * i_stock;                                    i_stock = 0;                                    p_value++;                                    while( ((p_value[0] < '0') || (p_value[0] > '9')) && (p_value[0] != '\0') )                                    {                                        p_value++;                                    }                                    break;                                }                                case 's': case 'S': case '"':  /* seconds */                                {                                    i_value += i_stock;                                    i_stock = 0;                                    while( ((p_value[0] < '0') || (p_value[0] > '9')) && (p_value[0] != '\0') )                                    {                                        p_value++;                                    }                                    break;                                }                                default:                                {                                    p_value++;                                    break;                                }                            }                        }                        /* if there is no known symbol, I consider it as seconds. Otherwise, i_stock = 0 */                        i_value += i_stock;                        switch(i_relative)                        {                            case VL_TIME_ABSOLUTE:                            {                                if( (uint64_t)( i_value ) * 1000000 <= i_length )                                    val.i_time = (uint64_t)( i_value ) * 1000000;                                else                                    val.i_time = i_length;                                var_Set( p_sys->p_input, "time", val );                                msg_Dbg( p_intf, "requested seek position: %dsec", i_value );                                break;                            }                            case VL_TIME_REL_FOR:                            {                                var_Get( p_sys->p_input, "time", &val );                                if( (uint64_t)( i_value ) * 1000000 + val.i_time <= i_length )                                {                                    val.i_time = ((uint64_t)( i_value ) * 1000000) + val.i_time;                                } else                                {                                    val.i_time = i_length;                                }                                var_Set( p_sys->p_input, "time", val );                                msg_Dbg( p_intf, "requested seek position forward: %dsec", i_value );                                break;                            }                            case VL_TIME_REL_BACK:                            {                                var_Get( p_sys->p_input, "time", &val );                                if( (int64_t)( i_value ) * 1000000 > val.i_time )                                {                                    val.i_time = 0;                                } else                                {                                    val.i_time = val.i_time - ((uint64_t)( i_value ) * 1000000);                                }                                var_Set( p_sys->p_input, "time", val );                                msg_Dbg( p_intf, "requested seek position backward: %dsec", i_value );                                break;                            }                            case POSITION_ABSOLUTE:                            {                                val.f_float = __MIN( __MAX( ((float) i_value ) / 100.0 , 0.0 ) , 100.0 );                                var_Set( p_sys->p_input, "position", val );                                msg_Dbg( p_intf, "requested seek percent: %d", i_value );                                break;                            }                            case POSITION_REL_FOR:                            {                                var_Get( p_sys->p_input, "position", &val );                                val.f_float += __MIN( __MAX( ((float) i_value ) / 100.0 , 0.0 ) , 100.0 );                                var_Set( p_sys->p_input, "position", val );                                msg_Dbg( p_intf, "requested seek percent forward: %d", i_value );                                break;                            }                            case POSITION_REL_BACK:                            {                                var_Get( p_sys->p_input, "position", &val );                                val.f_float -= __MIN( __MAX( ((float) i_value ) / 100.0 , 0.0 ) , 100.0 );                                var_Set( p_sys->p_input, "position", val );                                msg_Dbg( p_intf, "requested seek percent backward: %d", i_value );                                break;                            }                            default:                            {                                msg_Dbg( p_intf, "requested seek: what the f*** is going on here ?" );                                break;                            }                        }                    }#undef POSITION_ABSOLUTE#undef POSITION_REL_FOR#undef POSITION_REL_BACK#undef VL_TIME_ABSOLUTE#undef VL_TIME_REL_FOR#undef VL_TIME_REL_BACK                    break;                }                case MVLC_VOLUME:                {                    char vol[8];                    audio_volume_t i_volume;                    int i_value;                    uri_extract_value( p_request, "value", vol, 8 );                    aout_VolumeGet( p_intf, &i_volume );                    uri_decode_url_encoded( vol );                    if( vol[0] == '+' )                    {                        i_value = atoi( vol + 1 );                        if( (i_volume + i_value) > AOUT_VOLUME_MAX )                        {                            aout_VolumeSet( p_intf , AOUT_VOLUME_MAX );                            msg_Dbg( p_intf, "requested volume set: max" );                        } else                        {                            aout_VolumeSet( p_intf , (i_volume + i_value) );                            msg_Dbg( p_intf, "requested volume set: +%i", (i_volume + i_value) );                        }                    } else                    if( vol[0] == '-' )                    {                        i_value = atoi( vol + 1 );                        if( (i_volume - i_value) < AOUT_VOLUME_MIN )                        {                            aout_VolumeSet( p_intf , AOUT_VOLUME_MIN );                            msg_Dbg( p_intf, "requested volume set: min" );                        } else                        {                            aout_VolumeSet( p_intf , (i_volume - i_value) );                            msg_Dbg( p_intf, "requested volume set: -%i", (i_volume - i_value) );                        }                    } else                    if( strstr(vol, "%") != NULL )                    {                        i_value = atoi( vol );                        if( (i_value <= 100) && (i_value>=0) ){                            aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/100+AOUT_VOLUME_MIN);                            msg_Dbg( p_intf, "requested volume set: %i%%", atoi( vol ));                        }                    } else                    {                        i_value = atoi( vol );                        if( ( i_value <= AOUT_VOLUME_MAX ) && ( i_value >= AOUT_VOLUME_MIN ) )                        {                            aout_VolumeSet( p_intf , atoi( vol ) );                            msg_Dbg( p_intf, "requested volume set: %i", atoi( vol ) );                        }                    }                    break;                }                /* playlist management */                case MVLC_ADD:                {                    char mrl[512];                    playlist_item_t * p_item;                    uri_extract_value( p_request, "mrl", mrl, 512 );                    uri_decode_url_encoded( mrl );                    p_item = parse_MRL( p_intf, mrl );                    if( !p_item || !p_item->input.psz_uri ||                        !*p_item->input.psz_uri )                    {                        msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );                    } else                    {                        playlist_AddItem( p_sys->p_playlist , p_item ,                                          PLAYLIST_APPEND, PLAYLIST_END );                        msg_Dbg( p_intf, "requested mrl add: %s", mrl );                    }                    break;                }                case MVLC_DEL:                {                    int i_item, *p_items = NULL, i_nb_items = 0;                    char item[512], *p_parser = p_request;                    /* Get the list of items to delete */                    while( (p_parser =                            uri_extract_value( p_parser, "item", item, 512 )) )                    {                        if( !*item ) continue;                        i_item = atoi( item );                        p_items = realloc( p_items, (i_nb_items + 1) *                                           sizeof(int) );                        p_items[i_nb_items] = i_item;                        i_nb_items++;                    }                    if( i_nb_items )                    {                        int i;                        for( i = 0; i < i_nb_items; i++ )                        {                            playlist_LockDelete( p_sys->p_playlist, p_items[i] );                            msg_Dbg( p_intf, "requested playlist delete: %d",                                     p_items[i] );                            p_items[i] = -1;                        }                    }                    if( p_items ) free( p_items );                    break;                }                case MVLC_KEEP:                {                    int i_item, *p_items = NULL, i_nb_items = 0;                    char item[512], *p_parser = p_request;                    int i,j;                    /* Get the list of items to keep */                    while( (p_parser =                            uri_extract_value( p_parser, "item", item, 512 )) )                    {                        if( !*item ) continue;                        i_item = atoi( item );                        p_items = realloc( p_items, (i_nb_items + 1) *                                           sizeof(int) );                        p_items[i_nb_items] = i_item;                        i_nb_items++;                    }                    for( i = p_sys->p_playlist->i_size - 1 ; i >= 0; i-- )                    {                        /* Check if the item is in the keep list */                        for( j = 0 ; j < i_nb_items ; j++ )                        {                            if( p_items[j] ==                                p_sys->p_playlist->pp_items[i]->input.i_id ) break;                        }                        if( j == i_nb_items )                        {                            playlist_LockDelete( p_sys->p_playlist, p_sys->p_playlist->pp_items[i]->input.i_id );                            msg_Dbg( p_intf, "requested playlist delete: %d",                                     i );                        }                    }                    if( p_items ) free( p_items );                    break;                }                case MVLC_EMPTY:                {                    playlist_LockClear( p_sys->p_playlist );                    msg_Dbg( p_intf, "requested playlist empty" );                    break;                }                case MVLC_SORT:                {                    char type[12];                    char order[2];                    char item[512];                    int i_order;                    int i_item;                    uri_extract_value( p_request, "type", type, 12 );                    uri_extract_value( p_request, "order", order, 2 );                    uri_extract_value( p_request, "item", item, 512 );                    i_item = atoi( item );                    if( order[0] == '0' ) i_order = ORDER_NORMAL;                    else i_order = ORDER_REVERSE;                    if( !strcmp( type , "title" ) )                    {                        playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/                                                    p_sys->p_playlist->pp_views[0]->p_root,                                                    SORT_TITLE_NODES_FIRST,                                                    ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );                        msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order );                    } else if( !strcmp( type , "author" ) )                    {                        playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/                                                    p_sys->p_playlist->pp_views[0]->p_root,                                                    SORT_AUTHOR,                                                    ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );                        msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order );                    } else if( !strcmp( type , "shuffle" ) )                    {                        playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/                                                    p_sys->p_playlist->pp_views[0]->p_root,                                                    SORT_RANDOM,                                                    ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );                        msg_Dbg( p_intf, "requested playlist shuffle");                    }                    break;                }                case MVLC_MOVE:                {                    char psz_pos[6];                    char psz_newpos[6];                    int i_pos;                    int i_newpos;                    uri_extract_value( p_request, "psz_pos", psz_pos, 6 );                    uri_extract_value( p_request, "psz_newpos", psz_newpos, 6 );                    i_pos = atoi( psz_pos );                    i_newpos = atoi( psz_newpos );                    if ( i_pos < i_newpos )                    {                        playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );                    } else {                        playlist_Move( p_sys->p_playlist, i_pos, i_newpos );                    }                    msg_Dbg( p_intf, "requested move playlist item %d to %d", i_pos, i_newpos);                    break;                }                /* admin function */                case MVLC_CLOSE:                {                    char id[512];                    uri_extract_value( p_request, "id", id, 512 );                    msg_Dbg( p_intf, "requested close id=%s", id );#if 0                    if( p_sys->p_httpd->pf_control( p_sys->p_httpd, HTTPD_SET_CLOSE, id, NULL ) )                    {                        msg_Warn( p_intf, "close failed for id=%s", id );                    }#endif                    break;                }                case MVLC_SHUTDOWN:                {                    msg_Dbg( p_intf, "requested shutdown" );                    p_intf->p_vlc->b_die = VLC_TRUE;                    break;                }                /* vlm */                case MVLC_VLM_NEW:                case MVLC_VLM_SETUP:                {                    static const char *vlm_properties[11] =                    {                        /* no args */                        "enabled", "disabled", "loop", "unloop",                        /* args required */                        "input", "output", "option", "date", "period", "repeat", "append",                    };                    vlm_message_t *vlm_answer;                    char name[512];                    char *psz = malloc( strlen( p_request ) + 1000 );                    char *p = psz;                    char *vlm_error;                    int i;                    if( p_intf->p_sys->p_vlm == NULL )                        p_intf->p_sys->p_vlm = vlm_New( p_intf );                    if( p_intf->p_sys->p_vlm == NULL ) break;                    uri_extract_value( p_request, "name", name, 512 );                    if( StrToMacroType( control ) == MVLC_VLM_NEW )                    {                        char type[20];                        uri_extract_value( p_request, "type", type, 20 );                        p += sprintf( psz, "new %s %s", name, type );                    }                    else                    {                        p += sprintf( psz, "setup %s", name );                    }                    /* Parse the request */                    for( i = 0; i < 11; i++ )                    {                        char val[512];                        uri_extract_value( p_request, vlm_properties[i], val, 512 );                        uri_decode_url_encoded( val );                        if( strlen( val ) > 0 && i >= 4 )                        {                            p += sprintf( p, " %s %s", vlm_properties[i], val );                        }                        else if( uri_test_param( p_request, vlm_properties[i] ) && i < 4 )                        {                            p += sprintf( p, " %s", vlm_properties[i] );                        }                    }                    vlm_ExecuteCommand( p_intf->p_sys->p

⌨️ 快捷键说明

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