source: trunk/DirectShowSpy/FilterGraphSpy.cpp @ 569

Last change on this file since 569 was 569, checked in by roman, 8 years ago

Added ability to flush media sample trace data to file via command line

  • Property svn:keywords set to Id
File size: 4.6 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2008-2015
3// Created by Roman Ryltsov roman@alax.info, http://alax.info
4//
5// This source code is published to complement DirectShowSpy developer powertoy
6// and demonstrate the internal use of APIs and tricks powering the tool. It is
7// allowed to freely re-use the portions of the code in other projects, commercial
8// or otherwise (provided that you don’t pretend that you wrote the original tool).
9//
10// Please keep in mind that DirectShowSpy is a developer tool, it is strongly recommended
11// that it is not shipped with release grade software. It is allowed to distribute
12// DirectShowSpy if only it is not registered with Windows by default and either
13// used privately, or registered on specific throubleshooting request. The advice applies
14// to hooking methods used by DirectShowSpy in general as well.
15
16#include "stdafx.h"
17#include "resource.h"
18#include "FilterGraphSpy.h"
19#include "FilterMapperSpy.h"
20#include "SystemDeviceEnumeratorSpy.h"
21
22////////////////////////////////////////////////////////////
23// DoGraphBuilderCallbackPropertySheetModal
24
25#include "GraphBuilderCallbackPropertySheet.h"
26
27#if defined(_WIN64)
28        extern "C" __declspec(dllexport) 
29#else
30        #pragma comment(linker, "/EXPORT:DoGraphBuilderCallbackPropertySheetModal=_DoGraphBuilderCallbackPropertySheetModal@0,PRIVATE")
31        extern "C" // __declspec(dllexport)
32#endif // defined(_WIN64)
33
34HRESULT STDMETHODCALLTYPE DoGraphBuilderCallbackPropertySheetModal()
35{
36        _ATLTRY
37        {
38                CSingleThreadedApartment SingleThreadedApartment;
39                _W(AtlInitCommonControls(ICC_WIN95_CLASSES | ICC_COOL_CLASSES | ICC_STANDARD_CLASSES));
40                CGraphBuilderCallbackPropertySheet PropertySheet;
41                PropertySheet.DoModal(GetActiveWindow());
42        }
43        _ATLCATCH(Exception)
44        {
45                _C(Exception);
46        }
47        return S_OK;
48}
49
50////////////////////////////////////////////////////////////
51// DoFilterGraphListPropertySheetModal
52
53#include "FilterGraphList.h"
54
55#if defined(_WIN64)
56        extern "C" __declspec(dllexport) 
57#else
58        #pragma comment(linker, "/EXPORT:DoFilterGraphListPropertySheetModal=_DoFilterGraphListPropertySheetModal@0,PRIVATE")
59        extern "C" // __declspec(dllexport)
60#endif // defined(_WIN64)
61
62HRESULT STDMETHODCALLTYPE DoFilterGraphListPropertySheetModal()
63{
64        _ATLTRY
65        {
66                CSingleThreadedApartment SingleThreadedApartment;
67                _W(AtlInitCommonControls(ICC_WIN95_CLASSES | ICC_COOL_CLASSES | ICC_STANDARD_CLASSES));
68                CFilterGraphListPropertySheet PropertySheet;
69                PropertySheet.DoModal(GetActiveWindow());
70        }
71        _ATLCATCH(Exception)
72        {
73                _C(Exception);
74        }
75        return S_OK;
76}
77
78////////////////////////////////////////////////////////////
79// DoGraphBuilderCallbackPropertySheetModal
80
81#include "MediaSampleTrace.h"
82
83#if defined(_WIN64)
84        extern "C" __declspec(dllexport) 
85#else
86        #pragma comment(linker, "/EXPORT:DoMediaSampleTracePropertySheetModal=_DoMediaSampleTracePropertySheetModal@0,PRIVATE")
87        extern "C" // __declspec(dllexport)
88#endif // defined(_WIN64)
89
90HRESULT STDMETHODCALLTYPE DoMediaSampleTracePropertySheetModal()
91{
92        _ATLTRY
93        {
94                CSingleThreadedApartment SingleThreadedApartment;
95                _W(AtlInitCommonControls(ICC_WIN95_CLASSES | ICC_COOL_CLASSES | ICC_STANDARD_CLASSES));
96                CMediaSampleTracePropertySheet PropertySheet;
97                PropertySheet.DoModal(GetActiveWindow());
98        }
99        _ATLCATCH(Exception)
100        {
101                _C(Exception);
102        }
103        return S_OK;
104}
105
106#if defined(_WIN64)
107        extern "C" __declspec(dllexport) 
108#else
109        #pragma comment(linker, "/EXPORT:DoMediaSampleTraceTasks=_DoMediaSampleTraceTasks@16,PRIVATE")
110        extern "C" // __declspec(dllexport)
111#endif // defined(_WIN64)
112
113HRESULT STDMETHODCALLTYPE DoMediaSampleTraceTasks(HWND hParentWindow, HINSTANCE, LPSTR pszCommandLine, INT nShowCommand)
114{
115        _ATLTRY
116        {
117                CSingleThreadedApartment SingleThreadedApartment;
118                hParentWindow; nShowCommand;
119                CCommandLineArguments Arguments((LPCWSTR) CStringW(pszCommandLine), 0);
120                for(; ; )
121                {
122                        CCommandLineArguments::CArgument Argument;
123                        if(!Arguments.Next(Argument))
124                                break;
125                        __D(!Argument.m_bSwitch, E_INVALIDARG);
126                        if(Argument.m_sValue.CompareNoCase(_T("reset")) == 0)
127                        {
128                                CMediaSampleTraceBase::ResetData();
129                        } else
130                        if(Argument.m_sValue.CompareNoCase(_T("write")) == 0)
131                        {
132                                CCommandLineArguments::CArgument PathArgument;
133                                __D(Arguments.Next(PathArgument), E_INVALIDARG);
134                                __D(!PathArgument.m_bSwitch, E_INVALIDARG);
135                                CMediaSampleTraceBase::SaveToFile(CMediaSampleTraceBase::CreateDataText(), (LPCTSTR) PathArgument.m_sValue);
136                        } else
137                                __C(E_INVALIDARG);
138                }
139        }
140        _ATLCATCH(Exception)
141        {
142                _C(Exception);
143        }
144        return S_OK;
145}
146
Note: See TracBrowser for help on using the repository browser.