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

📄 real.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 4 页
字号:
                *pi64 = (int64_t)( 1000.0 * p_sys->i_our_duration * stream_Tell( p_demux->s ) / i64 );                return VLC_SUCCESS;            }            *pi64 = 0;            return VLC_EGENERIC;        case DEMUX_SET_POSITION:            f = (double) va_arg( args, double );            i64 = (int64_t) ( stream_Size( p_demux->s ) * f );            if ( p_sys->i_index_offset == 0 && i64 != 0 )            {                msg_Err(p_demux,"Seek No Index Real File failed!" );                return VLC_EGENERIC; // no index!            }            if ( i64 == 0 )            {                /* it is a rtsp stream , it is specials in access/rtsp/... */                msg_Dbg(p_demux, "Seek in real rtsp stream!");                p_sys->i_pcr = (int64_t)1000 * ( p_sys->i_our_duration * f  );                es_out_Control( p_demux->out, ES_OUT_RESET_PCR , p_sys->i_pcr );                p_sys->b_seek = 1;                return stream_Seek( p_demux->s, p_sys->i_pcr );            }            if ( p_sys->i_index_offset > 0 )            {                p_index = p_sys->p_index;                while( p_index->file_offset !=0 )                {                    if ( p_index->file_offset > i64 )                    {                        msg_Dbg( p_demux, "Seek Real find! %d %d %d",                                 p_index->time_offset, p_index->file_offset,                                 (uint32_t) i64 );                        if ( p_index != p_sys->p_index ) p_index --;                        i64 = p_index->file_offset;                        break;                    }                    p_index++;                }                p_sys->i_pcr = 1000 * (int64_t) p_index->time_offset;                es_out_Control( p_demux->out, ES_OUT_RESET_PCR , p_sys->i_pcr );                return stream_Seek( p_demux->s, i64 );            }        case DEMUX_SET_TIME:            i64 = (int64_t) va_arg( args, int64_t ) / 1000;            p_index = p_sys->p_index;            while( p_index->file_offset !=0 )            {                if ( p_index->time_offset > i64 )                {                    if ( p_index != p_sys->p_index )                        p_index --;                    i64 = p_index->file_offset;                    break;                }                p_index++;            }            p_sys->i_pcr = 1000 * (int64_t) p_index->time_offset;            es_out_Control( p_demux->out, ES_OUT_RESET_PCR , p_sys->i_pcr );            return stream_Seek( p_demux->s, i64 );        case DEMUX_GET_LENGTH:            pi64 = (int64_t*)va_arg( args, int64_t * );             /* the commented following lines are fen's implementation, which doesn't seem to             * work for one reason or another -- FK */            /*if( p_sys->i_mux_rate > 0 )            {                *pi64 = (int64_t)1000000 * ( stream_Size( p_demux->s ) / 50 ) / p_sys->i_mux_rate;                return VLC_SUCCESS;            }*/            if( p_sys->i_our_duration > 0 )            {                /* our stored duration is in ms, so... */                *pi64 = (int64_t)1000 * p_sys->i_our_duration;                 return VLC_SUCCESS;            }            *pi64 = 0;            return VLC_EGENERIC;        case DEMUX_GET_META:        {            vlc_meta_t *p_meta = (vlc_meta_t*)va_arg( args, vlc_meta_t* );            /* the core will crash if we provide NULL strings, so check             * every string first */            if( p_sys->psz_title )                vlc_meta_SetTitle( p_meta, p_sys->psz_title );            if( p_sys->psz_artist )                vlc_meta_SetArtist( p_meta, p_sys->psz_artist );            if( p_sys->psz_copyright )                vlc_meta_SetCopyright( p_meta, p_sys->psz_copyright );            if( p_sys->psz_description )                vlc_meta_SetDescription( p_meta, p_sys->psz_description );            return VLC_SUCCESS;        }        case DEMUX_GET_FPS:        default:            return VLC_EGENERIC;    }    return VLC_EGENERIC;}/***************************************************************************** * ReadRealIndex: *****************************************************************************/static void ReadRealIndex( demux_t *p_demux ){    demux_sys_t *p_sys = p_demux->p_sys;    uint8_t       buffer[100];    uint32_t      i_id;    uint32_t      i_size;    int           i_version;    unsigned int  i;    uint32_t      i_index_count;    if ( p_sys->i_index_offset == 0 )        return;    stream_Seek( p_demux->s, p_sys->i_index_offset );    if ( stream_Read( p_demux->s, buffer, 20 ) < 20 )        return ;    i_id = VLC_FOURCC( buffer[0], buffer[1], buffer[2], buffer[3] );    i_size      = GetDWBE( &buffer[4] );    i_version   = GetWBE( &buffer[8] );    msg_Dbg( p_demux, "Real index %4.4s size=%d version=%d",                 (char*)&i_id, i_size, i_version );    if( (i_size < 20) && (i_id != VLC_FOURCC('I','N','D','X')) )        return;    i_index_count = GetDWBE( &buffer[10] );    msg_Dbg( p_demux, "Real Index : num : %d ", i_index_count );    if( i_index_count == 0 )        return;    if( GetDWBE( &buffer[16] ) > 0 )        msg_Dbg( p_demux, "Real Index: Does next index exist? %d ",                        GetDWBE( &buffer[16] )  );    p_sys->p_index =             (rm_index_t *)malloc( sizeof( rm_index_t ) * (i_index_count+1) );    if( p_sys->p_index == NULL )    {        msg_Err( p_demux, "Memory allocation error" );         return;    }    memset( p_sys->p_index, 0, sizeof(rm_index_t) * (i_index_count+1) );    for( i=0; i<i_index_count; i++ )    {        if( stream_Read( p_demux->s, buffer, 14 ) < 14 )            return ;        if( GetWBE( &buffer[0] ) != 0 )        {            msg_Dbg( p_demux, "Real Index: invaild version of index entry %d ",                              GetWBE( &buffer[0] ) );            return;        }        p_sys->p_index[i].time_offset = GetDWBE( &buffer[2] );        p_sys->p_index[i].file_offset = GetDWBE( &buffer[6] );        p_sys->p_index[i].frame_index = GetDWBE( &buffer[10] );        msg_Dbg( p_demux, "Real Index: time %d file %d frame %d ",                        p_sys->p_index[i].time_offset,                        p_sys->p_index[i].file_offset,                        p_sys->p_index[i].frame_index );    }}/***************************************************************************** * HeaderRead: *****************************************************************************/static int HeaderRead( demux_t *p_demux ){    demux_sys_t *p_sys = p_demux->p_sys;    uint8_t header[100];    /* FIXME */    uint32_t    i_id;    uint32_t    i_size;    int64_t     i_skip;    int         i_version;    p_sys->p_meta = vlc_meta_New();    for( ;; )    {        /* Read the header */        if( stream_Read( p_demux->s, header, 10 ) < 10 )        {            return VLC_EGENERIC;        }        i_id        = VLC_FOURCC( header[0], header[1], header[2], header[3] );        i_size      = GetDWBE( &header[4] );        i_version   = GetWBE( &header[8] );        msg_Dbg( p_demux, "object %4.4s size=%d version=%d",                 (char*)&i_id, i_size, i_version );        if( i_size < 10 && i_id != VLC_FOURCC('D','A','T','A') )        {            msg_Dbg( p_demux, "invalid size for object %4.4s", (char*)&i_id );            return VLC_EGENERIC;        }        i_skip = i_size - 10;        if( i_id == VLC_FOURCC('.','R','M','F') )        {            if( stream_Read( p_demux->s, header, 8 ) < 8 ) return VLC_EGENERIC;            msg_Dbg( p_demux, "    - file version=0x%x num headers=%d",                     GetDWBE( &header[0] ), GetDWBE( &header[4] ) );            i_skip -= 8;        }        else if( i_id == VLC_FOURCC('P','R','O','P') )        {            int i_flags;            if( stream_Read(p_demux->s, header, 40) < 40 ) return VLC_EGENERIC;            msg_Dbg( p_demux, "    - max bitrate=%d avg bitrate=%d",                     GetDWBE(&header[0]), GetDWBE(&header[4]) );            msg_Dbg( p_demux, "    - max packet size=%d avg bitrate=%d",                     GetDWBE(&header[8]), GetDWBE(&header[12]) );            msg_Dbg( p_demux, "    - packets count=%d", GetDWBE(&header[16]) );            msg_Dbg( p_demux, "    - duration=%d ms", GetDWBE(&header[20]) );            msg_Dbg( p_demux, "    - preroll=%d ms", GetDWBE(&header[24]) );            msg_Dbg( p_demux, "    - index offset=%d", GetDWBE(&header[28]) );            msg_Dbg( p_demux, "    - data offset=%d", GetDWBE(&header[32]) );            msg_Dbg( p_demux, "    - num streams=%d", GetWBE(&header[36]) );             /* set the duration for export in control */            p_sys->i_our_duration = (int)GetDWBE(&header[20]);             p_sys->i_index_offset = GetDWBE(&header[28]);            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';                EnsureUTF8( psz );                msg_Dbg( p_demux, "    - title=`%s'", psz );                p_sys->psz_title = 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';                EnsureUTF8( psz );                msg_Dbg( p_demux, "    - author=`%s'", psz );                p_sys->psz_artist = 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';                EnsureUTF8( psz );                msg_Dbg( p_demux, "    - copyright=`%s'", psz );                p_sys->psz_copyright = 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';                EnsureUTF8( psz );                msg_Dbg( p_demux, "    - comment=`%s'", psz );                p_sys->psz_description = 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') )

⌨️ 快捷键说明

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