Need a callback per frame
Thanks,
Jake
Thanks,
Jake
ISampleGrabber::SetCallback( pMyCallback, 0 );
The zero tells the sample grabber to call you back with a pointer to the original media sample. No data copy is made.
See ISampleGrabber::SetCallback docs for more info.
Also see Using the Sample Grabber.
-Nick
Read this post and I think that it would help me also. All I need to for a function to be called when the frame is updated (I don't need the buffer) but I'm having a problem with setting up the callback, I want to call VideoFrame() on each frame, but I'm at a loss to set this up (old time C programmer who struggles w/ C++):
void VideoFrame();
BOOL Play(HWND hChildWnd, LPCWSTR szFileName, int top, int left);
IGraphBuilder *pGraph = NULL;
IMediaControl *pMediaControl = NULL;
IMediaEventEx *pEvent = NULL;
IVideoWindow *pVidWin = NULL;
IMediaSeeking *pMediaSeeking = NULL;
// For playback speedIBaseFilter *pGrabberF = NULL;
ISampleGrabber *pGrabber;
BOOL Play(HWND hChildWnd, LPCWSTR szFileName,
int top, int left){
AM_MEDIA_TYPE mt;
ISampleGrabberCB *pGrabberCB = NULL;
hr = CoInitialize(NULL);
// initialize Graphhr = CoCreateInstance( CLSID_FilterGraph, NULL, CLSCTX_INPROC,IID_IGraphBuilder, (
void **)&pGraph ); // Load the File to renderhr = pGraph->RenderFile(szFileName, NULL);
//Add Sample grabber filter and interfacehr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (
void**)&pGrabberF); hr = pGraph->AddFilter(pGrabberF, L"Sample Grabber");ZeroMemory(&mt,
sizeof(AM_MEDIA_TYPE)); mt.majortype = MEDIATYPE_Video; mt.subtype = MEDIASUBTYPE_RGB24;hr = pGrabber->SetMediaType(&mt);
hr = pGrabberF->QueryInterface(IID_ISampleGrabber, (
void**)&pGrabber);hr = pGrabber->SetCallback((ISampleGrabberCB *)VideoFrame,(
long)0); <FAILS//....Sets Events Notification, other stuff
}
void
VideoFrame(){
iVideoFrame++;
}
Thank you,
-- Justin
Jake