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

📄 sdpplin.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        *ppvObj = (IHXRTPPayloadInfo*)this;        return HXR_OK;    }    *ppvObj = NULL;    return HXR_NOINTERFACE;}///////////////////////////////////////////////////////////////////////////  Method://        IUnknown::AddRef//  Purpose://        Everyone usually implements this the same... feel free to use//        this implementation.//STDMETHODIMP_(ULONG32) CSDPStreamDescription::AddRef(){    return InterlockedIncrement(&m_lRefCount);}///////////////////////////////////////////////////////////////////////////  Method://        IUnknown::Release//  Purpose://        Everyone usually implements this the same... feel free to use//        this implementation.//STDMETHODIMP_(ULONG32) CSDPStreamDescription::Release(){    if (InterlockedDecrement(&m_lRefCount) > 0)    {        return m_lRefCount;    }    delete this;    return 0;}// *** IHXStreamDescription methods ***CSDPStreamDescription::CSDPStreamDescription()                : m_lRefCount(0)                , m_pDescParser(0)                , m_pDescGenerator(0)                , m_pContext(0)                , m_pCCF(0){    RefCountSDPP()++;    m_pDescParser = new SDPMediaDescParser(TARVER_ULONG32_VERSION);#if defined(HELIX_FEATURE_SERVER)    m_pDescGenerator = new SDPMediaDescGenerator(SDP_MEDIA_DESC_GENERATOR_VERSION);#endif /* defined(HELIX_FEATURE_SERVER) */}CSDPStreamDescription::~CSDPStreamDescription(){    RefCountSDPP()--;    delete m_pDescParser;    HX_DELETE(m_pDescGenerator);    HX_RELEASE(m_pCCF);    HX_RELEASE(m_pContext);}HX_RESULTCSDPStreamDescription::Update(){    IHXPlayer* pPlayer = NULL;    if (HXR_OK == m_pContext->QueryInterface(IID_IHXPlayer, (void**)&pPlayer))    {                    IHXUpgradeCollection* pUpgradeCollection = NULL;        if (HXR_OK == pPlayer->QueryInterface(IID_IHXUpgradeCollection,                 (void**)&pUpgradeCollection))        {            IHXBuffer* pBuf = NULL;            m_pCCF->CreateInstance(CLSID_IHXBuffer, (void**)&pBuf);            if (!pBuf)            {                HX_RELEASE(pUpgradeCollection);                HX_RELEASE(pPlayer);                                return HXR_OUTOFMEMORY;            }            pBuf->Set((const BYTE*)zm_pStreamDescriptionMimeType,                     strlen(zm_pStreamDescriptionMimeType) + 1);            pUpgradeCollection->Add(eUT_Required, pBuf, 0, 0);            HX_RELEASE(pBuf);        }        HX_RELEASE(pUpgradeCollection);        }    HX_RELEASE(pPlayer);                    return HXR_OK;}STDMETHODIMPCSDPStreamDescription::GetValues(IHXBuffer* pDescription,    REF(UINT16) nValues, REF(IHXValues**) pValueArray){    HX_RESULT res = HXR_UNEXPECTED;    if (m_pDescParser)        res = m_pDescParser->Parse(pDescription, nValues, pValueArray);    if (HXR_REQUEST_UPGRADE == res)    {        res = Update();        if (HXR_OK == res)            res = HXR_REQUEST_UPGRADE;    }    return res;}STDMETHODIMPCSDPStreamDescription::GetDescription(UINT16 nValues, IHXValues** pValueArray,    REF(IHXBuffer*) pDescription){    HX_RESULT res = HXR_UNEXPECTED;    if (m_pDescGenerator)        res = m_pDescGenerator->Generate(nValues, pValueArray, pDescription);    return res;}// *** IHXStreamDescriptionSettings methods ***STDMETHODIMPCSDPStreamDescription::SetOption(const char* pKey, IHXBuffer* pVal){    if (pKey == NULL || pVal == NULL)    {        return HXR_POINTER;    }    const char* pszVal = (const char*)pVal->GetBuffer();    if (pszVal == NULL || *(pszVal+pVal->GetSize()-1) != '\0')    {        return HXR_UNEXPECTED;    }    HX_RESULT pnr = HXR_FAIL;    if ((strcasecmp(pKey, "UseOldEOL") == 0) && m_pDescGenerator)    {        if (strcasecmp(pszVal, "true") == 0)        {            m_pDescGenerator->SetUseOldEOL(TRUE);            pnr = HXR_OK;        }        else if (strcasecmp(pszVal, "false") == 0)        {            m_pDescGenerator->SetUseOldEOL(FALSE);            pnr = HXR_OK;        }    }    else if (strcasecmp(pKey, "AbsoluteBaseURL") == 0)    {        if (*pszVal == '0')        {                m_pDescGenerator->SetUseAbsoluteURL(FALSE);            pnr = HXR_OK;        }        else if  (*pszVal == '1')        {                m_pDescGenerator->SetUseAbsoluteURL(TRUE);            pnr = HXR_OK;        }    }    else if (strcasecmp(pKey, "SessionGUID") == 0)    {        if (*pszVal == '0')        {                m_pDescGenerator->SetUseSessionGUID(FALSE);            pnr = HXR_OK;        }        else if  (*pszVal == '1')        {                m_pDescGenerator->SetUseSessionGUID(TRUE);        }    }    // add new options here    return pnr;}STDMETHODIMPCSDPStreamDescription::GetOption(const char* pKey, REF(IHXBuffer*) pVal){    if (pKey == NULL)    {        return HXR_POINTER;    }    if (m_pCCF == NULL)    {        return HXR_UNEXPECTED;    }    m_pCCF->CreateInstance(CLSID_IHXBuffer, (void**)&pVal);    if (pVal == NULL)    {        return HXR_OUTOFMEMORY;    }    HX_RESULT pnr = HXR_FAIL;    char* pszVal;    if ((strcasecmp(pKey, "UseOldEOL") == 0) && m_pDescGenerator)    {        pVal->SetSize(5+1);        pszVal = (char*)pVal->GetBuffer();        strcpy(pszVal, (m_pDescGenerator->GetUseOldEOL()?"true":"false")); /* Flawfinder: ignore */        pnr = HXR_OK;    }    else    {        BOOL bIsOptionSet = FALSE;        if (strcasecmp(pKey, "AbsoluteBaseURL") == 0)        {            bIsOptionSet = m_pDescGenerator->GetUseAbsoluteURL();            pnr = HXR_OK;        }        else if (strcasecmp(pKey, "SessionGUID") == 0)        {            bIsOptionSet = m_pDescGenerator->GetUseSessionGUID();            pnr = HXR_OK;        }        if (HXR_OK == pnr)        {            pVal->SetSize(5+1);            pszVal = (char*)pVal->GetBuffer();            strcpy(pszVal, (bIsOptionSet ? "true":"false")); /* Flawfinder: ignore */        }    }    if (pnr != HXR_OK)    {        HX_RELEASE(pVal);    }    return pnr;}// *** IHXRTPPayloadInfo methods ***/************************************************************************ *        Method: *            IHXRTPPayloadInfo::PayloadSupported *        Purpose: *            Returns TRUE if this payload type is handled by this interface */ BOOLCSDPStreamDescription::IsPayloadSupported(UINT32 ulRTPPayloadType){    // make sure it's not one of reserved/unassigned ones    if (SDPIsStaticPayload(ulRTPPayloadType) &&        SDPMapPayloadToEncodingName(ulRTPPayloadType))    {        return TRUE;            }    return FALSE;}/************************************************************************ *        Method: *            IHXRTPPayloadInfo::GetTimestampConversionFactors *        Purpose: *            Retrieves the RTP and RMA factors for RTP to RMA timestamp ratio. *      RTP->RMA is RTPTimestamp * RTPFactor / HXFactor *      RMA->RTP is HXTimestamp * HXFactor / RTPFactor *         *        Note: does not check if the payload type is supported */ STDMETHODIMPCSDPStreamDescription::GetTimestampConversionFactors(                                    UINT32 ulRTPPayloadType,    REF(UINT32) /*OUT*/ ulRTPFactor,    REF(UINT32) /*OUT*/ ulHXFactor){    HX_ASSERT(IsPayloadSupported(ulRTPPayloadType));    ulRTPFactor = SDPMapPayloadToRTPFactor(ulRTPPayloadType);    ulHXFactor = SDPMapPayloadToRMAFactor(ulRTPPayloadType);    return HXR_OK;}/************************************************************************ *        Method: *            IHXRTPPayloadInfo::IsTimestampDeliverable *        Purpose: *            Returns TRUE if this payload type is timestamp deliverable */ BOOLCSDPStreamDescription::IsTimestampDeliverable(UINT32 ulRTPPayloadType){    HX_ASSERT(IsPayloadSupported(ulRTPPayloadType));    return SDPIsTimestampDeliverable(ulRTPPayloadType);    }

⌨️ 快捷键说明

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