locked
Play video in directx via SetSourceFromByteStream in an IMFMediaEngineEx using InMemoryRandomAccessStream

    Question

  • Hi,

    I'm trying to pass a byteStream to IMFMediaEngine using a InMemoryRandomAccessStream but when I do so the player doesn't play anything.

    If I use an IRandomAccessStream from a file it works but if I pass an InMemoryRandomAccessStream the player simply doesn't play anything.

    I made a simple test which was first test the SetSource method of the IMFMediaEngineEx passing the URL of a video. It plays.

    Then, I changed the code creating my InMemoryRandomAccessStream from an HttpRequest to that URL which holds the bytes of the video and then I pass it to the IMFMediaEngineEx  using SetSourceFromByteStream  but nothing gets played.

    I tested my InMemoryRandomAccessStream and it has the correct bytes in it, I can read from it and I also could detect that the method ReadAsync in the InMemoryRandomAccessStream in fact gets called after I call SetSourceFromByteStream but nothing is displayed in the screen.

    What might be the issue here? Does SetSourceFromByteStream support InMemoryRandomAccessStream?

    By the way, what is the purpose of the pURL parameter in the SetSourceFromByteStream method? What should I pass there in the case of an InMemoryRandomAccessStream?

     

    Thank you!

    Thursday, August 23, 2012 2:46 PM

Answers

  • Hello,

    Q. Does this mean we can't have a producer/consumer stream to feed the ME? Is that possible using Media Engine and RAS? Or maybe using other APIs?

    A. The RAS must not be written to once it is handed to the ME. All of the data must be present in the RAS before you pass it to the ME. Failure to do so will cause undefined behavior and / or unexpected errors. There is no way to create a buffered network sink without writing a custom source component and registering a new protocol handler.

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/


    Tuesday, August 28, 2012 9:33 PM
    Moderator

All replies

  • Hello,

    You should be able to pass a random access stream (RAS) to the Media Engine (ME). However when sourcing the data from the network you need to verify that all of the data is present in memory before passing it to the ME. You also need to make sure that the RAS does not contain any of the HTTP header information that might have been sent along with your request data. You can verify that your data is correct by saving the data in your RAS to a file and then playing the file with the TopoEdit tool. If the file plays then you know your data is correct.

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Friday, August 24, 2012 12:10 AM
    Moderator
  • Thank you James for your reply.

    I'll make some more tests (like the ones you referred) to guarantee the data in the stream is correct but by the tests i've made so far the data in the stream seems ok.

    One question though, when you say "However when sourcing the data from the network you need to verify that all of the data is present in memory before passing it to the ME" does this mean we can't have a producer/consumer stream to feed the ME? My objective is to create a buffering mechanism having a process writing to the RAS (to create a buffer before the ME starts reading) and while the ME reads from that RAS the other process continues to feed the RAS with the remaining data. A mechanism like this would enable me to speed up the start of the video and also be able to process the data before passing it to the player.

    Currently I have all the data of the video in the InMemoryRandomAccessStream (so it should be working) and i'm doing nothing more than passing the bytes from the HTTP request to the RAS but my final goal is to have the mechanism like the one i described above. Is that possible using Media Engine and RAS? Or maybe using other APIs?

    Thank you,

    Helder


    Monday, August 27, 2012 12:11 AM
  • Hello,

    Q. Does this mean we can't have a producer/consumer stream to feed the ME? Is that possible using Media Engine and RAS? Or maybe using other APIs?

    A. The RAS must not be written to once it is handed to the ME. All of the data must be present in the RAS before you pass it to the ME. Failure to do so will cause undefined behavior and / or unexpected errors. There is no way to create a buffered network sink without writing a custom source component and registering a new protocol handler.

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/


    Tuesday, August 28, 2012 9:33 PM
    Moderator