What debugging tools are available for directshow filters? Presently, I have a project that compiles and registers a video source filter that I then setup a graph in GraphE
In a debug build, the DirectShow base classes already include a flexible logging mechanism controlled by registry keys. The base classes themselves use this mechanism to log their own operation. If required it should be possible to modify the base classes so that logging is available in a diagnostic release build.
A simple example:
DbgLog(( LOG_TIMING, 1, TEXT(__FUNCTION__ " : Frame:%d, Stream Time:%dms, Sample Time:%dms"),
(int)currentFrame, (int)currentTime, (int)sampleTime ));
This produces log output prefixed by the name of the calling function if the logging level for the 'TIMING' category is set to >=1. Logging levels for each category are configured in the registry under the key below. There is a 'GLOBAL' sub-key for the minimum logging level for all filters and sub-keys for extra logging by filter file name.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectShow\Debug HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DirectShow\Debug (32bit code on x64 Windows).
Edit the 'LogToFile' key for each filter to specify a logging destination. This defaults to 'Debug' (debugger output) but can also be 'Console' to log to a console window, or a file name to log to. Other types of logging could be added too.
The console option is particularly convenient for live monitoring without a debugger. On my system the base classes fail to open a console window if not already open so I added the following tweak in wxdebug.cpp to open a console unconditionally if console output is requested.
if (!lstrcmpi(szFile, TEXT("Console"))) {
AllocConsole (); // modification - always allocate console if using Console output
See DirectShow Debug Output Functions for further information.