⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 srcinfo.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	if ((HXR_OK != pStreamInfo->m_pStreamProps->GetPropertyCString("playto",pStreamPlayTo)) ||
	    !pStreamPlayTo)
	{
	    /* Set region name to playto property */
	    pStreamInfo->m_pStreamProps->GetPropertyCString("region",pStreamPlayTo);
	    
	    /* create a unique value */
	    if (!pStreamPlayTo)
	    {
		char szBuffer[14]; /* Flawfinder: ignore */
		ULONG32 length = SafeSprintf(szBuffer,14, "%#010lx",(ULONG32)(void*)pStreamInfo); /* Flawfinder: ignore */

		pStreamPlayTo = (IHXBuffer*) new CHXBuffer();
		pStreamPlayTo->AddRef();

		pStreamPlayTo->Set((UCHAR*)szBuffer,length+1);
	    }

	    pStreamInfo->m_pStreamProps->SetPropertyCString("playto",pStreamPlayTo);
	}

	HX_RELEASE(pStreamPlayTo);

	theErr = SetupRenderer(pRendInfo, pRenderer, pStreamInfo, pStream);

nextrend:
	if (theErr)
	{
	    if (theErr == HXR_OUTOFMEMORY)
	    {
		m_pPlayer->Report( HXLOG_ERR, theErr, 0, NULL, NULL );
	    }

	    if (theErr == HXR_REQUEST_UPGRADE)
	    {
		bAddDefaultUpgrade = TRUE;
	    }

	    HX_RELEASE(pUnkRenderer);
	    if (pRendInfo->m_pRendererEnumerator &&
		HXR_OK == pRendInfo->m_pRendererEnumerator->GetNextPlugin(pUnkRenderer, NULL) &&
		pUnkRenderer)
	    {
		theErr = HXR_OK;
		HX_RELEASE(pRendInfo->m_pRenderer);
		goto tryNextRendererForSameMimeType;
	    }
	    else
	    {
		if (!theFinalErr)
		{
		    bSourceInitialized = FALSE;
		    theFinalErr = theErr;
		}	    

		// merge any upgrade requests for this source to the player
		m_pSource->MergeUpgradeRequest(bAddDefaultUpgrade, pMimeTypeBuffer ? (char*) pMimeTypeBuffer->GetBuffer() : (char*)NULL);
		theErr = HXR_OK;
	    }
	}
    }

exit:

    if (theErr && !theFinalErr)
    {
	bSourceInitialized = FALSE;
	theFinalErr = theErr;
    }

#if defined(HELIX_FEATURE_BASICGROUPMGR)
    if(!theFinalErr && 
       m_bTrackStartedToBeSent)
    {    
	m_pPlayer->m_pGroupManager->TrackStarted(m_uGroupID, m_uTrackID);  
	m_bTrackStartedToBeSent = FALSE;
	if (m_pPeerSourceInfo)
	{
	    m_pPeerSourceInfo->m_bTrackStartedToBeSent = FALSE;
	}
    }
#endif /* HELIX_FEATURE_BASICGROUPMGR */

    HX_RELEASE(pMimeTypeBuffer);
    HX_RELEASE(pUnkRenderer);

    if (!theFinalErr)
    {
	theFinalErr = InitializeRenderersExt(bSourceInitialized);
    }

    if (!theFinalErr && bSourceInitialized)
    {
	m_bInitialized = TRUE;
	  
	// renderers initialized...clear any pending upgrade requests for this source!
	m_pSource->ClearUpgradeRequest();

	if (m_bAudioDeviceReflushHint)
	{
	    m_pSource->SetAudioDeviceReflushHint();
	}

	// set the soundLevel != 100 by default
	if (m_uSoundLevel != 100)
	{
	    m_pSource->SetSoundLevel(m_uSoundLevel, FALSE);
	}

	/* Enter the order of the stream numbers in which they will be 
	 * scheduled for GetEvent() calls
	 */
	if (NULL == m_pCurrentScheduleList)
	{
	    m_pCurrentScheduleList = new CHXSimpleList;
	}

	CHXMapLongToObj::Iterator ndxRend = m_pRendererMap->Begin();
	for (; ndxRend != m_pRendererMap->End(); ++ndxRend)
	{
	    RendererInfo* pRendInfo = (RendererInfo*)(*ndxRend);
	    m_pCurrentScheduleList->AddTail((void*) pRendInfo);
	}
    }

    return theFinalErr;
}

