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

📄 access.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 2 页
字号:
    block_FifoRelease( p_sys->p_thread->p_empty_blocks );    for( i = 0; i < 64; i++ ) /* RTMP_HEADER_STREAM_INDEX_MASK */    {        if( p_sys->p_thread->rtmp_headers_recv[i].body != NULL )        {            free( p_sys->p_thread->rtmp_headers_recv[i].body->body );            free( p_sys->p_thread->rtmp_headers_recv[i].body );        }    }    net_Close( p_sys->p_thread->fd );    var_Destroy( p_access, "rtmp-caching" );    vlc_UrlClean( &p_sys->p_thread->url );    free( p_sys->p_thread->psz_application );    free( p_sys->p_thread->psz_media );    vlc_object_detach( p_sys->p_thread );    vlc_object_release( p_sys->p_thread );    free( p_sys );}/***************************************************************************** * Read: standard read on a file descriptor. *****************************************************************************/static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len ){    access_sys_t *p_sys = p_access->p_sys;    rtmp_packet_t *rtmp_packet;    uint8_t *tmp_buffer;    ssize_t i_ret;    size_t i_len_tmp;    i_len_tmp = 0;    while( i_len_tmp < i_len )    {        if( p_sys->p_thread->result_stop || p_access->info.b_eof || !vlc_object_alive (p_access) )        {            p_access->info.b_eof = true;            return 0;        }        if( p_sys->read_packet )        {            if( !p_sys->p_thread->metadata_received )            {                /* Wait until enough data is received for extracting metadata */                if( block_FifoCount( p_sys->p_thread->p_fifo_input ) < 10 )                {                    msleep(100000);                    continue;                }                p_sys->flv_packet = flv_get_metadata( p_access );                p_sys->p_thread->metadata_received = 1;            }            else            {                p_sys->flv_packet = block_FifoGet( p_sys->p_thread->p_fifo_input );                if( p_sys->flv_packet == NULL )                    continue; /* Forced wake-up */            }            if( p_sys->p_thread->first_media_packet )            {                p_sys->flv_packet = flv_insert_header( p_access, p_sys->flv_packet );                p_sys->p_thread->first_media_packet = 0;            }        }        if( i_len - i_len_tmp >= p_sys->flv_packet->i_buffer )        {            p_sys->read_packet = 1;            memcpy( p_buffer + i_len_tmp, p_sys->flv_packet->p_buffer, p_sys->flv_packet->i_buffer );            block_FifoPut( p_sys->p_thread->p_empty_blocks, p_sys->flv_packet );            i_len_tmp += p_sys->flv_packet->i_buffer;        }        else        {            p_sys->read_packet = 0;            memcpy( p_buffer + i_len_tmp, p_sys->flv_packet->p_buffer, i_len - i_len_tmp);            p_sys->flv_packet->i_buffer -= i_len - i_len_tmp;            memmove( p_sys->flv_packet->p_buffer, p_sys->flv_packet->p_buffer + i_len - i_len_tmp, p_sys->flv_packet->i_buffer );            i_len_tmp += i_len - i_len_tmp;        }    }    if( i_len_tmp > 0 )    {        if( p_sys->p_thread->result_publish )        {            /* Send publish onStatus event only once */            p_sys->p_thread->result_publish = 0;            rtmp_packet = rtmp_build_publish_start( p_sys->p_thread );            tmp_buffer = rtmp_encode_packet( p_sys->p_thread, rtmp_packet );            i_ret = net_Write( p_sys->p_thread, p_sys->p_thread->fd, NULL, tmp_buffer, rtmp_packet->length_encoded );            if( i_ret != rtmp_packet->length_encoded )            {                free( rtmp_packet->body->body );                free( rtmp_packet->body );                free( rtmp_packet );                free( tmp_buffer );                msg_Err( p_access, "failed send publish start" );                return -1;            }            free( rtmp_packet->body->body );            free( rtmp_packet->body );            free( rtmp_packet );            free( tmp_buffer );        }        p_access->info.i_pos += i_len_tmp;        rtmp_packet = rtmp_build_bytes_read( p_sys->p_thread, p_access->info.i_pos );        tmp_buffer = rtmp_encode_packet( p_sys->p_thread, rtmp_packet );         i_ret = net_Write( p_sys->p_thread, p_sys->p_thread->fd, NULL, tmp_buffer, rtmp_packet->length_encoded );        if( i_ret != rtmp_packet->length_encoded )        {            free( rtmp_packet->body->body );            free( rtmp_packet->body );            free( rtmp_packet );            free( tmp_buffer );            msg_Err( p_access, "failed send bytes read" );            return -1;        }        free( rtmp_packet->body->body );        free( rtmp_packet->body );        free( rtmp_packet );        free( tmp_buffer );    }    return i_len_tmp;}/***************************************************************************** * Seek: seek to a specific location in a file *****************************************************************************/static int Seek( access_t *p_access, int64_t i_pos ){    VLC_UNUSED( p_access );    VLC_UNUSED( i_pos );/*msg_Warn ( p_access, "Seek to %lld", i_pos);    switch( rtmp_seek( p_access, i_pos ) )    {        case -1:            return VLC_EGENERIC;        case 0:            break;        default:            msg_Err( p_access, "You should not be here" );            abort();    }*/    return VLC_EGENERIC;}/***************************************************************************** * Control: *****************************************************************************/static int Control( access_t *p_access, int i_query, va_list args ){    bool    *pb_bool;    int     *pi_int;    int64_t *pi_64;    switch( i_query )    {        /* */        case ACCESS_CAN_SEEK:        case ACCESS_CAN_FASTSEEK:            pb_bool = (bool*) va_arg( args, bool* );            *pb_bool = false; /* TODO */            break;        case ACCESS_CAN_PAUSE:            pb_bool = (bool*) va_arg( args, bool* );            *pb_bool = false; /* TODO */            break;        case ACCESS_CAN_CONTROL_PACE:            pb_bool = (bool*) va_arg( args, bool* );            *pb_bool = true;            break;        /* */        case ACCESS_GET_MTU:            pi_int = (int*) va_arg( args, int * );            *pi_int = 0;            break;        case ACCESS_GET_PTS_DELAY:            pi_64 = (int64_t*) va_arg( args, int64_t * );            *pi_64 = var_GetInteger( p_access, "rtmp-caching" ) * INT64_C(1000);            break;        /* */        case ACCESS_SET_PAUSE_STATE:            /* Nothing to do */            break;        case ACCESS_GET_TITLE_INFO:        case ACCESS_SET_TITLE:        case ACCESS_SET_SEEKPOINT:        case ACCESS_SET_PRIVATE_ID_STATE:        case ACCESS_GET_META:        case ACCESS_GET_CONTENT_TYPE: /* DOWN: comment this line */            return VLC_EGENERIC;        default:            msg_Warn( p_access, "unimplemented query in control" );            return VLC_EGENERIC;    }    return VLC_SUCCESS;}/***************************************************************************** * ThreadControl: manage control messages and pipe media to Read *****************************************************************************/static void* ThreadControl( vlc_object_t *p_this ){    rtmp_control_thread_t *p_thread = (rtmp_control_thread_t *) p_this;    rtmp_packet_t *rtmp_packet;    rtmp_init_handler( p_thread->rtmp_handler );    while( vlc_object_alive (p_thread) )    {        rtmp_packet = rtmp_read_net_packet( p_thread );        if( rtmp_packet != NULL )        {            if( rtmp_packet->content_type < 0x01 /* RTMP_CONTENT_TYPE_CHUNK_SIZE */                || rtmp_packet->content_type > 0x14 ) /* RTMP_CONTENT_TYPE_INVOKE */            {                free( rtmp_packet->body->body );                free( rtmp_packet->body );                free( rtmp_packet );                msg_Warn( p_thread, "unknown content type received" );            }            else                p_thread->rtmp_handler[rtmp_packet->content_type]( p_thread, rtmp_packet );        }        else        {            /* Sometimes server close connection too soon */            if( p_thread->result_connect )            {                vlc_mutex_lock( &p_thread->lock );                vlc_cond_signal( &p_thread->wait );                vlc_mutex_unlock( &p_thread->lock );            }            p_thread->b_die = 1;            ((access_t *) p_thread->p_base_object)->info.b_eof = true;            block_FifoWake( p_thread->p_fifo_input );        }    }    return NULL;}

⌨️ 快捷键说明

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