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

📄 c_rtrndr.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: c_rtrndr.cpp,v 1.1.2.1 2004/07/09 01:50:49 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 ***** *//////////////////////////////////////////////////////////////////////////////////  C_RTRNDR.CPP//// Method://  ULONG32 RealTextRenderer::OnHeader(void* pData,	ULONG32 dataLength);// Purpose://  Gets the header information from the pData string and fills //  m_pTextWindow's fields appropriately. // Returns://  Returns the index of pData where the <WINDOW ..> tag's //  '>' char is, plus 1.  Returns dataLength if failure to find//  valid <WINDOW..> tag.////// Method://  void RealTextRenderer::OnData(void* pData, ULONG32 dataLength,//				  BOOL bFromOnPacket)// Purpose://  This function receives the latest packet's raw data (in pData) and//  inserts it into the (*m_pTextWindow)::TextContaierList with the latest//  render attribute in (*m_pTextWindow)::TextAttributeStacks.////// Method://  BOOL RealTextRenderer::OnTimeSynch(ULONG32 ulCurTime);// Purpose://  For each TextContainer of (*m_pTextWindow)::TextContainerList, move its//  text's location by an amount determined by the crawlrate and scrollrate//  and  the difference between the current time and the last time the text//  was rendered.  If any TextContainer's text has moved, invalidate the //  area that needs updating.//  When finished re-rendering all text that has moved, update the window so//  that the changes will appear.//  Note: "ulCurTime" is the number of milliseconds since the stream started.////#include "hxtypes.h" /*Must be included before windows.h for VC6 compiler*/#if defined(_WINDOWS)#include <windows.h>#endif#include "hxassert.h"#include <stdlib.h>#include <string.h>#include "hxstack.h"#include "hxslist.h"#include "rt_types.h" //for _CHAR, RED_GREEN_OR_BLUE, COLORTYPE#include "fontdefs.h"#include "txtattrb.h"#include "txtcntnr.h"#include "textline.h"#include "hxstrutl.h"#include "txtwindw.h" //for class TextWindow.#include "parsing.h"  //for parsing helper functions.#include "atocolor.h" //for string-to-COLORTYPE conversion functions.#include "rt_string.h" //for stringCompare().#include "atotime.h"#include "textprsr.h"  //added parent class TextParser.#include "fontinfo.h" //for GetCharacterWidth().#include "c_rtrndr.h"#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE		static char HX_THIS_FILE[] = __FILE__;#endif#if defined(_DEBUG)// /#define XXXEH_TESTING_DATAURLPLAINTEXT_HANDLING#endif#define MIN_ACCEPTABLE_PLAINTEXT_CHAR_WIDTH 3#define MIN_ACCEPTABLE_PLAINTEXT_HEIGHT	    5BOOLListOfPacketDataIDsReceived::HaveAlreadySeenThisData(ULONG32 ulPacketDataID){    if(Find((void *)ulPacketDataID, NULL) != NULL)    {	return TRUE;    }    else    {	//Insert it at the START of the list (because Find() will start	// at the start of the list and will find more-recent IDs there	// and thus calls to HaveAlreadySeenThisData() will be quicker	// since chances are we've seen ulPacketDataID very recently if	// at all:	AddHead((void *)ulPacketDataID);	return FALSE;    }}///////////////////////////////////////////////////////////////////////////// //  Returns 1 + (index of pData where the <WINDOW ..> tag's '>' char is).//		returns dataLength if failure to find valid <WINDOW..> tag.ULONG32 RealTextRenderer::OnHeader(void* pData, ULONG32 dataLength){    //Now parse pData:#if !defined(_CHARsizeInBytesIs1)#error this code needs to be updated...#endif    _CHAR* pData_CHAR = (_CHAR*)pData;    if(!m_pTextWindow)    {	return dataLength;    }    /*	Find the first '<' and then find the first '>' or end-of-data, and     *  send the contents found to m_pTextWindow->parseHeaderTag(): */    _CHAR* pHeaderTagBuf;    LONG32 headerTagBufLen;    LONG32 indexOfLeftBracket = -1;    LONG32 indexOfRightBracket = -1;    LONG32 indx;    LONG32 len = LONG32(dataLength);    for(indx=0; indx<len; indx++)    {/*XXXEH- for now, we have to assume that the first text encountered is not  DBCS text; it and all text inside tags must be us-ascii charset:	//added the following to handle DBCS chars:	if((UCHAR)pData_CHAR[indx] >= DBCS_MIN_LEAD_BYTE_VAL)	{	    indx++; //skip this and the following trail byte.	    continue;	}*/		if(pData_CHAR[indx] == '<')	{	    indexOfLeftBracket = indx;	    break;	}    }    if(indexOfLeftBracket != -1)    {	for(indx++; indx<len; indx++)	{/*XXXEH- for now, we have to assume that the first text encountered is not  DBCS text; it and all text inside tags must be us-ascii charset:	    //added the following to handle DBCS chars:	    if((UCHAR)pData_CHAR[indx] >= DBCS_MIN_LEAD_BYTE_VAL)	    {		indx++; //skip this and the following trail byte.		continue;	    }*/	    if(pData_CHAR[indx] == '>')	    {		indexOfRightBracket = indx;		break;	    }		}    }    if(-1 == indexOfLeftBracket  ||  -1 == indexOfRightBracket  ||	    ((indexOfRightBracket-indexOfLeftBracket)-1) <	    LONG32(int(strlen("WINDOW"))) )    {	char* pszWrtstr = new char[64];	if (!pszWrtstr)	{	    return 0;	}    	strcpy(pszWrtstr, "WINDOW type="); /* Flawfinder: ignore */	//Added this to allow <HTML> to be the first tag:	if( ((indexOfRightBracket-indexOfLeftBracket)-1) >=		LONG32(int(strlen("HTML"))) )	{	    if(('H' == pData_CHAR[indexOfLeftBracket]  ||		    'h' == pData_CHAR[indexOfLeftBracket])  &&		    ('T' == pData_CHAR[indexOfLeftBracket+1]  ||		    't' == pData_CHAR[indexOfLeftBracket+1])  &&		    ('M' == pData_CHAR[indexOfLeftBracket+2]  ||		    'm' == pData_CHAR[indexOfLeftBracket+2])  &&		    ('L' == pData_CHAR[indexOfLeftBracket+3]  ||		    'l' == pData_CHAR[indexOfLeftBracket+3])    )	    {	//XXXEH- need to handle type=html in parseHeaderTag():	    	strcat(pszWrtstr, "HTML"); /* Flawfinder: ignore */	    }	}	else	{	    //Added this to allow files with no header tag:	    // No '<' was found (or no valid header tag was found),	    //Need to set default vals to type	    // generic's default vals here:	    //XXXEH- need to handle type=plaintext in parseHeaderTag():	    strcat(pszWrtstr, "plaintext"); /* Flawfinder: ignore */	}	m_pTextWindow->parseHeaderTag((_CHAR*)pszWrtstr, strlen(pszWrtstr),		m_ulRTMarkupParsingMajorVersion,		m_ulRTMarkupParsingMinorVersion);	delete [] pszWrtstr;	pszWrtstr = NULL;	if(-1 == indexOfRightBracket)	{   //XXXEH- should dataLength be returned here?!:	    return 0L; //signals that no header tag was found (and			//that the text starts at byte zero of file).	}	else	{	    return (indexOfRightBracket+1);	}    }    //	Next, parse the header's tag after copying it into pHeaderTagBuf:    headerTagBufLen = indexOfRightBracket-indexOfLeftBracket-1;    pHeaderTagBuf = new _CHAR[headerTagBufLen+1];//Add 1 for terminating '\0'    HX_ASSERT_VALID_PTR(pHeaderTagBuf);    if(NULL == pHeaderTagBuf)    {	return dataLength;  //return end-of-pData index to signal error.		    }    for(indx=0; indx<headerTagBufLen; indx++)    {	pHeaderTagBuf[indx] = pData_CHAR[indx+indexOfLeftBracket+1];    }    pHeaderTagBuf[headerTagBufLen] = '\0';    /*  Now parse the header to get the WINDOW tag, and, if it is     *  found, get the "NAME=value" pairs and assign the TextWindow's     *  appropriate objects' data to these requested values:  */    if(!m_pTextWindow->parseHeaderTag(pHeaderTagBuf, headerTagBufLen,	    m_ulRTMarkupParsingMajorVersion,	    m_ulRTMarkupParsingMinorVersion))    {	/*  Returned FALSE because of invalid header tag:  */	delete [] pHeaderTagBuf;	pHeaderTagBuf = NULL;	return dataLength; //return end-of-pData index to signal error.							    }    delete [] pHeaderTagBuf;    pHeaderTagBuf = NULL;    return (indexOfRightBracket+1);}// /XXXEH- add this to hxmisc at some point; hxsmil/smlparse.cpp uses it too:// /This is needed for calculating the max possible size that a plain-// text window might grow to so that a guess at the max number of plain-// text characters to be accepted can be calculated for fixing PR 78150:voidRealTextRenderer::GetSystemScreenInfo(UINT32& rulScreenHeight,				 UINT32& rulScreenWidth,				 UINT32& rulScreenBitDepth){#if defined(_WINDOWS)    rulScreenHeight = (UINT32)GetSystemMetrics(SM_CYSCREEN);    rulScreenWidth = (UINT32)GetSystemMetrics(SM_CXSCREEN);    HDC hDCMain = GetDC(NULL); // /Get screen DC.    if (hDCMain)    {	rulScreenBitDepth = (UINT32)GetDeviceCaps(hDCMain, BITSPIXEL);	ReleaseDC(NULL, hDCMain);    }/* The following relies on X Windows, and we don't want to do that, so   just use the numbers in the #else, below:#elif defined(_UNIX) && (!(defined(_BEOS)))    // /Pass NULL string to XOpenDisplay to get default display, which    // is the one that we're playing to:    Display* pDisplay = XOpenDisplay(NULL);    if (pDisplay)    {	Screen* pScreen = XDefaultScreenOfDisplay(pDisplay);	rulScreenHeight = (UINT32)HeightOfScreen(pScreen);	rulScreenWidth = (UINT32)WidthOfScreen(pScreen);	rulScreenBitDepth = (UINT32)DefaultDepthOfScreen(pScreen);    } */#elif defined(_MACINTOSH)    // /XXXEH- note: on a Mac, you can have multiple display devices and our    // player can actually play to more than one at once, and can be dragged    // from one to the other while running.  Dynamic re-evaluation is needed.    GDHandle mainGD = ::GetMainDevice();    rulScreenHeight = (UINT32)((**mainGD).gdRect.bottom - (**mainGD).gdRect.top);    rulScreenWidth = (UINT32)((**mainGD).gdRect.right - (**mainGD).gdRect.left);    PixMapHandle pmh = (**mainGD).gdPMap;    if (pmh)    {	rulScreenBitDepth = (UINT32)((**pmh).pixelSize);    }#else// /    HX_ASSERT(0  &&  "need screen info from this OS");    rulScreenHeight = 1600;    rulScreenWidth  = 1200;    rulScreenBitDepth = 32;#endif}/////////////////////////////////////////////////////////////////////////////// Method://  void RealTextRenderer::OnData(void* pData, ULONG32 dataLength,//				  BOOL bFromOnPacket)// Purpose://  This function receives the latest packet's raw data (in pData) and//  inserts it into the m_pTextWindow::TextContaierList with the latest//  render attribute in m_pTextWindow::TextAttributeStacks.//void RealTextRenderer::OnData(void* pData, ULONG32 dataLength, BOOL bFromOnPacket){    //Look through the data for the first valid markup tag.  Any text found    //	before that gets put in a new TextContainer object and is inserted    //	into the TextContainerList part of the TextWindow object.  If that    //	list is empty, a new TextContainer is added to it with the default    //	characteristics for the text.  If a valid markup tag is found before    //	the end of the pData is reached, the text that follows it, up to the    //	next tag, goes into a new TextContainer object that is added to the    //	list and has the text-rendering characteristic specified in that tag:	#if !defined(_CHARsizeInBytesIs1)#error this code needs to be updated...#endif    _CHAR* pData_CHAR = (_CHAR*)pData;    BOOL bDataCHARwasAllocd = FALSE;    TextContainer* pTC = NULL;  // /Part of fix for PR 59951: if this is an in-line <text> source in a  // SMIL 2.0+ file, then we want to treat this as plain text which has  // no file header:  // /Handle .txt files this way too, now:  if (isPlainText())  {	// /Helps fix PR 78150: if m_ulPlainTextDataLen is too large for	// the window, then we can safely ignore the rest.  This prevents	// system-overload problems when someone renames, say, a 40MB mpg file	// to .txt.  We can't use the point size nor the window width and	// height to calculate this because those might be animated (changed)	// on the fly by SMIL2 renderer:	if (dataLength > 0)	{	    UINT32 rulScreenHeight = 0;	    UINT32 rulScreenWidth = 0;	    UINT32 rulScreenBitDepth = 0;	    // /Could change dynamically, so redo each pkt:	    GetSystemScreenInfo(rulScreenHeight, rulScreenWidth,		    rulScreenBitDepth);	    ULONG32 ulMaxCharsOnOneLine = (rulScreenWidth /		    MIN_ACCEPTABLE_PLAINTEXT_CHAR_WIDTH) *2 /* *2 for safety*/;	    ULONG32 ulMaxRowsOfPlainText = (rulScreenHeight /

⌨️ 快捷键说明

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