HX_RESULT
SourceInfo::InitializeRenderersExt(BOOL& bSourceInitialized)
{
    return HXR_OK;
}

HX_RESULT
SourceInfo::SetupStreams()
{
    if (m_bAreStreamsSetup)
    {
	return HXR_OK;
    }

    HX_RESULT	    theErr          = HXR_OK;
    IHXValues*	    pHeader         = NULL;
    HXStream*	    pStream         = NULL;
    STREAM_INFO*    pStreamInfo     = NULL;
    RendererInfo*   pRendInfo       = NULL;
    HXSource*	    pSource	    = m_pSource;

    if (!pSource->IsInitialized())
    {
	HX_ASSERT(FALSE);
	return HXR_UNEXPECTED;
    }

    UINT16 uNumStreams = pSource->GetNumStreams();

    HX_ASSERT(m_pRendererMap->IsEmpty() == TRUE);
    if (m_pRendererMap->IsEmpty() && uNumStreams > 0 &&
	(UINT32) uNumStreams < m_pRendererMap->GetHashTableSize())
    {
	m_pRendererMap->InitHashTable((UINT32) uNumStreams);
    }
    
    for (UINT16 i=0; i < uNumStreams; i++)
    {
	UINT32	ulStreamNumber = 0;
	pHeader         = NULL;
	pStream         = NULL;

	pSource->GetStreamHeaderInfo(i, pHeader);

	if (!pHeader)
	{
	    GOTOEXITONERROR(theErr = HXR_FAILED, exit);	    
	}

	pStream = new HXStream;
	if (!pStream)
	{
	    theErr = HXR_OUTOFMEMORY;
	    goto exit;
	}

	pStream->AddRef();
	theErr = pStream->Init(m_pPlayer, pSource, pHeader);
	
	GOTOEXITONERROR(theErr, exit);

	pHeader->GetPropertyULONG32("StreamNumber", ulStreamNumber);

	if (HXR_OK != pSource->GetStreamInfo(ulStreamNumber, pStreamInfo) || !pStreamInfo)
	{
	    GOTOEXITONERROR(theErr = HXR_FAILED, exit);
	}

	HX_RELEASE(pHeader);

	pRendInfo = NewRendererInfo();
	if (!pRendInfo)
	{
	    theErr = HXR_OUTOFMEMORY;
	    GOTOEXITONERROR(theErr, exit);
	}
	// get properties of the header
	pRendInfo->m_pRenderer          = NULL;
	pRendInfo->m_pStreamInfo        = pStreamInfo;
	pRendInfo->m_ulGranularity      = 0;
	pRendInfo->m_ulDuration         = pStreamInfo->m_ulDuration;
	pRendInfo->m_BufferingReason    = BUFFERING_START_UP;
        
        struct timeSyncParamStruct obj = {this, pRendInfo};
        pRendInfo->m_pTimeSyncCallback  = new CTimeSyncCallback((void*)&obj, (fGenericCBFunc)TimeSyncCallback);
	pRendInfo->m_pStream		= pStream;
	pRendInfo->m_pStream->AddRef();

	if (m_ulSourceDuration < pStreamInfo->m_ulDuration)
	{
	    m_ulSourceDuration = pStreamInfo->m_ulDuration;
	}
    
	if (pRendInfo->m_pTimeSyncCallback)
	{
	    pRendInfo->m_pTimeSyncCallback->AddRef();
	}
	else
	{
	    theErr = HXR_OUTOFMEMORY;
	    GOTOEXITONERROR(theErr, exit);
	}

	m_pRendererMap->SetAt(pStreamInfo->m_uStreamNumber, (void*) pRendInfo);

	if (pStream)
	{
	    if (pStream->IsSureStream())
	    {
		pSource->m_bSureStreamClip = TRUE;
	    }
	    pSource->AddHXStream(pStream);
	    HX_RELEASE(pStream);
	}
    }

exit:
    HX_RELEASE(pStream);
    HX_RELEASE(pHeader);

    if (!theErr)
    {
	m_bAreStreamsSetup = TRUE;
    }

    return theErr;
}

