1 | //////////////////////////////////////////////////////////// |
---|
2 | // Copyright (C) Roman Ryltsov, 2006-2014 |
---|
3 | // Created by Roman Ryltsov roman@alax.info |
---|
4 | // |
---|
5 | // A permission to use the source code is granted as long as reference to |
---|
6 | // source website http://alax.info is retained. |
---|
7 | |
---|
8 | #include "stdafx.h" |
---|
9 | //#include <qedit.h> |
---|
10 | #include "rodshow.h" |
---|
11 | #include "Handler.h" |
---|
12 | |
---|
13 | #pragma region Re-Adding Removed from Windows SDK qedit.h |
---|
14 | |
---|
15 | struct __declspec(uuid("0579154a-2b53-4994-b0d0-e773148eff85")) |
---|
16 | ISampleGrabberCB : IUnknown |
---|
17 | { |
---|
18 | // |
---|
19 | // Raw methods provided by interface |
---|
20 | // |
---|
21 | |
---|
22 | virtual HRESULT __stdcall SampleCB ( |
---|
23 | double SampleTime, |
---|
24 | struct IMediaSample * pSample ) = 0; |
---|
25 | virtual HRESULT __stdcall BufferCB ( |
---|
26 | double SampleTime, |
---|
27 | unsigned char * pBuffer, |
---|
28 | long BufferLen ) = 0; |
---|
29 | }; |
---|
30 | |
---|
31 | struct __declspec(uuid("6b652fff-11fe-4fce-92ad-0266b5d7c78f")) |
---|
32 | ISampleGrabber : IUnknown |
---|
33 | { |
---|
34 | // |
---|
35 | // Raw methods provided by interface |
---|
36 | // |
---|
37 | |
---|
38 | virtual HRESULT __stdcall SetOneShot ( |
---|
39 | long OneShot ) = 0; |
---|
40 | virtual HRESULT __stdcall SetMediaType ( |
---|
41 | struct _AMMediaType * pType ) = 0; |
---|
42 | virtual HRESULT __stdcall GetConnectedMediaType ( |
---|
43 | struct _AMMediaType * pType ) = 0; |
---|
44 | virtual HRESULT __stdcall SetBufferSamples ( |
---|
45 | long BufferThem ) = 0; |
---|
46 | virtual HRESULT __stdcall GetCurrentBuffer ( |
---|
47 | /*[in,out]*/ long * pBufferSize, |
---|
48 | /*[out]*/ long * pBuffer ) = 0; |
---|
49 | virtual HRESULT __stdcall GetCurrentSample ( |
---|
50 | /*[out,retval]*/ struct IMediaSample * * ppSample ) = 0; |
---|
51 | virtual HRESULT __stdcall SetCallback ( |
---|
52 | struct ISampleGrabberCB * pCallback, |
---|
53 | long WhichMethodToCallback ) = 0; |
---|
54 | }; |
---|
55 | |
---|
56 | struct __declspec(uuid("c1f400a0-3f08-11d3-9f0b-006008039e37")) |
---|
57 | SampleGrabber; |
---|
58 | // [ default ] interface ISampleGrabber |
---|
59 | |
---|
60 | #pragma endregion |
---|
61 | |
---|
62 | #include "Module.h" |
---|
63 | |
---|
64 | //////////////////////////////////////////////////////////// |
---|
65 | // Main |
---|
66 | |
---|
67 | int _tmain(int argc, _TCHAR* argv[]) |
---|
68 | { |
---|
69 | INT nResult = 0; |
---|
70 | _ATLTRY |
---|
71 | { |
---|
72 | CModule Module; |
---|
73 | #pragma region Parse Command Line |
---|
74 | for(INT nIndex = 1; nIndex < argc; nIndex++) |
---|
75 | { |
---|
76 | CString sArgument = argv[nIndex]; |
---|
77 | _A(!sArgument.IsEmpty()); |
---|
78 | #pragma region Switches |
---|
79 | if(_tcschr(_T("-/"), sArgument[0])) |
---|
80 | { |
---|
81 | sArgument.Delete(0); |
---|
82 | #pragma region Switch Value/Specification |
---|
83 | CString sArgumentValue; |
---|
84 | if(sArgument.GetLength() > 1) |
---|
85 | { |
---|
86 | SIZE_T nIndex = 1; |
---|
87 | if(sArgument[1] == _T(':')) |
---|
88 | nIndex++; |
---|
89 | sArgumentValue = (LPCTSTR) sArgument + nIndex; |
---|
90 | } |
---|
91 | INT nIntegerArgumentValue = 0; |
---|
92 | const BOOL bIntegerArgumentValueValid = !sArgumentValue.IsEmpty() ? AtlStringToInteger(sArgumentValue, nIntegerArgumentValue) : FALSE; |
---|
93 | #pragma endregion |
---|
94 | if(_tcschr(_T("Cc"), sArgument[0])) // No Reference Clock |
---|
95 | { |
---|
96 | Module.m_bNoReferenceClock = TRUE; |
---|
97 | } else |
---|
98 | if(_tcschr(_T("Ee"), sArgument[0])) // Suppress Load Failure |
---|
99 | { |
---|
100 | Module.m_bSuppressLoadFailure = TRUE; |
---|
101 | } |
---|
102 | continue; |
---|
103 | } |
---|
104 | #pragma endregion |
---|
105 | if(sArgument.GetLength() >= 2 && sArgument[0] == _T('"') && sArgument[sArgument.GetLength() - 1] == _T('"')) |
---|
106 | sArgument = sArgument.Mid(1, sArgument.GetLength() - 2); |
---|
107 | __D(!_tcslen(Module.m_sPath), E_UNNAMED); |
---|
108 | Module.m_sPath = (LPCTSTR) sArgument; |
---|
109 | } |
---|
110 | #pragma endregion |
---|
111 | __D(_tcslen(Module.m_sPath), E_UNNAMED); |
---|
112 | nResult = Module.WinMain(SW_SHOWNORMAL); |
---|
113 | } |
---|
114 | _ATLCATCH(Exception) |
---|
115 | { |
---|
116 | _tprintf(_T("Fatal: Error 0x%08x\n"), (HRESULT) Exception); |
---|
117 | } |
---|
118 | _ATLCATCHALL() |
---|
119 | { |
---|
120 | _tprintf(_T("Fatal: Fatal error\n")); |
---|
121 | } |
---|
122 | return nResult; |
---|
123 | } |
---|
124 | |
---|
125 | |
---|