Changeset 440


Ignore:
Timestamp:
May 18, 2015, 2:09:09 AM (9 years ago)
Author:
roman
Message:

Added media sample trace API and UI

Location:
trunk/DirectShowSpy
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/DirectShowSpy/Common.h

    r432 r440  
    1515
    1616#pragma once
     17
     18#include "AboutDialog.h"
     19#include "..\..\Repository-Private\Utilities\EmailTools\Message.h"
     20#define  BZ_NO_STDIO
     21#include "..\..\Repository-Private\Utilities\DeflateTools\Bzip2Item.h"
    1722
    1823////////////////////////////////////////////////////////////
  • trunk/DirectShowSpy/DirectShowSpy.vcxproj

    r432 r440  
    162162      <PrecompiledHeader>Use</PrecompiledHeader>
    163163      <WarningLevel>Level3</WarningLevel>
    164       <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
     164      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
    165165    </ClCompile>
    166166    <ResourceCompile>
     
    474474    <ClInclude Include="FilterMapperSpy.h" />
    475475    <ClInclude Include="GraphBuilderCallbackPropertySheet.h" />
     476    <ClInclude Include="MediaSampleTrace.h" />
    476477    <ClInclude Include="RunPropertyBag.h" />
    477478    <ClInclude Include="Resource.h" />
  • trunk/DirectShowSpy/DirectShowSpy.vcxproj.filters

    r322 r440  
    115115      <Filter>Generated Files</Filter>
    116116    </ClInclude>
     117    <ClInclude Include="MediaSampleTrace.h">
     118      <Filter>Header Files</Filter>
     119    </ClInclude>
    117120  </ItemGroup>
    118121  <ItemGroup>
  • trunk/DirectShowSpy/FilterGraphHelper.h

    r432 r440  
    2222#include "RunPropertyBag.h"
    2323#include "RunEvent.h"
    24 #include "AboutDialog.h"
    25 #include "..\..\Repository-Private\Utilities\EmailTools\Message.h"
    26 #define  BZ_NO_STDIO
    27 #include "..\..\Repository-Private\Utilities\DeflateTools\Bzip2Item.h"
    2824
    2925INT_PTR DoFilterGraphListPropertySheetModal(HWND hParentWindow = GetActiveWindow(), COptions* pOptions = NULL);
  • trunk/DirectShowSpy/FilterGraphSpy.cpp

    r376 r440  
    2929#endif // defined(_WIN64)
    3030
    31 HRESULT STDMETHODCALLTYPE DoGraphBuilderCallbackPropertySheetModal() throw()
     31HRESULT STDMETHODCALLTYPE DoGraphBuilderCallbackPropertySheetModal()
    3232{
    3333        _ATLTRY
     
    7373}
    7474
     75////////////////////////////////////////////////////////////
     76// DoGraphBuilderCallbackPropertySheetModal
     77
     78#include "MediaSampleTrace.h"
     79
     80#if defined(_WIN64)
     81        extern "C" __declspec(dllexport)
     82#else
     83        #pragma comment(linker, "/EXPORT:DoMediaSampleTracePropertySheetModal=_DoMediaSampleTracePropertySheetModal@0,PRIVATE")
     84        extern "C" // __declspec(dllexport)
     85#endif // defined(_WIN64)
     86
     87HRESULT STDMETHODCALLTYPE DoMediaSampleTracePropertySheetModal()
     88{
     89        _ATLTRY
     90        {
     91                CSingleThreadedApartment SingleThreadedApartment;
     92                _W(AtlInitCommonControls(ICC_WIN95_CLASSES | ICC_COOL_CLASSES | ICC_STANDARD_CLASSES));
     93                CMediaSampleTracePropertySheet PropertySheet;
     94                PropertySheet.DoModal(GetActiveWindow());
     95        }
     96        _ATLCATCH(Exception)
     97        {
     98                _C(Exception);
     99        }
     100        return S_OK;
     101}
     102
  • trunk/DirectShowSpy/FilterGraphSpy.h

    r376 r440  
    2020#include "Common.h"
    2121#include "RunPropertyBag.h"
     22#include "MediaSampleTrace.h"
    2223
    2324HRESULT FilterGraphHelper_OpenGraphStudioNext(LONG nParentWindowHandle, LPCWSTR pszMonikerDisplayName, VARIANT_BOOL* pbResult);
     
    947948                return S_OK;
    948949        }
     950        STDMETHOD(CreateMediaSampleTrace)(IMediaSampleTrace** ppMediaSampleTrace)
     951        {
     952                _Z4(atlTraceCOM, 4, _T("this 0x%p\n"), this);
     953                _ATLTRY
     954                {
     955                        __D(ppMediaSampleTrace, E_POINTER);
     956                        *ppMediaSampleTrace = NULL;
     957                        CObjectPtr<CMediaSampleTrace> pMediaSampleTrace;
     958                        pMediaSampleTrace.Construct()->Initialize(this);
     959                        *ppMediaSampleTrace = pMediaSampleTrace.Detach();
     960                }
     961                _ATLCATCHALL()
     962                {
     963                        _Z_EXCEPTION();
     964                }
     965                return S_OK;
     966        }
    949967
    950968// ISpyEx
  • trunk/DirectShowSpy/Helper.cpp

    r376 r440  
    1717#include "resource.h"
    1818#include "FilterGraphHelper.h"
     19#include "MediaSampleTrace.h"
    1920
    2021////////////////////////////////////////////////////////////
    2122// Test
    2223
    23 #if _DEVELOPMENT
     24#if _DEVELOPMENT && FALSE
    2425
    2526COMPILER_MESSAGE("Development: CFilterGraphHelper::DoPropertyFrameModal as Test")
     
    3233#endif // defined(_WIN64)
    3334
    34 HRESULT STDMETHODCALLTYPE Test() throw()
     35HRESULT STDMETHODCALLTYPE Test()
    3536{
    3637        _ATLTRY
     
    6263
    6364#endif // _DEVELOPMENT
     65
     66#if _DEVELOPMENT //&& FALSE
     67
     68COMPILER_MESSAGE("Development: MediaSampleTrace test as Test")
     69
     70////////////////////////////////////////////////////////////
     71// CRendererFilter
     72
     73class ATL_NO_VTABLE CRendererFilter :
     74        public CComObjectRootEx<CComMultiThreadModelNoCS>,
     75        //public CComCoClass<CRendererFilter>,
     76        public CBaseFilterT<CRendererFilter>,
     77        public CBasePersistT<CRendererFilter>,
     78        public CAmFilterMiscFlagsT<CRendererFilter, AM_FILTER_MISC_FLAGS_IS_RENDERER>,
     79        public CUpstreamMediaPositionAwareRendererFilterT<CRendererFilter>
     80{
     81public:
     82        //enum { IDR = };
     83
     84DECLARE_NO_REGISTRY() //DECLARE_REGISTRY_RESOURCEID(IDR)
     85
     86DECLARE_PROTECT_FINAL_CONSTRUCT()
     87
     88//DECLARE_QI_TRACE(CRendererFilter)
     89
     90BEGIN_COM_MAP(CRendererFilter)
     91        COM_INTERFACE_ENTRY(IBaseFilter)
     92        COM_INTERFACE_ENTRY(IMediaFilter)
     93        COM_INTERFACE_ENTRY_IID(__uuidof(IPersist), IBaseFilter)
     94        COM_INTERFACE_ENTRY(IAMFilterMiscFlags)
     95        COM_INTERFACE_ENTRY_FUNC(__uuidof(IMediaSeeking), 0, QueryUpstreamMediaPositionInterface)
     96        COM_INTERFACE_ENTRY_FUNC(__uuidof(IDispatch), 0, QueryUpstreamMediaPositionInterface)
     97        COM_INTERFACE_ENTRY_FUNC(__uuidof(IMediaPosition), 0, QueryUpstreamMediaPositionInterface)
     98END_COM_MAP()
     99
     100public:
     101
     102        ////////////////////////////////////////////////////////
     103        // CInputPin
     104
     105        class ATL_NO_VTABLE CInputPin :
     106                public CComObjectRootEx<CComMultiThreadModelNoCS>,
     107                public CInputPinT<CInputPin, CRendererFilter>
     108        {
     109        public:
     110
     111        //DECLARE_QI_TRACE(CRendererFilter::CInputPin)
     112
     113        BEGIN_COM_MAP(CInputPin)
     114                COM_INTERFACE_ENTRY(IPin)
     115                COM_INTERFACE_ENTRY(IMemInputPin)
     116        END_COM_MAP()
     117
     118        public:
     119        // CInputPin
     120                CInputPin()
     121                {
     122                        _Z5_THIS();
     123                }
     124                ~CInputPin()
     125                {
     126                        _Z5_THIS();
     127                }
     128                BOOL CheckMediaType(const CMediaType& pMediaType) const
     129                {
     130                        _A(pMediaType);
     131                        return TRUE;
     132                }
     133        };
     134
     135private:
     136        CObjectPtr<CInputPin> m_pInputPin;
     137        mutable CRoCriticalSection m_ReceiveCriticalSection;
     138        CComPtr<IMediaSampleTrace> m_pMediaSampleTrace;
     139
     140public:
     141// CRendererFilter
     142        CRendererFilter() :
     143                CBasePersistT<CRendererFilter>(GetDataCriticalSection())
     144        {
     145                _Z4_THIS();
     146        }
     147        ~CRendererFilter()
     148        {
     149                _Z4_THIS();
     150        }
     151        HRESULT FinalConstruct()
     152        {
     153                _ATLTRY
     154                {
     155                        m_pInputPin.Construct()->Initialize(this, L"Input");
     156                        AddPin(m_pInputPin);
     157                        CreateUpstreamMediaPosition();
     158                }
     159                _ATLCATCH(Exception)
     160                {
     161                        _C(Exception);
     162                }
     163                return S_OK;
     164        }
     165        VOID FinalRelease()
     166        {
     167                DestroyUpstreamMediaPosition();
     168                m_pInputPin.Release();
     169        }
     170        VOID DeliverNewSegment(IPin*, REFERENCE_TIME nStartTime, REFERENCE_TIME nStopTime, DOUBLE fRate)
     171        {
     172                CRoCriticalSectionLock ReceiveLock(m_ReceiveCriticalSection);
     173                if(m_pMediaSampleTrace)
     174                        _V(m_pMediaSampleTrace->RegisterNewSegment((IBaseFilter*) this, L"Main", nStartTime, nStopTime, fRate, NULL));
     175        }
     176        VOID DeliverEndOfStream(CInputPin*)
     177        {
     178                CRoCriticalSectionLock ReceiveLock(m_ReceiveCriticalSection);
     179                if(m_pMediaSampleTrace)
     180                        _V(m_pMediaSampleTrace->RegisterEndOfStream((IBaseFilter*) this, L"Main", L"That's All!"));
     181                NotifyComplete(S_OK);
     182        }
     183        VOID CueFilter()
     184        {
     185                CRoCriticalSectionLock ReceiveLock(m_ReceiveCriticalSection);
     186                CRoCriticalSectionLock DataLock(GetDataCriticalSection());
     187                if(!m_pInputPin->IsPeerPinAvailable())
     188                {
     189                        NotifyComplete(S_FALSE);
     190                        return;
     191                }
     192                const CComQIPtr<ISpy> pSpy = GetFilterGraph();
     193                _A(pSpy);
     194                CComPtr<IMediaSampleTrace> pMediaSampleTrace;
     195                __C(pSpy->CreateMediaSampleTrace(&pMediaSampleTrace));
     196                m_pMediaSampleTrace = pMediaSampleTrace;
     197        }
     198        VOID StopFilter()
     199        {
     200                CRoCriticalSectionLock ReceiveLock(m_ReceiveCriticalSection);
     201                CRoCriticalSectionLock DataLock(GetDataCriticalSection());
     202                m_pMediaSampleTrace.Release();
     203        }
     204        VOID ReceiveMediaSample(CInputPin* pInputPin, IMediaSample2* pMediaSample, HRESULT& nReceiveResult)
     205        {
     206                CRoCriticalSectionLock ReceiveLock(m_ReceiveCriticalSection);
     207                CMediaSampleProperties Properties(pMediaSample);
     208                CRoCriticalSectionLock DataLock(GetDataCriticalSection());
     209                if(m_pMediaSampleTrace)
     210                        _V(m_pMediaSampleTrace->RegisterMediaSample((IBaseFilter*) this, L"Main", (BYTE*) (AM_SAMPLE2_PROPERTIES*) &Properties, NULL));
     211                nReceiveResult = S_OK;
     212        }
     213        const CObjectPtr<CInputPin>& GetInputPin() const
     214        {
     215                return m_pInputPin;
     216        }
     217};
     218
     219#if defined(_WIN64)
     220        extern "C" __declspec(dllexport)
     221#else
     222        #pragma comment(linker, "/EXPORT:Test=_Test@0,PRIVATE")
     223        extern "C" // __declspec(dllexport)
     224#endif // defined(_WIN64)
     225
     226HRESULT STDMETHODCALLTYPE Test()
     227{
     228        _ATLTRY
     229        {
     230                CSingleThreadedApartment SingleThreadedApartment;
     231                CGenericFilterGraph FilterGraph;
     232                FilterGraph.CoCreateInstance();
     233                const CComPtr<IBaseFilter> pSourceBaseFilter = FilterGraph.AddSourceFilter(
     234                        //_T("E:\\Media\\Robotica_1080.wmv")
     235                        _T("E:\\Media\\Windows Phone - Design for Developers.mp4")
     236                        );
     237                CComPtr<IPin> pOutputPin = _FilterGraphHelper::GetFilterPin(pSourceBaseFilter, PINDIR_OUTPUT);
     238                if(TRUE)
     239                {
     240                        class __declspec(uuid("{025BE2E4-1787-4DA4-A585-C5B2B9EEB57C}")) Demultiplexer;
     241                        CComPtr<IBaseFilter> pBaseFilter;
     242                        __C(pBaseFilter.CoCreateInstance(__uuidof(Demultiplexer)));
     243                        __C(FilterGraph.AddFilter(pBaseFilter, _T("Demultiplexer")));
     244                        __C(FilterGraph.Connect(pOutputPin, _FilterGraphHelper::GetFilterPin(pBaseFilter, PINDIR_INPUT)));
     245                        pOutputPin = _FilterGraphHelper::GetFilterPin(pBaseFilter, PINDIR_OUTPUT);
     246                }
     247                CObjectPtr<CRendererFilter> pRendererFilter;
     248                pRendererFilter.Construct();
     249                __C(FilterGraph.AddFilter(pRendererFilter, _T("Renderer")));
     250                __C(FilterGraph.Connect(pOutputPin, pRendererFilter->GetInputPin()));
     251                __C(FilterGraph.m_pMediaFilter->SetSyncSource(NULL));
     252                const CComQIPtr<ISpy> pSpy = FilterGraph.m_pFilterGraph;
     253                _A(pSpy);
     254                __C(pSpy->put_FriendlyName(CComBSTR(_T("Test"))));
     255                __C(FilterGraph.m_pMediaControl->Run());
     256                __C(FilterGraph.WaitForCompletionDispatchingMessages());
     257                CMediaSampleTracePropertySheet PropertySheet;
     258                PropertySheet.DoModal(GetActiveWindow());
     259        }
     260        _ATLCATCH(Exception)
     261        {
     262                _C(Exception);
     263        }
     264        return S_OK;
     265}
     266
     267#endif // _DEVELOPMENT
  • trunk/DirectShowSpy/Module.idl

    r438 r440  
    5252        [
    5353                object,
     54                uuid(B8270A07-1A10-41B1-B5A6-D8D9397020A8),
     55                nonextensible,
     56                helpstring("IMediaSampleTrace Interface"),
     57                pointer_default(unique)
     58        ]
     59        interface IMediaSampleTrace : IUnknown
     60        {
     61                HRESULT RegisterNewSegment([in] IUnknown* pBaseFilterUnknown, [in] const WCHAR* pszStreamName, [in] LONGLONG nStartTime, [in] LONGLONG nStopTime, [in] DOUBLE fRate, [in] const WCHAR* pszComment);
     62                HRESULT RegisterMediaSample([in] IUnknown* pBaseFilterUnknown, [in] const WCHAR* pszStreamName, [in] const BYTE* pnSamplePropertiesData, [in] const WCHAR* pszComment);
     63                HRESULT RegisterEndOfStream([in] IUnknown* pBaseFilterUnknown, [in] const WCHAR* pszStreamName, [in] const WCHAR* pszComment);
     64                HRESULT RegisterComment([in] IUnknown* pBaseFilterUnknown, [in] const WCHAR* pszStreamName, [in] const WCHAR* pszComment);
     65        };
     66        [
     67                object,
    5468                uuid(6945711B-FE0F-4C54-965F-5B67969C28B7),
    5569                dual,
     
    7084                [id(7)] HRESULT OpenGraphEdit([in] LONG nParentWindowHandle, [out, retval] VARIANT_BOOL* pbResult);
    7185                [id(8)] HRESULT ReadRunPropertyBag([in] IUnknown* pBaseFilterUnknown, [in] VARIANT_BOOL bAllowExtension, [out, retval] VARIANT* pvValue);
     86                [id(9)] HRESULT CreateMediaSampleTrace([out, retval] IMediaSampleTrace** ppMediaSampleTrace);
    7287        };
    7388        [
  • trunk/DirectShowSpy/resource.h

    r376 r440  
    122122#define IDC_FILTERGRAPHHELPER_MEMORYALLOCATOR_LIST 2010
    123123#define IDC_FILTERGRAPHHELPER_MEMORYALLOCATOR_REFRESH 2011
     124#define IDS_MEDIASAMPLETRACE_MEDIASAMPLE_PROPERTYSHEETCAPTION 2100
     125#define IDD_MEDIASAMPLETRACE_MEDIASAMPLE_PROPERTYPAGE 2101
     126#define IDC_MEDIASAMPLETRACE_MEDIASAMPLE_INTRODUCTION 2105
     127#define IDC_MEDIASAMPLETRACE_MEDIASAMPLE_LIST 2110
     128#define IDC_MEDIASAMPLETRACE_MEDIASAMPLE_REFRESH 2111
     129#define IDC_MEDIASAMPLETRACE_MEDIASAMPLE_COPYTOCLIPBOARD 2112
     130#define IDC_MEDIASAMPLETRACE_MEDIASAMPLE_SAVETOFILE 2113
     131#define IDC_MEDIASAMPLETRACE_MEDIASAMPLE_RESETDATA 2114
     132#define IDC_MEDIASAMPLETRACE_MEDIASAMPLE_OPENFILTERGRAPHLIST 2120
    124133#define IDR_FILTERGRAPHSPY              25000
    125134#define IDR_NOTHREADFILTERGRAPHSPY      25001
     
    143152#ifdef APSTUDIO_INVOKED
    144153#ifndef APSTUDIO_READONLY_SYMBOLS
    145 #define _APS_NEXT_RESOURCE_VALUE        211
    146 #define _APS_NEXT_COMMAND_VALUE         32783
    147 #define _APS_NEXT_CONTROL_VALUE         249
     154#define _APS_NEXT_RESOURCE_VALUE        213
     155#define _APS_NEXT_COMMAND_VALUE         32796
     156#define _APS_NEXT_CONTROL_VALUE         252
    148157#define _APS_NEXT_SYMED_VALUE           103
    149158#endif
Note: See TracChangeset for help on using the changeset viewer.