{"id":784,"date":"2009-01-29T23:11:45","date_gmt":"2009-01-29T21:11:45","guid":{"rendered":"https:\/\/alax.info\/blog\/?p=784"},"modified":"2009-01-29T23:11:45","modified_gmt":"2009-01-29T21:11:45","slug":"directshow-filter-graph-spy-clsid_filtergraphnothread","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/784","title":{"rendered":"DirectShow Filter Graph Spy &#8211; CLSID_FilterGraphNoThread"},"content":{"rendered":"<p>At the time of <a href=\"https:\/\/alax.info\/blog\/777\">original implementation<\/a> I intentionally left off a variation of <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd375786(VS.85).aspx\">Filter Graph Manager<\/a> that runs on application thread, CLSID_FilterGraphNoThread. MSDN says:<\/p>\n<p style=\"padding-left: 30px;\">CLSID_FilterGraphNoThread creates the Filter Graph Manager on the application&#8217;s thread. If you use this CLSID, the thread that calls CoCreateInstance must have a message loop that dispatches messages; otherwise, deadlocks can occur. Also, before the application thread exits, it must release the Filter Graph Manager and all graph objects (such as filters, pins, reference clocks, and so forth).<\/p>\n<p>I have never needed to use this CLSID (by the way Windows SDK has one more CLSID &#8211; CLSID_FilterGraphPrivateThread &#8211; but it does not seem to be documented) and for this reason I left it for the time a need in it comes up. However it appeared that this CLSID was not created just for fun, there was a need in it. Filter graphs of Windows Media Player playing well known Windows&#8217; clock.avi appeared to be not published on <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms684004%28VS.85%29.aspx\">Running Object Table<\/a>. Why?<\/p>\n<p><a href=\"http:\/\/technet.microsoft.com\/en-us\/sysinternals\/bb896645.aspx\">Process Monitor<\/a> showed clearly that Windows Media Player created filter graph through CLSID_FilterGraphNoThread and quite obviously it was not intercepted by <a href=\"https:\/\/alax.info\/blog\/777\">Filter Graph Spy<\/a> (still I wonder what made it different previous time when I could see WMP&#8217;s graph).<\/p>\n<p><a href=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2009\/01\/29-image001.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-785\" title=\"Another Windows Media Player Filter Graph\" src=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2009\/01\/29-image001-300x119.png\" alt=\"\" width=\"300\" height=\"119\" srcset=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2009\/01\/29-image001-300x119.png 300w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2009\/01\/29-image001.png 975w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><!--more--><\/p>\n<p>In order to extend spy&#8217;s support to CLSID_FilterGraphNoThread I moved most of the code from CSpy COM class into CSpyT template class and derived two COM classes from it, CSpy and CNoThreadSpy, in order to cover and &#8220;COM Treat As&#8221; both DirectShow\/Quartz COM classes.<\/p>\n<pre><span style=\"color: #3f5fbf;\">\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/<\/span>\r\n<span style=\"color: #696969;\">\/\/ CSpy<\/span>\r\n\r\n<span style=\"color: #800000; font-weight: bold;\">class<\/span> ATL_NO_VTABLE CSpy <span style=\"color: #800080;\">:<\/span>\r\n    <span style=\"color: #800000; font-weight: bold;\">public<\/span> CSpyT<span style=\"color: #800080;\">&lt;<\/span>CSpy<span style=\"color: #808030;\">,<\/span> <span style=\"color: #808030;\">&amp;<\/span>CLSID_FilterGraph<span style=\"color: #800080;\">&gt;<\/span><span style=\"color: #808030;\">,<\/span>\r\n    <span style=\"color: #800000; font-weight: bold;\">public<\/span> CComCoClass<span style=\"color: #800080;\">&lt;<\/span>CSpy<span style=\"color: #808030;\">,<\/span> <span style=\"color: #808030;\">&amp;<\/span>CLSID_Spy<span style=\"color: #800080;\">&gt;<\/span>\r\n<span style=\"color: #800080;\">{<\/span>\r\n<span style=\"color: #800000; font-weight: bold;\">public<\/span><span style=\"color: #e34adc;\">:<\/span>\r\n    <span style=\"color: #800000; font-weight: bold;\">enum<\/span> <span style=\"color: #800080;\">{<\/span> IDR <span style=\"color: #808030;\">=<\/span> IDR_SPY <span style=\"color: #800080;\">}<\/span><span style=\"color: #800080;\">;<\/span>\r\n\r\n<span style=\"color: #800000; font-weight: bold;\">public<\/span><span style=\"color: #e34adc;\">:<\/span>\r\n<span style=\"color: #696969;\">\/\/ CSpy<\/span>\r\n<span style=\"color: #800080;\">}<\/span><span style=\"color: #800080;\">;<\/span>\r\n\r\nOBJECT_ENTRY_AUTO<span style=\"color: #808030;\">(<\/span><span style=\"color: #800000; font-weight: bold;\">__uuidof<\/span><span style=\"color: #808030;\">(<\/span>Spy<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">,<\/span> CSpy<span style=\"color: #808030;\">)<\/span>\r\n\r\n<span style=\"color: #3f5fbf;\">\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/<\/span>\r\n<span style=\"color: #696969;\">\/\/ CNoThreadSpy<\/span>\r\n\r\n<span style=\"color: #800000; font-weight: bold;\">class<\/span> ATL_NO_VTABLE CNoThreadSpy <span style=\"color: #800080;\">:<\/span>\r\n    <span style=\"color: #800000; font-weight: bold;\">public<\/span> CSpyT<span style=\"color: #800080;\">&lt;<\/span>CNoThreadSpy<span style=\"color: #808030;\">,<\/span> <span style=\"color: #808030;\">&amp;<\/span>CLSID_FilterGraphNoThread<span style=\"color: #800080;\">&gt;<\/span><span style=\"color: #808030;\">,<\/span>\r\n    <span style=\"color: #800000; font-weight: bold;\">public<\/span> CComCoClass<span style=\"color: #800080;\">&lt;<\/span>CNoThreadSpy<span style=\"color: #808030;\">,<\/span> <span style=\"color: #808030;\">&amp;<\/span>CLSID_NoThreadSpy<span style=\"color: #800080;\">&gt;<\/span>\r\n<span style=\"color: #800080;\">{<\/span>\r\n<span style=\"color: #800000; font-weight: bold;\">public<\/span><span style=\"color: #e34adc;\">:<\/span>\r\n    <span style=\"color: #800000; font-weight: bold;\">enum<\/span> <span style=\"color: #800080;\">{<\/span> IDR <span style=\"color: #808030;\">=<\/span> IDR_NOTHREADSPY <span style=\"color: #800080;\">}<\/span><span style=\"color: #800080;\">;<\/span>\r\n\r\n<span style=\"color: #800000; font-weight: bold;\">public<\/span><span style=\"color: #e34adc;\">:<\/span>\r\n<span style=\"color: #696969;\">\/\/ CNoThreadSpy<\/span>\r\n<span style=\"color: #800080;\">}<\/span><span style=\"color: #800080;\">;<\/span>\r\n\r\nOBJECT_ENTRY_AUTO<span style=\"color: #808030;\">(<\/span><span style=\"color: #800000; font-weight: bold;\">__uuidof<\/span><span style=\"color: #808030;\">(<\/span>NoThreadSpy<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">,<\/span> CNoThreadSpy<span style=\"color: #808030;\">)<\/span><\/pre>\n<p>A partial Visual C++ .NET 2008 source code is <a href=\"http:\/\/code.assembla.com\/roatl-utilities\/subversion\/nodes\/trunk\/FilterGraphSpy\">available from SVN<\/a>, release binary <a href=\"http:\/\/code.assembla.com\/roatl-utilities\/subversion\/nodes\/trunk\/FilterGraphSpy\/Release%20Trace\/FilterGraphSpy.dll?format=raw\">included<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At the time of original implementation I intentionally left off a variation of Filter Graph Manager that runs on application thread, CLSID_FilterGraphNoThread. MSDN says: CLSID_FilterGraphNoThread creates the Filter Graph Manager on the application&#8217;s thread. If you use this CLSID, the thread that calls CoCreateInstance must have a message loop that dispatches messages; otherwise, deadlocks can&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/784\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,13,2],"tags":[487,38,78,119,163,488,164],"class_list":["post-784","post","type-post","status-publish","format-standard","hentry","category-atl","category-source","category-utilities","tag-atl","tag-c","tag-directshow","tag-filter","tag-graph","tag-source","tag-spy"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/784","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=784"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/784\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}