SchemeHandler: Generating streams from media stored in locations not accessible to inbox ByteStream RRS feed

  • Question

  • Hi,

    We're trying to build a windows store app to play videos hosted in a Http server. Those videos are basically standard .mp4 files with h.264 encoding, and they are encrypted with a custom algorithm so no one can watch them without first decrypting. Since there's no way we can save a video file in local storage, because it is huge, we need to create Http Requests to progressively download it chunk-by-chunk, decrypt each chunk on-the-fly, and then give the resulting raw mp4/h.264 chunk (in some sort of IBuffer or IStream) to the platform to play in the MediaElement. This resembles a producer/consumer pattern. We don't want to decode the mp4/h.264 video and generating frames through MediaStreams and MediaSources, since the platform already does it for mp4/h.264. As far as we've been reading it seems possible with Scheme Handlers, but we couldn't find a sample with this producer/consumer pattern to play progressively downloaded video.

    We're not going to use PlayReady since we're building our own DRM mechanism.

    So far we've done our Scheme Handler and it can only read a local file to an IMFByteStream, and then get a MediaSource using the MFCreateSourceResolver() function, but it requires the whole data to be present inside the IMFByteStream, which is not suitable for our requirements.

    We've watched this nice Build session "Using media extensions to build great video playback apps" and at slide 12 of 38 it says Scheme Handlers could be used to generate our own streams, to access media stored in locations not accessible to inbox ByteStream, and to create a custom streaming protocol. It looks very powerful and promising, but it is short on samples for those 3 points.

    In short: where, in this pipeline, should we create http requests and feed the chunks to the platform?


    Thursday, November 8, 2012 4:29 PM


  • Hello Ricardo,

    That is a really good question. I think that you are in a bit of a grey area. I can think of two possible solutions for your scenario.

    1) Create a custom source.

    2) Create a custom mime type for the file.

    The first one will certainly work but you will need to create your own HTTP stack (although we have a sample to get you started). The second one *should* work but it might take some trial and error. I would personally investigate the second one first and if that doesn't work just go ahead and write the custom source.

    I will only discuss the second option as the first is self explanatory. What we want is for MF to load the standard HTTP source and then based on the file type load your decryption MFT. We would register the MFT as if it were a codec. We would make sure the scheme was HTTP and the file type was .XYZ. You should then be able to output the raw h.264 frames from your MFT and MF should load the in box h.264 decoder. Notice there are a lot of "should's" in that sentence. In other words, I can't guarantee that it will work. But if I were in your situation I would certainly give it a try since it would save on having to implement a custom and potentially error prone HTTP stack.

    This sample shows how to write a custom scheme handler and source.

    Real-time communication sample



    I hope this helps,


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

    Wednesday, November 21, 2012 1:09 AM