Originally committed as revision 22548 to svn://svn.ffmpeg.org/ffmpeg/trunk
Martin Storsjö authored on 2010/03/16 01:36:20... | ... |
@@ -72,20 +72,30 @@ static int rtsp_write_packet(AVFormatContext *s, AVPacket *pkt) |
72 | 72 |
struct timeval tv; |
73 | 73 |
AVFormatContext *rtpctx; |
74 | 74 |
AVPacket local_pkt; |
75 |
+ int ret; |
|
75 | 76 |
|
76 |
- FD_ZERO(&rfds); |
|
77 | 77 |
tcp_fd = url_get_file_handle(rt->rtsp_hd); |
78 |
- FD_SET(tcp_fd, &rfds); |
|
79 | 78 |
|
79 |
+ while (1) { |
|
80 |
+ FD_ZERO(&rfds); |
|
81 |
+ FD_SET(tcp_fd, &rfds); |
|
80 | 82 |
tv.tv_sec = 0; |
81 | 83 |
tv.tv_usec = 0; |
82 | 84 |
n = select(tcp_fd + 1, &rfds, NULL, NULL, &tv); |
83 |
- if (n > 0) { |
|
85 |
+ if (n <= 0) |
|
86 |
+ break; |
|
84 | 87 |
if (FD_ISSET(tcp_fd, &rfds)) { |
85 | 88 |
RTSPMessageHeader reply; |
86 | 89 |
|
87 |
- if (ff_rtsp_read_reply(s, &reply, NULL, 0) < 0) |
|
90 |
+ /* Don't let ff_rtsp_read_reply handle interleaved packets, |
|
91 |
+ * since it would block and wait for an RTSP reply on the socket |
|
92 |
+ * (which may not be coming any time soon) if it handles |
|
93 |
+ * interleaved packets internally. */ |
|
94 |
+ ret = ff_rtsp_read_reply(s, &reply, NULL, 1); |
|
95 |
+ if (ret < 0) |
|
88 | 96 |
return AVERROR(EPIPE); |
97 |
+ if (ret == 1) |
|
98 |
+ ff_rtsp_skip_packet(s); |
|
89 | 99 |
/* XXX: parse message */ |
90 | 100 |
if (rt->state != RTSP_STATE_STREAMING) |
91 | 101 |
return AVERROR(EPIPE); |