ChannelMgr.h
资源名称:p2p_vod.rar [点击查看]
上传用户:liguizhu
上传日期:2015-11-01
资源大小:2422k
文件大小:3k
源码类别:
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 __CHANNELMGR_H_
- #define __CHANNELMGR_H_
- typedef UINT16 CHANNELID;
- #include "Layer1Pin.h"
- #include "NetWorkStub.h"
- #include "MsgMgr.h"
- #include "ZZLFileReader.h"
- class HttpRequest;
- class InfAnime;
- class CChannelMgr
- {
- protected:
- CChannelMgr(CHANNELID ChannelID);
- virtual ~CChannelMgr();
- public:
- static CChannelMgr* Allocator(CHANNELID ChannelID);
- static void Dellocator(CChannelMgr* pdel, BOOL block = FALSE);
- private:
- static unsigned int CALLBACK _DellocatorProc(void* lpParameter);
- static unsigned int CALLBACK _RequestFunc(void* lpParameter);
- HANDLE h_RequestThread;
- enum REQUEST_STATUS{
- REQUEST_DEAD = -2,
- REQUEST_FAIL = -1,
- REQUEST_NOPP = 0,
- REQUEST_INIT,
- REQUEST_BUFFER,
- REQUEST_TESTSTATE,
- REQUEST_OK
- };
- // 处理状态切换时的初始化,包括ZZL文件的初始化和气球消息
- void TestSwitchStatus(void);
- volatile LONG m_bRequesting;
- volatile LONG m_PrevRequest;
- volatile LONG m_CoutPinInit;
- P2P_RETURN_TYPE m_errorcode;
- HttpRequest* pHttpSession;
- CString m_RequestURL;
- CString m_ChannelNameBuf;
- public:
- BOOL Init(
- SOCKET SockFromProxy // in, 来自NetworkProxy的连接
- );
- // 开始下载这个频道
- BOOL Request(
- LPCTSTR url // in, 要播放的文件
- );
- // 停止下载当前频道
- void Stop();
- BOOL DeadforFatalError(){return m_bRequesting == REQUEST_FAIL;}
- P2P_RETURN_TYPE GetErrorCode(){return m_errorcode;}
- void SendMsgToShow(LPCTSTR msg, UINT len) { return; }
- // 获取数据,可能得到普通Sample或者MediaType(参考struct SampleHeader的注释)
- // 返回值:>=1 表示成功;0表示暂时没有数据;<=-1 表示错误
- // *这个函数有递归调用的可能
- int GetData(
- SampleHeader& header, // out, 数据头
- PBYTE& pData, // out, 存储数据的缓冲区
- const UINT maxSize, // in, 缓冲区的长度
- const bool bAudio, // in, 获取音频还是视频
- const bool bKeySample // in, 是否寻找关键帧
- );
- static int HandleLayerErrCode(P2P_RETURN_TYPE RetType, CString& strRetErr); //将字符串strRetErr变成错误的消息(支持多语言),并根据消息返回一个iRet
- void GetChannelName(CString& strRet); //将字符串strRet变成格式化的频道名
- CMsgMgr* GetMsgMgr();
- private:
- CMsgMgr m_MsgMgr;
- private:
- Layer1Pin m_videopin;
- Layer1Pin m_audiopin;
- NPLayer1::Layer1 m_Layer1;
- NetworkStub m_NetworkStub;
- SOCKET m_SockFromProxy;
- CCritSec m_MapCritSec;
- CHANNELID m_ChannelID;
- MSGID m_NameMsgID;
- InfAnime* pInfAnime;
- };
- #endif