PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
nvSDIin.h
Go to the documentation of this file.
1 /***************************************************************************\
2 |* *|
3 |* Copyright 2007 NVIDIA Corporation. All rights reserved. *|
4 |* *|
5 |* NOTICE TO USER: *|
6 |* *|
7 |* This source code is subject to NVIDIA ownership rights under U.S. *|
8 |* and international Copyright laws. Users and possessors of this *|
9 |* source code are hereby granted a nonexclusive, royalty-free *|
10 |* license to use this code in individual and commercial software. *|
11 |* *|
12 |* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE *|
13 |* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR *|
14 |* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH *|
15 |* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF *|
16 |* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR *|
17 |* PURPOSE. IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, *|
18 |* INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES *|
19 |* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN *|
20 |* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING *|
21 |* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE *|
22 |* CODE. *|
23 |* *|
24 |* U.S. Government End Users. This source code is a "commercial item" *|
25 |* as that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting *|
26 |* of "commercial computer software" and "commercial computer software *|
27 |* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) *|
28 |* and is provided to the U.S. Government only as a commercial end item. *|
29 |* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through *|
30 |* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the *|
31 |* source code with only those rights set forth herein. *|
32 |* *|
33 |* Any use of this source code in individual and commercial software must *|
34 |* include, in the user documentation and internal comments to the code, *|
35 |* the above Disclaimer and U.S. Government End Users Notice. *|
36 |* *|
37 |* *|
38 \***************************************************************************/
39 
40 #ifndef NVSDIIN_H
41 #define NVSDIIN_H
42 
43 #if WIN32
44 #include <windows.h>
45 #endif
46 #include <assert.h>
47 #include <stdio.h>
48 
49 #include "nvConfigure.h"
50 #include <GL/glu.h>
51 
52 #include "nvapi.h"
53 
54 // Definitions
55 #define MAX_VIDEO_STREAMS 4
56 #define MEASURE_PERFORMANCE
57 
58 struct nvOptions;
59 
60 //----------------------------------------------------------------------------
61 typedef class CNvSDIinTopology
62 {
63 public:
64  static CNvSDIinTopology& Instance();
65  NVVIOTOPOLOGYTARGET* GetDevice( int index );
66  int GetNumDevice();
67 
68 protected:
70  virtual ~CNvSDIinTopology();
71 
72  bool Init();
73 
74 protected:
75  NVVIOTOPOLOGYTARGET* m_lDevice[NVAPI_MAX_VIO_DEVICES];
77  int m_nDevice;
79 
80 //----------------------------------------------------------------------------
81 // CNvSDIin - class that allows to capture one or multiple streams into a texture/video buffer object
82 typedef class CNvSDIin
83 {
84 public:
85  float m_gviTime;
86  float m_gpuTime;
87 
88  CNvSDIin();
89  ~CNvSDIin();
90 
91  HRESULT Init( nvOptions* options = NULL );
92 
93  HRESULT SetupDevice( int deviceNumber = 0 ); //sets up a particular capture device
94  //it is up to the developer to make sure that the same video slot is not used twice for two different capture devices
95  //on one context. Later this accounting can be made transparent to the user and done in the class
96  HRESULT BindDevice( GLuint videoSlot, HDC hDC );
97 
98  HRESULT BindVideoTexture( GLuint videoTexture, unsigned int stream );
99  HRESULT UnbindVideoTexture( unsigned int stream );
100 
101  HRESULT BindVideoFrameBuffer( GLuint videoBuffer, GLint videoBufferFormat, unsigned int stream );
102  HRESULT UnbindVideoFrameBuffer( unsigned int stream );
103 
104  HRESULT StartCapture();
105  GLenum Capture( GLuint* sequenceNum, GLuint64EXT* captureTime );
106  HRESULT EndCapture();
107 
108  HRESULT Cleanup();
109  HRESULT UnbindDevice();
110 
111  void SetCSCParams( GLfloat* cscMat, GLfloat* cscOffset, GLfloat* cscMin, GLfloat* cscMax );
112 
113  NvVioHandle GetVioHandle();
114  unsigned int GetWidth();
115  unsigned int GetHeight();
116  int GetBufferObjectPitch( unsigned int streamIndex );
117  unsigned int GetNumStreams();
118  NVVIOSIGNALFORMAT GetSignalFormat();
119  HRESULT GetFrameRate( float* rate );
120  int GetDeviceNumber();
121 
122 protected:
123  // Get video input state
124  HRESULT GetVideoInState( NVVIOCONFIG_V1* vioConfig, NVVIOSTATUS* vioStatus );
125  HRESULT SetVideoConfig();
126  void DumpChannelStatus( NVVIOCHANNELSTATUS jack );
127  void DumpStreamStatus( NVVIOSTREAM stream );
128 
129 protected:
130  //Capture Interpretation settings
132  NVVIOCOMPONENTSAMPLING m_Sampling;
135 
136  //Capture detected settings
137  unsigned int m_videoWidth; // Video format resolution in pixels
138  unsigned int m_videoHeight; // Video format resolution in lines
139  float m_fFrameRate; // Video frame rate
140  NVVIOSIGNALFORMAT m_videoFormat;
141  unsigned int m_numStreams;
142  unsigned int m_activeJacks[NVAPI_MAX_VIO_JACKS];
143  NVVIOSIGNALFORMATDETAIL m_signalFormatDetail; // Video Signal Details
144 
145  HDC m_hDC; // GPU device context
146  GLuint m_videoSlot; // GPU Video slot
147 
148  HVIDEOINPUTDEVICENV m_device; // Video input device
149  NvU32 m_vioID; // Unique video device ID
150  NvVioHandle m_vioHandle; // Video device handle
152 
153  //GPU object settings
154  GLfloat m_cscMat[4][4];
155  GLfloat m_cscMax[4];
156  GLfloat m_cscMin[4];
157  GLfloat m_cscOffset[4];
158 
159  bool m_bCaptureStarted; // Set to true when glBeginVideoCaptureNV had successfully completed
160 
162 } CNvSDIin;
163 
164 #endif NVSDIIN_H
HRESULT StartCapture()
Definition: nvSDIin.cpp:975
HRESULT Cleanup()
Definition: nvSDIin.cpp:1071
HRESULT GetFrameRate(float *rate)
Definition: nvSDIin.cpp:1079
NvU32 m_vioID
Definition: nvSDIin.h:149
int GetDeviceNumber()
Definition: nvSDIin.cpp:1087
NVVIOCOMPONENTSAMPLING m_Sampling
Definition: nvSDIin.h:132
virtual ~CNvSDIinTopology()
Definition: nvSDIin.cpp:59
class CNvSDIin CNvSDIin
GLenum Capture(GLuint *sequenceNum, GLuint64EXT *captureTime)
Definition: nvSDIin.cpp:1012
unsigned int GetHeight()
Definition: nvSDIin.cpp:263
HRESULT UnbindVideoFrameBuffer(unsigned int stream)
Definition: nvSDIin.cpp:969
float m_gviTime
Definition: nvSDIin.h:85
GLfloat m_cscMax[4]
Definition: nvSDIin.h:155
static CNvSDIinTopology & Instance()
Definition: nvSDIin.cpp:73
unsigned int m_videoWidth
Definition: nvSDIin.h:137
HRESULT BindDevice(GLuint videoSlot, HDC hDC)
Definition: nvSDIin.cpp:641
int GetNumDevice()
Definition: nvSDIin.cpp:80
GLfloat m_cscMat[4][4]
Definition: nvSDIin.h:154
bool m_bCaptureStarted
Definition: nvSDIin.h:159
HRESULT SetupDevice(int deviceNumber=0)
Definition: nvSDIin.cpp:554
bool m_bInitialized
Definition: nvSDIin.h:76
HRESULT GetVideoInState(NVVIOCONFIG_V1 *vioConfig, NVVIOSTATUS *vioStatus)
Definition: nvSDIin.cpp:319
NVVIOSIGNALFORMAT GetSignalFormat()
Definition: nvSDIin.cpp:963
unsigned int m_videoHeight
Definition: nvSDIin.h:138
NvVioHandle GetVioHandle()
Definition: nvSDIin.cpp:251
NVVIOSIGNALFORMATDETAIL m_signalFormatDetail
Definition: nvSDIin.h:143
float m_fFrameRate
Definition: nvSDIin.h:139
CNvSDIin()
Definition: nvSDIin.cpp:196
void DumpChannelStatus(NVVIOCHANNELSTATUS jack)
Definition: nvSDIin.cpp:269
HRESULT BindVideoFrameBuffer(GLuint videoBuffer, GLint videoBufferFormat, unsigned int stream)
Definition: nvSDIin.cpp:924
HRESULT Init(nvOptions *options=NULL)
Definition: nvSDIin.cpp:294
float m_gpuTime
Definition: nvSDIin.h:86
~CNvSDIin()
Definition: nvSDIin.cpp:237
class CNvSDIinTopology CNvSDIinTopology
unsigned int m_activeJacks[NVAPI_MAX_VIO_JACKS]
Definition: nvSDIin.h:142
int m_BitsPerComponent
Definition: nvSDIin.h:133
HRESULT SetVideoConfig()
Definition: nvSDIin.cpp:365
NvVioHandle m_vioHandle
Definition: nvSDIin.h:150
NVVIOTOPOLOGYTARGET * m_lDevice[NVAPI_MAX_VIO_DEVICES]
Definition: nvSDIin.h:75
GLuint m_captureTimeQuery
Definition: nvSDIin.h:161
bool m_bDualLink
Definition: nvSDIin.h:131
GLfloat m_cscMin[4]
Definition: nvSDIin.h:156
unsigned int GetWidth()
Definition: nvSDIin.cpp:257
HRESULT UnbindVideoTexture(unsigned int stream)
Definition: nvSDIin.cpp:913
HRESULT BindVideoTexture(GLuint videoTexture, unsigned int stream)
Definition: nvSDIin.cpp:902
GLfloat m_cscOffset[4]
Definition: nvSDIin.h:157
unsigned int GetNumStreams()
Definition: nvSDIin.cpp:957
void SetCSCParams(GLfloat *cscMat, GLfloat *cscOffset, GLfloat *cscMin, GLfloat *cscMax)
Definition: nvSDIin.cpp:242
unsigned int m_numStreams
Definition: nvSDIin.h:141
int GetBufferObjectPitch(unsigned int streamIndex)
Definition: nvSDIin.cpp:943
HDC m_hDC
Definition: nvSDIin.h:145
NVVIOSIGNALFORMAT m_videoFormat
Definition: nvSDIin.h:140
NVVIOTOPOLOGYTARGET * GetDevice(int index)
Definition: nvSDIin.cpp:86
HRESULT EndCapture()
Definition: nvSDIin.cpp:1043
void DumpStreamStatus(NVVIOSTREAM stream)
Definition: nvSDIin.cpp:281
GLuint m_videoSlot
Definition: nvSDIin.h:146
HRESULT UnbindDevice()
Definition: nvSDIin.cpp:1056
int m_deviceNumber
Definition: nvSDIin.h:151
HVIDEOINPUTDEVICENV m_device
Definition: nvSDIin.h:148
int m_ExpansionEnable
Definition: nvSDIin.h:134