{"id":989,"date":"2009-07-23T09:26:16","date_gmt":"2009-07-23T07:26:16","guid":{"rendered":"https:\/\/alax.info\/blog\/?p=989"},"modified":"2009-07-23T10:34:53","modified_gmt":"2009-07-23T08:34:53","slug":"iamgraphbuildercallback-and-intelligent-connect-tuning","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/989","title":{"rendered":"IAMGraphBuilderCallback and Intelligent Connect tuning"},"content":{"rendered":"<p>There was a question asked about how <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd389376%28VS.85%29.aspx\">IAMGraphBuilderCallback<\/a> interface is used to prevent from particular filter insertion during <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd390342%28VS.85%29.aspx\">Intelligent Connect<\/a>.<\/p>\n<p>First of all, there is sample code at <a href=\"http:\/\/tmhare.mvps.org\/downloads.htm\">The March Hare<\/a>&#8216;s website:<\/p>\n<p style=\"padding-left: 30px;\">The IAMGraphBuilderCallback class can be used to  remove problematic dshow filters when building a graph with intelligent connect.\u00a0  This sample does not provide the UI to blacklist filters but will give you a  better head start than the information in the documentation.\u00a0 See the  header file for an example of how to use it in your code.\u00a0 Add your own  code to the SelectedFilter or CreatedFilter methods to remove any unwanted  filters.<\/p>\n<p>The idea behind the method can be easily illustrated with a code snippet. Each time <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd375786%28VS.85%29.aspx\">Filter Graph Manager<\/a> considers trying a filter, before its instantiation it calls (if provided) <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd389378(VS.85).aspx\">IAMGraphBuilderCallback::SelectedFilter<\/a> method, where there is an option to reject it (before it even was instantiated using <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms686615%28VS.85%29.aspx\">CoCreateInstance<\/a>).<\/p>\n<p>The code snippet below checks selected filter and instructs to reject it if it is an <a href=\"http:\/\/sourceforge.net\/projects\/ffdshow\/\">FFDshow<\/a> Audio Decoder filter.<\/p>\n<pre><span style=\"color: #696969;\">\/\/ IAMGraphBuilderCallback<\/span>\r\nSTDMETHOD<span style=\"color: #808030;\">(<\/span>SelectedFilter<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">(<\/span>IMoniker<span style=\"color: #808030;\">*<\/span> pMoniker<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800000; font-weight: bold;\">throw<\/span><span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800080;\">{<\/span>\r\n    ATLTRACE<span style=\"color: #808030;\">(<\/span>atlTraceCOM<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">4<\/span><span style=\"color: #808030;\">,<\/span> _T<span style=\"color: #808030;\">(<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #0000e6;\">...<\/span><span style=\"color: #0f69ff;\">\\n<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\r\n    _ATLTRY\r\n    <span style=\"color: #800080;\">{<\/span>\r\n        ATLASSERT<span style=\"color: #808030;\">(<\/span>pMoniker<span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\r\n        <span style=\"color: #800000; font-weight: bold;\">const<\/span> CStringW sMonikerDisplayName <span style=\"color: #808030;\">=<\/span> _FilterGraphHelper<span style=\"color: #800080;\">::<\/span>GetMonikerDisplayName<span style=\"color: #808030;\">(<\/span>pMoniker<span style=\"color: #808030;\">,<\/span> <span style=\"color: #7d0045;\">NULL<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\r\n        ATLTRACE<span style=\"color: #808030;\">(<\/span>atlTraceGeneral<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">4<\/span><span style=\"color: #808030;\">,<\/span> _T<span style=\"color: #808030;\">(<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #0000e6;\">sMonikerDisplayName <\/span><span style=\"color: #0f69ff;\">%ls<\/span><span style=\"color: #0f69ff;\">\\n<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">,<\/span> sMonikerDisplayName<span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\r\n        <span style=\"color: #800000; font-weight: bold;\">static<\/span> <span style=\"color: #800000; font-weight: bold;\">const<\/span> <span style=\"color: #603000;\">LPCTSTR<\/span> g_pszFfdshowAudioDecoderClassIdentifier <span style=\"color: #808030;\">=<\/span> _T<span style=\"color: #808030;\">(<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #0000e6;\">{0F40E1E5-4F79-4988-B1A9-CC98794E6B55}<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\r\n        <span style=\"color: #800000; font-weight: bold;\">if<\/span><span style=\"color: #808030;\">(<\/span>sMonikerDisplayName<span style=\"color: #808030;\">.<\/span>Find<span style=\"color: #808030;\">(<\/span>CStringW<span style=\"color: #808030;\">(<\/span>g_pszFfdshowAudioDecoderClassIdentifier<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">)<\/span> <span style=\"color: #808030;\">&gt;<\/span><span style=\"color: #808030;\">=<\/span> <span style=\"color: #008c00;\">0<\/span><span style=\"color: #808030;\">)<\/span>\r\n            <span style=\"color: #800000; font-weight: bold;\">return<\/span> E_FAIL<span style=\"color: #800080;\">;<\/span> <span style=\"color: #696969;\">\/\/ Die!<\/span>\r\n    <span style=\"color: #800080;\">}<\/span>\r\n    _ATLCATCH<span style=\"color: #808030;\">(<\/span>Exception<span style=\"color: #808030;\">)<\/span>\r\n    <span style=\"color: #800080;\">{<\/span>\r\n        <span style=\"color: #800000; font-weight: bold;\">return<\/span> Exception<span style=\"color: #800080;\">;<\/span>\r\n    <span style=\"color: #800080;\">}<\/span>\r\n    <span style=\"color: #800000; font-weight: bold;\">return<\/span> S_OK<span style=\"color: #800080;\">;<\/span>\r\n<span style=\"color: #800080;\">}<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There was a question asked about how IAMGraphBuilderCallback interface is used to prevent from particular filter insertion during Intelligent Connect. First of all, there is sample code at The March Hare&#8216;s website: The IAMGraphBuilderCallback class can be used to remove problematic dshow filters when building a graph with intelligent connect.\u00a0 This sample does not provide&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/989\">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],"tags":[78,119,163,225],"class_list":["post-989","post","type-post","status-publish","format-standard","hentry","category-atl","tag-directshow","tag-filter","tag-graph","tag-iamgraphbuildercallback"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/989","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=989"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/989\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}