]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit '79331df362fb05a0d04ca9489c87e5b80077a3f4'
authorJames Almer <jamrial@gmail.com>
Wed, 4 Oct 2017 02:08:06 +0000 (23:08 -0300)
committerJames Almer <jamrial@gmail.com>
Wed, 4 Oct 2017 02:08:06 +0000 (23:08 -0300)
* commit '79331df362fb05a0d04ca9489c87e5b80077a3f4':
  rtsp: Lazily set up the pollfd array once

Merged-by: James Almer <jamrial@gmail.com>
1  2 
libavformat/rtsp.c
libavformat/rtsp.h

index 2d1df80ed0bdd9a1f22af1a24827826e10336faa,141477bbbfee428c83d4d13b0f8777dc215e79cc..375d0d9e14f20bb5039d2b66f7e28d6cb0e427ff
@@@ -1932,33 -1920,33 +1931,33 @@@ static int udp_read_packet(AVFormatCont
          p = rt->p = av_malloc_array(2 * (rt->nb_rtsp_streams + 1), sizeof(struct pollfd));
          if (!p)
              return AVERROR(ENOMEM);
-     }
  
-     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;
+         if (rt->rtsp_hd) {
+             tcp_fd = ffurl_get_file_handle(rt->rtsp_hd);
+             p[rt->max_p].fd = tcp_fd;
+             p[rt->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[rt->max_p].fd       = fds[fdsidx];
+                     p[rt->max_p++].events = POLLIN;
+                 }
 -                av_free(fds);
++                av_freep(&fds);
              }
-             av_freep(&fds);
          }
      }
  
Simple merge