From: James Almer Date: Wed, 4 Oct 2017 00:37:37 +0000 (-0300) Subject: Merge commit 'b9b82151a1aaa8bbf389853a6142c4e101d80b86' X-Git-Tag: n3.5-dev~84 X-Git-Url: http://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff_plain/7c74efeaf89111d686f928cbf1fe20d9a768d31f Merge commit 'b9b82151a1aaa8bbf389853a6142c4e101d80b86' * commit 'b9b82151a1aaa8bbf389853a6142c4e101d80b86': rtsp: Move the pollfd setup out of the for loop Merged-by: James Almer --- 7c74efeaf89111d686f928cbf1fe20d9a768d31f diff --cc libavformat/rtsp.c index 736559e,e4cbae4..7407014 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@@ -1931,6 -1920,34 +1931,34 @@@ static int udp_read_packet(AVFormatCont struct pollfd *p = rt->p; int *fds = NULL, fdsnum, fdsidx; + if (rt->rtsp_hd) { + tcp_fd = ffurl_get_file_handle(rt->rtsp_hd); + p[max_p].fd = tcp_fd; + p[max_p++].events = POLLIN; + } else { + tcp_fd = -1; + } + for (i = 0; i < rt->nb_rtsp_streams; i++) { + rtsp_st = rt->rtsp_streams[i]; + if (rtsp_st->rtp_handle) { + if (ret = ffurl_get_multi_file_handle(rtsp_st->rtp_handle, + &fds, &fdsnum)) { + av_log(s, AV_LOG_ERROR, "Unable to recover rtp ports\n"); + return ret; + } + if (fdsnum != 2) { + av_log(s, AV_LOG_ERROR, + "Number of fds %d not supported\n", fdsnum); + return AVERROR_INVALIDDATA; + } + for (fdsidx = 0; fdsidx < fdsnum; fdsidx++) { + p[max_p].fd = fds[fdsidx]; + p[max_p++].events = POLLIN; + } - av_free(fds); ++ av_freep(&fds); + } + } + for (;;) { if (ff_check_interrupt(&s->interrupt_callback)) return AVERROR_EXIT;