1 | //////////////////////////////////////////////////////////// |
---|
2 | // Copyright (C) Roman Ryltsov, 2015 |
---|
3 | // Created by Roman Ryltsov roman@alax.info |
---|
4 | |
---|
5 | #include "stdafx.h" |
---|
6 | #include "resource.h" |
---|
7 | #include <dshow.h> |
---|
8 | #include "Module_i.h" |
---|
9 | |
---|
10 | #pragma comment(lib, "strmiids.lib") |
---|
11 | |
---|
12 | //////////////////////////////////////////////////////////// |
---|
13 | // CFilterGraphServiceModule |
---|
14 | |
---|
15 | class CFilterGraphServiceModule : |
---|
16 | public CAtlServiceModuleT<CFilterGraphServiceModule, IDS_SERVICENAME> |
---|
17 | { |
---|
18 | public : |
---|
19 | DECLARE_LIBID(LIBID_AlaxInfoFilterGraphService) |
---|
20 | |
---|
21 | DECLARE_REGISTRY_APPID_RESOURCEID(IDR_MODULE, "{9C4402F4-5831-4593-B788-917609D12169}") |
---|
22 | |
---|
23 | public: |
---|
24 | // CFilterGraphServiceModule |
---|
25 | |
---|
26 | // CAtlServiceModuleT |
---|
27 | HRESULT InitializeSecurity() |
---|
28 | { |
---|
29 | // TODO : Call CoInitializeSecurity and provide the appropriate security settings for your service |
---|
30 | // Suggested - PKT Level Authentication, |
---|
31 | // Impersonation Level of RPC_C_IMP_LEVEL_IDENTIFY |
---|
32 | // and an appropriate Non NULL Security Descriptor. |
---|
33 | _ATLTRY |
---|
34 | { |
---|
35 | static const DWORD g_nAuthenticationLevel = RPC_C_AUTHN_LEVEL_PKT; |
---|
36 | static const DWORD g_nImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE; |
---|
37 | static const DWORD g_nAuthenticationCapabilities = EOAC_NONE; |
---|
38 | ATLENSURE_SUCCEEDED(CoInitializeSecurity(NULL, -1, NULL, NULL, g_nAuthenticationLevel, g_nImpersonationLevel, NULL, g_nAuthenticationCapabilities, NULL)); |
---|
39 | } |
---|
40 | _ATLCATCHALL() |
---|
41 | { |
---|
42 | ATLTRACE(_T("An exception has been caught\n")); |
---|
43 | } |
---|
44 | return S_OK; |
---|
45 | } |
---|
46 | HRESULT RegisterClassObjects(DWORD nClassContext, DWORD nFlags) |
---|
47 | { |
---|
48 | const HRESULT nResult = __super::RegisterClassObjects(nClassContext, nFlags); |
---|
49 | ATLASSERT(nResult == S_FALSE); |
---|
50 | return SUCCEEDED(nResult) ? S_OK : nResult; |
---|
51 | } |
---|
52 | HRESULT PreMessageLoop(INT nShowCommand) |
---|
53 | { |
---|
54 | const HRESULT nResult = __super::PreMessageLoop(nShowCommand); |
---|
55 | ATLASSERT(nResult == S_FALSE); |
---|
56 | return SUCCEEDED(nResult) ? S_OK : nResult; |
---|
57 | } |
---|
58 | VOID RunMessageLoop() |
---|
59 | { |
---|
60 | _ATLTRY |
---|
61 | { |
---|
62 | CComPtr<IFilterGraph2> pFilterGraph; |
---|
63 | ATLENSURE_SUCCEEDED(pFilterGraph.CoCreateInstance(CLSID_FilterGraph)); |
---|
64 | CComPtr<IBaseFilter> pBaseFilter; |
---|
65 | ATLENSURE_SUCCEEDED(pBaseFilter.CoCreateInstance(CLSID_VideoRenderer)); |
---|
66 | ATLENSURE_SUCCEEDED(pFilterGraph->AddFilter(pBaseFilter, CT2CW(_T("Test Video Renderer")))); |
---|
67 | __super::RunMessageLoop(); |
---|
68 | } |
---|
69 | _ATLCATCHALL() |
---|
70 | { |
---|
71 | ATLTRACE(_T("An exception has been caught\n")); |
---|
72 | } |
---|
73 | } |
---|
74 | }; |
---|
75 | |
---|
76 | CFilterGraphServiceModule _AtlModule; |
---|
77 | |
---|
78 | extern "C" int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int nShowCommand) |
---|
79 | { |
---|
80 | return _AtlModule.WinMain(nShowCommand); |
---|
81 | } |
---|
82 | |
---|