Building a playback app (DShow vs. MF vs. OCX)
If you want to add audio/video playback capabilities to your Windows application, you have several options to choose from. For tighter control, you can take advantage of the API exposed in lower-level infrastructure components, like DirectShow, the Format SDK, or Media Foundation. If you just want generic, universal playback functionality, you can use the WMP OCX.
I think it’s a common misconception that the OCX is only used for embedding in web pages, in places like gamespot.com or cnn.com. In fact, the OCX can be embedded in a standalone app and used solely for its playback infrastructure, without the user even knowing that it’s there. Media Center for example uses the OCX for some of its playback paths even though from the user perspective, you wouldn’t know that there are completely different pipelines being used when switching between DVD, TV, or WMV.
In Windows Vista, there are a lot of benefits to using MF, including enhanced glitch resilience. But there are still limitations in terms of the video formats supported natively in MF, and a simple intuitive programming model. DShow has been the defacto Windows A/V standard for the last several versions of Windows, but it doesn’t have a high-level API to program to, neither is it particularly resilient to system load in Windows Vista.
The OCX provides a sophisticated playback model that spans all the different pipelines, while maintaining a relatively easy API. Rollover is a big piece of functionality that the OCX provides, in that it will always choose the most optimal playback pipeline and then roll back as it needs to. The OCX also has some limitations in terms of overhead (namely playlist support) and trying to overlay text or other UI on top of the video (including if you try to use a non-rectangular video surface), but it is otherwise a solid mid-weight playback solution.
For future versions of Windows we’re looking at simplifying the playback story – making it easier to embed playback functionality into apps without having to deal with the complexities of different playback infrastructures without some of the current limitations in the OCX.
11/2/06 Addendum:
I just came across a whitepaper that a coworker of mine wrote that goes into a bit more detail on this for those that are interested. I would’ve taken it a different direction - maybe started it off with a joke about three guys who go into a bar - but hey, it’s still a good write-up. Enjoy! http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwmt/html/t_d_migrating_from_directshow_to_media_foundation__cyor.asp