hxplay.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:277k
- m_pGroupManager->SetCurrentGroup(0);
- #else
- HX_DELETE(m_pURL);
- CloseAllRenderers(0);
- m_pURL = new CHXURL(*pURL);
- if( m_pURL )
- {
- theErr = m_pURL->GetLastError();
- }
- else
- {
- theErr = HXR_OUTOFMEMORY;
- }
- if (HXR_OK == theErr)
- {
- pSourceInfo = NewSourceInfo();
- if (pSourceInfo)
- {
- theErr = AddURL(pSourceInfo, TRUE);
- }
- else
- {
- theErr = HXR_OUTOFMEMORY;
- }
- }
- #endif /* HELIX_FEATURE_BASICGROUPMGR */
- if (HXR_OK == theErr)
- {
- // At this point, we setup the number of active streams to be the
- // number of sctreams described in the SourceList!
- UpdateSourceActive();
- if (m_bIsFirstBeginPending)
- {
- m_bIsFirstBeginPending = FALSE;
- Begin();
- }
- }
- else
- {
- HX_DELETE(m_pURL);
- }
- return theErr;
- };
- /************************************************************************
- * Method:
- * IHXPlayer::AddURL
- * Purpose:
- * Tell the player to add an URL to the current source list.
- */
- HX_RESULT HXPlayer::AddURL(SourceInfo*& /*OUT*/ pSourceInfo, BOOL bAltURL)
- {
- HX_RESULT theErr = HXR_OK;
- HXSource* pSource = NULL;
- theErr = CreateSourceInfo(pSourceInfo, bAltURL);
- if (theErr != HXR_OK)
- {
- goto cleanup;
- }
- pSource = pSourceInfo->m_pSource;
- /* add to the list of sources for this player... */
- if (pSource)
- {
- if (!m_bPartOfNextGroup)
- {
- #if defined(HELIX_FEATURE_PREFETCH)
- if (pSourceInfo->m_bPrefetch)
- {
- if (!m_pPrefetchManager)
- {
- m_pPrefetchManager = new PrefetchManager(this);
- }
- m_pPrefetchManager->AddSource(pSourceInfo);
- pSourceInfo->m_pSource->PartOfPrefetchGroup(TRUE);
- }
- else
- #endif /* HELIX_FEATURE_PREFETCH */
- {
- m_pSourceMap->SetAt((void*) pSourceInfo->m_pSource,
- (void*) pSourceInfo);
- if (pSource->GetDelay() >= m_ulCurrentPlayTime &&
- pSource->GetDelay() - m_ulCurrentPlayTime <= MIN_DELAYBEFORE_START)
- {
- pSourceInfo->m_bTobeInitializedBeforeBegin = TRUE;
- m_uNumSourceToBeInitializedBeforeBegin++;
- }
- m_bPlayerWithoutSources = FALSE;
- m_bSourceMapUpdated = TRUE;
- m_bForceStatsUpdate = TRUE;
- }
- }
- else
- {
- if (pSource->GetDelay() <= MIN_DELAYBEFORE_START)
- {
- pSourceInfo->m_bTobeInitializedBeforeBegin = TRUE;
- /* We will increment the
- * m_uNumSourceToBeInitializedBeforeBegin value
- * once we start this next group
- */
- //m_uNumSourceToBeInitializedBeforeBegin++;
- }
- }
- }
- /* Are we adding more sources mid presentation ? */
- if (!m_bPartOfNextGroup && !pSourceInfo->m_bPrefetch)
- {
- m_uNumSourcesActive++;
- m_uNumCurrentSourceNotDone++;
- }
- cleanup:
- return (theErr);
- }
- HX_RESULT
- HXPlayer::CreateSourceInfo(SourceInfo*& pSourceInfo, BOOL bAltURL)
- {
- HX_RESULT theErr = HXR_OK;
- HXSource* pSource = NULL;
- if (m_pURL->IsNetworkProtocol())
- {
- theErr = InitializeNetworkDrivers();
- if (!theErr)
- {
- theErr = DoNetworkOpen(pSourceInfo, bAltURL);
- }
- }
- else
- {
- // Only send in URL now.
- theErr = DoFileSystemOpen(pSourceInfo, bAltURL);
- }
- pSource = pSourceInfo->m_pSource;
- if (!theErr && pSource)
- {
- pSourceInfo->m_bInitialized = FALSE;
- if (HXR_OK != pSource->QueryInterface(IID_IHXPendingStatus,
- (void**)&(pSourceInfo->m_pStatus)))
- {
- pSourceInfo->m_pStatus = NULL;
- }
- }
- if (HXR_OK != theErr)
- {
- HX_DELETE(pSourceInfo);
- }
- return (theErr);
- }
- HX_RESULT
- HXPlayer::PrepareSourceInfo(IHXValues* pTrack, SourceInfo*& pSourceInfo)
- {
- #if defined(HELIX_FEATURE_ADVANCEDGROUPMGR)
- HX_RESULT rc = HXR_OK;
- char szMaxDuration[] = "maxduration";
- char szIndefiniteDuration[] = "indefiniteduration";
- char szPrefetchType[] = "PrefetchType";
- char szPrefetchValue[] = "PrefetchValue";
- char szSoundLevel[] = "soundLevel";
- char szAudioDeviceReflushHint[] = "audioDeviceReflushHint";
- char szPersistentComponentID[] = "PersistentComponentID";
- char szFill[] = "fill";
- UINT32 ulValue = 0;
- #ifdef SEQ_DEPENDENCY
- char szTrack_hint[] = "track-hint";
- #endif
- pSourceInfo->m_bAudioDeviceReflushHint = FALSE;
- pSourceInfo->m_uSoundLevel = 100;
- pSourceInfo->m_bIndefiniteDuration = FALSE;
- pSourceInfo->m_ulMaxDuration = 0;
- pSourceInfo->m_ulPersistentComponentID = MAX_UINT32;
- pSourceInfo->m_ulPersistentComponentSelfID = MAX_UINT32;
- #if defined(HELIX_FEATURE_PREFETCH)
- // read prefetch info
- if (HXR_OK == pTrack->GetPropertyULONG32(szPrefetchType, ulValue) && ulValue)
- {
- pSourceInfo->m_bPrefetch = TRUE;
- pSourceInfo->m_prefetchType = (PrefetchType)ulValue;
- if (HXR_OK == pTrack->GetPropertyULONG32(szPrefetchValue, ulValue) && ulValue)
- {
- pSourceInfo->m_ulPrefetchValue = ulValue;
- }
- }
- #endif /* HELIX_FEATURE_PREFETCH */
- // read audioDeviceReflushHint
- if (HXR_OK == pTrack->GetPropertyULONG32(szAudioDeviceReflushHint, ulValue) && ulValue)
- {
- pSourceInfo->m_bAudioDeviceReflushHint = TRUE;
- }
- // read soundLevel
- if (HXR_OK == pTrack->GetPropertyULONG32(szSoundLevel, ulValue))
- {
- pSourceInfo->m_uSoundLevel = (UINT16)ulValue;
- }
- if (HXR_OK == pTrack->GetPropertyULONG32(szIndefiniteDuration, ulValue) && ulValue)
- {
- pSourceInfo->m_bIndefiniteDuration = TRUE;
- }
- if (HXR_OK == pTrack->GetPropertyULONG32(szMaxDuration, ulValue))
- {
- pSourceInfo->m_ulMaxDuration = ulValue;
- }
- if (HXR_OK == pTrack->GetPropertyULONG32(szPersistentComponentID, ulValue))
- {
- pSourceInfo->m_ulPersistentComponentID = ulValue;
- }
- if (HXR_OK == pTrack->GetPropertyULONG32(szFill, ulValue))
- {
- pSourceInfo->m_fillType = (FillType)ulValue;
- }
- #ifdef SEQ_DEPENDENCY
- IHXBuffer* pDependency = NULL;
- pTrack->GetPropertyCString(szTrack_hint,pDependency);
- if (pDependency && *(pDependency->GetBuffer()))
- {
- pSourceInfo->SetDependency(pDependency);
- }
- HX_RELEASE(pDependency);
- #endif /*SEQ_DEPENDENCY*/
- return rc;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_ADVANCEDGROUPMGR */
- }
- /************************************************************************
- * Method:
- * IHXPendingStatus::GetStatus
- * Purpose:
- * Called by the user to get the current pending status from an object
- */
- STDMETHODIMP
- HXPlayer::GetStatus
- (
- REF(UINT16) uStatusCode,
- REF(IHXBuffer*) pStatusDesc,
- REF(UINT16) ulPercentDone
- )
- {
- HX_RESULT hResult = HXR_OK;
- UINT16 statusCode = 0;
- UINT16 percentDone = 0;
- UINT16 totalPercentDone = 0;
- BOOL bIsContacting = FALSE;
- BOOL bIsBuffering = FALSE;
- BOOL bIsReady = FALSE;
- BOOL bInitializing = FALSE;
- IHXPendingStatus* pStatus = NULL;
- // initialize(default)
- uStatusCode = HX_STATUS_READY;
- pStatusDesc = NULL;
- ulPercentDone = 0;
- // collect info from all the sources
- CHXMapPtrToPtr::Iterator ndxSource = m_pSourceMap->Begin();
- for (; ndxSource != m_pSourceMap->End(); ++ndxSource)
- {
- SourceInfo* pSourceInfo = (SourceInfo*)(*ndxSource);
- pStatus = pSourceInfo->m_pStatus;
- if (pStatus && HXR_OK == pStatus->GetStatus(statusCode, pStatusDesc, percentDone))
- {
- if (HX_STATUS_CONTACTING == statusCode)
- {
- bIsContacting = TRUE;
- break;
- }
- else if (HX_STATUS_BUFFERING == statusCode)
- {
- bIsBuffering = TRUE;
- totalPercentDone += percentDone;
- }
- else if (HX_STATUS_READY == statusCode)
- {
- bIsReady = TRUE;
- totalPercentDone += 100;
- }
- else if (HX_STATUS_INITIALIZING == statusCode)
- {
- bInitializing = TRUE;
- }
- }
- }
- if (bInitializing)
- {
- uStatusCode = HX_STATUS_INITIALIZING;
- ulPercentDone = 0;
- }
- else if (bIsContacting)
- {
- uStatusCode = HX_STATUS_CONTACTING;
- ulPercentDone = 0;
- }
- else if (bIsBuffering)
- {
- uStatusCode = HX_STATUS_BUFFERING;
- pStatusDesc = NULL;
- ulPercentDone = totalPercentDone / m_pSourceMap->GetCount();
- }
- else if (bIsReady)
- {
- uStatusCode = HX_STATUS_READY;
- pStatusDesc = NULL;
- ulPercentDone = 0;
- }
- return hResult;
- }
- HX_RESULT
- HXPlayer::DoOpenGroup(UINT16 nGroupNumber)
- {
- #if defined(HELIX_FEATURE_BASICGROUPMGR)
- HX_RESULT theErr = HXR_OK;
- IHXGroup* pGroup = 0;
- HX_VERIFY((theErr = m_pGroupManager->GetGroup(nGroupNumber, pGroup)) == HXR_OK);
- if (theErr)
- {
- return theErr;
- }
- if (!m_bPartOfNextGroup)
- {
- m_bInitialized = FALSE; //so that we InitializeRenderers for this group
- m_bIsPresentationClosedToBeSent = FALSE;
- StopAllStreams(END_STOP);
- ResetGroup();
- CloseAllRenderers(m_nCurrentGroup); //kill all currently open renderers
- m_bIsDone = FALSE;
- }
- // add all the tracks in the group to the player's source list
- UINT16 nTrackCount = pGroup->GetTrackCount();
- IHXValues* pTrack = NULL;
- IHXPrefetch* pPrefetch = NULL;
- HX_RESULT theErrToReturn = HXR_OK;
- for (UINT16 nTrackIndex = 0; nTrackIndex < nTrackCount; nTrackIndex++)
- {
- if ((theErr = pGroup->GetTrack(nTrackIndex,pTrack)) == HXR_OK)
- {
- theErr = OpenTrack(pTrack, nGroupNumber, nTrackIndex);
- if (theErr && !theErrToReturn)
- {
- theErrToReturn = theErr;
- }
- HX_RELEASE(pTrack);
- }
- }
- #if defined(HELIX_FEATURE_PREFETCH)
- if (HXR_OK == pGroup->QueryInterface(IID_IHXPrefetch, (void**)&pPrefetch))
- {
- nTrackCount = pPrefetch->GetPrefetchTrackCount();
- for (UINT16 nTrackIndex = 0; nTrackIndex < nTrackCount; nTrackIndex++)
- {
- if ((theErr = pPrefetch->GetPrefetchTrack(nTrackIndex,pTrack)) == HXR_OK &&
- pTrack)
- {
- theErr = OpenTrack(pTrack, nGroupNumber, nTrackIndex);
- if (theErr && !theErrToReturn)
- {
- theErrToReturn = theErr;
- }
- HX_RELEASE(pTrack);
- }
- }
- }
- #endif /* HELIX_FEATURE_PREFETCH */
- HX_RELEASE(pPrefetch);
- HX_RELEASE(pGroup);
- return theErrToReturn;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_BASICGROUPMGR */
- }
- HX_RESULT
- HXPlayer::DoAltURLOpen(char* pAltURL, BOOL bDefault, SourceInfo* pMainSourceInfo)
- {
- #if defined(HELIX_FEATURE_ALT_URL)
- HX_RESULT hr = HXR_OK;
- SourceInfo* pSourceInfo = NULL;
- m_bIsDone = FALSE;
- ResetActiveRequest();
- HX_DELETE(m_pURL);
- m_pURL = new CHXURL(pAltURL);
- if( m_pURL )
- {
- pAltURL = (char*) m_pURL->GetURL();
- hr = m_pURL->GetLastError();
- }
- else
- {
- hr = HXR_OUTOFMEMORY;
- }
- if (hr)
- {
- HX_DELETE(m_pURL);
- goto cleanup;
- }
- pSourceInfo = NewSourceInfo();
- if (pSourceInfo)
- {
- pSourceInfo->m_uGroupID = pMainSourceInfo->m_uGroupID;
- pSourceInfo->m_uTrackID = pMainSourceInfo->m_uTrackID;
- pSourceInfo->m_bPrefetch = pMainSourceInfo->m_bPrefetch;
- pSourceInfo->m_id = pMainSourceInfo->m_id;
- pSourceInfo->m_bAltURL = TRUE;
- pSourceInfo->m_lastErrorFromMainURL = pMainSourceInfo->m_lastErrorFromMainURL;
- pSourceInfo->m_lastErrorStringFromMainURL = pMainSourceInfo->m_lastErrorStringFromMainURL;
- pSourceInfo->m_ulPersistentComponentID = pMainSourceInfo->m_ulPersistentComponentID;
- }
- else
- {
- hr = HXR_OUTOFMEMORY;
- goto cleanup;
- }
- hr = AddURL(pSourceInfo, TRUE);
- if (HXR_OK == hr && pSourceInfo->m_pSource)
- {
- pSourceInfo->m_pSource->SetAltURLType(bDefault);
- }
- SchedulePlayer();
- cleanup:
- return hr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_ALT_URL */
- }
- HX_RESULT
- HXPlayer::SpawnSourceIfNeeded(SourceInfo* pSourceInfo)
- {
- #if defined(HELIX_FEATURE_SMIL_REPEAT)
- HX_RESULT theErr = HXR_OK;
- RepeatInfo* pRepeatInfo = NULL;
- // spawned the source if it is repeated
- if (pSourceInfo->m_pRepeatList &&
- !pSourceInfo->m_pPeerSourceInfo &&
- pSourceInfo->m_pSource->IsInitialized())
- {
- SourceInfo* pPeerSourceInfo = NewSourceInfo();
- if( !pPeerSourceInfo )
- {
- return HXR_OUTOFMEMORY;
- }
- CHXURL* pURL = m_pURL;
- const char* pszURL = pSourceInfo->m_pSource->GetURL();
- m_pURL = new CHXURL(pszURL);
- if( !m_pURL )
- {
- HX_DELETE(pSourceInfo);
- return HXR_OUTOFMEMORY;
- }
- pPeerSourceInfo->m_curPosition = pSourceInfo->m_curPosition;
- pRepeatInfo = (RepeatInfo*)pSourceInfo->m_pRepeatList->GetAtNext(pPeerSourceInfo->m_curPosition);
- if (pRepeatInfo->ulStart)
- {
- m_pURL->AddOption("Start", pRepeatInfo->ulStart);
- }
- if (pRepeatInfo->ulEnd)
- {
- m_pURL->AddOption("End", pRepeatInfo->ulEnd);
- }
- m_pURL->AddOption("Delay", pRepeatInfo->ulDelay);
- m_pURL->AddOption("Duration", pRepeatInfo->ulDuration);
- pPeerSourceInfo->m_bLeadingSource = FALSE;
- pPeerSourceInfo->m_bRepeatIndefinite = pSourceInfo->m_bRepeatIndefinite;
- pPeerSourceInfo->m_ulRepeatInterval = pSourceInfo->m_ulRepeatInterval;
- pPeerSourceInfo->m_ulMaxDuration = pSourceInfo->m_ulMaxDuration;
- pPeerSourceInfo->m_bTrackStartedToBeSent = pSourceInfo->m_bTrackStartedToBeSent;
- pPeerSourceInfo->m_uGroupID = pSourceInfo->m_uGroupID;
- pPeerSourceInfo->m_uTrackID = pRepeatInfo->uTrackID;
- pPeerSourceInfo->m_ulPersistentComponentID = pSourceInfo->m_ulPersistentComponentID;
- pPeerSourceInfo->m_ulTotalTrackDuration = pSourceInfo->m_ulTotalTrackDuration;
- theErr = CreateSourceInfo(pPeerSourceInfo, FALSE);
- if(pPeerSourceInfo && pPeerSourceInfo->m_pSource)
- {
- pPeerSourceInfo->m_pSource->m_ulOriginalDelay = pSourceInfo->m_pSource->m_ulOriginalDelay;
- pSourceInfo->m_pPeerSourceInfo = pPeerSourceInfo;
- pPeerSourceInfo->m_pPeerSourceInfo = pSourceInfo;
- }
- HX_DELETE(m_pURL);
- m_pURL = pURL;
- }
- return theErr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_SMIL_REPEAT */
- }
- HX_RESULT
- HXPlayer::SwitchSourceIfNeeded(void)
- {
- #if defined(HELIX_FEATURE_SMIL_REPEAT)
- // swapping the repeated sources if it's time
- HX_RESULT theErr = HXR_OK;
- UINT32 ulTotalTrackDuration = 0;
- UINT32 ulPeerSourceDuration = 0;
- UINT32 ulPeerSourceDelay = 0;
- SourceInfo* pSourceInfo = NULL;
- CHXMapPtrToPtr::Iterator ndxSource = m_pSourceMap->Begin();
- for (;!theErr && ndxSource != m_pSourceMap->End(); ++ndxSource)
- {
- pSourceInfo = (SourceInfo*)(*ndxSource);
- if (!pSourceInfo->m_pPeerSourceInfo ||
- !pSourceInfo->m_pPeerSourceInfo->m_pSource)
- {
- continue;
- }
- ulTotalTrackDuration = pSourceInfo->GetActiveDuration();
- ulPeerSourceDuration = pSourceInfo->m_pPeerSourceInfo->m_pSource->GetDuration();
- ulPeerSourceDelay = pSourceInfo->m_pPeerSourceInfo->m_pSource->GetDelay();
- if (ulTotalTrackDuration > m_ulCurrentPlayTime &&
- ulPeerSourceDelay > pSourceInfo->m_pSource->GetDelay() &&
- ulPeerSourceDelay <= m_ulCurrentPlayTime)
- {
- if (ulPeerSourceDuration > ulTotalTrackDuration)
- {
- pSourceInfo->m_pPeerSourceInfo->UpdateDuration(ulTotalTrackDuration - ulPeerSourceDelay);
- }
- m_pSourceMap->RemoveKey(pSourceInfo->m_pSource);
- if (!pSourceInfo->m_pSource->IsSourceDone())
- {
- pSourceInfo->m_pSource->SetEndOfClip(TRUE);
- }
- pSourceInfo->m_bDone = TRUE;
- pSourceInfo->m_bRepeatPending = TRUE;
- pSourceInfo->m_pPeerSourceInfo->m_bRepeatPending = FALSE;
- m_pSourceMap->SetAt((void*) pSourceInfo->m_pPeerSourceInfo->m_pSource,
- (void*) pSourceInfo->m_pPeerSourceInfo);
- m_bSourceMapUpdated = TRUE;
- m_bForceStatsUpdate = TRUE;
- break;
- }
- }
- return theErr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_SMIL_REPEAT */
- }
- HX_RESULT
- HXPlayer::OpenTrack(IHXValues* pTrack, UINT16 uGroupID, UINT16 uTrackID)
- {
- #if defined(HELIX_FEATURE_BASICGROUPMGR)
- HX_RESULT theErr = HXR_OK;
- IHXBuffer* pBuffer = NULL;
- IHXBuffer* pID = NULL;
- SourceInfo* pSourceInfo = NULL;
- const char* pURL = NULL;
- char szID[] = "id";
- char szUrl[] = "url";
- char szSrc[] = "src";
- char szStart[] = "Start";
- char szEnd[] = "End";
- char szDelay[] = "Delay";
- char szDuration[] = "Duration";
- UINT32 ulValue = 0;
- theErr = pTrack->GetPropertyCString(szUrl,pBuffer);
- /*
- * Make sure everyone is setting url property (and not the
- * src property) for consistency.
- */
- /* temp - for now support both "src" & "url" */
- if (theErr)
- {
- theErr = pTrack->GetPropertyCString(szSrc,pBuffer);
- }
- if (theErr)
- {
- theErr = HXR_INVALID_PATH;
- goto cleanup;
- }
- pURL = (const char*)pBuffer->GetBuffer();
- if (!pURL || !*pURL)
- {
- theErr = HXR_INVALID_PATH;
- goto cleanup;
- }
- // Cleanup any url object!
- HX_DELETE(m_pURL);
- m_pURL = new CHXURL(pURL); //parse the url
- if (!m_pURL)
- {
- theErr = HXR_OUTOFMEMORY;
- goto cleanup;
- }
- theErr = m_pURL->GetLastError();
- if (theErr)
- {
- goto cleanup;
- }
- theErr = OpenTrackExt();
- //temp - DoNetworkOpen/DoFSOpen extract these properties from m_pURL
- if (HXR_OK == pTrack->GetPropertyULONG32(szStart,ulValue))
- {
- m_pURL->AddOption(szStart, ulValue);
- }
- //pProperty = NULL;
- if (HXR_OK == pTrack->GetPropertyULONG32(szEnd,ulValue))
- {
- m_pURL->AddOption(szEnd, ulValue);
- }
- if (HXR_OK == pTrack->GetPropertyULONG32(szDelay,ulValue))
- {
- m_pURL->AddOption(szDelay, ulValue);
- }
- if (HXR_OK == pTrack->GetPropertyULONG32(szDuration,ulValue))
- {
- m_pURL->AddOption(szDuration, ulValue);
- }
- pSourceInfo = NewSourceInfo();
- if(pSourceInfo)
- {
- pSourceInfo->m_uGroupID = uGroupID;
- pSourceInfo->m_uTrackID = uTrackID;
- if (HXR_OK == pTrack->GetPropertyCString(szID, pID))
- {
- pSourceInfo->m_id = (const char*)pID->GetBuffer();
- }
- PrepareSourceInfo(pTrack, pSourceInfo);
- }
- else
- {
- theErr = HXR_OUTOFMEMORY;
- goto cleanup;
- }
- theErr = AddURL(pSourceInfo, FALSE);
- #if defined(HELIX_FEATURE_NEXTGROUPMGR)
- if (HXR_OK == theErr &&
- m_bPartOfNextGroup &&
- pSourceInfo->m_pSource)
- {
- m_pNextGroupManager->AddSource(pSourceInfo);
- }
- #endif /* HELIX_FEATURE_NEXTGROUPMGR */
- cleanup:
- HX_RELEASE(pBuffer);
- HX_RELEASE(pID);
- return theErr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_BASICGROUPMGR */
- }
- HX_RESULT
- HXPlayer::OpenTrackExt()
- {
- return HXR_OK;
- }
- /* called from ProcessIdle when done playing current group */
- void HXPlayer::PlayNextGroup()
- {
- UINT16 uNextGroup = 0;
- #if defined(HELIX_FEATURE_BASICGROUPMGR)
- m_pGroupManager->GetNextGroup(uNextGroup);
- #else
- uNextGroup = m_nGroupCount;
- #endif /* HELIX_FEATURE_BASICGROUPMGR */
- m_nCurrentGroup = uNextGroup;
- if (m_nCurrentGroup >= m_nGroupCount)
- {
- // Stop completely...
- m_bIsPresentationClosedToBeSent = TRUE;
- m_bIsDone = TRUE;
- StopPlayer(END_DURATION);
- #if defined(HELIX_FEATURE_VIDEO)
- /*
- * Let the site supplier know that we are done changing the layout.
- */
- if (m_pSiteSupplier && !m_bBeginChangeLayoutTobeCalled)
- {
- m_bBeginChangeLayoutTobeCalled = TRUE;
- m_pSiteSupplier->DoneChangeLayout();
- }
- #endif /* HELIX_FEATURE_VIDEO */
- }
- else
- {
- // build the group's source list
- m_bIsPresentationClosedToBeSent = FALSE;
- StopAllStreams(END_DURATION);
- m_bIsPresentationClosedToBeSent = TRUE;
- ResetGroup();
- #if defined(HELIX_FEATURE_BASICGROUPMGR)
- m_pGroupManager->SetCurrentGroup((UINT16) m_nCurrentGroup);
- #endif /* HELIX_FEATURE_BASICGROUPMGR */
- }
- m_bForceStatsUpdate = TRUE;
- }
- /************************************************************************
- * Method:
- * HXPlayer::CheckTrackAndSourceOnTrackStarted
- * Purpose:
- * Passthrough to allow SourceInfo to call Master TAC manager
- *
- */
- BOOL HXPlayer::CheckTrackAndSourceOnTrackStarted(INT32 nGroup,
- INT32 nTrack,
- UINT32 sourceID)
- {
- #if defined(HELIX_FEATURE_MASTERTAC)
- return (!m_pMasterTAC ?TRUE :m_pMasterTAC->CheckTrackAndSourceOnTrackStarted(nGroup, nTrack, sourceID));
- #else
- return TRUE;
- #endif /* HELIX_FEATURE_MASTERTAC */
- }
- /*
- * IHXRegistryID methods
- */
- /************************************************************************
- * Method:
- * IHXRegistryID::GetID
- * Purpose:
- * Get registry ID(hash_key) of the objects(player, source and stream)
- *
- */
- STDMETHODIMP HXPlayer::GetID(REF(UINT32) /*OUT*/ ulRegistryID)
- {
- #if defined(HELIX_FEATURE_STATS) && defined(HELIX_FEATURE_REGISTRY)
- (m_pStats)?(ulRegistryID = m_pStats->m_ulRegistryID):(ulRegistryID = 0);
- return HXR_OK;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */
- }
- HX_RESULT HXPlayer::DoNetworkOpen(SourceInfo*& pSourceInfo, BOOL bAltURL)
- {
- #if defined(HELIX_FEATURE_PLAYBACK_NET)
- HX_RESULT theErr = HXR_OK;
- HXSource* pSource = NULL;
- IHXValues* pURLProperties = NULL;
- IHXBuffer* pBuffer = NULL;
- UINT32 ulRegistryID = 0;
- char* pszHost = NULL;
- char* pszResource = NULL;
- const char* pszURL = NULL;
- ULONG32 ulPort = 0;
- IHXBuffer* pszParentName = NULL;
- m_bAllLocalSources = FALSE;
- #if defined(HELIX_FEATURE_SMARTERNETWORK)
- if (!m_bPrefTransportInitialized && m_pPreferredTransportManager)
- {
- // re-load proxy/subnet preferences
- m_bPrefTransportInitialized = TRUE;
- if (m_pNetInterfaces)
- {
- m_pNetInterfaces->UpdateNetInterfaces();
- }
- m_pPreferredTransportManager->Initialize();
- }
- #endif /* HELIX_FEATURE_SMARTERNETWORK */
- pSource = pSourceInfo->m_pSource = NewNetSource();
- if (!pSource)
- {
- return( HXR_OUTOFMEMORY );
- }
- pSource->AddRef();
- #if defined(HELIX_FEATURE_STATS) && defined(HELIX_FEATURE_REGISTRY)
- // registry setting
- if (m_pRegistry && m_pStats)
- {
- char szSourceName[MAX_DISPLAY_NAME] = {0}; /* Flawfinder: ignore */
- if (m_bPartOfNextGroup &&
- HXR_OK == m_pRegistry->GetPropName(m_ulNextGroupRegistryID, pszParentName))
- {
- SafeSprintf(szSourceName, MAX_DISPLAY_NAME, "%s.Source%ld", pszParentName->GetBuffer(),
- pSourceInfo->m_uTrackID);
- }
- else if (HXR_OK == m_pRegistry->GetPropName(m_pStats->m_ulRegistryID, pszParentName))
- {
- SafeSprintf(szSourceName, MAX_DISPLAY_NAME, "%s.Source%ld", pszParentName->GetBuffer(),
- pSourceInfo->m_uTrackID);
- }
- else
- {
- HX_ASSERT(FALSE);
- }
- /* does this ID already exists ? */
- ulRegistryID = m_pRegistry->GetId(szSourceName);
- if (!ulRegistryID)
- {
- ulRegistryID = m_pRegistry->AddComp(szSourceName);
- }
- }
- #endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */
- HX_RELEASE(pszParentName);
- pSource->SetSourceInfo(pSourceInfo);
- pSource->Init(this, ulRegistryID);
- UINT32 ulStart = 0, ulEnd = HX_EOF_TIME, ulDelay = 0, ulDuration = 0;
- GetTimingFromURL(m_pURL, ulStart, ulEnd, ulDelay, ulDuration);
- if (!(pURLProperties = m_pURL->GetProperties()))
- {
- theErr = HXR_FAILED;
- goto cleanup;
- }
- pURLProperties->GetPropertyULONG32(PROPERTY_PORT, ulPort);
- if (HXR_OK == pURLProperties->GetPropertyBuffer(PROPERTY_HOST, pBuffer))
- {
- pszHost = (char*)pBuffer->GetBuffer();
- pBuffer->Release();
- }
- if (HXR_OK == pURLProperties->GetPropertyBuffer(PROPERTY_RESOURCE, pBuffer))
- {
- pszResource = (char*)pBuffer->GetBuffer();
- pBuffer->Release();
- }
- pszURL = m_pURL->GetURL();
- pSource->SetPlayTimes(ulStart, ulEnd, ulDelay, ulDuration);
- pSource->PartOfNextGroup(m_bPartOfNextGroup);
- #if defined(HELIX_FEATURE_PREFETCH)
- if (pSourceInfo->m_bPrefetch)
- {
- pSource->EnterPrefetch(pSourceInfo->m_prefetchType, pSourceInfo->m_ulPrefetchValue);
- }
- #endif /* HELIX_FEATURE_PREFETCH */
- theErr = ((HXNetSource*)pSource)->Setup(pszHost, pszResource, (UINT16)ulPort, TRUE, m_pURL, bAltURL);
- cleanup:
- HX_RELEASE(pURLProperties);
- // cleanup...
- if(theErr && pSource)
- {
- pSource->DoCleanup();
- HX_RELEASE(pSource);
- }
- return theErr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_PLAYBACK_NET */
- }
- HX_RESULT HXPlayer::DoFileSystemOpen(SourceInfo*& pSourceInfo, BOOL bAltURL)
- {
- #if defined(HELIX_FEATURE_PLAYBACK_LOCAL)
- HX_RESULT theErr = HXR_OK;
- HXSource* pSource = NULL;
- IHXValues* pURLProperties = NULL;
- UINT32 ulRegistryID = 0;
- IHXBuffer* pszParentName = NULL;
- pSource = pSourceInfo->m_pSource = NewFileSource();
- if (!pSource)
- {
- return( HXR_OUTOFMEMORY );
- }
- pSource->AddRef();
- UINT32 ulStart = 0, ulEnd = HX_EOF_TIME, ulDelay = 0, ulDuration = 0;
- GetTimingFromURL(m_pURL, ulStart, ulEnd, ulDelay, ulDuration);
- if (m_pURL)
- {
- if (!(pURLProperties = m_pURL->GetProperties()))
- {
- theErr = HXR_FAILED;
- goto cleanup;
- }
- }
- #if defined(HELIX_FEATURE_STATS) && defined(HELIX_FEATURE_REGISTRY)
- // registry setting
- if (m_pRegistry && m_pStats)
- {
- HX_RESULT res = HXR_OK;
- UINT32 nRegID = 0;
- if(m_bPartOfNextGroup)
- nRegID = m_ulNextGroupRegistryID;
- else
- nRegID = m_pStats->m_ulRegistryID;
- res = m_pRegistry->GetPropName(nRegID, pszParentName);
- if ( HXR_OK == res && pszParentName )
- {
- char szSourceName[MAX_DISPLAY_NAME] = {0}; /* Flawfinder: ignore */
- SafeSprintf(szSourceName, MAX_DISPLAY_NAME, "%s.Source%u", pszParentName->GetBuffer(),
- pSourceInfo->m_uTrackID);
- // does this ID already exist?
- ulRegistryID = m_pRegistry->GetId(szSourceName);
- if ( !ulRegistryID )
- {
- ulRegistryID = m_pRegistry->AddComp(szSourceName);
- }
- HX_RELEASE(pszParentName);
- }
- else
- {
- HX_ASSERT(FALSE);
- }
- }
- HX_RELEASE(pszParentName);
- #endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */
- pSource->SetSourceInfo(pSourceInfo);
- pSource->Init(this, ulRegistryID);
- pSource->SetPlayTimes(ulStart, ulEnd, ulDelay, ulDuration);
- pSource->PartOfNextGroup(m_bPartOfNextGroup);
- theErr = ((HXFileSource*)pSource)->Setup(m_pURL, bAltURL);
- cleanup:
- HX_RELEASE(pURLProperties);
- // cleanup...
- if(theErr && pSource)
- {
- pSource->DoCleanup();
- HX_RELEASE(pSource);
- }
- return theErr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_PLAYBACK_LOCAL */
- }
- HX_RESULT
- HXPlayer::UnRegisterCurrentSources()
- {
- HX_RESULT theErr = HXR_OK;
-
- CHXMapPtrToPtr::Iterator ndxSource = m_pSourceMap->Begin();
- for (; !theErr && ndxSource != m_pSourceMap->End(); ++ndxSource)
- {
- SourceInfo* pSourceInfo = (SourceInfo*)(*ndxSource);
- theErr = pSourceInfo->UnRegister();
- }
- return theErr;
- }
- HX_RESULT HXPlayer::InitializeRenderers(void)
- {
- HX_RESULT theErr = HXR_OK;
- HX_RESULT thefinalErr = HXR_OK;
- SourceInfo* pSourceInfo = NULL;
- BOOL bSourceInitialized = TRUE;
- // assume everything will be initialized in this pass...
- BOOL bAllInitialized = TRUE;
- UINT16 uInitialSourceCount = m_pSourceMap->GetCount();
- CHXMapPtrToPtr::Iterator ndxSource = m_pSourceMap->Begin();
- for (; ndxSource != m_pSourceMap->End(); ++ndxSource)
- {
- pSourceInfo = (SourceInfo*)(*ndxSource);
- if (pSourceInfo->m_bInitialized)
- continue;
- theErr = pSourceInfo->InitializeRenderers(bSourceInitialized);
- if (theErr && !thefinalErr)
- {
- thefinalErr = theErr;
- }
- if (!bSourceInitialized)
- {
- bAllInitialized = FALSE;
- }
- /* Someone added a source during ProcessIdle.
- * Start all over again
- */
- if (uInitialSourceCount != m_pSourceMap->GetCount())
- {
- bAllInitialized = FALSE;
- break;
- }
- }
- if (!thefinalErr && bAllInitialized)
- {
- m_bInitialized = TRUE;
- if (m_pAdviseSink)
- {
- m_pAdviseSink->OnPosLength( m_ulCurrentPlayTime,
- m_ulPresentationDuration);
- m_pAdviseSink->OnBegin(m_ulCurrentPlayTime);
- }
- }
- if (!thefinalErr && m_bInitialized && m_pSourceMap->GetCount() == 0)
- {
- m_bPlayerWithoutSources = TRUE;
- }
- #if defined(HELIX_FEATURE_PREFETCH)
- if (!thefinalErr && m_bInitialized)
- {
- while (m_pPendingTrackList && m_pPendingTrackList->GetCount() > 0)
- {
- PendingTrackInfo* pPendingTrackInfo =
- (PendingTrackInfo*) m_pPendingTrackList->RemoveHead();
- theErr = OpenTrack(pPendingTrackInfo->m_pTrack,
- pPendingTrackInfo->m_uGroupIndex,
- pPendingTrackInfo->m_uTrackIndex);
- if (theErr && !thefinalErr)
- {
- thefinalErr = theErr;
- }
- delete pPendingTrackInfo;
- }
- if (thefinalErr)
- {
- ReportError(NULL, thefinalErr, NULL);
- }
- }
- #endif /* HELIX_FEATURE_PREFETCH */
- return thefinalErr;
- }
- // get all packets from event queue and send them to the various renders
- HX_RESULT
- HXPlayer::ProcessCurrentEvents()
- {
- HX_RESULT theErr = HXR_OK;
- BOOL bDone = FALSE;
- LISTPOSITION listpos = NULL;
- CHXEvent* pEvent = 0;
- /*
- * check for m_bLiveSeekToBeDone && m_bPaused is so that we do not issue
- * a seek (and start sending packets) before the user has issued a Begin()
- * after Pausing a live stream.
- *
- * Should work for now. Need to be re-visited when Live Pause support
- * is refined in the core.
- *
- * XXXRA
- */
- if (m_bProcessEventsLocked || (m_bLiveSeekToBeDone && m_bPaused))
- {
- return HXR_OK;
- }
- m_bDidWeDeleteAllEvents = FALSE;
- m_bProcessEventsLocked = TRUE;
- if (m_EventList.GetNumEvents() > 0)
- {
- pEvent = m_EventList.GetHead();
- listpos = m_EventList.GetHeadPosition();
- }
- UINT32 ulEndFillTime = m_ulCurrentPlayTime + m_ulLowestGranularity;
- #ifdef _MACINTOSH
- #define ADDITIONAL_PREDELIVERY_TIME 4000
- /* on Mac we try to be even farther ahead than the timeline in
- * packet delivery since the callbacks are not that smooth
- * and if we are really close to the wire, it results in
- * unnecccessary re-buffers.
- */
- ulEndFillTime += ADDITIONAL_PREDELIVERY_TIME;
- #endif
- /* If we are in a buffering state, then keep pushing packets
- * This is required due to ReportRebufferStatus()
- */
- if (!m_bIsPlaying && !m_bPaused && pEvent)
- {
- UINT32 ulNewEndFillTime = pEvent->GetTimeStartPos() + 1000;
- ulEndFillTime = ulNewEndFillTime > ulEndFillTime ?
- ulNewEndFillTime : ulEndFillTime;
- }
- while (!theErr && pEvent && !bDone)
- {
- // due?
- /* Do not hold back any packets for live streams */
- //{FILE* f1 = ::fopen("c:\temp\onpacket.txt", "a+"); ::fprintf(f1, "startPos: %lu endFillTime: %lun", pEvent->GetTimeStartPos(), ulEndFillTime);::fclose(f1);}
- if (pEvent->GetTimeStartPos() <= ulEndFillTime)
- {
- IHXPacket* pPacket = pEvent->GetPacket();
- /* since packet's time may be different from player's time, send
- * renderer the offset */
- #if defined(_DEBUG) && defined(DEBUG_LOG_INFO)
- HXStaticStatLog::StatPrintf("Packet Time: %lun",
- pPacket->GetTime());
- #endif // DEBUG_LOG_INFO
- BOOL bAtInterrupt = m_pEngine->AtInterruptTime();
- if (m_bLiveSeekToBeDone && !pEvent->IsPreSeekEvent())
- {
- /* Audio device was earlier seeked based on the last timesync
- * + pause duration. The actual first packet time we get after
- * Pause may be different from the seek time. This is because
- * at pause time, packets may have been given in advance to
- * the renderers due to preroll. Also, they may be stored in
- * resend buffer at protocol level. So the only way to kind
- * of know what time we should have actually seeked to is based
- * on the first packet time. Even this may result in initial
- * re-buffering. This is still a hack. We probably need a
- * better live pause solution.
- */
- m_bLiveSeekToBeDone = FALSE;
- UINT32 ulCurTime = m_pAudioPlayer->GetCurrentPlayBackTime();
- /* make sure we have sent ATLEAST one ontimesync to the renderer.
- * otherwise, we cannot rely on the m_ulTimeAfterSeek value since it is based on
- * m_ulTimeDiff which only gets set in the first ontimesync call.
- * Needed to fix pause during inital buffering of live playback
- */
- if (!pEvent->m_pRendererInfo->m_bIsFirstTimeSync &&
- pPacket->GetTime() > pEvent->m_pRendererInfo->m_pStreamInfo->m_ulTimeAfterSeek)
- {
- #if defined(_MACINTOSH) || defined(_MAC_UNIX)
- /* Cannot call audio player Seek() at interrupt time. It results
- * in audio device Reset() which issues DoImmediate commands
- */
- if (bAtInterrupt)
- {
- if (m_pHXPlayerCallback)
- {
- RemovePendingCallback(m_pHXPlayerCallback);
- m_pHXPlayerCallback->CallbackScheduled(
- m_pScheduler->RelativeEnter(m_pHXPlayerCallback, 0));
- }
- bDone = TRUE;
- continue;
- }
- #endif
- UINT32 ulTimeDiff = 0;
- ulTimeDiff = pPacket->GetTime() -
- pEvent->m_pRendererInfo->m_pStreamInfo->m_ulTimeAfterSeek;
- m_pAudioPlayer->Seek(ulCurTime + ulTimeDiff);
- }
- }
- if (!bAtInterrupt || pEvent->m_pRendererInfo->m_bInterruptSafe)
- {
- if (!pEvent->IsPreSeekEvent())
- {
- SendPostSeekIfNecessary(pEvent->m_pRendererInfo);
- }
- // remove this event from the packet list...
- listpos = m_EventList.RemoveAt(listpos);
- theErr = SendPacket(pEvent);
- /* A renderer may call SetCurrentGroup OR Stop() from within
- * OnPacket call. If so, we delete all the pending events
- */
- if (m_bDidWeDeleteAllEvents)
- {
- delete pEvent;
- bDone = TRUE;
- break;
- }
- HX_ASSERT(pEvent->m_pRendererInfo->m_ulNumberOfPacketsQueued > 0);
- pEvent->m_pRendererInfo->m_ulNumberOfPacketsQueued--;
- if (pEvent->m_pRendererInfo->m_ulNumberOfPacketsQueued == 0 &&
- pEvent->m_pRendererInfo->m_pStreamInfo->m_bSrcInfoStreamDone)
- {
- SendPostSeekIfNecessary(pEvent->m_pRendererInfo);
- pEvent->m_pRendererInfo->m_bOnEndOfPacketSent = TRUE;
- pEvent->m_pRendererInfo->m_pRenderer->OnEndofPackets();
- }
- // cleanup this event...
- delete pEvent;
- pEvent = NULL;
- // and get the next event...
- if (m_EventList.GetNumEvents() > 0)
- {
- pEvent = m_EventList.GetAt(listpos);
- }
- }
- else
- {
- pEvent = m_EventList.GetAtNext(listpos); //skip over event - *++listpos
- }
- }
- else
- {
- bDone = TRUE;
- }
- }
- m_bDidWeDeleteAllEvents = FALSE;
- m_bProcessEventsLocked = FALSE;
- return theErr;
- }
- HX_RESULT HXPlayer::SendPreSeekEvents()
- {
- HX_RESULT theErr = HXR_OK;
- LISTPOSITION listpos = m_EventList.GetHeadPosition();
- while (listpos && (m_EventList.GetNumEvents() != 0))
- {
- CHXEvent* pEvent = m_EventList.GetAt(listpos);
- BOOL bAtInterrupt = m_pEngine->AtInterruptTime();
- if (!bAtInterrupt || pEvent->m_pRendererInfo->m_bInterruptSafe)
- {
- listpos = m_EventList.RemoveAt(listpos);
- theErr = SendPacket(pEvent);
- HX_ASSERT(pEvent->m_pRendererInfo->m_ulNumberOfPacketsQueued > 0);
- pEvent->m_pRendererInfo->m_ulNumberOfPacketsQueued--;
- delete pEvent;
- }
- else
- {
- pEvent->SetPreSeekEvent();
- m_EventList.GetNext(listpos);
- }
- }
- SendPreSeekEventsExt();
- CHXMapPtrToPtr::Iterator ndxSource = m_pSourceMap->Begin();
- for (; !theErr && ndxSource != m_pSourceMap->End(); ++ndxSource)
- {
- SourceInfo* pSourceInfo = (SourceInfo*)(*ndxSource);
- if (pSourceInfo->m_pSource && pSourceInfo->m_pSource->m_PacketBufferList.GetCount() > 0)
- {
- CHXSimpleList* pPacketList = &pSourceInfo->m_pSource->m_PacketBufferList;
- LISTPOSITION pos = pPacketList->GetHeadPosition();
- while (pos != NULL)
- {
- CHXEvent* pTempEvent = (CHXEvent*) pPacketList->GetNext(pos);
- pTempEvent->SetPreSeekEvent();
- }
- }
- }
- return theErr;
- }
- HX_RESULT HXPlayer::DeleteAllEvents()
- {
- while (m_EventList.GetNumEvents() != 0)
- {
- CHXEvent* pEvent = m_EventList.RemoveHead();
- /* If these packets belong to a persistent source,
- * pass them over.
- */
- if (pEvent->m_pRendererInfo->m_bIsPersistent)
- {
- BOOL bAtInterrupt = m_pEngine->AtInterruptTime();
- if (!bAtInterrupt || pEvent->m_pRendererInfo->m_bInterruptSafe)
- {
- SendPacket(pEvent);
- }
- }
- delete pEvent;
- }
- CHXMapPtrToPtr::Iterator ndxSource = m_pSourceMap->Begin();
- for (; ndxSource != m_pSourceMap->End(); ++ndxSource)
- {
- SourceInfo* pSourceInfo = (SourceInfo*)(*ndxSource);
- if (pSourceInfo->m_pSource)
- {
- pSourceInfo->m_pSource->DeleteAllEvents();
- }
- }
- m_bDidWeDeleteAllEvents = TRUE;
- return HXR_OK;
- }
- HX_RESULT
- HXPlayer::EventReady(HXSource* pSource, CHXEvent* pEvent)
- {
- HX_RESULT theErr = HXR_OK;
- SourceInfo* pSourceInfo = NULL;
- RendererInfo* pRendInfo = NULL;
- if (!m_pSourceMap->Lookup(pSource, (void*&) pSourceInfo))
- {
- HX_ASSERT(FALSE);
- return HXR_INVALID_PARAMETER;
- }
- if (!pSourceInfo->m_pRendererMap->Lookup((pEvent->GetPacket())->GetStreamNumber(), (void*&) pRendInfo))
- {
- HX_ASSERT(FALSE);
- return HXR_INVALID_PARAMETER;
- }
- pEvent->m_pRendererInfo = pRendInfo;
- BOOL bOkToSend = (!m_pEngine->AtInterruptTime() ||
- pEvent->m_pRendererInfo->m_bInterruptSafe);
- if (pEvent->IsPreSeekEvent() && bOkToSend)
- {
- SendPacket(pEvent);
- delete pEvent;
- }
- else
- {
- m_EventList.InsertEvent(pEvent);
- pEvent->m_pRendererInfo->m_ulNumberOfPacketsQueued++;
- }
- return theErr;
- }
- HX_RESULT HXPlayer::SendPacket(CHXEvent* pEvent)
- {
- HX_RESULT retVal = pEvent->m_pRendererInfo->m_pRenderer->OnPacket(pEvent->GetPacket(),
- pEvent->GetTimeOffset());
- if( retVal == HXR_OUTOFMEMORY )
- {
- Report( HXLOG_ERR, retVal, HXR_OK, "Ran out of memory in SendPacket", NULL );
- }
- return retVal;
- }
- BOOL
- HXPlayer::AreAllPacketsSent()
- {
- BOOL bAllSent = TRUE;
- CHXMapPtrToPtr::Iterator ndxSource = m_pSourceMap->Begin();
- for (; ndxSource != m_pSourceMap->End(); ++ndxSource)
- {
- SourceInfo* pSourceInfo = (SourceInfo*)(*ndxSource);
- if (pSourceInfo->m_pSource && pSourceInfo->m_pSource &&
- pSourceInfo->m_pSource->m_PacketBufferList.GetCount() > 0)
- {
- bAllSent = FALSE;
- break;
- }
- }
- bAllSent = bAllSent & (m_EventList.GetNumEvents() == 0);
- return bAllSent;
- }
- void
- HXPlayer::StopAllStreams(EndCode endCode)
- {
- /* If we do not have access to engine any more, it means it is the final
- * destruction and everything has been deleted by now
- */
- if (!m_pEngine)
- return;
- StopAllStreamsExt(endCode);
- m_bIsDone = TRUE;
- if (m_bInStop)
- return;
- m_bInStop = TRUE;
- m_bIsPlaying = FALSE;
- /* stop timeline */
- m_pAudioPlayer->Stop(TRUE);
- m_bPendingAudioPause = FALSE;
- #if defined(HELIX_FEATURE_STATS) && defined(HELIX_FEATURE_REGISTRY)
- if (m_pUpdateStatsCallback->m_bIsCallbackPending)
- {
- m_pUpdateStatsCallback->m_bIsCallbackPending = FALSE;
- m_pScheduler->Remove(m_pUpdateStatsCallback->m_PendingHandle);
- m_pUpdateStatsCallback->m_PendingHandle = 0;
- }
- #endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */
- RemovePendingCallback(m_pHXPlayerCallback);
- RemovePendingCallback(m_pHXPlayerInterruptCallback);
- RemovePendingCallback(m_pSetupCallback);
- #if defined(HELIX_FEATURE_AUTHENTICATION)
- ClearPendingAuthenticationRequests();
- #endif /* HELIX_FEATURE_AUTHENTICATION */
- m_bCloseAllRenderersPending = TRUE;
- CHXMapPtrToPtr::Iterator ndxSource = m_pSourceMap->Begin();
- for (; ndxSource != m_pSourceMap->End(); ++ndxSource)
- {
- SourceInfo* pSourceInfo = (SourceInfo *) (*ndxSource);
- //{FILE* f1 = ::fopen("c:\temp\ts.txt", "a+"); ::fprintf(f1, "%p pSourceInfo::Stop, ThreadID: %lun", pSourceInfo, GetCurrentThreadId());::fclose(f1);}
- pSourceInfo->Stop(endCode);
- if (pSourceInfo->m_pPeerSourceInfo)
- {
- pSourceInfo->m_pPeerSourceInfo->Stop(endCode);
- }
- }
- DeleteAllEvents();
- if (m_bIsPresentationClosedToBeSent)
- {
- m_bIsPresentationClosedToBeSent = FALSE;
- if (m_pAdviseSink)
- {
- m_pAdviseSink->OnStop();
- m_pAdviseSink->OnPresentationClosed();
- }
- }
- m_bInStop = FALSE;
- m_bCurrentPresentationClosed = TRUE;
- }
- HX_RESULT
- HXPlayer::StopAllStreamsExt(EndCode endCode)
- {
- return HXR_OK;
- }
- HX_RESULT
- HXPlayer::SendPreSeekEventsExt()
- {
- return HXR_OK;
- }
- SourceInfo*
- HXPlayer::NewSourceInfo(void)
- {
- return (new SourceInfo(this));
- }
- HXFileSource*
- HXPlayer::NewFileSource(void)
- {
- #if defined(HELIX_FEATURE_PLAYBACK_LOCAL)
- return (new HXFileSource());
- #else
- return NULL;
- #endif /* #if defined(HELIX_FEATURE_PLAYBACK_LOCAL) */
- }
- HXNetSource*
- HXPlayer::NewNetSource(void)
- {
- #if defined(HELIX_FEATURE_PLAYBACK_NET)
- return (new HXNetSource());
- #else
- return NULL;
- #endif /* #if defined(HELIX_FEATURE_PLAYBACK_NET) */
- }
- void
- HXPlayer::CloseAllRenderers(INT32 nGroupSwitchTo)
- {
- CHXMapPtrToPtr::Iterator ndxSource = m_pSourceMap->Begin();
- for (; ndxSource != m_pSourceMap->End(); ++ndxSource)
- {
- SourceInfo* pSourceInfo = (SourceInfo*)(*ndxSource);
- if (pSourceInfo->m_pPeerSourceInfo)
- {
- pSourceInfo->m_pPeerSourceInfo->CloseRenderers();
- HX_DELETE(pSourceInfo->m_pPeerSourceInfo);
- }
- if (pSourceInfo->CloseRenderers() == HXR_OK)
- {
- HX_DELETE(pSourceInfo);
- }
- }
- m_pSourceMap->RemoveAll();
- m_bSourceMapUpdated = TRUE;
- #if defined(HELIX_FEATURE_NESTEDMETA)
- if (m_pPersistentComponentManager)
- {
- m_pPersistentComponentManager->CloseAllRenderers(nGroupSwitchTo);
- }
- #else
- CleanupLayout();
- #endif /* HELIX_FEATURE_NESTEDMETA */
- #ifdef _MACINTOSH
- unsigned long lastFree = ::TempFreeMem();
- long deltaFree = 1;
- long iterationCount = 0;
- while (deltaFree > 0 && iterationCount < 5)
- {
- HXMM_COMPACT();
- unsigned long curFree = ::TempFreeMem();
- deltaFree = curFree - lastFree;
- lastFree = curFree;
- iterationCount++;
- }
- #endif
- m_bCloseAllRenderersPending = FALSE;
- }
- /* Reset the player condition
- * Remove all sources and re-initialize all variables...
- */
- void
- HXPlayer::ResetPlayer(void)
- {
- if (m_pCookies)
- {
- #if defined(HELIX_FEATURE_COOKIES)
- m_pCookies->SyncRMCookies(TRUE);
- #endif /* defined(HELIX_FEATURE_COOKIES) */
- }
- EmptyBeginList();
- ResetGroup();
- if (m_pAltURLs)
- {
- m_pAltURLs->RemoveAll();
- }
- #if defined(HELIX_FEATURE_BASICGROUPMGR)
- if (m_pGroupManager && m_pGroupManager->GetGroupCount() > 0)
- {
- m_pGroupManager->RemoveAllGroup();
- }
- #endif /* HELIX_FEATURE_BASICGROUPMGR */
- #if defined(HELIX_FEATURE_NEXTGROUPMGR)
- if (m_pNextGroupManager)
- {
- m_pNextGroupManager->Cleanup();
- }
- #endif /* HELIX_FEATURE_NEXTGROUPMGR */
- #if defined(HELIX_FEATURE_PREFETCH)
- if (m_pPrefetchManager)
- {
- m_pPrefetchManager->Cleanup();
- }
- #endif /* HELIX_FEATURE_PREFETCH */
- #if defined(HELIX_FEATURE_NESTEDMETA)
- if (m_pPersistentComponentManager)
- {
- m_pPersistentComponentManager->Reset();
- }
- #endif /* HELIX_FEATURE_NESTEDMETA */
- m_bSetupLayoutSiteGroup = TRUE;
- m_bIsDone = TRUE;
- m_bIsPresentationDone = TRUE;
- m_bPlayerWithoutSources = FALSE;
- m_bPartOfNextGroup = FALSE;
- m_bLastGroup = FALSE;
- m_bNextGroupStarted = FALSE;
- m_bUserHasCalledBegin = FALSE;
- m_bSourceMapUpdated = FALSE;
- m_bPrefTransportInitialized = FALSE;
- m_bAddLayoutSiteGroupCalled = FALSE;
- if (!m_bDoRedirect && !m_bBeginChangeLayoutTobeCalled)
- {
- m_bBeginChangeLayoutTobeCalled = TRUE;
- #if defined(HELIX_FEATURE_VIDEO)
- if (m_pSiteSupplier)
- {
- m_pSiteSupplier->DoneChangeLayout();
- }
- #endif /* HELIX_FEATURE_VIDEO */
- }
- #if defined(HELIX_FEATURE_ASM)
- if (m_pBandwidthMgr)
- {
- m_pBandwidthMgr->PresentationDone();
- }
- #endif /* HELIX_FEATURE_ASM */
- if (m_bPlayStateNotified && m_pEngine)
- {
- m_bPlayStateNotified = FALSE;
- m_pEngine->NotifyPlayState(m_bPlayStateNotified);
- }
- #if defined(HELIX_FEATURE_VIDEO)
- if (m_pSiteManager)
- {
- m_pSiteManager->NeedFocus(FALSE);
- }
- #endif /* HELIX_FEATURE_VIDEO */
- #if defined(HELIX_FEATURE_PLAYBACK_NET) && !defined(_SYMBIAN) && !defined(_OPENWAVE)
- /* Clean DNS cache */
- conn::clear_cache();
- #endif /* HELIX_FEATURE_PLAYBACK_NET */
- /* Compact memory pools now that we are done with a presentation */
- #ifdef _MACINTOSH
- unsigned long lastFree = ::TempFreeMem();
- long deltaFree = 1;
- long iterationCount = 0;
- while (deltaFree > 0 && iterationCount < 5)
- {
- HXMM_COMPACT();
- unsigned long curFree = ::TempFreeMem();
- deltaFree = curFree - lastFree;
- lastFree = curFree;
- iterationCount++;
- }
- #endif
- }
- /* Before playing the next group
- * reset everything ResetPlayer does except .
- */
- void
- HXPlayer::ResetGroup(void)
- {
- m_uNumSourcesActive = 0;
- m_uNumCurrentSourceNotDone = 0;
- m_bInitialized = FALSE;
- m_bSetupLayoutSiteGroup = TRUE;
- m_ulCurrentPlayTime = 0;
- #if defined(_MACINTOSH)
- m_ulCurrentSystemPlayTime = 0;
- #endif
- m_ulPresentationDuration = 0;
- m_ulTimeBeforeSeek = 0;
- m_ulTimeAfterSeek = 0;
- m_BufferingReason = BUFFERING_START_UP;
- m_bIsDone = FALSE;
- m_bPaused = FALSE;
- m_bBeginPending = FALSE;
- m_bTimelineToBeResumed = FALSE;
- m_bIsPlaying = FALSE;
- m_bSetupToBeDone = FALSE;
- m_bPostSetupToBeDone = FALSE;
- /* default DEFAULT_TIMESYNC_GRANULARITY ms timesyncs are
- * given to renderers
- */
- m_ulLowestGranularity = DEFAULT_TIMESYNC_GRANULARITY;
- m_bIsFirstBegin = TRUE;
- m_bIsLive = FALSE;
- m_LastError = HXR_OK;
- m_ulMinimumAudioPreroll = 0;
- m_bInternalPauseResume = FALSE;
- m_bInternalReset = FALSE;
- m_bContactingDone = FALSE;
- m_bIsFirstTimeSync = TRUE;
- m_ulFirstTimeSync = 0;
- m_ulElapsedPauseTime = 0;
- m_ulLiveSeekTime = 0;
- m_ulTimeOfPause = 0;
- m_bLiveSeekToBeDone = FALSE;
- m_bFastStartInProgress = FALSE;
- m_ulFSBufferingEndTime = 0;
- m_bFSBufferingEnd = FALSE;
- m_b100BufferingToBeSent = TRUE;
- m_uNumSourceToBeInitializedBeforeBegin = 0;
- m_bAllLocalSources = TRUE;
- m_bResumeOnlyAtSystemTime = FALSE;
- #if defined(HELIX_FEATURE_PREFETCH)
- if (m_pPrefetchManager)
- {
- m_pPrefetchManager->Cleanup();
- HX_DELETE(m_pPrefetchManager);
- }
- #endif /* HELIX_FEATURE_PREFETCH */
- HX_RELEASE(m_pCurrentGroup);
- while (m_pPendingTrackList && m_pPendingTrackList->GetCount() > 0)
- {
- PendingTrackInfo* pPendingTrackInfo =
- (PendingTrackInfo*) m_pPendingTrackList->RemoveHead();
- delete pPendingTrackInfo;
- }
- }
- /************************************************************************
- * Method:
- * HXPlayer::ReportError
- * Purpose:
- * The source object reports of any fatal errors.
- *
- */
- void
- HXPlayer::ReportError
- (
- HXSource* pSource,
- HX_RESULT theErr,
- const char* pUserString
- )
- {
- SourceInfo* pSourceInfo = NULL;
- BOOL bDefault = FALSE;
- char* pAltURL = NULL;
- CHXURL* pURL = NULL;
- if (pSource && theErr != HXR_DNR && theErr != HXR_PROXY_DNR)
- {
- pURL = pSource->GetCHXURL();
- // Alt-URL only in network playback mode
- if (pURL &&
- (m_pSourceMap->Lookup(pSource, (void*&)pSourceInfo))
- #if defined(HELIX_FEATURE_NEXTGROUPMGR)
- || (m_pNextGroupManager &&
- m_pNextGroupManager->Lookup(pSource, pSourceInfo))
- #endif /* HELIX_FEATURE_NEXTGROUPMGR */
- #if defined(HELIX_FEATURE_PREFETCH)
- || (m_pPrefetchManager &&
- m_pPrefetchManager->Lookup(pSource, pSourceInfo))
- #endif /* HELIX_FEATURE_PREFETCH */
- )
- {
- if (pSourceInfo && pSourceInfo->m_bAltURL)
- {
- ResetError();
- /* If this error is for the next group, we do not want to
- * display the error in the current group playback. Instead,
- * pass it to the next group manager (by falling out of this
- * if condition) so that it can be displayed when the next
- * group is played
- */
- if (!pSourceInfo->m_pSource ||
- (!pSourceInfo->m_pSource->IsPartOfNextGroup() &&
- !pSourceInfo->m_pSource->IsPartOfPrefetchGroup()))
- {
- // return the last error from the main URL instead
- Report(HXLOG_ERR, pSourceInfo->m_lastErrorFromMainURL,
- HXR_OK, pSourceInfo->m_lastErrorStringFromMainURL, NULL);
- goto cleanup;
- }
- else
- {
- /* Use the error from the main URL even for the next group */
- theErr = pSourceInfo->m_lastErrorFromMainURL;
- pUserString = pSourceInfo->m_lastErrorStringFromMainURL;
- /* Fall through to report this error to the
- * next group manager
- */
- }
- }
- #if defined(HELIX_FEATURE_ALT_URL)
- // switch to Alt-URL when:
- // * the network playback has succeeded in this session or
- // the network playback is in HTTP Cloaking mode
- // AND
- // * the pSource is at SourceMap OR
- // * the pSource is at the NextGroupManager
- else if ((theErr != HXR_NOT_AUTHORIZED) &&
- !IS_SERVER_ALERT(theErr) &&
- pURL->IsNetworkProtocol() &&
- (pAltURL = pSource->GetAltURL(bDefault)))
- {
- if (!m_pAltURLs)
- {
- m_pAltURLs = new CHXSimpleList();
- }
- if (!m_pAltURLs->Find(pSourceInfo))
- {
- pSourceInfo->m_lastErrorFromMainURL = theErr;
- pSourceInfo->m_lastErrorStringFromMainURL = pUserString;
- m_pAltURLs->AddTail(pSourceInfo);
- }
- goto cleanup;
- }
- #endif /* HELIX_FEATURE_ALT_URL */
- }
- }
- #if defined(HELIX_FEATURE_NEXTGROUPMGR)
- /* Check if this error is for the next group */
- if (m_pNextGroupManager &&
- m_pNextGroupManager->ReportError(pSource, theErr, pUserString))
- {
- goto cleanup;
- }
- #endif /* HELIX_FEATURE_NEXTGROUPMGR */
- Report(HXLOG_ERR, theErr, HXR_OK, pUserString, NULL);
- cleanup:
- HX_VECTOR_DELETE(pAltURL);
- return;
- }
- HX_RESULT HXPlayer::InitializeNetworkDrivers(void)
- {
- #if defined(HELIX_FEATURE_PLAYBACK_NET)
- if (!m_bNetInitialized)
- {
- #if defined( _WIN32 ) || defined( _WINDOWS )
- // Have we been able to load and initialize the winsock stuff yet?
- m_bNetInitialized = win_net::IsWinsockAvailable(this);
- #elif defined (_MACINTOSH)
- m_bNetInitialized = (conn::init_drivers(NULL) == HXR_OK);
- #elif defined(_UNIX) || defined(_SYMBIAN) || defined(__TCS__) || defined(_OPENWAVE)
- m_bNetInitialized = TRUE;
- #endif
- }
- return (m_bNetInitialized) ? HXR_OK : HXR_GENERAL_NONET;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_PLAYBACK_NET */
- }
- void
- HXPlayer::EventOccurred(HXxEvent* pEvent)
- {
- // Note: Unix player does not go through here.
- // calls for UNIX go directly from Client Engine to
- // Site Window class
- #if defined (_MACINTOSH) || defined(_MAC_UNIX)
- // if (HXMM_RAHUL_CHECK())
- // {
- // DebugStr("pEventOccurred SYSTEM Task ENTER;g");
- // }
- #ifdef _MACINTOSH
- extern ULONG32 gTIMELINE_MUTEX;
- InterlockedIncrement(&gTIMELINE_MUTEX);
- #endif
- if (pEvent->event == nullEvent && m_bIsPlaying)
- {
- ULONG32 ulAudioTime = m_pAudioPlayer->GetCurrentPlayBackTime();
- if ( m_ulCurrentSystemPlayTime != ulAudioTime )
- {
- OnTimeSync( ulAudioTime );
- }
- }
- #ifdef _MACINTOSH
- InterlockedDecrement(&gTIMELINE_MUTEX);
- #endif
- // if (HXMM_RAHUL_CHECK())
- // {
- // DebugStr("pEventOccurred SYSTEM Task LEAVE;g");
- // }
- #endif
- }
- #ifdef _UNIX
- void
- HXPlayer::CollectSelectInfo(INT32* n,
- fd_set* readfds,
- fd_set* writefds,
- fd_set* exceptfds,
- struct timeval* tv)
- {
- }
- void
- HXPlayer::ProcessSelect(INT32* n,
- fd_set* readfds,
- fd_set* writefds,
- fd_set* exceptfds,
- struct timeval* tv)
- {
- }
- #endif
- void
- HXPlayer::SetGranularity(ULONG32 ulGranularity)
- {
- if (m_ulLowestGranularity > ulGranularity)
- {
- m_ulLowestGranularity = ulGranularity;
- }
- /* sanity check */
- if (m_ulLowestGranularity < MINIMUM_TIMESYNC_GRANULARITY)
- {
- m_ulLowestGranularity = MINIMUM_TIMESYNC_GRANULARITY;
- }
- }
- HX_RESULT
- HXPlayer::SetGranularity(HXSource* pSource, UINT16 uStreamNumber,
- UINT32 ulGranularity)
- {
- SourceInfo* pSourceInfo = pSource->m_pSourceInfo;
- RendererInfo* pRendInfo = NULL;
- HX_ASSERT(pSourceInfo);
- if (!pSourceInfo->m_pRendererMap->Lookup((LONG32) uStreamNumber, (void*&) pRendInfo))
- {
- HX_ASSERT(FALSE);
- return HXR_INVALID_PARAMETER;
- }
- pRendInfo->m_ulGranularity = ulGranularity;
- /* sanity check */
- if (pRendInfo->m_ulGranularity < MINIMUM_TIMESYNC_GRANULARITY)
- {
- pRendInfo->m_ulGranularity = MINIMUM_TIMESYNC_GRANULARITY;
- }
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * HXPlayer::ClosePlayer
- * Purpose:
- * Just adding a lock around calls to Close()
- *
- */
- void HXPlayer::ClosePlayer(void)
- {
- m_bCoreLocked = TRUE;
- m_pCoreMutex->Lock();
- Close();
- m_pCoreMutex->Unlock();
- m_bCoreLocked = FALSE;
- }
- void
- HXPlayer::AbortPlayer(void)
- {
- // Stop completely...
- m_bIsPresentationClosedToBeSent = TRUE;
- m_bIsDone = TRUE;
- StopPlayer(END_ABORT);
- #if defined(HELIX_FEATURE_VIDEO)
- /*
- * Let the site supplier know that we are done changing the layout.
- */
- if (m_pSiteSupplier && !m_bBeginChangeLayoutTobeCalled)
- {
- m_bBeginChangeLayoutTobeCalled = TRUE;
- m_pSiteSupplier->DoneChangeLayout();
- }
- #endif /* HELIX_FEATURE_VIDEO */
- }
- void
- HXPlayer::Close()
- {
- StopPlayer(END_STOP);
- CloseAllRenderers(m_nCurrentGroup);
- #if defined(HELIX_FEATURE_STATS) && defined(HELIX_FEATURE_REGISTRY)
- if (m_pRegistry)
- {
- // delete player stats
- if (m_pStats && m_pStats->m_ulRegistryID)
- {
- m_pRegistry->DeleteById(m_pStats->m_ulRegistryID);
- }
- HX_DELETE(m_pStats);
- // delete repeat stats
- if (m_ulRepeatedRegistryID)
- {
- m_pRegistry->DeleteById(m_ulRepeatedRegistryID);
- m_ulRepeatedRegistryID = 0;
- }
- // delete nextgroup stats
- if (m_ulNextGroupRegistryID)
- {
- m_pRegistry->DeleteById(m_ulNextGroupRegistryID);
- m_ulNextGroupRegistryID = 0;
- }
- }
- if (m_pUpdateStatsCallback)
- {
- if (m_pUpdateStatsCallback->m_bIsCallbackPending)
- {
- m_pUpdateStatsCallback->m_bIsCallbackPending = FALSE;
- m_pScheduler->Remove(m_pUpdateStatsCallback->m_PendingHandle);
- m_pUpdateStatsCallback->m_PendingHandle = 0;
- }
- HX_RELEASE(m_pUpdateStatsCallback);
- }
- #endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */
- if (m_bIsPresentationClosedToBeSent)
- {
- m_bIsPresentationClosedToBeSent = FALSE;
- if (m_pAdviseSink)
- {
- m_pAdviseSink->OnStop();
- m_pAdviseSink->OnPresentationClosed();
- }
- }
- HX_RELEASE (m_pAdviseSink);
- RemovePendingCallback(m_pHXPlayerCallback);
- HX_RELEASE(m_pHXPlayerCallback);
- RemovePendingCallback(m_pHXPlayerInterruptCallback);
- HX_RELEASE(m_pHXPlayerInterruptCallback);
- RemovePendingCallback(m_pSetupCallback);
- HX_RELEASE(m_pSetupCallback);
- #if defined(HELIX_FEATURE_AUTHENTICATION)
- if (m_pAuthenticationCallback)
- {
- ClearPendingAuthenticationRequests();
- HX_RELEASE(m_pAuthenticationCallback);
- }
- #endif /* HELIX_FEATURE_AUTHENTICATION */
- HX_RELEASE(m_pAutheticationValues);
- HX_RELEASE(m_pRequest);
- ResetRedirectList();
- HX_DELETE (m_pRedirectList);
- HX_DELETE (m_pURL);
- HX_DELETE (m_pAltURLs);
- #if defined(HELIX_FEATURE_REGISTRY)
- HX_RELEASE (m_pRegistry);
- #endif /* HELIX_FEATURE_REGISTRY */
- HX_RELEASE (m_pEngine);
- HX_RELEASE (m_pClient);
- HX_RELEASE (m_pScheduler);
- if (m_pErrorSinkControl)
- {
- #if defined(HELIX_FEATURE_SINKCONTROL)
- m_pErrorSinkControl->Close();
- #endif /* HELIX_FEATURE_SINKCONTROL */
- HX_RELEASE (m_pErrorSinkControl);
- }
- HX_RELEASE(m_pClientRequestSink);
- #if defined(HELIX_FEATURE_PREFERENCES)
- HX_RELEASE (m_pPreferences);
- #endif /* HELIX_FEATURE_PREFERENCES */
- #if defined(HELIX_FEATURE_HYPER_NAVIGATE)
- if (m_pHyperNavigate)
- {
- #if defined(HELIX_FEATURE_HYPER_NAVIGATE)
- m_pHyperNavigate->Close();
- #endif /* defined(HELIX_FEATURE_HYPER_NAVIGATE) */
- HX_RELEASE (m_pHyperNavigate);
- }
- #endif /* HELIX_FEATURE_HYPER_NAVIGATE */
- #if defined(HELIX_FEATURE_BASICGROUPMGR)
- if (m_pGroupManager)
- {
- m_pGroupManager->RemoveSink(this);
- #if defined(HELIX_FEATURE_NESTEDMETA)
- m_pGroupManager->RemoveSink(m_pPersistentComponentManager);
- #endif /* HELIX_FEATURE_NESTEDMETA */
- HX_RELEASE(m_pGroupManager);
- }
- #endif /* HELIX_FEATURE_BASICGROUPMGR */
- #if defined(HELIX_FEATURE_VIDEO)
- HX_RELEASE (m_pSiteManager);
- HX_RELEASE (m_pSiteSupplier);
- #endif /* HELIX_FEATURE_VIDEO */
- #if defined(HELIX_FEATURE_AUTOUPGRADE)
- HX_RELEASE (m_pUpgradeCollection);
- #endif /* HELIX_FEATURE_AUTOUPGRADE */
- #if defined(HELIX_FEATURE_PACKETHOOKMGR)
- HX_RELEASE (m_pPacketHookManager);
- #endif /* HELIX_FEATURE_PACKETHOOKMGR */
- #if defined(HELIX_FEATURE_SMARTERNETWORK)
- HX_RELEASE (m_pPreferredTransportManager);
- #endif /* HELIX_FEATURE_SMARTERNETWORK */
- HX_RELEASE (m_pNetInterfaces);
- HX_RELEASE (m_pClientViewSource);
- HX_RELEASE (m_pViewPortManager);
- HX_RELEASE (m_pClientViewRights);
- #if defined(HELIX_FEATURE_MEDIAMARKER)
- if (m_pMediaMarkerManager)
- {
- m_pMediaMarkerManager->Close();
- HX_RELEASE(m_pMediaMarkerManager);
- }
- #endif /* #if defined(HELIX_FEATURE_MEDIAMARKER) */
- #if defined(HELIX_FEATURE_EVENTMANAGER)
- if (m_pEventManager)
- {
- m_pEventManager->Close();
- HX_RELEASE(m_pEventManager);
- }
- #endif /* #if defined(HELIX_FEATURE_EVENTMANAGER) */
- #if defined(HELIX_FEATURE_NESTEDMETA)
- if (m_pPersistentComponentManager)
- {
- m_pPersistentComponentManager->Close();
- HX_RELEASE (m_pPersistentComponentManager);
- }
- #endif /* HELIX_FEATURE_NESTEDMETA */
- #if defined(HELIX_FEATURE_AUDIO)
- if (m_pAudioPlayer)
- {
- CHXAudioSession* pAudioSession = m_pAudioPlayer->GetOwner();
- if (pAudioSession)
- {
- pAudioSession->CloseAudioPlayer(m_pAudioPlayer);
- }
- HX_RELEASE (m_pAudioPlayer);
- }
- #endif /* HELIX_FEATURE_AUDIO */
- if (m_pMasterTAC)
- {
- #if defined(HELIX_FEATURE_MASTERTAC)
- m_pMasterTAC->Close();
- #endif /* HELIX_FEATURE_MASTERTAC */
- HX_RELEASE(m_pMasterTAC);
- }
- #if defined(HELIX_FEATURE_PREFETCH)
- HX_DELETE(m_pPrefetchManager);
- #endif /* HELIX_FEATURE_PREFETCH */
- #if defined(HELIX_FEATURE_NEXTGROUPMGR)
- HX_DELETE(m_pNextGroupManager);
- #endif /* HELIX_FEATURE_NEXTGROUPMGR */
- #if defined(HELIX_FEATURE_ASM)
- if (m_pBandwidthMgr)
- {
- m_pBandwidthMgr->PresentationDone();
- HX_RELEASE(m_pBandwidthMgr);
- }
- #endif /* HELIX_FEATURE_ASM */
- #if defined(HELIX_FEATURE_ASM)
- HX_RELEASE(m_pASM);
- #endif /* HELIX_FEATURE_ASM */
- HX_ASSERT(!m_pPendingTrackList || m_pPendingTrackList->IsEmpty());
- HX_DELETE(m_pPendingTrackList);
- if (m_pChildPlayerList)
- {
- CHXSimpleList::Iterator i = m_pChildPlayerList->Begin();
- for (; i != m_pChildPlayerList->End(); ++i)
- {
- IHXPlayer* pChildPlayer = (IHXPlayer*)(*i);
- HX_RELEASE(pChildPlayer);
- }
- HX_DELETE(m_pChildPlayerList);
- }
- HX_RELEASE(m_pParentPlayer);
- #if defined(HELIX_FEATURE_PLAYBACK_NET)
- if (m_bNetInitialized)
- {
- m_bNetInitialized = FALSE;
- #if defined( _WIN32 ) || defined( _WINDOWS )
- win_net::ReleaseWinsockUsage(this);
- #endif /* defined( _WIN32 ) || defined( _WINDOWS ) */
- }
- #endif /* HELIX_FEATURE_PLAYBACK_NET */
- #if defined(_DEBUG) && defined(DEBUG_LOG_INFO)
- HXStaticStatLog::Close();
- #endif // DEBUG_LOG_INFO
- HX_RELEASE(m_pPlugin2Handler);
- #if defined(HELIX_FEATURE_RECORDCONTROL)
- UnloadRecordService();
- #endif /* HELIX_FEATURE_RECORDCONTROL */
- ResetError();
- }
- void
- HXPlayer::ProcessPendingAuthentication(void)
- {
- #if defined(HELIX_FEATURE_AUTHENTICATION)
- IHXAuthenticationManager2* pAuthenticationManagerClient2 = NULL;
- if (HXR_OK == m_pClient->QueryInterface(IID_IHXAuthenticationManager2,
- (void**)&pAuthenticationManagerClient2))
- {
- HX_ASSERT(pAuthenticationManagerClient2);
- if (pAuthenticationManagerClient2)
- {
- pAuthenticationManagerClient2->HandleAuthenticationRequest2(this, m_pAutheticationValues);
- }
- HX_RELEASE(pAuthenticationManagerClient2);
- return;
- }
- // otherwise continue with the old-fashioned authentication manager
- IHXAuthenticationManager* pAuthenticationManagerClient = NULL;
- m_pClient->QueryInterface(IID_IHXAuthenticationManager,
- (void**)&pAuthenticationManagerClient);
- HX_ASSERT(pAuthenticationManagerClient);
- if (pAuthenticationManagerClient)
- {
- pAuthenticationManagerClient->HandleAuthenticationRequest(this);
- }
- HX_RELEASE(pAuthenticationManagerClient);
- #endif /* HELIX_FEATURE_AUTHENTICATION */
- }
- void
- HXPlayer::ClearPendingAuthenticationRequests(void)
- {
- #if defined(HELIX_FEATURE_AUTHENTICATION)
- m_AuthenticationRequestsPending.ClearPendingList();
- RemovePendingCallback(m_pAuthenticationCallback);
- /* Remove all pending authentication requests TBD */
- #endif /* HELIX_FEATURE_AUTHENTICATION */
- }
- STDMETHODIMP
- HXPlayer::HandleAuthenticationRequest(
- IHXAuthenticationManagerResponse* pResponse)
- {
- #if defined(HELIX_FEATURE_AUTHENTICATION)
- return HandleAuthenticationRequest2( pResponse, NULL );
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_AUTHENTICATION */
- }
- STDMETHODIMP
- HXPlayer::HandleAuthenticationRequest2(
- IHXAuthenticationManagerResponse* pResponse, IHXValues* pValues)
- {
- #if defined(HELIX_FEATURE_AUTHENTICATION)
- IHXValues* pHeader = NULL;
- IHXBuffer* pUserName = NULL;
- IHXBuffer* pPassword = NULL;
- ULONG32 ulAuthenticationAttempts = 0;
- HX_RELEASE(m_pAutheticationValues);
- m_pAutheticationValues = pValues;
- if (m_pAutheticationValues)
- {
- m_pAutheticationValues->AddRef();
- }
- /* Username/Password in the url will not work for tracks within
- * SMIL/RAM files.
- * This is because the m_pURL points to the last opened track
- * in the presentation and may not point to the URL for which
- * the authentication has been requested for.
- * This is tricky to fix --- post B2 - XXXRA
- */
- // Get info about the URL
- if (m_pURL)
- {
- pHeader = m_pURL->GetProperties();
- }
- if (pHeader)
- {
- // Try to get the username and password from the URL
- pHeader->GetPropertyBuffer(PROPERTY_USERNAME, pUserName);
- pHeader->GetPropertyBuffer(PROPERTY_PASSWORD, pPassword);
- // Try to get the number of times we've tried to authenticate
- // already based on this name and password
- HX_RESULT res = pHeader->GetPropertyULONG32("AUTHENTICATION_ATTEMPTS", ulAuthenticationAttempts);
- }
- // First check to see if a username and/or password were supplied in the URL. If they were there is no need to pass
- // this on to the client to display any UI.
- // (And in case the wrong name/password were supplied, don't let them try too many times.)
- if (pUserName && pPassword && (ulAuthenticationAttempts < 3))
- {
- if (pHeader)
- {
- pHeader->SetPropertyULONG32("AUTHENTICATION_ATTEMPTS", ulAuthenticationAttempts + 1);
- }
- pResponse->AuthenticationRequestDone(HXR_OK, (const char*)pUserName->GetBuffer(), (const char*)pPassword->GetBuffer());
- }
- else
- {
- #ifndef _WIN16
- m_AuthenticationRequestsPending.Add(this, pResponse, pValues);
- #else
- IHXAuthenticationManager2* pAuthenticationManagerClient2 = NULL;
- if (HXR_OK == m_pClient->QueryInterface(IID_IHXAuthenticationManager2, (void**)&pAuthenticationManagerClient2))
- {
- pAuthenticationManagerClient2->HandleAuthenticationRequest2
- (
- pResponse, pValues
- );
- HX_RELEASE(pAuthenticationManagerClient2);
- }
- else
- {
- // if the new authentication manager isn't available, use the old authentication manager.
- IHXAuthenticationManager* pAuthenticationManagerClient = NULL;
- m_pClient->QueryInterface
- (
- IID_IHXAuthenticationManager,
- (void**)&pAuthenticationManagerClient
- );
- pAuthenticationManagerClient->HandleAuthenticationRequest
- (
- pResponse
- );
- HX_RELEASE(pAuthenticationManagerClient);
- }
- #endif /* _WIN16 */
- }
- HX_RELEASE(pUserName);
- HX_RELEASE(pPassword);
- HX_RELEASE(pHeader);
- #endif /* HELIX_FEATURE_AUTHENTICATION */
- return HXR_OK;
- }
- // IHXAuthenticationManagerResponse
- STDMETHODIMP
- HXPlayer::AuthenticationRequestDone
- (
- HX_RESULT result,
- const char* user,
- const char* password
- )
- {
- #if !defined(_WIN16) && defined(HELIX_FEATURE_AUTHENTICATION)
- return m_AuthenticationRequestsPending.SatisfyPending
- (
- result,
- user,
- password
- );
- #else
- return HXR_NOTIMPL;
- #endif /* _WIN16 */
- }
- /*
- * IHXViewSourceCommand::CanViewSouce
- */
- STDMETHODIMP_(BOOL)
- HXPlayer::CanViewSource(IHXStreamSource* pStream)
- {
- #if defined(HELIX_FEATURE_VIEWSOURCE)
- BOOL bRet = TRUE;
- HX_RESULT ret = HXR_OK;
- if ( m_pClientViewSource == NULL && m_pEngine )
- {
- m_pEngine->QueryInterface(IID_IHXClientViewSource,
- (void**)&m_pClientViewSource);
- }
- if ( m_pClientViewSource )
- {
- if ( pStream )
- {
- bRet = m_pClientViewSource->CanViewSource(pStream);
- }
- else
- {
- IHXStreamSource* pStrmSource = NULL;
- if ( GetViewSourceStream(pStrmSource) )
- {
- bRet = m_pClientViewSource->CanViewSource(pStrmSource);
- }
- else
- {
- bRet = FALSE;
- }
- HX_RELEASE(pStrmSource);
- }
- }
- else
- {
- bRet = FALSE;
- }
- return bRet;
- #else
- return FALSE;
- #endif
- }
- /*
- * IHXViewSourceCommand::DoViewSouce
- */
- STDMETHODIMP
- HXPlayer::DoViewSource(IHXStreamSource* pStream)
- {
- #if defined(HELIX_FEATURE_VIEWSOURCE)
- HX_RESULT ret = HXR_OK;
- if ( m_pClientViewSource == NULL && m_pEngine )
- {
- m_pEngine->QueryInterface(IID_IHXClientViewSource,
- (void**)&m_pClientViewSource);
- }
- if ( m_pClientViewSource )
- {
- if ( pStream )
- {
- ret = m_pClientViewSource->DoViewSource((IUnknown*)(IHXPlayer*)this, pStream);
- }
- else
- {
- IHXStreamSource* pStrmSource = NULL;
- if ( GetViewSourceStream(pStrmSource) )
- {
- ret = m_pClientViewSource->DoViewSource((IUnknown*)(IHXPlayer*)this,
- pStrmSource);
- }
- else
- {
- // pass null for the stream source -
- // will cause a no source error to be shown.
- ret = m_pClientViewSource->DoViewSource(
- (IUnknown*)(IHXPlayer*)this, NULL);
- }
- HX_RELEASE(pStrmSource);
- }
- }
- else
- {
- ret = HXR_NOT_INITIALIZED;
- }
- return ret;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_AUTHENTICATION */
- }
- /*
- * IHXViewSourceCommand::GetViewSourceURL
- */
- STDMETHODIMP
- HXPlayer::GetViewSourceURL(IHXStreamSource* pStream, IHXViewSourceURLResponse* pResp)
- {
- #if defined(HELIX_FEATURE_VIEWSOURCE)
- HX_RESULT ret = HXR_OK;
- if ( m_pClientViewSource == NULL && m_pEngine )
- {
- m_pEngine->QueryInterface(IID_IHXClientViewSource,
- (void**)&m_pClientViewSource);
- }
- if ( m_pClientViewSource )
- {
- if ( pStream )
- {
- ret = m_pClientViewSource->GetViewSourceURL(
- (IUnknown*)(IHXPlayer*)this, pStream, pResp);
- }
- else
- {
- IHXStreamSource* pStrmSource = NULL;
- if ( GetViewSourceStream(pStrmSource) )
- {
- ret = m_pClientViewSource->GetViewSourceURL(
- (IUnknown*)(IHXPlayer*)this, pStrmSource, pResp);
- }
- else
- {
- ret = HXR_FAIL;
- }
- HX_RELEASE(pStrmSource);
- }
- }
- else
- {
- ret = HXR_NOT_INITIALIZED;
- }
- return ret;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_VIEWSOURCE */
- }
- BOOL
- HXPlayer::GetViewSourceStream(REF(IHXStreamSource*) pStrmSource)
- {
- BOOL bRet = FALSE;
- #if defined(HELIX_FEATURE_VIEWSOURCE)
- #if defined(HELIX_FEATURE_NESTEDMETA)
- HXPersistentComponent* pPersistentComponent = m_pPersistentComponentManager->m_pRootPersistentComponent;
- // not a persistent playback
- if (!pPersistentComponent)
- {
- HX_ASSERT(m_pSourceMap->GetCount() <= 1);
- if ( m_pSourceMap->GetCount() > 0 )
- {
- CHXMapPtrToPtr::Iterator ndxSource = m_pSourceMap->Begin();
- SourceInfo* pSourceInfo = (SourceInfo*)(*ndxSource);
- HX_ASSERT(pSourceInfo);
- HXSource* pSource = pSourceInfo->m_pSource;
- if( pSource )
- {
- HX_RELEASE(pStrmSource);
- if ( SUCCEEDED(pSource->QueryInterface(IID_IHXStreamSource,
- (void**)&pStrmSource)) )
- {
- bRet = TRUE;
- }
- }
- }
- }
- else
- {
- HXSource* pSource = pPersistentComponent->m_pSourceInfo->m_pSource;
- if ( pSource )
- {
- HX_RELEASE(pStrmSource);
- if ( SUCCEEDED(pSource->QueryInterface(IID_IHXStreamSource,
- (void**)&pStrmSource)) )
- {
- bRet = TRUE;
- }
- }
- }
- #else
- HX_ASSERT(m_pSourceMap->GetCount() <= 1);
- if ( m_pSourceMap->GetCount() > 0 )
- {
- CHXMapPtrToPtr::Iterator ndxSource = m_pSourceMap->Begin();
- SourceInfo* pSourceInfo = (SourceInfo*)(*ndxSource);
- HX_ASSERT(pSourceInfo);
- HXSource* pSource = pSourceInfo->m_pSource;
- if( pSource )
- {
- HX_RELEASE(pStrmSource);
- if ( SUCCEEDED(pSource->QueryInterface(IID_IHXStreamSource,
- (void**)&pStrmSource)) )
- {
- bRet = TRUE;
- }
- }
- }
- #endif /* HELIX_FEATURE_NESTEDMETA */
- #endif /* HELIX_FEATURE_VIEWSOURCE */
- return bRet;
- }
- HX_RESULT
- HXPlayer::GetSourceInfo(UINT16 uGroupIndex, UINT16 uTrackIndex, SourceInfo*& pSourceInfo)
- {
- #if defined(HELIX_FEATURE_BASICGROUPMGR)
- HX_RESULT hr = HXR_OK;
- SourceInfo* pTempSourceInfo = NULL;
- CHXMapPtrToPtr::Iterator ndxSource;
- pSourceInfo = NULL;
- if (uGroupIndex != m_nCurrentGroup)
- {
- hr = HXR_UNEXPECTED;
- goto cleanup;
- }
- // find the sourceinfo
- ndxSource = m_pSourceMap->Begin();
- for (; ndxSource != m_pSourceMap->End(); ++ndxSource)
- {
- pTempSourceInfo = (SourceInfo*)(*ndxSource);
- if (pTempSourceInfo->m_uTrackID == uTrackIndex)
- {
- pSourceInfo = pTempSourceInfo;
- break;
- }
- }
- if (!pSourceInfo)
- {
- hr = HXR_FAILED;
- }
- cleanup:
- return hr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_BASICGROUPMGR */
- }
- HX_RESULT
- HXPlayer::CopyRegInfo(UINT32 ulFromRegID, UINT32 ulToRegID)
- {
- #if defined(HELIX_FEATURE_REGISTRY)
- HX_RESULT hr = HXR_OK;
- const char* pPropName = NULL;
- ULONG32 ulPropId = 0;
- UINT32 ulRegId = 0;
- IHXBuffer* pFromRegName = NULL;
- IHXBuffer* pToRegName = NULL;
- IHXValues* pValues = NULL;
- char szRegName[MAX_DISPLAY_NAME] = {0}; /* Flawfinder: ignore */
- m_pRegistry->GetPropName(ulFromRegID, pFromRegName);
- m_pRegistry->GetPropName(ulToRegID, pToRegName);
- // Get the IHXValues under this id.
- m_pRegistry->GetPropListById(ulFromRegID, pValues);
- // PT_COMPOSITE without child
- if (!pValues)
- {
- return HXR_OK;
- }
- // iterate through the child list
- hr = pValues->GetFirstPropertyULONG32(pPropName, ulPropId);
- while (hr == HXR_OK)
- {
- HXPropType type = m_pRegistry->GetTypeById(ulPropId);
- SafeSprintf(szRegName, MAX_DISPLAY_NAME, "%s.%s", pToRegName->GetBuffer(),
- pPropName + pFromRegName->GetSize());
- if (type == PT_COMPOSITE)
- {
- ulRegId = m_pRegistry->AddComp(szRegName);
- CopyRegInfo(ulPropId, ulRegId);
- }
- else
- {
- switch(type)
- {
- case PT_INTEGER:
- {
- INT32 val;
- if(HXR_OK == m_pRegistry->GetIntById(ulPropId, val))
- {
- m_pRegistry->AddInt(szRegName, val);
- }
- break;
- }
- case PT_STRING:
- {
- IHXBuffer* pBuffer = NULL;
- if(HXR_OK == m_pRegistry->GetStrById(ulPropId,
- pBuffer))
- {
- m_pRegistry->AddStr(szRegName, pBuffer);
- }
- HX_RELEASE(pBuffer);
- break;
- }
- case PT_BUFFER:
- {
- IHXBuffer* pBuffer = NULL;
- if(HXR_OK == m_pRegistry->GetBufById(ulPropId,
- pBuffer))
- {
- m_pRegistry->AddBuf(szRegName, pBuffer);
- }
- HX_RELEASE(pBuffer);
- break;
- }
- default:
- break;
- }
- }
- hr = pValues->GetNextPropertyULONG32(pPropName, ulPropId);
- }
- HX_RELEASE(pFromRegName);
- HX_RELEASE(pToRegName);
- HX_RELEASE(pValues);
- #endif /* HELIX_FEATURE_REGISTRY */
- return HXR_OK;
- }
- HX_RESULT
- HXPlayer::UpdateTrack(UINT16 uGroupIndex, UINT16 uTrackIndex, IHXValues* pValues)
- {
- #if defined(HELIX_FEATURE_ADVANCEDGROUPMGR)
- HX_RESULT hr = HXR_OK;
- UINT16 uCurrentGroup = 0;
- UINT16 uNewTrackIndex = 0;
- UINT32 ulParentRegId = 0;
- SourceInfo* pSourceInfo = NULL;
- IHXGroup* pGroup = NULL;
- if (HXR_OK == pValues->GetPropertyULONG32("TrackIndex", (UINT32&)uNewTrackIndex))
- {
- if (uGroupIndex == m_nCurrentGroup &&
- HXR_OK == GetSourceInfo(uGroupIndex, uTrackIndex, pSourceInfo))
- {
- #if defined(HELIX_FEATURE_STATS) && defined(HELIX_FEATURE_REGISTRY)
- ulParentRegId = m_pStats->m_ulRegistryID;
- #endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */
- }
- #if defined (HELIX_FEATURE_NEXTGROUPMGR)
- else if (m_bNextGroupStarted &&
- m_pNextGroupManager->GetCurrentGroup(uCurrentGroup, pGroup) == HXR_OK &&
- uCurrentGroup == uGroupIndex)
- {
- m_pNextGroupManager->GetSource(uTrackIndex, pSourceInfo);
- ulParentRegId = m_ulNextGroupRegistryID;
- }
- #endif /* HELIX_FEATURE_NEXTGROUPMGR */
- if (pSourceInfo)
- {
- hr = UpdateSourceInfo(pSourceInfo,
- ulParentRegId,
- uNewTrackIndex);
- }
- }
- #if defined(HELIX_FEATURE_NESTEDMETA)
- m_pPersistentComponentManager->TrackUpdated(uGroupIndex, uTrackIndex, pValues);
- #endif /* HELIX_FEATURE_NESTEDMETA */
- return hr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_ADVANCEDGROUPMGR */
- }
- HX_RESULT
- HXPlayer::RemoveTrack(UINT16 uGroupIndex, UINT16 uTrackIndex, IHXValues* pValues)
- {
- #if defined(HELIX_FEATURE_ADVANCEDGROUPMGR)
- HX_RESULT hr = HXR_OK;
- UINT16 uCurrentGroup = 0;
- SourceInfo* pSourceInfo = NULL;
- IHXGroup* pGroup = NULL;
- // track removed from the current group
- if (uGroupIndex == m_nCurrentGroup &&
- HXR_OK == GetSourceInfo(uGroupIndex, uTrackIndex, pSourceInfo))
- {
- // remove source from the current group
- m_pSourceMap->RemoveKey(pSourceInfo->m_pSource);
- pSourceInfo->Remove();
- HX_DELETE(pSourceInfo);
- AdjustPresentationTime();
- m_bSourceMapUpdated = TRUE;
- m_bForceStatsUpdate = TRUE;
- }
- #if defined(HELIX_FEATURE_NEXTGROUPMGR)
- // track removed from the next group being prefetched
- else if (m_bNextGroupStarted &&
- m_pNextGroupManager->GetCurrentGroup(uCurrentGroup, pGroup) == HXR_OK &&
- uCurrentGroup == uGroupIndex)
- {
- if (HXR_OK == m_pNextGroupManager->GetSource(uTrackIndex, pSourceInfo))
- {
- m_pNextGroupManager->RemoveSource(pSourceInfo);
- pSourceInfo->Remove();
- HX_DELETE(pSourceInfo);
- }
- }
- #endif /* HELIX_FEATURE_NEXTGROUPMGR */
- return hr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_ADVANCEDGROUPMGR */
- }
- HX_RESULT
- HXPlayer::AddPrefetchTrack(UINT16 uGroupIndex,
- UINT16 uPrefetchTrackIndex,
- IHXValues* pTrack)
- {
- #if defined(HELIX_FEATURE_PREFETCH)
- HX_RESULT theErr = HXR_OK;
- char szDelay[] = "Delay";
- UINT32 ulDelay = 0;
- IHXGroup* pGroup = NULL;
- if (m_pGroupManager)
- {
- theErr = m_pGroupManager->GetGroup(uGroupIndex, pGroup);
- }
- /* Check if a track is added to the group currently played */
- if (uGroupIndex == m_nCurrentGroup && pGroup == m_pCurrentGroup)
- {
- /* If we are not yet initialized, add tracks to the current source
- * map only if the track is within the fudge factor.
- *
- * This is to fix a bug in SMIL file with multiple sources in seq
- * with outer par.
- * The expected behavior is to start the first source
- * in seq and then initialize the remaining sources. Since we were
- * adding additional tracks to the source map, the player was not
- * getting initialized until ALL the sources in the seq have been
- * initialized. This resulted in massive startup delays.
- */
- if (!m_bInitialized)
- {
- if ((HXR_OK != pTrack->GetPropertyULONG32(szDelay,ulDelay)) ||
- (ulDelay <= m_ulCurrentPlayTime + MIN_DELAYBEFORE_START))
- {
- theErr = OpenTrack(pTrack, uGroupIndex, uPrefetchTrackIndex);
- }
- else
- {
- if (!m_pPendingTrackList)
- {
- m_pPendingTrackList = new CHXSimpleList;
- }
- PendingTrackInfo* pPendingTrackInfo =
- new PendingTrackInfo(uGroupIndex, uPrefetchTrackIndex, pTrack);
- m_pPendingTrackList->AddTail(pPendingTrackInfo);
- }
- }
- else
- {
- theErr = OpenTrack(pTrack, uGroupIndex, uPrefetchTrackIndex);
- }
- if (theErr)
- {
- ReportError(NULL, theErr, NULL);
- }
- }
- // we don't support prefetch for the next group
- else
- {
- HX_ASSERT(FALSE);
- }
- HX_RELEASE(pGroup);
- return theErr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_PREFETCH */
- }
- HX_RESULT
- HXPlayer::UpdatePrefetchTrack(UINT16 uGroupIndex,
- UINT16 uPrefetchTrackIndex,
- IHXValues* pValues)
- {
- #if defined(HELIX_FEATURE_PREFETCH)
- HX_RESULT hr = HXR_OK;
- UINT16 uCurrentGroup = 0;
- UINT16 uNewTrackIndex = 0;
- SourceInfo* pSourceInfo = NULL;
- IHXGroup* pGroup = NULL;
- if (!m_pPrefetchManager)
- {
- hr = HXR_FAILED;
- goto cleanup;
- }
- if (HXR_OK == pValues->GetPropertyULONG32("TrackIndex", (UINT32&)uNewTrackIndex))
- {
- if (uGroupIndex == m_nCurrentGroup &&
- HXR_OK == m_pPrefetchManager->GetSource(uNewTrackIndex, pSourceInfo))
- {
- HX_ASSERT(pSourceInfo->m_uTrackID == uNewTrackIndex);
- }
- #if defined(HELIX_FEATURE_NEXTGROUPMGR)
- else if (m_bNextGroupStarted &&
- m_pNextGroupManager->GetCurrentGroup(uCurrentGroup, pGroup) == HXR_OK &&
- uCurrentGroup == uGroupIndex)
- {
- hr = HXR_NOTIMPL;
- }
- #endif /* HELIX_FEATURE_NEXTGROUPMGR */
- }
- cleanup:
- return hr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_PREFETCH */
- }
- HX_RESULT
- HXPlayer::RemovePrefetchTrack(UINT16 uGroupIndex,
- UINT16 uPrefetchTrackIndex,
- IHXValues* pValues)
- {
- #if defined(HELIX_FEATURE_PREFETCH)
- HX_RESULT theErr = HXR_OK;
- SourceInfo* pSourceInfo = NULL;
- if (m_pPrefetchManager &&
- m_pPrefetchManager->Lookup(pValues, pSourceInfo))
- {
- theErr = m_pPrefetchManager->RemoveSource(pSourceInfo);
- // cleanup if the prefetch track has not been activated
- if (pSourceInfo->m_pSource->IsPartOfPrefetchGroup())
- {
- pSourceInfo->Remove();
- HX_DELETE(pSourceInfo);
- }
- }
- return theErr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_PREFETCH */
- }
- HX_RESULT
- HXPlayer::PrefetchTrackDone(UINT16 uGroupIndex, UINT16 uPrefetchTrackIndex, HX_RESULT status)
- {
- #if defined(HELIX_FEATURE_PREFETCH)
- IHXGroup* pGroup = NULL;
- IHXPrefetchSink* pPrefetchSink = NULL;
- if (m_pGroupManager && HXR_OK == m_pGroupManager->GetGroup(uGroupIndex, pGroup))
- {
- if (HXR_OK == pGroup->QueryInterface(IID_IHXPrefetchSink, (void**)&pPrefetchSink))
- {
- pPrefetchSink->PrefetchTrackDone(uGroupIndex, uPrefetchTrackIndex, status);
- }
- HX_RELEASE(pPrefetchSink);
- }
- HX_RELEASE(pGroup);
- #endif /* HELIX_FEATURE_PREFETCH */
- return HXR_OK;
- }
- HX_RESULT
- HXPlayer::BeginTrack(UINT16 uGroupIndex, UINT16 uTrackIndex, IHXValues* pValues)
- {
- #if defined(HELIX_FEATURE_ADVANCEDGROUPMGR)
- HX_RESULT hr = HXR_OK;
- SourceInfo* pSourceInfo = NULL;
- // begin on the current group only
- if (uGroupIndex == m_nCurrentGroup &&
- HXR_OK == GetSourceInfo(uGroupIndex, uTrackIndex, pSourceInfo))
- {
- hr = pSourceInfo->BeginTrack();
- }
- else
- {
- hr = HXR_UNEXPECTED;
- }
- return hr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_ADVANCEDGROUPMGR */
- }
- HX_RESULT
- HXPlayer::PauseTrack(UINT16 uGroupIndex, UINT16 uTrackIndex, IHXValues* pValues)
- {
- #if defined(HELIX_FEATURE_ADVANCEDGROUPMGR)
- HX_RESULT hr = HXR_OK;
- SourceInfo* pSourceInfo = NULL;
- // pause on the current group only
- if (uGroupIndex == m_nCurrentGroup &&
- HXR_OK == GetSourceInfo(uGroupIndex, uTrackIndex, pSourceInfo))
- {
- hr = pSourceInfo->PauseTrack();
- }
- else
- {
- hr = HXR_UNEXPECTED;
- }
- return hr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_ADVANCEDGROUPMGR */
- }
- HX_RESULT
- HXPlayer::SeekTrack(UINT16 uGroupIndex, UINT16 uTrackIndex, IHXValues* pValues, UINT32 ulSeekTime)
- {
- #if defined(HELIX_FEATURE_ADVANCEDGROUPMGR)
- HX_RESULT hr = HXR_OK;
- SourceInfo* pSourceInfo = NULL;
- // seek on the current group only
- if (uGroupIndex == m_nCurrentGroup &&
- HXR_OK == GetSourceInfo(uGroupIndex, uTrackIndex, pSourceInfo))
- {
- hr = pSourceInfo->SeekTrack(ulSeekTime);
- }
- else
- {
- hr = HXR_UNEXPECTED;
- }
- return hr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_ADVANCEDGROUPMGR */
- }
- HX_RESULT
- HXPlayer::StopTrack(UINT16 uGroupIndex, UINT16 uTrackIndex, IHXValues* pValues)
- {
- #if defined(HELIX_FEATURE_ADVANCEDGROUPMGR)
- HX_RESULT hr = HXR_OK;
- SourceInfo* pSourceInfo = NULL;
- // stop on the current group only
- if (uGroupIndex == m_nCurrentGroup &&
- HXR_OK == GetSourceInfo(uGroupIndex, uTrackIndex, pSourceInfo))
- {
- hr = pSourceInfo->StopTrack();
- }
- else
- {
- hr = HXR_UNEXPECTED;
- }
- return hr;
- #else
- return HXR_NOTIMPL;
- #endif /* HELIX_FEATURE_ADVANCEDGROUPMGR */
- }
- HX_RESULT
- HXPlayer::SetSoundLevel(UINT16 uGroupIndex, UINT16 uTrackIndex, UINT16 uSoundLevel, BOOL bReflushAudioDevice)
- {
- HX_RESULT hr = HXR_OK;
- SourceInfo* pSourceInfo = NULL;
- // set on the current group only