📄 hxflsrc.cpp
字号:
!m_pSourceInfo->m_pRepeatList) { //Copy over the 'next group' stats. SOURCE_STATS* pTmpSourceStats = new SOURCE_STATS(m_pRegistry, m_ulRegistryID); *pTmpSourceStats = *m_pStats; ndxStream = mStreamInfoTable->Begin(); for(; ndxStream != mStreamInfoTable->End(); ++ndxStream) { pStreamInfo = (STREAM_INFO*) (*ndxStream); if (m_pRegistry && pTmpSourceStats && HXR_OK == m_pRegistry->GetPropName(pTmpSourceStats->m_ulRegistryID, pParentName)) { SafeSprintf(szRegName, MAX_DISPLAY_NAME, "%s.Stream%ld", pParentName->GetBuffer(), pStreamInfo->m_uStreamNumber); ulRegId = m_pRegistry->GetId(szRegName); if (!ulRegId) { ulRegId = m_pRegistry->AddComp(szRegName); } STREAM_STATS* pTmpStreamStats = new STREAM_STATS(m_pRegistry, ulRegId); //Copy over the "next-group" stats *pTmpStreamStats = *pStreamInfo->m_pStats; HX_DELETE(pStreamInfo->m_pStats); pStreamInfo->m_pStats = pTmpStreamStats; } HX_RELEASE(pParentName); } HX_DELETE(m_pStats); m_pStats = pTmpSourceStats; } else if (m_pStatsManager) { m_pStatsManager->UpdateRegistry(m_ulRegistryID); } }#endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */ return theErr;}HX_RESULTHXFileSource::UpdateStatistics(void){#if defined(HELIX_FEATURE_STATS) && defined(HELIX_FEATURE_REGISTRY) ULONG32 ulSourceLost = 0; ULONG32 ulSourceTotal = 0; ULONG32 ulSourceReceived = 0; ULONG32 ulSourceNormal = 0; ULONG32 ulSourceBandwidth = 0; CHXMapLongToObj::Iterator ndxStream = mStreamInfoTable->Begin(); for (; ndxStream != mStreamInfoTable->End(); ++ndxStream) { STREAM_INFO* pStreamInfo = (STREAM_INFO*) (*ndxStream); ULONG32 ulStreamTotal = 0; ULONG32 ulStreamReceived = 0; ULONG32 ulStreamNormal = 0; // update the statistics in the registry ulStreamNormal = pStreamInfo->m_ulReceived; ulStreamReceived = ulStreamNormal; ulStreamTotal = ulStreamNormal + pStreamInfo->m_ulLost; pStreamInfo->m_pStats->m_pNormal->SetInt((INT32)ulStreamNormal); pStreamInfo->m_pStats->m_pReceived->SetInt((INT32)ulStreamReceived); pStreamInfo->m_pStats->m_pLost->SetInt((INT32)pStreamInfo->m_ulLost); pStreamInfo->m_pStats->m_pTotal->SetInt((INT32)ulStreamTotal); ulSourceTotal += ulStreamTotal; ulSourceReceived += ulStreamReceived; ulSourceNormal += ulStreamNormal; ulSourceLost += pStreamInfo->m_ulLost; ulSourceBandwidth += pStreamInfo->m_pStats->m_pClipBandwidth->GetInt(); } if (m_pStats->m_pNormal) m_pStats->m_pNormal->SetInt((INT32)ulSourceNormal); if (m_pStats->m_pReceived) m_pStats->m_pReceived->SetInt((INT32)ulSourceReceived); if (m_pStats->m_pTotal) m_pStats->m_pTotal->SetInt((INT32)ulSourceTotal); if (m_pStats->m_pClipBandwidth) m_pStats->m_pClipBandwidth->SetInt((INT32)ulSourceBandwidth); if (m_pStats->m_pLost) m_pStats->m_pLost->SetInt((INT32)ulSourceLost); if (m_pStats->m_pCurBandwidth) m_pStats->m_pCurBandwidth->SetInt((INT32)ulSourceBandwidth); if (m_pStats->m_pAvgBandwidth) m_pStats->m_pAvgBandwidth->SetInt((INT32)ulSourceBandwidth); // update buffering mode(local machine) if (m_pStats->m_pBufferingMode) { m_pStats->m_pBufferingMode->SetInt(NORMAL_PLAY); }#endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */ return HXR_OK;}HX_RESULT HXFileSource::_ProcessIdle(BOOL atInterrupt){ HX_RESULT theErr = HXR_OK; if (m_bLocked) { return HXR_OK; } theErr = _ProcessIdleExt(atInterrupt); if (HXR_ABORT == theErr) { return HXR_OK; } // need to try the next fileformat for same mimetype... // cannot do it at interrupt time! if (m_pCurrentFileFormatUnk && (m_bCurrentFileFormatUnkInUse || atInterrupt)) { return HXR_OK; } m_bLocked = TRUE; if (m_pCurrentFileFormatUnk) { m_bCurrentFileFormatUnkInUse = TRUE; CleanupFileObjects(); ReSetup(); m_bLocked = FALSE; return HXR_OK; } if (!m_bInitialized) { m_bLocked = FALSE; return theErr; } if (m_bRedirectPending && !m_bPartOfNextGroup) { m_bRedirectPending = FALSE; HX_ASSERT(m_pRedirectURL); theErr = m_pSourceInfo->HandleRedirectRequest((char*)m_pRedirectURL->GetURL()); HX_DELETE(m_pRedirectURL); m_bLocked = FALSE; return theErr; } // we keep RAM FF object around by AddRef() in ::InitFileFormat // to avoid self-destruct in ::InitDone when it's not a RAM HX_RELEASE(m_pRAMFFObject); if (!m_bSourceEnd && !m_bFirstResume) { theErr = FillBuffers(); if (theErr == HXR_AT_END) { SetEndOfClip(); theErr = HXR_OK; } } if (!theErr) { UINT32 ulCurrentTime = m_pPlayer->GetInternalCurrentPlayTime(); // set m_bDelayed to FALSE as soon as it's due to begin playback // even it's still in pre-fetch mode if (!m_bPaused && m_bDelayed) { UINT32 ulStartTime = 0; if (m_ulDelay > m_ulPreRollInMs + NETWORK_FUDGE_FACTOR) { ulStartTime = m_ulDelay - (m_ulPreRollInMs + NETWORK_FUDGE_FACTOR); } if (ulCurrentTime >= ulStartTime) { m_bDelayed = FALSE; } } if (!m_bSourceEnd && m_bIsPreBufferingStarted && !m_bIsPreBufferingDone) { /* Get Current buffering status every 1 sec. */ UINT32 ulCurrentSystemTime = HX_GET_TICKCOUNT(); if (CALCULATE_ELAPSED_TICKS(m_ulLastBufferingCalcTime, ulCurrentSystemTime) > 1000) { m_ulLastBufferingCalcTime = ulCurrentSystemTime; CalculateCurrentBuffering(); } } // XXX HP TBD HTTP prefetch // no prefetch support for now if (m_bPrefetch) { LeavePrefetch(); } // rebuffer if the source hasn't satisfy its initial preroll when it's // time to start // resume in InitialBufferingDone() if (m_pPlayer->IsPlaying() && !m_bPartOfPrefetchGroup && m_bInitialBuffering && !m_bRebufferingRequired && (ulCurrentTime + MIN_BUFFERTIME_BEFORE_DELAY) >= m_ulDelay) { DoRebuffer(); } } m_bLocked = FALSE; if (!theErr && !m_bIsActive && !m_bDelayed && m_pPlayer->GetInternalCurrentPlayTime() >= m_ulDelay) { AdjustClipBandwidthStats(TRUE); } /* tell the player about the error... * This is crucial... */ if (theErr) { ReportError(theErr); } return theErr;}HX_RESULTHXFileSource::_ProcessIdleExt(BOOL atInterrupt){ return HXR_OK;}STDMETHODIMPHXFileSource::InitDone( HX_RESULT status){ if (!m_bValidateMetaDone) { m_bValidateMetaDone = TRUE; if (HXR_OK == status) { m_bIsMeta = TRUE; // reset all the timing attributes since meta file(RAM) // doesn't support any SetPlayTimes(0, 0, 0, 0); } else { m_bIsMeta = FALSE; HX_RELEASE(m_pFFObject); HX_RELEASE(m_pCurrentFileFormatUnk); HX_RELEASE(m_pFileFormatEnumerator); // not a meta file, since the file object has been initialized, // calling ExtendedSetup() again to find the actual mimetype if // the file object supports findings of mimetypes. return ExtendedSetup(m_pszURL); } } if (!mLastError && status != HXR_OK) { CheckForDefaultUpgrade(status); /* do we need to try the next one! */ if (!m_pCurrentFileFormatUnk && m_pFileFormatEnumerator) { m_pFileFormatEnumerator->GetNextPlugin(m_pCurrentFileFormatUnk, NULL); if (m_pCurrentFileFormatUnk && m_pSourceInfo) { m_pSourceInfo->ScheduleProcessCallback(); } } // early exit to try next fileformat for the same mimetype! if (m_pCurrentFileFormatUnk) { return HXR_OK; } mLastError = status; // merge any upgrade requests for this source to the player MergeUpgradeRequest(m_bAddDefaultUpgrade, m_pDefaultUpgradeString); } if (HXR_OK == status && m_ulStreamHeadersExpected == 0) { HX_RELEASE(m_pBackChannel); HX_RELEASE(m_pASMSource); m_pFFObject->QueryInterface(IID_IHXBackChannel, (void**) &m_pBackChannel); m_pFFObject->QueryInterface(IID_IHXASMSource, (void**) &m_pASMSource); HX_RESULT result = m_pFFObject->GetFileHeader(); return result; } else { ReportError(status); } return HXR_OK;}STDMETHODIMPHXFileSource::FileHeaderReady( HX_RESULT status, IHXValues* pHeader){ HX_RELEASE(m_pFileHeader); if (HXR_OK == status) { status = HandleSDPData(pHeader); }#if defined(HELIX_FEATURE_RECORDCONTROL) SendHeaderToRecordControl(TRUE, pHeader);#endif /* HELIX_FEATURE_RECORDCONTROL */ return ContinueWithFileHeader(status, pHeader);}HX_RESULTHXFileSource::ContinueWithFileHeader(HX_RESULT status, IHXValues* pHeader){ HX_RESULT result = HXR_OK; HX_ASSERT(!m_pFileHeader); if( pHeader ) { m_pFileHeader = pHeader; m_pFileHeader->AddRef(); } result = ContinueWithFileHeaderExt(status, m_pFileHeader); if (result == HXR_REQUEST_UPGRADE) { mLastError = result; return HXR_OK; } else if (result == HXR_WOULD_BLOCK) { return HXR_OK; } m_bContinueWithHeaders = FALSE; if (status != HXR_OK) { CheckForDefaultUpgrade(status); /* do we need to try the next one! */ if (!m_pCurrentFileFormatUnk && m_pFileFormatEnumerator) { m_pFileFormatEnumerator->GetNextPlugin(m_pCurrentFileFormatUnk, NULL); // only proceed source info(renderer) initialization in the // CURRENT group so that sources in the NEXT group won't have // effect(i.e. layout) in the current playback if (m_pCurrentFileFormatUnk && m_pPlayer && m_pSourceInfo && m_pPlayer->GetCurrentGroupID() == m_pSourceInfo->m_uGroupID) { m_pSourceInfo->ScheduleProcessCallback(); } } // early exit to try next fileformat for the same mimetype! if (m_pCurrentFileFormatUnk) { return HXR_OK; } mLastError = status; // merge any upgrade requests for this source to the player MergeUpgradeRequest(m_bAddDefaultUpgrade, m_pDefaultUpgradeString); ReportError(mLastError); return HXR_FAILED; } ProcessFileHeader(); if( m_pFileHeader ) { UINT32 ulLiveStream = 0; m_pFileHeader->GetPropertyULONG32("LiveStream", ulLiveStream); mLiveStream = ulLiveStream ? TRUE : FALSE; ULONG32 ulFlags = 0; m_pFileHeader->GetPropertyULONG32("Flags", ulFlags); mSaveAsAllowed = ulFlags & HX_SAVE_ENABLED ? TRUE : FALSE; for (UINT16 i=0; (result == HXR_OK) && i < m_ulStreamHeadersExpected; i++) { result = m_pFFObject->GetStreamHeader(i); } } return result;}HX_RESULTHXFileSource::ContinueWithFileHeaderExt(HX_RESULT status, IHXValues* pHeader){ return HXR_OK;}STDMETHODIMP HXFileSource::StreamHeaderReady(HX_RESULT status, IHXValues* pHeader){ HX_RESULT theErr = HXR_OK; char szRegKeyName[MAX_DISPLAY_NAME] = {0}; /* Flawfinder: ignore */ IHXBuffer* pszParentName = NULL; STREAM_INFO* pStreamInfo = NULL; // we do not support receiving headers once we have started getting data... if (m_bReceivedData) return HXR_FAILED; // define some more appropriate error code.. if (HXR_OK == status) { status = HandleSDPData(pHeader); } if (HXR_OK != status) { mLastError = status; ReportError(mLastError); return HXR_OK; }#if defined(HELIX_FEATURE_RECORDCONTROL) SendHeaderToRecordControl(FALSE, pHeader);#endif /* HELIX_FEATURE_RECORDCONTROL */ StreamHeaderReadyExt(pHeader); // fileformat initialized...clear any pending upgrade requests for this source! ClearUpgradeRequest(); // we have already received enough headers... if (m_uNumStreams >= m_ulStreamHeadersExpected) return HXR_FAILED; theErr = ProcessStreamHeaders(pHeader, pStreamInfo); if (!theErr) {#if defined(HELIX_FEATURE_STATS) && defined(HELIX_FEATURE_REGISTRY) HX_ASSERT(pStreamInfo); // create all the statistic registry keys if (m_pRegistry && m_pStats && HXR_OK == m_pRegistry->GetPropName(m_pStats->m_ulRegistryID, pszParentName)) { SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Stream%ld", pszParentName->GetBuffer(), m_ulStreamIndex); /* does this ID already exists ? */ UINT32 ulRegistryID = m_pRegistry->GetId(szRegKeyName); if (!ulRegistryID) { ulRegistryID = m_pRegistry->AddComp(szRegKeyName); } pStreamInfo->m_pStats = new STREAM_STATS(m_pRegistry, ulRegistryID); if(pStreamInfo->m_pStats) { // set stream bandwidth pStreamInfo->m_pStats->m_pClipBandwidth->SetInt((INT32)pStreamInfo->BufferingState().AvgBandwidth()); } else { // NOTE: It may be that we can still function without the // m_pStats object, but can we still function if we are // running out of memory at this point? Assuming no. theErr = HXR_OUTOFMEMORY; } } HX_RELEASE(pszParentName);#endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */ m_ulStreamIndex++; m_uNumStreams++; } if (!theErr && m_uNumStreams == m_ulStreamHeadersExpected) { m_uActiveStreams = m_uNumStreams; m_ulOriginalDuration = m_ulDuration; m_bInitialized = TRUE; theErr = AdjustClipTime(); m_pBufferManager->Init(); } return theErr;}HX_RESULTHXFileSource::StreamHeaderReadyExt(IHXValues* pHeader){ return HXR_OK;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -