diff options
author | Martin Storsjö <martin@martin.st> | 2013-07-26 21:24:06 +0400 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-07-31 22:12:34 +0400 |
commit | 54e03ff6af8a070f1055edd26028f3f7b2e2ca8e (patch) | |
tree | b61c6a885f1480627a5a7b041cd1cadae58df34c /libavformat/rtpproto.c | |
parent | 2e814d0329aded98c811d0502839618f08642685 (diff) |
rtpproto: Support nonblocking reads
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/rtpproto.c')
-rw-r--r-- | libavformat/rtpproto.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index b82e2f7325..024c69ba59 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -326,12 +326,13 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size) socklen_t from_len; int len, n; 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(;;) { if (ff_check_interrupt(&h->interrupt_callback)) return AVERROR_EXIT; /* build fdset to listen to RTP and RTCP packets */ - n = poll(p, 2, 100); + n = poll(p, 2, poll_delay); if (n > 0) { /* first try RTCP */ if (p[1].revents & POLLIN) { @@ -368,6 +369,8 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size) continue; return AVERROR(EIO); } + if (h->flags & AVIO_FLAG_NONBLOCK) + return AVERROR(EAGAIN); } return len; } |