JunkBox_Win_Lib 1.5.3
Loading...
Searching...
No Matches
OpenNiAudio.h
Go to the documentation of this file.
1#pragma once
2
3#if defined(ENABLE_OPENNI) || defined(ENABLE_OPENNI2)
4
5
6#include "WinAudioStream.h"
7#include "OpenNiTool.h"
8
9#include <mfapi.h> // IPropertyStore
10#include <wmcodecdsp.h> // MFPKEY_WMAAECMA_SYSTEM_MODE
11#include <uuids.h> // FORMAT_WaveFormatEx
12
13// Lib
14#pragma comment(lib, "Msdmo.lib")
15#pragma comment(lib, "amstrmid.lib")
16
17
18//
19namespace jbxwl {
20
21
22using namespace jbxl;
23
24
26// COpenNiMedia
27
28class COpenNiMedia : public IMediaObject
29{
30public:
31 COpenNiMedia(void);
32 ~COpenNiMedia(void) {}
33
34public:
36 // IUnknown methods
37 //
38 STDMETHODIMP_(ULONG) AddRef() { return 2;}
39 STDMETHODIMP_(ULONG) Release() { return 1;}
40
41 STDMETHODIMP QueryInterface(REFIID riid, void** ppv)
42 {
43 if (riid==IID_IUnknown) {
44 AddRef();
45 *ppv = (IUnknown*)this;
46 return NOERROR;
47 }
48 else if (riid==IID_IMediaBuffer) {
49 AddRef();
50 *ppv = (IMediaObject*)this;
51 return NOERROR;
52 }
53 else return E_NOINTERFACE;
54 }
55
56public:
58 // IMediaObject methods
59 //
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);
63
64 // Not Implement
65 HRESULT STDMETHODCALLTYPE GetStreamCount(
66 DWORD *pcInputStreams,
67 DWORD *pcOutputStreams) { return E_NOTIMPL;}
68
69 HRESULT STDMETHODCALLTYPE GetInputStreamInfo(
70 DWORD dwInputStreamIndex,
71 DWORD *pdwFlags) { return E_NOTIMPL;}
72
73 HRESULT STDMETHODCALLTYPE GetOutputStreamInfo(
74 DWORD dwOutputStreamIndex,
75 DWORD *pdwFlags) { return E_NOTIMPL;}
76
77 HRESULT STDMETHODCALLTYPE GetInputType(
78 DWORD dwInputStreamIndex,
79 DWORD dwTypeIndex,
80 DMO_MEDIA_TYPE *pmt) { return E_NOTIMPL;}
81
82 HRESULT STDMETHODCALLTYPE GetOutputType(
83 DWORD dwOutputStreamIndex,
84 DWORD dwTypeIndex,
85 DMO_MEDIA_TYPE *pmt) { return E_NOTIMPL;}
86
87 HRESULT STDMETHODCALLTYPE SetInputType(
88 DWORD dwInputStreamIndex,
89 const DMO_MEDIA_TYPE *pmt,
90 DWORD dwFlags) { return E_NOTIMPL;}
91
92 HRESULT STDMETHODCALLTYPE GetInputCurrentType(
93 DWORD dwInputStreamIndex,
94 DMO_MEDIA_TYPE *pmt) { return E_NOTIMPL;}
95
96 HRESULT STDMETHODCALLTYPE GetInputSizeInfo(
97 DWORD dwInputStreamIndex,
98 DWORD *pcbSize,
99 DWORD *pcbMaxLookahead,
100 DWORD *pcbAlignment) { return E_NOTIMPL;}
101
102 HRESULT STDMETHODCALLTYPE GetOutputSizeInfo(
103 DWORD dwOutputStreamIndex,
104 DWORD *pcbSize,
105 DWORD *pcbAlignment) { return E_NOTIMPL;}
106
107 HRESULT STDMETHODCALLTYPE GetInputMaxLatency(
108 DWORD dwInputStreamIndex,
109 REFERENCE_TIME *prtMaxLatency) { return E_NOTIMPL;}
110
111 HRESULT STDMETHODCALLTYPE SetInputMaxLatency(
112 DWORD dwInputStreamIndex,
113 REFERENCE_TIME rtMaxLatency) { return E_NOTIMPL;}
114
115 HRESULT STDMETHODCALLTYPE Flush(void) { return E_NOTIMPL;}
116
117 HRESULT STDMETHODCALLTYPE Discontinuity(
118 DWORD dwInputStreamIndex) { return E_NOTIMPL;}
119
120 HRESULT STDMETHODCALLTYPE AllocateStreamingResources(void) { return E_NOTIMPL;}
121
122 HRESULT STDMETHODCALLTYPE FreeStreamingResources(void) { return E_NOTIMPL;}
123
124 HRESULT STDMETHODCALLTYPE GetInputStatus(
125 DWORD dwInputStreamIndex,
126 DWORD *dwFlags) { return E_NOTIMPL;}
127
128 HRESULT STDMETHODCALLTYPE ProcessInput(
129 DWORD dwInputStreamIndex,
130 IMediaBuffer *pBuffer,
131 DWORD dwFlags,
132 REFERENCE_TIME rtTimestamp,
133 REFERENCE_TIME rtTimelength) { return E_NOTIMPL;}
134
135 HRESULT STDMETHODCALLTYPE Lock(
136 LONG bLock) { return E_NOTIMPL;}
137};
138
139
140
141
143// COpenNiAudio
144
145// Audio Parameters
146static const WORD OpenNiAudioFormat = WAVE_FORMAT_PCM;
147static const WORD OpenNiAudioChannels = 2;
148static const DWORD OpenNiAudioSamplesPerSec = 44100;
149static const WORD OpenNiAudioBitsPerSample = 16;
150
151//static const WORD OpenNiAudioBlockAlign = 2;
152//static const DWORD OpenNiAudioAverageBytesPerSec = 88200;
153
154
155
156class COpenNiAudio
157{
158public:
159 //
160// COpenNiAudio(xn::Context* context);
161 COpenNiAudio(COpenNiTool* tool);
162 virtual ~COpenNiAudio(void);
163
164// BOOL init(xn::Context* context);
165 BOOL init(COpenNiTool* tool);
166 void free(void);
167 IStream* getIStream(void) { return m_pStream;}
168
169public:
170 COpenNiMedia* m_mediaObj;
171
172public:
173 //
174 BOOL setMediaType(void);
175
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(); }
178
179 Buffer getAudioData(void) { if (m_audioStream!=NULL) return m_audioStream->input(); else return init_Buffer();} // not free
180 void getAudioData(Buffer* pbuf);
181
182 //
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();}
185
186public:
187 //
188 WAVEFORMATEX getAudioFormat(void);
189
190private:
191 //
192 CWinAudioStream* m_audioStream;
193// xn::AudioGenerator* m_audioSource;
194
195 IMediaObject* m_audioMedia;
196 IStream* m_pStream;
197
198private:
199 // コピーしないで参照を返す
200 COpenNiAudio& operator = (COpenNiAudio& rhs) { return rhs;}
201};
202
203
204} // namespace
205
206
207#endif
オーディオストリーム ヘッダ