📄 sdpplin.cpp
字号:
/////////////////////////////////////////////////////////////////////////
// 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_RESULT
CSDPStreamDescription::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;
}
STDMETHODIMP
CSDPStreamDescription::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;
}
STDMETHODIMP
CSDPStreamDescription::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 ***
STDMETHODIMP
CSDPStreamDescription::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;
}
STDMETHODIMP
CSDPStreamDescription::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
*/
BOOL
CSDPStreamDescription::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
*/
STDMETHODIMP
CSDPStreamDescription::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
*/
BOOL
CSDPStreamDescription::IsTimestampDeliverable(UINT32 ulRTPPayloadType)
{
HX_ASSERT(IsPayloadSupported(ulRTPPayloadType));
return SDPIsTimestampDeliverable(ulRTPPayloadType);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -