locked
Sending an METransformNeedInput event from an Asynchronous MFT RRS feed

  • Question

  •  Hello

     In the MSDN documentation for the METransformNeedInput event, it is written that the event has to deliver the stream ID through its MF_EVENT_MFT_INPUT_STREAM_ID attribute, and that this event has to be sent through the IMFMediaEventGenerator interface.

     However, the  IMFMediaEventGenerator::QueueEvent method has no attribute input parameter, and the only way to pass a value through it is through its PROPVARIANT input parameter.

     Shall I convert this PROPVARIANT value to an attribute (in my implementation of QueEvent) in the special case the MediaEventType is METransformNeedInput,  or perhaps is it OK to pass the stream ID as a PROPVARIANT ?

    Thursday, September 30, 2010 3:03 PM

Answers

  • 1. Yes, METransformNeedInput is an out-of-band event, meaning that IMFMediaEventGenerator is used to send the event. This is different from the synchronous MFT model, where the MFT communicates state changes through the (synchronous) IMFTransform methods.

    2. The MF_EVENT_MFT_INPUT_STREAM_ID is set on the event object using IMFAttributes, which IMFMediaEvent inherits.

    3. The recommended way to implement IMFMediaEventGenerator is by using the IMFMediaEventQueue helper interface, which is described here:

    http://msdn.microsoft.com/en-us/library/ms696196(VS.85).aspx

    To send the event, you would do something like this:

    hr = MFCreateMediaEvent(METransformNeedInput, GUID_NULL, S_OK, NULL, &pEvent);
    if (SUCCEEDED(hr))
    {
     hr = pEvent->SetUINT32(MF_EVENT_MFT_INPUT_STREAM_ID, id);
     if (SUCCEEDED(hr))
     {
     hr = m_pEventQueue->QueueEvent(pEvent);
     }
    }

    (I didn't actually compile this, but that's the idea...)

    - Mike

     

     


     

    Mike Wasson (SDK Documentation)

    This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use.

    • Marked as answer by lorin_f Saturday, October 2, 2010 9:22 PM
    Saturday, October 2, 2010 5:33 PM

All replies

  •  It seems I can call MFCreateEventQueue to create an event queue, and then overload QueueEvent() with functions which call functions from the IMFMediaEventQueue interface - so that the implementation of QueueEvent() for the METransformNeedInput event would actually first call MFCreateMediaEvent() to create a  METransformNeedInput event, then create the MF_EVENT_MFT_INPUT_STREAM_ID attribute on this event and then call the  IMFMediaEventQueue::QueueEvent method to queue the event. Am I right ?
    Thursday, September 30, 2010 11:19 PM
  • IMFMediaEvent inherits IMFAttributes. You set the stream ID via the IMFAttributes interface which you cast from IMFMediaEvent. You parse a PROPVARIANT with the type VT_EMPTY. Once you've set the event up, you queue it.

    IMFMediaEvent* myEvent = blahblah //you create the event

    ((IMFAttributes*)myEvent)->SetUINT32(MF_EVENT_MFT_INPUT_STREAM_ID,0); //Sets the stream ID for the event to stream 0

    Thursday, September 30, 2010 11:22 PM
  •  Thank you, Nobby_, for your answer.

     It seems to me that I need the PROPVARIANT only if I use IMFMediaEventGenerator::QueueEvent(), but then IMFMediaEventGenerator::QueueEvent() doesn't have an event as its input parameter - only the event type.

     If you mean your answer would be the implementation of QueueEvent(), then how would I get the stream ID from the PROPVARIANT if its type is VT_EMPTY ?    

    Friday, October 1, 2010 12:03 AM
  • Hmmm, I haven't implemented my own MFT yet. Looking at the docos on Asynchronous MFTs though, it appears that you send downstream events through streams via the interface member IMFTransform::ProcessEvent(). You create the event using MFCreateMediaEvent(), then set the IMFAttribute for the stream number(as in my first post).

    As the documentation for Asynchronous MFTs outlines, events like METransformNeedInput are considered in-band events. By using IMFTransform::ProcessEvent(), this will generate the appropriate client-side response via IMFTransform::ProcessInput() and IMFTransform::ProcessOutput().

    IMFMediaEventGenerator::QueueEvent() is for processing out-band events in the case of MFTs.

    Hope this gives you a point in the right direction.

    Friday, October 1, 2010 3:46 AM
  •  First, thank you for your time and energy. It is important to clarify issues in this forum.

     As mentioned in the MSDN documentation (Asynchronous MFTs  , under "Events"), the METransformNeedInput even is actually an out-of-band event. An asynchronous MFT must implement the IMFMediaEventGenerator interface in dealing with asynchronous events, yet it seems this that this interface is not always a natural fit for events such as the METransformNeedInput event and workarounds are required, such as using the much more general  IMFMediaEventQueue interface, as in the example above, or sending info through the PROPVARIANT parameter and then type-cheking the event and parsing the PROPVARIANT as required (in the general case).  

    Friday, October 1, 2010 8:57 AM
  • 1. Yes, METransformNeedInput is an out-of-band event, meaning that IMFMediaEventGenerator is used to send the event. This is different from the synchronous MFT model, where the MFT communicates state changes through the (synchronous) IMFTransform methods.

    2. The MF_EVENT_MFT_INPUT_STREAM_ID is set on the event object using IMFAttributes, which IMFMediaEvent inherits.

    3. The recommended way to implement IMFMediaEventGenerator is by using the IMFMediaEventQueue helper interface, which is described here:

    http://msdn.microsoft.com/en-us/library/ms696196(VS.85).aspx

    To send the event, you would do something like this:

    hr = MFCreateMediaEvent(METransformNeedInput, GUID_NULL, S_OK, NULL, &pEvent);
    if (SUCCEEDED(hr))
    {
     hr = pEvent->SetUINT32(MF_EVENT_MFT_INPUT_STREAM_ID, id);
     if (SUCCEEDED(hr))
     {
     hr = m_pEventQueue->QueueEvent(pEvent);
     }
    }

    (I didn't actually compile this, but that's the idea...)

    - Mike

     

     


     

    Mike Wasson (SDK Documentation)

    This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use.

    • Marked as answer by lorin_f Saturday, October 2, 2010 9:22 PM
    Saturday, October 2, 2010 5:33 PM