1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
26 // * The name of Intel Corporation may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
42 #ifndef __CVCAMAVI_H__
43 #define __CVCAMAVI_H__
50 /////////////////////////////////////////////////////////////////////////////////////////
51 template <class T> class SafePointer
57 SafePointer() : m_pointer(0) {};
58 SafePointer(T* pointer) {m_pointer = pointer;};
59 SafePointer(const SafePointer& p)
61 m_pointer = p.m_pointer;
77 T* value() {return m_pointer;};
78 T* operator ->() {return m_pointer;};
89 void operator =(T* pointer)
91 if(m_pointer) m_pointer->Release();
94 int is_valid() {return int(m_pointer);};
96 /////////////////////////////////////////////////////////////////////////////////////////
110 /////////////////////////////////////////////////////////////////////////////////////////
117 /////////////////////////////////////////////////////////////////////////////////////////
126 HRESULT operator=(HRESULT res)
134 excpt.occasion = m_occasion;
145 /////////////////////////////////////////////////////////////////////////////////////////
147 class cvcamSourceFile
150 HRESULT WaitForCompletion();
152 HRESULT SetWindow(const HWND window);
153 cvcamSourceFile(const char* file = NULL, void (*callback)(void*) = NULL);
155 //Media controlling methods
162 HRESULT SetCallBack(void (*callback)(void*));
163 HRESULT SetWidth(const int width);
164 HRESULT SetHeight(const int height);
169 HRESULT SetTimeFormat(const int format);
170 HRESULT GetDuration(LONGLONG *pDuration);
171 HRESULT GetCurrentPosition(LONGLONG *pCurrent);
172 HRESULT SetPosition(LONGLONG *pCurrent);
181 //Initialise/Release COM
184 //DirectShow Interfaces
185 SafePointer<IGraphBuilder> m_pGraph;
186 SafePointer<IMediaControl> m_pMediaControl;
187 SafePointer<IMediaEventEx> m_pEvent;
188 SafePointer<IVideoWindow> m_pVideoWindow;
189 SafePointer<IPin> m_pPin;
190 SafePointer<IBasicVideo> m_pBasicVideo;
191 SafePointer<IBaseFilter> m_pSFilter;
192 SafePointer<IProxyTransform> m_pProxyTrans;
193 SafePointer<IPin> m_pSourceOut;
194 SafePointer<IPin> m_pProxyIn;
195 SafePointer<IPin> m_pProxyOut;
196 SafePointer<IEnumPins> m_pEnumPins;
197 SafePointer<IBaseFilter> m_pProxyBase;
198 SafePointer<IMediaSeeking> m_pMediaSeeking;
202 void (*m_pcallback)(void*);
209 /////////////////////////////////////////////////////////////////////////////////////////
211 #define AVIS_START 1000
212 typedef unsigned int uint;
218 memset(files,0,MAX_AVIS);
221 uint AddSource( char* path, void (*callback)(void*) )
223 cvcamSourceFile* tmp = new cvcamSourceFile(path, callback);
244 bool ReleaseSource(uint source)
246 // source -= AVIS_START;
250 delete files[source];
251 files[source] = NULL;
258 cvcamSourceFile* operator[](uint source)
260 // source -= AVIS_START;
262 if( source < MAX_AVIS )
263 return files[source];
271 // for(uint i = AVIS_START; i < AVIS_START+MAX_AVIS; i++)
272 for(uint i = 0; i < MAX_AVIS; i++)
276 cvcamSourceFile* files[MAX_AVIS];
280 /////////////////////////////////////////////////////////////////////////////////////////
281 extern HINSTANCE DLLhinst;
284 #endif //__CVCAMAVI_H__