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

📄 advgroup.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: advgroup.cpp,v 1.3.8.2 2004/07/09 02:05:57 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 "hxcom.h"#include "hxresult.h"#include "hxausvc.h"#include "ihxpckts.h"#include "hxmap.h"#include "smiltype.h"#include "hxgroup.h"#include "advgroup.h"#include "hxwintyp.h"#include "hxengin.h"#include "hxcore.h"#include "hxplay.h"#include "hxbsrc.h"#include "hxsrc.h"#include "srcinfo.h"#include "hxslist.h"#include "hxtac.h"#include "hxstrutl.h"#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILEstatic const char HX_THIS_FILE[] = __FILE__;#endifHXAdvancedTrack::HXAdvancedTrack(HXAdvancedGroup* pHXGroup)                :HXBasicTrack(pHXGroup)                ,m_pRepeatList(NULL)                ,m_uSoundLevel(100)                ,m_bInSoundLevelAnimation(FALSE)                ,m_ulSoundLevelAnimationTime(0)                ,m_ulGranularity(0){}HXAdvancedTrack::~HXAdvancedTrack(void){    Close();}#if defined(HELIX_FEATURE_AUDIOHOOK)/* *  IUnknown methods */STDMETHODIMP HXAdvancedTrack::QueryInterface(REFIID riid, void** ppvObj){    if (HXR_OK == HXBasicTrack::QueryInterface(riid, ppvObj))    {	return HXR_OK;    }    else if (IsEqualIID(riid, IID_IHXAudioHook))    {        AddRef();        *ppvObj = (IHXAudioHook*)this;        return HXR_OK;    }    *ppvObj = NULL;    return HXR_NOINTERFACE;}STDMETHODIMP_(ULONG32) HXAdvancedTrack::AddRef(){    return InterlockedIncrement(&m_lRefCount);}STDMETHODIMP_(ULONG32) HXAdvancedTrack::Release(){    if (InterlockedDecrement(&m_lRefCount) > 0)    {        return m_lRefCount;    }    delete this;    return 0;}/* *  IHXAudioHook methods *//************************************************************************ *  Method: *      IHXAudioHook::OnInit *  Purpose: *      Audio Services calls OnInit() with the audio data format of the *	    audio data that will be provided in the OnBuffer() method. */STDMETHODIMPHXAdvancedTrack::OnInit(HXAudioFormat* /*IN*/ pFormat){    CHXAudioPlayer* pAudioPlayer = NULL;        pAudioPlayer = m_pHXGroup->m_pPlayer->GetAudioPlayer();    if (pAudioPlayer)    {	m_ulSoundLevelAnimationTime = pAudioPlayer->GetCurrentPlayBackTime();	m_ulGranularity = pAudioPlayer->GetGranularity();    }    return HXR_OK;}/************************************************************************ *  Method: *      IHXAudioHook::OnBuffer *  Purpose: *      Audio Services calls OnBuffer() with audio data packets. The *	    renderer should not modify the data in the IHXBuffer part of *	    pAudioInData.  If the renderer wants to write a modified *	    version of the data back to Audio Services, then it should  *	    create its own IHXBuffer, modify the data and then associate  *	    this buffer with the pAudioOutData->pData member. */STDMETHODIMPHXAdvancedTrack::OnBuffer(HXAudioData*	/*IN*/   pAudioInData,		   HXAudioData*	/*OUT*/  pAudioOutData){    HX_RESULT	rc = HXR_OK;    if (!m_pHXGroup)    {	rc = HXR_UNEXPECTED;	goto cleanup;    }    m_ulSoundLevelAnimationTime += m_ulGranularity;    rc = ((HXAdvancedGroup*)m_pHXGroup)->OnSoundLevelAnimation(m_uTrackIndex, m_uSoundLevel, m_ulSoundLevelAnimationTime);cleanup:    return rc;}#endif /* HELIX_FEATURE_AUDIOHOOK *//* *  IHXTrack methods *//*************************************************************************  Method:*	    IHXTrack::Begin()*  Purpose:*	    start the track*/STDMETHODIMPHXAdvancedTrack::Begin(void){    HX_RESULT	rc = HXR_OK;    if (!m_pHXGroup)    {	rc = HXR_UNEXPECTED;	goto cleanup;    }    rc = ((HXAdvancedGroup*)m_pHXGroup)->BeginTrack(m_uTrackIndex, m_pValues);cleanup:    return rc;}/*************************************************************************  Method:*	    IHXTrack::Pause()*  Purpose:*	    pause the track*/STDMETHODIMPHXAdvancedTrack::Pause(void){    HX_RESULT	rc = HXR_OK;    if (!m_pHXGroup)    {	rc = HXR_UNEXPECTED;	goto cleanup;    }    rc = ((HXAdvancedGroup*)m_pHXGroup)->PauseTrack(m_uTrackIndex, m_pValues);cleanup:    return rc;}/*************************************************************************  Method:*	    IHXTrack::Seek()*  Purpose:*	    seek the track*/STDMETHODIMPHXAdvancedTrack::Seek(UINT32 ulSeekTime){    HX_RESULT	rc = HXR_OK;    if (!m_pHXGroup)    {	rc = HXR_UNEXPECTED;	goto cleanup;    }    rc = ((HXAdvancedGroup*)m_pHXGroup)->SeekTrack(m_uTrackIndex, m_pValues, ulSeekTime);cleanup:    return rc;}/*************************************************************************  Method:*	    IHXTrack::Stop()*  Purpose:*	    stop the track*/STDMETHODIMPHXAdvancedTrack::Stop(void){    HX_RESULT	rc = HXR_OK;    if (!m_pHXGroup)    {	rc = HXR_UNEXPECTED;	goto cleanup;    }    rc = ((HXAdvancedGroup*)m_pHXGroup)->StopTrack(m_uTrackIndex, m_pValues);cleanup:    return rc;}/*************************************************************************  Method:*	    IHXTrack::AddRepeat()*  Purpose:*	    add repeat tracks*/STDMETHODIMPHXAdvancedTrack::AddRepeat(IHXValues* pTrack){    if (!m_pRepeatList)    {	m_pRepeatList = new CHXSimpleList();    }    m_pRepeatList->AddTail(pTrack);    pTrack->AddRef();    ((HXAdvancedGroup*)m_pHXGroup)->RepeatTrackAdded(m_uTrackIndex, pTrack);    return HXR_OK;}/************************************************************************ *	Method: *	    IHXTrack::GetSource *	Purpose: *	    Returns the Nth source instance supported by this player. */STDMETHODIMPHXAdvancedTrack::GetSource(REF(IHXStreamSource*) pStreamSource){    HX_RESULT	rc = HXR_OK;    if (!m_pHXGroup)    {	rc = HXR_UNEXPECTED;	goto cleanup;    }    rc = ((HXAdvancedGroup*)m_pHXGroup)->GetSource(m_uTrackIndex, pStreamSource);cleanup:    return rc;}/*************************************************************************  Method:*	    IHXTrack::SetSoundLevel()*  Purpose:*	    Set Audio Level*/STDMETHODIMPHXAdvancedTrack::SetSoundLevel(UINT16 uSoundLevel){    HX_RESULT	rc = HXR_OK;    if (!m_pHXGroup)    {	rc = HXR_UNEXPECTED;	goto cleanup;    }    if (m_uSoundLevel != uSoundLevel)    {	m_uSoundLevel = uSoundLevel;	rc = ((HXAdvancedGroup*)m_pHXGroup)->SetSoundLevel(m_uTrackIndex, m_uSoundLevel, !m_bInSoundLevelAnimation);    }cleanup:    return rc;}/*************************************************************************  Method:*	    IHXTrack::GetSoundLevel()*  Purpose:*	    Get Audio Level*/STDMETHODIMP_(UINT16)HXAdvancedTrack::GetSoundLevel(){    return m_uSoundLevel;}/*************************************************************************  Method:*	    IHXTrack::BeginSoundLevelAnimation()*  Purpose:*	    notify the start of soundlevel animation*/STDMETHODIMPHXAdvancedTrack::BeginSoundLevelAnimation(UINT16 uSoundLevelBeginWith){    HX_RESULT	rc = HXR_OK;    if (!m_pHXGroup)    {	rc = HXR_UNEXPECTED;	goto cleanup;    }    m_uSoundLevel = uSoundLevelBeginWith;    m_bInSoundLevelAnimation = TRUE;    rc = ((HXAdvancedGroup*)m_pHXGroup)->BeginSoundLevelAnimation(m_uTrackIndex, m_uSoundLevel);    cleanup:    return rc;}/*************************************************************************  Method:*	    IHXTrack::EndSoundLevelAnimation()*  Purpose:*	    notify the stop of soundlevel animation*/STDMETHODIMPHXAdvancedTrack::EndSoundLevelAnimation(UINT16 uSoundLevelEndWith){    HX_RESULT	rc = HXR_OK;    if (!m_pHXGroup)    {	rc = HXR_UNEXPECTED;	goto cleanup;    }    m_uSoundLevel = uSoundLevelEndWith;    rc = ((HXAdvancedGroup*)m_pHXGroup)->EndSoundLevelAnimation(m_uTrackIndex, m_uSoundLevel);    m_bInSoundLevelAnimation = FALSE;cleanup:    return rc;}voidHXAdvancedTrack::Close(void){    if (m_bInSoundLevelAnimation)    {	EndSoundLevelAnimation(0);    }    if (m_pRepeatList)    {	CHXSimpleList::Iterator i = m_pRepeatList->Begin();	for (; i != m_pRepeatList->End(); ++i)	{	    IHXValues* pValues = (IHXValues*)*i;	    HX_RELEASE(pValues);	}	HX_DELETE(m_pRepeatList);    }    HXBasicTrack::Close();}HXAdvancedGroup::HXAdvancedGroup(HXAdvancedGroupManager* pManager)                :HXBasicGroup(pManager)                ,m_pGroupProperties(NULL)                ,m_bPrefetchSinkAdded(FALSE)                ,m_pPrefetchTrackMap(NULL)                ,m_pPersistentComponentPropertyMap(NULL)                ,m_uPrefetchTrackCount(0)                ,m_pTrackSinkList(NULL)                ,m_pPrefetchSinkList(NULL){}HXAdvancedGroup::~HXAdvancedGroup(void){    Close();}/* *  IUnknown methods */STDMETHODIMP HXAdvancedGroup::QueryInterface(REFIID riid, void** ppvObj){    if (HXR_OK == HXBasicGroup::QueryInterface(riid, ppvObj))    {	return HXR_OK;    }    else if (IsEqualIID(riid, IID_IHXGroup2))    {        AddRef();        *ppvObj = (IHXGroup2*)this;        return HXR_OK;    }#if defined(HELIX_FEATURE_PREFETCH)    else if (IsEqualIID(riid, IID_IHXPrefetch))    {        AddRef();        *ppvObj = (IHXPrefetch*)this;        return HXR_OK;    }    else if (IsEqualIID(riid, IID_IHXPrefetchSink))    {        AddRef();        *ppvObj = (IHXPrefetchSink*)this;        return HXR_OK;    }#endif /* HELIX_FEATURE_PREFETCH */    *ppvObj = NULL;    return HXR_NOINTERFACE;}STDMETHODIMP_(ULONG32) HXAdvancedGroup::AddRef(){    return InterlockedIncrement(&m_lRefCount);}STDMETHODIMP_(ULONG32) HXAdvancedGroup::Release(){    if (InterlockedDecrement(&m_lRefCount) > 0)    {        return m_lRefCount;    }    delete this;    return 0;}/* *  IHXGroup methods *//*************************************************************************  Method:*      IHXGroup::SetGroupProperties*  Purpose:*		Set any group specific information like Title Author *		Copyright etc. */STDMETHODIMPHXAdvancedGroup::SetGroupProperties(IHXValues*  /*IN*/ pProperties){    UINT32  ulDuration = 0;    if (m_pGroupProperties || !pProperties)    {	return HXR_UNEXPECTED;    }    m_pGroupProperties = pProperties;    m_pGroupProperties->AddRef();    // support adjust current group's duration on the fly    if (m_uGroupIndex == m_pGroupManager->m_uCurrentGroup)    {		if (HXR_OK == m_pGroupProperties->GetPropertyULONG32("duration", ulDuration))	{	    m_pPlayer->SetPresentationTime(ulDuration);	}    }    return HXR_OK;}/*************************************************************************  Method:*      IHXGroup::GetGroupProperties*  Purpose:*		Get any group specific information. May return NULL.*/STDMETHODIMP_(IHXValues*)HXAdvancedGroup::GetGroupProperties(void){    if (m_pGroupProperties)    {	m_pGroupProperties->AddRef();    }    return m_pGroupProperties;}/*************************************************************************  Method:*      IHXGroup2::SetPersistentComponentProperties*  Purpose:*		Set persistent component properties associated with this group*		One group may contain multiple persistent components*/STDMETHODIMP

⌨️ 快捷键说明

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