Changeset 107


Ignore:
Timestamp:
08/26/10 21:20:12 (18 months ago)
Author:
shiretu
Message:

-- added second implementation for RTCP packets

Location:
trunk/sources/thelib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/thelib/include/protocols/rtp/connectivity/outboundconnectivity.h

    r106 r107  
    3636        uint32_t _videoBytesCount; 
    3737        uint32_t _videoFirstRtp; 
     38        double _videoNextRTCPTs; 
    3839        map<uint32_t, sockaddr_in> _udpVideoDataClients; 
    3940        map<uint32_t, sockaddr_in> _udpVideoRTCPClients; 
     
    4647        uint32_t _audioBytesCount; 
    4748        uint32_t _audioFirstRtp; 
     49        double _audioNextRTCPTs; 
    4850        map<uint32_t, sockaddr_in> _udpAudioDataClients; 
    4951        map<uint32_t, sockaddr_in> _udpAudioRTCPClients; 
     
    5355        msghdr _message; 
    5456        double _startupTime; 
     57        double _nextRTCPIncrement; 
    5558public: 
    5659        OutboundConnectivity(); 
     
    8790        bool FeedAudioDataUDP(msghdr &message); 
    8891        bool FeedAudioDataTCP(msghdr &message); 
    89         bool CreateRTCPPacket(uint8_t *pDest, uint8_t *pSrc, 
     92        bool CreateRTCPPacket_mystyle(uint8_t *pDest, uint8_t *pSrc, 
     93                        uint32_t ssrc, uint32_t rate, uint32_t packetsCount, 
     94                        uint32_t bytesCount, bool isAudio); 
     95        bool CreateRTCPPacket_live555style(uint8_t *pDest, uint8_t *pSrc, 
    9096                        uint32_t ssrc, uint32_t rate, uint32_t packetsCount, 
    9197                        uint32_t bytesCount, bool isAudio); 
  • trunk/sources/thelib/src/protocols/rtp/connectivity/outboundconnectivity.cpp

    r106 r107  
    7878while (0) 
    7979 
     80//#define CreateRTCPPacket CreateRTCPPacket_mystyle 
     81#define CreateRTCPPacket CreateRTCPPacket_live555style 
     82 
    8083OutboundConnectivity::OutboundConnectivity() 
    8184: BaseConnectivity() { 
     85        _nextRTCPIncrement = 1000.00; 
     86 
    8287        _videoDataFd = -1; 
    8388        _videoDataPort = 0; 
     
    8792        _videoBytesCount = 0; 
    8893        _videoFirstRtp = 0; 
     94        _videoNextRTCPTs = _nextRTCPIncrement; 
    8995 
    9096        _audioDataFd = -1; 
     
    95101        _audioBytesCount = 0; 
    96102        _audioFirstRtp = 0; 
     103        _audioNextRTCPTs = _nextRTCPIncrement; 
    97104 
    98105        _pOutStream = NULL; 
     
    383390} 
    384391 
    385 bool OutboundConnectivity::CreateRTCPPacket(uint8_t *pDest, uint8_t *pSrc, 
     392bool OutboundConnectivity::CreateRTCPPacket_mystyle(uint8_t *pDest, uint8_t *pSrc, 
    386393                uint32_t ssrc, uint32_t rate, uint32_t packetsCount, uint32_t bytesCount, 
    387394                bool isAudio) { 
     
    406413        +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 
    407414         */ 
    408  
    409         //      WARN("%s: MUST send SR to %d clients", 
    410         //                      isAudio ? "Audio" : "Video", 
    411         //                      _udpVideoRTCPClients.size()); 
    412415 
    413416        //1. V,P,RC 
     
    481484} 
    482485 
     486bool OutboundConnectivity::CreateRTCPPacket_live555style(uint8_t *pDest, uint8_t *pSrc, 
     487                uint32_t ssrc, uint32_t rate, uint32_t packetsCount, uint32_t bytesCount, 
     488                bool isAudio) { 
     489 
     490        /* 
     491         0                   1                   2                   3 
     492         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
     493        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     494        |V=2|P|    RC   |   PT=SR=200   |             length            | header 
     495        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     496        |                         SSRC of sender                        | 
     497        +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 
     498        |              NTP timestamp, most significant word             | sender 
     499        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ info 
     500        |             NTP timestamp, least significant word             | 
     501        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     502        |                         RTP timestamp                         | 
     503        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     504        |                     sender's packet count                     | 
     505        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     506        |                      sender's octet count                     | 
     507        +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 
     508         */ 
     509 
     510        //1. V,P,RC 
     511        pDest[0] = 0x80; 
     512 
     513        //2. PT 
     514        pDest[1] = 0xc8; 
     515 
     516        //3. Length 
     517        pDest[2] = 0x00; 
     518        pDest[3] = 0x06; 
     519 
     520        //4. ssrc 
     521        put_htonl(pDest + 4, ssrc); //SSRC 
     522 
     523        //5. NTP 
     524        struct timeval timeNow; 
     525        gettimeofday(&timeNow, NULL); 
     526        put_htonl(pDest + 8, timeNow.tv_sec + 0x83AA7E80); 
     527        double fractionalPart = (timeNow.tv_usec / 15625.0)*0x04000000; // 2^32/10^6 
     528        put_htonl(pDest + 12, (uint32_t) fractionalPart); 
     529 
     530        //6. RTP 
     531        uint32_t timestampIncrement = (rate * timeNow.tv_sec); 
     532        timestampIncrement += (uint32_t) ((2.0 * rate * timeNow.tv_usec + 1000000.0) / 2000000); 
     533        uint32_t rtpTimestamp = 0 + timestampIncrement; 
     534        put_htonl(pDest + 16, rtpTimestamp); 
     535 
     536        //7. sender's packet count 
     537        put_htonl(pDest + 20, packetsCount); 
     538 
     539        //8. sender's octet count 
     540        put_htonl(pDest + 24, bytesCount); 
     541 
     542        return true; 
     543} 
     544 
    483545#endif /* HAS_PROTOCOL_RTP */ 
Note: See TracChangeset for help on using the changeset viewer.