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

📄 ppffplin.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: ppffplin.cpp,v 1.8.16.1 2004/07/19 21:04:16 hubbe Exp $ *  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. *  * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks.  You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL.  Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. *  * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. *  * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. *  * Technology Compatibility Kit Test Suite(s) Location: *    http://www.helixcommunity.org/content/tck *  * Contributor(s): *  * ***** END LICENSE BLOCK ***** *//////////////////////////////////////////////////////////////////////////////// //  RealAudio Server side plugin that will sink to get live packets, create//  a virtual .SDP file for the HTTP server to send to clients which will//  start listening to the live multicast packets formatted in RTP.///**************************************************************************** *  Defines */// #define _TIMELINE_TRACE#define _GETPACKET_TRACE#define INITGUID#define RA_MINETYPE			"audio/x-pn-realaudio"#define STANDARD_START_HXOFFSET	200	    // 100 ms#define HX_COMMON_MIME_TYPE_FRAGMENT	"x-pn-"#define TRANSPORT_BUFFERING_TIME	10	    // ms#define MAX_TIME_GAP_FORWARD		20000#define MAX_TIME_GAP_BACKWARD		5000#define MAX_SUSPENDED_BUFFER_SIZE	1000#define FLEX_BUFFER_SWITCHOVER_TIME	40000	    // 40 seconds#define LISTENINING_TIME_INTERVAL	PP_SYNC_TIMEOUT_MS/**************************************************************************** *  Includes */#include "hxtypes.h"#include "hlxclib/windows.h"#include "hxcom.h"#include "hxcomm.h"#include "ihxpckts.h"#include "hxfiles.h"#include "hxformt.h"#include "hxplugn.h"#include "hxmon.h"#include "hxerror.h"#include "hxcore.h"#include "hxprefs.h"#include "rtptypes.h"#include "hxrand.h"#include "hxslist.h"#include "hxstring.h"#include "hxstrutl.h"#include "chxpckts.h"#include "hxbuffer.h"#include "tconverter.h"#include "asmrulep.h"#include "hxtick.h"#include "hxengin.h"#include "netbyte.h"	// rninet_addr#include "statinfo.h" // STREAM_STATS#include "hxmangle.h" // CLIENT_ID_REGNAME#include "hxurl.h"// error reporting #include "hxxres.h"#include "hxxrsmg.h"#include "resid.h"#include "scalmres.h"   // in coreres module#include "packetq.h"#include "carray.h"#include "ppbin.h"#include "ppfformat.ver"#include "rtpwrap.h"#include "ppffplin.h"#include "ppffsrc.h"#include "ppffstrm.h"#include "ppffhttp.h"#include "hxver.h"#include "sdpchunk.h"#include "sdppyldinfo.h"#include "hxhyper.h"	// IHXHyperNavigation#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE		static char HX_THIS_FILE[] = __FILE__;#endif#ifdef _AIX#include "hxtbuf.h"#include "dllpath.h"ENABLE_MULTILOAD_DLLACCESS_PATHS(Ppffplin);#endifconst UINT32	MS_PER_SECOND	= 1000;const UINT32	MICRO_PER_MS	= 1000;/*************************************************************************** *  CPurePlayFileFormat static variables                         ref:  rprxypln.h * *  These variables are passed to the RMA core to provide information about *  this plug-in. They are required to be static in order to remain valid *  for the lifetime of the plug-in. */const char*  CPurePlayFileFormat::zm_pDescription	= "RealNetworks Scalable Multicast Plugin";const char*  CPurePlayFileFormat::zm_pCopyright		= HXVER_COPYRIGHT;const char*  CPurePlayFileFormat::zm_pMoreInfoURL	= HXVER_MOREINFO;const char*  CPurePlayFileFormat::zm_pFileMimeTypes[]	= {"application/sdp", NULL};const char*  CPurePlayFileFormat::zm_pFileExtensions[]	= {"sdp", NULL};const char*  CPurePlayFileFormat::zm_pFileOpenNames[]	= {"Scalable multicast stream description", NULL};#ifdef _WINDOWS#if defined(WIN32_PLATFORM_PSPC)#define HDLL_TYPE HANDLE#else#define HDLL_TYPE HINSTANCE#endif /* defined(WIN32_PLATFORM_PSPC) */extern HDLL_TYPE g_hInstance;#endif#if defined(_TIMELINE_TRACE) || defined(_GETPACKET_TRACE)FILE* m_tfile = NULL;#endif	// _TIMELINE_TRACE || _GETPACKET_TRACE/**************************************************************************** *  *  Function: *  *	HXCreateInstance() *  *  Purpose: *  *	Function implemented by all plugin DLL's to create an instance of  *	any of the objects supported by the DLL. This method is similar to  *	Window's CoCreateInstance() in its purpose, except that it only  *	creates objects from this plugin DLL. * *	NOTE: Aggregation is never used. Therefore and outer unknown is *	not passed to this function, and you do not need to code for this *	situation. *  */STDAPI ENTRYPOINT(HXCREATEINSTANCE)(    IUnknown**  /*OUT*/	ppIUnknown){    *ppIUnknown = (IUnknown*)(IHXFileSystemObject*)new CPurePlayFileFormat;    if(*ppIUnknown)    {	(*ppIUnknown)->AddRef();	return HXR_OK;    }    return HXR_OUTOFMEMORY;}CPurePlayFileFormat::CPurePlayFileFormat()    : m_lRefCount(0)    , m_pContext(NULL)    , m_pStreamDesc(NULL)    , m_pRTPInfo(NULL)    , m_pLog(NULL)    , m_pFileObject(NULL)    , m_pFileBufferList(NULL)    , m_pScheduler(NULL)    , m_pClassFactory(NULL)    , m_pFileHeader(NULL)    , m_pRegistry(NULL)    , m_pSDPDesc(NULL)    , m_state(Init)    , m_pFFResponse(NULL)    , m_uActiveStreams(0)    , m_pMasterSyncStream(NULL)    , m_bInitialPacket(TRUE)    , m_uStatusCode(HX_STATUS_READY)    , m_pStatusDesc(NULL)    , m_pCName(NULL)    , m_pUserName(NULL)    , m_pTool(NULL)      , m_pEmail(NULL)    , m_hFileHeader(0)    , m_bRMPresentation(TRUE)#ifdef _ALLOW_TS_OFFSETTING    , m_bDisableOffsetting(FALSE)#else	// _ALLOW_TS_OFFSETTING    , m_bDisableOffsetting(TRUE)#endif	// _ALLOW_TS_OFFSETTING    , m_bSourceAdmissionClosed(FALSE)    , m_ulFileHeaderWaitStartTime(0)    , m_ulListeningWaitStartTime(0)    , m_ulServerTimeout(0)    , m_bOneMoreTry(TRUE)    , m_lSmallestTSStrm(-1)    , m_tryUnicast(NO_TRY)    , m_pRequest(NULL)    , m_lRAStreamNum(NO_EXIST)    , m_bWantClientStats(TRUE)    , m_bAttempMulticast(TRUE)    , m_ulFirstTSSent(0)    , m_bFirstPktSent(FALSE)    , m_bFirstPktRcvd(FALSE)    , m_ulHXOffset(0)    , m_pInterfaceMgr(NULL)    , m_ppInterfacesReady(NULL)    , m_ulNumInterfacesReady(0)    , m_ulStartTimeMS(0)#ifdef BW_BASED    , m_lRuleNumber(-1)#endif    #ifdef _DEBUG    , m_bFileHeaderReadyCalled(FALSE)#endif    {    ;}CPurePlayFileFormat::~CPurePlayFileFormat() {     HX_RELEASE(m_pContext);        HX_RELEASE(m_pCName);    HX_RELEASE(m_pUserName);    HX_RELEASE(m_pTool);    HX_RELEASE(m_pEmail);}// *** IUnknown methods ***///////////////////////////////////////////////////////////////////////////  Method://	IUnknown::QueryInterface//  Purpose://	Implement this to export the interfaces supported by your //	object.//STDMETHODIMP CPurePlayFileFormat::QueryInterface(REFIID riid, void** ppvObj){    if (IsEqualIID(riid, IID_IHXTransportSyncServer))    {	AddRef();	*ppvObj = (IHXTransportSyncServer*) this;	return HXR_OK;    }    else if (IsEqualIID(riid, IID_IUnknown))    {	AddRef();	*ppvObj = this;	return HXR_OK;    }    else if(IsEqualIID(riid, IID_IHXPlugin))    {	AddRef();	*ppvObj = (IHXPlugin*)this;	return HXR_OK;    }    else if(IsEqualIID(riid, IID_IHXFileFormatObject))    {	AddRef();	*ppvObj = (IHXFileFormatObject*)this;	return HXR_OK;    }    else if(IsEqualIID(riid, IID_IHXFileResponse))    {	AddRef();	*ppvObj = (IHXFileResponse*)this;	return HXR_OK;    }    else if(IsEqualIID(riid, IID_IHXASMSource))    {	AddRef();	*ppvObj = (IHXASMSource*)this;	return HXR_OK;    }    else if(IsEqualIID(riid, IID_IHXPendingStatus))    {	AddRef();	*ppvObj = (IHXPendingStatus*)this;	return HXR_OK;    }    else if(IsEqualIID(riid, IID_IHXPropertyAdviser))    {	AddRef();	*ppvObj = (IHXPropertyAdviser*)this;	return HXR_OK;    }        *ppvObj = NULL;    return HXR_NOINTERFACE;}///////////////////////////////////////////////////////////////////////////  Method://	IUnknown::AddRef//  Purpose://	Everyone usually implements this the same... feel free to use//	this implementation.//STDMETHODIMP_(ULONG32) CPurePlayFileFormat::AddRef(){    return InterlockedIncrement(&m_lRefCount);}///////////////////////////////////////////////////////////////////////////  Method://	IUnknown::Release//  Purpose://	Everyone usually implements this the same... feel free to use//	this implementation.//STDMETHODIMP_(ULONG32) CPurePlayFileFormat::Release(){    if (InterlockedDecrement(&m_lRefCount) > 0)    {        return m_lRefCount;    }    delete this;    return 0;}/**************************************************************************** *  IHXPlugin::GetPluginInfo                                ref:  hxplugn.h * *  This routine returns descriptive information about the plug-in, most *  of which is used in the About box of the user interface. It is called     *  when the RMA core application is launched. */STDMETHODIMPCPurePlayFileFormat::GetPluginInfo(    REF(BOOL)	    /*OUT*/ bLoadMultiple,    REF(const char*)/*OUT*/ pDescription,    REF(const char*)/*OUT*/ pCopyright,    REF(const char*)/*OUT*/ pMoreInfoURL,    REF(UINT32)     /*OUT*/ ulVersionNumber){    bLoadMultiple = TRUE;   // Must be true for file formats.    pDescription    = zm_pDescription;    pCopyright	    = zm_pCopyright;    pMoreInfoURL    = zm_pMoreInfoURL;    ulVersionNumber = TARVER_ULONG32_VERSION;    return HXR_OK;}/**************************************************************************** *  IHXFileFormatObject::GetFileFormatInfo                  ref:  hxformt.h * *  This routine returns crucial information required to associate this *  plug-in with a given MIME type. This information tells the core which *  File Format plug-in to use for a particular URL. The routine is called *  when the RMA core application is launched. */STDMETHODIMPCPurePlayFileFormat::GetFileFormatInfo(    REF(const char**) /*OUT*/ pFileMimeTypes,    REF(const char**) /*OUT*/ pFileExtensions,    REF(const char**) /*OUT*/ pFileOpenNames){    pFileMimeTypes  = zm_pFileMimeTypes;    pFileExtensions = zm_pFileExtensions;    pFileOpenNames  = zm_pFileOpenNames;    return HXR_OK;}/**************************************************************************** *  IHXPlugin::InitPlugin                                   ref:  hxplugn.h * *  This routine performs initialization steps such as determining whether *  required interfaces are available. It is called when the RMA core  *  application is launched, and whenever an URL associated with this *  plug-in is opened. */STDMETHODIMPCPurePlayFileFormat::InitPlugin(IUnknown* /*IN*/ pContext){    HX_RESULT theErr = HXR_OK;         int localizedErrCode = 0;    m_pContext = pContext;        if (NULL == m_pContext)    {    	theErr = HXR_INVALID_PARAMETER;	localizedErrCode = IDS_ERR_SM_NO_CTXT;    	goto bail;    }    m_pContext->AddRef();    /*     * Get the necessary interfaces     */    theErr = m_pContext->QueryInterface(IID_IHXErrorMessages,					(void**)&m_pLog);    if (theErr != HXR_OK || NULL == m_pLog)    {	theErr = HXR_INVALID_PARAMETER;	localizedErrCode = IDS_ERR_SM_CTXT_QI_FAILED;	goto bail;    }    theErr = m_pContext->QueryInterface(IID_IHXScheduler,					(void**)&m_pScheduler);	    if (theErr != HXR_OK || NULL == m_pScheduler)    {	theErr = HXR_INVALID_PARAMETER;	localizedErrCode = IDS_ERR_SM_CTXT_QI_FAILED;	goto bail;    }    theErr = m_pContext->QueryInterface(IID_IHXRegistry,					(void**)&m_pRegistry);    if (theErr != HXR_OK || NULL == m_pRegistry)    {	theErr = HXR_INVALID_PARAMETER;	localizedErrCode = IDS_ERR_SM_CTXT_QI_FAILED;	goto bail;    }    theErr = m_pContext->QueryInterface(IID_IHXCommonClassFactory,     					(void**)&m_pClassFactory);    if (theErr != HXR_OK || NULL == m_pClassFactory)    {    	theErr = HXR_INVALID_PARAMETER;	localizedErrCode = IDS_ERR_SM_CTXT_QI_FAILED;    	goto bail;    }bail:    if (theErr != HXR_OK)    {	ReportError(localizedErrCode, HXLOG_WARNING, HXR_FAIL);    }    return theErr;}/**************************************************************************** *  IHXFileFormatObject::InitFileFormat                     ref:  hxformt.h * *  This routine initializes the file, and stores references to objects used *  throughout the example. It is called whenever an URL associated with this

⌨️ 快捷键说明

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