3#if defined(ENABLE_OPENNI) || defined(ENABLE_OPENNI2)
10#include <wmcodecdsp.h>
14#pragma comment(lib, "Msdmo.lib")
15#pragma comment(lib, "amstrmid.lib")
28class COpenNiMedia :
public IMediaObject
32 ~COpenNiMedia(
void) {}
38 STDMETHODIMP_(ULONG) AddRef() {
return 2;}
39 STDMETHODIMP_(ULONG) Release() {
return 1;}
41 STDMETHODIMP QueryInterface(REFIID riid,
void** ppv)
43 if (riid==IID_IUnknown) {
45 *ppv = (IUnknown*)
this;
48 else if (riid==IID_IMediaBuffer) {
50 *ppv = (IMediaObject*)
this;
53 else return E_NOINTERFACE;
60 HRESULT STDMETHODCALLTYPE SetOutputType(DWORD index,
const DMO_MEDIA_TYPE *pmt, DWORD flags);
61 HRESULT STDMETHODCALLTYPE GetOutputCurrentType(DWORD index, DMO_MEDIA_TYPE *pmt);
62 HRESULT STDMETHODCALLTYPE ProcessOutput(DWORD dwFlags, DWORD oputBufferCount, DMO_OUTPUT_DATA_BUFFER *outputBuffers, DWORD *pdwStatus);
65 HRESULT STDMETHODCALLTYPE GetStreamCount(
66 DWORD *pcInputStreams,
67 DWORD *pcOutputStreams) {
return E_NOTIMPL;}
69 HRESULT STDMETHODCALLTYPE GetInputStreamInfo(
70 DWORD dwInputStreamIndex,
71 DWORD *pdwFlags) {
return E_NOTIMPL;}
73 HRESULT STDMETHODCALLTYPE GetOutputStreamInfo(
74 DWORD dwOutputStreamIndex,
75 DWORD *pdwFlags) {
return E_NOTIMPL;}
77 HRESULT STDMETHODCALLTYPE GetInputType(
78 DWORD dwInputStreamIndex,
80 DMO_MEDIA_TYPE *pmt) {
return E_NOTIMPL;}
82 HRESULT STDMETHODCALLTYPE GetOutputType(
83 DWORD dwOutputStreamIndex,
85 DMO_MEDIA_TYPE *pmt) {
return E_NOTIMPL;}
87 HRESULT STDMETHODCALLTYPE SetInputType(
88 DWORD dwInputStreamIndex,
89 const DMO_MEDIA_TYPE *pmt,
90 DWORD dwFlags) {
return E_NOTIMPL;}
92 HRESULT STDMETHODCALLTYPE GetInputCurrentType(
93 DWORD dwInputStreamIndex,
94 DMO_MEDIA_TYPE *pmt) {
return E_NOTIMPL;}
96 HRESULT STDMETHODCALLTYPE GetInputSizeInfo(
97 DWORD dwInputStreamIndex,
99 DWORD *pcbMaxLookahead,
100 DWORD *pcbAlignment) {
return E_NOTIMPL;}
102 HRESULT STDMETHODCALLTYPE GetOutputSizeInfo(
103 DWORD dwOutputStreamIndex,
105 DWORD *pcbAlignment) {
return E_NOTIMPL;}
107 HRESULT STDMETHODCALLTYPE GetInputMaxLatency(
108 DWORD dwInputStreamIndex,
109 REFERENCE_TIME *prtMaxLatency) {
return E_NOTIMPL;}
111 HRESULT STDMETHODCALLTYPE SetInputMaxLatency(
112 DWORD dwInputStreamIndex,
113 REFERENCE_TIME rtMaxLatency) {
return E_NOTIMPL;}
115 HRESULT STDMETHODCALLTYPE Flush(
void) {
return E_NOTIMPL;}
117 HRESULT STDMETHODCALLTYPE Discontinuity(
118 DWORD dwInputStreamIndex) {
return E_NOTIMPL;}
120 HRESULT STDMETHODCALLTYPE AllocateStreamingResources(
void) {
return E_NOTIMPL;}
122 HRESULT STDMETHODCALLTYPE FreeStreamingResources(
void) {
return E_NOTIMPL;}
124 HRESULT STDMETHODCALLTYPE GetInputStatus(
125 DWORD dwInputStreamIndex,
126 DWORD *dwFlags) {
return E_NOTIMPL;}
128 HRESULT STDMETHODCALLTYPE ProcessInput(
129 DWORD dwInputStreamIndex,
130 IMediaBuffer *pBuffer,
132 REFERENCE_TIME rtTimestamp,
133 REFERENCE_TIME rtTimelength) {
return E_NOTIMPL;}
135 HRESULT STDMETHODCALLTYPE Lock(
136 LONG bLock) {
return E_NOTIMPL;}
146static const WORD OpenNiAudioFormat = WAVE_FORMAT_PCM;
147static const WORD OpenNiAudioChannels = 2;
148static const DWORD OpenNiAudioSamplesPerSec = 44100;
149static const WORD OpenNiAudioBitsPerSample = 16;
161 COpenNiAudio(COpenNiTool* tool);
162 virtual ~COpenNiAudio(
void);
165 BOOL init(COpenNiTool* tool);
167 IStream* getIStream(
void) {
return m_pStream;}
170 COpenNiMedia* m_mediaObj;
174 BOOL setMediaType(
void);
176 BOOL startCapture(
void) {
if (m_audioStream!=NULL)
return m_audioStream->startCapture();
else return FALSE;}
177 void stopCapture(
void) {
if (m_audioStream!=NULL) m_audioStream->stopCapture(); }
179 Buffer getAudioData(
void) {
if (m_audioStream!=NULL)
return m_audioStream->input();
else return init_Buffer();}
180 void getAudioData(Buffer* pbuf);
183 BOOL openOutput(
void) {
if (m_audioStream!=NULL)
return m_audioStream->openOutput();
else return FALSE;}
184 void closeOutput(
void) {
if (m_audioStream!=NULL) m_audioStream->closeOutput();}
188 WAVEFORMATEX getAudioFormat(
void);
192 CWinAudioStream* m_audioStream;
195 IMediaObject* m_audioMedia;
200 COpenNiAudio& operator = (COpenNiAudio& rhs) {
return rhs;}