RendererInfo* 
SourceInfo::NewRendererInfo()
{
    return (new RendererInfo());
}

HX_RESULT
SourceInfo::SetupRenderer(RendererInfo*& pRendInfo, IHXRenderer*& pRenderer, 
			 STREAM_INFO*& pStreamInfo, HXStream*& pStream)
{
    HX_RESULT       theErr              = HXR_OK;
    ULONG32         ulSyncGranularity   = DEFAULT_TIMESYNC_GRANULARITY;
    BOOL	    bLiveSource		= FALSE;
    HXSource*      pSource             = m_pSource;
    IHXPlugin*     pPlugin             = NULL;
    STREAM_INFO*    pSrcStreamInfo	= NULL;
    IHXStatistics* pStatistics		= NULL;
    const char**    ppTmpMimeType = 0;

    pRendInfo->m_pRenderer          = pRenderer;

    if (HXR_OK != pRenderer->QueryInterface(IID_IHXPlugin,(void**)&pPlugin))
    {
	theErr = HXR_NOT_INITIALIZED;
    }
    else
    {
	/* Initialize the plugin for use */
	if (HXR_OK != pPlugin->InitPlugin((IUnknown*) (IHXStreamSource*) m_pSource))
	{
	    theErr = HXR_NOT_INITIALIZED;
	}
	pPlugin->Release();
    }

    GOTOEXITONERROR(theErr, exit);

#if defined(HELIX_FEATURE_STATS) && defined(HELIX_FEATURE_REGISTRY)
    if (HXR_OK == pRenderer->QueryInterface(IID_IHXStatistics, (void**) &pStatistics))
    {
	if (HXR_OK == pSource->GetStreamInfo(pRendInfo->m_pStreamInfo->m_uStreamNumber, pSrcStreamInfo) &&
	    pSrcStreamInfo && pSrcStreamInfo->m_pStats)
	{
	    pStatistics->InitializeStatistics(pSrcStreamInfo->m_pStats->m_pRenderer->m_ulRegistryID);
	}

	HX_RELEASE (pStatistics);
    }
#endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */

    theErr = pRenderer->StartStream(pStream, m_pPlayer);
    GOTOEXITONERROR(theErr, exit);

    theErr = pRenderer->OnHeader(pStreamInfo->m_pHeader);
    GOTOEXITONERROR(theErr, exit);

    // start the stream
    /* get the minimum granularity */
    pRenderer->GetRendererInfo(ppTmpMimeType, ulSyncGranularity);
    /* sanity check */
    if (ulSyncGranularity < MINIMUM_TIMESYNC_GRANULARITY)
    {
	ulSyncGranularity = MINIMUM_TIMESYNC_GRANULARITY;
    }

    if (ulSyncGranularity < m_pPlayer->m_ulLowestGranularity)
    {
	m_pPlayer->m_ulLowestGranularity = ulSyncGranularity;
    }

    // get properties of the header
    pStreamInfo->m_ulDelay  	    = m_pSource->GetDelay();
    pRendInfo->m_ulGranularity      = ulSyncGranularity;
    pRendInfo->m_ulDuration         = pStreamInfo->m_ulDuration;
    // OnHeader may have overriddden the m_ulPreroll from the stream header
    // if it was too big or too small or not set.

    ULONG32 ulPreroll;
    if (HXR_OK == pStreamInfo->m_pHeader->GetPropertyULONG32("Preroll", ulPreroll))
    {
	pStreamInfo->BufferingState().SetPreroll(ulPreroll);
    }

    // check if renderer is interrupt safe
    IHXInterruptSafe* pInterruptSafe;
    if (HXR_OK == pRenderer->QueryInterface(IID_IHXInterruptSafe,(void**)&pInterruptSafe))
    {
	HX_ASSERT(pInterruptSafe) ;
	if (pInterruptSafe)
	{
	    pRendInfo->m_bInterruptSafe = pInterruptSafe->IsInterruptSafe();
	    pInterruptSafe->Release();
	}
    }    
    
    m_pPlayer->m_bResumeOnlyAtSystemTime |= (!pRendInfo->m_bInterruptSafe);
    
    /* Enter to the begin list so that we can call Begin at the right time */
    m_pPlayer->EnterToBeginList(pRendInfo);

    // notify the persistent renderer(source) who implements
    // IHXRendererAdviseSink to monitor the status of its tracks
    if (m_pRendererAdviseSink && pStream && !m_bIsPersistentSource)
    {
	bLiveSource = pSource->IsLive();

	if (m_bIndefiniteDuration)
	{
	    m_ulTrackDuration = MAX_UINT32;
	}
	else	
	{	
	    m_ulTrackDuration = m_pSource->GetDuration();
	}

	if (!m_bIsTrackDurationSet)
	{	    
	    m_bIsTrackDurationSet = TRUE;

	    m_pRendererAdviseSink->TrackDurationSet(m_uGroupID,
						    m_uTrackID,
						    m_ulTrackDuration,
						    pStreamInfo->m_ulDelay,
						    bLiveSource);
	}
    }	

    if (m_pRendererAdviseSink && pStream)
    {
	IUnknown* pUnk = 0;
	if(HXR_OK == pStream->QueryInterface(IID_IUnknown, (void**)&pUnk))
	{
	    /* 
	     * construct the IHXValues info for the RendererInitialized call
	     */
	    IHXValues* pValues = new CHXHeader;
	    pValues->AddRef();

	    pValues->SetPropertyULONG32("GroupIndex", m_uGroupID);
	    pValues->SetPropertyULONG32("TrackIndex", m_uTrackID);
	    pValues->SetPropertyULONG32("Delay", pStreamInfo->m_ulDelay);
	    
	    /* We should really fix SMIL renderer to look at MAX duration
	     * For now, we will pass max duration for all the renderers.
	     * The only case where the duration is different is with image maps 
	     * in video/audio stream.
	     */
	    pValues->SetPropertyULONG32("Duration", m_ulTrackDuration);	    
	    pValues->SetPropertyULONG32("LiveSource", bLiveSource);

	    if (!m_id.IsEmpty())
	    {
    		IHXBuffer* pBuffer = new CHXBuffer();
		pBuffer->AddRef();
    
		pBuffer->Set((const UCHAR*)(const char*)m_id, m_id.GetLength()+1);
		pValues->SetPropertyCString("id", pBuffer);

		HX_RELEASE(pBuffer);
	    }

	    HX_RESULT rc = m_pRendererAdviseSink->RendererInitialized(pRenderer, pUnk, pValues);

	    pValues->Release();
	    pUnk->Release();
	}
    }

    // XXX HP we need to re-examine how the SMIL renderer's layout site 
    // setup work!!
    if (m_bIsPersistentSource)
    {
	m_pPlayer->m_bSetupLayoutSiteGroup = FALSE;
    }

exit:
    return theErr;
}


