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

📄 real.c

📁 uclinux 下的vlc播放器源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
                        i_flags = GetWBE(&header[38]);            msg_Dbg( p_demux, "    - flags=0x%x %s%s%s",                     i_flags,                     i_flags&0x0001 ? "PN_SAVE_ENABLED " : "",                     i_flags&0x0002 ? "PN_PERFECT_PLAY_ENABLED " : "",                     i_flags&0x0004 ? "PN_LIVE_BROADCAST" : "" );            i_skip -= 40;        }        else if( i_id == VLC_FOURCC('C','O','N','T') )        {            int i_len;            char *psz;                        /* FIXME FIXME: should convert from whatever the character             * encoding of the input meta data is to UTF-8. */            stream_Read( p_demux->s, header, 2 );            if( ( i_len = GetWBE( header ) ) > 0 )            {                psz = malloc( i_len + 1 );                stream_Read( p_demux->s, psz, i_len );                psz[i_len] = '\0';                msg_Dbg( p_demux, "    - title=`%s'", psz );                EnsureUTF8( psz );                vlc_meta_Add( p_sys->p_meta, VLC_META_TITLE, psz );                free( psz );                i_skip -= i_len;            }            i_skip -= 2;            stream_Read( p_demux->s, header, 2 );            if( ( i_len = GetWBE( header ) ) > 0 )            {                psz = malloc( i_len + 1 );                stream_Read( p_demux->s, psz, i_len );                psz[i_len] = '\0';                msg_Dbg( p_demux, "    - author=`%s'", psz );                EnsureUTF8( psz );                vlc_meta_Add( p_sys->p_meta, VLC_META_ARTIST, psz );                free( psz );                i_skip -= i_len;            }            i_skip -= 2;            stream_Read( p_demux->s, header, 2 );            if( ( i_len = GetWBE( header ) ) > 0 )            {                psz = malloc( i_len + 1 );                stream_Read( p_demux->s, psz, i_len );                psz[i_len] = '\0';                msg_Dbg( p_demux, "    - copyright=`%s'", psz );                EnsureUTF8( psz );                vlc_meta_Add( p_sys->p_meta, VLC_META_COPYRIGHT, psz );                free( psz );                i_skip -= i_len;            }            i_skip -= 2;            stream_Read( p_demux->s, header, 2 );            if( ( i_len = GetWBE( header ) ) > 0 )            {                psz = malloc( i_len + 1 );                stream_Read( p_demux->s, psz, i_len );                psz[i_len] = '\0';                msg_Dbg( p_demux, "    - comment=`%s'", psz );                EnsureUTF8( psz );                vlc_meta_Add( p_sys->p_meta, VLC_META_DESCRIPTION, psz );                free( psz );                i_skip -= i_len;            }            i_skip -= 2;        }        else if( i_id == VLC_FOURCC('M','D','P','R') )        {            /* Media properties header */            int  i_num;            int  i_len;            char *psz;            if( stream_Read(p_demux->s, header, 30) < 30 ) return VLC_EGENERIC;            i_num = GetWBE( header );            msg_Dbg( p_demux, "    - id=0x%x", i_num );            msg_Dbg( p_demux, "    - max bitrate=%d avg bitrate=%d",                     GetDWBE(&header[2]), GetDWBE(&header[6]) );            msg_Dbg( p_demux, "    - max packet size=%d avg packet size=%d",                     GetDWBE(&header[10]), GetDWBE(&header[14]) );            msg_Dbg( p_demux, "    - start time=%d", GetDWBE(&header[18]) );            msg_Dbg( p_demux, "    - preroll=%d", GetDWBE(&header[22]) );            msg_Dbg( p_demux, "    - duration=%d", GetDWBE(&header[26]) );                        i_skip -= 30;            stream_Read( p_demux->s, header, 1 );            if( ( i_len = header[0] ) > 0 )            {                psz = malloc( i_len + 1 );                stream_Read( p_demux->s, psz, i_len );                psz[i_len] = '\0';                msg_Dbg( p_demux, "    - name=`%s'", psz );                free( psz );                i_skip -= i_len;            }            i_skip--;            stream_Read( p_demux->s, header, 1 );            if( ( i_len = header[0] ) > 0 )            {                psz = malloc( i_len + 1 );                stream_Read( p_demux->s, psz, i_len );                psz[i_len] = '\0';                msg_Dbg( p_demux, "    - mime=`%s'", psz );                free( psz );                i_skip -= i_len;            }            i_skip--;            stream_Read( p_demux->s, header, 4 );            if( ( i_len = GetDWBE( header ) ) > 0 )            {                ReadCodecSpecificData( p_demux, i_len, i_num );                stream_Read( p_demux->s, NULL, i_len );                i_skip -= i_len;            }            i_skip -= 4;        }        else if( i_id == VLC_FOURCC('D','A','T','A') )        {            stream_Read( p_demux->s, header, 8 );            p_sys->i_data_offset    = stream_Tell( p_demux->s ) - 10;            p_sys->i_data_size      = i_size;            p_sys->i_data_packets_count = GetDWBE( header );            p_sys->i_data_packets   = 0;            p_sys->i_data_offset_next = GetDWBE( &header[4] );            msg_Dbg( p_demux, "    - packets count=%d next=%u",                     p_sys->i_data_packets_count,                     (uint32_t)p_sys->i_data_offset_next );            /* we have finished the header */            break;        }        else        {            /* unknow header */            msg_Dbg( p_demux, "unknown chunk" );        }        if( i_skip < 0 ) return VLC_EGENERIC;        stream_Read( p_demux->s, NULL, i_skip );    }    /* TODO read index if possible */    return VLC_SUCCESS;}static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num ){    demux_sys_t *p_sys = p_demux->p_sys;    es_format_t fmt;    real_track_t *tk;    uint8_t *p_peek;    msg_Dbg( p_demux, "    - specific data len=%d", i_len );    if( stream_Peek(p_demux->s, &p_peek, i_len) < i_len ) return VLC_EGENERIC;    if( !strncmp( (char *)&p_peek[4], "VIDO", 4 ) )    {        es_format_Init( &fmt, VIDEO_ES, VLC_FOURCC( p_peek[8], p_peek[9],                        p_peek[10], p_peek[11] ) );        fmt.video.i_width = GetWBE( &p_peek[12] );        fmt.video.i_height= GetWBE( &p_peek[14] );        fmt.i_extra = 8;        fmt.p_extra = malloc( 8 );        ((uint32_t*)fmt.p_extra)[0] = GetDWBE( &p_peek[26] );        ((uint32_t*)fmt.p_extra)[1] = GetDWBE( &p_peek[30] );        msg_Dbg( p_demux, "    - video 0x%08x 0x%08x",                 ((uint32_t*)fmt.p_extra)[0], ((uint32_t*)fmt.p_extra)[1] );        if( GetDWBE( &p_peek[30] ) == 0x10003000 ||            GetDWBE( &p_peek[30] ) == 0x10003001 )        {            fmt.i_codec = VLC_FOURCC( 'R','V','1','3' );        }        else if( GetDWBE( &p_peek[30] ) == 0x20001000 ||                 GetDWBE( &p_peek[30] ) == 0x20100001 ||                 GetDWBE( &p_peek[30] ) == 0x20200002 )        {            fmt.i_codec = VLC_FOURCC( 'R','V','2','0' );        }        else if( GetDWBE( &p_peek[30] ) == 0x30202002 )        {            fmt.i_codec = VLC_FOURCC( 'R','V','3','0' );        }        else if( GetDWBE( &p_peek[30] ) == 0x40000000 )        {            fmt.i_codec = VLC_FOURCC( 'R','V','4','0' );        }        msg_Dbg( p_demux, "    - video %4.4s %dx%d",                 (char*)&fmt.i_codec, fmt.video.i_width, fmt.video.i_height );        tk = malloc( sizeof( real_track_t ) );        tk->i_out_subpacket = 0;        tk->i_subpacket = 0;        tk->i_subpackets = 0;        tk->p_subpackets = NULL;        tk->i_id = i_num;        tk->fmt = fmt;        tk->i_frame = 0;        tk->p_frame = NULL;        tk->p_es = es_out_Add( p_demux->out, &fmt );        TAB_APPEND( p_sys->i_track, p_sys->track, tk );    }    else if( !strncmp( (char *)p_peek, ".ra\xfd", 4 ) )    {        int i_version = GetWBE( &p_peek[4] );        int i_header_size, i_flavor, i_coded_frame_size, i_subpacket_h;        int i_frame_size, i_subpacket_size;        msg_Dbg( p_demux, "    - audio version=%d", i_version );        p_peek += 6;        es_format_Init( &fmt, AUDIO_ES, 0 );        if( i_version == 3 )        {            msg_Dbg( p_demux, "    - audio version 3 is not supported!" );            return VLC_EGENERIC;        }        p_peek += 2; /* 00 00 */        p_peek += 4; /* .ra4 or .ra5 */        p_peek += 4; /* ?? */        p_peek += 2; /* version (4 or 5) */        i_header_size = GetDWBE( p_peek ); p_peek += 4; /* header size */        i_flavor = GetWBE( p_peek ); p_peek += 2; /* codec flavor */        i_coded_frame_size = GetDWBE( p_peek ); p_peek += 4;        p_peek += 4; /* ?? */        p_peek += 4; /* ?? */        p_peek += 4; /* ?? */        i_subpacket_h = GetWBE( p_peek ); p_peek += 2;        i_frame_size = GetWBE( p_peek ); p_peek += 2;        i_subpacket_size = GetWBE( p_peek ); p_peek += 2;        p_peek += 2; /* ?? */        if( i_version == 5 ) p_peek += 6; /* 0, srate, 0 */        fmt.audio.i_rate = GetWBE( p_peek ); p_peek += 2;        p_peek += 2; /* ?? */        fmt.audio.i_bitspersample = GetWBE( p_peek ); p_peek += 2;        fmt.audio.i_channels = GetWBE( p_peek ); p_peek += 2;        fmt.audio.i_blockalign = i_frame_size;        if( i_version == 5 )        {            p_peek += 4; /* genr */            memcpy( (char *)&fmt.i_codec, p_peek, 4 ); p_peek += 4;        }        else        {            p_peek += p_peek[0] + 1; /* descr 1 */            memcpy( (char *)&fmt.i_codec, p_peek + 1, 4 ); /* descr 2 */            p_peek += p_peek[0] + 1;        }        msg_Dbg( p_demux, "    - audio codec=%4.4s channels=%d rate=%dHz",                 (char*)&fmt.i_codec, fmt.audio.i_channels, fmt.audio.i_rate );        p_peek += 3; /* ?? */        if( i_version == 5 ) p_peek++;        switch( fmt.i_codec )        {        case VLC_FOURCC( 'd', 'n', 'e', 't' ):            fmt.i_codec = VLC_FOURCC( 'a', '5', '2', ' ' );            break;        case VLC_FOURCC( 'r', 'a', 'a', 'c' ):        case VLC_FOURCC( 'r', 'a', 'c', 'p' ):            fmt.i_extra = GetDWBE( p_peek ); p_peek += 4;            if( fmt.i_extra > 0 ) { fmt.i_extra--; p_peek++; }            if( fmt.i_extra > 0 )            {                fmt.p_extra = malloc( fmt.i_extra );                memcpy( fmt.p_extra, p_peek, fmt.i_extra );            }            fmt.i_codec = VLC_FOURCC( 'm', 'p', '4', 'a' );            break;        case VLC_FOURCC('c','o','o','k'):            fmt.audio.i_blockalign = i_subpacket_size;            if( !(fmt.i_extra = GetDWBE( p_peek )) ) break;            fmt.p_extra = malloc( fmt.i_extra );            memcpy( fmt.p_extra, p_peek + 4, fmt.i_extra );            break;        case VLC_FOURCC('2','8','_','8'):            fmt.audio.i_blockalign = i_coded_frame_size;            break;        default:            msg_Dbg( p_demux, "    - unknown audio codec=%4.4s",                     (char*)&fmt.i_codec );            break;        }        if( fmt.i_codec != 0 )        {            int i;            msg_Dbg( p_demux, "        - extra data=%d", fmt.i_extra );            tk = malloc( sizeof( real_track_t ) );            tk->i_id = i_num;            tk->fmt = fmt;            tk->i_frame = 0;            tk->p_frame = NULL;            tk->i_subpacket_h = i_subpacket_h;            tk->i_subpacket_size = i_subpacket_size;            tk->i_coded_frame_size = i_coded_frame_size;            tk->i_frame_size = i_frame_size;            tk->i_out_subpacket = 0;            tk->i_subpacket = 0;            tk->i_subpackets = 0;            tk->p_subpackets = NULL;            if( fmt.i_codec == VLC_FOURCC('c','o','o','k') )            {                tk->i_subpackets =                    i_subpacket_h * i_frame_size / tk->i_subpacket_size;                tk->p_subpackets =                    malloc( tk->i_subpackets * sizeof(block_t *) );            }            else if( fmt.i_codec == VLC_FOURCC('2','8','_','8') )            {                tk->i_subpackets =                    i_subpacket_h * i_frame_size / tk->i_coded_frame_size;                tk->p_subpackets =                    malloc( tk->i_subpackets * sizeof(block_t *) );            }            for( i = 0; i < tk->i_subpackets; i++ ) tk->p_subpackets[i] = NULL;            tk->p_es = es_out_Add( p_demux->out, &fmt );            TAB_APPEND( p_sys->i_track, p_sys->track, tk );        }    }    return VLC_SUCCESS;}

⌨️ 快捷键说明

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