]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/rtpenc_mpegts.c
qsv: Default PicStruct to progressive
[ffmpeg] / libavformat / rtpenc_mpegts.c
index f170f97934911870086a021c79b7d0c20cf4eee8..d93a26a2098dacc81ad705428cf2656d43a24acc 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) {
@@ -69,7 +66,7 @@ static int rtp_mpegts_write_header(AVFormatContext *s)
             goto fail;
         st->time_base           = s->streams[i]->time_base;
         st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
-        avcodec_copy_context(st->codec, s->streams[i]->codec);
+        avcodec_parameters_copy(st->codecpar, s->streams[i]->codecpar);
     }
     if ((ret = avio_open_dyn_buf(&mpegts_ctx->pb)) < 0)
         goto fail;
@@ -90,22 +87,17 @@ static int rtp_mpegts_write_header(AVFormatContext *s)
     st = avformat_new_stream(rtp_ctx, NULL);
     st->time_base.num   = 1;
     st->time_base.den   = 90000;
-    st->codec->codec_id = AV_CODEC_ID_MPEG2TS;
-    chain->rtp_ctx = rtp_ctx;
+    st->codecpar->codec_id = AV_CODEC_ID_MPEG2TS;
     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)