HX_RESULT
SourceInfo::InitializeAndSetupRendererSites()
{
    HX_RESULT theErr = HXR_OK;
    BOOL bInitialized = FALSE;

    if (HXR_OK != m_lastError)
    {
        return m_lastError;
    }

    if (m_bLocked)
    {
	return HXR_OK;
    }

    m_bLocked = TRUE;
    m_pMutex->Lock();

    theErr = InitializeRenderers(bInitialized);
    if (!theErr && m_bInitialized)
    {
	/* This source may have audio streams */
	if (!m_pPlayer->m_ulMinimumAudioPreroll)
	{
	    m_pPlayer->m_ulMinimumAudioPreroll = 
		m_pPlayer->m_pAudioPlayer->GetInitialPushdown();
	}

	UINT32 ulMinimumStartingPreroll = m_pPlayer->m_pAudioPlayer->GetInitialPushdown(TRUE);

	m_pSource->SetMinimumPreroll(m_pPlayer->m_ulMinimumAudioPreroll, ulMinimumStartingPreroll);

#if defined(HELIX_FEATURE_VIDEO)
	/* Set all the renderer sites */
	SetupRendererSites(!m_pPlayer->m_bSetupLayoutSiteGroup);

	/* Did we have to call BeginChangeLayout? */
	if (m_pPlayer->m_pSiteSupplier			&& 
	    !m_pPlayer

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -