~didier-barvaux/+junk/rohc-tcp

« back to all changes in this revision

Viewing changes to src/decomp/d_rtp.c

  • Committer: Didier Barvaux
  • Date: 2013-06-30 12:53:19 UTC
  • mfrom: (535.1.213 rohc-main)
  • Revision ID: didier@barvaux.org-20130630125319-33xosfau63ygas1f
Sync with main branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
589
589
        }
590
590
        bits->udp_check = GET_NEXT_16_BITS(packet);
591
591
        bits->udp_check_nr = 16;
592
 
        rohc_decomp_debug(context, "UDP checksum = 0x%04x\n", ntohs(bits->udp_check));
 
592
        rohc_decomp_debug(context, "UDP checksum = 0x%04x\n",
 
593
                          rohc_ntoh16(bits->udp_check));
593
594
        packet += sizeof(uint16_t);
594
595
        read += sizeof(uint16_t);
595
596
        length -= sizeof(uint16_t);
634
635
        length--;
635
636
 
636
637
        /* part 4: 16-bit RTP SN */
637
 
        bits->sn = ntohs(GET_NEXT_16_BITS(packet));
 
638
        bits->sn = rohc_ntoh16(GET_NEXT_16_BITS(packet));
638
639
        bits->sn_nr = 16;
639
640
        packet += sizeof(uint16_t);
640
641
        read += sizeof(uint16_t);
643
644
 
644
645
        /* part 5: 4-byte TimeStamp (TS) */
645
646
        memcpy(&bits->ts, packet, sizeof(uint32_t));
646
 
        bits->ts = ntohl(bits->ts);
 
647
        bits->ts = rohc_ntoh32(bits->ts);
647
648
        bits->ts_nr = 32;
648
649
        read += sizeof(uint32_t);
649
650
        packet += sizeof(uint32_t);
665
666
        /* part 7 */
666
667
        if(rx)
667
668
        {
668
 
                int x, mode, tis, tss;
 
669
                int mode, tis, tss;
669
670
 
670
671
                /* check the minimal length to decode the flags that are only present
671
672
                   if RX flag is set */
677
678
                        goto error;
678
679
                }
679
680
 
680
 
                x = GET_REAL(GET_BIT_4(packet));
 
681
                bits->rtp_x = GET_REAL(GET_BIT_4(packet));
 
682
                bits->rtp_x_nr = 1;
681
683
                mode = ((*packet) >> 2) & 0x03;
682
684
                tis = GET_REAL(GET_BIT_1(packet));
683
685
                tss = GET_REAL(GET_BIT_0(packet));
684
 
                rohc_decomp_debug(context, "x = %d, rohc_mode = %d, tis = %d, "
685
 
                                  "tss = %d\n", x, mode, tis, tss);
 
686
                rohc_decomp_debug(context, "X = %u, rohc_mode = %d, tis = %d, "
 
687
                                  "tss = %d\n", bits->rtp_x, mode, tis, tss);
686
688
                read++;
687
689
                packet++;
688
690
                length--;
800
802
                bits->udp_check = GET_NEXT_16_BITS(packet);
801
803
                bits->udp_check_nr = 16;
802
804
                rohc_decomp_debug(context, "UDP checksum = 0x%04x\n",
803
 
                                  ntohs(bits->udp_check));
 
805
                                  rohc_ntoh16(bits->udp_check));
804
806
                packet += 2;
805
807
                read += 2;
806
808
        }
862
864
                decoded->udp_src = udp->source;
863
865
        }
864
866
        rohc_decomp_debug(context, "decoded UDP source port = 0x%04x\n",
865
 
                          ntohs(decoded->udp_src));
 
867
                          rohc_ntoh16(decoded->udp_src));
866
868
 
867
869
        /* decode UDP destination port */
868
870
        if(bits.udp_dst_nr > 0)
877
879
                decoded->udp_dst = udp->dest;
878
880
        }
879
881
        rohc_decomp_debug(context, "decoded UDP destination port = 0x%04x\n",
880
 
                          ntohs(decoded->udp_dst));
 
882
                          rohc_ntoh16(decoded->udp_dst));
881
883
 
882
884
        /* UDP checksum:
883
885
         *  - error if udp_checksum_present not initialized,
910
912
                decoded->udp_check = 0;
911
913
        }
912
914
        rohc_decomp_debug(context, "decoded UDP checksum = 0x%04x (checksum "
913
 
                          "present = %d)\n", ntohs(decoded->udp_check),
 
915
                          "present = %d)\n", rohc_ntoh16(decoded->udp_check),
914
916
                          rtp_context->udp_checksum_present);
915
917
 
916
918
        /* decode version field */
1102
1104
        udp->check = decoded.udp_check;
1103
1105
 
1104
1106
        /* UDP interfered fields */
1105
 
        udp->len = htons(payload_len + sizeof(struct udphdr) + sizeof(struct rtphdr));
1106
 
        rohc_decomp_debug(context, "UDP + RTP length = 0x%04x\n", ntohs(udp->len));
 
1107
        udp->len = rohc_hton16(payload_len + sizeof(struct udphdr) +
 
1108
                               sizeof(struct rtphdr));
 
1109
        rohc_decomp_debug(context, "UDP + RTP length = 0x%04x\n",
 
1110
                          rohc_ntoh16(udp->len));
1107
1111
 
1108
1112
        /* RTP fields: version, R-P flag, R-X flag, M flag, R-PT, TS and SN */
1109
1113
        rtp->version = decoded.rtp_version;
1113
1117
        rtp->m = decoded.rtp_m;
1114
1118
        rtp->pt = decoded.rtp_pt & 0x7f;
1115
1119
        assert(decoded.sn <= 0xffff);
1116
 
        rtp->sn = htons((uint16_t) decoded.sn);
1117
 
        rtp->timestamp = htonl(decoded.ts);
 
1120
        rtp->sn = rohc_hton16((uint16_t) decoded.sn);
 
1121
        rtp->timestamp = rohc_hton32(decoded.ts);
1118
1122
        rtp->ssrc = decoded.rtp_ssrc;
1119
1123
 
1120
1124
        return sizeof(struct udphdr) + sizeof(struct rtphdr);