how and where share my codes

Asked by regulararmy on 2017-12-12

Hello Didier,

how and where can I share my codes?

Regards,
rarmy

Question information

Language:
English Edit question
Status:
Solved
For:
rohc Edit question
Assignee:
No assignee Edit question
Solved by:
Didier Barvaux
Solved:
2017-12-18
Last query:
2017-12-18
Last reply:
2017-12-17

Hi,

You may share your changes to the ROHC library in several ways:
* create a Github account (if you don't have one yet), create a fork of the ROHC projet, push your changes to a dedicated Git branch and then create a pull request for me: click on the "Fork" button on the top-right of https://github.com/didier-barvaux/rohc to begin the process
* send your patches to the ROHC mailing list : https://rohc-lib.org/support/mailing-list/

Regards,
Didier

regulararmy (regulararmy) said : #2

Thanks Didier Barvaux, that solved my question.

regulararmy (regulararmy) said : #3

I only modify a little for my college study,maybe it is not necessary to share.

Tell me what are your modifications. I'll tell you if it is of interest for all.

regulararmy (regulararmy) said : #5

It is about RTP detection.

That looks interesting ! What did you changed ? Is it the library itself or did you improve the code in the RTP callback?

regulararmy (regulararmy) said : #7

I modify the code in the RTP callback,it shows as follows:
uint8_t count = 0;
uint32_t ssrc[4] = {0};
static bool rtp_detect_cb(const unsigned char *const ip,
                          const unsigned char *const udp,
                          const unsigned char *const payload,
                          const unsigned int payload_size,
                          void *const rtp_private)
{
 const uint16_t max_well_known_port = 1024;
 const uint16_t sip_port = 5060;
 uint16_t udp_sport;
 uint16_t udp_dport;
 uint16_t udp_len;
 uint8_t rtp_pt;
 uint32_t currentSsrc ;
 bool is_rtp = false;

 assert(ip != NULL);
 assert(udp != NULL);
 assert(payload != NULL);
 assert(rtp_private == NULL);

 /* retrieve UDP source and destination ports and UDP length */
 memcpy(&udp_sport, udp, sizeof(uint16_t));
 memcpy(&udp_dport, udp + 2, sizeof(uint16_t));
 memcpy(&udp_len, udp + 4, sizeof(uint16_t));

 /* RTP streams do not use well known ports */
 if(ntohs(udp_sport) <= max_well_known_port ||
    ntohs(udp_dport) <= max_well_known_port)
 {
  goto not_rtp;
 }

 /* SIP (UDP/5060) is not RTP */
 if(ntohs(udp_sport) == sip_port && ntohs(udp_dport) == sip_port)
 {
  goto not_rtp;
 }

 /* the UDP destination port of RTP packet is even (the RTCP destination
  * port are RTP destination port + 1, so it is odd) */
 if((ntohs(udp_dport) % 2) != 0)
 {
  goto not_rtp;
 }

 /* UDP Length shall not be too large */
 if(ntohs(udp_len) > 200)
 {
  goto not_rtp;
 }

 /* UDP payload shall at least contain the smallest RTP header */
 if(payload_size < 12)
 {
  goto not_rtp;
 }

 /* RTP version bits shall be 2 */
 if(((payload[0] >> 6) & 0x3) != 0x2)
 {
  goto not_rtp;
 }

 /* RTP payload type shall be GSM (0x03), ITU-T G.723 (0x04),
  * ITU-T G.729 (0x12), dynamic RTP type 97 (0x61),
  * telephony-event (0x65), Speex (0x72),
  * or dynamic RTP type 125 (0x7d) */
 rtp_pt = payload[1] & 0x7f;
 if(rtp_pt != 0x03 && rtp_pt != 0x04 && rtp_pt != 0x12 && rtp_pt != 0x61 &&
    rtp_pt != 0x65 && rtp_pt != 0x72 && rtp_pt != 0x7d)
 {
  goto not_rtp;
 }

    memcpy(&currentSsrc, payload + 8, sizeof(uint32_t));
    if(ssrc[0] != ntohl(currentSsrc) || ssrc[1] != ntohl(currentSsrc)||ssrc[2] != ntohl(currentSsrc) || ssrc[3] != ntohl(currentSsrc))
    {
        ssrc[count++ & 0x03] = ntohl(currentSsrc);
        goto not_rtp;
    }
 /* we think that the UDP packet is a RTP packet */
 is_rtp = true;

not_rtp:
 return is_rtp;
}