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

📄 sdpmdgen.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 4 页
字号:
            // don't add it to attribute.            bAddToHeader = FALSE;            }        else        {            bAddToHeader = TRUE;            }        if(bAddToHeader)        {            NEW_FAST_TEMP_STR(pszAttBuf, 256, strlen(pPropName) + 64);            SafeSprintf(pszAttBuf, 256,"a=%s:integer;%d%s", pPropName, propValue,                                                    pszEOL);            headerAttributes += pszAttBuf;            DELETE_FAST_TEMP_STR(pszAttBuf);        }        /* make sure to reset SdpFileType header */        if (strcasecmp(pPropName, "SdpFileType") == 0)        {            pValueArray[0]->SetPropertyULONG32(pPropName, NONE_SDP);        }        rc = pValueArray[0]->GetNextPropertyULONG32(pPropName,            propValue);    }    /*      * 3GPP compliance: session-level "b=" parameter is required.  If we     * it's not in the file header, then compute it from component streams.     */    if (!bFoundAvgBitRate)    {        UINT32 ulSessionBitRate = 0;        UINT32 ulStreamBitRate = 0;                for(UINT16 i=2 ; i < nValues; ++i)        {            if (pValueArray[i])            {                if (HXR_OK == pValueArray[i]->GetPropertyULONG32("AvgBitRate",                                                               ulStreamBitRate))                {                       bFoundAvgBitRate = TRUE;                    ulSessionBitRate += ulStreamBitRate;                }            }        }        if (bFoundAvgBitRate)         {             // Convert bits/sec -> Kbits/sec (round up to nearest whole num)                avgBitRate = (UINT32) ((double)ulSessionBitRate / 1000.0 + 0.5);        }    }    rc = pValueArray[0]->GetFirstPropertyBuffer(pPropName, pPropBuffer);    while(rc == HXR_OK)    {        INT32 dataSize = pPropBuffer->GetSize();        char* pString = (char*) pPropBuffer->GetBuffer();        bAddToHeader = TRUE;         // add it to attribute by default        if (dataSize > 0 && pString != NULL && *pString != '\0')        {            if(strcasecmp(pPropName, "Title") == 0)            {                pszTitle = new char [ dataSize + 1 ];                memcpy(pszTitle, (const char*)pPropBuffer->GetBuffer(), dataSize); /* Flawfinder: ignore */                pszTitle[dataSize] = '\0';            }            else if(strcasecmp(pPropName, "Author") == 0)            {                pszAuthor = new char [ dataSize + 1 ];                memcpy(pszAuthor, (const char*)pPropBuffer->GetBuffer(), dataSize); /* Flawfinder: ignore */                pszAuthor[dataSize] = '\0';            }            else if(strcasecmp(pPropName, "Copyright") == 0)            {                pszCopyright = new char [ dataSize + 1 ];                memcpy(pszCopyright, (const char*)pPropBuffer->GetBuffer(), dataSize); /* Flawfinder: ignore */                pszCopyright[dataSize] = '\0';            }            if (bAddToHeader)            {                NEW_FAST_TEMP_STR(pszAttBuf, 4096, dataSize * 2 + strlen(pPropName)                                                   + 64);                NEW_FAST_TEMP_STR(pszPropString, 4096, dataSize * 2 + 64);                (void)BinTo64((const BYTE*)pPropBuffer->GetBuffer(),                    dataSize, pszPropString);                SafeSprintf(pszAttBuf, 4096, "a=%s:buffer;\"%s\"%s",pPropName,                                                           pszPropString, pszEOL);                headerAttributes += pszAttBuf;                DELETE_FAST_TEMP_STR(pszPropString);                DELETE_FAST_TEMP_STR(pszAttBuf);            }        }        HX_RELEASE(pPropBuffer);        rc = pValueArray[0]->GetNextPropertyBuffer(pPropName,            pPropBuffer);    }    rc = pValueArray[0]->GetFirstPropertyCString(pPropName,        pPropBuffer);    while(rc == HXR_OK)    {        char* pString = (char*) pPropBuffer->GetBuffer();        char* pszData=NULL;        BOOL bDeleteString=FALSE;        bAddToHeader = FALSE;        INT32 dataSize = pPropBuffer->GetSize();        if (dataSize > 0 && pString != NULL && *pString != '\0')        {            if(strcasecmp(pPropName, "Title") == 0)            {                pszTitle = EscapeBuffer(pString, pPropBuffer->GetSize());                pszData = pszTitle;                bAddToHeader = TRUE;                }            else if(strcasecmp(pPropName, "Author") == 0)            {                pszAuthor = EscapeBuffer(pString, pPropBuffer->GetSize());                pszData = pszAuthor;                bAddToHeader = TRUE;                }            else if(strcasecmp(pPropName, "Copyright") == 0)            {                pszCopyright = EscapeBuffer(pString, pPropBuffer->GetSize());                pszData = pszCopyright;                bAddToHeader = TRUE;                }            else if(strcasecmp(pPropName, "MulticastAddress") == 0)            {                pszConnAddr = EscapeBuffer(pString, pPropBuffer->GetSize());            }            else if(strcasecmp(pPropName, "SDPData") == 0)            {                pszSDPData = new char [ dataSize + 1 ];                memcpy(pszSDPData, (const char*)pPropBuffer->GetBuffer(), dataSize); /* Flawfinder: ignore */                pszSDPData[dataSize] = '\0';		RemoveASLine(pszSDPData, dataSize);            }               else if(strcasecmp(pPropName, "Information") == 0)            {                // "i="                pszInfo = EscapeBuffer(pString, pPropBuffer->GetSize());            }            else            {                pszData = EscapeBuffer(pString, pPropBuffer->GetSize());                bAddToHeader = TRUE;                bDeleteString = TRUE;            }            if(bAddToHeader)            {                HX_ASSERT(pszData);                NEW_FAST_TEMP_STR(pszAttBuf, 4096, dataSize +                                                   strlen(pPropName) + 64);                SafeSprintf(pszAttBuf, 4096,"a=%s:string;\"%s\"%s", pPropName,                                                           pszData, pszEOL);                headerAttributes += pszAttBuf;                DELETE_FAST_TEMP_STR(pszAttBuf);            }            if (bDeleteString)            {                HX_VECTOR_DELETE(pszData);            }        }                HX_RELEASE(pPropBuffer);        rc = pValueArray[0]->GetNextPropertyCString(pPropName,                                                    pPropBuffer);    }    /*     *  Things in headerAttributes that depend on the value in "SdpFileType"     */    if (!bIsLive)    {        if (bDefaultDurationFound)        {                NPTime npTime(ulDefaultDuration);            const char* pszTime = (const char*)npTime;            headerAttributes += "a=range:npt=0-";            headerAttributes += pszTime;            headerAttributes += pszEOL;        }                       else        {            /*             * error case - SpecComplianceCheck() should be taking care of it.             *             * let's just treat it as live.  When file is done, RTCP_BYE             * will be sent, and client TEARDOWN             */                if (bUseOldSdp)                {                    SafeSprintf(psz256, 256, "a=range:npt=0-0%s", pszEOL);                         headerAttributes += psz256;                             }                else                {                    SafeSprintf(psz256, 256,"a=range:npt=0-%s", pszEOL);                         headerAttributes += psz256;                             }        }    }            if (!pszTitle)    {       SafeSprintf(psz256, 256,"s=<No title>%s", pszEOL);        mDesc += psz256;    }    else    {        NEW_FAST_TEMP_STR(pszTmpStr, 256, strlen(pszTitle) + 64);        SafeSprintf(pszTmpStr, 256, "s=%s%s", pszTitle, pszEOL);         mDesc += pszTmpStr;        DELETE_FAST_TEMP_STR(pszTmpStr);    }    if (pszInfo)    {        NEW_FAST_TEMP_STR(pszTmpStr, 256, strlen(pszInfo) + 64);        SafeSprintf(pszTmpStr, 256,"i=%s%s", pszInfo, pszEOL);         mDesc += pszTmpStr;        DELETE_FAST_TEMP_STR(pszTmpStr);        HX_VECTOR_DELETE(pszInfo);        pszInfo = NULL;    }    else    {        const char* pszDefaultAuthor = "<No author>";        const char* pszDefaultCopyright = "<No copyright>";        UINT32 len = 64;        len += pszAuthor ? strlen(pszAuthor) : 16;        len += pszCopyright ? strlen(pszCopyright) : 16;        NEW_FAST_TEMP_STR(pszTmpString, 512, len);        SafeSprintf(pszTmpString, 256, "i=%s %s%s",            pszAuthor ? pszAuthor : pszDefaultAuthor,             pszCopyright ? pszCopyright : pszDefaultCopyright,            pszEOL);        mDesc += pszTmpString;        DELETE_FAST_TEMP_STR(pszTmpString);    }    if (pszTitle)        HX_VECTOR_DELETE(pszTitle);    if (pszAuthor)        HX_VECTOR_DELETE(pszAuthor);    if (pszCopyright)        HX_VECTOR_DELETE(pszCopyright);    /* Format the connection line only if MulticastAddress and MulticastTTL     * exist in the file header     */    if (pszConnAddr && strlen(pszConnAddr) && bFoundTTL)    {        NEW_FAST_TEMP_STR(pszTmpString, 256, strlen(pszConnAddr) + 64);        if (bFoundRange)        {            SafeSprintf(pszTmpString,256, "c=IN IP4 %s/%d/%d%s",                 pszConnAddr, connTTL, connRange, pszEOL);        }        else        {            SafeSprintf(pszTmpString, 256, "c=IN IP4 %s/%d%s",                pszConnAddr, connTTL, pszEOL);        }        mDesc += pszTmpString;        DELETE_FAST_TEMP_STR(pszTmpString);    }    else if (!bUseOldSdp)    {           // we still need a c= line with a NULL value (RFC 2326 C.1.7)        // XXXGo        // Since adding this line w/o TTL (i.e. 0.0.0.0/ttl) will cause         // older sdpplin to skip the next line (due to a wrong parsing),         // add this only when we are using new sdp type.        mDesc += "c=IN IP4 0.0.0.0";        mDesc += pszEOL;    }        if (bFoundAvgBitRate)    {        SafeSprintf(psz256, 256, "b=AS:%u%s", avgBitRate, pszEOL);         mDesc += psz256;        bFoundAvgBitRate = FALSE;    }    mDesc += "t=0 0";    mDesc += pszEOL;    /* add sdpplin version */    SafeSprintf(psz256, 256, "a=SdpplinVersion:%u%s", m_ulVersion, pszEOL);     mDesc += psz256;        mDesc += headerAttributes;    // expand SDPData if it's there...    if (pszSDPData)    {        mDesc += pszSDPData;        HX_VECTOR_DELETE(pszSDPData);        pszSDPData = NULL;    }    for(UINT16 i=2;i<nValues;++i)    {        if(pValueArray[i])        {            CHXString streamAttributes;            streamAttributes.SetMinBufSize(8192);            UINT32 streamNumber = 0;            BOOL   bStreamNumberFound=FALSE;            UINT32 duration = 0;            BOOL   bDurationFound = FALSE;            UINT32 rtpPayloadType = 0;            BOOL   bRtpPayloadTypeFound=FALSE;            UINT32 samplesPerSecond = 0;            BOOL   bSamplesPerSecondFound=FALSE;            UINT32 nChannels = 0;            BOOL   bChannelsFound=FALSE;            UINT32 port = 0;            UINT32 ulPayloadType = 0;            BOOL   bFoundRTCPRR = FALSE;            UINT32 ulRTCPRR = 0;            BOOL   bFoundRTCPSR = FALSE;            UINT32 ulRTCPSR = 0;            BOOL   bFoundPreDecBufSize = FALSE;            UINT32 ulPreDecBufSize = 0;            BOOL   bFoundPreDecBufPeriod = FALSE;            UINT32 ulPreDecBufPeriod = 0;            BOOL   bFoundPostDecBufPeriod = FALSE;            UINT32 ulPostDecBufPeriod = 0;            BOOL   bFoundDecByteRate = FALSE;            UINT32 ulDecByteRate = 0;            char* pszMimeType=NULL;            char* pszMimeFirst=NULL;            UINT32 ulMimeFirstBufLen = 0;            char* pszMimeLast=NULL;                        UINT32 ptime=0;            BOOL bPtimeFound=FALSE;            char* pszFmtp=NULL;            // Reuse connection strings from file header            if (pszConnAddr)            {                HX_VECTOR_DELETE(pszConnAddr);                pszConnAddr = NULL;            }            bFoundTTL = FALSE;            bFoundRange = FALSE;            port = 0;                        rc = pValueArray[i]->GetFirstPropertyULONG32(pPropName, propValue);            while(rc == HXR_OK)            {                bAddToHeader = FALSE;                if(strcasecmp(pPropName, "StreamNumber") == 0)                {                    streamNumber = propValue;                    bStreamNumberFound = TRUE;                }                else if(strcasecmp(pPropName, "Duration") == 0)                {

⌨️ 快捷键说明

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