Changeset 545 for trunk/DirectShowSpy/FilterMapperSpy.h
- Timestamp:
- Nov 26, 2015, 3:24:03 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DirectShowSpy/FilterMapperSpy.h
r376 r545 17 17 18 18 #include "rodshow.h" 19 #include <..\Samples\multimedia\directshow\misc\mapper\fil_data.h>19 #include "fil_data.h" //<..\Samples\multimedia\directshow\misc\mapper\fil_data.h> 20 20 #include "Module_i.h" 21 21 #include "Common.h" … … 31 31 public IDispatchImpl<IFilterMapperSpy>, 32 32 public IAMFilterData, 33 public IFilterMapper2 33 public IFilterMapper, 34 public IFilterMapper3 34 35 { 35 36 typedef CFilterMapperSpyT<T, t_pFilterMapperClassIdentifier> CFilterMapperSpy; … … 44 45 DECLARE_GET_CONTROLLING_UNKNOWN() 45 46 46 DECLARE_QI_TRACE(CFilterMapperSpy )47 48 BEGIN_COM_MAP(CFilterMapperSpy )47 DECLARE_QI_TRACE(CFilterMapperSpyT) 48 49 BEGIN_COM_MAP(CFilterMapperSpyT) 49 50 COM_INTERFACE_ENTRY(IFilterMapperSpy) 50 51 COM_INTERFACE_ENTRY(IAMFilterData) 52 COM_INTERFACE_ENTRY(IFilterMapper3) 51 53 COM_INTERFACE_ENTRY(IFilterMapper2) 54 COM_INTERFACE_ENTRY(IFilterMapper) 52 55 COM_INTERFACE_ENTRY_AGGREGATE_BLIND(m_pInnerUnknown) 53 56 //COM_INTERFACE_ENTRY(IDispatch) … … 58 61 HINSTANCE m_hQuartzModule; 59 62 CComPtr<IUnknown> m_pInnerUnknown; 60 CComPtr<IFilterMapper2> m_pFilterMapper2; 63 CComPtr<IFilterMapper3> m_pFilterMapper3; 64 CComPtr<IFilterMapper> m_pFilterMapper; 61 65 CComPtr<IAMFilterData> m_pAmFilterData; 62 66 … … 64 68 { 65 69 _A(pFilterInformation); 66 _Z4(atlTraceCOM, 4, _T("pFilterInformation { dwVersion %d, dwMerit 0x%08 x, cPins2 %d }\n"), pFilterInformation->dwVersion, pFilterInformation->dwMerit, pFilterInformation->cPins2);70 _Z4(atlTraceCOM, 4, _T("pFilterInformation { dwVersion %d, dwMerit 0x%08X, cPins2 %d }\n"), pFilterInformation->dwVersion, pFilterInformation->dwMerit, pFilterInformation->cPins2); 67 71 if(pFilterInformation->dwVersion == 2) 68 72 for(ULONG nPinIndex = 0; nPinIndex < pFilterInformation->cPins2; nPinIndex++) 69 73 { 70 74 const REGFILTERPINS2& Pin = pFilterInformation->rgPins2[nPinIndex]; 71 _Z4(atlTraceCOM, 4, _T("pFilterInformation->rgPins2[%d] { dwFlags 0x% x, cInstances %d, nMediaTypes %d, nMediums %d }\n"), nPinIndex, Pin.dwFlags, Pin.cInstances, Pin.nMediaTypes, Pin.nMediums, Pin.clsPinCategory ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*Pin.clsPinCategory) : L"NULL");75 _Z4(atlTraceCOM, 4, _T("pFilterInformation->rgPins2[%d] { dwFlags 0x%X, cInstances %d, nMediaTypes %d, nMediums %d }\n"), nPinIndex, Pin.dwFlags, Pin.cInstances, Pin.nMediaTypes, Pin.nMediums, Pin.clsPinCategory ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*Pin.clsPinCategory) : L"NULL"); 72 76 for(UINT nIndex = 0; nIndex < Pin.nMediaTypes; nIndex++) 73 77 { … … 78 82 { 79 83 const REGPINMEDIUM& Medium = Pin.lpMedium[nIndex]; 80 _Z4(atlTraceCOM, 4, _T("pFilterInformation->rgPins2[...].lpMedium[%d] { clsMedium %ls, dw1 0x% x, dw2 0x%x}\n"), nIndex, _PersistHelper::StringFromIdentifier(Medium.clsMedium), Medium.dw1, Medium.dw2);84 _Z4(atlTraceCOM, 4, _T("pFilterInformation->rgPins2[...].lpMedium[%d] { clsMedium %ls, dw1 0x%X, dw2 0x%X }\n"), nIndex, _PersistHelper::StringFromIdentifier(Medium.clsMedium), Medium.dw1, Medium.dw2); 81 85 } 82 86 } 83 87 } 84 BOOL IsAggregated() const throw()88 BOOL IsAggregated() const 85 89 { 86 90 return (ULONG) m_dwRef >= 0x00001000; … … 89 93 public: 90 94 // CFilterMapperSpyT 91 static LPCTSTR GetOriginalLibraryName() throw()95 static LPCTSTR GetOriginalLibraryName() 92 96 { 93 97 return _T("quartz.dll"); … … 97 101 return _StringHelper::GetLine(T::IDR, 2); 98 102 } 99 static HRESULT WINAPI UpdateRegistry(BOOL bRegister) throw()103 static HRESULT WINAPI UpdateRegistry(BOOL bRegister) 100 104 { 101 105 _Z2(atlTraceRegistrar, 2, _T("bRegister %d\n"), bRegister); … … 110 114 return S_OK; 111 115 } 112 CFilterMapperSpyT() throw():116 CFilterMapperSpyT() : 113 117 m_hQuartzModule(NULL) 114 118 { 115 119 _Z4_THIS(); 116 120 } 117 ~CFilterMapperSpyT() throw()121 ~CFilterMapperSpyT() 118 122 { 119 123 _Z4_THIS(); 120 124 } 121 HRESULT FinalConstruct() throw()125 HRESULT FinalConstruct() 122 126 { 123 127 _ATLTRY … … 126 130 TCHAR pszPath[MAX_PATH] = { 0 }; 127 131 _W(GetModuleFileName(NULL, pszPath, DIM(pszPath))); 128 _Z4(atlTraceRefcount, 4, _T("pszPath \"%s\", this 0x% 08x, m_dwRef %d, m_bIsAggregated %d\n"), pszPath, this, m_dwRef, m_bIsAggregated);132 _Z4(atlTraceRefcount, 4, _T("pszPath \"%s\", this 0x%p, m_dwRef %d, m_bIsAggregated %d\n"), pszPath, this, m_dwRef, m_bIsAggregated); 129 133 const HINSTANCE hModule = CoLoadLibrary(const_cast<LPOLESTR>((LPCOLESTR) CT2COLE(GetOriginalLibraryName())), TRUE); 130 134 _ATLTRY … … 140 144 CComPtr<IUnknown> pUnknown; 141 145 __C(pClassFactory->CreateInstance(pControllingUnknown, __uuidof(IUnknown), (VOID**) &pUnknown)); 142 const CComQIPtr<IFilterMapper2> pFilterMapper2 = pUnknown; 143 __D(pFilterMapper2, E_NOINTERFACE); 144 pFilterMapper2.p->Release(); 146 const CComQIPtr<IFilterMapper3> pFilterMapper3 = pUnknown; 147 __D(pFilterMapper3, E_NOINTERFACE); 148 pFilterMapper3.p->Release(); 149 const CComQIPtr<IFilterMapper> pFilterMapper = pUnknown; 150 __D(pFilterMapper, E_NOINTERFACE); 151 pFilterMapper.p->Release(); 145 152 const CComQIPtr<IAMFilterData> pAmFilterData = pUnknown; 146 153 __D(pAmFilterData, E_NOINTERFACE); 147 154 pAmFilterData.p->Release(); 148 155 m_pInnerUnknown = pUnknown; 149 m_pFilterMapper2 = pFilterMapper2; 156 m_pFilterMapper3 = pFilterMapper3; 157 m_pFilterMapper = pFilterMapper; 150 158 m_pAmFilterData = pAmFilterData; 151 159 } … … 165 173 return S_OK; 166 174 } 167 VOID FinalRelease() throw()168 { 169 _Z5(atlTraceRefcount, 5, _T("m_dwRef 0x% x\n"), m_dwRef);175 VOID FinalRelease() 176 { 177 _Z5(atlTraceRefcount, 5, _T("m_dwRef 0x%X\n"), m_dwRef); 170 178 CComPtr<IUnknown> pControllingUnknown = GetControllingUnknown(); 171 if(m_pFilterMapper 2)179 if(m_pFilterMapper3) 172 180 { 173 181 pControllingUnknown.p->AddRef(); 174 m_pFilterMapper2 = NULL; 182 m_pFilterMapper3.Release(); 183 } 184 if(m_pFilterMapper) 185 { 186 pControllingUnknown.p->AddRef(); 187 m_pFilterMapper.Release(); 175 188 } 176 189 if(m_pAmFilterData) 177 190 { 178 191 pControllingUnknown.p->AddRef(); 179 m_pAmFilterData = NULL;192 m_pAmFilterData.Release(); 180 193 } 181 194 _ATLTRY 182 195 { 183 m_pInnerUnknown = NULL;196 m_pInnerUnknown.Release(); 184 197 } 185 198 _ATLCATCHALL() … … 199 212 200 213 // IAMFilterData 201 STDMETHOD(ParseFilterData)(BYTE* pnFilterData, ULONG nFilterDataSize, BYTE** ppFilterInformation) throw()214 STDMETHOD(ParseFilterData)(BYTE* pnFilterData, ULONG nFilterDataSize, BYTE** ppFilterInformation) override 202 215 { 203 216 _Z4(atlTraceCOM, 4, _T("nFilterDataSize %d\n"), nFilterDataSize); … … 214 227 return nResult; 215 228 } 216 STDMETHOD(CreateFilterData)(REGFILTER2* pFilterInformation, BYTE** ppnFilterData, ULONG* pnFilterDataSize) throw()229 STDMETHOD(CreateFilterData)(REGFILTER2* pFilterInformation, BYTE** ppnFilterData, ULONG* pnFilterDataSize) override 217 230 { 218 231 _Z4(atlTraceCOM, 4, _T("...\n")); … … 229 242 } 230 243 244 // IFilterMapper3 245 STDMETHOD(GetICreateDevEnum)(ICreateDevEnum** ppEnum) override 246 { 247 _Z4(atlTraceCOM, 4, _T("...\n")); 248 return m_pFilterMapper3->GetICreateDevEnum(ppEnum); 249 } 250 231 251 // IFilterMapper2 232 STDMETHOD(CreateCategory)(REFCLSID CategoryIdentifier, DWORD nMerit, LPCWSTR pszDescription) throw()233 { 234 _Z4(atlTraceCOM, 4, _T("CategoryIdentifier %ls, nMerit 0x%08 x, pszDescription \"%s\"\n"), _PersistHelper::StringFromIdentifier(CategoryIdentifier), nMerit, CString(pszDescription));235 return m_pFilterMapper 2->CreateCategory(CategoryIdentifier, nMerit, pszDescription);236 } 237 STDMETHOD(UnregisterFilter)(const CLSID* pCategoryIdentifier, LPCOLESTR pszInstance, REFCLSID FilterClassIdentifier) throw()252 STDMETHOD(CreateCategory)(REFCLSID CategoryIdentifier, DWORD nMerit, LPCWSTR pszDescription) override 253 { 254 _Z4(atlTraceCOM, 4, _T("CategoryIdentifier %ls, nMerit 0x%08X, pszDescription \"%s\"\n"), _PersistHelper::StringFromIdentifier(CategoryIdentifier), nMerit, CString(pszDescription)); 255 return m_pFilterMapper3->CreateCategory(CategoryIdentifier, nMerit, pszDescription); 256 } 257 STDMETHOD(UnregisterFilter)(const CLSID* pCategoryIdentifier, LPCOLESTR pszInstance, REFCLSID FilterClassIdentifier) override 238 258 { 239 259 _Z4(atlTraceCOM, 4, _T("pCategoryIdentifier %ls, pszInstance %s, FilterClassIdentifier %ls\n"), pCategoryIdentifier ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*pCategoryIdentifier) : L"NULL", pszInstance ? (LPCTSTR) AtlFormatString(_T("\"%s\""), CString(pszInstance)) : _T("NULL"), _PersistHelper::StringFromIdentifier(FilterClassIdentifier)); 240 return m_pFilterMapper 2->UnregisterFilter(pCategoryIdentifier, pszInstance, FilterClassIdentifier);241 } 242 STDMETHOD(RegisterFilter)(REFCLSID FilterClassIdentifier, LPCWSTR pszName, IMoniker** ppMoniker, const CLSID* pCategoryIdentifier, LPCOLESTR pszInstance, const REGFILTER2* pFilterInformation) throw()260 return m_pFilterMapper3->UnregisterFilter(pCategoryIdentifier, pszInstance, FilterClassIdentifier); 261 } 262 STDMETHOD(RegisterFilter)(REFCLSID FilterClassIdentifier, LPCWSTR pszName, IMoniker** ppMoniker, const CLSID* pCategoryIdentifier, LPCOLESTR pszInstance, const REGFILTER2* pFilterInformation) override 243 263 { 244 264 _Z4(atlTraceCOM, 4, _T("FilterClassIdentifier %ls, pszName \"%s\", pCategoryIdentifier %ls, pszInstance %s\n"), _PersistHelper::StringFromIdentifier(FilterClassIdentifier), CString(pszName), pCategoryIdentifier ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*pCategoryIdentifier) : L"NULL", pszInstance ? (LPCTSTR) AtlFormatString(_T("\"%s\""), CString(pszInstance)) : _T("NULL")); … … 252 272 _Z_EXCEPTION(); 253 273 } 254 return m_pFilterMapper 2->RegisterFilter(FilterClassIdentifier, pszName, ppMoniker, pCategoryIdentifier, pszInstance, pFilterInformation);255 } 256 STDMETHOD(EnumMatchingFilters)(IEnumMoniker** ppEnumMoniker, DWORD nFlags, BOOL bExactMatch, DWORD nMinimalMerit, BOOL bInputNeeded, DWORD nInputTypeCount, const GUID* pInputTypes, const REGPINMEDIUM* pInputMedium, const CLSID* pInputPinCategory, BOOL bRender, BOOL bOutputNeeded, DWORD nOutputTypeCount, const GUID* pOutputTypes, const REGPINMEDIUM* pOutputMedium, const CLSID* pOutputPinCategory) throw()257 { 258 _Z4(atlTraceCOM, 4, _T("nFlags 0x% x, bExactMatch %d, nMinimalMerit 0x%08x, bInputNeeded %d, nInputTypeCount %d, pInputPinCategory %ls, bRender %d, bOutputNeeded %d, nOutputTypeCount %d, pOutputPinCategory %ls\n"), nFlags, bExactMatch, nMinimalMerit, bInputNeeded, nInputTypeCount, pInputPinCategory ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*pInputPinCategory) : L"NULL", bRender, bOutputNeeded, nOutputTypeCount, pOutputPinCategory ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*pOutputPinCategory) : L"NULL");274 return m_pFilterMapper3->RegisterFilter(FilterClassIdentifier, pszName, ppMoniker, pCategoryIdentifier, pszInstance, pFilterInformation); 275 } 276 STDMETHOD(EnumMatchingFilters)(IEnumMoniker** ppEnumMoniker, DWORD nFlags, BOOL bExactMatch, DWORD nMinimalMerit, BOOL bInputNeeded, DWORD nInputTypeCount, const GUID* pInputTypes, const REGPINMEDIUM* pInputMedium, const CLSID* pInputPinCategory, BOOL bRender, BOOL bOutputNeeded, DWORD nOutputTypeCount, const GUID* pOutputTypes, const REGPINMEDIUM* pOutputMedium, const CLSID* pOutputPinCategory) override 277 { 278 _Z4(atlTraceCOM, 4, _T("nFlags 0x%X, bExactMatch %d, nMinimalMerit 0x%08X, bInputNeeded %d, nInputTypeCount %d, pInputPinCategory %ls, bRender %d, bOutputNeeded %d, nOutputTypeCount %d, pOutputPinCategory %ls\n"), nFlags, bExactMatch, nMinimalMerit, bInputNeeded, nInputTypeCount, pInputPinCategory ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*pInputPinCategory) : L"NULL", bRender, bOutputNeeded, nOutputTypeCount, pOutputPinCategory ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*pOutputPinCategory) : L"NULL"); 259 279 for(DWORD nInputTypeIndex = 0; nInputTypeIndex < nInputTypeCount; nInputTypeIndex++) 260 280 { … … 264 284 } 265 285 if(pInputMedium) 266 _Z4(atlTraceCOM, 4, _T("pInputMedium { clsMedium %ls, dw1 0x% x, dw2 0x%x}\n"), _PersistHelper::StringFromIdentifier(pInputMedium->clsMedium), pInputMedium->dw1, pInputMedium->dw2);286 _Z4(atlTraceCOM, 4, _T("pInputMedium { clsMedium %ls, dw1 0x%X, dw2 0x%X }\n"), _PersistHelper::StringFromIdentifier(pInputMedium->clsMedium), pInputMedium->dw1, pInputMedium->dw2); 267 287 for(DWORD nOutputTypeIndex = 0; nOutputTypeIndex < nOutputTypeCount; nOutputTypeIndex++) 268 288 { … … 272 292 } 273 293 if(pOutputMedium) 274 _Z4(atlTraceCOM, 4, _T("pOutputMedium { clsMedium %ls, dw1 0x% x, dw2 0x%x}\n"), _PersistHelper::StringFromIdentifier(pOutputMedium->clsMedium), pOutputMedium->dw1, pOutputMedium->dw2);275 const HRESULT nResult = m_pFilterMapper 2->EnumMatchingFilters(ppEnumMoniker, nFlags, bExactMatch, nMinimalMerit, bInputNeeded, nInputTypeCount, pInputTypes, pInputMedium, pInputPinCategory, bRender, bOutputNeeded, nOutputTypeCount, pOutputTypes, pOutputMedium, pOutputPinCategory);294 _Z4(atlTraceCOM, 4, _T("pOutputMedium { clsMedium %ls, dw1 0x%X, dw2 0x%X }\n"), _PersistHelper::StringFromIdentifier(pOutputMedium->clsMedium), pOutputMedium->dw1, pOutputMedium->dw2); 295 const HRESULT nResult = m_pFilterMapper3->EnumMatchingFilters(ppEnumMoniker, nFlags, bExactMatch, nMinimalMerit, bInputNeeded, nInputTypeCount, pInputTypes, pInputMedium, pInputPinCategory, bRender, bOutputNeeded, nOutputTypeCount, pOutputTypes, pOutputMedium, pOutputPinCategory); 276 296 if(SUCCEEDED(nResult)) 277 297 _ATLTRY … … 279 299 const CComPtr<IEnumMoniker>& pEnumMoniker = reinterpret_cast<const CComPtr<IEnumMoniker>&>(*ppEnumMoniker); 280 300 __C(pEnumMoniker->Reset()); 281 CComPtr<IMoniker> pMoniker; 282 while(pEnumMoniker->Next(1, &pMoniker, NULL) == S_OK) 301 for(; ; ) 283 302 { 284 _Z4(atlTraceCOM, 4, _T("pMoniker %ls\n"), _FilterGraphHelper::GetMonikerDisplayName(pMoniker)); 303 CComPtr<IMoniker> pMoniker; 304 ULONG nElementCount; 305 if(pEnumMoniker->Next(1, &pMoniker, &nElementCount) != S_OK) 306 break; 307 _Z4(atlTraceGeneral, 4, _T("pMoniker %ls\n"), _FilterGraphHelper::GetMonikerDisplayName(pMoniker)); 285 308 CComPtr<IBindCtx> pBindCtx; 286 309 __C(CreateBindCtx(0, &pBindCtx)); … … 291 314 const CStringW sDevicePath = _FilterGraphHelper::ReadPropertyBagString(pPropertyBag, OLESTR("DevicePath")); 292 315 _Z4(atlTraceCOM, 4, _T("sFriendlyName \"%ls\", sDescription \"%ls\", sDevicePath \"%ls\"\n"), sFriendlyName, sDescription, sDevicePath); 293 pMoniker.Release();294 316 } 295 317 __C(pEnumMoniker->Reset()); … … 300 322 } 301 323 return nResult; 324 } 325 326 // IFilterMapper 327 STDMETHOD(RegisterFilter)(CLSID FilterClassIdentifier, LPCWSTR pszName, DWORD nMerit) override 328 { 329 _Z4(atlTraceCOM, 4, _T("...\n")); 330 return m_pFilterMapper->RegisterFilter(FilterClassIdentifier, pszName, nMerit); 331 } 332 STDMETHOD(RegisterFilterInstance)(CLSID FilterClassIdentifier, LPCWSTR pszName, CLSID* pMediaResourceIdentifier) override 333 { 334 _Z4(atlTraceCOM, 4, _T("...\n")); 335 return m_pFilterMapper->RegisterFilterInstance(FilterClassIdentifier, pszName, pMediaResourceIdentifier); 336 } 337 STDMETHOD(RegisterPin)(CLSID Filter, LPCWSTR pszName, BOOL bRendered, BOOL bOutput, BOOL bZero, BOOL bMany, CLSID ConnectsToFilter, LPCWSTR pszConnectsToPin) override 338 { 339 _Z4(atlTraceCOM, 4, _T("...\n")); 340 return m_pFilterMapper->RegisterPin(Filter, pszName, bRendered, bOutput, bZero, bMany, ConnectsToFilter, pszConnectsToPin); 341 } 342 STDMETHOD(RegisterPinType)(CLSID FilterClassIdentifier, LPCWSTR pszName, CLSID MajorType, CLSID Subtype) override 343 { 344 _Z4(atlTraceCOM, 4, _T("...\n")); 345 return m_pFilterMapper->RegisterPinType(FilterClassIdentifier, pszName, MajorType, Subtype); 346 } 347 STDMETHOD(UnregisterFilter)(CLSID FilterClassIdentifier) override 348 { 349 _Z4(atlTraceCOM, 4, _T("...\n")); 350 return m_pFilterMapper->UnregisterFilter(FilterClassIdentifier); 351 } 352 STDMETHOD(UnregisterFilterInstance)(CLSID MediaResourceIdentifier) override 353 { 354 _Z4(atlTraceCOM, 4, _T("...\n")); 355 return m_pFilterMapper->UnregisterFilterInstance(MediaResourceIdentifier); 356 } 357 STDMETHOD(UnregisterPin)(CLSID FilterClassIdentifier, LPCWSTR pszName) override 358 { 359 _Z4(atlTraceCOM, 4, _T("...\n")); 360 return m_pFilterMapper->UnregisterPin(FilterClassIdentifier, pszName); 361 } 362 STDMETHOD(EnumMatchingFilters)(IEnumRegFilters** ppEnum, DWORD nMerit, BOOL bInputNeeded, CLSID clsInMaj, CLSID clsInSub, BOOL bRender, BOOL bOutputNeeded, CLSID clsOutMaj, CLSID clsOutSub) override 363 { 364 _Z4(atlTraceCOM, 4, _T("...\n")); 365 return m_pFilterMapper->EnumMatchingFilters(ppEnum, nMerit, bInputNeeded, clsInMaj, clsInSub, bRender, bOutputNeeded, clsOutMaj, clsOutSub); 302 366 } 303 367 };
Note: See TracChangeset
for help on using the changeset viewer.