]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/rtpenc_mpegts.c
avfilter/vf_fieldmatch: Change enums to int, which are accessed via AVOption as int
[ffmpeg] / libavformat / rtpenc_mpegts.c
index e0339bd58d272a9c7d337aa4f2442d44acd703a5..db1680e069b995a3e244fe0d632aafbd688d5c91 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "libavutil/mathematics.h"
 #include "avformat.h"
+#include "avio_internal.h"
 
 struct MuxChain {
     AVFormatContext *mpegts_ctx;
@@ -33,11 +34,7 @@ static int rtp_mpegts_write_close(AVFormatContext *s)
 
     if (chain->mpegts_ctx) {
         av_write_trailer(chain->mpegts_ctx);
-        if (chain->mpegts_ctx->pb) {
-            uint8_t *buf;
-            avio_close_dyn_buf(chain->mpegts_ctx->pb, &buf);
-            av_free(buf);
-        }
+        ffio_free_dyn_buf(&chain->mpegts_ctx->pb);
         avformat_free_context(chain->mpegts_ctx);
     }
     if (chain->rtp_ctx) {
@@ -91,21 +88,16 @@ static int rtp_mpegts_write_header(AVFormatContext *s)
     st->time_base.num   = 1;
     st->time_base.den   = 90000;
     st->codec->codec_id = AV_CODEC_ID_MPEG2TS;
-    chain->rtp_ctx = rtp_ctx;
     rtp_ctx->pb = s->pb;
     if ((ret = avformat_write_header(rtp_ctx, NULL)) < 0)
         goto fail;
-    rtp_ctx = NULL;
+    chain->rtp_ctx = rtp_ctx;
 
     return 0;
 
 fail:
     if (mpegts_ctx) {
-        if (mpegts_ctx->pb) {
-            uint8_t *buf;
-            avio_close_dyn_buf(mpegts_ctx->pb, &buf);
-            av_free(buf);
-        }
+        ffio_free_dyn_buf(&mpegts_ctx->pb);
         avformat_free_context(mpegts_ctx);
     }
     if (rtp_ctx)