3gppttrenderer.cpp
来自「symbian 下的helix player源代码」· C++ 代码 · 共 1,765 行 · 第 1/5 页
CPP
1,765 行
/* ***** BEGIN LICENSE BLOCK *****
* Version: RCSL 1.0/RPSL 1.0
*
* Portions Copyright (c) 1995-2003 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
* Version 1.0 (the "RPSL") available at
* http://www.helixcommunity.org/content/rpsl unless you have licensed
* the file under the RealNetworks Community Source License Version 1.0
* (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.
*
* 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 ***** */
/****************************************************************************
* Defines
*/
#define INITGUID /* Interface ID's */
#if !defined(STRICT)
#define STRICT
#endif
/****************************************************************************
* Includes
*/
#include "hxtypes.h"
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h> // /for memset, strncmp, stricmp
#if defined(_SYMBIAN) // / -----vvvvvvvvvvvvvvvvvvvvvvvvvv-----
#include <gdi.h> // /For CFont, TFontSpec, CGraphicsDevice, ...etc.
#include <utf.h> // /For CnvUtfConverter::ConvertToUnicodeFromUtf8();
#include <coecntrl.h>
#include <fbs.h> // /For CFbsBitmap
#include <eikenv.h>
#endif // /_SYMBIAN _____^^^^^^^^^^^^^^^^^^^^^^^^^^_____
#if defined(_WINDOWS) // / -----vvvvvvvvvvvvvvvvvvvvvvvvvv-----
#include <windows.h>
#include "platform\\win\\resource.h"
#endif // /_WINDOWS _____^^^^^^^^^^^^^^^^^^^^^^^^^^_____
#if defined(_UNIX) && (!(defined(_BEOS)))
#include <stdlib.h>
#include <unistd.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <X11/Xaw/Label.h>
#endif
#include "hxwintyp.h"
#include "hxevent.h"
#include "hxcom.h"
#include "hxcomm.h"
#include "chxpckts.h"
#include "baseobj.h"
#include "hxfiles.h"
#include "hxcore.h"
#include "hxrendr.h"
#include "hxhyper.h"
#include "hxplugn.h"
#include "hxwin.h"
#include "hxasm.h"
#include "hxver.h"
#include "hxvsurf.h"
#include "hxslist.h"
#include "hxtick.h" //for HX_GET_BETTERTICKCOUNT()
#include "rule2flg.h" // /For RuleToFlagMap
#include "3gppttstructs.h"
#include "3gppttutils.h"
#include "3gppttrenderer.h"
#include "3gppttrenderer.ver"
#include "hxheap.h"
#ifdef _DEBUG
#undef HX_THIS_FILE
static const char HX_THIS_FILE[] = __FILE__;
#endif
// /#define XXXEH_DEBUGOUT_DRAW_3GPPTT
#if defined(XXXEH_DEBUGOUT_DRAW_3GPPTT)
#pragma message("====##### THIS CODE SHOULD NOT BE ENABLED IN SOURCE REPOSITORY #####====")
static UINT32 ulCount;
FILE* pFile = NULL;
#endif // /XXXEH_DEBUGOUT_DRAW_3GPPTT.
#if defined(_WINDOWS) // / -----vvvvvvvvvvvvvvvvvvvvvvvvvv-----
extern HINSTANCE g_hInstance;
COLORREF convertARGBtoWinBGRColor(UINT32 ulARGBVal)
{
COLORREF winColor = 0L;
UCHAR red, green, blue;
red = (UCHAR)(ulARGBVal>>16); //red is bytes 4,5
green = (UCHAR)(ulARGBVal>>8); //green is 2,3
blue = (UCHAR)ulARGBVal; //and blue is bytes 0,1
winColor = (COLORREF)red | (COLORREF(green)<<8) |
(COLORREF(blue)<<16);
return winColor;
}
#endif // /_WINDOWS. _____^^^^^^^^^^^^^^^^^^^^^^^^^^_____
//
#if defined(_SYMBIAN) // / -----vvvvvvvvvvvvvvvvvvvvvvvvvv-----
void convertARGBtoSymbianTrgbColor(TRgb& rgbColor,
UINT32 ulARGBVal)
{
UCHAR red, green, blue;
red = (UCHAR)(ulARGBVal>>16); //red is bytes 4,5
green = (UCHAR)(ulARGBVal>>8); //green is 2,3
blue = (UCHAR)ulARGBVal; //and blue is bytes 0,1
// /TRgb is: 0x00bbggrr :
rgbColor = (UINT32)red | (UINT32(green)<<8) |
(UINT32(blue)<<16);
}
#endif // /_SYMBIAN. _____^^^^^^^^^^^^^^^^^^^^^^^^^^_____
/****************************************************************************
* HXCreateInstance ref: hxplugn.h
*
* This routine creates a new instance of the C3GPPTimedTextRenderer class.
* It is called when the Helix core application is launched, and whenever
* a stream associated with this plug-in needs to be rendered.
*/
STDAPI
ENTRYPOINT(HXCREATEINSTANCE)(IUnknown** ppIUnknown)
{
*ppIUnknown = (IUnknown*)(IHXPlugin*)new C3GPPTimedTextRenderer();
if (*ppIUnknown)
{
(*ppIUnknown)->AddRef();
return HXR_OK;
}
return HXR_OUTOFMEMORY;
}
/****************************************************************************
*
* Function:
*
* CanUnload2()
*
* Purpose:
*
* Function implemented by all plugin DLL's if it returns HXR_OK
* then the pluginhandler can unload the DLL
*
*/
STDAPI ENTRYPOINT(CanUnload2)(void)
{
return ((CHXBaseCountingObject::ObjectsActive() > 0) ?
HXR_FAIL : HXR_OK);
}
/****************************************************************************
* C3GPPTimedTextRenderer static variables ref: 3gppttrender.h
*
* These variables are passed to the Helix 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* const C3GPPTimedTextRenderer::zm_pDescription = "3GPP Timed Text Renderer Plugin";
const char* const C3GPPTimedTextRenderer::zm_pCopyright = HXVER_COPYRIGHT;
const char* const C3GPPTimedTextRenderer::zm_pMoreInfoURL = HXVER_MOREINFO;
const char* const C3GPPTimedTextRenderer::zm_pStreamMimeTypes[] = {"video/X-RN-3GPP-TEXT", NULL};
/****************************************************************************
* 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 Helix core application is launched.
*/
STDMETHODIMP
C3GPPTimedTextRenderer::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;
pDescription = zm_pDescription;
pCopyright = zm_pCopyright;
pMoreInfoURL = zm_pMoreInfoURL;
ulVersionNumber = TARVER_ULONG32_VERSION;
return HXR_OK;
}
/****************************************************************************
* IHXRenderer::GetRendererInfo ref: hxrendr.h
*
* This routine returns crucial information required to associate this
* plug-in with a given stream MIME type. This information tells the Helix
* core which Renderer to use to display a particular type of stream. This
* method is called when the Helix core application is launched.
*/
STDMETHODIMP
C3GPPTimedTextRenderer::GetRendererInfo
(
REF(const char**) /*OUT*/ pStreamMimeTypes,
REF(UINT32) /*OUT*/ unInitialGranularity
)
{
pStreamMimeTypes = (const char**)zm_pStreamMimeTypes;
// /XXXEH- todo: adjust this on the fly when scrolling is happening;
// scrollrate can change over time:
unInitialGranularity = 50; // OnTimeSync() every 50ms
return HXR_OK;
}
/****************************************************************************
* IHXPlugin::InitPlugin ref: hxplugn.h
*
* This routine performs initialization steps such as determining if
* required interfaces are available. It is called when the Helix core
* application is launched, and whenever a stream associated with this
* plug-in needs to be rendered.
*/
STDMETHODIMP
C3GPPTimedTextRenderer::InitPlugin(IUnknown* /*IN*/ pContext)
{
m_pContext = pContext;
m_pContext->AddRef();
m_pContext->QueryInterface(IID_IHXHyperNavigate, (void**) &m_pHyperNavigate);
m_pContext->QueryInterface(IID_IHXCommonClassFactory,(void**)&m_pCommonClassFactory);
#if defined(HELIX_3GPPTT_USE_STATUS_BAR)
m_pContext->QueryInterface(IID_IHXStatusMessage, (void**)&m_pStatusMessage);
#endif /* HELIX_3GPPTT_USE_STATUS_BAR */
return HXR_OK;
}
/****************************************************************************
* IHXRenderer::StartStream ref: hxrendr.h
*
* The Helix core calls this routine to provide access to the stream and
* player. It is called when the plug-in is being initialized.
*/
STDMETHODIMP
C3GPPTimedTextRenderer::StartStream
(
IHXStream* pStream,
IHXPlayer* pPlayer
)
{
m_pStream = pStream;
m_pPlayer = pPlayer;
if (m_pStream ) m_pStream->AddRef();
if (m_pPlayer ) m_pPlayer->AddRef();
#if defined (HELIX_FEATURE_MISU)
m_pCommonClassFactory->CreateInstance(CLSID_IHXMultiInstanceSiteUserSupplier,
(void**)&m_pMISUS);
if (m_pMISUS)
{
m_pMISUS->SetSingleSiteUser((IUnknown*)(IHXSiteUser*) this);
}
#endif //HELIX_FEATURE_MISU
if (m_pStream)
{
IHXStreamSource* pSource = 0;
if (m_pStream->GetSource(pSource) == HXR_OK)
{
/* It is OK if the source does not support backchannel. Reasons:
*
* 1. This stream may not be coming from the MP4/3GPP fileformat.
* It may instead be merged into a container fileformat which
* maybe does not support BackChannel.
*
* 2. The protocol used to serve this stream may not support
* BackChannel.
*/
pSource->QueryInterface(IID_IHXBackChannel, (void**) &m_pBackChannel);
pSource->Release();
}
/* Is ASM supported on this stream? */
m_pStream->QueryInterface(IID_IHXASMStream, (void**) &m_pASMStream);
}
return HXR_OK;
}
/****************************************************************************
* IHXRenderer::OnHeader ref: hxrendr.h
*
* This routine is passed the stream header object created by the associated
* file format plug-in. Use the methods defined in the IHXValues interface
* to access the stream header data. This method is called from the Helix
* core when the plug-in is being initialized.
*/
STDMETHODIMP
C3GPPTimedTextRenderer::OnHeader(IHXValues* pHeader)
{
HX_RESULT hxrslt = HXR_OK;
IHXBuffer* pRuleToFlagMapValue = NULL;
UINT32 ulRegionWidth = 0;
UINT32 ulRegionHeight = 0;
UINT32 ulTransformX = 0;
UINT32 ulTransformY = 0;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?