2

Few days ago, I wanted to give Media Foundation a try.

The first thing I've noticed is that is doesn't play an MPEG2 file (at least not on Windows 7), however, Windows Media Player 12 does. Therefore, I've ran mftrace wmplayer.exe and examined the output.

9052,2BF4 14:06:36.00364 COle32ExportDetours::CoCreateInstance @ Created {14D7A407-396B-44B3-BE85-5199A0F0F80A} Media Foundation DShow Source Resolver (C:\Windows\SysWOW64\mfds.dll) @0984E950 - traced interfaces: 
9052,1BEC 14:06:36.00450 COle32ExportDetours::CoCreateInstance @ Created {CDA42200-BD88-11D0-BD4E-00A0C911CE86} Filter Mapper2 (C:\Windows\SysWOW64\quartz.dll) @0821B894 - traced interfaces: 
9052,2BF4 14:06:36.00723 COle32ExportDetours::CoCreateInstance @ Created {E436EBB3-524F-11CE-9F53-0020AF0BA770} Filter Graph (C:\Windows\SysWOW64\quartz.dll) @081C7DD0 - traced interfaces: IGraphBuilder @081C7DD0, IMediaControl @04E6D66C, 
9052,2BF4 14:06:36.00741 COle32ExportDetours::CoCreateInstance @ Created {0344EC28-5339-4124-A186-2E8EEF168785} MFSourceFilter (C:\Windows\SysWOW64\mfds.dll) @09934228 - traced interfaces: 
9052,2BF4 14:06:36.00742 CMFPlatExportDetours::MFStartup @ Version=0x00020070, dwFlags=0x00000000
9052,2BF4 14:06:36.01176 CGraphBuilderDetours::AddFilter @081C7DD0 filter: 'MF Source Filter'
9052,2BF4 14:06:36.01194 COle32ExportDetours::CoCreateInstance @ Created {336475D0-942A-11CE-A870-00AA002FEAB5} MPEG-I Stream Splitter (C:\Windows\SysWOW64\quartz.dll) @08084574 - traced interfaces: 
9052,2BF4 14:06:36.01238 COle32ExportDetours::CoCreateInstance @ Created {AFB6C280-2C41-11D3-8A60-0000F81E0E4A} MPEG-2 Demultiplexer (C:\Windows\SysWOW64\mpg2splt.ax) @082003E4 - traced interfaces: 
9052,2BF4 14:06:36.01328 COle32ExportDetours::CoCreateInstance @ Created {E1F1A0B8-BEEE-490D-BA7C-066C40B5E2B9} Microsoft DTV-DVD Audio Decoder (C:\Windows\SysWOW64\msmpeg2adec.dll) @0829C77C - traced interfaces: 
9052,2BF4 14:06:36.04667 COle32ExportDetours::CoCreateInstance @ Created {212690FB-83E5-4526-8FD7-74478B7939CD} Microsoft DTV-DVD Video Decoder (C:\Windows\SysWOW64\msmpeg2vdec.dll) @082C04BC - traced interfaces: 
9052,2BF4 14:06:36.04668 CGraphBuilderDetours::AddFilter @081C7DD0 filter: ''

It seems like they're creating a Media Source that uses DirectShow. They're building a DirectShow graph with an MFSourceFilter which, I guess, is passing the decoded audio/video information to Media Foundation. Because searching the web for MFSourceFilter doesn't help at all, I was wondering if anyone has used that MFSourceFilter before and where I should get started.

(I've already read the question decode MPEG1/2 video with Media Foundation but it doesn't contain what I'm looking for.)

2
  • WMP plays via DirectShow if it cannot via MF. Jul 22, 2013 at 7:45
  • Yes, but they still use MF for playing the DirectShow source (by using that MFSourceFilter). So basically, this is what I'm after. I want to know if I can reuse that MFSourceFilter. Jul 22, 2013 at 7:47

1 Answer 1

1

WMP uses Media Foundation, and if unlucky, detours via DirectShow.

Here is a sample WMP playback for MPEG-2 file in Windows 7. Windows Media Player built a DirectShow graph internally and picked on of the available MPEG-2 decoders.

enter image description here

This actual playback is backed by DirectShow entirely, the source on this playback is regular File Source (Async) Filter. WMP might be using the filter in question to obtain information (esp. media types) involved in playback or for other reasons specific to its internal implementation. Possibly even trying to substitute the source of the media to play, however what I see is that this filter is removed and regular DirectShow playback remains.

The bottom line is that Media Foundation DirectShow Wrapper and Source Resolver exist, but they are not documented, used by WMP temporarily (possibly used by MF transparently) and not used on actual playback. Hence, nothing to reuse at the moment.

One of the possible scenarious for this filter that I can think of is to build internal DirectShow topology to provide metadata information for MF client.

4
  • The mftrace output from wmplayer learns that they're using MFSourceFilter instead of the Video Renderer as output because they're passing the decoded output to MF. I know I can program this all by myself and fix bugs for years to come. So I'm wondering if this mechanism of wmplayer can be reused... Jul 22, 2013 at 7:54
  • You are describing something that switches back to DirectShow and takes it then back to Media Foundation to resolve the missing blocks. I don't think it's taking place: eventually WMP uses fully built DShow topology, even DShow interface for EVR. So WMP just plays it back entirely through DShow using its alternate code path, this is what believe is taking place. Jul 22, 2013 at 8:04
  • Some more info for you: WMP attempts to build the graph using MF Source Filter, then cleans up and build a playback graph from fresh. I suppose that for some (not MPEG-2) media it can work out with this undocumented filter, but I am not aware of any real cases. Jul 22, 2013 at 8:18
  • Well, guess you're right. In mftrace output, there are calls to IMFTransform::SetInputType/SetOutputTime/ProcessInput/ProcessOutput before playback happens. But since the calls come from an other threadid, they possibly have nothing to do with the directshow playback that happens afterwards. Jul 22, 2013 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.