locked
Custom MediaFoundation MediaSource error

    Question

  • Hi all,

    I came across with an issue about a custom MediaSource I'm developing and I couldn't find any documentation about my problem. I registered my custom source and it actually works when I set the source of the MediaElement object to a proper uri. But when I try to set the AutoPlay property to false, it fails. I get the MediaFailed event with the MF_E_UNSUPPORTED_SERVICE hresult. I debugged the IMFGetService's GetService method (which I implemented on the mediasource and where I return the previously mentioned hresult) and the framework asks for some interfaces I didn't implement because nothing was mentioned about them being mandatory.

    I could find info about these two:
    {B7E2BE11-2F96-4640-B52C-282365BDF16C} (IMFQualityAdvise)
    {E002AADC-F4AF-4EE5-9847-053EDF840426} (IMFMediaSourcePresentationProvider)
    Is it mandatory to implement them to have manual play control with MediaElement? (Actually it wouldn't make any sense but after 1 year of win8 development i'm not suprised about anything...)

    On the other hand, this one is absolutely unknown, at least i couldn't find anything about it: {F09992F7-9FBA-4C4A-A37F-8C47B4E1DFE7}. I did some step-by-step debugging and i got the mediafailed event right after I return MF_E_UNSUPPORTED_SERVICE as a response for the request asking this unknown interface.

    This is the only place where my component returns anything else but S_OK and the same thing happens with AutoPlay set to true but it plays nicely then. I tried not to implement IMFGetService but I got E_NOINTERFACE in that case.

    What am I doing wrong? I tried all the MediaFoundation samples I could find and they did the same thing (failed) when I turned off AutoPlay...Does anybody have any idea or experiance? Maybe I'm missing something but I'm getting desperate now..so any idea/info is appreciated.

    Thank you very much!

    Greets,
    David

    Tuesday, March 19, 2013 7:50 PM

Answers

  • Eventually I managed to solve the MediaFailed issue...apparently you must support IMFRateControl interface and have to be able to set the rate to 0 because that's what the framework tries to do when you set AutoPlay to false (i implemented the interface before but I always returned MF_E_UNSUPPORTED_RATE)...

    • Marked as answer by David Serfozo Wednesday, March 20, 2013 3:56 PM
    Wednesday, March 20, 2013 3:56 PM

All replies

  • Eventually I managed to solve the MediaFailed issue...apparently you must support IMFRateControl interface and have to be able to set the rate to 0 because that's what the framework tries to do when you set AutoPlay to false (i implemented the interface before but I always returned MF_E_UNSUPPORTED_RATE)...

    • Marked as answer by David Serfozo Wednesday, March 20, 2013 3:56 PM
    Wednesday, March 20, 2013 3:56 PM
  • Thanks for sharing the solution.

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 21, 2013 1:56 AM
  • Hey David,

    I, too, have implemented the IMFGetService and IMFRateControl interfaces but am still failing.

    How are you handling {F09992F7-9FBA-4C4A-A37F-8C47B4E1DFE7} since it is unknown (I cannot find a reference to it anywhere).

    The GetService method gets called with this GUID as an input argument and, since I cannot create a matching object, my GetService function returns MF_E_UNSUPPORTED_SERVICE which, in turn, causes the whole house of cards to fall.

    The call stack shows that my source is called by MFMediaEngine's IsMP4Source() function:

      H264Source.dll!CH264Source::GetService(const _GUID & guidService, const _GUID & riid, void * * ppvObject) 
      MFMediaEngine.dll!IsMP4Source(struct IMFMediaSource *)
      MFMediaEngine.dll!CMediaEngine::ConfigureStreams(struct IMFPMediaItem *)
      MFMediaEngine.dll!CMediaEngine::CompleteSourceCreation(struct IUnknown *)

    Thanks.

    Friday, April 19, 2013 3:35 AM
  • Never mind. I found the bug and it was, of course, in my own code. My MF_MT_SUBTYPE was wrong and didn't match the data format. 

    Thanks.

    Friday, April 19, 2013 5:05 PM