If you've been reading this blog this week, you probably noticed am attempting to make a WPF control that allows a developer to play DVDs rendered WPF. I had some reasonable success, but the project had to be hard-coded way to much. For instance I required 3rd party DVD filters and two (count them, TWO!) FFDShow filters to even make the DirectShow graph work. The problem lies in the design of the VideoRendererElement. I expected to always be able to use the SampleGrabber filter to get samples from the DirectShow graph and just pump them into the VRE. Well it turns out the SampleGrabber is not compatible with VIDEOINFOHEADER2, the media type used by MPEG2, probably for the extra interlace information. So to get DVDs in WPF cleanly:
1.) I need to modify the VRE to be more flexible so all the AMMediaType fields can be set.
2.) I need to make my own SampleGrabber filter that does play nice with VIDEOINFOHEADER2. This may be a DirectShow renderer filter.
The VRE should, in theory, be able to play DVDs out of the box, without the menagerie of 3rd party filters I have to use right now.
These changes could also pave the way for adding the ability to play audio/video files embedded in your DLLs. Imagine being able to point to a "pack://application:,,,/MyVideo.wmv" in your XAML. Maybe if not from your resource file, but any System.IO.Stream? That may be handy.
I don't foresee any huge changes to the VRE API. I was thinking something like this (for you DirectShow folks):
//Tell VRE to get samples from the VRE input renderer
videoRendererElement.UseInputRenderer = true;
//Add the input renderer to the filter graph which is rendering the media, such as a DVD graph
myDShowFilterGraph.AddFilter(videoRendererElement.InputRenderer, "VRE Renderer")
Now that you have this custom renderer in your DVD graph, when it runs, it will automagically pump the samples into the VRE, no more messy SampleGrabber crap and very simple integration with DirectShow...Of course I'll still have the simple GDI and pixel buffer update hooks.
Feel free to give any feedback on things you'd like to see or ridicule about my approach :)!