[FFmpeg-cvslog] r24912 - in trunk/libavformat: rtp.h rtpdec.c rtpenc.c rtpproto.c rtspenc.c

mstorsjo subversion
Wed Aug 25 11:15:32 CEST 2010


Author: mstorsjo
Date: Wed Aug 25 11:15:31 2010
New Revision: 24912

Log:
rtp: Replace hardcoded RTCP packet types with defines

Patch by Josh Allmann, joshua dot allmann at gmail

Modified:
   trunk/libavformat/rtp.h
   trunk/libavformat/rtpdec.c
   trunk/libavformat/rtpenc.c
   trunk/libavformat/rtpproto.c
   trunk/libavformat/rtspenc.c

Modified: trunk/libavformat/rtp.h
==============================================================================
--- trunk/libavformat/rtp.h	Tue Aug 24 22:48:58 2010	(r24911)
+++ trunk/libavformat/rtp.h	Wed Aug 25 11:15:31 2010	(r24912)
@@ -82,4 +82,13 @@ enum CodecID ff_rtp_codec_id(const char 
  */
 #define RTP_XIPH_IDENT 0xfecdba
 
+/* RTCP packet types */
+enum RTCPType {
+    RTCP_SR     = 200,
+    RTCP_RR,   // 201
+    RTCP_SDES, // 202
+    RTCP_BYE,  // 203
+    RTCP_APP   // 204
+};
+
 #endif /* AVFORMAT_RTP_H */

Modified: trunk/libavformat/rtpdec.c
==============================================================================
--- trunk/libavformat/rtpdec.c	Tue Aug 24 22:48:58 2010	(r24911)
+++ trunk/libavformat/rtpdec.c	Wed Aug 25 11:15:31 2010	(r24912)
@@ -74,7 +74,7 @@ void av_register_rtp_dynamic_payload_han
 
 static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int len)
 {
-    if (buf[1] != 200)
+    if (buf[1] != RTCP_SR)
         return -1;
     s->last_rtcp_ntp_time = AV_RB64(buf + 8);
     if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE)
@@ -209,7 +209,7 @@ int rtp_check_and_send_back_rr(RTPDemuxC
 
     // Receiver Report
     put_byte(pb, (RTP_VERSION << 6) + 1); /* 1 report block */
-    put_byte(pb, 201);
+    put_byte(pb, RTCP_RR);
     put_be16(pb, 7); /* length in words - 1 */
     // our own SSRC: we use the server's SSRC + 1 to avoid conflicts
     put_be32(pb, s->ssrc + 1);
@@ -248,7 +248,7 @@ int rtp_check_and_send_back_rr(RTPDemuxC
 
     // CNAME
     put_byte(pb, (RTP_VERSION << 6) + 1); /* 1 report block */
-    put_byte(pb, 202);
+    put_byte(pb, RTCP_SDES);
     len = strlen(s->hostname);
     put_be16(pb, (6 + len + 3) / 4); /* length in words - 1 */
     put_be32(pb, s->ssrc);
@@ -299,7 +299,7 @@ void rtp_send_punch_packets(URLContext* 
         return;
 
     put_byte(pb, (RTP_VERSION << 6));
-    put_byte(pb, 201); /* receiver report */
+    put_byte(pb, RTCP_RR); /* receiver report */
     put_be16(pb, 1); /* length in words - 1 */
     put_be32(pb, 0); /* our own SSRC */
 
@@ -434,7 +434,7 @@ int rtp_parse_packet(RTPDemuxContext *s,
 
     if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
         return -1;
-    if (buf[1] >= 200 && buf[1] <= 204) {
+    if (buf[1] >= RTCP_SR && buf[1] <= RTCP_APP) {
         rtcp_parse_packet(s, buf, len);
         return -1;
     }

Modified: trunk/libavformat/rtpenc.c
==============================================================================
--- trunk/libavformat/rtpenc.c	Tue Aug 24 22:48:58 2010	(r24911)
+++ trunk/libavformat/rtpenc.c	Wed Aug 25 11:15:31 2010	(r24912)
@@ -191,7 +191,7 @@ static void rtcp_send_sr(AVFormatContext
     rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, (AVRational){1, 1000000},
                           s1->streams[0]->time_base) + s->base_timestamp;
     put_byte(s1->pb, (RTP_VERSION << 6));
-    put_byte(s1->pb, 200);
+    put_byte(s1->pb, RTCP_SR);
     put_be16(s1->pb, 6); /* length in words - 1 */
     put_be32(s1->pb, s->ssrc);
     put_be32(s1->pb, ntp_time / 1000000);

Modified: trunk/libavformat/rtpproto.c
==============================================================================
--- trunk/libavformat/rtpproto.c	Tue Aug 24 22:48:58 2010	(r24911)
+++ trunk/libavformat/rtpproto.c	Wed Aug 25 11:15:31 2010	(r24912)
@@ -285,7 +285,7 @@ static int rtp_write(URLContext *h, cons
     int ret;
     URLContext *hd;
 
-    if (buf[1] >= 200 && buf[1] <= 204) {
+    if (buf[1] >= RTCP_SR && buf[1] <= RTCP_APP) {
         /* RTCP payload type */
         hd = s->rtcp_hd;
     } else {

Modified: trunk/libavformat/rtspenc.c
==============================================================================
--- trunk/libavformat/rtspenc.c	Tue Aug 24 22:48:58 2010	(r24911)
+++ trunk/libavformat/rtspenc.c	Wed Aug 25 11:15:31 2010	(r24912)
@@ -85,7 +85,7 @@ static int tcp_write_packet(AVFormatCont
         size -= 4;
         if (packet_len > size || packet_len < 2)
             break;
-        if (ptr[1] >= 200 && ptr[1] <= 204)
+        if (ptr[1] >= RTCP_SR && ptr[1] <= RTCP_APP)
             id = rtsp_st->interleaved_max; /* RTCP */
         else
             id = rtsp_st->interleaved_min; /* RTP */



More information about the ffmpeg-cvslog mailing list