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

📄 textline.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	    }	    SafeStrCat(pPacketHeaderBuf, ">", packetHeaderBufSize);	    pktHdrLen ++;	}	else  //do ticker upper first:	{	    if(origTuc != DEFAULT_TICKER_UPPERCOLOR)	    {			ulSprintfLen = sprintf(pTmp, "<TU color=#%02X%02X%02X>", /* Flawfinder: ignore */			ptuc[1],ptuc[2],ptuc[3]);		if(pktHdrLen+ulSprintfLen < packetHeaderBufSize-1)		{		    SafeStrCat(pPacketHeaderBuf, pTmp, packetHeaderBufSize);		    pktHdrLen += ulSprintfLen;		}	    }	    if(pktHdrLen+3 < packetHeaderBufSize-1)	    {		SafeStrCat(pPacketHeaderBuf, "<TL", packetHeaderBufSize);		pktHdrLen += 3;	    }	    if(origTlc != DEFAULT_TICKER_LOWERCOLOR)	    {			ulSprintfLen = sprintf(pTmp, " color=#%02X%02X%02X", /* Flawfinder: ignore */			ptlc[1],ptlc[2],ptlc[3]);		if(pktHdrLen+ulSprintfLen < packetHeaderBufSize-1)		{		    SafeStrCat(pPacketHeaderBuf, pTmp, packetHeaderBufSize);		    pktHdrLen += ulSprintfLen;		}	    }	    SafeStrCat(pPacketHeaderBuf, ">", packetHeaderBufSize);	    pktHdrLen ++;	}    }/// if(!bStateIsGetPacketSeekBackReadPending) //XXXEH-do this for ALL states?    {	//Now, change the zeros in bytes 1 through	// NUM_DIGITS_IN_START_TAG_OF_PKT_HDR of pPacketHeaderBuf to the	// actual numbers in pktHdrLen:	sprintf(pTmp, "%04d", pktHdrLen); /* Flawfinder: ignore */	for(ULONG32 ii=0; ii<NUM_DIGITS_IN_START_TAG_OF_PKT_HDR; ii++)	{	    pPacketHeaderBuf[ii+1] = pTmp[ii];	}	//fill with NUM_DIGITS_IN_START_TAG_OF_PKT_HDR digits of pktHdrLen:	sprintf(pTmp, "</%04d>", pktHdrLen); /* Flawfinder: ignore */	SafeStrCat(pPacketHeaderBuf, pTmp, packetHeaderBufSize);	HX_ASSERT(strlen(pPacketHeaderBuf) == pktHdrLen);    }    delete [] pTmp;    return pktHdrLen;} //end of OutputPacketHeaderString method.///////////////////////////////////////////////////////////////////////////////class TextLineList methods:///////////////////////////////////////////////////////////////////////////////LISTPOSITION TextLineList::GetEndPosition(){    if (GetCount() > 0)    {	return (TextLine*)GetTailPosition();    }    else    {	return NULL;    }}///////////////////////////////////////////////////////////////////////////////LISTPOSITION TextLineList::GetStartPosition(){    if (GetCount() > 0)    {	return (TextLine*)GetHeadPosition();    }    else    {	return NULL;    }}///////////////////////////////////////////////////////////////////////////////TextLine* TextLineList::end() //returns NULL if list is empty.{    if (GetCount() > 0)    {	return (TextLine*)GetTail();    }    else    {	return NULL;    }}///////////////////////////////////////////////////////////////////////////////TextLine* TextLineList::start() //returns NULL if list is empty.{    if (GetCount() > 0)    {	return (TextLine*)GetHead();    }    else    {	return NULL;    }}///////////////////////////////////////////////////////////////////////////////BOOL TextLineList::insertAtEndOfList(TextLine* tc){    HX_ASSERT_VALID_PTR(tc);    if(NULL == tc)    {	return FALSE;    }    else    {	LISTPOSITION lpos = AddTail(tc);	return (lpos!=NULL);    }}///////////////////////////////////////////////////////////////////////////////ULONG32 TextLineList::flush() //Returns number of nodes deleted.{    ULONG32 numDeleted = 0L;    while(nodeCount())    {	TextLine* pTLHead = (TextLine*)CHXSimpleList::RemoveHead();	HX_ASSERT_VALID_PTR(pTLHead);	if(pTLHead) 	{	    delete pTLHead;	    pTLHead = NULL;	    numDeleted++;	}    }    return numDeleted;}/////////////////////////////////////////////////////////////////////////////////  If <CLEAR> tag is sent, effective at time t, then this function is//  called to change all in this list whose m_ulEndTimeOfData is > t;//  Returns the number of nodes in the list whose endTimes were reduced to t://ULONG32 TextLineList::MarkAllForClear(ULONG32 ulTimeOfClear,				      BOOL bIsLiveSource){    ULONG32 listSize = size();    ULONG32 numTLsWhoseEndTimesWereReduced = 0L;    if(listSize)    {	LISTPOSITION pos = GetStartPosition();	while(pos)	{	    TextLine* pTL = (TextLine*)GetAt(pos);	    HX_ASSERT_VALID_PTR(pTL);	    if(pTL)	    {		if(pTL->MarkForClear(ulTimeOfClear, bIsLiveSource))		{		    numTLsWhoseEndTimesWereReduced++;		}	    }	    GetNext(pos);	} //end "while(pos)".    } //end "if(listSize)".	    return numTLsWhoseEndTimesWereReduced;}///////////////////////////////////////////////////////////////////////////////// Added this so seek() can calculate what to send;//// returns 0 if there are no active TextLines at ulTime or if error://ULONG32 TextLineList::findBoundingStartAndEndBytesOfActiveTextLines(	ULONG32 ulTime, ULONG32* p_ulPktStartByte, ULONG32* p_ulPktEndByte,	TextLine** ppFirstTextLineInPkt){    if(!p_ulPktStartByte  ||  !p_ulPktEndByte)    {	return 0L;    }    *p_ulPktStartByte = 0L;    *p_ulPktEndByte = 0L;    *ppFirstTextLineInPkt = NULL;    BOOL bNoPktStartByteFoundYet = TRUE;    ULONG32 ulNextPktStartByte = 0L;    ULONG32 ulNextPktEndByte = 0L;    ULONG32 listSize = size();    ULONG32 numTLsActiveAtThisTime = 0L;    ULONG32 numTLsActiveAtLaterTime = 0L;    ULONG32 ul_totalLaterBytes = 0L;    TextLine* pFirstTextLineInNextPkt = NULL;    if(listSize)    {	LISTPOSITION pos = GetStartPosition();	while(pos)	{	    TextLine* pTL = (TextLine*)GetAt(pos);	    HX_ASSERT_VALID_PTR(pTL);	    if(pTL)	    {		if(pTL->getStartTime() <= ulTime  &&			pTL->getEndTime() >= ulTime)		{		    if(pTL->getStartByteInFile() < *p_ulPktStartByte  ||			((0L == *p_ulPktStartByte && bNoPktStartByteFoundYet)			&& !numTLsActiveAtThisTime))		    {			*p_ulPktStartByte = pTL->getStartByteInFile();			bNoPktStartByteFoundYet = FALSE;			*ppFirstTextLineInPkt = pTL;		    }		    if(pTL->getEndByteInFile() > *p_ulPktEndByte)		    {			*p_ulPktEndByte = pTL->getEndByteInFile();		    }		    		    		    numTLsActiveAtThisTime++;		}		//Keep track of T.L. that is the first one with a start time		// that is just after ulTime in case none (or very few bytes)		// are found above:		if(pTL->getEndTime() >= ulTime  &&			((1+ulNextPktEndByte-ulNextPktStartByte) <			IDEAL_SIZE_OF_NONHEADER_PART_OF_PKT)    )		{		    if(pTL->getStartByteInFile() < ulNextPktStartByte  ||			    0L == ulNextPktStartByte)		    {			ulNextPktStartByte = pTL->getStartByteInFile();			pFirstTextLineInNextPkt = pTL;		    }		    if(pTL->getEndByteInFile() > ulNextPktEndByte)		    {			ulNextPktEndByte = pTL->getEndByteInFile();		    }		    		    		    numTLsActiveAtLaterTime++;		}	    }	    GetNext(pos);	} //end "while(pos)".    } //end "if(listSize)".        if(!numTLsActiveAtThisTime) //none were found, so send later ones:    {	if(!numTLsActiveAtLaterTime)	{	    return 0L;	}	*p_ulPktStartByte = ulNextPktStartByte;	bNoPktStartByteFoundYet = FALSE;	*p_ulPktEndByte = ulNextPktEndByte;	*ppFirstTextLineInPkt = pFirstTextLineInNextPkt;    }    else if(numTLsActiveAtLaterTime  &&	    ((1 + *p_ulPktEndByte - *p_ulPktStartByte) <	    MIN_SIZE_OF_NONHEADER_PART_OF_PKT) )    {	//include some more text to round out the pkt to a better size:	*p_ulPktEndByte = ulNextPktEndByte;    }    //Note: p_ulPktStartByte can be zero if tagless "plaintext"-type file:    HX_ASSERT(!bNoPktStartByteFoundYet  &&  *p_ulPktEndByte);    //This if should never be TRUE, but...    if(bNoPktStartByteFoundYet  &&  !*p_ulPktEndByte)    {	return 0L;     }    return (numTLsActiveAtThisTime>0L?	    numTLsActiveAtThisTime:numTLsActiveAtLaterTime);}/////////////////////////////////////////////////////////////////////////////////Added this so GetPacket() can calculate how many// bytes need to be read; returns 0 if there are no already-read // TextLines at startByte or later, or if other error:ULONG32 TextLineList::makeReasonableSizedPacketFromTextLinesAtStartByte(	ULONG32 ulStartByte, ULONG32* p_ulPktEndByte,	BOOL* p_bCurPacketHasREQUIREDContents,	TextLine** ppFirstTextLineInPkt){    if(!p_ulPktEndByte  ||  !p_bCurPacketHasREQUIREDContents)    {	return 0L;    }    *p_ulPktEndByte = 0L;    *ppFirstTextLineInPkt = NULL;    ULONG32 ulNextPktEndByte = 0L;    ULONG32 listSize = size();    ULONG32 numTLsInThisPacket = 0L;    if(listSize)    {	LISTPOSITION pos = GetStartPosition();	while(pos)	{	    TextLine* pTL = (TextLine*)GetAt(pos);	    HX_ASSERT_VALID_PTR(pTL);	    if(pTL)	    {		if(pTL->getStartByteInFile() >= ulStartByte)		{		    if(!(*ppFirstTextLineInPkt))		    {			*ppFirstTextLineInPkt = pTL;		    }		    if(pTL->getEndByteInFile() > *p_ulPktEndByte)		    {			*p_ulPktEndByte = pTL->getEndByteInFile();			numTLsInThisPacket++;			if(pTL->isRequired())			{			    *p_bCurPacketHasREQUIREDContents = TRUE;			}		    }		    		    if(*p_ulPktEndByte > ulStartByte  &&			    *p_ulPktEndByte - ulStartByte >			    IDEAL_SIZE_OF_NONHEADER_PART_OF_PKT)		    {			break;		    }		}	    }	    GetNext(pos);	} //end "while(pos)".    } //end "if(listSize)".        return numTLsInThisPacket;}

⌨️ 快捷键说明

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