Commit d2c613dd authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '54e03ff6'

* commit '54e03ff6':
  rtpproto: Support nonblocking reads
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 57b8ce41 54e03ff6
...@@ -327,12 +327,13 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size) ...@@ -327,12 +327,13 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
socklen_t from_len; socklen_t from_len;
int len, n; int len, n;
struct pollfd p[2] = {{s->rtp_fd, POLLIN, 0}, {s->rtcp_fd, POLLIN, 0}}; struct pollfd p[2] = {{s->rtp_fd, POLLIN, 0}, {s->rtcp_fd, POLLIN, 0}};
int poll_delay = h->flags & AVIO_FLAG_NONBLOCK ? 0 : 100;
for(;;) { for(;;) {
if (ff_check_interrupt(&h->interrupt_callback)) if (ff_check_interrupt(&h->interrupt_callback))
return AVERROR_EXIT; return AVERROR_EXIT;
/* build fdset to listen to RTP and RTCP packets */ /* build fdset to listen to RTP and RTCP packets */
n = poll(p, 2, 100); n = poll(p, 2, poll_delay);
if (n > 0) { if (n > 0) {
/* first try RTCP */ /* first try RTCP */
if (p[1].revents & POLLIN) { if (p[1].revents & POLLIN) {
...@@ -369,6 +370,8 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size) ...@@ -369,6 +370,8 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
continue; continue;
return AVERROR(EIO); return AVERROR(EIO);
} }
if (h->flags & AVIO_FLAG_NONBLOCK)
return AVERROR(EAGAIN);
} }
return len; return len;
} }
......
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