Over the last 2 weeks, Rob and I have been working hard to get custom video streams into WPF without using WinForms. The issue with WPF is that the application has no access to the lower-level DirectShow stuff to control how the filter graph is built. This leaves the programmer with 2 choices: (1) build a custom WinForms user control and build the filter graph manually (2) register a custom protocol type that will allow DirectShow’s Intelligent Connect to build the graph you want via a specially formed URL.
Option #1 works, but doesn’t allow WPF to do any overlays on the video. This means that all overlays (text, timestamps, images, controls, etc) must be drawn at the DirectShow layer. This is difficult, inflexible, and bypasses all the visual effects power of WPF (not to mention to loose hardware acceleration).
Option #2 is the optimal solution, and was what we set out to prove. This option allows WPF to control the render surface, and thus provide all the overlay functionality the UI designer can expect from WPF. We succeed this week in proving that option #2 is possible, and one of our UI guys went off and used it to create a custom list box for choosing video (good job Brent). The video clips below are live and displayed in real time:

The videos are displayed using WPF MediaElement objects, and passing in a URL with our custom protocol type and the id of the camera to connect to. The great thing about WPF is that we get all the scaling, reflection, and overlays you see above for free. Another one of our UI guys (Nick) did a demo with live video playing on a 3D cube that can be rotated by the mouse. (UPDATED) Check it out:

You can find information about registering custom protocols at http://msdn2.microsoft.com/en-us/library/ms787558.aspx. The DirectShow documentation is at http://msdn2.microsoft.com/en-us/library/ms783323%28VS.85%29.aspx. We downloaded the Windows Vista Platform SDK and built off of the Push Source Filters sample.


I have made a project you may be interested in. It allows for any video to be pumped into the MediaElement, so you have full flexibility with the video. Here is a link to the project on codeplex.
http://www.codeplex.com/VideoRendererElement
-Jer
Reply
Hey Tom,
Do you have any code to share with this technique? I’d love to see your latest and see how you were able to finish it out…
Thanks,
James
Reply
Tom reply on August 26th, 2008 5:25 pm:
James,
I’m sorry, but the code is proprietary to my employer. However, with the release of .NET 3.5 SP1, it is possible to achieve the same thing without this DirectShow work-around. Look at the D3DImage object and THIS article on CodeProject. Performance still needs to be evaluated, but I don’t foresee a significant amount of overhead given what we know about how the MIL works.
-Tom
Reply
James Chittenden reply on August 28th, 2008 10:06 pm:
Thanks, Tom!
Reply
Hi Tom,
I just released an open-source project for integrating DirectShow and WPF via the new D3DImage. Lemme know what you think!
Btw, didn’t know you worked at Pelco! We just finished an integration with your product!
-Jer
Reply
OH yeah, the url is:
http://www.codeplex.com/WPFMediaKit
Reply