Capture.h
资源名称:p2p_vod.rar [点击查看]
上传用户:liguizhu
上传日期:2015-11-01
资源大小:2422k
文件大小:10k
源码类别:
P2P编程
开发平台:
Visual C++
- /*
- * Openmysee
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
- #ifndef __CAPTURE_H__
- #define __CAPTURE_H__
- #include "../captureserver/TVSourceConfig.h"
- // definition of IGraph interface, this interface now is not useful, but
- // it can extend later development.
- class IGraph: public IUnknown
- {
- public:
- // initialize & unintiliase graph
- STDMETHOD(Initialize)() PURE;
- STDMETHOD(Uninitialize)() PURE;
- STDMETHOD(BuildGraph)() PURE;
- STDMETHOD(DisassembleGraph)() PURE;
- STDMETHOD(AddFilter)(CLSID clsidFilter,
- IBaseFilter** ppIFilter,
- LPCTSTR pstrFilterName = NULL) PURE;
- STDMETHOD(RemoveFilter)(IBaseFilter* pIFilter) PURE;
- // Connects two pins together.
- // pIFilterOutput -- A pointer to the filter that contains the output pin
- // to connect.
- // pstrPinNameOutput -- The name of the output pin. If it is NULL, the
- // first output pin found will be connected.
- // pIFilterInput -- A pointer to the filter that contains the input pin
- // to connect
- // pstrPinNameInput -- The name of the input pin. If NULL, the first input
- // pin found will be connected
- // pmt -- The media type of the connection.
- STDMETHOD(ConnectPins)(IBaseFilter* pIFilterOutput,
- LPCTSTR pstrPinNameOutput,
- IBaseFilter* pIFilterInput,
- LPCTSTR pstrPinNameInput,
- AM_MEDIA_TYPE* pmt = NULL) PURE;
- // Disconnects the specified pin.
- // pIFilter -- The filter that contains the pstrPinName
- // pstrPinName -- The name of pin be disconnected
- // dir -- The direction of pin
- // PINDIR_INPUT : input pin/PINDIR_OUTPUT : output pin
- STDMETHOD(DisconnectPin)(IBaseFilter *pIFilter,
- LPCTSTR pstrPinName,
- PIN_DIRECTION dir = PINDIR_OUTPUT) PURE;
- STDMETHOD_(BOOL, IsConnected)(IBaseFilter *pFilter,
- LPCTSTR pstrPinName,
- PIN_DIRECTION pd = PINDIR_OUTPUT) PURE;
- // Finds the specified pin on a filter.
- // pIFilter -- The filter that contains the pstrPinName
- // pstrPinName -- The name of pin to be find
- // dir -- Same with below
- STDMETHOD_(IPin* ,FindPinOnFilter)(IBaseFilter* pIFilter,
- LPCTSTR pstrPinName,
- PIN_DIRECTION dir = PINDIR_OUTPUT) PURE;
- // graph controls
- STDMETHOD(Run)() PURE;
- STDMETHOD(Stop)() PURE;
- STDMETHOD(Pause)() PURE;
- };
- class CCaptureGraph: public IGraph
- {
- friend class CAudioCompressSelectorDlg;
- // reference count of object
- ULONG m_RefCount;
- IGraphBuilder *m_pGB; // capture graph
- CComPtr<ICaptureGraphBuilder2> graphBuilder2_;
- IAMCrossbar* m_pSB;
- IVideoWindow *m_pVW; // video window
- IMediaControl *m_pMC; // media control
- ITVSourceConfig *m_pTVConfig; // tv sink config
- // filters in graph
- IBaseFilter *m_pVideoCapture;
- IBaseFilter *m_pVideoEncoder;
- IBaseFilter *m_pAudioEncoder;
- IBaseFilter *m_pAudioCapture;
- IBaseFilter *m_pTVStreamSink;
- IBaseFilter *m_pVideoSmartTee;
- IBaseFilter* m_pDVDecoder;
- //xiezhouwei 05-08-17添加
- IBaseFilter *m_pVideoOverlay;
- CPtrArray m_arrayOtherFilter;// filters that created by Render() func.
- // three filters added by zk 2004-04-16 for saving video and audio data to persist harddisk
- IBaseFilter *m_pAudioSmartTee;
- IBaseFilter *m_pAVIMuxer;
- IBaseFilter *m_pFileWriter;
- IBaseFilter* m_pftrDVSpliter;
- BOOL m_bGraphBuiled;
- BOOL m_bIsPreview;
- BOOL m_bIsOnlyAudio;
- BOOL m_bSave; // added by zk for saving 2004-04-16
- BOOL mbIsDV; //added by xiezhouwei 2005-09-01
- //xiezhouwei 05-08-23
- BOOL m_bNeedOverlay;
- BOOL m_bISCrossBar;
- // current video encoder used to config
- CString m_strCurVideoEncoder;
- // current audio format that user selected, it will be used in
- // ConnectPin() func.
- AM_MEDIA_TYPE *m_pCurAudioAMT;
- // video owner window
- HWND m_hWndOwner;
- char m_szAVIFile[ MAX_PATH ];//AVI保存路径
- public:
- CCaptureGraph();
- ~CCaptureGraph();
- BOOL m_config;
- BYTE *state;
- int sstate;
- // Iunknown interface
- public:
- STDMETHODIMP_(ULONG) AddRef();
- STDMETHODIMP_(ULONG) Release();
- STDMETHODIMP QueryInterface(REFIID iid, void** ppInter);
- public:
- bool SetVideoState(BYTE* apState, int aiSize);
- bool SetCurMediaType(AM_MEDIA_TYPE* aMTMediaType);
- bool GetCurMediaType(AM_MEDIA_TYPE** aMTMediaType);
- // ini & unini
- STDMETHODIMP Initialize();
- STDMETHODIMP Uninitialize();
- // controls
- STDMETHODIMP Run();
- STDMETHODIMP Stop();
- STDMETHODIMP Pause();
- // enums,it respectively call EnumSpeciFilters
- // with diffrent specification
- STDMETHODIMP EnumVideoCapDevices(CStringArray &);
- STDMETHODIMP EnumAudioCapDevices(CStringArray &);
- STDMETHODIMP EnumVideoEncoders(CStringArray &);
- STDMETHODIMP EnumAudioEncoders(CStringArray &);
- // configs
- STDMETHODIMP ConfigVideoCapDeviceByName(HWND hParent);
- STDMETHODIMP ConfigAudioCapDeviceByName(HWND hParent);
- STDMETHODIMP ConfigVideoEncoderByName(HWND hParent);
- STDMETHODIMP ConfigAudioEncoderByName(HWND hParent);
- STDMETHODIMP ConfigSysCfg(HWND hParent);
- // some filter creations must be implemented by enumulator
- // implemented with FindFilterByName auxily function
- HRESULT CreateVideoCapDeviceFilterByName(LPTSTR strName);
- HRESULT CreateAudioCapDeviceFilterByName(LPTSTR strName);
- HRESULT CreateVideoEncoderFilterByName(LPTSTR strName);
- HRESULT CreateAudioEncoderFilterByName(LPTSTR strName);
- //判断是否是DMOFilter by xiezhouwei
- BOOL IsDMOFilter();
- //设置DMO属性 by xiezhouwei
- STDMETHODIMP BuildVideoDMOEncoder();
- //设置DMO时,得到媒体类型 by xiezhouwei 0917
- HRESULT GetInputMediaType(IBaseFilter* pCap, AM_MEDIA_TYPE& mt);
- //创建DMOFilter
- HRESULT CreateV9EncoderFilter();
- //
- //xiezhouwei 05-08-17 添加
- //初始化字幕Filter
- // 设置是否需要字幕的
- //void SetNeedOverlay(bool abNeedOverlay);
- HRESULT CreateUideoOverlay();
- HRESULT ConfigVideoOverlay(HWND hParent);
- void ReleaseUideoOverlay();
- // video owner wnd
- void SetOwner(HWND hWnd){m_hWndOwner = hWnd;}
- // preview
- VOID SetPreview(BOOL bIsPreview);
- BOOL IsPreview(){ return m_bIsPreview; }
- // CrossBar
- VOID SetCrossBar(BOOL abIsCrossBar)
- {
- if (abIsCrossBar != m_bISCrossBar)
- {
- m_bISCrossBar = abIsCrossBar;
- DisassembleGraph();
- }
- }
- // only audio
- void SetOnlyAudio( BOOL bIsOnlyAudio );
- BOOL IsOnlyAudio(){ return m_bIsOnlyAudio; }
- // compress bit rate
- FLOAT GetCompressRata(){ return m_pTVConfig->GetCompressedSpeed();}
- //=========================================
- // Writed by zhuwei 2005-8-12
- //Show Pin Setting
- public:
- void ShowPinSetting(HWND);
- //Set AVI FileName
- public:
- void SetAVIFile( char* );
- private:
- //////////////////////////////////////////////////////////////////////////
- //与DV的相关处理
- //////////////////////////////////////////////////////////////////////////
- //判断是否为DV
- void JudgeDV();
- //将DV信号分离
- STDMETHODIMP DVSplitter();
- //构建DV音频链路
- STDMETHODIMP BuildDVAudio();
- //添加DV字幕
- STDMETHODIMP AddDVVideoOverlay();
- //构建DV视频预览
- STDMETHODIMP BuildDVVideoPrview();
- //构建DV视频链路
- STDMETHODIMP BuildDVVideo();
- //Build DV链路
- STDMETHODIMP DisplayDV();
- //////////////////////////////////////////////////////////////////////////
- //一般的采集链路
- //////////////////////////////////////////////////////////////////////////
- //构建一般的Graph的音频部分
- STDMETHODIMP BuildGeneralAudio();
- //在VideoGraph中加入字幕Filter
- STDMETHODIMP AddVideoOverlayFilter();
- //视频部分预览
- STDMETHODIMP BuildVideoPreview();
- //打开CrossBar
- STDMETHODIMP OpenCrossBar();
- //构建并预览一般的Graph的视频部分
- STDMETHODIMP BuildGeneralVideo();
- //构建存储链路
- STDMETHODIMP BuildSaveGraph();
- //构建一般的Graph
- STDMETHODIMP BuildGeneralGraph();
- //=========================================
- private:
- STDMETHODIMP AddFilter(CLSID clsidFilter,
- IBaseFilter** ppIFilter,
- LPCTSTR pstrFilterName = NULL);
- STDMETHODIMP RemoveFilter(IBaseFilter* pIFilter);
- STDMETHODIMP ConnectPins(IBaseFilter* pIFilterOutput,
- LPCTSTR pstrPinNameOutput,
- IBaseFilter* pIFilterInput,
- LPCTSTR pstrPinNameInput,
- AM_MEDIA_TYPE* pmt = NULL);
- //自动连接Filter
- STDMETHODIMP CCaptureGraph::ConnectAutoPins(IBaseFilter* pIFilterOutput,
- LPCTSTR pstrPinNameOutput,
- IBaseFilter* pIFilterInput,
- LPCTSTR pstrPinNameInput);
- STDMETHODIMP_(BOOL) IsConnected(IBaseFilter *pFilter,
- LPCTSTR pstrPinName,
- PIN_DIRECTION pd = PINDIR_OUTPUT);
- STDMETHODIMP DisconnectPin(IBaseFilter *pIFilter,
- LPCTSTR pstrPinName,
- PIN_DIRECTION dir = PINDIR_OUTPUT);
- STDMETHODIMP_(IPin*) FindPinOnFilter(IBaseFilter* pIFilter,
- LPCTSTR pstrPinName,
- PIN_DIRECTION dir = PINDIR_OUTPUT);
- STDMETHODIMP BuildGraph();
- STDMETHODIMP DisassembleGraph();
- // audio compression format
- HRESULT EnumAudioWaveFormat(CListBox* pLB);// called by main dlg
- void SetAudioWaveformat(AM_MEDIA_TYPE* pamt);// called by selector dlg
- // used to enum fiters in specified catagory
- HRESULT EnumSpeciFilters(IID iidEnumType, CStringArray &);
- // used to create filter
- HRESULT FindFilterByName(LPTSTR strName, IBaseFilter **ppFilter, IID iidEnumType);
- // used to get audio capture device
- HRESULT GetAudioCaptureDevice();
- // used for filling the m_arryOtherFilter, diff from our
- // refrenced filters
- BOOL IsFilterInStdFilters(IBaseFilter *pFilter);
- };
- #endif// __CAPTURE_H__