Pleora Technologies Inc. eBUS SDK v6.2.8.5877 API



PvDSStream.h
1 // *****************************************************************************
2 //
3 // Copyright (c) 2012, Pleora Technologies Inc., All rights reserved.
4 //
5 // *****************************************************************************
6 
7 #pragma once
8 
9 #include <PvPipeline.h>
10 #include <PvDevice.h>
11 #include <PvStream.h>
12 #include <PvBufferConverter.h>
13 #include <list>
14 #include <vector>
15 #ifdef OPENCV_PRESENT
16 #include <opencv2/opencv.hpp>
17 #endif
18 
19 typedef std::list<PvBuffer *> PvBufferList;
20 
21 class PvDSSource;
22 class IVideoInfoHeader;
23 
24 typedef std::vector<std::pair<int, int>> ResolutionList;
25 
26 
27 namespace PtUtilsLib
28 {
29  class Logger;
30 }
31 
32 
33 class PvDSStream :
34  public CSourceStream,
35  public IAMStreamConfig,
36  public IKsPropertySet
37 {
38 public:
39 
40  // IUnknown
41  STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
42  STDMETHODIMP_(ULONG) AddRef() { return GetOwner()->AddRef(); }
43  STDMETHODIMP_(ULONG) Release() { return GetOwner()->Release(); }
44 
45  // IQualityControl
46  STDMETHODIMP Notify( IBaseFilter * pSender, Quality q );
47 
48  // IAMStreamConfig
49  HRESULT STDMETHODCALLTYPE SetFormat( AM_MEDIA_TYPE *pmt );
50  HRESULT STDMETHODCALLTYPE GetFormat( AM_MEDIA_TYPE **ppmt );
51  HRESULT STDMETHODCALLTYPE GetNumberOfCapabilities( int *piCount, int *piSize );
52  HRESULT STDMETHODCALLTYPE GetStreamCaps( int iIndex, AM_MEDIA_TYPE **pmt, BYTE *pSCC );
53 
54  // IKsPropertySet
55  HRESULT STDMETHODCALLTYPE Set( REFGUID guidPropSet, DWORD dwID, void *pInstanceData, DWORD cbInstanceData, void *pPropData, DWORD cbPropData );
56  HRESULT STDMETHODCALLTYPE Get( REFGUID guidPropSet, DWORD dwPropID, void *pInstanceData,DWORD cbInstanceData, void *pPropData, DWORD cbPropData, DWORD *pcbReturned );
57  HRESULT STDMETHODCALLTYPE QuerySupported( REFGUID guidPropSet, DWORD dwPropID, DWORD *pTypeSupport );
58 
59  // CSourceStream
60  PvDSStream( HRESULT *phr, PvDSSource *pParent, LPCWSTR pPinName );
61  ~PvDSStream();
62 
63  HRESULT FillBuffer( IMediaSample *pms );
64  HRESULT DecideBufferSize( IMemAllocator *pIMemAlloc, ALLOCATOR_PROPERTIES *pProperties );
65  HRESULT CheckMediaType( const CMediaType *pMediaType );
66  HRESULT GetMediaType( int iPosition, CMediaType *pMediaType );
67  HRESULT SetMediaType( const CMediaType *pmt );
68 
69  HRESULT OnThreadCreate( void );
70  HRESULT OnThreadDestroy(void);
71  HRESULT OnThreadStartPlay(void);
72 
73  HRESULT StartAcquisition();
74  HRESULT StopAcquisition();
75 
76  HRESULT Save( PvString &aContent, bool aBasic = false );
77  HRESULT Load( const PvString &aContent, bool aBasic = false );
78  HRESULT LoadDefault();
79 
80  void SyncFormat();
81  PvGenParameterArray *GetSelectedParameters();
82  void CopyImageYUV( PvBuffer *aBuffer, BYTE *pData, bool aIsYUYV );
83  void CopyImageRGB( PvBuffer *aBuffer, BYTE *pData, bool aEnableAdvanced );
84  void DrawText( BYTE *pData, const std::wstring &aText );
85  void OutputDiagnostics( BYTE *pData );
86 
87  IVideoInfoHeader *AllocPVIFrom( const CMediaType *aMediaType );
88 
89  HRESULT GetRole( int &aValue ) const { aValue = mRole; return NOERROR; }
90  HRESULT SetRole( int aValue ) { mRole = aValue; return NOERROR; }
91  HRESULT GetUnicastPort( int &aValue ) const { aValue = mUnicastPort; return NOERROR; }
92  HRESULT SetUnicastPort( int aValue ) { mUnicastPort = aValue; return NOERROR; }
93  HRESULT GetMulticastIP( std::wstring &aValue ) const { aValue = mMulticastIP; return NOERROR; }
94  HRESULT SetMulticastIP( const std::wstring &aValue ) { mMulticastIP = aValue; return NOERROR; }
95  HRESULT GetMulticastPort( int &aValue ) const { aValue = mMulticastPort; return NOERROR; }
96  HRESULT SetMulticastPort( int aValue ) { mMulticastPort = aValue; return NOERROR; }
97  HRESULT DisconnectDevice();
98  HRESULT ConnectIfNeeded();
99 
100  HRESULT GetDiagnosticEnabled( bool &aValue ) const { aValue = mDiagnosticEnabled; return NOERROR; }
101  HRESULT SetDiagnosticEnabled( bool aValue );
102 
103  HRESULT GetDeviceID( std::wstring &aValue ) const { aValue = mDeviceID; return NOERROR; }
104  HRESULT SetDeviceID( const std::wstring &aValue );
105  HRESULT GetSourceCount( int &aValue );
106  HRESULT GetSourceName( int aIndex, std::wstring &aValue );
107  HRESULT GetSource( std::wstring &aValue ) const { aValue = mSource; return NOERROR; }
108  HRESULT SetSource( const std::wstring &aValue );
109  HRESULT GetChannel( int &aValue ) const { aValue = mChannel; return NOERROR; }
110  HRESULT SetChannel( int aValue ) { mChannel = aValue; return NOERROR; }
111 
112  HRESULT GetBufferCount( int &aValue ) const { aValue = mBufferCount; return NOERROR; }
113  HRESULT SetBufferCount( int aValue ) { mBufferCount = aValue; return NOERROR; }
114  HRESULT GetDefaultBufferSize( int &aValue ) const { aValue = mDefaultBufferSize; return NOERROR; }
115  HRESULT SetDefaultBufferSize( int aValue ) { mDefaultBufferSize = aValue; return NOERROR; }
116  HRESULT GetDropThreshold( int &aValue ) const { aValue = mDropThreshold; return NOERROR; }
117  HRESULT SetDropThreshold( int aValue ) { mDropThreshold = aValue; return NOERROR; }
118  HRESULT GetWidth( int &aValue ) const { aValue = mDeviceWidth; return NOERROR; }
119  HRESULT SetWidth( int aValue );
120  HRESULT GetHeight( int &aValue ) const { aValue = mDeviceHeight; return NOERROR; }
121  HRESULT SetHeight( int aValue );
122 
123  HRESULT GetParametersSelector( int &aValue ) const { aValue = mParameterSelector; return NOERROR; }
124  HRESULT SetParametersSelector( int aValue );
125  HRESULT GetParametersAvailable( bool &aValue ) const;
126  HRESULT GetParameterCount( int &aValue );
127  HRESULT GetParameterName( int aIndex, std::wstring &aValue );
128  HRESULT GetParameterCategory( const std::wstring &aName, std::wstring &aValue );
129  HRESULT GetParameterValue( const std::wstring &aName, std::wstring &aValue );
130  HRESULT SetParameterValue( const std::wstring &aName, const std::wstring &aValue, std::wstring &aMessage );
131  HRESULT GetParameterType( const std::wstring &aName, std::wstring &aType );
132  HRESULT GetParameterAccess( const std::wstring &aName, bool &aAvailable, bool &aReadable, bool &aWritable );
133  HRESULT ParameterExecute( const std::wstring &aName, std::wstring &aMessage );
134  HRESULT GetParameterPossibleValueCount( const std::wstring &aName, int &aCount );
135  HRESULT GetParameterPossibleValue( const std::wstring &aName, int aIndex, std::wstring &aValue );
136  HRESULT GetParameterVisibility( const std::wstring &aName, int &aVisibility );
137 
138  LONGLONG GetImageCount() const { return mImageCount; }
139  LONGLONG GetImageDroppedCount() const { return mImageDroppedCount; }
140  int GetLastImageSize() const { return mLastImageSize; }
141 
142  HRESULT MakeDefault();
143  HRESULT ResetDefault();
144  HRESULT GetDefaultSummary( std::wstring &aSummary ) { aSummary = mDefaultSummary; return NOERROR; }
145 
146  HRESULT GetOutputPixelType( int &aValue ) const { aValue = mOutputPixelTypeIndex; return NOERROR; }
147  HRESULT SetOutputPixelType( int aValue );
148 
149  HRESULT GetKernelSize( int &aValue ) const { aValue = mKernelSize; return NOERROR; }
150  HRESULT SetKernelSize( int aValue );
151 
152  HRESULT GetZoomValue( int &aZoomValue ) const { aZoomValue = mZoomValue; return NOERROR; }
153  HRESULT SetZoomValue( int aZoomValue );
154 
155  HRESULT GetOutputResolution( int &aWidth, int &aHeight ) const;
156  HRESULT SetOutputResolution( int aWidth, int aHeight );
157 
158  void CalculateResolutionsForZoom();
159 #ifdef OPENCV_PRESENT
160  void EnableHotPixelDiagnostic( cv::Mat aMat );
161 #endif
162 
163 private:
164 
165  PvDSSource *m_pParent;
166 
167  PvDevice *mDevice;
168  PvStream *mStream;
169  PvPipeline *mPipeline;
170 
171  std::wstring mActiveDeviceID;
172  std::wstring mActiveSource;
173  int mActiveChannel;
174  int mActiveUnicastPort;
175  std::wstring mActiveMulticastIP;
176  int mActiveMulticastPort;
177 
178  int mDeviceWidth;
179  int mDeviceHeight;
180  int mOutputWidth;
181  int mOutputHeight;
182  int mWidth;
183  int mHeight;
184  int mLastImageWidth;
185  int mLastImageHeight;
186  int mLastImageSize;
187  int mOutputPixelTypeIndex; // 0 for RGB, 1 for YUV
188  int mKernelSize;
189  int mPixelVariationScore;
190  int mZoomValue;
191 
192  REFERENCE_TIME mReferenceTime;
193  REFERENCE_TIME mLastTime;
194  LONGLONG mImageCount;
195  LONGLONG mImageDroppedCount;
196 
197  HANDLE mMutex;
198  BOOL mStreaming;
199 
200  PvResult mLastConnect;
201  PvResult mLastOpen;
202  std::wstring mLastWarning;
203 
204  int mRole;
205  int mUnicastPort;
206  std::wstring mMulticastIP;
207  int mMulticastPort;
208  bool mDiagnosticEnabled;
209  std::wstring mDeviceID;
210  std::wstring mSource;
211  int mChannel;
212  int mBufferCount;
213  int mDefaultBufferSize;
214  int mDropThreshold;
215  std::wstring mDefaultSummary;
216 
217  int mParameterSelector;
218 
219  PvBufferConverter mConverter;
220 
221  ULONG_PTR mGdiplusToken;
222 
223  IReferenceClock *mClock;
224 
225  bool mClearOutputFlag;
226 
227  ResolutionList mResolutions;
228 };
229 
230 
Receive data from a GigE Vision or USB3 Vision transmitter.
Definition: PvStream.h:39
Helper class for receiving data from a GigE Vision or USB3 Vision transmitter.
Definition: PvPipeline.h:21
Used to convert a PvBuffer to another pixel type.
Definition: PvBufferConverter.h:28
String class.
Definition: PvString.h:21
Result information.
Definition: PvResult.h:13
Definition: PvDeviceAdapter.h:16
Definition: PvDSStream.h:33
Represents a block of GigE Vision or USB3 Vision data in memory.
Definition: PvBuffer.h:47
GenICam feature array.
Definition: PvGenParameterArray.h:38
Definition: PvDSSource.h:12
Connect, configure and control a GigE Vision or USB3 Vision device.
Definition: PvDevice.h:30

Copyright (c) 2002-2021 Pleora Technologies Inc.
www.pleora.com