Commit 298a587f authored by Martin Storsjö's avatar Martin Storsjö

rtp: Factorize the check for distinguishing RTCP packets from RTP

The binary doesn't change after this patch.
Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent c6643fdd
...@@ -333,7 +333,7 @@ static int write_hint_packets(AVIOContext *out, const uint8_t *data, ...@@ -333,7 +333,7 @@ static int write_hint_packets(AVIOContext *out, const uint8_t *data,
size -= 4; size -= 4;
if (packet_len > size || packet_len <= 12) if (packet_len > size || packet_len <= 12)
break; break;
if (data[1] >= RTCP_SR && data[1] <= RTCP_APP) { if (RTP_PT_IS_RTCP(data[1])) {
/* RTCP packet, just skip */ /* RTCP packet, just skip */
data += packet_len; data += packet_len;
size -= packet_len; size -= packet_len;
......
...@@ -91,4 +91,6 @@ enum RTCPType { ...@@ -91,4 +91,6 @@ enum RTCPType {
RTCP_APP // 204 RTCP_APP // 204
}; };
#define RTP_PT_IS_RTCP(x) ((x) >= RTCP_SR && (x) <= RTCP_APP)
#endif /* AVFORMAT_RTP_H */ #endif /* AVFORMAT_RTP_H */
...@@ -695,7 +695,7 @@ static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt, ...@@ -695,7 +695,7 @@ static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt,
if ((buf[0] & 0xc0) != (RTP_VERSION << 6)) if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
return -1; 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); return rtcp_parse_packet(s, buf, len);
} }
......
...@@ -266,7 +266,7 @@ static int rtp_write(URLContext *h, const uint8_t *buf, int size) ...@@ -266,7 +266,7 @@ static int rtp_write(URLContext *h, const uint8_t *buf, int size)
int ret; int ret;
URLContext *hd; URLContext *hd;
if (buf[1] >= RTCP_SR && buf[1] <= RTCP_APP) { if (RTP_PT_IS_RTCP(buf[1])) {
/* RTCP payload type */ /* RTCP payload type */
hd = s->rtcp_hd; hd = s->rtcp_hd;
} else { } else {
......
...@@ -1927,7 +1927,7 @@ static int rtp_read_header(AVFormatContext *s) ...@@ -1927,7 +1927,7 @@ static int rtp_read_header(AVFormatContext *s)
continue; continue;
} }
if (recvbuf[1] >= RTCP_SR && recvbuf[1] <= RTCP_APP) if (RTP_PT_IS_RTCP(recvbuf[1]))
continue; continue;
payload_type = recvbuf[1] & 0x7f; payload_type = recvbuf[1] & 0x7f;
......
...@@ -159,7 +159,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) ...@@ -159,7 +159,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st)
size -= 4; size -= 4;
if (packet_len > size || packet_len < 2) if (packet_len > size || packet_len < 2)
break; break;
if (ptr[1] >= RTCP_SR && ptr[1] <= RTCP_APP) if (RTP_PT_IS_RTCP(ptr[1]))
id = rtsp_st->interleaved_max; /* RTCP */ id = rtsp_st->interleaved_max; /* RTCP */
else else
id = rtsp_st->interleaved_min; /* RTP */ id = rtsp_st->interleaved_min; /* RTP */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment