aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-08-01 11:58:13 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-08-01 11:58:17 +0200
commitd6b37de4d42d7bcb1173f6e5c488a02af9470568 (patch)
tree9b1fff4984be2089902a2e76465712b15ec9f3bb
parentb39f012dee7aac577b43c51a7119955e7509a72b (diff)
parent892b0be1dfbdeaf71235fb6c593286e4f5c7e4ec (diff)
downloadffmpeg-d6b37de4d42d7bcb1173f6e5c488a02af9470568.tar.gz
Merge commit '892b0be1dfbdeaf71235fb6c593286e4f5c7e4ec'
* commit '892b0be1dfbdeaf71235fb6c593286e4f5c7e4ec': rtpproto: Simplify the rtp_read function by looping over the fds Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/rtpproto.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index 4b0b933c54..218566d299 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -325,7 +325,7 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
RTPContext *s = h->priv_data;
struct sockaddr_storage from;
socklen_t from_len;
- int len, n;
+ int len, n, i;
struct pollfd p[2] = {{s->rtp_fd, POLLIN, 0}, {s->rtcp_fd, POLLIN, 0}};
int poll_delay = h->flags & AVIO_FLAG_NONBLOCK ? 0 : 100;
@@ -334,25 +334,12 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
return AVERROR_EXIT;
n = poll(p, 2, poll_delay);
if (n > 0) {
- /* first try RTCP */
- if (p[1].revents & POLLIN) {
- from_len = sizeof(from);
- len = recvfrom (s->rtcp_fd, buf, size, 0,
- (struct sockaddr *)&from, &from_len);
- if (len < 0) {
- if (ff_neterrno() == AVERROR(EAGAIN) ||
- ff_neterrno() == AVERROR(EINTR))
- continue;
- return AVERROR(EIO);
- }
- if (rtp_check_source_lists(s, &from))
+ /* first try RTCP, then RTP */
+ for (i = 1; i >= 0; i--) {
+ if (!(p[i].revents & POLLIN))
continue;
- break;
- }
- /* then RTP */
- if (p[0].revents & POLLIN) {
from_len = sizeof(from);
- len = recvfrom (s->rtp_fd, buf, size, 0,
+ len = recvfrom(p[i].fd, buf, size, 0,
(struct sockaddr *)&from, &from_len);
if (len < 0) {
if (ff_neterrno() == AVERROR(EAGAIN) ||
@@ -362,7 +349,7 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
}
if (rtp_check_source_lists(s, &from))
continue;
- break;
+ return len;
}
} else if (n < 0) {
if (ff_neterrno() == AVERROR(EINTR))