root/trunk/FilterGraphSpy/Spy.h
| 173 | 178 | ||
|---|---|---|---|
10 | #include "FilterGraphSpy_i.h" | 10 | #include "FilterGraphSpy_i.h" |
11 | 11 | ||
12 | //////////////////////////////////////////////////////////// | 12 | //////////////////////////////////////////////////////////// |
13 | // CHookHostT | ||
14 | |||
15 | template <typename T, typename IHook, LPCTSTR* t_ppszHookName> | ||
16 | class CHookHostT | ||
17 | { | ||
18 | public: | ||
19 | |||
20 | //////////////////////////////////////////////////////// | ||
21 | // CHookArray | ||
22 | |||
23 | class CHookArray : | ||
24 | public CRoArrayT<CComPtr<IHook> > | ||
25 | { | ||
26 | public: | ||
27 | // CHookArray | ||
28 | }; | ||
29 | |||
30 | private: | ||
31 | mutable CRoCriticalSection m_HookCriticalSection; | ||
32 | BOOL m_bHookArrayInitialized; | ||
33 | CHookArray m_HookArray; | ||
34 | |||
35 | VOID InitializeHookArray() | ||
36 | { | ||
37 | _A(m_HookArray.IsEmpty()); | ||
38 | CRoListT<CLSID> ClassIdentifierList; | ||
39 | static const HKEY g_phParentKeys[] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER }; | ||
40 | static const LPCTSTR g_ppszKeyNameFormats[] = { _T("SOFTWARE\\Classes\\"), _T("Software\\Classes\\") }; | ||
41 | for(SIZE_T nKeyIndex = 0; nKeyIndex < DIM(g_phParentKeys); nKeyIndex++) | ||
42 | { | ||
43 | const CString sKeyName = AtlFormatString(_T("%sCLSID\\%ls\\Hooks\\%s"), g_ppszKeyNameFormats[nKeyIndex],
_PersistHelper::StringFromIdentifier(T::GetObjectCLSID()), *t_ppszHookName); | ||
44 | CRegKey Key; | ||
45 | if(FAILED(HRESULT_FROM_WIN32(Key.Open(g_phParentKeys[nKeyIndex], sKeyName, KEY_READ)))) | ||
46 | continue; | ||
47 | for(DWORD nIndex = 0; ; nIndex++) | ||
48 | { | ||
49 | DWORD nNameLength = 0; | ||
50 | RegEnumKeyEx(Key, nIndex, NULL, &nNameLength, NULL, NULL, NULL, NULL); | ||
51 | nNameLength = max(2 * nNameLength, 256); | ||
52 | CTempBuffer<TCHAR, 4096> pszName(nNameLength); | ||
53 | const HRESULT nRegEnumKeyResult = HRESULT_FROM_WIN32(RegEnumKeyEx(Key, nIndex, pszName, &nNameLength, NULL, NULL, NULL, NULL)); | ||
54 | if(FAILED(nRegEnumKeyResult)) | ||
55 | { | ||
56 | __D(nRegEnumKeyResult == HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS), nRegEnumKeyResult); | ||
57 | break; | ||
58 | } | ||
59 | _ATLTRY | ||
60 | { | ||
61 | const CLSID ClassIdentifier = _PersistHelper::ClassIdentifierFromString(CT2CW(pszName)); | ||
62 | _Z4(atlTraceGeneral, 4, _T("ClassIdentifier %ls\n"), _PersistHelper::StringFromIdentifier(ClassIdentifier)); | ||
63 | __D(ClassIdentifier != CLSID_NULL, E_UNNAMED); | ||
64 | if(ClassIdentifierList.Find(ClassIdentifier)) | ||
65 | continue; | ||
66 | _W(ClassIdentifierList.AddTail(ClassIdentifier)); | ||
67 | CComPtr<IHook> pHook; | ||
68 | __C(pHook.CoCreateInstance(ClassIdentifier)); | ||
69 | _W(m_HookArray.Add(pHook) >= 0); | ||
70 | } | ||
71 | _ATLCATCHALL() | ||
72 | { | ||
73 | _Z_EXCEPTION(); | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | |||
79 | public: | ||
80 | // CHookHostT | ||
81 | CHookHostT() throw() : | ||
82 | m_bHookArrayInitialized(FALSE) | ||
83 | { | ||
84 | } | ||
85 | SIZE_T GetHookArray(CHookArray& HookArray) | ||
86 | { | ||
87 | _A(HookArray.IsEmpty()); | ||
88 | CRoCriticalSectionLock HookLock(m_HookCriticalSection); | ||
89 | if(!m_bHookArrayInitialized) | ||
90 | _ATLTRY | ||
91 | { | ||
92 | m_bHookArrayInitialized = TRUE; | ||
93 | InitializeHookArray(); | ||
94 | } | ||
95 | _ATLCATCHALL() | ||
96 | { | ||
97 | _Z_EXCEPTION(); | ||
98 | } | ||
99 | HookArray.Append(m_HookArray); | ||
100 | return HookArray.GetCount(); | ||
101 | } | ||
102 | }; | ||
103 | |||
104 | #define HOOK_PROLOG(Base) \ | ||
105 | _ATLTRY \ | ||
106 | { \ | ||
107 | Base::CHookArray HookArray; \ | ||
108 | if(Base::GetHookArray(HookArray)) \ | ||
109 | { \ | ||
110 | T* pT = static_cast<T*>(this); \ | ||
111 | for(SIZE_T nIndex = 0; nIndex < HookArray.GetCount(); nIndex++) \ | ||
112 | { \ | ||
113 | BOOL bDefault = TRUE; \ | ||
114 | const HRESULT nResult = HookArray[nIndex]-> | ||
115 | |||
116 | #define HOOK_EPILOG() \ | ||
117 | if(!bDefault) \ | ||
118 | return nResult; \ | ||
119 | _A(SUCCEEDED(nResult)); \ | ||
120 | } \ | ||
121 | } \ | ||
122 | } \ | ||
123 | _ATLCATCHALL() \ | ||
124 | { \ | ||
125 | _Z_EXCEPTION(); \ | ||
126 | } | ||
127 | |||
128 | //////////////////////////////////////////////////////////// | ||
13 | // CSpyT | 129 | // CSpyT |
14 | 130 | ||
131 | LPCTSTR g_pszAddRemoveHookName = _T("Add/Remove Hooks"); | ||
132 | LPCTSTR g_pszConnectHookName = _T("Connect Hooks"); | ||
133 | LPCTSTR g_pszStateControlHookName = _T("State Control Hooks"); | ||
134 | |||
15 | template <typename T, const CLSID* t_pFilterGraphClassIdentifier> | 135 | template <typename T, const CLSID* t_pFilterGraphClassIdentifier> |
16 | class ATL_NO_VTABLE CSpyT : | 136 | class ATL_NO_VTABLE CSpyT : |
17 | public CComObjectRootEx<CComMultiThreadModel>, | 137 | public CComObjectRootEx<CComMultiThreadModel>, |
18 | //public CComCoClass<CSpyT, &CLSID_Spy>, | 138 | //public CComCoClass<CSpyT, &CLSID_Spy>, |
19 | public IDispatchImpl<ISpy>, | 139 | public IDispatchImpl<ISpy>, |
20 | public IFilterGraph2, | 140 | public IFilterGraph2, |
21 | public IDispatchImpl<IMediaControl, &__uuidof(IMediaControl), &__uuidof(Quartz::__QuartzTypeLib)> | 141 | public IDispatchImpl<IMediaControl, &__uuidof(IMediaControl), &__uuidof(Quartz::__QuartzTypeLib)>, |
142 | public CHookHostT<T, IFilterGraphAddRemoveHook, &g_pszAddRemoveHookName>, | ||
143 | public CHookHostT<T, IFilterGraphConnectHook, &g_pszConnectHookName>, | ||
144 | public CHookHostT<T, IFilterGraphStateControlHook, &g_pszStateControlHookName> | ||
22 | { | 145 | { |
23 | typedef CSpyT<T, t_pFilterGraphClassIdentifier> CSpy; | 146 | typedef CSpyT<T, t_pFilterGraphClassIdentifier> CSpy; |
147 | typedef CHookHostT<T, IFilterGraphAddRemoveHook, &g_pszAddRemoveHookName> CFilterGraphAddRemoveHookHost; | ||
148 | typedef CHookHostT<T, IFilterGraphConnectHook, &g_pszConnectHookName> CFilterGraphConnectHookHost; | ||
149 | typedef CHookHostT<T, IFilterGraphStateControlHook, &g_pszStateControlHookName> CFilterGraphStateControlHookHost; | ||
24 | 150 | ||
25 | public: | 151 | public: |
26 | //enum { IDR = IDR_SPY }; | 152 | //enum { IDR = IDR_SPY }; |
... | ... | ||
31 | 157 | ||
32 | DECLARE_GET_CONTROLLING_UNKNOWN() | 158 | DECLARE_GET_CONTROLLING_UNKNOWN() |
33 | 159 | ||
34 | DECLARE_QI_TRACE(CSpy) | 160 | //DECLARE_QI_TRACE(CSpy) |
35 | 161 | ||
36 | BEGIN_COM_MAP(CSpy) | 162 | BEGIN_COM_MAP(CSpy) |
37 | COM_INTERFACE_ENTRY(ISpy) | 163 | COM_INTERFACE_ENTRY(ISpy) |
38 | //COM_INTERFACE_ENTRY(IFilterGraph3) | 164 | COM_INTERFACE_ENTRY_FUNC(__uuidof(IFilterGraph3), 0, QueryFilterGraph3Interface) |
39 | COM_INTERFACE_ENTRY(IFilterGraph2) | 165 | COM_INTERFACE_ENTRY(IFilterGraph2) |
40 | COM_INTERFACE_ENTRY(IGraphBuilder) | 166 | COM_INTERFACE_ENTRY(IGraphBuilder) |
41 | COM_INTERFACE_ENTRY(IFilterGraph) | 167 | COM_INTERFACE_ENTRY(IFilterGraph) |
... | ... | ||
168 | BOOL m_bIsAggregated; | 294 | BOOL m_bIsAggregated; |
169 | CComPtr<IUnknown> m_pInnerUnknown; | 295 | CComPtr<IUnknown> m_pInnerUnknown; |
170 | CComPtr<IFilterGraph2> m_pInnerFilterGraph2; | 296 | CComPtr<IFilterGraph2> m_pInnerFilterGraph2; |
297 | CComPtr<IFilterGraph3> m_pInnerFilterGraph3; | ||
171 | CComPtr<IMediaControl> m_pInnerMediaControl; | 298 | CComPtr<IMediaControl> m_pInnerMediaControl; |
172 | _FilterGraphHelper::CRotRunningFilterGraph m_RunningFilterGraph; | 299 | _FilterGraphHelper::CRotRunningFilterGraph m_RunningFilterGraph; |
173 | CComPtr<IUnknown> m_pTemporaryUnknown; | 300 | CComPtr<IUnknown> m_pTemporaryUnknown; |
... | ... | ||
223 | m_RunningFilterGraph.SetFilterGraph(NULL); | 350 | m_RunningFilterGraph.SetFilterGraph(NULL); |
224 | _Z4(atlTraceRefcount, 4, _T("this 0x%08x, m_dwRef 0x%x\n"), this, m_dwRef); | 351 | _Z4(atlTraceRefcount, 4, _T("this 0x%08x, m_dwRef 0x%x\n"), this, m_dwRef); |
225 | } | 352 | } |
353 | HRESULT InternalQueryFilterGraph3Interface(REFIID InterfaceIdentifier, VOID** ppvObject) throw() | ||
354 | { | ||
355 | _A(InterfaceIdentifier == __uuidof(IFilterGraph3)); | ||
356 | _A(ppvObject); | ||
357 | if(!m_pInnerFilterGraph3) | ||
358 | { | ||
359 | *ppvObject = NULL; | ||
360 | return E_NOINTERFACE; | ||
361 | } | ||
362 | T* pT = static_cast<T*>(this); | ||
363 | *ppvObject = (IFilterGraph3*) pT; | ||
364 | pT->InternalAddRef(); | ||
365 | return S_OK; | ||
366 | } | ||
367 | static HRESULT WINAPI QueryFilterGraph3Interface(VOID* pvThis, REFIID InterfaceIdentifier, VOID** ppvObject, DWORD_PTR) throw() | ||
368 | { | ||
369 | return ((CSpy*) pvThis)->InternalQueryFilterGraph3Interface(InterfaceIdentifier, ppvObject); | ||
370 | } | ||
371 | HRESULT HookMediaControlAddSourceFilter(BSTR sFileName, IBaseFilter** ppBaseFilter, BOOL* pbDefault) throw() | ||
372 | { | ||
373 | _A(pbDefault); | ||
374 | HOOK_PROLOG(CFilterGraphAddRemoveHookHost) | ||
375 | OnAddSourceFilter(pT, sFileName, NULL, reinterpret_cast<IUnknown**>(ppBaseFilter), &bDefault); | ||
376 | *pbDefault = bDefault; | ||
377 | HOOK_EPILOG() | ||
378 | return S_OK; | ||
379 | } | ||
226 | 380 | ||
227 | public: | 381 | public: |
228 | // CSpyT | 382 | // CSpyT |
... | ... | ||
318 | CComQIPtr<IFilterGraph2> pFilterGraph2 = pUnknown; | 472 | CComQIPtr<IFilterGraph2> pFilterGraph2 = pUnknown; |
319 | __D(pFilterGraph2, E_NOINTERFACE); | 473 | __D(pFilterGraph2, E_NOINTERFACE); |
320 | pFilterGraph2.p->Release(); | 474 | pFilterGraph2.p->Release(); |
475 | CComQIPtr<IFilterGraph3> pFilterGraph3 = pUnknown; | ||
476 | if(pFilterGraph3) | ||
477 | pFilterGraph3.p->Release(); | ||
321 | CComQIPtr<IMediaControl> pMediaControl = pUnknown; | 478 | CComQIPtr<IMediaControl> pMediaControl = pUnknown; |
322 | __D(pMediaControl, E_NOINTERFACE); | 479 | __D(pMediaControl, E_NOINTERFACE); |
323 | pMediaControl.p->Release(); | 480 | pMediaControl.p->Release(); |
... | ... | ||
326 | { const ULONG nAddRefCount = pControllingUnknown.p->AddRef(); const ULONG nReleaseCount = pControllingUnknown.p->Release(); _Z5(atlTraceRefcount, 5,
_T("m_dwRef 0x%x, AddRef %d, Release %d\n"), m_dwRef, nAddRefCount, nReleaseCount); } | 483 | { const ULONG nAddRefCount = pControllingUnknown.p->AddRef(); const ULONG nReleaseCount = pControllingUnknown.p->Release(); _Z5(atlTraceRefcount, 5,
_T("m_dwRef 0x%x, AddRef %d, Release %d\n"), m_dwRef, nAddRefCount, nReleaseCount); } |
327 | m_pInnerUnknown = pUnknown; | 484 | m_pInnerUnknown = pUnknown; |
328 | m_pInnerFilterGraph2 = pFilterGraph2; | 485 | m_pInnerFilterGraph2 = pFilterGraph2; |
486 | m_pInnerFilterGraph3 = pFilterGraph3; | ||
329 | m_pInnerMediaControl = pMediaControl; | 487 | m_pInnerMediaControl = pMediaControl; |
330 | } | 488 | } |
331 | if(m_bIsAggregated) | 489 | if(m_bIsAggregated) |
... | ... | ||
367 | pControllingUnknown.p->AddRef(); | 525 | pControllingUnknown.p->AddRef(); |
368 | m_pInnerMediaControl = NULL; | 526 | m_pInnerMediaControl = NULL; |
369 | } | 527 | } |
528 | if(m_pInnerFilterGraph3) | ||
529 | { | ||
530 | pControllingUnknown.p->AddRef(); | ||
531 | m_pInnerFilterGraph3 = NULL; | ||
532 | } | ||
370 | if(m_pInnerFilterGraph2) | 533 | if(m_pInnerFilterGraph2) |
371 | { | 534 | { |
372 | pControllingUnknown.p->AddRef(); | 535 | pControllingUnknown.p->AddRef(); |
... | ... | ||
387 | // ISpy | 550 | // ISpy |
388 | 551 | ||
389 | // IFilterGraph | 552 | // IFilterGraph |
390 | STDMETHOD(AddFilter)(IBaseFilter* pFilter, LPCWSTR pszName) throw() | 553 | STDMETHOD(AddFilter)(IBaseFilter* pBaseFilter, LPCWSTR pszName) throw() |
391 | { | 554 | { |
392 | _Z4(atlTraceCOM, 4, _T("pszName \"%s\"\n"), CString(pszName)); | 555 | _Z4(atlTraceCOM, 4, _T("pBaseFilter 0x%08x, pszName \"%s\"\n"), pBaseFilter, CString(pszName)); |
393 | ReleaseTemporaryUnknown(); | 556 | ReleaseTemporaryUnknown(); |
394 | return m_pInnerFilterGraph2->AddFilter(pFilter, pszName); | 557 | HOOK_PROLOG(CFilterGraphAddRemoveHookHost) |
558 | OnAddFilter(pT, pBaseFilter, pszName, &bDefault); | ||
559 | HOOK_EPILOG() | ||
560 | return m_pInnerFilterGraph2->AddFilter(pBaseFilter, pszName); | ||
395 | } | 561 | } |
396 | STDMETHOD(RemoveFilter)(IBaseFilter* pFilter) throw() | 562 | STDMETHOD(RemoveFilter)(IBaseFilter* pBaseFilter) throw() |
397 | { | 563 | { |
398 | _Z4(atlTraceCOM, 4, _T("...\n")); | 564 | _Z4(atlTraceCOM, 4, _T("pBaseFilter 0x%08x\n"), pBaseFilter); |
399 | return m_pInnerFilterGraph2->RemoveFilter(pFilter); | 565 | if(pBaseFilter) |
566 | _ATLTRY | ||
567 | { | ||
568 | const CStringW sName = _FilterGraphHelper::GetFilterName(pBaseFilter); | ||
569 | _Z4(atlTraceGeneral, 4, _T("sName \"%ls\"\n"), sName); | ||
570 | } | ||
571 | _ATLCATCHALL() | ||
572 | { | ||
573 | _Z_EXCEPTION(); | ||
574 | } | ||
575 | HOOK_PROLOG(CFilterGraphAddRemoveHookHost) | ||
576 | OnRemoveFilter(pT, pBaseFilter, &bDefault); | ||
577 | HOOK_EPILOG() | ||
578 | return m_pInnerFilterGraph2->RemoveFilter(pBaseFilter); | ||
400 | } | 579 | } |
401 | STDMETHOD(EnumFilters)(IEnumFilters** ppEnumFilters) throw() | 580 | STDMETHOD(EnumFilters)(IEnumFilters** ppEnumFilters) throw() |
402 | { | 581 | { |
... | ... | ||
411 | STDMETHOD(ConnectDirect)(IPin* pOutputPin, IPin* pInputPin, const AM_MEDIA_TYPE* pMediaType) throw() | 590 | STDMETHOD(ConnectDirect)(IPin* pOutputPin, IPin* pInputPin, const AM_MEDIA_TYPE* pMediaType) throw() |
412 | { | 591 | { |
413 | _Z4(atlTraceCOM, 4, _T("...\n")); | 592 | _Z4(atlTraceCOM, 4, _T("...\n")); |
593 | if(pOutputPin && pInputPin) | ||
594 | _ATLTRY | ||
595 | { | ||
596 | _Z4(atlTraceGeneral, 4, _T("pOutputPin \"%ls\", pInputPin \"%ls\"\n"), _FilterGraphHelper::GetPinFullName(pOutputPin),
_FilterGraphHelper::GetPinFullName(pInputPin)); | ||
597 | if(pMediaType) | ||
598 | _FilterGraphHelper::TraceMediaType(pMediaType); | ||
599 | } | ||
600 | _ATLCATCHALL() | ||
601 | { | ||
602 | _Z_EXCEPTION(); | ||
603 | } | ||
604 | HOOK_PROLOG(CFilterGraphConnectHookHost) | ||
605 | OnConnectDirect(pT, pOutputPin, pInputPin, (const BYTE*) pMediaType, &bDefault); | ||
606 | HOOK_EPILOG() | ||
414 | return m_pInnerFilterGraph2->ConnectDirect(pOutputPin, pInputPin, pMediaType); | 607 | return m_pInnerFilterGraph2->ConnectDirect(pOutputPin, pInputPin, pMediaType); |
415 | } | 608 | } |
416 | STDMETHOD(Reconnect)(IPin* pPin) throw() | 609 | STDMETHOD(Reconnect)(IPin* pPin) throw() |
417 | { | 610 | { |
418 | _Z4(atlTraceCOM, 4, _T("...\n")); | 611 | _Z4(atlTraceCOM, 4, _T("...\n")); |
612 | HOOK_PROLOG(CFilterGraphConnectHookHost) | ||
613 | OnReconnect(pT, pPin, &bDefault); | ||
614 | HOOK_EPILOG() | ||
419 | return m_pInnerFilterGraph2->Reconnect(pPin); | 615 | return m_pInnerFilterGraph2->Reconnect(pPin); |
420 | } | 616 | } |
421 | STDMETHOD(Disconnect)(IPin* pPin) throw() | 617 | STDMETHOD(Disconnect)(IPin* pPin) throw() |
422 | { | 618 | { |
423 | _Z4(atlTraceCOM, 4, _T("...\n")); | 619 | _Z4(atlTraceCOM, 4, _T("...\n")); |
620 | HOOK_PROLOG(CFilterGraphConnectHookHost) | ||
621 | OnDisconnect(pT, pPin, &bDefault); | ||
622 | HOOK_EPILOG() | ||
424 | return m_pInnerFilterGraph2->Disconnect(pPin); | 623 | return m_pInnerFilterGraph2->Disconnect(pPin); |
425 | } | 624 | } |
426 | STDMETHOD(SetDefaultSyncSource)() throw() | 625 | STDMETHOD(SetDefaultSyncSource)() throw() |
... | ... | ||
433 | STDMETHOD(Connect)(IPin* pOutputPin, IPin* pInputPin) throw() | 632 | STDMETHOD(Connect)(IPin* pOutputPin, IPin* pInputPin) throw() |
434 | { | 633 | { |
435 | _Z4(atlTraceCOM, 4, _T("...\n")); | 634 | _Z4(atlTraceCOM, 4, _T("...\n")); |
635 | if(pOutputPin && pInputPin) | ||
636 | _ATLTRY | ||
637 | { | ||
638 | _Z4(atlTraceGeneral, 4, _T("pOutputPin \"%ls\", pInputPin \"%ls\"\n"), _FilterGraphHelper::GetPinFullName(pOutputPin),
_FilterGraphHelper::GetPinFullName(pInputPin)); | ||
639 | } | ||
640 | _ATLCATCHALL() | ||
641 | { | ||
642 | _Z_EXCEPTION(); | ||
643 | } | ||
644 | HOOK_PROLOG(CFilterGraphConnectHookHost) | ||
645 | OnConnect(pT, pOutputPin, pInputPin, &bDefault); | ||
646 | HOOK_EPILOG() | ||
436 | return m_pInnerFilterGraph2->Connect(pOutputPin, pInputPin); | 647 | return m_pInnerFilterGraph2->Connect(pOutputPin, pInputPin); |
437 | } | 648 | } |
438 | STDMETHOD(Render)(IPin* pOutputPin) throw() | 649 | STDMETHOD(Render)(IPin* pOutputPin) throw() |
... | ... | ||
445 | _Z4(atlTraceCOM, 4, _T("pszFileName \"%s\", pszPlayListFileName \"%s\"\n"), CString(pszFileName), CString(pszPlayListFileName)); | 656 | _Z4(atlTraceCOM, 4, _T("pszFileName \"%s\", pszPlayListFileName \"%s\"\n"), CString(pszFileName), CString(pszPlayListFileName)); |
446 | return m_pInnerFilterGraph2->RenderFile(pszFileName, pszPlayListFileName); | 657 | return m_pInnerFilterGraph2->RenderFile(pszFileName, pszPlayListFileName); |
447 | } | 658 | } |
448 | STDMETHOD(AddSourceFilter)(LPCWSTR pszFileName, LPCWSTR pszFilterName, IBaseFilter** ppFilter) throw() | 659 | STDMETHOD(AddSourceFilter)(LPCWSTR pszFileName, LPCWSTR pszFilterName, IBaseFilter** ppBaseFilter) throw() |
449 | { | 660 | { |
450 | _Z4(atlTraceCOM, 4, _T("pszFileName \"%s\", pszFilterName \"%s\"\n"), CString(pszFileName), CString(pszFilterName)); | 661 | _Z4(atlTraceCOM, 4, _T("pszFileName \"%s\", pszFilterName \"%s\"\n"), CString(pszFileName), CString(pszFilterName)); |
451 | ReleaseTemporaryUnknown(); | 662 | ReleaseTemporaryUnknown(); |
452 | return m_pInnerFilterGraph2->AddSourceFilter(pszFileName, pszFilterName, ppFilter); | 663 | HOOK_PROLOG(CFilterGraphAddRemoveHookHost) |
664 | OnAddSourceFilter(pT, pszFileName, pszFilterName, reinterpret_cast<IUnknown**>(ppBaseFilter), &bDefault); | ||
665 | HOOK_EPILOG() | ||
666 | return m_pInnerFilterGraph2->AddSourceFilter(pszFileName, pszFilterName, ppBaseFilter); | ||
453 | } | 667 | } |
454 | STDMETHOD(SetLogFile)(DWORD_PTR hFile) throw() | 668 | STDMETHOD(SetLogFile)(DWORD_PTR hFile) throw() |
455 | { | 669 | { |
456 | _Z4(atlTraceCOM, 4, _T("...\n")); | 670 | _Z4(atlTraceCOM, 4, _T("...\n")); |
457 | return m_pInnerFilterGraph2->SetLogFile(hFile); | 671 | return m_pInnerFilterGraph2->SetLogFile(hFile); |
458 | } | 672 | } |
459 | STDMETHOD(Abort)() throw() | 673 | STDMETHOD(Abort)() throw() |
460 | { | 674 | { |
461 | _Z4(atlTraceCOM, 4, _T("...\n")); | 675 | _Z4(atlTraceCOM, 4, _T("...\n")); |
462 | return m_pInnerFilterGraph2->Abort(); | 676 | return m_pInnerFilterGraph2->Abort(); |
463 | } | 677 | } |
464 | STDMETHOD(ShouldOperationContinue)() throw() | 678 | STDMETHOD(ShouldOperationContinue)() throw() |
465 | { | 679 | { |
466 | _Z4(atlTraceCOM, 4, _T("...\n")); | 680 | _Z4(atlTraceCOM, 4, _T("...\n")); |
467 | return m_pInnerFilterGraph2->ShouldOperationContinue(); | 681 | return m_pInnerFilterGraph2->ShouldOperationContinue(); |
468 | } | 682 | } |
469 | 683 | ||
470 | // IFilterGraph2 | 684 | // IFilterGraph2 |
471 | STDMETHOD(AddSourceFilterForMoniker)(IMoniker* pMoniker, IBindCtx* pBindCtx, LPCWSTR pszFilterName, IBaseFilter** ppFilter) throw() | 685 | STDMETHOD(AddSourceFilterForMoniker)(IMoniker* pMoniker, IBindCtx* pBindCtx, LPCWSTR pszFilterName, IBaseFilter** ppBaseFilter) throw() |
472 | { | 686 | { |
473 | _Z4(atlTraceCOM, 4, _T("pszFilterName \"%s\"\n"), CString(pszFilterName)); | 687 | _Z4(atlTraceCOM, 4, _T("pszFilterName \"%s\"\n"), CString(pszFilterName)); |
474 | ReleaseTemporaryUnknown(); | 688 | ReleaseTemporaryUnknown(); |
475 | return m_pInnerFilterGraph2->AddSourceFilterForMoniker(pMoniker, pBindCtx, pszFilterName, ppFilter); | 689 | HOOK_PROLOG(CFilterGraphAddRemoveHookHost) |
690 | OnAddSourceFilterForMoniker(pT, pMoniker, pBindCtx, pszFilterName, reinterpret_cast<IUnknown**>(ppBaseFilter), &bDefault); | ||
691 | HOOK_EPILOG() | ||
692 | return m_pInnerFilterGraph2->AddSourceFilterForMoniker(pMoniker, pBindCtx, pszFilterName, ppBaseFilter); | ||
476 | } | 693 | } |
477 | STDMETHOD(ReconnectEx)(IPin* pPin, const AM_MEDIA_TYPE* pMediaType) throw() | 694 | STDMETHOD(ReconnectEx)(IPin* pPin, const AM_MEDIA_TYPE* pMediaType) throw() |
478 | { | 695 | { |
479 | _Z4(atlTraceCOM, 4, _T("...\n")); | 696 | _Z4(atlTraceCOM, 4, _T("...\n")); |
697 | HOOK_PROLOG(CFilterGraphConnectHookHost) | ||
698 | OnReconnectEx(pT, pPin, (const BYTE*) pMediaType, &bDefault); | ||
699 | HOOK_EPILOG() | ||
480 | return m_pInnerFilterGraph2->ReconnectEx(pPin, pMediaType); | 700 | return m_pInnerFilterGraph2->ReconnectEx(pPin, pMediaType); |
481 | } | 701 | } |
482 | STDMETHOD(RenderEx)(IPin* pOutputPin, DWORD nFlags, DWORD* pnContext) throw() | 702 | STDMETHOD(RenderEx)(IPin* pOutputPin, DWORD nFlags, DWORD* pnContext) throw() |
483 | { | 703 | { |
484 | _Z4(atlTraceCOM, 4, _T("nFlags 0x%x\n"), nFlags); | 704 | _Z4(atlTraceCOM, 4, _T("nFlags 0x%x\n"), nFlags); |
485 | return m_pInnerFilterGraph2->RenderEx(pOutputPin, nFlags, pnContext); | 705 | return m_pInnerFilterGraph2->RenderEx(pOutputPin, nFlags, pnContext); |
486 | } | 706 | } |
487 | 707 | ||
488 | //// IFilterGraph3 | 708 | // IFilterGraph3 |
489 | // STDMETHOD(SetSyncSourceEx)(IReferenceClock* pFilterGraphClock, IReferenceClock* pFilterClock, IBaseFilter* pFilter) throw() | 709 | STDMETHOD(SetSyncSourceEx)(IReferenceClock* pFilterGraphReferenceClock, IReferenceClock* pFilterReferenceClock, IBaseFilter* pBaseFilter) throw() |
490 | // { | 710 | { |
491 | // _Z4(atlTraceCOM, 4, _T("...\n")); | 711 | _Z4(atlTraceCOM, 4, _T("...\n")); |
492 | // return m_pInnerFilterGraph3->SetSyncSourceEx(pFilterGraphClock, pFilterClock, pFilter); | 712 | _A(m_pInnerFilterGraph3); |
493 | // } | 713 | return m_pInnerFilterGraph3->SetSyncSourceEx(pFilterGraphReferenceClock, pFilterReferenceClock, pBaseFilter); |
714 | } | ||
494 | 715 | ||
495 | // IMediaControl | 716 | // IMediaControl |
496 | STDMETHOD(Run)() throw() | 717 | STDMETHOD(Run)() throw() |
497 | { | 718 | { |
498 | _Z4(atlTraceCOM, 4, _T("...\n")); | 719 | _Z4(atlTraceCOM, 4, _T("...\n")); |
499 | #if TRUE | ||
500 | const HRESULT nResult = m_pInnerMediaControl->Run(); | ||
501 | _ATLTRY | 720 | _ATLTRY |
502 | { | 721 | { |
503 | _Z4(atlTraceCOM, 4, _T("nResult 0x%08x\n"), nResult); | ||
504 | _FilterGraphHelper::TraceGraphBuilder(this); | 722 | _FilterGraphHelper::TraceGraphBuilder(this); |
505 | } | 723 | } |
506 | _ATLCATCHALL() | 724 | _ATLCATCHALL() |
507 | { | 725 | { |
508 | _Z_EXCEPTION(); | 726 | _Z_EXCEPTION(); |
509 | } | 727 | } |
510 | return nResult; | 728 | HOOK_PROLOG(CFilterGraphStateControlHookHost) |
511 | #else | 729 | OnRun(pT, &bDefault); |
512 | return m_pInnerMediaControl->Run(); | 730 | HOOK_EPILOG() |
513 | #endif | 731 | const HRESULT nRunResult = m_pInnerMediaControl->Run(); |
732 | _Z4(atlTraceGeneral, 4, _T("nRunResult 0x%08x\n"), nRunResult); | ||
733 | return nRunResult; | ||
514 | } | 734 | } |
515 | STDMETHOD(Pause)() throw() | 735 | STDMETHOD(Pause)() throw() |
516 | { | 736 | { |
517 | _Z4(atlTraceCOM, 4, _T("...\n")); | 737 | _Z4(atlTraceCOM, 4, _T("...\n")); |
738 | HOOK_PROLOG(CFilterGraphStateControlHookHost) | ||
739 | OnPause(pT, &bDefault); | ||
740 | HOOK_EPILOG() | ||
518 | return m_pInnerMediaControl->Pause(); | 741 | return m_pInnerMediaControl->Pause(); |
519 | } | 742 | } |
520 | STDMETHOD(Stop)() throw() | 743 | STDMETHOD(Stop)() throw() |
521 | { | 744 | { |
522 | _Z4(atlTraceCOM, 4, _T("...\n")); | 745 | _Z4(atlTraceCOM, 4, _T("...\n")); |
746 | HOOK_PROLOG(CFilterGraphStateControlHookHost) | ||
747 | OnStop(pT, &bDefault); | ||
748 | HOOK_EPILOG() | ||
523 | return m_pInnerMediaControl->Stop(); | 749 | return m_pInnerMediaControl->Stop(); |
524 | } | 750 | } |
525 | STDMETHOD(GetState)(LONG nTimeout, OAFilterState* pState) throw() | 751 | STDMETHOD(GetState)(LONG nTimeout, OAFilterState* pState) throw() |
526 | { | 752 | { |
527 | _Z4(atlTraceCOM, 4, _T("nTimeout %d\n"), nTimeout); | 753 | _Z4(atlTraceCOM, 4, _T("nTimeout %d\n"), nTimeout); |
528 | return m_pInnerMediaControl->GetState(nTimeout, pState); | 754 | return m_pInnerMediaControl->GetState(nTimeout, pState); |
529 | } | 755 | } |
530 | STDMETHOD(RenderFile)(BSTR sFilename) throw() | 756 | STDMETHOD(RenderFile)(BSTR sFileName) throw() |
531 | { | 757 | { |
532 | _Z4(atlTraceCOM, 4, _T("sFilename \"%s\"\n"), CString(sFilename)); | 758 | _Z4(atlTraceCOM, 4, _T("sFileName \"%s\"\n"), CString(sFileName)); |
533 | return m_pInnerMediaControl->RenderFile(sFilename); | 759 | return m_pInnerMediaControl->RenderFile(sFileName); |
534 | } | 760 | } |
535 | STDMETHOD(AddSourceFilter)(BSTR sFilename, IDispatch** ppDispatch) throw() | 761 | STDMETHOD(AddSourceFilter)(BSTR sFileName, IDispatch** ppDispatch) throw() |
536 | { | 762 | { |
537 | _Z4(atlTraceCOM, 4, _T("sFilename \"%s\"\n"), CString(sFilename)); | 763 | _Z4(atlTraceCOM, 4, _T("sFileName \"%s\"\n"), CString(sFileName)); |
538 | return m_pInnerMediaControl->AddSourceFilter(sFilename, ppDispatch); | 764 | ReleaseTemporaryUnknown(); |
765 | _ATLTRY | ||
766 | { | ||
767 | CComPtr<IBaseFilter> pBaseFilter; | ||
768 | BOOL bDefault = TRUE; | ||
769 | const HRESULT nResult = HookMediaControlAddSourceFilter(sFileName, &pBaseFilter, &bDefault); | ||
770 | if(!bDefault) | ||
771 | { | ||
772 | __D(ppDispatch, E_POINTER); | ||
773 | *ppDispatch = NULL; | ||
774 | if(SUCCEEDED(nResult)) | ||
775 | { | ||
776 | CComQIPtr<IDispatch> pDispatch = pBaseFilter; | ||
777 | __D(pDispatch, E_NOINTERFACE); | ||
778 | *ppDispatch = pDispatch.Detach(); | ||
779 | } | ||
780 | return nResult; | ||
781 | } | ||
782 | } | ||
783 | _ATLCATCH(Exception) | ||
784 | { | ||
785 | _C(Exception); | ||
786 | } | ||
787 | return m_pInnerMediaControl->AddSourceFilter(sFileName, ppDispatch); | ||
539 | } | 788 | } |
540 | STDMETHOD(get_FilterCollection)(IDispatch** ppDispatch) throw() | 789 | STDMETHOD(get_FilterCollection)(IDispatch** ppDispatch) throw() |
541 | { | 790 | { |
542 | _Z4(atlTraceCOM, 4, _T("...\n")); | 791 | _Z4(atlTraceCOM, 4, _T("...\n")); |
543 | ReleaseTemporaryUnknown(); | 792 | ReleaseTemporaryUnknown(); |
544 | return m_pInnerMediaControl->get_FilterCollection(ppDispatch); | 793 | return m_pInnerMediaControl->get_FilterCollection(ppDispatch); |
545 | } | 794 | } |
546 | STDMETHOD(get_RegFilterCollection)(IDispatch** ppDispatch) throw() | 795 | STDMETHOD(get_RegFilterCollection)(IDispatch** ppDispatch) throw() |
547 | { | 796 | { |
548 | _Z4(atlTraceCOM, 4, _T("...\n")); | 797 | _Z4(atlTraceCOM, 4, _T("...\n")); |
549 | ReleaseTemporaryUnknown(); | 798 | ReleaseTemporaryUnknown(); |
550 | return m_pInnerMediaControl->get_RegFilterCollection(ppDispatch); | 799 | return m_pInnerMediaControl->get_RegFilterCollection(ppDispatch); |
551 | } | 800 | } |
552 | STDMETHOD(StopWhenReady)() throw() | 801 | STDMETHOD(StopWhenReady)() throw() |
553 | { | 802 | { |
554 | _Z4(atlTraceCOM, 4, _T("...\n")); | 803 | _Z4(atlTraceCOM, 4, _T("...\n")); |
555 | return m_pInnerMediaControl->StopWhenReady(); | 804 | return m_pInnerMediaControl->StopWhenReady(); |
Download diff