From patchwork Tue Mar 23 05:37:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 26549 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 44ECD44A77B for ; Tue, 23 Mar 2021 07:37:59 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 14D0C68AB03; Tue, 23 Mar 2021 07:37:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CF8B568A6B5 for ; Tue, 23 Mar 2021 07:37:52 +0200 (EET) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4F4Krv6TQDzQjmX for ; Tue, 23 Mar 2021 06:37:51 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id BDmMxwIwBgSE for ; Tue, 23 Mar 2021 06:37:48 +0100 (CET) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Tue, 23 Mar 2021 11:07:32 +0530 Message-Id: <20210323053734.6741-1-ffmpeg@gyani.pro> MIME-Version: 1.0 X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 7.24 / 15.00 / 15.00 X-Rspamd-Queue-Id: D7FB217BE X-Rspamd-UID: 7fbd39 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/rtpenc_mpegts: allow options for mpeg-ts muxer X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavformat/rtpenc_mpegts.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/libavformat/rtpenc_mpegts.c b/libavformat/rtpenc_mpegts.c index 28522f8913..d501d09590 100644 --- a/libavformat/rtpenc_mpegts.c +++ b/libavformat/rtpenc_mpegts.c @@ -20,6 +20,7 @@ */ #include "libavutil/mathematics.h" +#include "libavutil/opt.h" #include "avformat.h" #include "avio_internal.h" @@ -27,6 +28,7 @@ typedef struct MuxChain { AVFormatContext *mpegts_ctx; AVFormatContext *rtp_ctx; AVPacket *pkt; + AVDictionary* mpegts_muxer_options; } MuxChain; static int rtp_mpegts_write_close(AVFormatContext *s) @@ -56,6 +58,7 @@ static int rtp_mpegts_write_header(AVFormatContext *s) ff_const59 AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL); int i, ret = AVERROR(ENOMEM); AVStream *st; + AVDictionary *mpegts_muxer_options = NULL; if (!mpegts_format || !rtp_format) return AVERROR(ENOSYS); @@ -78,7 +81,10 @@ static int rtp_mpegts_write_header(AVFormatContext *s) } if ((ret = avio_open_dyn_buf(&mpegts_ctx->pb)) < 0) goto fail; - if ((ret = avformat_write_header(mpegts_ctx, NULL)) < 0) + + av_dict_copy(&mpegts_muxer_options, chain->mpegts_muxer_options, 0); + + if ((ret = avformat_write_header(mpegts_ctx, &mpegts_muxer_options)) < 0) goto fail; for (i = 0; i < s->nb_streams; i++) s->streams[i]->time_base = mpegts_ctx->streams[i]->time_base; @@ -111,6 +117,7 @@ fail: if (mpegts_ctx) { ffio_free_dyn_buf(&mpegts_ctx->pb); av_dict_free(&mpegts_ctx->metadata); + av_dict_free(&mpegts_muxer_options); avformat_free_context(mpegts_ctx); } avformat_free_context(rtp_ctx); @@ -155,6 +162,20 @@ static int rtp_mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) return ret; } +#define OFFSET(x) offsetof(MuxChain, x) +#define E AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "mpegts_muxer_options", "set list of options for the MPEG-TS muxer", OFFSET(mpegts_muxer_options), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, E }, + { NULL }, +}; + +static const AVClass rtp_mpegts_class = { + .class_name = "rtp_mpegts muxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVOutputFormat ff_rtp_mpegts_muxer = { .name = "rtp_mpegts", .long_name = NULL_IF_CONFIG_SMALL("RTP/mpegts output format"), @@ -164,4 +185,5 @@ AVOutputFormat ff_rtp_mpegts_muxer = { .write_header = rtp_mpegts_write_header, .write_packet = rtp_mpegts_write_packet, .write_trailer = rtp_mpegts_write_close, + .priv_class = &rtp_mpegts_class, };