コード例 #1
0
ファイル: hdprefctrl.cpp プロジェクト: muromec/qtopia-ezx
/************************************************************************
* IHXActivePropUser::SetActiveStr
*
*    Async request to set string pName to string in pBuffer.
*/
STDMETHODIMP
HTTPDeliverablePrefController::SetActiveStr(const char* pName,
			IHXBuffer* pBuffer,
			IHXActivePropUserResponse* pResponse)
{

    /*
     * Get everything under HTTPDeliverable.
     */
    IHXValues* pHTTPPath = 0;
    IHXBuffer* pBuf = 0;
    char** pNewHTTPD;
    HX_RESULT res;
    const char* name;
    UINT32 ul;
    int i;

    /*
     * If the list is already in the reg, then we have to merge
     * our new stuff to set with the stuff from the reg.
     */
    if (HXR_OK == m_proc->pc->registry->GetPropList(
	m_pCharListName, pHTTPPath, m_proc))
    {
	UINT32 ulNumPaths = 0;
	res = pHTTPPath->GetFirstPropertyULONG32(name, ul);
	while (res == HXR_OK)
	{
	    ulNumPaths++;
	    res = pHTTPPath->GetNextPropertyULONG32(name, ul);
	}
	/*
	 * If we are changing one that is already there...
	 */
	if (HXR_OK == pHTTPPath->GetPropertyULONG32(
	    pName, ul))
	{
	    pNewHTTPD = new char* [ulNumPaths+1];
	    i = 0;
	    res = pHTTPPath->GetFirstPropertyULONG32(name, ul);
	    while (res == HXR_OK)
	    {
		pBuf = 0;
		/*
		 * If this is the one we are changing...
		 */
		if (!strcasecmp(name, pName))
		{
		    pNewHTTPD[i] = new_string(
			(const char*)pBuffer->GetBuffer());
		}
		else
		{
		    m_proc->pc->registry->GetStr(name, pBuf, m_proc);
		    if (!pBuf)
		    {
			i--;
		    }
		    else
		    {
			pNewHTTPD[i] = new_string(
			    (const char*)pBuf->GetBuffer());
			pBuf->Release();
		    }
		}
		i++;
		res = pHTTPPath->GetNextPropertyULONG32(name, ul);
	    }
	    pNewHTTPD[i] = 0;
	}
	/*
	 * We must be adding one...
	 */
	else
	{
	    pNewHTTPD = new char* [ulNumPaths+2];
	    i = 0;
	    res = pHTTPPath->GetFirstPropertyULONG32(name, ul);
	    while (res == HXR_OK)
	    {
		pBuf = 0;
		m_proc->pc->registry->GetStr(name, pBuf, m_proc);
		if (pBuf)
		{
		    pNewHTTPD[i] = new_string(
			(const char*)pBuf->GetBuffer());
		    pBuf->Release();
		    i++;
		}
		res = pHTTPPath->GetNextPropertyULONG32(name, ul);
	    }
	    pNewHTTPD[i++] = new_string((const char*)pBuffer->GetBuffer());
	    pNewHTTPD[i] = 0;

	}
    }
    /*
     * It was not in the reg, so this is the only one.
     */
    else
    {
	pNewHTTPD = new char* [2];
	pNewHTTPD[0] = new_string((const char*)pBuffer->GetBuffer());
	pNewHTTPD[1] = 0;
    }

    /*
     * Clean up the old one.
     */
    if (m_HTTP_paths && *m_HTTP_paths)
    {
	i = 0;
	while ((*m_HTTP_paths)[i])
	{
	    delete[] (*m_HTTP_paths)[i];
	    i++;
	}
	delete[] (*m_HTTP_paths);
    }
    *m_HTTP_paths = pNewHTTPD;

    pResponse->SetActiveStrDone(HXR_OK, pName, pBuffer, 0, 0);
    return HXR_OK;
}
コード例 #2
0
ファイル: hdprefctrl.cpp プロジェクト: muromec/qtopia-ezx
/************************************************************************
* IHXActivePropUser::DeleteActiveProp
*
*	Async request to delete the active property.
*/
STDMETHODIMP
HTTPDeliverablePrefController::DeleteActiveProp(const char* pName,
			    IHXActivePropUserResponse* pResponse)
{
    IHXValues* pHTTPPath;
    char** pNewHTTPD = 0;
    const char* name;
    UINT32 ul;
    UINT32 ulNumPaths = 0;
    HX_RESULT res;
    int i;
    IHXBuffer* pBuf = 0;
    if (HXR_OK == m_proc->pc->registry->GetPropList(
	m_pCharListName, pHTTPPath, m_proc))
    {
	if (HXR_OK == pHTTPPath->GetPropertyULONG32(pName, ul))
	{
	    /*
	     * Count the number of current paths.
	     */
	    res = pHTTPPath->GetFirstPropertyULONG32(name, ul);
	    while (res == HXR_OK)
	    {
		ulNumPaths++;
		res = pHTTPPath->GetNextPropertyULONG32(name, ul);
	    }

	    pNewHTTPD = new char* [ulNumPaths];
	    i = 0;
	    res = pHTTPPath->GetFirstPropertyULONG32(name, ul);
	    while (res == HXR_OK)
	    {
		pBuf = 0;
		/*
		 * If this is the one we want to delete, then just 
		 * skip over it in the copy.
		 */
		if (strcasecmp(name, pName))
		{
		    m_proc->pc->registry->GetStr(name, pBuf, m_proc);
		    if (pBuf)
		    {
			pNewHTTPD[i] = new_string(
			    (const char*)pBuf->GetBuffer());
			pBuf->Release();
			i++;
		    }
		}
		res = pHTTPPath->GetNextPropertyULONG32(name, ul);
	    }
	    pNewHTTPD[i] = 0;
	    /*
	     * Clean up the old one and set it to the new one.
	     */
	    if (m_HTTP_paths && *m_HTTP_paths)
	    {
		i = 0;
		while ((*m_HTTP_paths)[i])
		{
		    delete[] (*m_HTTP_paths)[i];
		    i++;
		}
		delete[] (*m_HTTP_paths);
	    }
	    *m_HTTP_paths = pNewHTTPD;
	    pNewHTTPD = 0;
	}
    }
    pResponse->DeleteActivePropDone(HXR_OK, pName, 0, 0);
    return HXR_OK;
}
コード例 #3
0
ファイル: srcfinder.cpp プロジェクト: muromec/qtopia-ezx
/*
* IHXBroadcastMapperResponse
*/
STDMETHODIMP
BasicSourceFinder::BroadcastTypeFound(HX_RESULT status, const char* pType)
{
    if (SF_CLOSED == m_findState)
    {
        return HXR_OK;
    }

    m_CurrentSourceType = pType;

    HX_ASSERT(m_pBroadcastMapper);
    HX_RELEASE(m_pBroadcastMapper);

    PluginHandler::BroadcastFormat* broadcast_handler;
    PluginHandler::Errors            plugin_result;
    PluginHandler::Plugin*          plugin;

    broadcast_handler =
        m_pProc->pc->plugin_handler->m_broadcast_handler;
    plugin_result = broadcast_handler->Find(pType, plugin);

    if(PluginHandler::NO_ERRORS != plugin_result)
    {
        ERRMSG(m_pProc->pc->error_handler, "No live handler for %s\n",
               pType?pType:"(null)");
        return HXR_FAIL;
    }


    /*
    * Depending on a request
    */
    HX_RESULT  theErr = HXR_FAIL;
    IHXPSourceControl* pSource = NULL;
    IHXValues* pVal = NULL;
    IHXBuffer* pBuf = NULL;

    const char* pFileName = m_pURL->name + m_pFSManager->m_mount_point_len - 1;
    UINT32     bUseSourceContainer = FALSE;
    BOOL       bUseMediaDeliveryPipeline = FALSE;

    /* XXDWL
     * For live (broadcast) sessions, the media delivery pipeline needs to be turned off.
     * This is a temporary solution until a number of issues dealing with timestamp
     * dependent media, and ASM rule handling are worked out.
     * See also: server/engine/session/player.cpp:1947

     bUseMediaDeliveryPipeline = m_pPlayerSession->m_bUseMediaDeliveryPipeline;
    */

#if NOTYET
    /* XXTDM
     * According to ghori, this was an attempt to merge the various source
     * finding code into one place.  Due to time constraints, it was never
     * finished.  Therefore, this code is currently unused and untested.
     */
    theErr = m_pRequest->GetRequestHeaders(FS_HEADERS, pVal);
    if (HXR_OK == theErr)
    {
        theErr = pVal->GetPropertyULONG32("UseSourceContainer", bUseSourceContainer);
        if (HXR_OK != theErr)
        {
            bUseSourceContainer = FALSE;
        }

        theErr = pVal->GetPropertyCString("BroadcastAlias", pBuf);
        if (HXR_OK == theErr)
        {
            pFileName = (const char*)pBuf->GetBuffer();
        }
    }
#endif /* NOTYET */

    HX_ASSERT(pFileName);
    theErr = m_pProc->pc->broadcast_manager->GetStream(pType, pFileName,
                           pSource, m_pProc, bUseMediaDeliveryPipeline,
                           m_pPlayerSession ? m_pPlayerSession->GetSessionStats()
                                            : NULL);
    if (HXR_OK == theErr)
    {
        if (bUseSourceContainer)
        {
            SourceContainer* pContainer =
                new SourceContainer(m_pProc->pc->server_context, pSource);

            if (pContainer)
            {
                pContainer->AddRef();
                FindSourceDone(HXR_OK, (IUnknown*)(IHXPSinkPackets*)pContainer);
                pContainer->Release();
            }
            else
            {
                theErr = HXR_OUTOFMEMORY;
                HX_RELEASE(pSource);
            }
        }
    }

    FindSourceDone(theErr, pSource);

    HX_RELEASE(pSource);
    HX_RELEASE(pVal);
    HX_RELEASE(pBuf);
    return HXR_OK;
}
コード例 #4
0
ファイル: hxsmstr.cpp プロジェクト: muromec/qtopia-ezx
HXASMStream::HXASMStream(HXStream* pStream, HXSource* pSource)
    : m_bTimeStampDeliveryMode(FALSE)
    , m_bInitialSubscribe(TRUE)
    , m_bHasExpression(FALSE)
    , m_bEndOneRuleEndAll(FALSE)
    , m_ulLastLimitBandwidth(0xffffffff)
    , m_lRefCount(0)
    , m_nNumRules(0)
    , m_pAtomicRuleChange(0)
    , m_pRuleBook(0)
    , m_pLossCB(0)
    , m_ulLossCBHandle(0)
    , m_ulBandwidthAllocation(0)
    , m_ulFixedBandwidth(0)
    , m_pSubInfo(0)
    , m_ulRuleBw(0)
    , m_ulRulePreData(0)
    , m_ulCurrentPreData(0)
    , m_ulCurrentBandwidth(0)
    , m_ulLastBandwidth(0)
    , m_bRuleTimeStampDelivery(0)
    , m_ulSubscribedBw(0)
    , m_lBias(0)
    , m_bStartRecalc(FALSE)
    , m_pSubList(0)
    , m_pSubscriptionVariables(0)
    , m_pRuleSubscribeStatus(NULL)
    , m_pASMRuleState(NULL)
    , m_pRuleEnableState(NULL)
    , m_bSubsLocked(FALSE)
