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

📄 rtp.c

📁 Radvision rtpRtcp协议栈 4.5.0.18 版本
💻 C
📖 第 1 页 / 共 3 页
字号:
    rtpSession* s = (rtpSession *)hRTP;    RvAddress localAddress;    RvUint16 sockPort = 0;    RvStatus res;    res = RvSocketGetLocalAddress(&s->socket, logMgr, &localAddress);    if (res == RV_OK)    {        sockPort = RvAddressGetIpPort(&localAddress);        RvAddressDestruct(&localAddress);    }    return sockPort;}/************************************************************************************ * rtpGetVersion * description:  Returns the RTP version of the installed RTP Stack. * input:  none. * output: none. * return value: If no error occurs, the function returns the current version value. *               Otherwise, it returns a negative value. ***********************************************************************************/RVAPIchar * RVCALLCONV rtpGetVersion(void){    return (char*)VERSION_STR;}/************************************************************************************ * rtpGetVersionNum * description:  Returns the RTP version of the installed RTP Stack. * input:  none. * output: none. * return value: If no error occurs, the function returns the current version value. *               Otherwise, it returns a negative value. ***********************************************************************************/RVAPIRvUint32 RVCALLCONV rtpGetVersionNum(void){    return VERSION_NUM;}                    /* == ENDS: Basic RTP Functions == */                     /* == Accessory RTP Functions == *//************************************************************************************ * rtpGetRTCPSession * description:  Returns the RTCP session. * input:  hRTP - Handle of RTP session. * output: none. * return value: hRTCP - Handle of RTCP session. ***********************************************************************************/RVAPIHRTCPSESSION RVCALLCONV rtpGetRTCPSession(        IN  HRTPSESSION  hRTP){    rtpSession *s = (rtpSession *)hRTP;    return (s->hRTCP);}/************************************************************************************ * rtpSetRTCPSession * description:  set the RTCP session. * input:  hRTP  - Handle of RTP session. *         hRTCP - Handle of RTCP session. * output: none. * return value:return 0. ***********************************************************************************/RVAPIRvInt32 RVCALLCONV rtpSetRTCPSession(        IN  HRTPSESSION   hRTP,        IN  HRTCPSESSION  hRTCP){    rtpSession *s = (rtpSession *)hRTP;    s->hRTCP = hRTCP;    return RV_OK;}/************************************************************************************ * rtpGetHeaderLength * description:  return the header of RTP message. * input:  none. * output: none. * return value:The return value is twelve. ***********************************************************************************/RVAPIRvInt32 RVCALLCONV rtpGetHeaderLength(void){    return 12;}/************************************************************************************ * rtpRegenSSRC * description:  Generates a new synchronization source value for the RTP session. *               This function, in conjunction with rtpGetSSRC() may be used to *               change the SSRC value when an SSRC collision is detected. * input:  hRTP  - Handle of RTP session. * output: none. * return value: ssrc - If an error occurs, the function returns a negative value. *               If no error occurs, the function returns a non-negative value. ***********************************************************************************/RVAPIRvUint32 RVCALLCONV rtpRegenSSRC(        IN  HRTPSESSION  hRTP){    rtpSession *s = (rtpSession *)hRTP;    RvRandom randomValue;    /* those line is to prevent collision.*/    RvRandomGeneratorGetValue(&rvRtpInstance.randomGenerator, &randomValue);    s->sSrc = (RvUint32)randomValue * RvUint64ToRvUint32(RvUint64ShiftRight(RvTimestampGet(logMgr), 16));    s->sSrc &= ~s->sSrcMask;    s->sSrc |= s->sSrcPattern;    return s->sSrc;}/************************************************************************************ * rtpSetGroupAddress * description:  Defines a multicast IP for the RTP session. * input:  hRTP  - Handle of RTP session. *         ip    - Multicast IP address for the RTP session. * output: none. * return value: return 0. ***********************************************************************************/RVAPIRvInt32 RVCALLCONV rtpSetGroupAddress(        IN HRTPSESSION hRTP,    /* RTP Session Opaque Handle */        IN RvUint32     ip){    rtpSession *s = (rtpSession *)hRTP;    RvAddress addresses[2];    RvStatus res;    RvAddressConstructIpv4(&addresses[0], ip, RV_ADDRESS_IPV4_ANYPORT);    RvAddressConstructIpv4(&addresses[1], rvRtpInstance.localIp, RV_ADDRESS_IPV4_ANYPORT);    /* This function adds the specified address (in network format) to the specified       Multicast interface for the specified socket.*/    res = RvSocketJoinMulticastGroup(&s->socket, addresses, addresses+1, logMgr);    RvAddressDestruct(&addresses[0]);    RvAddressDestruct(&addresses[1]);    return res;}/************************************************************************************ * rtpResume * description:  Causes a blocked rtpRead() or rtpReadEx() function running in *               another thread to fail. * input:  hRTP  - Handle of RTP session. * output: none. * return value: If an error occurs, the function returns a negative value. *               If no error occurs, the function returns a non-negative value. ***********************************************************************************/RVAPIRvInt32 RVCALLCONV rtpResume(        IN  HRTPSESSION hRTP){    rtpSession *s = (rtpSession *)hRTP;    RvAddress localAddress;    RvAddressIpv4* localIpV4;    RvStatus status;    status = RvSocketGetLocalAddress(&s->socket, logMgr, &localAddress);    if (status == RV_OK)    {        localIpV4 = (RvAddressIpv4 *)RvAddressGetIpv4(&localAddress);        if (RvAddressIpv4GetIp(localIpV4) == RV_ADDRESS_IPV4_ANYADDRESS)        {            /* No specific IP on this socket - use our default one */            if (rvRtpInstance.localIp != RV_ADDRESS_IPV4_ANYADDRESS)                RvAddressIpv4SetIp(localIpV4, rvRtpInstance.localIp);            else                RvAddressIpv4SetIp(localIpV4, rvRtpInstance.hostIPs[0]);        }        /* We send a dummy buffer to get this connection released from its blocking mode */        RvSocketSendBuffer(&s->socket, (RvUint8*)"", 1, &localAddress, logMgr, NULL);        RvAddressDestruct(&localAddress);    }    return status;}/************************************************************************************ * rtpUseSequenceNumber * description:  Forces the Stack to accept user input for the sequence number of *               the RTP packet. The RTP Stack usually determines the sequence number. *               However, the application can force its own sequence number. *               Call rtpUseSequenceNumber() at the beginning of the RTP session and *               then specify the sequence number in the rtpParam structure of the *               rtpWrite() function. * input:  hRTP  - Handle of RTP session. * output: none. * return value: return 0. ***********************************************************************************/RVAPIRvInt32 RVCALLCONV rtpUseSequenceNumber(                IN HRTPSESSION  hRTP){    rtpSession *s = (rtpSession *)hRTP;    s->useSequenceNumber = 1;    return RV_OK;}/************************************************************************************ * rtpSetReceiveBufferSize * description:  Changes the RTP session receive buffer size. * input:  hRTP  - Handle of RTP session. * output: none. * return value: return 0. ***********************************************************************************/RVAPIRvInt32 RVCALLCONV rtpSetReceiveBufferSize(        IN HRTPSESSION  hRTP,        IN int size){    rtpSession* s = (rtpSession *)hRTP;    /* This function sets the size of the read/write buffers of a socket*/    return RvSocketSetBuffers(&s->socket, -1, size, logMgr);}/************************************************************************************ * rtpSetTransmitBufferSize * description:  Changes the RTP session transmit buffer size. * input:  hRTP - Handle of RTP session. *         size - The new transmit buffer size. * output: none. * return value: return 0. ***********************************************************************************/RVAPIRvInt32 RVCALLCONV rtpSetTransmitBufferSize(                IN HRTPSESSION  hRTP,                IN int size){    rtpSession* s = (rtpSession *)hRTP;    /* This function sets the size of the read/write buffers of a socket*/    return RvSocketSetBuffers(&s->socket, size, -1, logMgr);}/************************************************************************************ * rtpSetTrasmitBufferSize * description:  Changes the RTP session transmit buffer size. * input:  hRTP - Handle of RTP session. *         size - The new transmit buffer size. * output: none. * return value: return 0. * comment     : obsolete function provided for compatibility with prev. version ***********************************************************************************/RVAPIRvInt32 RVCALLCONV rtpSetTrasmitBufferSize(                IN HRTPSESSION  hRTP,                IN int size){  return rtpSetTransmitBufferSize(hRTP, size);}/************************************************************************************ * rtpGetAvailableBytes * description:  Gets the number of bytes available for reading in the RTP session. * input:  hRTP - Handle of RTP session. * output: none. * return value: If an error occurs, the function returns a negative value. *               If no error occurs, the function returns a non-negative value. ***********************************************************************************/RVAPIRvInt32 RVCALLCONV rtpGetAvailableBytes(                IN HRTPSESSION  hRTP){    rtpSession *s = (rtpSession *)hRTP;    RvSize_t bytes;    RvStatus ret;    /* This function returns the number of bytes in the specified socket that are       available for reading.*/    ret = RvSocketGetBytesAvailable(&s->socket, logMgr, &bytes);    if (ret != RV_OK)        return ret;    return (RvInt32)bytes;}#if defined(RV_DEPRECATED_CORE)/************************************************************************************ * rtpGetSeliHandle * description:  Gets Seli handle used by the rtp * output: none. * return value: Rtp Seli handle. ***********************************************************************************/RVAPIRV_SELI_Handle RVCALLCONV rtpGetSeliHandle(void){   return (RV_SELI_Handle)rvRtpInstance.selectEngine;}#endif /*RV_DEPRECATED_CORE*/                  /* == ENDS: Accessory RTP Functions == */                     /* == Internal RTP Functions == */static void rtpEvent(        IN RvSelectEngine*  selectEngine,        IN RvSelectFd*      fd,        IN RvSelectEvents   selectEvent,        IN RvBool           error){    rtpSession* s;    RV_UNUSED_ARG(selectEngine);    RV_UNUSED_ARG(selectEvent);    RV_UNUSED_ARG(error);    s = RV_GET_STRUCT(rtpSession, selectFd, fd);    if (s->eventHandler)    {        s->eventHandler((HRTPSESSION)s, s->context);    }}static RvBool isMyIP(RvUint32 ip){    RvUint32 i;    for (i = 0; (i < RV_RTP_MAXIPS) && (rvRtpInstance.hostIPs[i]); i++)    {        if (ip == rvRtpInstance.hostIPs[i])            return RV_TRUE;    }    return RV_FALSE;}                  /* == ENDS: Internal RTP Functions == */#ifdef __cplusplus}#endif

⌨️ 快捷键说明

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