📄 basgroup.cpp
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: basgroup.cpp,v 1.3.4.1 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 "basgroup.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__;#endifHXBasicTrack::HXBasicTrack(HXBasicGroup* pHXGroup) : m_lRefCount(0) , m_uTrackIndex(0) , m_pHXGroup(NULL) , m_pValues(NULL) , m_bActive(TRUE){ m_pHXGroup = pHXGroup;}HXBasicTrack::~HXBasicTrack(void){ Close();}/* * IUnknown methods */STDMETHODIMP HXBasicTrack::QueryInterface(REFIID riid, void** ppvObj){ if (IsEqualIID(riid, IID_IHXTrack)) { AddRef(); *ppvObj = (IHXGroup*)this; return HXR_OK; } else if (IsEqualIID(riid, IID_IUnknown)) { AddRef(); *ppvObj = this; return HXR_OK; } *ppvObj = NULL; return HXR_NOINTERFACE;}STDMETHODIMP_(ULONG32) HXBasicTrack::AddRef(){ return InterlockedIncrement(&m_lRefCount);}STDMETHODIMP_(ULONG32) HXBasicTrack::Release(){ if (InterlockedDecrement(&m_lRefCount) > 0) { return m_lRefCount; } delete this; return 0;}/* * IHXTrack methods *//************************************************************************* Method:* IHXBasicTrack::Begin()* Purpose:* start the track*/STDMETHODIMPHXBasicTrack::Begin(void){ return HXR_NOTIMPL;}/************************************************************************* Method:* IHXBasicTrack::Pause()* Purpose:* pause the track*/STDMETHODIMPHXBasicTrack::Pause(void){ return HXR_NOTIMPL;}/************************************************************************* Method:* IHXBasicTrack::Seek()* Purpose:* seek the track*/STDMETHODIMPHXBasicTrack::Seek(UINT32 ulSeekTime){ return HXR_NOTIMPL;}/************************************************************************* Method:* IHXBasicTrack::Stop()* Purpose:* stop the track*/STDMETHODIMPHXBasicTrack::Stop(void){ return HXR_NOTIMPL;}/************************************************************************* Method:* IHXBasicTrack::AddRepeat()* Purpose:* add repeat tracks*/STDMETHODIMPHXBasicTrack::AddRepeat(IHXValues* pTrack){ return HXR_NOTIMPL;}/************************************************************************* Method:* IHXBasicTrack::GetTrackProperties()* Purpose:* get track properties*/STDMETHODIMPHXBasicTrack::GetTrackProperties(REF(IHXValues*) pValues, REF(IHXValues*) pValuesInRequest){ pValues = m_pValues; if (pValues) { pValues->AddRef(); } pValuesInRequest = m_pValuesInRequest; if (pValuesInRequest) { pValuesInRequest->AddRef(); } return HXR_OK;}/************************************************************************ * Method: * IHXBasicTrack::GetSource * Purpose: * Returns the Nth source instance supported by this player. */STDMETHODIMPHXBasicTrack::GetSource(REF(IHXStreamSource*) pStreamSource){ return HXR_NOTIMPL;}/************************************************************************* Method:* IHXBasicTrack::SetSoundLevel()* Purpose:* Set Audio Level*/STDMETHODIMPHXBasicTrack::SetSoundLevel(UINT16 uSoundLevel){ return HXR_NOTIMPL;}/************************************************************************* Method:* IHXBasicTrack::GetSoundLevel()* Purpose:* Get Audio Level*/STDMETHODIMP_(UINT16)HXBasicTrack::GetSoundLevel(){ return 0;}/************************************************************************* Method:* IHXBasicTrack::BeginSoundLevelAnimation()* Purpose:* notify the start of soundlevel animation*/STDMETHODIMPHXBasicTrack::BeginSoundLevelAnimation(UINT16 uSoundLevelBeginWith){ return HXR_NOTIMPL;}/************************************************************************* Method:* IHXBasicTrack::EndSoundLevelAnimation()* Purpose:* notify the stop of soundlevel animation*/STDMETHODIMPHXBasicTrack::EndSoundLevelAnimation(UINT16 uSoundLevelEndWith){ return HXR_NOTIMPL;}HX_RESULTHXBasicTrack::SetTrackProperties(IHXValues* pValues, IHXValues* pValuesInRequest){ m_pValues = pValues; if (m_pValues) { m_pValues->AddRef(); } m_pValuesInRequest = pValuesInRequest; if (m_pValuesInRequest) { m_pValuesInRequest->AddRef(); } return HXR_OK;}voidHXBasicTrack::Close(void){ HX_RELEASE(m_pValues); HX_RELEASE(m_pValuesInRequest);}HXBasicGroup::HXBasicGroup(HXBasicGroupManager* pManager) : m_lRefCount(0) , m_pGroupManager(NULL) , m_pPlayer(NULL) , m_bToNotifyTrack(FALSE) , m_pTrackMap(NULL) , m_uGroupIndex(0) , m_uTrackCount(0){ m_pTrackMap = new CHXMapLongToObj; m_pGroupManager = pManager; m_pGroupManager->AddRef(); m_pPlayer = m_pGroupManager->m_pPlayer;}HXBasicGroup::~HXBasicGroup(void){ Close(); HX_RELEASE(m_pGroupManager);}/* * IUnknown methods */STDMETHODIMP HXBasicGroup::QueryInterface(REFIID riid, void** ppvObj){ if (IsEqualIID(riid, IID_IHXGroup)) { AddRef(); *ppvObj = (IHXGroup*)this; return HXR_OK; } else if (IsEqualIID(riid, IID_IUnknown)) { AddRef(); *ppvObj = this; return HXR_OK; } *ppvObj = NULL; return HXR_NOINTERFACE;}STDMETHODIMP_(ULONG32) HXBasicGroup::AddRef(){ return InterlockedIncrement(&m_lRefCount);}STDMETHODIMP_(ULONG32) HXBasicGroup::Release(){ if (InterlockedDecrement(&m_lRefCount) > 0) { return m_lRefCount; } delete this; return 0;}/* * IHXGroup methods *//************************************************************************* Method:* IHXBasicGroup::SetGroupProperties* Purpose:* Set any group specific information like Title Author * Copyright etc. */STDMETHODIMPHXBasicGroup::SetGroupProperties(IHXValues* /*IN*/ pProperties){ return HXR_NOTIMPL;}/************************************************************************* Method:* IHXBasicGroup::GetGroupProperties* Purpose:* Get any group specific information. May return NULL.*/STDMETHODIMP_(IHXValues*)HXBasicGroup::GetGroupProperties(void){ return NULL;}/************************************************************************* Method:* IHXBasicGroup::GetTrackCount* Purpose:* Get the number of tracks within this group.*/STDMETHODIMP_(UINT16)HXBasicGroup::GetTrackCount(void){ return m_uTrackCount;}/************************************************************************* Method:* IHXBasicGroup::GetTrack* Purpose:* Call this to hook audio data after all audio streams in this* have been mixed.*/STDMETHODIMPHXBasicGroup::GetTrack(UINT16 /*IN*/ uTrackIndex, REF(IHXValues*) /*OUT*/ pTrack){ HX_RESULT rc = HXR_OK; IHXValues* pTrackPropInRequest = NULL; rc = DoGetTrack(uTrackIndex, pTrack, pTrackPropInRequest); HX_RELEASE(pTrackPropInRequest); return rc;}HX_RESULTHXBasicGroup::DoGetTrack(UINT16 /*IN*/ uTrackIndex, REF(IHXValues*) /*OUT*/ pTrack, REF(IHXValues*) /*OUT*/ pTrackPropInRequest){ HX_RESULT rc = HXR_OK; HXBasicTrack* pHXTrack = NULL; if (!m_pTrackMap->Lookup(uTrackIndex, (void*&)pHXTrack)) { rc = HXR_UNEXPECTED; goto cleanup; } if (!pHXTrack->m_bActive) { rc = HXR_IGNORE; goto cleanup; } rc = pHXTrack->GetTrackProperties(pTrack, pTrackPropInRequest);cleanup: return rc;}/************************************************************************* Method:* IHXBasicGroup::AddTrack* Purpose:* SMIL renderer (IHXGroupSupplier) may want to add tracks even * after adding IHXGroup to the IHXGroupManager*/STDMETHODIMPHXBasicGroup::AddTrack(IHXValues* /*IN*/ pTrack){ HX_RESULT rc = HXR_OK; HXBasicTrack* pHXTrack = new HXBasicTrack(this); pHXTrack->AddRef(); rc = DoAddTrack(pTrack, NULL, pHXTrack); if (HXR_OK != rc) { HX_RELEASE(pHXTrack); } return rc;}HX_RESULTHXBasicGroup::DoAddTrack(IHXValues* /*IN*/ pTrack, IHXValues* /*IN*/ pTrackPropInRequest, HXBasicTrack* /*IN*/ pHXTrack){ HX_RESULT theErr = HXR_OK; if (!pTrack || !pHXTrack) { return HXR_UNEXPECTED; } pHXTrack->SetTrackProperties(pTrack, pTrackPropInRequest); pHXTrack->m_uTrackIndex = m_uTrackCount; (*m_pTrackMap)[m_uTrackCount] = pHXTrack; m_uTrackCount++; if (m_bToNotifyTrack) { theErr = m_pGroupManager->TrackAdded(m_uGroupIndex, pHXTrack->m_uTrackIndex, pTrack); HX_ASSERT(theErr == HXR_OK); } return theErr;}/************************************************************************* Method:* IHXBasicGroup::RemoveTrack* Purpose:* Remove an already added track*/STDMETHODIMPHXBasicGroup::RemoveTrack(UINT16 /*IN*/ uTrackIndex){ return HXR_NOTIMPL;}HX_RESULTHXBasicGroup::CurrentGroupSet(void){ return HXR_OK;}void HXBasicGroup::StartTrackNotification(void){ m_bToNotifyTrack = TRUE;}voidHXBasicGroup::Close(void){ CHXMapLongToObj::Iterator i; m_uTrackCount = 0; if (m_pTrackMap) { i = m_pTrackMap->Begin(); for(; i != m_pTrackMap->End(); ++i) { HXBasicTrack* pHXTrack = (HXBasicTrack*)(*i); pHXTrack->Close(); HX_RELEASE(pHXTrack); } HX_DELETE(m_pTrackMap); }}/*HXGroupManager*/HXBasicGroupManager::HXBasicGroupManager(HXPlayer* pPlayer) : m_lRefCount(0) , m_pGroupMap(NULL) , m_pSinkList(NULL) , m_uGroupCount(0) , m_uCurrentGroup(0) , m_uNextGroup(0) , m_bDefaultNextGroup(TRUE) , m_pPlayer(pPlayer) , m_bCurrentGroupInitialized(FALSE) , m_pPresentationProperties(NULL){ m_pGroupMap = new CHXMapLongToObj; m_pSinkList = new CHXSimpleList; if (m_pPlayer) m_pPlayer->AddRef();}HXBasicGroupManager::~HXBasicGroupManager(void){ Close();}/* * IUnknown methods */STDMETHODIMP HXBasicGroupManager::QueryInterface(REFIID riid, void** ppvObj){ if (IsEqualIID(riid, IID_IHXGroupManager))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -