1 | /******************************************************************************
|
---|
2 | * SAGE - Scalable Adaptive Graphics Environment
|
---|
3 | *
|
---|
4 | * Copyright (C) 2004 Electronic Visualization Laboratory,
|
---|
5 | * University of Illinois at Chicago
|
---|
6 | *
|
---|
7 | * All rights reserved.
|
---|
8 | *
|
---|
9 | * Redistribution and use in source and binary forms, with or without
|
---|
10 | * modification, are permitted provided that the following conditions are met:
|
---|
11 | *
|
---|
12 | * * Redistributions of source code must retain the above copyright
|
---|
13 | * notice, this list of conditions and the following disclaimer.
|
---|
14 | * * Redistributions in binary form must reproduce the above
|
---|
15 | * copyright notice, this list of conditions and the following disclaimer
|
---|
16 | * in the documentation and/or other materials provided with the distribution.
|
---|
17 | * * Neither the name of the University of Illinois at Chicago nor
|
---|
18 | * the names of its contributors may be used to endorse or promote
|
---|
19 | * products derived from this software without specific prior written permission.
|
---|
20 | *
|
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
---|
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
---|
24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
---|
25 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
---|
27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
---|
28 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
---|
29 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
---|
30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
---|
31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
32 | *
|
---|
33 | * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/
|
---|
34 | *
|
---|
35 | *****************************************************************************/
|
---|
36 | #ifndef _GRABBERCB_
|
---|
37 | #define _GRABBERCB_
|
---|
38 |
|
---|
39 | #include <qedit.h> // Sample grabber
|
---|
40 |
|
---|
41 | #include "Histogram.h"
|
---|
42 | #include "Utils.h"
|
---|
43 | #include "output_sail.h"
|
---|
44 |
|
---|
45 | class C_GrabProc {
|
---|
46 |
|
---|
47 | // static GrabberCB m_grabberCallback; // Make this global so that it stays in scope while the graph exists
|
---|
48 | // create filter------------
|
---|
49 | AM_MEDIA_TYPE m_mt;
|
---|
50 | AM_MEDIA_TYPE m_audiomt;
|
---|
51 | CComPtr<IBaseFilter> m_pGrabF;
|
---|
52 | CComPtr<IBaseFilter> m_pAudioGrabF;
|
---|
53 | CComPtr<IBaseFilter> m_pYUVtransF;
|
---|
54 | int m_sub_type;
|
---|
55 | // send image---------------
|
---|
56 | BYTE* m_pImg;
|
---|
57 | BYTE* m_pAudioSamples;
|
---|
58 | DWORD m_dwWidth;
|
---|
59 | DWORD m_dwHeight;
|
---|
60 | LONG m_lStride;
|
---|
61 | int m_iBitDepth;
|
---|
62 | int m_out_color_mode;
|
---|
63 | unsigned char* m_pbRGB_buff;
|
---|
64 | DWORD m_bufLen;
|
---|
65 | bool m_sageOn;
|
---|
66 | CString m_ip;
|
---|
67 |
|
---|
68 | class C_Output_sail Out_sail;
|
---|
69 |
|
---|
70 | public :
|
---|
71 | // create filter------------
|
---|
72 | C_GrabProc(void);
|
---|
73 | void FreeFilter(void);
|
---|
74 | HRESULT SetFilter(IGraphBuilder* pGraph, IBaseFilter* pUpstream, wchar_t* pUpstreamPinName, int out_color_mode, bool sage=false);
|
---|
75 | HRESULT SetAudioFilter(IGraphBuilder* pGraph, IBaseFilter* pUpstream, wchar_t* pUpstreamPinName);
|
---|
76 | IBaseFilter* GrabF(void);
|
---|
77 | // send image---------------
|
---|
78 | HRESULT SetVideoFormat(const VIDEOINFOHEADER& vih, int out_color_mode);
|
---|
79 | HRESULT SetImageBuffer(BYTE *pBuffer);
|
---|
80 | HRESULT SetAudioBuffer(BYTE *pBuffer);
|
---|
81 | HRESULT ConvertImage();
|
---|
82 | int SendToBmp(void);
|
---|
83 | int SendToSage(void);
|
---|
84 | int SendAudioToSage(int buflen);
|
---|
85 | void setIP(CString ip);
|
---|
86 |
|
---|
87 | void SetAudioOn(bool on);
|
---|
88 | void SetAudioCaptureMode(bool on);
|
---|
89 | void Shutdown();
|
---|
90 |
|
---|
91 | bool GetSageOn();
|
---|
92 | };
|
---|
93 |
|
---|
94 | // GrabberCB: Class to implement the callback function for the sample grabber
|
---|
95 | // Note: No ref-counting, so keep the object in scope while you're using it!
|
---|
96 | class GrabberCB : public ISampleGrabberCB
|
---|
97 | {
|
---|
98 | private:
|
---|
99 | BITMAPINFOHEADER m_bmi; // Holds the bitmap format
|
---|
100 | bool m_fFirstSample; // true if the next sample is the first one.
|
---|
101 |
|
---|
102 | public:
|
---|
103 |
|
---|
104 | GrabberCB();
|
---|
105 | ~GrabberCB();
|
---|
106 |
|
---|
107 | C_GrabProc m_GrabProc;
|
---|
108 | int m_out_color_mode;
|
---|
109 |
|
---|
110 | // IUnknown methods
|
---|
111 | STDMETHODIMP_(ULONG) AddRef() { return 1; }
|
---|
112 | STDMETHODIMP_(ULONG) Release() { return 2; }
|
---|
113 | STDMETHOD(QueryInterface)(REFIID iid, void** ppv);
|
---|
114 |
|
---|
115 | // ISampleGrabberCB methods
|
---|
116 | STDMETHOD(SampleCB)(double SampleTime, IMediaSample *pSample);
|
---|
117 | STDMETHODIMP BufferCB(double, BYTE *, long) { return E_NOTIMPL; }
|
---|
118 |
|
---|
119 | };
|
---|
120 |
|
---|
121 | // AudioGrabberCB: Class to implement the callback function for the sample grabber
|
---|
122 | // Note: No ref-counting, so keep the object in scope while you're using it!
|
---|
123 | class AudioGrabberCB : public ISampleGrabberCB
|
---|
124 | {
|
---|
125 | private:
|
---|
126 | BITMAPINFOHEADER m_bmi; // Holds the bitmap format
|
---|
127 | bool m_fFirstSample; // true if the next sample is the first one.
|
---|
128 | int m_index;
|
---|
129 | public:
|
---|
130 |
|
---|
131 | AudioGrabberCB();
|
---|
132 | ~AudioGrabberCB();
|
---|
133 |
|
---|
134 | C_GrabProc* m_GrabProc;
|
---|
135 |
|
---|
136 | // IUnknown methods
|
---|
137 | STDMETHODIMP_(ULONG) AddRef() { return 1; }
|
---|
138 | STDMETHODIMP_(ULONG) Release() { return 2; }
|
---|
139 | STDMETHOD(QueryInterface)(REFIID iid, void** ppv);
|
---|
140 |
|
---|
141 | // ISampleGrabberCB methods
|
---|
142 | STDMETHOD(SampleCB)(double SampleTime, IMediaSample *pSample);
|
---|
143 | STDMETHODIMP BufferCB(double, BYTE *, long) { return E_NOTIMPL; }
|
---|
144 |
|
---|
145 | };
|
---|
146 |
|
---|
147 | // GUID media_type_ary[] = {MEDIASUBTYPE_UYVY, MEDIASUBTYPE_YUY2, MEDIASUBTYPE_YUYV};
|
---|
148 |
|
---|
149 | #ifdef _MAIN_
|
---|
150 | GrabberCB grabberCallback; // Make this global so that it stays in scope while the graph exists
|
---|
151 | AudioGrabberCB AudioGrabCallback;
|
---|
152 | #else
|
---|
153 | extern GrabberCB grabberCallback; // Make this global so that it stays in scope while the graph exists
|
---|
154 | extern AudioGrabberCB AudioGrabCallback;
|
---|
155 | #endif
|
---|
156 |
|
---|
157 |
|
---|
158 | #endif
|
---|