vlc_linux/vlc-3.0.16/modules/access/dshow/dshow.cpp
/*****************************************************************************
 * ReadCompressed: reads compressed (MPEG/DV) data from the device.
 *****************************************************************************/
reads compressed (MPEG/DV) data from the device.
reads compressed ( MPEG / DV ) data from the device .
static block_t *ReadCompressed( stream_t *p_access, bool *eof )
{
    ComContext ctx( COINIT_MULTITHREADED );
    access_sys_t   *p_sys = (access_sys_t *)p_access->p_sys;
    dshow_stream_t *p_stream = p_sys->pp_streams[0];
    VLCMediaSample sample;
    vlc_mutex_lock( &p_sys->lock );
    if( p_stream->p_capture_filter->CustomGetPin()->CustomGetSample(&sample) != S_OK )
    {   
        vlc_cond_wait( &p_sys->wait, &p_sys->lock );
        vlc_mutex_unlock( &p_sys->lock );
        return NULL;
    }
    vlc_mutex_unlock( &p_sys->lock );
    block_t *p_block = NULL;
    uint8_t *p_data;
    int i_data_size = sample.p_sample->GetActualDataLength();
    if( i_data_size == 0 )
        goto out;
    p_block = block_Alloc( i_data_size );
    if( unlikely(p_block == NULL) )
        goto out;
    sample.p_sample->GetPointer( &p_data );
    memcpy( p_block->p_buffer, p_data, i_data_size );
out:
    (void) eof;
    return p_block;
}
static block_t * ReadCompressed ( stream_t * p_access , bool * eof ) { ComContext ctx ( COINIT_MULTITHREADED ) ; access_sys_t * p_sys = ( access_sys_t * ) p_access -> p_sys ; dshow_stream_t * p_stream = p_sys -> pp_streams [ 0 ] ; VLCMediaSample sample ; vlc_mutex_lock ( & p_sys -> lock ) ; if ( p_stream -> p_capture_filter -> CustomGetPin ( ) -> CustomGetSample ( & sample ) != S_OK ) { vlc_cond_wait ( & p_sys -> wait , & p_sys -> lock ) ; vlc_mutex_unlock ( & p_sys -> lock ) ; return NULL ; } vlc_mutex_unlock ( & p_sys -> lock ) ; block_t * p_block = NULL ; uint8_t * p_data ; int i_data_size = sample . p_sample -> GetActualDataLength ( ) ; if ( i_data_size == 0 ) goto out ; p_block = block_Alloc ( i_data_size ) ; if ( unlikely ( p_block == NULL ) ) goto out ; sample . p_sample -> GetPointer ( & p_data ) ; memcpy ( p_block -> p_buffer , p_data , i_data_size ) ; out : ( void ) eof ; return p_block ; }
ReadCompressed: reads compressed (MPEG/DV) data from the device.
ReadCompressed : reads compressed ( MPEG / DV ) data from the device .
/* There must be only 1 elementary stream to produce a valid stream
     * of MPEG or DV data */ /* Read 1 DV/MPEG frame (they contain the video and audio data) */ /* Get new sample/frame from the elementary stream (blocking). */ /* No data available. Wait until some data has arrived */ /*
     * We got our sample
     */ /* The caller got what he wanted */