qttrack.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:20k
- /* ***** 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 ***** */
- /****************************************************************************
- * Defines
- */
- // #define _LOG_DATA_ACCESS
- #define QTTRACKCACHE_PAGE_SIZE 0x0000FFFF
- /****************************************************************************
- * Includes
- */
- #include "qtpktasm.h"
- #include "qtffplin.h"
- #include "qtpacketizerfct.h"
- #include "qttrack.h"
- #include "qtffrefcounter.h"
- /****************************************************************************
- * Class CQTTrack
- */
- /****************************************************************************
- * Constructor/Destructor
- */
- CQTTrack::CQTTrack(CQTAtom* pTrackAtom)
- : m_pTrackAtom((CQT_trak_Atom*) pTrackAtom)
- , m_pFileFormat(NULL)
- , m_pPacketAssembler(NULL)
- , m_pReadFileNameBuffer(NULL)
- , m_pReadFileName(NULL)
- , m_pFileSwitcher(NULL)
- , m_pPacketizer(NULL)
- , m_pClassFactory(NULL)
- , m_ulTrackID(0)
- , m_bTrackDone(FALSE)
- , m_PendingState(QTT_Offline)
- , m_uStreamNumber(0)
- , m_ulReadSize(0)
- , m_ulReadPageSize(0)
- , m_ulReadPageOffset(0)
- , m_uBytesPerCBlock(0)
- , m_uSamplesPerCBlock(0)
- , m_lRefCount(0)
- , m_ulLastSampleDescIdx(0)
- {
- CQT_tkhd_Atom* pTrackHeaderAtom = NULL;
- HX_ASSERT(pTrackAtom);
- pTrackAtom->AddRef();
-
- if (pTrackAtom)
- {
- pTrackHeaderAtom = (CQT_tkhd_Atom*)
- pTrackAtom->FindPresentChild(QT_tkhd);
- }
-
- if (pTrackHeaderAtom)
- {
- m_ulTrackID = pTrackHeaderAtom->Get_TrackID();
- }
- g_nRefCount_qtff++;
- }
- CQTTrack::~CQTTrack()
- {
- Close();
- g_nRefCount_qtff--;
- }
- /****************************************************************************
- * Main Interface
- */
- /****************************************************************************
- * Init
- */
- HX_RESULT CQTTrack::Init(CQTFileFormat *pFileFormat,
- CQTPacketAssembler *pPacketAssembler,
- CQTPacketizerFactory* pPacketizerFactory,
- const char* pProtocol)
- {
- CQTAtom* pAtom = NULL;
- BOOL bIsStreamTrack = FALSE;
- HX_RESULT retVal = HXR_OK;
- if (!m_pTrackAtom)
- {
- retVal = HXR_UNEXPECTED;
- }
- pAtom = m_pTrackAtom;
- m_uBytesPerCBlock = 0;
- m_uSamplesPerCBlock = 0;
- if (SUCCEEDED(retVal))
- {
- HX_ASSERT(pFileFormat);
- bIsStreamTrack = pFileFormat->m_TrackManager.IsStreamTrack(this);
-
- m_pFileFormat = pFileFormat;
- pFileFormat->AddRef();
- HX_ASSERT(pPacketAssembler);
- m_pPacketAssembler = pPacketAssembler;
- pPacketAssembler->AddRef();
- retVal = pFileFormat->QueryInterface(
- IID_IHXFileSwitcher,
- (void**) &m_pFileSwitcher);
- }
- if (SUCCEEDED(retVal))
- {
- retVal = pFileFormat->QueryInterface(IID_IHXCommonClassFactory,
- (void**) &m_pClassFactory);
- }
- if (SUCCEEDED(retVal))
- {
- CQT_tkhd_Atom* pTrackHeaderAtom = NULL;
- HX_ASSERT(m_pFileSwitcher);
- if (pAtom)
- {
- pTrackHeaderAtom = (CQT_tkhd_Atom*)
- pAtom->FindPresentChild(QT_tkhd);
- }
- if (pTrackHeaderAtom)
- {
- m_ulTrackID = pTrackHeaderAtom->Get_TrackID();
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- if (SUCCEEDED(retVal))
- {
- IHXCommonClassFactory* pClassFactory = NULL;
- CQTAtom* pChildAtom = NULL;
- if (pAtom)
- {
- pAtom = pAtom->FindPresentChild(QT_mdia);
- }
-
- if (pAtom)
- {
- pAtom = pAtom->FindPresentChild(QT_minf);
- }
-
- if (pAtom)
- {
- pChildAtom = pAtom->FindPresentChild(QT_dinf);
- }
-
- retVal = pFileFormat->QueryInterface(
- IID_IHXCommonClassFactory,
- (void**) &pClassFactory);
- if (SUCCEEDED(retVal))
- {
- retVal = m_DataRef.Init(pChildAtom, pClassFactory);
- }
- HX_RELEASE(pClassFactory);
- }
- if (retVal == HXR_OK)
- {
- if (pAtom)
- {
- pAtom = pAtom->FindPresentChild(QT_stbl);
- }
- retVal = m_SampleSize.Init(pAtom);
- }
- if (retVal == HXR_OK)
- {
- retVal = m_SampleToChunk.Init(pAtom);
- }
- if (retVal == HXR_OK)
- {
- retVal = m_TimeToSample.Init(pAtom);
- }
- if (retVal == HXR_OK)
- {
- retVal = m_ChunkToOffset.Init(pAtom);
- }
- if (retVal == HXR_OK)
- {
- retVal = m_SampleDesc.Init(pAtom);
- }
- if ((retVal == HXR_OK) && bIsStreamTrack)
- {
- retVal = m_TrackInfo.Init(pFileFormat->GetContext(),
- m_pTrackAtom,
- &m_SampleDesc,
- &pFileFormat->m_TrackManager,
- &pFileFormat->m_MovieInfo);
- }
- if ((retVal == HXR_OK) && bIsStreamTrack)
- {
- retVal = InitPacketizer(m_pPacketizer,
- pPacketizerFactory,
- pProtocol,
- &m_TrackInfo,
- &pFileFormat->m_MovieInfo,
- &pFileFormat->m_TrackManager,
- this,
- pFileFormat->GetContext());
- }
- if ((retVal == HXR_OK) && bIsStreamTrack)
- {
- CQTAtom* pChildAtom = NULL;
- pChildAtom = m_pTrackAtom->FindPresentChild(QT_edts);
- retVal = m_TrackEdit.Init(
- pChildAtom,
- pFileFormat->m_MovieInfo.GetMovieTimeScale(),
- m_TrackInfo.GetMediaTimeScale());
- }
- if ((retVal == HXR_OK) && bIsStreamTrack)
- {
- retVal = Seek(0);
- if (retVal == HXR_STREAM_DONE)
- {
- retVal = HXR_OK;
- }
- }
- HX_RELEASE(m_pTrackAtom);
- return retVal;
- }
- /****************************************************************************
- * Close
- */
- void CQTTrack::Close(void)
- {
- m_PendingState = QTT_Offline;
- HX_RELEASE(m_pTrackAtom);
- HX_RELEASE(m_pFileFormat);
- HX_RELEASE(m_pPacketAssembler);
- HX_RELEASE(m_pReadFileNameBuffer);
- HX_RELEASE(m_pFileSwitcher);
- HX_RELEASE(m_pPacketizer);
- HX_RELEASE(m_pClassFactory);
- }
- /****************************************************************************
- * Seek
- */
- HX_RESULT CQTTrack::Seek(ULONG32 ulTime)
- {
- if (m_pPacketizer)
- {
- m_pPacketizer->Reset();
- }
- m_bTrackDone = !m_TrackEdit.EstablishByTime(ulTime);
- if (!m_bTrackDone)
- {
- m_bTrackDone = !SequenceToTime(m_TrackEdit,
- m_TimeToSample,
- m_SampleToChunk,
- QTTRK_USE_KEY_FRAMES);
- }
- return m_bTrackDone ? HXR_STREAM_DONE : HXR_OK;
- }
- /****************************************************************************
- * GetPacket
- */
- HX_RESULT CQTTrack::GetPacket(UINT16 uStreamNum)
- {
- HX_RESULT retVal = HXR_STREAM_DONE;
- m_uStreamNumber = uStreamNum;
- if (m_pPacketizer)
- {
- IHXPacket* pPacket = NULL;
-
- retVal = m_pPacketizer->GetPacket(pPacket);
-
- if (retVal != HXR_INCOMPLETE)
- {
- m_pFileFormat->PacketReady(m_uStreamNumber,
- retVal,
- pPacket);
-
- HX_RELEASE(pPacket);
-
- return HXR_OK;
- }
- retVal = HXR_STREAM_DONE;
- }
- if (!m_bTrackDone)
- {
- m_PendingState = QTT_SampleRead;
- // Locate Sample
- if (m_ChunkToOffset.EstablishByChunk(
- m_SampleToChunk.GetChunkNum()) &&
- m_SampleSize.EstablishBySample(
- m_TimeToSample.GetSampleNumber(),
- m_SampleToChunk.GetChunkSampleNum()) &&
- m_SampleDesc.EstablishByIdx(
- m_SampleToChunk.GetSampleDescIdx()) &&
- m_DataRef.EstablishByIdx(
- m_SampleDesc.GetDataRefIdx()))
- {
- ULONG32 ulFileOffset = m_ChunkToOffset.GetChunkOffset() +
- m_SampleSize.GetChunkSampleOffset();
- #ifdef QTCONFIG_TRACK_CACHE
- if (m_DataRef.GetDataRefName() == NULL)
- {
- if (m_TrackCache.IsInPage(ulFileOffset, m_SampleSize.GetSampleSize()))
- {
- IHXBuffer* pBuffer;
- UINT32 ulPageOffset;
- m_TrackCache.Get(ulFileOffset,
- pBuffer,
- ulPageOffset);
- return ReturnPacket(HXR_OK,
- pBuffer,
- ulPageOffset,
- m_SampleSize.GetSampleSize());
- }
- }
- #endif // QTCONFIG_TRACK_CACHE
- retVal = LoadData(
- m_DataRef.GetDataRefName(),
- ulFileOffset,
- m_SampleSize.GetSampleSize());
- }
- else
- {
- retVal = ReturnPacket(retVal, NULL);
- }
- }
- else
- {
- retVal = ReturnPacket(retVal, NULL);
- }
- return retVal;
- }
- /****************************************************************************
- * ComputeTrackSize
- */
- HX_RESULT CQTTrack::ComputeTrackSize(ULONG32& ulTrackSizeOut)
- {
- ULONG32 ulTrackSize = 0;
- ULONG32 ulCurrentMediaTime = m_TrackEdit.GetMediaTime();
- HX_RESULT retVal = Seek(0);
- if (SUCCEEDED(retVal))
- {
- do
- {
- if (!m_SampleSize.EstablishBySample(
- m_TimeToSample.GetSampleNumber(),
- m_SampleToChunk.GetChunkSampleNum()))
- {
- break;
- }
- ulTrackSize += m_SampleSize.GetSampleSize();
- } while (AdvanceSample(m_TrackEdit,
- m_TimeToSample,
- m_SampleToChunk));
- ulTrackSizeOut = ulTrackSize;
- }
- Seek(ulCurrentMediaTime);
- return retVal;
- }
- /****************************************************************************
- * IHXThreadSafeMethods method
- */
- /****************************************************************************
- * IsThreadSafe
- */
- STDMETHODIMP_(UINT32)
- CQTTrack::IsThreadSafe()
- {
- return HX_THREADSAFE_METHOD_FF_GETPACKET | HX_THREADSAFE_METHOD_FSR_READDONE;
- }
- /****************************************************************************
- * Protected Functions
- */
- /****************************************************************************
- * InitPacketizer
- */
- HX_RESULT CQTTrack::InitPacketizer(IHXPayloadFormatObject* &pPacketizer,
- CQTPacketizerFactory* pPacketizerFactory,
- const char* pProtocol,
- CQT_TrackInfo_Manager* pTrackInfo,
- CQT_MovieInfo_Manager* pMovieInfo,
- CQTTrackManager* pTrackManager,
- CQTTrack* pTrack,
- IUnknown* pContext)
- {
- HX_RESULT retVal = HXR_OK;
- #ifdef QTCONFIG_PACKETIZER_FACTORY
- if (pPacketizerFactory)
- {
- retVal = pPacketizerFactory->Construct(pPacketizer,
- pProtocol,
- pTrackInfo,
- pMovieInfo,
- pTrackManager,
- pTrack,
- pContext);
- if (retVal == HXR_NO_DATA)
- {
- retVal = HXR_OK;
- }
- }
- if (SUCCEEDED(retVal))
- {
- if (pPacketizer)
- {
- IHXValues* pHeader = NULL;
- retVal = pPacketizer->Init(pContext, TRUE);
- if (SUCCEEDED(retVal))
- {
- retVal = m_pFileFormat->BuildStreamHeader(pHeader,
- this,
- pTrackInfo,
- pMovieInfo,
- pTrackManager,
- m_pClassFactory);
- }
- if (SUCCEEDED(retVal))
- {
- retVal = pPacketizer->SetStreamHeader(pHeader);
- }
- HX_RELEASE(pHeader);
- if (SUCCEEDED(retVal))
- {
- retVal = pPacketizer->GetStreamHeader(pHeader);
- }
- if (SUCCEEDED(retVal))
- {
- pTrackInfo->SetHeader(pHeader);
- }
- HX_RELEASE(pHeader);
- }
- }
- #endif // QTCONFIG_PACKETIZER_FACTORY
- return retVal;
- }
- /****************************************************************************
- * LoadData
- */
- HX_RESULT CQTTrack::LoadData(IHXBuffer* pFileName,
- ULONG32 ulOffset,
- ULONG32 ulSize)
- {
- HX_RELEASE(m_pReadFileNameBuffer);
- m_pReadFileName = NULL;
- #ifdef _LOG_DATA_ACCESS
- FILE* pf = fopen("C:\qt_access.txt", "a");
- fprintf(pf, "%d %d %dn", m_ulTrackID, ulOffset, ulSize);
- fclose(pf);
- #endif // _LOG_DATA_ACCESS
- #ifdef QTCONFIG_TRACK_CACHE
- m_TrackCache.ReleasePage();
- #endif // QTCONFIG_TRACK_CACHE
- m_ulReadSize = ulSize;
- m_ulReadPageSize = ulSize;
- m_ulReadPageOffset = ulOffset;
-
- if (pFileName)
- {
- m_pReadFileNameBuffer = pFileName;
- pFileName->AddRef();
- m_pReadFileName = (char *) pFileName->GetBuffer();
- }
- #ifdef QTCONFIG_TRACK_CACHE
- else if (m_TrackCache.IsEnabled() && (ulSize < QTTRACKCACHE_PAGE_SIZE))
- {
- m_ulReadPageSize = QTTRACKCACHE_PAGE_SIZE;
- }
- #endif // QTCONFIG_TRACK_CACHE
- return m_pFileSwitcher->Seek( ulOffset,
- FALSE,
- (IHXFileResponse*) this,
- m_pReadFileName);
- }
- /****************************************************************************
- * DataReady
- */
- HX_RESULT CQTTrack::DataReady(HX_RESULT status, IHXBuffer *pBuffer)
- {
- #ifdef QTCONFIG_TRACK_CACHE
- if (status == HXR_OK)
- {
- if (m_ulReadPageSize > m_ulReadSize)
- {
- m_TrackCache.SetPage(m_ulReadPageOffset, pBuffer);
- }
- }
- else
- {
- if (m_TrackCache.IsEnabled())
- {
- m_TrackCache.Enable(FALSE);
- return LoadData(m_pReadFileNameBuffer,
- m_ulReadPageOffset,
- m_ulReadSize);
- }
- }
- #endif // QTCONFIG_TRACK_CACHE
- switch (m_PendingState)
- {
- case QTT_SegmentRead:
- m_PendingState = QTT_Offline;
- if (m_pPacketAssembler)
- {
- return m_pPacketAssembler->SegmentReady(status, pBuffer,
- 0, m_ulReadSize);
- }
- break;
- case QTT_SampleRead:
- m_PendingState = QTT_Offline;
- return ReturnPacket(status, pBuffer, 0, m_ulReadSize);
- }
- return HXR_UNEXPECTED;
- }
- /****************************************************************************
- * ReturnPacket
- */
- HX_RESULT CQTTrack::ReturnPacket(HX_RESULT status,
- IHXBuffer *pBuffer)
- {
- return ReturnPacket(status,
- pBuffer,
- 0,
- pBuffer ? pBuffer->GetSize() : 0);
- }
- /****************************************************************************
- * ReturnPacket
- */
- HX_RESULT CQTTrack::ReturnPacket(HX_RESULT status,
- IHXBuffer *pBuffer,
- ULONG32 ulOffset,
- ULONG32 ulSize)
- {
- ULONG32 ulTime = (ULONG32) (m_TrackEdit.GetRealTime() + 0.5);
- ULONG32 ulRTPTime = m_TrackEdit.GetMediaTime() +
- m_TimeToSample.GetCompositionOffset();
- IHXPacket* pPacket = NULL;
- HX_RESULT retVal = HXR_OK;
- if (pBuffer)
- {
- #ifdef QTCONFIG_BFRAG
- if ((ulOffset != 0) || (ulSize != pBuffer->GetSize()))
- {
- #ifdef QTCONFIG_BFRAG_FACTORY
- pBuffer =
- m_pFileFormat->m_pBufferFragmentFactory->WrapFragment(
- pBuffer, ulOffset, ulSize);
- #else // QTCONFIG_BFRAG_FACTORY
- pBuffer = new CBufferFragment(pBuffer, ulOffset, ulSize);
-
- if (pBuffer)
- {
- pBuffer->AddRef();
- }
- #endif // QTCONFIG_BFRAG_FACTORY
- }
- else
- #else // QTCONFIG_BFRAG
- HX_ASSERT((ulOffset == 0) && (ulSize == pBuffer->GetSize()));
- #endif // QTCONFIG_BFRAG
- {
- pBuffer->AddRef();
- }
- }
- // Form packet
- if (status == HXR_OK)
- {
- status = m_pClassFactory->CreateInstance(CLSID_IHXRTPPacket,
- (void**) &pPacket);
- }
- if (pBuffer)
- {
- if (status == HXR_OK)
- {
- status = ((IHXRTPPacket*) pPacket)->SetRTP(
- pBuffer,
- ulTime,
- ulRTPTime,
- m_uStreamNumber,
- m_TimeToSample.IsOnSyncSample() ?
- (HX_ASM_SWITCH_ON | HX_ASM_SWITCH_OFF) :
- HX_ASM_SWITCH_OFF, // ASM Flags
- QTASM_MARKER_ON_RULE);
- }
- pBuffer->Release();
- pBuffer = NULL;
- }
-
- if (status == HXR_OK)
- {
- m_ulLastSampleDescIdx = m_SampleToChunk.GetSampleDescIdx();
- m_bTrackDone = !AdvanceSample(m_TrackEdit,
- m_TimeToSample,
- m_SampleToChunk);
- }
- else
- {
- m_bTrackDone = TRUE;
- }
- if (m_pPacketizer)
- {
- if (status == HXR_OK)
- {
- m_pPacketizer->SetPacket(pPacket);
- }
- HX_RELEASE(pPacket);
- if (m_bTrackDone)
- {
- m_pPacketizer->Flush();
- }
- status = m_pPacketizer->GetPacket(pPacket);
- if (status == HXR_INCOMPLETE)
- {
- if (!m_bTrackDone)
- {
- status = GetPacket(m_uStreamNumber);
- if (status == HXR_OK)
- {
- return status;
- }
- }
- else
- {
- status = HXR_STREAM_DONE;
- }
- }
- }
- retVal = m_pFileFormat->PacketReady(m_uStreamNumber, status, pPacket);
- HX_RELEASE(pPacket);
- return retVal;
- }
- /****************************************************************************
- * SequenceToTime
- */
- BOOL CQTTrack::SequenceToTime(CQT_TrackEdit_Manager &TrackEdit,
- CQT_TimeToSample_Manager &TimeToSample,
- CQT_SampleToChunk_Manager &SampleToChunk,
- BOOL bUseNonKeyFrames)
- {
- BOOL bOverSeek;
- do
- {
- bOverSeek = !( bUseNonKeyFrames ?
- TimeToSample.EstablishByMediaTime(
- TrackEdit.GetMediaTime()) :
- TimeToSample.EstablishAtKeyByMediaTime(
- TrackEdit.GetMediaTime()));
- } while ((!bOverSeek) &&
- TrackEdit.AdvanceByMediaTime(
- TimeToSample.GetLastMediaSyncTime(), bOverSeek) &&
- (!bOverSeek));
- if (!bOverSeek)
- {
- bOverSeek = !SampleToChunk.EstablishBySample(
- TimeToSample.GetSampleNumber());
- }
- return !bOverSeek;
- }
- /****************************************************************************
- * AdvanceSample
- */
- BOOL CQTTrack::AdvanceSample(CQT_TrackEdit_Manager &TrackEdit,
- CQT_TimeToSample_Manager &TimeToSample,
- CQT_SampleToChunk_Manager &SampleToChunk)
- {
- BOOL bStreamDone;
- if (TrackEdit.AdvanceByMediaTime(
- TimeToSample.GetSampleDuration(),
- bStreamDone))
- {
- // Advancement in time caused change in edit segment
- if (!bStreamDone)
- {
- bStreamDone = !SequenceToTime(TrackEdit,
- TimeToSample,
- SampleToChunk,
- QTTRK_USE_ANY_FRAME);
- }
- }
- else
- {
- bStreamDone = ((!TimeToSample.AdvanceBySample()) ||
- (!SampleToChunk.AdvanceBySample()));
- }
- return !bStreamDone;
- }
- /****************************************************************************
- * IHXFileResponse methods
- */
- /****************************************************************************
- * ReadDone
- */
- STDMETHODIMP CQTTrack::ReadDone(HX_RESULT status,
- IHXBuffer* pBuffer)
- {
- return DataReady(status, pBuffer);
- }
- /****************************************************************************
- * SeekDone
- */
- STDMETHODIMP CQTTrack::SeekDone(HX_RESULT status)
- {
- if (SUCCEEDED(status))
- {
- return m_pFileSwitcher->Read( m_ulReadPageSize,
- (IHXFileResponse*) this,
- m_pReadFileName);
- }
- return DataReady(status, NULL);
- }
- /****************************************************************************
- * IUnknown methods
- */
- /////////////////////////////////////////////////////////////////////////
- // Method:
- // IUnknown::QueryInterface
- //
- STDMETHODIMP CQTTrack::QueryInterface(REFIID riid, void** ppvObj)
- {
- if (IsEqualIID(riid, IID_IHXThreadSafeMethods))
- {
- AddRef();
- *ppvObj = (IHXThreadSafeMethods*) this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IUnknown))
- {
- AddRef();
- *ppvObj = this;
- return HXR_OK;
- }
- *ppvObj = NULL;
- return HXR_NOINTERFACE;
- }
- /////////////////////////////////////////////////////////////////////////
- // Method:
- // IUnknown::AddRef
- //
- STDMETHODIMP_(ULONG32) CQTTrack::AddRef()
- {
- return InterlockedIncrement(&m_lRefCount);
- }
- /////////////////////////////////////////////////////////////////////////
- // Method:
- // IUnknown::Release
- //
- STDMETHODIMP_(ULONG32) CQTTrack::Release()
- {
- if (InterlockedDecrement(&m_lRefCount) > 0)
- {
- return m_lRefCount;
- }
- delete this;
- return 0;
- }