This project is read-only.

Custom source

Topics: Windows 8 Xaml, Windows Phone 8
Dec 14, 2012 at 1:38 PM

Hi .

Could you tell me how I can customize processing of incoming stream.

I have a bytestream (it's custom container for video) which contains Audio (AAC) and Video (H.264) frames.

In Windows Phone 7 (and silverlight) I implemented my own MediaStreamSource which contains methods GetSample that can return frames from my bytestream. It's working fine. 
But now, in Win 8 I don't have this.

So how I can implement it with this Player Framework (maybe custom plugin, or something? )





Dec 14, 2012 at 5:17 PM

To support other streaming formats not natively supported by Windows in your app you need to ship Media Foundation Extensions with your app. This is the equivalent of a MediaStreamSource in Silverlight but must be written in C++. Once you have a media foundation extension built, add it to your project references and then you write a couple lines of code to connect it to the media foundation pipeline (MediaPlayer.MediaExtensionManager). After that, when you try to play that type of media in your app the media pipeline in Windows will call out to the custom extension to decode the stream.

Here is a good resource about custom extensions page on MSDN as well as a sample MPEG1 decoder.

Dec 14, 2012 at 8:03 PM

I don't believe that H.264 and AAC is not supported. More I hope that decoding of these formats is hardware accelerated.

All that I need is parse my stream and providing some interface parsed frames. But which interfaces or classes?

Dec 14, 2012 at 8:24 PM

MediaExtensionManager allows you to selectively choose where in the pipeline you want to insert custom code; it doesn't have to be at the decoding level since as you explain, H.264 and AAC are already supported. I think RegisterByteStreamHandler is what you want to parse the container.

Dec 17, 2012 at 3:10 PM
Edited Dec 17, 2012 at 3:11 PM

Here is another "just an idea" example:

However "devil is in the details" - all these MSDN samples are useless 'cause nobody needs MPEG1 decoder or uncompressed PCM audio sample. I'm trying to adapt my Silverlight solution to WinRT/Win8 but can't find any AAC/H.264 specific information... Seems like all about AAC/H.264 is a classified top-secret information that Microsoft should keep for own usage....

I've tried to modify MediaStreamSourceStream.cpp from sample mentioned above but don't have any luck. I'm getting some access violation exception from the "bowels" of NT kernel - it looks like some very specific AAC info is incorrect.

timgreenfield ,could you please provide some help to work with AAC/H.264? Or could you recommend someone who can help?


Dec 17, 2012 at 3:17 PM


I know a bit about AAC/H264 (Implemented 2 media projects using these formats for Windows Phone) so if you need some theoretical knowledges - you are welcome. 

More, for Windows Phone 8 and WinRT I'm planning to implement idea like this:

And I would be very happy if you join. 
A lot of code should be written in C++ and this is terrible, but what we can if we must =)





Dec 17, 2012 at 3:55 PM

Roman, thanks for the provided info! Actually I don't need theoretical knowledge for Silverlight implementation - I have already done 4 different container parsers/demuxers in managed code.

Now I have very specific task: I need to adapt my managed HLS solution (worked perfect on WP7/WP8/desktop) to the Win8/WinRT.

As for joining your project: thanks a lot for offering but I'm extremely busy now, not only with my job but with my home-brew projects (check marketplace for SeNSSoFT). I'm so sorry but can't join right now (may be later?). 

BTW, C++ isn't that terrible ;) (but I'm not touched C++ last 3 or 4 years - should work on C#). But I agree - MediaFoundation code and concept are very complicated and le me say kinda outdated (c++ samples looks like a 10 years old Direct Show samples). I prefer Silverlight concept - very clean and easy to understand.

WBR, Sergey

Dec 17, 2012 at 4:05 PM


I didn't mean join a project just a parcipiating in creating a work-around or something for adapting existing expirience to WinRT. 

And yes, I have silverlight-based implementation too that works fine for wp7, and can work in wp8 and desktop (but not winRT).

So, I think you still come to the necessary solution using MF or something like. (But if you find any others ways to do it - let me know, please ;) )




Dec 17, 2012 at 4:30 PM


"and desktop" - you mean in the "desktop" regular browser which can run Silverlight plugin? Yes, same to me: SL works fine but unfortunately Silverlight isn't supported in "store" apps (or "metro" apps or whatever apps - MS changes name too frequently :( ). And I still don't understand why SL isn't supported in "store" apps... Unbelievable but looks like MS prefer java script to SL :(

I still hope to implement wrapper (as on mentioned above sample MediaStreamSource). I believe it's the best way to re-use SL code (technically I already adapted my Sl code - now it's a common .NET C# - SL-specific classes already abstracted).

I only need one simple thing: a helpful guy who is a real expert in MF, and can provide a real help instead usual RTFM's. I'm ready to pay for the consultation but all my tries was ineffectual :(