PDA

View Full Version : How to detect an output filter


rse
13th January 2008, 23:34
Hi!

Iīm programming my own media player with Lazarus using DShow without any manipulation of the filter graph. Mostly either the graph cannot be built or it plays fine, but sometimes it can be built but doesnīt play anyways. For example a m3u-file will build a graph but wonīt play. The only filter in the chain is the ram source filter, no output, nothing. Problem is: The filter chain has a length, but it wonīt progress so that it never comes to an end.

I want to detect such behavior and kick this file from the playlist, like the files that wonīt build a filterchain at all. But how can I detect it? I can only think of one thing: Testing the filter chain for output-devices like "Video Renderer", "Default DirectSound Device" or "DSound Renderer". There is only one catch: How can I be sure to detect _any_ output filter that outputs sound or video? There may be others probably. Probably they have other names in other language windows systems (which could be no problem if I tested for the CLSID instead...). If so, I would probably kick an otherwise working file. Do you have any suggestions?

JohnnyMalaria
14th January 2008, 00:33
QueryInterface for IBasicVideo or IBasicAudio would probably work.

rse
14th January 2008, 02:03
Reading the remarks on
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/htm/defaultdirectsounddevicefilter.asp
I think that a test for either "DirectSound Renderer" or any filter in the category "CLSID_AudioRendererCategory" will cover any possible audio output filter. Probably the "CLSID_MidiRendererCategory" needs to be included, too. For Video there seems to be no Category and the "Video Renderer" filter seems to be the only video output filter. Would it be possible that there was any (proprietary) other non-windows output filter which wasnīt in one of these categorys and therefore wouldnīt be covered by this test?

Assuming that the CLSID wonīt change in different versions of DShow I think probably a search for a matching CLSID in the filter chain would be faster and not less appropriate than the test for an IBasicVideo or IBasicAudio interface, because according to the documentation these are only implemented by the "Video Renderer" filter and the "Audio Renderer (WaveOut)" and "DirectSound Renderer" filter. What do you think? Iīm only a newbie in DShow programming ;-)

JohnnyMalaria
14th January 2008, 15:15
I had thought about the CLSID_xxxx option but wondered if a filter might exist that is not registered as one of the standard filter categories.

Certainly, testing for any of the ones listed in the MS documentation would help. If none show up, querying the graph for IBasicAudio and IBasicVideo would tell you if any filters are present that renderer audio or video.

BTW, are you using Render() to create the downstream graph? If you are and you want to force DirectShow to use a specific filter (instead of the default ones), you can use RenderEx()

rse
14th January 2008, 17:17
Testing for IBasicAudio or IBasicVideo only if no matching CLSID is found is a great idea! That gives good performance if everything is good and itīs very tough if something might be wrong.

The goal of this player was to use DirectShow with as less intervention as possible. So I will continue to use Render(). The only thing where RenderEx() would be needed would be a possibility for the user to build its own filter graphs by hand with an interface similar to graphedit, but thatīs only probably planned for the future ;-)