#ifndef GOLD
    , m_pEM(0)
#endif
{
    m_pStreamSinkMap = new CHXMapPtrToPtr;
    
    UINT32  ulStreamID;
    IHXPlayer* pPlayer;

    pStream->GetID(ulStreamID);
    m_pSource = pSource;
    m_pSource->AddRef();
    m_pHeader = pStream->GetHeader();
    m_uStreamNumber = pStream->GetStreamNumber();

    /* Hold onto some useful interfaces */

    m_pSource->GetPlayer(pPlayer);
    pPlayer->QueryInterface(IID_IHXRegistry,  (void **)&m_pRegistry);
    pPlayer->QueryInterface(IID_IHXScheduler,   (void **)&m_pScheduler);
    pPlayer->QueryInterface(IID_IHXCommonClassFactory,   (void **)&m_pCCF);
    pPlayer->Release();

    /*
     * WARNING!  You must update all interfaces queried off the source
     * in ResetASMSource().
     */
    m_pSource->QueryInterface(IID_IHXASMSource, (void **)&m_pASMSource);
    m_pSource->QueryInterface(IID_IHXAtomicRuleChange,
	(void **)&m_pAtomicRuleChange);

#ifndef GOLD
    pPlayer->QueryInterface(IID_IHXErrorMessages, (void **)&m_pEM);
#endif

    UINT32 ulEndOneruleEndAll = 0;
    if (m_pHeader->GetPropertyULONG32("EndOneRuleEndAll", ulEndOneruleEndAll) == HXR_OK)
    {
	m_bEndOneRuleEndAll = (ulEndOneruleEndAll == 1);
    }
    /* temporary hack to properly shut down RA and RV streams with end time */
    else
    {	
	IHXBuffer* pMimeType = NULL;
	m_pHeader->GetPropertyCString("MimeType", pMimeType);

	if (pMimeType && 
	    ((::strcasecmp((const char*) pMimeType->GetBuffer(), REALAUDIO_MIME_TYPE) == 0) ||
	     (::strcasecmp((const char*) pMimeType->GetBuffer(), REALAUDIO_MULTIRATE_MIME_TYPE) == 0) ||
	     (::strcasecmp((const char*) pMimeType->GetBuffer(), REALVIDEO_MIME_TYPE) == 0) ||
	     (::strcasecmp((const char*) pMimeType->GetBuffer(), REALVIDEO_MULTIRATE_MIME_TYPE) == 0)))
	{
	    m_bEndOneRuleEndAll = TRUE;
	}

	HX_RELEASE(pMimeType);
    }

    /* Extract RuleBook from the stream header */

    IHXBuffer* pRuleBook = NULL;
    m_pHeader->GetPropertyCString("ASMRuleBook", pRuleBook);
    if (pRuleBook)
    {
        m_pRuleBook = new ASMRuleBook (m_pCCF, (const char *)pRuleBook->GetBuffer());

	m_nNumRules = m_pRuleBook->GetNumRules();
	m_ulRuleBw = new UINT32[m_nNumRules];
	m_ulRulePreData = new UINT32[m_nNumRules];
	m_bRuleTimeStampDelivery = new HXBOOL[m_nNumRules];
	m_pSubInfo = new HXBOOL[m_nNumRules];
	m_pRuleSubscribeStatus = new HXBOOL[m_nNumRules];
        m_pRuleEnableState = new RuleEnableState[m_nNumRules];

        for (UINT16 i = 0; i < m_nNumRules; i++)
        {
	    IHXValues*	pValues;
	    IHXBuffer* pBuffer;

	    m_pRuleBook->GetProperties(i, pValues);

	    m_ulRuleBw[i] = 0;
	    m_ulRulePreData[i] = 0;
	    m_bRuleTimeStampDelivery[i] = FALSE;
            m_pRuleEnableState[i] = resEnabled;

	    if (HXR_OK == pValues->GetPropertyCString("PreData",
		pBuffer))
	    {
		m_ulRulePreData[i] = atoi((char*)pBuffer->GetBuffer());
		pBuffer->Release();
	    }

	    if (HXR_OK == pValues->GetPropertyCString("AverageBandwidth",
		pBuffer))
	    {
		m_ulRuleBw[i] = atoi((char*)pBuffer->GetBuffer());
		pBuffer->Release();
	    }
	    else if (HXR_OK == pValues->GetPropertyCString("TimeStampDelivery",
		pBuffer))
	    {
		if ((pBuffer->GetBuffer()[0] == 'T') ||
		    (pBuffer->GetBuffer()[0] == 't'))
		{
		    // Handle TimeStamp Delivery (i.e. assume significant bandwidth)
		    m_ulRuleBw[i] = 0;
		    m_bRuleTimeStampDelivery[i] = TRUE;
		}
		pBuffer->Release();
	    }
	    else
	    {
		/* XXXSMP Temporary hack for invalid rulebooks */
		if (i == 0)
		{
		    IHXValues* pHeader = 0;

		    HX_VERIFY(pHeader = pStream->GetHeader());
		    pHeader->GetPropertyULONG32("AvgBitRate",m_ulRuleBw[i]);
		    pHeader->Release();
		}
		else
		{
		    m_ulRuleBw[i] = 0;
		}
	    }
	    pValues->Release();

            m_pSubInfo[i] = 0;
	    m_pRuleSubscribeStatus[i] = FALSE;
        }

	HXBOOL bFixed = TRUE;

	m_bHasExpression = m_pRuleBook->HasExpression();
	if (m_bHasExpression == FALSE)
	{
	    UINT16 i;
	    for (i = 0; i < m_nNumRules; i++)
	    {
		if (m_bRuleTimeStampDelivery[i] == FALSE)
		{
		    bFixed = FALSE;
		    break;
		}
	    }

	    if (bFixed)
	    {
		m_ulFixedBandwidth = 1;
	    }
	    else
	    {
		m_ulCurrentBandwidth = 0;
		for (i = 0; i < m_nNumRules; i++)
		{
		    m_ulCurrentBandwidth += m_ulRuleBw[i];
		}

		m_ulFixedBandwidth = m_ulCurrentBandwidth;
	    }
	}
    }
    else
    {
	IHXValues* pHeader = 0;

	HX_VERIFY(pHeader = pStream->GetHeader());
	HX_VERIFY(HXR_OK == pHeader->GetPropertyULONG32("AvgBitRate",
	    m_ulFixedBandwidth));
	
	m_ulCurrentBandwidth = m_ulFixedBandwidth; 

	pHeader->Release();
    }

    /* Get Registry ID's for interesting properties */
    IHXBuffer* pPropName = 0;

    // init. 
    memset(m_szRecv, 0, MAX_DISPLAY_NAME);
    memset(m_szLost, 0, MAX_DISPLAY_NAME);
    memset(m_szClipBandwidth, 0, MAX_DISPLAY_NAME);

    if( m_pRegistry )
	{
	    m_pRegistry->GetPropName(ulStreamID, pPropName);
	}
    
    if (pPropName)
    {
	SafeSprintf(m_szRecv, MAX_DISPLAY_NAME, "%s.received", pPropName->GetBuffer());
	m_ulIDRecv = m_pRegistry->GetId(m_szRecv);

	SafeSprintf(m_szLost, MAX_DISPLAY_NAME, "%s.lost", pPropName->GetBuffer());
	m_ulIDLost = m_pRegistry->GetId(m_szLost);

	SafeSprintf(m_szClipBandwidth, MAX_DISPLAY_NAME, "%s.ClipBandwidth", pPropName->GetBuffer());
	m_ulIDClipBandwidth = m_pRegistry->GetId(m_szClipBandwidth);
	pPropName->Release();
    }

    /* 
     * We consider Local source as a Network source IFF someone uses core
     * for simulated network playback (used for Preview mode in the Encoder)
     */
    if (pSource->IsLocalSource() && !pSource->IsSimulatedNetworkPlayback())
    {
	/* Some large bandwidth */
	m_ulBandwidthAllocation = 0x7FFFFFFF;
	HXBOOL b;
	SetBandwidthUsage(m_ulBandwidthAllocation, b);
    }
    else if (pSource->IsPNAProtocol())
    {
	IHXBuffer* pMimeType = NULL;
	m_pHeader->GetPropertyCString("MimeTYpe", pMimeType);

	if (pMimeType && 
	    ::strcasecmp((const char*) pMimeType->GetBuffer(), "audio/x-pn-realaudio") == 0)
	{
	    /* Some large bandwidth */
	    m_ulBandwidthAllocation = 0x7FFFFFFF;
	    HXBOOL b;
	    SetBandwidthUsage(m_ulBandwidthAllocation, b);
	}
	HX_RELEASE(pMimeType);
    }
    else if (pRuleBook)
    {
	m_pLossCB = new LossCheckCallback(this);
	m_pLossCB->AddRef();
	m_ulLossCBHandle = m_pScheduler->RelativeEnter(m_pLossCB, 1000);
    }
    
    HX_RELEASE(pRuleBook);
}
コード例 #5
0
ファイル: advisesink.cpp プロジェクト: zhxinx/HelixInWebkit
	void WebkitClientAdviseSink::GetClipInfo()
	{
		// Get HXSource and try to get clip infor. 
		UINT32 sourceCount = m_pPlayer->GetSourceCount();	
		for (UINT32 sourceID = 0; sourceID < sourceCount; sourceID ++)
		{
			// get HXSource
			IUnknown* pUnkSource = NULL;
			IHXStreamSource* pStreamSrc = NULL;

			if (HXR_OK != m_pPlayer->GetSource (sourceID, pUnkSource))
			{
				continue;
			}

			IHXValues* pFileHeader = NULL;
			if ( HXR_OK == pUnkSource->QueryInterface( IID_IHXValues, ( void ** )&pFileHeader ) )
			{
				/*
				IHXBuffer* pAutoLoopingBuf = NULL;
				if ( HXR_OK == pFileHeader->GetPropertyBuffer( "Webkit_LOOP", pAutoLoopingBuf ) )
				{
					if ( 0 == strcmp( pAutoLoopingBuf->GetBuffer(), "true" ) )
					{
						m_pWebkitContext->SetAutoLooping( TRUE );
					}
				}
				HX_RELEASE( pAutoLoopingBuf );
				*/

				static const char * PROPERTY_NAMES[] = {
					"LiveStream",
					"HttpLiveStream",
					"AdaptiveHTTP"
				};
				UINT32 ulTmp = 0;
				for (int i = 0; i < sizeof(PROPERTY_NAMES)/sizeof(const char *); ++i)
				{
					pFileHeader->GetPropertyULONG32(PROPERTY_NAMES[i], ulTmp);
					if (ulTmp)
					{
						m_bIsLiveOrAdaptiveHTTP = TRUE;
						break;
					}
				}
			}
			HX_RELEASE( pFileHeader );

			pUnkSource->QueryInterface(IID_IHXStreamSource, (void **)&pStreamSrc);

			HX_RELEASE(pUnkSource);

			if (!pStreamSrc)
			{
				continue;
			}

			UINT32 num_streams = pStreamSrc->GetStreamCount();
			// get information from Streams
			for (UINT32 streamID = 0; streamID < num_streams ; streamID++)
			{
				IUnknown* pUnkStream = NULL;

				if (HXR_OK == pStreamSrc->GetStream(streamID, pUnkStream))
				{
					IHXStream* pStream = NULL;

					if (HXR_OK == pUnkStream->QueryInterface(IID_IHXStream, (void**)&pStream))
					{
						IHXValues* pStreamHdr = pStream->GetHeader();
						if (pStreamHdr)
						{
							SendClipProperties(pStreamHdr);
						}
						HX_RELEASE(pStreamHdr);
					}
					HX_RELEASE(pStream);
				}
				HX_RELEASE(pUnkStream);
			}
			HX_RELEASE(pStreamSrc);
		}
	}