PDA

View Full Version : callback - frameReady timing



Unregistered
January 28, 2004, 09:54:14
Hi Everyone

I'm using grab continous mode to recieve video frames , is there a way to clear the buffer/stack in order to make sure I get a new video frame ?

Stefan Geissler
January 28, 2004, 13:55:17
Hello,

There is no exact way to clear the buffers in the filter chain of DirectShow. But you can drop frames that are too old. In the Clistener class (derived from GrabberListener) declare a member


REFERENCE_TIME m_GrabberRefTime; // Running time of the Grabber

Implement the frameReady() as follows:


void CListener::frameReady( Grabber& param, smart_ptr<MemBuffer> pBuffer, DWORD FrameNumber)
{
tsMediaSampleDesc MediaSampleDesc;
REFERENCE_TIME GrabberStartTime;
pBuffer->lock();
// Compare the sample time of the incomming MemBuffer with the previoulsy
// saved Grabber reference time. If the sample time of the Membuffer is
// less (older) than the saved grabber reference time, the frame in the
// MemBuffer will not be processed.

MediaSampleDesc = pBuffer->getSampleDesc();

if( MediaSampleDesc.SampleEnd >= m_GrabberRefTime )
{
DoImageProcessing( pBuffer ); // Do something
DrawBuffer(pBuffer); // Do something more

// Get the current grabber reference time. This time needed to check, whether
// the MemBuffers that will come in, are not too old.
param.getGraphStartReferenceTime(GrabberStartTime) ;
param.getCurReferenceTime(m_GrabberRefTime);
m_GrabberRefTime -= GrabberStartTime;
}
pBuffer->unlock();
}

webmice
April 1, 2004, 18:57:16
How to Define ????

Stefan Geissler
April 2, 2004, 08:43:41
How to define what? I do not understand your question.

webmice
April 2, 2004, 10:56:46
what is m_GrabberRefTime ???

Stefan Geissler
April 2, 2004, 11:34:08
In the Clistener class (derived from GrabberListener) declare a member


REFERENCE_TIME m_GrabberRefTime; // Running time of the Grabber

This means, add this line of code to CListener class in listener.h

A "member" is a variable in a class. In oop, variables of a class are named "member" or "attribute". Functions are named "methods".