Version 8.9.0
 
Loading...
Searching...
No Matches
IRDeviceDS.h
1/******************************************************************************
2 * Copyright (c) 2012-2017 All Rights Reserved, http://www.evocortex.com *
3 * Evocortex GmbH *
4 * Emilienstr. 1 *
5 * 90489 Nuremberg *
6 * Germany *
7 * *
8 * Contributors: *
9 * Initial version for Linux 64-Bit platform supported by Fraunhofer IPA, *
10 * http://www.ipa.fraunhofer.de *
11 *****************************************************************************/
12
13#pragma once
14#pragma comment(lib, "strmiids")
15
16#define SKIP_DXTRANS
17//#define SHOW_DEBUG_RENDERER
18#define _CRT_SECURE_NO_WARNINGS
19
20/* If you are having the problem you can't open dxtrans.h:
21 * Open qedit.h and add this to the start of the file:
22 *
23 * #ifdef SKIP_DXTRANS
24 * #define __IDxtAlphaSetter_INTERFACE_DEFINED__
25 * #define __IDxtJpeg_INTERFACE_DEFINED__
26 * #define __IDxtKey_INTERFACE_DEFINED__
27 * #define __IDxtCompositor_INTERFACE_DEFINED__
28 * #endif
29 *
30 * Also replace the line
31 * #include "dxtrans.h"
32 * with:
33 * #ifndef SKIP_DXTRANS
34 * #include "dxtrans.h"
35 * #endif
36 */
37
38#include "devices/directshow/SampleGrabber.h"
39#include <windows.h>
40#include <map>
41#include <atomic>
42#include "IRDevice.h"
43#include "irdirectsdk_defs.h"
44#include "Timer.h"
45
46namespace evo
47{
48
49#ifndef MAXLONGLONG
50#define MAXLONGLONG 0x7FFFFFFFFFFFFFFF
51#endif
52
53#ifndef MAX_DEVICE_NAME
54#define MAX_DEVICE_NAME 80
55#endif
56
57#ifndef BITS_PER_PIXEL
58#define BITS_PER_PIXEL 16
59#endif
60
61class IRDeviceDS;
62struct ISampleGrabber;
63class CallbackHandler;
64
65#define SAFE_DS_RELEASE(x) { if (x) x->Release(); x = NULL; }
66
72class __IRDIRECTSDK_API__ IRDeviceDS : public IRDevice
73{
74 friend class CallbackHandler;
75
76public:
77
82
88
95 static bool findSerial(unsigned long &query, unsigned int skipNResults = 0);
96
102
108
113 const char* getFriendlyName();
114
120 virtual void run();
121
125 virtual void exit();
126
131 bool isOpen();
132
139 virtual IRDeviceError getFrame(unsigned char* buffer, double* timestamp = NULL, int timeoutMilliseconds = -1);
140
141private:
145 IRDeviceDS(unsigned short bufferQueueSize);
146
147 static IRDeviceDS* createVideoGraph(unsigned long serial, int videoFormatIndex, unsigned short bufferQueueSize);
148
149 static void removeDownstream(IBaseFilter *pf, IFilterGraph2* pFg);
150
151 static HRESULT findCaptureDevice(IRDeviceDS ** device, unsigned long serial, unsigned short bufferQueueSize);
152
153 HRESULT initializeGraph();
154
155 void onRawFrame(unsigned char* data, int len);
156
157 static unsigned long determineSerialNumber(wchar_t* deviceName);
158
159 static void deleteMediaType(AM_MEDIA_TYPE *pmt);
160
161 char* _friendlyName;
162
163 WCHAR* _filterName;
164
165 IBaseFilter* _sourceFilter;
166
167 IBaseFilter* _sampleGrabberFilter;
168
169 IBaseFilter* _nullRenderer;
170
171 IEvoSampleGrabber* _sampleGrabber;
172
173 ICaptureGraphBuilder2* _builder;
174
175 IMediaControl* _control;
176
177 IFilterGraph2* _graph;
178
179 CallbackHandler* _callbackHandler;
180
181 IMediaEventEx* _eventEx;
182
183 unsigned char** _rawBuffer;
184
185 double* _rawBufferTimestamps;
186
187 byte _rawBufferIndexWrite;
188
189 byte _rawBufferIndexRead;
190
191 byte _newFrameCount;
192
193 CRITICAL_SECTION _critSec;
194
195 bool _run;
196
197 Timer _timer;
198
199 bool _isOpen;
200
201 HANDLE _available;
202
203 const unsigned short _bufferQueueSize = 4;
204};
205
206} // namespace
DirectShow device interface (Windows platforms)
Definition: IRDeviceDS.h:73
static bool findSerial(unsigned long &query, unsigned int skipNResults=0)
Determine serial number of attached device(s)
const char * getFriendlyName()
Get readable name of attached device.
int stopStreaming()
Stop video streaming.
virtual IRDeviceError getFrame(unsigned char *buffer, double *timestamp=NULL, int timeoutMilliseconds=-1)
Acquire one frame.
~IRDeviceDS()
Destructor.
virtual void exit()
Exit blocking run method, if previously called.
int startStreaming()
Start video streaming.
static IRDeviceDS * createInstance(IRDeviceParams &params)
Factory method.
virtual void run()
Run device, i.e., treat main thread in blocking mode.
bool isOpen()
Check if device was already opened.
Time measurement class.
Definition: Timer.h:27
Structure containing device parameters.
Definition: IRDeviceParams.h:125