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

📄 smltime.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: smltime.cpp,v 1.2.12.1 2004/07/09 01:57:38 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 ***** */#include <stdlib.h>#include <stdio.h>#include <ctype.h>#include "hxtypes.h"#include "hxresult.h"#include "hxcom.h"#include "hxcomm.h"#include "ihxpckts.h"#include "hxfiles.h"#include "hxformt.h"#include "hxengin.h"#include "hxplugn.h"#include "hxpends.h"#include "hxasm.h"#include "hxprefs.h"#include "hxassert.h"#include "chxpckts.h"#include "nptime.h"#include "smpte.h"#include "debug.h"#include "hxstrutl.h"#include "hxstring.h"#include "cbqueue.h"#include "hxslist.h"#include "hxmap.h"#include "hxstack.h"#include "hxwintyp.h"#include "chxxtype.h"#include "hxxml.h"#include "hxxmlprs.h"#include "xmlreslt.h"#include "looseprs.h"#include "sm1elem.h"#include "sm1parse.h"#include "sm1time.h"/* * CSmil1TimelineElementManager methods */CSmil1TimelineElementManager::CSmil1TimelineElementManager():    m_pElementMap(NULL),    m_pNotifierMap(NULL){}CSmil1TimelineElementManager::~CSmil1TimelineElementManager(){    HX_DELETE(m_pElementMap);    if(m_pNotifierMap)    {	CHXMapStringToOb::Iterator i = m_pNotifierMap->Begin();	for(; i != m_pNotifierMap->End(); ++i)	{	    CHXSimpleList* pList = (CHXSimpleList*)(*i);	    delete pList;	}	HX_DELETE(m_pNotifierMap);    }}voidCSmil1TimelineElementManager::addTimelineElement(CSmil1TimelineElement* pElement){    if(!m_pElementMap)    {	m_pElementMap = new CHXMapStringToOb;    }    (*m_pElementMap)[pElement->m_pID] = pElement;}CSmil1TimelineElement*CSmil1TimelineElementManager::getTimelineElement(const char* pID){    CSmil1TimelineElement* pElement = NULL;    if(m_pElementMap)    {	m_pElementMap->Lookup(pID, (void*&)pElement);    }    return pElement;}voidCSmil1TimelineElementManager::addNotification(const char* pID,					     CSmil1TimelineElement* pElement){    if(!m_pNotifierMap)    {	m_pNotifierMap = new CHXMapStringToOb;    }    CHXSimpleList* pNotifyList = NULL;    if(!m_pNotifierMap->Lookup(pID, (void*&)pNotifyList))    {	pNotifyList = new CHXSimpleList;	(*m_pNotifierMap)[pID] = pNotifyList;    }    pNotifyList->AddTail(pElement);}voidCSmil1TimelineElementManager::notify(const char* pID){    CHXSimpleList* pNotifyList = NULL;    if(m_pNotifierMap)    {	if(m_pNotifierMap->Lookup(pID, (void*&)pNotifyList))	{	    CSmil1TimelineElement* pDependentElement = NULL;	    if(m_pElementMap->Lookup(pID, (void*&)pDependentElement))	    {		CHXSimpleList::Iterator i = pNotifyList->Begin();		for(; i != pNotifyList->End(); ++i)		{		    CSmil1TimelineElement* pElement = 			(CSmil1TimelineElement*)(*i);		    pElement->elementResolved(pDependentElement);		}	    }	}    }}voidCSmil1TimelineElementManager::resetTimeline(){    if(m_pElementMap)    {	CHXMapStringToOb::Iterator i = m_pElementMap->Begin();	for(; i != m_pElementMap->End(); ++i)	{	    CSmil1TimelineElement* pElement = 		(CSmil1TimelineElement*)(*i);	    pElement->reset();	}    }}	/* * CSmil1TimelineElement methods */CSmil1TimelineElement::CSmil1TimelineElement(CSmil1Element* pSourceElement,					   CSmil1Parser* pParser):    m_pSourceElement(pSourceElement),    m_pParser(pParser),    m_bDurationSet(FALSE),    m_bMaxDurationSet(FALSE),    m_bDelaySet(FALSE),    m_bDontResetDuration(FALSE),    m_bNonEventDelaySet(FALSE),    m_bDelayEvent(FALSE),    m_bDurationEvent(FALSE),    m_pParent(NULL),    m_pChildren(NULL),    m_pDependent(NULL){    m_pID = new char[pSourceElement->m_pNode->m_id.GetLength() + 1];    strcpy(m_pID, (const char*)m_pSourceElement->m_pNode->m_id); /* Flawfinder: ignore */    if (m_pParser && m_pParser->m_pTimelineElementManager)    {        m_pParser->m_pTimelineElementManager->addTimelineElement(this);        if(pSourceElement->m_nBeginEventSourceTag == SMILEventSourceBegin ||	    pSourceElement->m_nBeginEventSourceTag == SMILEventSourceEnd ||	    pSourceElement->m_nBeginEventSourceTag == SMILEventSourceClock)        {	    m_pParser->m_pTimelineElementManager->addNotification(pSourceElement->m_BeginEventSourceID,	        this);	    m_bDelayEvent = TRUE;        }        if(pSourceElement->m_nEndEventSourceTag == SMILEventSourceBegin ||	    pSourceElement->m_nEndEventSourceTag == SMILEventSourceEnd ||	    pSourceElement->m_nEndEventSourceTag == SMILEventSourceClock)        {	    m_pParser->m_pTimelineElementManager->addNotification(pSourceElement->m_EndEventSourceID,	        this);	    m_bDurationEvent = TRUE;        }        if(pSourceElement->m_nEndsyncEventSourceTag == SMILEventSourceID)        {	    m_pParser->m_pTimelineElementManager->addNotification(pSourceElement->m_EndsyncEventSourceID,	        this);	    m_bDurationEvent = TRUE;        }    }}CSmil1TimelineElement::~CSmil1TimelineElement(){    delete m_pChildren;    delete[] m_pID;}voidCSmil1TimelineElement::reset(){    m_bDelaySet = FALSE;    m_bNonEventDelaySet = FALSE;    m_bDurationSet = FALSE;    m_bMaxDurationSet = FALSE;}void CSmil1TimelineElement::setDelay(UINT32 ulDelay){    if(!m_bDelaySet)    {	if(!m_bDelayEvent)	{	    if(m_pSourceElement->m_ulBeginOffset != (UINT32)-1)	    {		m_pSourceElement->m_ulDelay = ulDelay + 		    m_pSourceElement->m_ulBeginOffset;	    }	    else	    {		m_pSourceElement->m_ulDelay = ulDelay;	    }	    m_bDelaySet = TRUE;	    m_pParser->insertTimelineElement(m_pID, 		m_pSourceElement->m_ulDelay);	}    }    else    {	if(m_pSourceElement->m_ulBeginOffset != (UINT32)-1)	{	    m_pSourceElement->m_ulDelay = ulDelay + 		m_pSourceElement->m_ulBeginOffset;	}	else	{	    m_pSourceElement->m_ulDelay = ulDelay;	}    }}void CSmil1TimelineElement::setDuration(UINT32 ulDuration, BOOL bSetFromParent){    if(bSetFromParent)    {	m_pSourceElement->m_ulDuration = ulDuration;	m_bDurationSet = m_bDontResetDuration = TRUE;	m_pParser->resetTimelineElementDuration(m_pID,	    m_pSourceElement->m_ulDuration);    }    else    {	if(!m_bDurationSet)	{	    if(m_pSourceElement->m_ulBeginOffset != (UINT32)-1)	    {		m_pSourceElement->m_ulDuration = ulDuration + 		    m_pSourceElement->m_ulBeginOffset;	    }	    else	    {		m_pSourceElement->m_ulDuration = ulDuration;	    }	    m_bDurationSet = TRUE;	    if(m_pParent)	    {		m_pParent->addDuration(m_pSourceElement->m_ulDuration, 		    m_pSourceElement->m_ulDelay, m_pID);	    }	}	else if(!m_bDontResetDuration)	{	    m_pSourceElement->m_ulDuration = ulDuration;	    m_pParser->resetTimelineElementDuration(m_pID,		m_pSourceElement->m_ulDuration);	}    }    if(m_pDependent)    {	//Removed the addition of m_pSourceElement->m_ulDelay from the	// source's duration because the source's duration already includes	// its delay; we don't want to count the delay twice. Fixes PR 13983:	// /*XXXEH- UNFIXES 13983 by adding back in the ...m_ulDelay addition;	// the full fix for 13983 requires keeping track of begin=... delay	// (as opposed to seq-related delay) and then subtracting that begin	// delay from the m_ulDelay below:	adjustDependentDuration(m_pDependent);	m_pDependent->setDelay(m_pSourceElement->m_ulDelay + m_pSourceElement->m_ulDuration);    }    if (m_pParser && m_pParser->m_pTimelineElementManager)    {        m_pParser->m_pTimelineElementManager->notify(m_pID);    }}voidCSmil1TimelineElement::setMaxDuration(UINT32 ulMaxDuration){    m_bMaxDurationSet = TRUE;    m_pSourceElement->m_ulMaxDuration = ulMaxDuration;}void CSmil1TimelineElement::adjustDependentDuration(CSmil1TimelineElement* pDependent){    if (m_pParent)    {	m_pParent->adjustDependentDuration(m_pDependent);    }}voidCSmil1TimelineElement::elementResolved(CSmil1TimelineElement* pEventElement){    //First, let's see if we have a begin event to resolve:    if(m_pSourceElement->m_nBeginEventSourceTag == SMILEventSourceBegin)    {	if(pEventElement->m_bDelaySet)	{	    m_bDelaySet = TRUE;	    m_pSourceElement->m_ulDelay = 		pEventElement->m_pSourceElement->m_ulDelay;	    m_pParser->insertTimelineElement(m_pID, 		m_pSourceElement->m_ulDelay);	}    }    else if(m_pSourceElement->m_nBeginEventSourceTag == SMILEventSourceEnd)    {	if(pEventElement->m_bDurationSet)	{	    m_bDelaySet = TRUE;	    m_pSourceElement->m_ulDelay = 		pEventElement->m_pSourceElement->m_ulDuration +		    pEventElement->m_pSourceElement->m_ulDelay;	    m_pParser->insertTimelineElement(m_pID, 		m_pSourceElement->m_ulDelay);	}    }    else if(m_pSourceElement->m_nBeginEventSourceTag == SMILEventSourceClock)    {	//We want event *BEGIN* plus clock therefor check for m_bDelaySet not	// m_bDurationSet; after all, it's the eventElement's m_ulDelay	// that's used, below:	if(pEventElement->m_bDelaySet)	{	    m_bDelaySet = TRUE;	    m_pSourceElement->m_ulDelay = 		    pEventElement->m_pSourceElement->m_ulDelay;	    //[SMIL 1.0 compliance] helps fix 23025:	    // Rather than putting all the offset into m_ulDelay,	    // we want to put the event element's delay into our	    // delay and then put the event clock value into our	    // m_ulBeginOffset so that we can properly adjust	    // for any timing imposed on us later by our container	    // (parent):	    HX_ASSERT(m_pSourceElement->m_ulBeginOffset == UINT32(-1));	    m_pSourceElement->m_ulBeginOffset =		    m_pSourceElement->m_ulBeginEventClockValue;            m_pParser->insertTimelineElement(m_pID, 		m_pSourceElement->m_ulDelay +		//Allows SYMM 3/13/2000 test case 1.13 to work again		// while allowing 23025 to keep working:		m_pSourceElement->m_ulBeginOffset);	}    }    //[SMIL 1.0 compliance] Fixes PR 16629:    //Next, let's see if we have an end event to resolve:    if(m_pSourceElement->m_nEndEventSourceTag == SMILEventSourceBegin)    {	if(pEventElement->m_bDelaySet)	{	    m_bDurationSet = TRUE;	    m_pSourceElement->m_ulDuration = 		pEventElement->m_pSourceElement->m_ulDelay;	    m_pParser->insertTimelineElement(m_pID, 		m_pSourceElement->m_ulDelay);	}

⌨️ 快捷键说明

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