3gppttrenderer.h
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:15k
- /* ***** 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 ***** */
- #ifndef _3GPPTTRENDERER_H_
- #define _3GPPTTRENDERER_H_
- /************************************************************************
- *
- * Defines:
- */
- // /These are special-case font names that can be used in a FontTable entry:
- #define FONT_FAMILY_SERIF_STR "Serif"
- #define FONT_FAMILY_SANS_SERIF_STR "Sans-Serif"
- #define FONT_FAMILY_MONOSPACE_STR "Monospace"
- #define MAX_3GPPTT_URL_LEN (sizeof(UINT8))
- // /These are for drawing; it's possible that we want to set (1,0) (i.e.,
- // something other than (0,0) as the starting point for drawing text:
- #define INITIAL_CURSOR_X 0
- #define INITIAL_CURSOR_Y 0
- #if defined(_WINDOWS) // / -----vvvvvvvvvvvvvvvvvvvvvvvvvv-----
- #define USE_DIB_SECTION 1
- #endif // /_WINDOWS _____^^^^^^^^^^^^^^^^^^^^^^^^^^_____
- #if defined(_SYMBIAN) // / -----vvvvvvvvvvvvvvvvvvvvvvvvvv-----
- #define HX_3GPPTT_DEFAULT_bits_PER_PIXEL 12 /* RGB444 native*/
- #if defined(HELIX_3GPPTT_SUPPORTS_TRANSPARENCY) && (HX_3GPPTT_DEFAULT_bits_PER_PIXEL == 12)
- #error this bit depth wont work with ARGB, dimwit
- #endif // /HELIX_3GPPTT_SUPPORTS_TRANSPARENCY
- #else // / not _SYMBIAN ------------------------------------
- #define HX_3GPPTT_DEFAULT_bits_PER_PIXEL 32
- #endif // /end else of if _SYMBIAN _____^^^^^^^^^^^^^^^^^^^^^^^^^^_____
- #if defined(_WINDOWS) // / -----vvvvvvvvvvvvvvvvvvvvvvvvvv-----
- #define HX_3GPPTT_FIXED_PITCH FIXED_PITCH
- #define HX_3GPPTT_DEFAULT_PITCH DEFAULT_PITCH
- #define HX_3GPPTT_FF_DONTCARE FF_DONTCARE
- #define HX_3GPPTT_FF_SANSSERIF_PROPORTIONAL_PITCH FF_SWISS
- #define HX_3GPPTT_FF_SERIF_PROPORTIONAL_PITCH FF_ROMAN
- #define HX_3GPPTT_JUSTIFY_LEFT DT_LEFT
- #define HX_3GPPTT_JUSTIFY_HCENTER DT_CENTER
- #define HX_3GPPTT_JUSTIFY_RIGHT DT_RIGHT
- #define HX_3GPPTT_JUSTIFY_TOP DT_TOP
- #define HX_3GPPTT_JUSTIFY_VCENTER DT_VCENTER
- #define HX_3GPPTT_JUSTIFY_BOTTOM DT_BOTTOM
- #define HX_3GPPTT_INITIAL_TEXTFORMAT DT_NOCLIP
- #else // / not _WINDOWS ------------------------------------
- #define HX_3GPPTT_DEFAULT_PITCH 0x0
- #define HX_3GPPTT_FF_DONTCARE 0x0
- #define HX_3GPPTT_FIXED_PITCH 0x1
- #define HX_3GPPTT_FF_SANSSERIF_PROPORTIONAL_PITCH 0x0
- #define HX_3GPPTT_FF_SERIF_PROPORTIONAL_PITCH 0x2
- #define HX_3GPPTT_JUSTIFY_LEFT 0x1
- #define HX_3GPPTT_JUSTIFY_HCENTER 0x4
- #define HX_3GPPTT_JUSTIFY_RIGHT 0x2
- #define HX_3GPPTT_JUSTIFY_TOP 0x10
- #define HX_3GPPTT_JUSTIFY_VCENTER 0x40
- #define HX_3GPPTT_JUSTIFY_BOTTOM 0x20
- #define HX_3GPPTT_INITIAL_TEXTFORMAT 0x0
- #endif // /else of if _WINDOWS. _____^^^^^^^^^^^^^^^^^^^^^^^^^^_____
- /****************************************************************************
- *
- * C3GPPTimedTextRenderer Class
- *
- * 3GPPTimedText implementation of a basic renderer.
- */
- class C3GPPTimedTextRenderer : public IHXPlugin
- , public IHXRenderer
- , public IHXSiteUser
- , public CHXBaseCountingObject
- {
- public:
- /****** Public Class Methods ******************************************/
- C3GPPTimedTextRenderer();
- // /Clears out and deletes contents of m_pTextContainerList:
- void ClearTextContainerLists(BOOL bDeleteListPtrWhenCleared);
- BOOL OnMouseMove(INT16 fwKeys, INT16 xPos, INT16 yPos);
- HX_RESULT HandleClick(INT16 fwKeys, INT16 xPos, INT16 yPos);
- HX_RESULT UpdateDisplay(UINT32 ulTime);
- HX_RESULT Draw(IHXVideoSurface *pVideoSurface);
- HX_RESULT SetFont(const C3GPPTextSampleEntry* pCurTextSampleEntry,
- UINT16 uiFontID_override,
- const char* pCurFontFaceString,
- BOOL bIsBolded,
- BOOL bIsItalicized,
- BOOL bIsUnderlined,
- BOOL bIsStruckThrough,
- UINT32 ulScaledHeight
- #if defined(_WINDOWS) // / -----vvvvvvvvvvvvvvvvvvvvvvvvvv-----
- , DWORD fdwCharSet
- #endif // /_WINDOWS _____^^^^^^^^^^^^^^^^^^^^^^^^^^_____
- );
- UINT32 SetJustificationFlags(const C3GPPTextSampleEntry* pCurTextSampleEntry);
- HX_RESULT FillRectangle(UINT32 ulRectColorARGB);
- #if defined(_WINDOWS) // / -----vvvvvvvvvvvvvvvvvvvvvvvvvv-----
- HX_RESULT ConvertToOSRenderableChars(const C3GPPTextContainer* pTextCont,
- /*OUT*/ DWORD& fdwCharSet,
- /*OUT*/ char*& pszNativeString,
- /*OUT*/ INT32& lNativeStringLen);
- HX_RESULT GetAppropriateCharset(wchar_t* pUTF16String,
- INT32 lLenUTF16StrInWideChars,
- /*OUT*/ DWORD& fdwCharSet, /*OUT*/UINT32& ulCodePage);
- #endif // /_WINDOWS _____^^^^^^^^^^^^^^^^^^^^^^^^^^_____
- C3GPPTextHyperTextBox* findActiveHyperlinkAtXY(
- INT16 xPos, INT16 yPos);
- UINT32 GetPacketContentTime(IHXPacket* pPacket);
- HX_RESULT HandleNewText(IHXPacket* pNewPacket,
- LISTPOSITION& plistPosOfFirstTxtCntnr);
- // /(Only) call this when new packet arrives:
- HX_RESULT SetPriorPacketTCsEndTimes();
- HX_RESULT InsertInRedrawListInTemporalOrder(
- const C3GPPTextContainer* pTextContainer);
- HX_RESULT RemoveFromRedrawList(const C3GPPTextContainer* pTextContainer);
- /************************************************************************
- * IHXRenderer Interface Methods ref: hxrendr.h
- */
- STDMETHOD(StartStream) (THIS_ IHXStream* pStream, IHXPlayer* pPlayer);
- STDMETHOD(EndStream ) (THIS);
- STDMETHOD(OnHeader ) (THIS_ IHXValues* pStreamHeaderObj);
- STDMETHOD(OnPacket ) (THIS_ IHXPacket* pPacket, INT32 timeOffset);
- STDMETHOD(OnTimeSync) (THIS_ UINT32 currentPlayBackTime);
- STDMETHOD(OnPreSeek ) (THIS_ UINT32 timeBefore, UINT32 timeAfter);
- STDMETHOD(OnPostSeek) (THIS_ UINT32 timeBefore, UINT32 timeAfter);
- STDMETHOD(OnPause ) (THIS_ UINT32 timeBeforePause);
- STDMETHOD(OnBegin ) (THIS_ UINT32 timeAfterBegin);
- STDMETHOD(OnBuffering) (THIS_ UINT32 reason, UINT16 percentComplete);
- STDMETHOD(GetRendererInfo)
- (THIS_
- REF(const char**) pStreamMimeTypes,
- REF(UINT32) initialGranularity
- );
- STDMETHOD(GetDisplayType)
- (THIS_
- REF(HX_DISPLAY_TYPE) displayType,
- REF(IHXBuffer*) pDisplayInfo
- );
- STDMETHOD(OnEndofPackets) (THIS);
- /************************************************************************
- * IHXSiteUser Interface Methods ref: hxwin.h
- */
- STDMETHOD(AttachSite) (THIS_ IHXSite* pSite);
- STDMETHOD(DetachSite) (THIS);
- STDMETHOD(HandleEvent) (THIS_ HXxEvent* pEvent);
- STDMETHOD_(BOOL,NeedsWindowedSites) (THIS);
-
-
- /************************************************************************
- * IHXPlugin Interface Methods ref: hxplugn.h
- */
- STDMETHOD(GetPluginInfo)
- (THIS_
- REF(BOOL) bLoadMultiple,
- REF(const char*) pDescription,
- REF(const char*) pCopyright,
- REF(const char*) pMoreInfoURL,
- REF(UINT32) versionNumber
- );
- STDMETHOD(InitPlugin) (THIS_ IUnknown* pContext);
- /************************************************************************
- * IUnknown COM Interface Methods ref: pncom.h
- */
- STDMETHOD (QueryInterface ) (THIS_ REFIID ID, void** ppInterfaceObj);
- STDMETHOD_(UINT32, AddRef ) (THIS);
- STDMETHOD_(UINT32, Release) (THIS);
- private:
- /****** Private Class Methods ******************************************/
- HX_RESULT CreateOffscreenBuffer(HXxSize& hxsize);
- void SetDrawOutputBuffer();
- // /This recalculates the list of text containers that need to be drawn
- // as well as those that don't need to be drawn based on new time:
- HX_RESULT RecomputeTextContainerDrawList(UINT32 ulCurTime);
- /****** Private Class Variables ****************************************/
- INT32 m_lRefCount;
- IUnknown* m_pContext;
- IHXStream* m_pStream;
- IHXPlayer* m_pPlayer;
- IHXValues* m_pHeader;
- IHXPacket* m_pLatestPacket;
- BOOL m_bGotAllPacketsAlready;
- UINT32 m_ulTimeOfLastTimeSync; // /Most-recent time sync
- UINT32 m_ulLastPacketTime;
- UINT32 m_ulLastRealPacketTime;
- UINT32 m_ulNumberOfClicks;
- BOOL m_bIsSubscribed;
- IHXHyperNavigate* m_pHyperNavigate;
- IHXBackChannel* m_pBackChannel;
- IHXASMStream* m_pASMStream;
- HXxSize m_size;
- IHXMultiInstanceSiteUserSupplier* m_pMISUS;
- IHXSite* m_pMISUSSite;
- IHXCommonClassFactory* m_pCommonClassFactory;
- BOOL m_bInSeekMode;
- BOOL m_bRTPPacketTested;
- BOOL m_bUsesRTPPackets;
- UINT32 m_ulDuration;
- // /This is the offset from video's origin (top left point):
- HXxPoint m_originTransformXY;
- UINT32 m_ulNumTextSampleEntries;
- IHXBuffer* m_p3GPPTextSampleEntryPackedArray;
- SimpleArray m_textSampleEntries;
- RuleToFlagMap* m_pRuleToFlagMap;
- CHXSimpleList* m_pTextContainerList;
- LISTPOSITION m_pTextContainerListFutureTimePos;
- // /This keeps track of T.C.s that need to be redrawn periodically due to
- // scroll motion or blinking:
- CHXSimpleList* m_pTextContainerRedrawList;
- INT16 m_nLastMouseMoveXPos;
- INT16 m_nLastMouseMoveYPos;
- HXxEvent* m_pEvent;
- // /In Symbian, this is just a pointer into m_pBitMap so
- // DO NOT NEW OR DELETE in Symbian!:
- BYTE* m_pDrawOutputBuffer;
- UINT32 m_ulDrawOutputBufferSizeInBytes;
- UINT32 m_ulBitsPerPixel;
- INT32 m_lXScrollOffset;
- INT32 m_lYScrollOffset;
- double m_dScrollFactor;
- BOOL m_bDrawInNonTextScrollArea;
- #if defined(HELIX_3GPPTT_USE_STATUS_BAR)
- IHXStatusMessage* m_pStatusMessage;
- BOOL m_bStatusMsgWillNeedErasing;
- char* m_pszHLinkToDisplay;
- #endif /* HELIX_3GPPTT_USE_STATUS_BAR */
- #if defined(_WINDOWS) // / -----vvvvvvvvvvvvvvvvvvvvvvvvvv-----
- BOOL m_bNeedToSetHyperlinkHandCursor;
- HCURSOR m_hHyperlinkCursor;
- HCURSOR m_hPreHyperlinkCursor;
- // /These are used for TextOut()s of text to blt to vid surface:
- void* m_pDeviceContextMemory; //memory DC for textWindow.
- HFONT m_pFont;
- HFONT m_pFontOld;
-
- #if defined(USE_DIB_SECTION)
- HBITMAP m_hBitmap;
- HBITMAP m_hOldBitmap;
- LPBITMAPINFO m_LPBITMAPINFO;
- BITMAPINFOHEADER m_BITMAPINFOHEADER;
- BOOL AllocNewLPBITMAPINFO(UINT32 ulNumBytes);
- #else
- #error: non-DIB-section version not implemented for Win32
- #endif /* USE_DIB_SECTION */
- #elif defined(_MACINTOSH)
- CursHandle m_hHyperlinkCursor;
- typedef enum
- {
- CURSOR_ARROW,
- CURSOR_HYPERLINK
- }
- CursorShapes;
- CursorShapes m_CurrentCursor;
- CResourceLoader* m_pResourceLoader;
- // /For offscreen drawing of text:
- GWorldPtr m_pOffScreenWorld;
- #elif defined(_UNIX) && (!(defined(_BEOS)))
- Cursor m_hHyperlinkCursor;
- BOOL m_bHandActivated;
- Display* m_pdisp;
- Window m_window;
- GC m_gc;
- #elif defined(_SYMBIAN) // / ------------------------------------
- CFbsBitmap* m_pBitMap;
- CFont* m_pFont;
- CFbsScreenDevice* m_pScreenDevice;
- CFbsBitGc* m_pGCSite;
- CFbsBitGc* m_pGCOffscreen;
- #endif // /_WINDOWS -elif- _MACINTOSH -elif- (_UNIX && !_BEOS) _____^^^^^^^^^^^^^^^^^^^^^^^^^^_____
- #if !defined(_USE_DIB_SECTION)
- HXBitmapInfoHeader m_BitmapInfoHeader;
- #endif
- /****** Private Static Class Variables *********************************/
- static const char* const zm_pDescription;
- static const char* const zm_pCopyright;
- static const char* const zm_pMoreInfoURL;
- static const char* const zm_pStreamMimeTypes[];
- /****** Private Class Methods ******************************************/
- ~C3GPPTimedTextRenderer();
- PRIVATE_DESTRUCTORS_ARE_NOT_A_CRIME // Avoids GCC compiler warning
- };
- #endif /* ndef _3GPPTTRENDERER_H_*/