Pleora Technologies Inc. eBUS SDK v7.0.1.7536 API



Loading...
Searching...
No Matches
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
19typedef std::list<PvBuffer *> PvBufferList;
20
21class PvDSSource;
22class IVideoInfoHeader;
23
24typedef std::vector<std::pair<int, int>> ResolutionList;
25
26
27namespace PtUtilsLib
28{
29 class Logger;
30}
31
32
33class PvDSStream :
34 public CSourceStream,
35 public IAMStreamConfig,
36 public IKsPropertySet
37{
38public:
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 );
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();
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
159#ifdef OPENCV_PRESENT
160 void EnableHotPixelDiagnostic( cv::Mat aMat );
161#endif
162
163private:
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
Used to convert a PvBuffer to another pixel type.
Definition PvBufferConverter.h:67
Represents a block of GigE Vision or USB3 Vision data in memory.
Definition PvBuffer.h:111
Definition PvDSSource.h:18
Definition PvDSStream.h:37
HRESULT GetOutputResolution(int &aWidth, int &aHeight) const
If zoom factor is greater than 1, get the output resolution.
Definition PvDSStream.cpp:2145
HRESULT GetParameterCount(int &aValue)
Returns the parameter count for the currently selected parameter array.
Definition PvDSStream.cpp:1678
HRESULT SetParameterValue(const std::wstring &aName, const std::wstring &aValue, std::wstring &aMessage)
Tries changing the value of the parameter at aIndex in the currently selected parameter array.
Definition PvDSStream.cpp:1771
HRESULT SetDeviceID(const std::wstring &aValue)
Sets the device ID.
Definition PvDSStream.cpp:1531
HRESULT DecideBufferSize(IMemAllocator *pIMemAlloc, ALLOCATOR_PROPERTIES *pProperties)
This method is called after the pins are connected to allocate buffers to stream data.
Definition PvDSStream.cpp:858
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
QueryInterface.
Definition PvDSStream.cpp:246
HRESULT GetMediaType(int iPosition, CMediaType *pMediaType)
See Directshow help topic for IAMStreamConfig for details on this method.
Definition PvDSStream.cpp:730
PvGenParameterArray * GetSelectedParameters()
Returns the currently selected parameters, if available.
Definition PvDSStream.cpp:1643
HRESULT GetParameterName(int aIndex, std::wstring &aValue)
Returns the name of the parameter at aIndex in the currently selected parameter array.
Definition PvDSStream.cpp:1696
void CopyImageYUV(PvBuffer *aBuffer, BYTE *pData, bool aIsYUYV)
Copies an image into the DirectShow buffer.
Definition PvDSStream.cpp:609
STDMETHODIMP Notify(IBaseFilter *pSender, Quality q)
Notify. Ignore quality management messages sent from the downstream filter.
Definition PvDSStream.cpp:704
HRESULT SetWidth(int aValue)
Changes the filter width.
Definition PvDSStream.cpp:2043
~PvDSStream()
Destructor.
Definition PvDSStream.cpp:231
HRESULT GetParameterAccess(const std::wstring &aName, bool &aAvailable, bool &aReadable, bool &aWritable)
Returns the current access mode for a feature.
Definition PvDSStream.cpp:1872
HRESULT STDMETHODCALLTYPE GetNumberOfCapabilities(int *piCount, int *piSize)
GetNumberOfCapabilities.
Definition PvDSStream.cpp:968
HRESULT SetDiagnosticEnabled(bool aValue)
Sets whether diagnostic output on received images is enabled or not.
Definition PvDSStream.cpp:1354
HRESULT DisconnectDevice()
Disconnects device, stream.
Definition PvDSStream.cpp:1151
HRESULT STDMETHODCALLTYPE Get(REFGUID guidPropSet, DWORD dwPropID, void *pInstanceData, DWORD cbInstanceData, void *pPropData, DWORD cbPropData, DWORD *pcbReturned)
Get: Return the pin category (our only property).
Definition PvDSStream.cpp:1076
HRESULT LoadDefault()
Loads the default configuration from Registry.
Definition PvDSStream.cpp:2248
HRESULT GetParameterValue(const std::wstring &aName, std::wstring &aValue)
Returns the value of the parameter at aIndex in the currently selected parameter array.
Definition PvDSStream.cpp:1747
HRESULT STDMETHODCALLTYPE SetFormat(AM_MEDIA_TYPE *pmt)
SetFormat.
Definition PvDSStream.cpp:937
HRESULT SetKernelSize(int aValue)
Sets the kernel size for hot pixel correction.
Definition PvDSStream.cpp:2111
HRESULT FillBuffer(IMediaSample *pms)
Diagnostic for Hot pixel corrections.
Definition PvDSStream.cpp:352
HRESULT SetHeight(int aValue)
Changes the filter height.
Definition PvDSStream.cpp:2061
void SyncFormat()
Attempts to sync the device image size with the filter/graph configuration.
Definition PvDSStream.cpp:1436
void CopyImageRGB(PvBuffer *aBuffer, BYTE *pData, bool aEnableAdvanced)
Copies an image into the DirectShow buffer.
Definition PvDSStream.cpp:499
HRESULT MakeDefault()
Makes the current basic configuration (mostly camera selection) default.
Definition PvDSStream.cpp:2180
HRESULT SetParametersSelector(int aValue)
Sets the current parameters selector.
Definition PvDSStream.cpp:1601
HRESULT GetParameterType(const std::wstring &aName, std::wstring &aType)
Returns a string representing the type of the parameter.
Definition PvDSStream.cpp:1809
HRESULT GetSourceCount(int &aValue)
Returns the number of source available on the device.
Definition PvDSStream.cpp:1542
HRESULT STDMETHODCALLTYPE Set(REFGUID guidPropSet, DWORD dwID, void *pInstanceData, DWORD cbInstanceData, void *pPropData, DWORD cbPropData)
Set.
Definition PvDSStream.cpp:1065
void OutputDiagnostics(BYTE *pData)
Writes diagnostics output on the buffer.
Definition PvDSStream.cpp:2328
HRESULT ConnectIfNeeded()
Connects to a GEV or U3V device (if needed)
Definition PvDSStream.cpp:1203
HRESULT GetParameterCategory(const std::wstring &aName, std::wstring &aValue)
Returns the category of the parameter at aIndex in the currently selected parameter array.
Definition PvDSStream.cpp:1720
HRESULT ResetDefault()
Clears the default basic configuration.
Definition PvDSStream.cpp:2304
HRESULT StopAcquisition()
Stops image acquisition.
Definition PvDSStream.cpp:1415
HRESULT SetOutputResolution(int aWidth, int aHeight)
Sets the output resolution.
Definition PvDSStream.cpp:2158
HRESULT SetZoomValue(int aZoomValue)
Sets the zoom value.
Definition PvDSStream.cpp:2129
HRESULT OnThreadDestroy(void)
Called when a graph is stopped.
Definition PvDSStream.cpp:904
HRESULT CheckMediaType(const CMediaType *pMediaType)
This method is called to see if a given output format is supported.
Definition PvDSStream.cpp:810
HRESULT ParameterExecute(const std::wstring &aName, std::wstring &aMessage)
Executes a parameter of the currently selected parameter array.
Definition PvDSStream.cpp:1898
HRESULT SetMediaType(const CMediaType *pmt)
This is called when the output format has been negotiated.
Definition PvDSStream.cpp:714
HRESULT SetOutputPixelType(int aValue)
Sets the output pixel type.
Definition PvDSStream.cpp:2079
HRESULT OnThreadStartPlay(void)
Called when a graph starts playing.
Definition PvDSStream.cpp:920
HRESULT StartAcquisition()
Starts image acquisition.
Definition PvDSStream.cpp:1377
HRESULT GetSourceName(int aIndex, std::wstring &aValue)
Returns the name of a source.
Definition PvDSStream.cpp:1564
HRESULT GetParametersAvailable(bool &aValue) const
Returns if a specific parameter array is available.
Definition PvDSStream.cpp:1617
IVideoInfoHeader * AllocPVIFrom(const CMediaType *aMediaType)
Allocs a PVI from a specific media type.
Definition PvDSStream.cpp:2698
HRESULT GetParameterPossibleValue(const std::wstring &aName, int aIndex, std::wstring &aValue)
For a parameter of the currently selected parameter array, returns one of the possible values (if app...
Definition PvDSStream.cpp:1960
void CalculateResolutionsForZoom()
Calculate the resolutions to support zoom.
Definition PvDSStream.cpp:272
HRESULT STDMETHODCALLTYPE QuerySupported(REFGUID guidPropSet, DWORD dwPropID, DWORD *pTypeSupport)
QuerySupported: Query whether the pin supports the specified property.
Definition PvDSStream.cpp:1125
HRESULT GetParameterPossibleValueCount(const std::wstring &aName, int &aCount)
For a parameter of the currently selected parameter array, returns how many possible values there are...
Definition PvDSStream.cpp:1927
HRESULT Load(const PvString &aContent, bool aBasic=false)
Loads and applies the filter persistence data.
Definition PvDSStream.cpp:2643
HRESULT SetSource(const std::wstring &aValue)
Sets the source.
Definition PvDSStream.cpp:1590
void DrawText(BYTE *pData, const std::wstring &aText)
Draws some text on the output buffer.
Definition PvDSStream.cpp:2504
HRESULT STDMETHODCALLTYPE GetFormat(AM_MEDIA_TYPE **ppmt)
GetFormat.
Definition PvDSStream.cpp:956
HRESULT STDMETHODCALLTYPE GetStreamCaps(int iIndex, AM_MEDIA_TYPE **pmt, BYTE *pSCC)
GetStreamCaps.
Definition PvDSStream.cpp:981
HRESULT OnThreadCreate(void)
Called when graph is run.
Definition PvDSStream.cpp:893
HRESULT Save(PvString &aContent, bool aBasic=false)
Saves the filter persistence data.
Definition PvDSStream.cpp:2591
HRESULT GetParameterVisibility(const std::wstring &aName, int &aVisibility)
Returns the visibility of a GenICam parameter.
Definition PvDSStream.cpp:2015
Connect, configure and control a GigE Vision or USB3 Vision device.
Definition PvDevice.h:42
GenICam feature array.
Definition PvGenParameterArray.h:73
Helper class for receiving data from a GigE Vision or USB3 Vision transmitter.
Definition PvPipeline.h:33
Result information.
Definition PvResult.h:30
Receive data from a GigE Vision or USB3 Vision transmitter.
Definition PvStream.h:51
String class.
Definition PvString.h:26

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