diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-06-15 00:09:39 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-06-15 00:14:21 +0200 |
commit | 15f8941108c5372862035ce8e3cbfd2a6cefb241 (patch) | |
tree | 921dc52f4b22ae8f66f251000ecf495154f41e88 /libavformat/rtmpproto.c | |
parent | 01a14ce0424a45caa24d4a9103afe26c39a6fd35 (diff) | |
parent | d246c18ea6dca4dbdc92aec6ae4e3e038999a709 (diff) | |
download | ffmpeg-15f8941108c5372862035ce8e3cbfd2a6cefb241.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
Avoid C99 variable declarations within for statements.
rtmp: Read and handle incoming packets while writing data
doc: document THREAD_TYPE fate variable
rtpdec: Don't require frames to start with a Mode A packet
avconv: don't try to free threads that were not initialized.
Conflicts:
doc/fate.texi
ffplay.c
libavdevice/dv1394.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/rtmpproto.c')
-rw-r--r-- | libavformat/rtmpproto.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 5fcec0733e..03f959e009 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -1287,6 +1287,7 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size) int pktsize, pkttype; uint32_t ts; const uint8_t *buf_temp = buf; + uint8_t c; int ret; do { @@ -1356,6 +1357,35 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size) rt->flv_header_bytes = 0; } } while (buf_temp - buf < size); + + /* set stream into nonblocking mode */ + rt->stream->flags |= AVIO_FLAG_NONBLOCK; + + /* try to read one byte from the stream */ + ret = ffurl_read(rt->stream, &c, 1); + + /* switch the stream back into blocking mode */ + rt->stream->flags &= ~AVIO_FLAG_NONBLOCK; + + if (ret == AVERROR(EAGAIN)) { + /* no incoming data to handle */ + return size; + } else if (ret < 0) { + return ret; + } else if (ret == 1) { + RTMPPacket rpkt = { 0 }; + + if ((ret = ff_rtmp_packet_read_internal(rt->stream, &rpkt, + rt->chunk_size, + rt->prev_pkt[0], c)) <= 0) + return ret; + + if ((ret = rtmp_parse_result(s, rt, &rpkt)) < 0) + return ret; + + ff_rtmp_packet_destroy(&rpkt); + } + return size; } |