www.pudn.com > mputil.rar > MPDirectShow.h


/*  
 *  MPDirectShow.h 
 * 
 *  Created by Bret Fortenberry in June, 2004. 
 *  Fixes:  
 *  
 *  Copyright (c) 2004 Machine Perception Laboratory  
 *  University of California San Diego. 
 *  
 * Please read the disclaimer and notes about redistribution  
 * at the end of this file. 
 *   
 */ 
#ifndef _MPDIRECTSHOW_H_ 
#define _MPDIRECTSHOW_H_ 
 
#include  
#include  
#include  
#include  
 
#define NUM_PROJECTS 5 
enum ds_project{ds_mpisearch = 0, ds_eyefinder, ds_blinkDetector, ds_colorTracker, ds_mpisearchAda, ds_emoMirror}; 
const char ds_projectNames[NUM_PROJECTS][256] = {"mpisearch", "eyefinder", "blinkDetector", "colorTracker", "mpisearchAda"}; 
 
enum ds_recordMode{ds_capture = 0, ds_pause, ds_stop}; 
 
class MPDirectShow 
{ 
 
public: 
	ds_recordMode m_recordMode; 
	char m_deviceNames[100][256]; 
	int m_devicePos; 
 
	MPDirectShow(); 
	~MPDirectShow(); 
 
	HRESULT RunDirectShow(HWND hWnd); 
	HRESULT StopCapture(); 
	HRESULT PauseFilter(); 
	HRESULT RunFilter(); 
	HRESULT ChangeMPFilter(HWND hWnd); 
	HRESULT SaveGraphEditFile(WCHAR* wszFileName); 
	HRESULT SaveVideo(); 
	void SetProject(ds_project curProject); 
	void SetInput(int width, int height); 
	int GetVideoDevices(); 
	void SetVideoDevices(int pos); 
 
private: 
 
	// DShow Member Variables 
	int m_width; 
	int m_height; 
	bool m_usingCompressor; 
	ds_project m_curProject; 
  //string m_ErrMsg; 
	IGraphBuilder *pGraph; 
	ICaptureGraphBuilder2 *pBuild; 
	CComPtr< IReferenceClock > pClock; 
	CComQIPtr< IMediaControl> pControl; 
	CComQIPtr< IVideoWindow> pWindow; 
	CComQIPtr< IMediaEventEx> pEvent; 
 
	HRESULT FindAllDevices( REFCLSID clsidDeviceClass, int* totalFound); 
	HRESULT GetDefaultCapDevice( IBaseFilter ** ppCap, REFCLSID clsidDeviceClass ); 
	HRESULT GetListedDevice( IBaseFilter ** ppCom, REFCLSID clsidDeviceClass, char* deviceName ); 
	HRESULT GetPin(IBaseFilter *, PIN_DIRECTION, IPin **); 
	HRESULT GetPin_Name(IBaseFilter *pFilter, char* name, IPin **ppPin); 
	HRESULT ConnectFilters(IBaseFilter *, IBaseFilter *); 
	HRESULT ConnectFilters(IPin *pOut, IBaseFilter *pSecond); 
	HRESULT DisonnectFilters(IBaseFilter *pFilter, PIN_DIRECTION pindir); 
	HRESULT CreateManualGraph(HWND hWnd); 
	HRESULT SetDisplayWnd(HWND hWnd); 
	HRESULT GetMediaType(IPin *outPin, IPin *inPin, AM_MEDIA_TYPE *ppMediaType); 
	void EnumFilters(void); 
	void EnumPins(IBaseFilter *pFilter); 
 
}; 
 
#endif //_MPDIRECTSHOW_H_ 
 
/* 
 *  
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
 *  
 *    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
 *    2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
 *    3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. 
 *  
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 *  
 */