none
Class implements IMFMediaEventGenerator to listen for events in its queue and call its own callback to handle events. RRS feed

  • Question

  • I have a DeviceMFT for video capture in my project. Within DMFT, I have various classes I want to send custom events (like RAW_FRAME_READY etc.. ) between classes . Say ,

    - I have ClassA that initiates ClassB and ClassC.

    - ClassB wants to send custom event to classA.

    - Based on the event, classA calls a method in ClassC.

    Am thinking to use ClassA as Media event generator, thereby ClassB , ClassC can queue events. 

    ClassA also implements IMFAsyncCallback and whenever any class queues event, ClassA::Invoke() handles the events and calls methods of other interfaces accordingly.

    class ClassA: public IMFMediaEventGenerator , public IMFAsyncCallback

    ClassA::ClassA

    {

     MFCreateEventQueue(&iQueue);

    BeginGetEvent(this,NULL); //>>> I want the same interface to listen for events in its queue

    }

    ClassA::BeginGetEvent()

    {

    <assume we have a working code here>

    }

    ClassA::EndGetEvent()

    {

    <assume we have a working code here>

    }

    ClassA::QueueEvent()

    {

    <assume we have a working code here>

    }

    ClassA::Invoke()

    {

    // Get callback for events in the queue

    HandleEvent();

    ....

    }

    Here are my queries 

    1) Can i use IMFMediaEventGenerator to queue custom events ? I see that MediaEventType is of DWORD type and I can define my own events.

    2) even though ClassB, ClassC generates events, they do not implement IMFMediaEventGenerator. Instead they use ClassA event queue. Is this an acceptable design ?

    3) As ClassA implements IMFMediaEventGenerator and IMFAsyncCallback , Can i call BeginGetevent(this,...) in ClassA i.e ClassA will be listening for any events in queue and then call its ::Invoke()



    Monday, October 7, 2019 1:20 AM

All replies

  • Hi,
    IMFMediaEventGenerator::QueueEvent specifies the event type. The event type is returned by the event's IMFMediaEvent::GetType method. For a list of event types, see Media Foundation Events.
    Refer to Windows_Classic_Sample, in CHWMFT.h, call BeginGetevent() in IMFMediaEventGenerator implementations and call Invoke() in IMFAsyncCallbackIM implementations.

    Best regards,

    Jeffrey


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Jeffrey Shao Tuesday, October 8, 2019 7:15 AM
    • Proposed as answer by Jeffrey Shao Monday, October 14, 2019 2:54 AM
    Monday, October 7, 2019 8:19 AM