📄 basgroup.cpp
字号:
/* ***** BEGIN LICENSE BLOCK *****
* Version: RCSL 1.0/RPSL 1.0
*
* Portions Copyright (c) 1995-2002 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
* Version 1.0 (the "RPSL") available at
* http://www.helixcommunity.org/content/rpsl unless you have licensed
* the file under the RealNetworks Community Source License Version 1.0
* (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.
*
* 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_FILE
static const char HX_THIS_FILE[] = __FILE__;
#endif
HXBasicTrack::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
*/
STDMETHODIMP
HXBasicTrack::Begin(void)
{
return HXR_NOTIMPL;
}
/************************************************************************
* Method:
* IHXBasicTrack::Pause()
* Purpose:
* pause the track
*/
STDMETHODIMP
HXBasicTrack::Pause(void)
{
return HXR_NOTIMPL;
}
/************************************************************************
* Method:
* IHXBasicTrack::Seek()
* Purpose:
* seek the track
*/
STDMETHODIMP
HXBasicTrack::Seek(UINT32 ulSeekTime)
{
return HXR_NOTIMPL;
}
/************************************************************************
* Method:
* IHXBasicTrack::Stop()
* Purpose:
* stop the track
*/
STDMETHODIMP
HXBasicTrack::Stop(void)
{
return HXR_NOTIMPL;
}
/************************************************************************
* Method:
* IHXBasicTrack::AddRepeat()
* Purpose:
* add repeat tracks
*/
STDMETHODIMP
HXBasicTrack::AddRepeat(IHXValues* pTrack)
{
return HXR_NOTIMPL;
}
/************************************************************************
* Method:
* IHXBasicTrack::GetTrackProperties()
* Purpose:
* get track properties
*/
STDMETHODIMP
HXBasicTrack::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.
*/
STDMETHODIMP
HXBasicTrack::GetSource(REF(IHXStreamSource*) pStreamSource)
{
return HXR_NOTIMPL;
}
/************************************************************************
* Method:
* IHXBasicTrack::SetSoundLevel()
* Purpose:
* Set Audio Level
*/
STDMETHODIMP
HXBasicTrack::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
*/
STDMETHODIMP
HXBasicTrack::BeginSoundLevelAnimation(UINT16 uSoundLevelBeginWith)
{
return HXR_NOTIMPL;
}
/************************************************************************
* Method:
* IHXBasicTrack::EndSoundLevelAnimation()
* Purpose:
* notify the stop of soundlevel animation
*/
STDMETHODIMP
HXBasicTrack::EndSoundLevelAnimation(UINT16 uSoundLevelEndWith)
{
return HXR_NOTIMPL;
}
HX_RESULT
HXBasicTrack::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;
}
void
HXBasicTrack::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.
*/
STDMETHODIMP
HXBasicGroup::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.
*/
STDMETHODIMP
HXBasicGroup::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_RESULT
HXBasicGroup::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
*/
STDMETHODIMP
HXBasicGroup::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_RESULT
HXBasicGroup::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
*/
STDMETHODIMP
HXBasicGroup::RemoveTrack(UINT16 /*IN*/ uTrackIndex)
{
return HXR_NOTIMPL;
}
HX_RESULT
HXBasicGroup::CurrentGroupSet(void)
{
return HXR_OK;
}
void
HXBasicGroup::StartTrackNotification(void)
{
m_bToNotifyTrack = TRUE;
}
void
HXBasicGroup::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))
{
AddRef();
*ppvObj = (IHXGroupManager*)this;
return HXR_OK;
}
else if (IsEqualIID(riid, IID_IHXPreCacheGroupMgr))
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -