AJA NTV2 SDK  17.6.0.2675
NTV2 SDK 17.6.0.2675
main.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #include "ntv2vcam.h"
9 
10 #if defined(AJALinux)
11  int main (int argc, const char** argv)
12  {
13  NTV2VCAM vw;
14  if (vw.Initialize(argc, argv))
15  return vw.Run();
16  return 0;
17  }
18 #endif // if defined(AJALinux)
19 
20 #if defined(AJA_WINDOWS)
21  const AMOVIESETUP_MEDIATYPE gVcamOutputVideoPinTypes =
22  {
23  &MEDIATYPE_Video,
24  &MEDIASUBTYPE_UYVY
25  };
26 
27  const AMOVIESETUP_PIN gVcamOutputVideoPin =
28  {
29  VCAM_VIDEO_PIN_NAME_W,
30  FALSE,
31  TRUE,
32  FALSE,
33  FALSE,
34  &CLSID_NULL,
35  NULL,
36  1,
37  &gVcamOutputVideoPinTypes
38  };
39 
40  const AMOVIESETUP_MEDIATYPE gVcamOutputAudioPinTypes =
41  {
42  &MEDIATYPE_Audio,
43  &MEDIASUBTYPE_PCM
44  };
45 
46  const AMOVIESETUP_PIN gVcamOutputAudioPin =
47  {
48  VCAM_AUDIO_PIN_NAME_W,
49  FALSE,
50  TRUE,
51  FALSE,
52  FALSE,
53  &CLSID_NULL,
54  NULL,
55  1,
56  &gVcamOutputAudioPinTypes
57  };
58 
59  const AMOVIESETUP_PIN gVcamOutputPins[] =
60  {
61  gVcamOutputVideoPin,
62  gVcamOutputAudioPin
63  };
64 
65  const AMOVIESETUP_FILTER gVcamFilter =
66  {
67  &CLSID_VirtualWebcam,
68  VCAM_FILTER_NAME_W,
69  MERIT_DO_NOT_USE,
70  2,
71  gVcamOutputPins
72  };
73 
75  {
76  {
77  VCAM_FILTER_NAME_W,
78  &CLSID_VirtualWebcam,
79  NTV2VCAM::CreateInstance,
80  NULL,
81  &gVcamFilter
82  }
83  };
84  int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
85 
86  extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
87  BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
88  {
89  return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved);
90  }
91 
92  STDAPI DllRegisterServer()
93  {
94  HRESULT hr = AMovieDllRegisterServer2(TRUE);
95  if (SUCCEEDED(hr))
96  {
97  IFilterMapper2* pMapper = NULL;
98  hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, IID_IFilterMapper2, (void**)&pMapper);
99  if (SUCCEEDED(hr))
100  {
101  REGFILTER2 rf2FilterReg = { 1, MERIT_NORMAL, 1, &gVcamOutputVideoPin };
102  pMapper->RegisterFilter(CLSID_VirtualWebcam, VCAM_FILTER_NAME_W, NULL, &CLSID_VideoInputDeviceCategory, VCAM_FILTER_NAME_W, &rf2FilterReg);
103 
104  rf2FilterReg = { 1, MERIT_NORMAL, 1, &gVcamOutputAudioPin };
105  pMapper->RegisterFilter(CLSID_VirtualWebcam, VCAM_FILTER_NAME_W, NULL, &CLSID_AudioInputDeviceCategory, VCAM_FILTER_NAME_W, &rf2FilterReg);
106 
107  pMapper->Release();
108  }
109  }
110  return hr;
111  }
112 
113  STDAPI DllUnregisterServer()
114  {
115  HRESULT hr = AMovieDllRegisterServer2(FALSE);
116  if (SUCCEEDED(hr))
117  {
118  IFilterMapper2* pMapper = NULL;
119  hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, IID_IFilterMapper2, (void**)&pMapper);
120  if (SUCCEEDED(hr))
121  {
122  pMapper->UnregisterFilter(&CLSID_VideoInputDeviceCategory, VCAM_FILTER_NAME_W, CLSID_VirtualWebcam);
123  pMapper->UnregisterFilter(&CLSID_AudioInputDeviceCategory, VCAM_FILTER_NAME_W, CLSID_VirtualWebcam);
124  pMapper->Release();
125  }
126  }
127  return hr;
128  }
129 #endif // if defined(AJA_WINDOWS)
AMOVIESETUP_PIN
REGFILTERPINS AMOVIESETUP_PIN
Definition: combase.h:114
HANDLE
short HANDLE
Definition: ajatypes.h:318
NULL
#define NULL
Definition: ntv2caption608types.h:19
ntv2vcam.h
Header file for NTV2VCAM demonstration class.
main
int main(int argc, const char **argv)
Definition: main.cpp:30
CFactoryTemplate
Definition: combase.h:260
AMovieDllRegisterServer2
STDAPI AMovieDllRegisterServer2(BOOL bRegister)
Definition: dllsetup.cpp:368
_AMOVIESETUP_FILTER
Definition: combase.h:116
DllEntryPoint
DECLSPEC_NOINLINE BOOL WINAPI DllEntryPoint(HINSTANCE hInstance, ULONG ulReason, __inout_opt LPVOID pv)
Definition: dllentry.cpp:272
g_Templates
CFactoryTemplate g_Templates[]
g_cTemplates
int g_cTemplates
ULONG
ULONG(__stdcall *_RegisterTraceGuids)(__in IN WMIDPREQUEST RequestAddress
hr
__out HRESULT & hr
Definition: pstream.cpp:145
AMOVIESETUP_MEDIATYPE
REGPINTYPES AMOVIESETUP_MEDIATYPE
Definition: combase.h:111