locked
Anyone have an example of how to use IMFSampleGrabberSinkCallback?? RRS feed

  • Question

  • I am struggling to instantiate an instance of this type - anyone have a code sample on how to do it?

    Thanks

    Gareth
    Tuesday, January 12, 2010 8:37 PM

Answers

  • I do not believe we have any samples that use the IMFSampleGrabberSinkCallback interface.  However, there are some examples in the MF SDK samples of implementing other interfaces -- I know IMFAsyncCallback is implemented in the SDK samples.  The general idea is the same, though the functions will be different.

    Essentially what you want is a class that inherits from IMFSampleGrabberSinkCallback and implements its methods.  Note that IMFSampleGrabberSinkCallback inherits from IUnknown like all COM interfaces, so you have to implement IUnknown as well.  The ATL has helper objects that implement IUnknown for you, but either way there are plenty of articles on how to implement IUnknown if you search MSDN for 'implementing IUnknown'.  Your class declaration should look something like below.  Then you just need to write the definition for each method -- for example, defining OnProcessSample and passing the sample data off to your application.  If you have more specific questions, let me know.

    class CMySampleGrabberSinkCallback
        : public IMFSampleGrabberSinkCallback
    {
        // IUnknown
        STDMETHOD_(ULONG, AddRef)();
        STDMETHOD_(ULONG, Release)();
        STDMETHOD(QueryInterface)(REFIID riid, LPVOID* ppvObject);
    
        // IMFSampleGrabberSinkCallback
        STDMETHOD(OnProcessSample)(REFGUID guidMajorMediaType, DWORD dwSampleFlags, LONGLONG llSampleTime, LONGLONG llSampleDuration, const BYTE* pSampleBuffer, DWORD dwSampleSize);
        STDMETHOD(OnSetPresentationClock)(IMFPresentationClock* pPresentationClock);
        STDMETHOD(OnShutdown)();
    }
    Monday, January 18, 2010 2:52 AM