Пример #1
0
//
// OnReceiveFirstSample
//
// Use the image just delivered to display a poster frame
//
void CVideoRenderer::OnReceiveFirstSample(IMediaSample *pMediaSample)
{
    ASSERT(pMediaSample);

    DoRenderSample(pMediaSample);

} // OnReceiveFirstSample
void CTextureRenderer::OnReceiveFirstSample( IMediaSample * pSample )
{
    /* If the main thread is in MovieTexture_DShow::Create, kick: */
    if( m_OneFrameDecoded.GetValue() == 0 )
        m_OneFrameDecoded.Post();

    DoRenderSample( pSample );
}
Пример #3
0
BOOL CMpcAudioRenderer::ScheduleSample(IMediaSample *pMediaSample)
{
    REFERENCE_TIME		StartSample;
    REFERENCE_TIME		EndSample;

    // Is someone pulling our leg
    if (pMediaSample == NULL) {
        return FALSE;
    }

    // Get the next sample due up for rendering.  If there aren't any ready
    // then GetNextSampleTimes returns an error.  If there is one to be done
    // then it succeeds and yields the sample times. If it is due now then
    // it returns S_OK other if it's to be done when due it returns S_FALSE
    HRESULT hr = GetSampleTimes(pMediaSample, &StartSample, &EndSample);
    if (FAILED(hr)) {
        return FALSE;
    }

    // If we don't have a reference clock then we cannot set up the advise
    // time so we simply set the event indicating an image to render. This
    // will cause us to run flat out without any timing or synchronisation
    if (hr == S_OK) {
        EXECUTE_ASSERT(SetEvent((HANDLE) m_RenderEvent));
        return TRUE;
    }

    if (m_dRate <= 1.1) {
        ASSERT(m_dwAdvise == 0);
        ASSERT(m_pClock);
        WaitForSingleObject((HANDLE)m_RenderEvent,0);

        hr = m_pClock->AdviseTime( (REFERENCE_TIME) m_tStart, StartSample, (HEVENT)(HANDLE) m_RenderEvent, &m_dwAdvise);
        if (SUCCEEDED(hr)) {
            return TRUE;
        }
    } else {
        hr = DoRenderSample (pMediaSample);
    }

    // We could not schedule the next sample for rendering despite the fact
    // we have a valid sample here. This is a fair indication that either
    // the system clock is wrong or the time stamp for the sample is duff
    ASSERT(m_dwAdvise == 0);

    return FALSE;
}