summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2012-02-16 17:31:03 +0100
committerMartin Storsjö <martin@martin.st>2012-02-16 17:45:33 +0100
commit298a587f447fbc9103f66a50b8433aab977afc9b (patch)
tree3459d7d1ead32738239ea93c9c000ab25845bcad
parentc6643fddba73560f26f90d327c84d8832222a720 (diff)
rtp: Factorize the check for distinguishing RTCP packets from RTP
The binary doesn't change after this patch. Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r--libavformat/movenchint.c2
-rw-r--r--libavformat/rtp.h2
-rw-r--r--libavformat/rtpdec.c2
-rw-r--r--libavformat/rtpproto.c2
-rw-r--r--libavformat/rtsp.c2
-rw-r--r--libavformat/rtspenc.c2
6 files changed, 7 insertions, 5 deletions
diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c
index f3eb0f20d5..579d040f64 100644
--- a/libavformat/movenchint.c
+++ b/libavformat/movenchint.c
@@ -333,7 +333,7 @@ static int write_hint_packets(AVIOContext *out, const uint8_t *data,
size -= 4;
if (packet_len > size || packet_len <= 12)
break;
- if (data[1] >= RTCP_SR && data[1] <= RTCP_APP) {
+ if (RTP_PT_IS_RTCP(data[1])) {
/* RTCP packet, just skip */
data += packet_len;
size -= packet_len;
diff --git a/libavformat/rtp.h b/libavformat/rtp.h
index e619008007..e9f87782fa 100644
--- a/libavformat/rtp.h
+++ b/libavformat/rtp.h
@@ -91,4 +91,6 @@ enum RTCPType {
RTCP_APP // 204
};
+#define RTP_PT_IS_RTCP(x) ((x) >= RTCP_SR && (x) <= RTCP_APP)
+
#endif /* AVFORMAT_RTP_H */
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 668755ba41..a8c5c3ff4c 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -695,7 +695,7 @@ static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt,
if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
return -1;
- if (buf[1] >= RTCP_SR && buf[1] <= RTCP_APP) {
+ if (RTP_PT_IS_RTCP(buf[1])) {
return rtcp_parse_packet(s, buf, len);
}
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index 03794ae1ce..c93de4af2b 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -266,7 +266,7 @@ static int rtp_write(URLContext *h, const uint8_t *buf, int size)
int ret;
URLContext *hd;
- if (buf[1] >= RTCP_SR && buf[1] <= RTCP_APP) {
+ if (RTP_PT_IS_RTCP(buf[1])) {
/* RTCP payload type */
hd = s->rtcp_hd;
} else {
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index f8611deed2..359d910076 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1927,7 +1927,7 @@ static int rtp_read_header(AVFormatContext *s)
continue;
}
- if (recvbuf[1] >= RTCP_SR && recvbuf[1] <= RTCP_APP)
+ if (RTP_PT_IS_RTCP(recvbuf[1]))
continue;
payload_type = recvbuf[1] & 0x7f;
diff --git a/libavformat/rtspenc.c b/libavformat/rtspenc.c
index 86621cf19d..6c14fe6c2b 100644
--- a/libavformat/rtspenc.c
+++ b/libavformat/rtspenc.c
@@ -159,7 +159,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st)
size -= 4;
if (packet_len > size || packet_len < 2)
break;
- if (ptr[1] >= RTCP_SR && ptr[1] <= RTCP_APP)
+ if (RTP_PT_IS_RTCP(ptr[1]))
id = rtsp_st->interleaved_max; /* RTCP */
else
id = rtsp_st->interleaved_min; /* RTP */