⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graphcenter.h

📁 mysee网络直播源代码Mysee Lite是Mysee独立研发的网络视频流媒体播放系统。在应有了P2P技术和一系列先进流媒体技术之后
💻 H
字号:
/*
 *  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
 *
 */
#if defined (_MSC_VER) && (_MSC_VER >= 1000)
#pragma once
#endif

#ifndef _GAOV_GRAPHCENTER_H
#define  _GAOV_GRAPHCENTER_H

enum Pin_type
{
	VIDEO,
	AUDIO
};

// 这是回调函数的指针
typedef int (__stdcall GetZZLState)(void* apUserPara, int aiState);

#ifdef _DEBUG

//注册图类
static DWORD g_dwRegister;
static HRESULT AddGraphToRot(IUnknown *pUnkGraph, DWORD *pdwRegister) 
{
    IMoniker * pMoniker;
    IRunningObjectTable *pROT;
    HRESULT hr;

    hr = GetRunningObjectTable(0, &pROT);
    if (FAILED(hr)) return hr;

    WCHAR wsz[128];
    wsprintfW(wsz, L"FilterGraph %08x pid %08x", (DWORD_PTR)pUnkGraph, GetCurrentProcessId());
    hr = CreateItemMoniker(L"!", wsz, &pMoniker);
    if (SUCCEEDED(hr)) 
	{
        hr = pROT->Register(0, pUnkGraph, pMoniker, pdwRegister);
        pMoniker->Release();
    }
    pROT->Release(); 
    return hr;
}

static void RemoveGraphFromRot(DWORD pdwRegister)
{
    IRunningObjectTable *pROT;
    if (SUCCEEDED(GetRunningObjectTable(0, &pROT))) 
	{
        pROT->Revoke(pdwRegister);
        pROT->Release();
    }
}
#endif //_DEBUG

class CGraphCenter
{
public:
	CGraphCenter();
	~CGraphCenter();
public:
	STDMETHODIMP Initialize();
	STDMETHODIMP Uninitialize();
	STDMETHODIMP BuildGraph(LPCTSTR astrFileName, LPCTSTR astrZZLDirectory, LPCTSTR astrZZLFile);
	STDMETHODIMP DisassembleGraph();
public:
	STDMETHODIMP Run();
	STDMETHODIMP Stop();
public:	
	int GetState()
	{
		return m_iIsStop;
	};
	float GetCompressedSpeed();
	
	//设置状态回调函数
	void SetStateProc(GetZZLState* apStateproc, void* apUserPara);

private:
	STDMETHODIMP AddFilter(CLSID clsidFilter,			   
		IBaseFilter** ppIFilter,	
		LPCTSTR pstrFilterName = NULL);

	STDMETHODIMP ConnectAutoPins(IBaseFilter* pIFilterOutput, 
											LPCTSTR pstrPinNameOutput,
											IBaseFilter* pIFilterInput, 
											LPCTSTR pstrPinNameInput);

	STDMETHODIMP ConnectPins(IBaseFilter* pIFilterOutput, 
		LPCTSTR pstrPinNameOutput,
		IBaseFilter* pIFilterInput, 
		LPCTSTR pstrPinNameInput,
		AM_MEDIA_TYPE* pmt = NULL);


	//pin的连接
	STDMETHODIMP ConnectPinsEX(IBaseFilter* pIFilterOutput, 
		Pin_type atype,
		IBaseFilter* pIFilterInput, 
		LPCTSTR pstrPinNameInput,		
		BOOL bisAuto = FALSE,AM_MEDIA_TYPE* pmt = NULL);


	STDMETHODIMP_(IPin*) FindPinOnFilter(IBaseFilter* pIFilter, 
		LPCTSTR pstrPinName,
		PIN_DIRECTION dir);

	STDMETHODIMP_(IPin*) FindPinOnFilterbyType(IBaseFilter* pIFilter, 
		Pin_type aType,
		PIN_DIRECTION dir);

	STDMETHODIMP RemoveFilter(IBaseFilter* pIFilter);
private:
	static void WINAPI WaitForEnd(void * apParameter);

private:
	//回调指针
	GetZZLState* mpGetZZLStateProc;

	void* mpGetZZLUserPara;
private:
	//创建调试信息日志
	bool CreateDebugInfo();
private:
	IBaseFilter* m_pTVStreamSink;
	IBaseFilter* m_pSourceFile;
	IBaseFilter* m_pAviSplitter;
	IBaseFilter* mpAsfReader;

	IGraphBuilder* m_pGB;
	IMediaControl* m_pMC;
	IMediaEvent* m_pEvent;

	CRITICAL_SECTION	moCriticalSection;	//保护停止标志位。
	int m_iIsStop;			//0为运行,1为停止。-1为发生意外错误停止
};
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -