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

📄 dc1394.c

📁 uclinux 下的vlc播放器源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
    {        memcpy( p_block->p_buffer, (const char *)p_sys->camera.capture_buffer,                p_sys->camera.frame_width * p_sys->camera.frame_height * 2 );    }    else    {        int index = 0;        int offset = 0;        int i = 0, k = 0;        /* rotate UYVY image */        if( p_sys->rotate == ROTATION_LEFT )        {            for( i = p_sys->width-1; i >= 0; i-- )            {                for( k = 0; k < p_sys->height; k++ )                {                    index = (k * p_sys->width) + i;                    MovePixelUYVY( p_sys->camera.capture_buffer, index,                                   p_block->p_buffer, offset );                    offset++;                }            }        }        else        { /* ROTATION RIGHT */            for( i = 0; i < p_sys->width; i++ )            {                for( k = p_sys->height-1; k >= 0; k-- )                {                    index = (k * p_sys->width) + i;                    MovePixelUYVY( p_sys->camera.capture_buffer, index,                                   p_block->p_buffer, offset );                    offset++;                }            }        }    }    p_block->i_pts = p_block->i_dts = mdate();    if( p_sys->dma_capture )        dc1394_dma_done_with_buffer( &p_sys->camera );    return p_block;}static block_t *GrabAudio( demux_t *p_demux ){    demux_sys_t *p_sys = p_demux->p_sys;    struct audio_buf_info buf_info;    block_t *p_block = NULL;    int i_read = 0;    int i_correct = 0;    int result = 0;    p_block = block_New( p_demux, p_sys->i_audio_max_frame_size );    if( !p_block )    {        msg_Warn( p_demux, "cannot get buffer" );        return NULL;    }    i_read = read( p_sys->fd_audio, p_block->p_buffer,                   p_sys->i_audio_max_frame_size );    if( i_read <= 0 )        return NULL;    p_block->i_buffer = i_read;    /* Correct the date because of kernel buffering */    i_correct = i_read;    result = ioctl( p_sys->fd_audio, SNDCTL_DSP_GETISPACE, &buf_info );    if( result == 0 )        i_correct += buf_info.bytes;    p_block->i_pts = p_block->i_dts =                        mdate() - I64C(1000000) * (mtime_t)i_correct /                        2 / p_sys->channels / p_sys->i_sample_rate;    return p_block;}static int Demux( demux_t *p_demux ){    demux_sys_t *p_sys = p_demux->p_sys;    block_t *p_blocka = NULL;    block_t *p_blockv = NULL;    /* Try grabbing audio frames first */    if( p_sys->fd_audio > 0 )        p_blocka = GrabAudio( p_demux );    /* Try grabbing video frame */    if( (int)p_sys->fd_video > 0 )        p_blockv = GrabVideo( p_demux );    if( !p_blocka && !p_blockv )    {        /* Sleep so we do not consume all the cpu, 10ms seems         * like a good value (100fps)         */        msleep( 10000 );        return 1;    }    if( p_blocka )    {        es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_blocka->i_pts );        es_out_Send( p_demux->out, p_sys->p_es_audio, p_blocka );    }    if( p_blockv )    {        es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_blockv->i_pts );        es_out_Send( p_demux->out, p_sys->p_es_video, p_blockv );    }    return 1;}/***************************************************************************** * Control: *****************************************************************************/static int Control( demux_t *p_demux, int i_query, va_list args ){    vlc_bool_t *pb;    int64_t    *pi64;    switch( i_query )    {        /* Special for access_demux */        case DEMUX_CAN_PAUSE:        case DEMUX_SET_PAUSE_STATE:        case DEMUX_CAN_CONTROL_PACE:            pb = (vlc_bool_t*)va_arg( args, vlc_bool_t * );            *pb = VLC_FALSE;            return VLC_SUCCESS;        case DEMUX_GET_PTS_DELAY:            pi64 = (int64_t*)va_arg( args, int64_t * );            *pi64 = (int64_t)DEFAULT_PTS_DELAY;            return VLC_SUCCESS;        case DEMUX_GET_TIME:            pi64 = (int64_t*)va_arg( args, int64_t * );            *pi64 = mdate();            return VLC_SUCCESS;        /* TODO implement others */        default:            return VLC_EGENERIC;    }    return VLC_EGENERIC;}static int process_options( demux_t *p_demux ){    demux_sys_t *p_sys = p_demux->p_sys;    char *psz_dup;     char *psz_parser;    char *token = NULL;    char *state = NULL;    float rate_f;    if( strncmp(p_demux->psz_access,"dc1394",6) != 0 )        return VLC_EGENERIC;    psz_dup = strdup( p_demux->psz_path );    psz_parser = psz_dup;    for( token = strtok_r( psz_parser,":",&state); token;         token = strtok_r( NULL, ":", &state ) )    {        if( strncmp( token, "size=", strlen("size=") ) == 0 )        {            token += strlen("size=");            if( strncmp( token, "160x120", 7 ) == 0 )            {                /* TODO - UYV444 chroma converter is needed ...                    * video size of 160x120 is temporarily disabled                    */                msg_Err( p_demux,                    "video size of 160x120 is actually disabled for lack of chroma "                    "support. It will relased ASAP, until then try an higher size "                    "(320x240 and 640x480 are fully supported)" );                free(psz_dup);                return VLC_EGENERIC;#if 0                p_sys->frame_size = MODE_160x120_YUV444;                p_sys->width = 160;                p_sys->height = 120;#endif            }            else if( strncmp( token, "320x240", 7 ) == 0 )            {                p_sys->frame_size = MODE_320x240_YUV422;                p_sys->width = 320;                p_sys->height = 240;            }            else if( strncmp( token, "640x480", 7 ) == 0 )            {                p_sys->frame_size = MODE_640x480_YUV422;                p_sys->width = 640;                p_sys->height = 480;            }            else            {                msg_Err( p_demux,                    "This program currently suppots frame sizes of"                    " 160x120, 320x240, and 640x480. "                    "Please specify one of them. You have specified %s.",                    token );                free(psz_dup);                return VLC_EGENERIC;            }            msg_Dbg( p_demux, "Requested video size : %s",token );        }        else if( strncmp( token, "fps=", strlen( "fps=" ) ) == 0 )        {            token += strlen("fps=");            sscanf( token, "%g", &rate_f );            if( rate_f == 1.875 )                p_sys->frame_rate = FRAMERATE_1_875;            else if( rate_f == 3.75 )                p_sys->frame_rate = FRAMERATE_3_75;            else if( rate_f == 7.5 )                p_sys->frame_rate = FRAMERATE_7_5;            else if( rate_f == 15 )                p_sys->frame_rate = FRAMERATE_15;            else if( rate_f == 30 )                p_sys->frame_rate = FRAMERATE_30;            else if( rate_f == 60 )                p_sys->frame_rate = FRAMERATE_60;            else            {                msg_Err( p_demux ,                    "This program supports framerates of"                    " 1.875, 3.75, 7.5, 15, 30, 60. "                    "Please specify one of them. You have specified %s.",                    token);                free(psz_dup);                return VLC_EGENERIC;            }            msg_Dbg( p_demux, "Requested frame rate : %s",token );        }        else if( strncmp( token, "brightness=", strlen( "brightness=" ) ) == 0 )        {            int nr = 0;            token += strlen("brightness=");            nr = sscanf( token, "%u", &p_sys->brightness);            if( nr != 1 )            {                msg_Err( p_demux, "Bad brightness value '%s', "                                  "must be an unsigned integer.",                                  token );                free(psz_dup);                return VLC_EGENERIC;            }        }#if 0        else if( strncmp( token, "controller=", strlen( "controller=" ) ) == 0 )        {            int nr = 0;            token += strlen("controller=");            nr = sscanf( token, "%u", &p_sys->controller );            if( nr != 1)            {                msg_Err(p_demux, "Bad controller value '%s', "                                 "must be an unsigned integer.",                                 token );                return VLC_EGENERIC;            }        }#endif        else if( strncmp( token, "camera=", strlen( "camera=" ) ) == 0 )        {            int nr = 0;            token += strlen("camera=");            nr = sscanf(token,"%u",&p_sys->selected_camera);            if( nr != 1)            {                msg_Err( p_demux, "Bad camera number '%s', "                                  "must be an unsigned integer.",                                  token );                free(psz_dup);                return VLC_EGENERIC;            }        }        else if( strncmp( token, "capture=", strlen( "capture=" ) ) == 0)        {            token += strlen("capture=");            if( strncmp(token, "raw1394",7) == 0 )            {                msg_Dbg( p_demux, "DMA capture disabled!" );                p_sys->dma_capture = DMA_OFF;            }            else if( strncmp(token,"video1394",9) == 0 )            {                msg_Dbg( p_demux, "DMA capture enabled!" );                p_sys->dma_capture = DMA_ON;            }            else            {                msg_Err(p_demux, "Bad capture method value '%s', "                                 "it can be 'raw1394' or 'video1394'.",                                token );                free(psz_dup);                return VLC_EGENERIC;            }        }        else if( strncmp( token, "adev=", strlen( "adev=" ) ) == 0 )        {            token += strlen("adev=");            p_sys->audio_device = strdup(token);            msg_Dbg( p_demux, "Using audio device '%s'.", token );        }        else if( strncmp( token, "samplerate=", strlen( "samplerate=" ) ) == 0 )        {            token += strlen("samplerate=");            sscanf( token, "%d", &p_sys->i_sample_rate );        }        else if( strncmp( token, "channels=", strlen("channels=" ) ) == 0 )        {            token += strlen("channels=");            sscanf( token, "%d", &p_sys->channels );        }        else if( strncmp( token, "focus=", strlen("focus=" ) ) == 0)        {            token += strlen("focus=");            sscanf( token, "%u", &p_sys->focus );        }        else if( strncmp( token, "uid=", strlen("uid=") ) == 0)        {            token += strlen("uid=");            sscanf( token, "0x%llx", &p_sys->selected_uid );        }        else if( strncmp( token, "rotate=", strlen( "rotate=" ) ) == 0)        {            token += strlen("rotate=");            if( strncmp( token, "left", 4) == 0 )            {                msg_Dbg( p_demux, "Left Rotation enabled" );                p_sys->rotate = ROTATION_LEFT;            }            else if( strncmp( token, "right", 5 ) == 0 )            {                msg_Dbg( p_demux, "Right Rotation enabled" );                p_sys->rotate = ROTATION_RIGHT;            }            else            {                msg_Err( p_demux, "Bad rotation value '%s', "                                  "it can be 'left' or 'right'.",                                  token);                free(psz_dup);                return VLC_EGENERIC;            }        }    }    if( psz_dup ) free( psz_dup );    return VLC_SUCCESS;}

⌨️ 快捷键说明

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