#include "libavutil/mathematics.h"
#include "avformat.h"
+#include "avio_internal.h"
struct MuxChain {
AVFormatContext *mpegts_ctx;
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) {
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;
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)