From patchwork Sat Feb 18 04:49:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 40436 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp344253pzk; Fri, 17 Feb 2023 20:50:36 -0800 (PST) X-Google-Smtp-Source: AK7set9NtZ3SyCZpkCKvjj3dc2KqmkbOh3Wmc3KWuYbQyTpu6WYj4gwKtbtimE3Gbo7tlWGDhWle X-Received: by 2002:aa7:d690:0:b0:4ad:7224:ce97 with SMTP id d16-20020aa7d690000000b004ad7224ce97mr6141186edr.21.1676695835929; Fri, 17 Feb 2023 20:50:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676695835; cv=none; d=google.com; s=arc-20160816; b=c0/esz8HErVQWFw0sVwArvK5xut0tSct7t4nxPZeUys1COPEknH+LrExpvpokDsfcs 6eLbELWjwWI5dKgFdnfrj5md2Ujkr8PuE1PBxg7hFVvl0l4+ToigedMKqW2vPef0kR3u 7oPvqIaS+8JkRV+nzI+2vOIAwT/6x9AxoKEZ6U7TAOwjYYi58OA0J8+2sd/P4cGvNxnq 49yQLX8Umq4Anf0Lft9Sy+9KNMYBj/hWkyk4s6Br5i/nPRzBIo5sYjv8JG4gid5+D/er DfFyG5yex1f/yQ89ztOw90dcZca1KplbEJjP2emmxGrOYR2hdLV+4ueWU0bVyHosR5cD XsHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=Kcmac+PPCPHK9WjUmCvMCj+IgzkX7ix2kZmJHmSY+o0=; b=iF2a4N+PMIW8QW215YZmOobe2ZFOmcAg4pgjj7gsWGEbxSP+KS9IbcnLOArXR6yqZ5 SaMLsY/bQa+DQkhImi6ezjv5THJbUgN1C70U14EvMsZ+lyHfaTxnZFyKe7VeiZ8tHyHv vBmL5YJR+L1haJkjpjQxSeHm8son4A7cB0AKD3MWWZOGnnxMtkHbEvHjIwayCFW09/f8 YC94OUXwQUulygz4T9VbV/GnUCv0oZPUyKVWKKPj0znhAE3pucEq5bHAkvWxh/TgD0md yFvMcioaT+W8rDzpL29Ht51JY7e+MNnsy6qxX7juZqpetaOA9FOfjv2i17xXO0dyJ0Bm 5qnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d17-20020aa7ce11000000b004ace3a00b69si5387976edv.331.2023.02.17.20.50.35; Fri, 17 Feb 2023 20:50:35 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B2DE268BE6E; Sat, 18 Feb 2023 06:50:30 +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 82ECC68AC05 for ; Sat, 18 Feb 2023 06:50:22 +0200 (EET) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (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 4PJbpM6J0kz9sSL for ; Sat, 18 Feb 2023 05:50:19 +0100 (CET) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 Feb 2023 10:19:45 +0530 Message-Id: <20230218044949.1179-1-ffmpeg@gyani.pro> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4PJbpM6J0kz9sSL Subject: [FFmpeg-devel] [PATCH v4 1/5] avformat: add av_program_add_stream_index2() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: ULns17B80V+4 av_program_add_stream_index() added in 526efa10534 may fail to carry out its purpose but the lack of a return value stops callers from catching any error. Fixed in new function. --- As suggested by Andreas in https://ffmpeg.org/pipermail/ffmpeg-devel/2023-February/306645.html doc/APIchanges | 3 +++ libavformat/avformat.c | 21 +++++++++++++++------ libavformat/avformat.h | 13 +++++++++++++ libavformat/version.h | 2 +- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 29161e30bf..889f9925b1 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2023-02-xx - xxxxxxxxxx - lavf 60.3.100 - avformat.h + Add av_program_add_stream_index2(). + 2023-02-16 - xxxxxxxxxx - lavf 60.2.100 - avformat.h Deprecate AVFormatContext io_close callback. The superior io_close2 callback should be used instead. diff --git a/libavformat/avformat.c b/libavformat/avformat.c index 708d90b38c..0f203e4f86 100644 --- a/libavformat/avformat.c +++ b/libavformat/avformat.c @@ -333,14 +333,14 @@ AVProgram *av_new_program(AVFormatContext *ac, int id) return program; } -void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned idx) +int av_program_add_stream_index2(AVFormatContext *ac, int progid, unsigned idx) { AVProgram *program = NULL; void *tmp; if (idx >= ac->nb_streams) { - av_log(ac, AV_LOG_ERROR, "stream index %d is not valid\n", idx); - return; + av_log(ac, AV_LOG_ERROR, "stream index %d is greater than stream count %d\n", idx, ac->nb_streams); + return AVERROR(EINVAL); } for (unsigned i = 0; i < ac->nb_programs; i++) { @@ -349,15 +349,24 @@ void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned idx) program = ac->programs[i]; for (unsigned j = 0; j < program->nb_stream_indexes; j++) if (program->stream_index[j] == idx) - return; + return 0; tmp = av_realloc_array(program->stream_index, program->nb_stream_indexes+1, sizeof(unsigned int)); if (!tmp) - return; + return AVERROR(ENOMEM); program->stream_index = tmp; program->stream_index[program->nb_stream_indexes++] = idx; - return; + return 0; } + + av_log(ac, AV_LOG_ERROR, "No program with id %d found\n", progid); + return AVERROR(EINVAL); +} + +void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned idx) +{ + av_program_add_stream_index2(ac, progid, idx); + return; } AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 1916aa2dc5..33ab0bc8ba 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2046,6 +2046,19 @@ AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx); +/** + * Add the supplied index of a stream to the AVProgram with matching id. + * + * @param ac the format context which contains the target AVProgram + * @param progid the ID of the AVProgram whose stream index is to be updated + * @param idx the index of the stream to be added + * + * @return >=0 upon successful addition or if index was already present, + * AVERROR if no matching program is found or stream index is invalid or + * the stream index array reallocation failed. + */ +int av_program_add_stream_index2(AVFormatContext *ac, int progid, unsigned int idx); + /** * Find the "best" stream in the file. * The best stream is determined according to various heuristics as the most diff --git a/libavformat/version.h b/libavformat/version.h index 904e7f06aa..7ff1483912 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,7 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 2 +#define LIBAVFORMAT_VERSION_MINOR 3 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ From patchwork Sat Feb 18 04:49:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 40437 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp344317pzk; Fri, 17 Feb 2023 20:50:46 -0800 (PST) X-Google-Smtp-Source: AK7set9GqmMTodo/VEqaLCK36R0HVbSrRX7PL8d/ruKP5c/7CVxCC2GM4rCVI2g1nnfTrrcZWxa9 X-Received: by 2002:a17:906:769a:b0:8b1:319c:c29e with SMTP id o26-20020a170906769a00b008b1319cc29emr2046590ejm.74.1676695846155; Fri, 17 Feb 2023 20:50:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676695846; cv=none; d=google.com; s=arc-20160816; b=fsPW+nh5MXnC3OpX9XGVsHkmTUWDW2Tx19JBluBkG2S+gisw1JeKWj9PwUQ24n6Ek+ qF8AU0nLF0IYHXbaSdyqWZ66sAXwsWUId4R3jbQh6WR6oRdAXrYNGrK8H0Met1T9chIQ YcLAxbCssDtBwtNxwhrTclhrEyuVNaTPjw1qc8sZlfkBQaarHVJgOJDH/hu23RPUVkaL aqDnaJNf5ce9Me+FKQpRxxQH9vGmLkCIKXXnVaKpe9RxdDI8m/Fw6D51sX9QbZfbV19R YWm+/AFMkN6WITQ5QeLswO/frLOFYtCcteerPgGCfRjU8OuQaWLtD/esmdwbRkKcJO9H iiIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=nIcYIEIP1dXYzBcB8qaxajuY0ordCVDulyjac9pzQn8=; b=C1Rs+m0vgHrKWMsw23fgVFJkUE1K/o+3Ti9Xg9hLDIebmSkOEvwT20GENgp5S0FmSN WCnR9F8dFltMjcweIuJiWyPc4M3k4zSr1tRA+Ba4IOsggLIAm/Mgz6y2eTw28hixe+zw 9uFSHNlCXJbC37RV/vJv8zHBCkHfVHPxw0o+iRGjOmO1ybdnpb2nR64nmmP9yGHtU2ur WcQD7dK5DUrDby7jxhnDCc2M7CzT5WYgfqGS0WrEox17uo6QZOR9eI/BHITefJsOYH7U O6Fa22fASM5tXFVPjzZsRlqu53I8qOv8EoDy57//LqBb72U8j+gZmnnqUqKFrT52pb19 r1mA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e18-20020a50fb92000000b004acd2b308e0si7088281edq.404.2023.02.17.20.50.45; Fri, 17 Feb 2023 20:50:46 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C153468BE77; Sat, 18 Feb 2023 06:50:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2A87168AC05 for ; Sat, 18 Feb 2023 06:50:24 +0200 (EET) Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (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-103.mailbox.org (Postfix) with ESMTPS id 4PJbpP4bJ8z9sS3 for ; Sat, 18 Feb 2023 05:50:21 +0100 (CET) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 Feb 2023 10:19:46 +0530 Message-Id: <20230218044949.1179-2-ffmpeg@gyani.pro> In-Reply-To: <20230218044949.1179-1-ffmpeg@gyani.pro> References: <20230218044949.1179-1-ffmpeg@gyani.pro> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 2/5] avformat: add av_program_copy() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: gL2e+a9OlnTz Helper to transfer programs from one muxing context to another. --- doc/APIchanges | 3 ++ libavformat/avformat.c | 66 ++++++++++++++++++++++++++++++++++++++++++ libavformat/avformat.h | 22 ++++++++++++++ libavformat/version.h | 3 +- 4 files changed, 93 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 889f9925b1..2588c17560 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2023-02-xx - xxxxxxxxxx - lavf 60.4.100 - avformat.h + Add av_program_copy() + 2023-02-xx - xxxxxxxxxx - lavf 60.3.100 - avformat.h Add av_program_add_stream_index2(). diff --git a/libavformat/avformat.c b/libavformat/avformat.c index 0f203e4f86..64741b6f4a 100644 --- a/libavformat/avformat.c +++ b/libavformat/avformat.c @@ -369,6 +369,72 @@ void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned idx) return; } +int av_program_copy(AVFormatContext *dst, const AVFormatContext *src, int progid, int overwrite) +{ + const AVProgram *src_prog = NULL; + AVProgram *dst_prog = NULL; + int ret, idx = -1; + + for (unsigned i = 0; i < src->nb_programs; i++) + if (src->programs[i]->id == progid) + src_prog = src->programs[i]; + + if (!src_prog) { + av_log(dst, AV_LOG_ERROR, "source program not found: id=0x%04x\n", progid); + return AVERROR(EINVAL); + } + + for (unsigned i = 0; i < dst->nb_programs; i++) { + if (dst->programs[i]->id == progid) + idx = i; + } + + if (idx >= 0 && !overwrite) { + av_log(dst, AV_LOG_WARNING, "target muxer already has program with id=0x%04x; not overwriting\n", progid); + return 0; + } + + av_log(dst, AV_LOG_TRACE, "%s program: id=0x%04x\n", idx >= 0 ? "overwriting" : "copying", progid); + + if (idx >= 0) { + dst_prog = dst->programs[idx]; + av_dict_free(&dst_prog->metadata); + av_freep(&dst_prog->stream_index); + dst_prog->nb_stream_indexes = 0; + } else { + dst_prog = av_mallocz(sizeof(*dst_prog)); + if (!dst_prog) + return AVERROR(ENOMEM); + ret = av_dynarray_add_nofree(&dst->programs, &dst->nb_programs, dst_prog); + if (ret < 0) { + av_free(dst_prog); + return ret; + } + } + + /* public fields */ + dst_prog->id = src_prog->id; + dst_prog->flags = src_prog->flags; + dst_prog->discard = src_prog->discard; + dst_prog->program_num = src_prog->program_num; + dst_prog->pmt_pid = src_prog->pmt_pid; + dst_prog->pcr_pid = src_prog->pcr_pid; + dst_prog->pmt_version = src_prog->pmt_version; + + for (unsigned i = 0; i < dst->nb_streams; i++) { + for (unsigned j = 0; j < src_prog->nb_stream_indexes; j++) + if (dst->streams[i]->id == src->streams[src_prog->stream_index[j]]->id) { + if (ret = av_program_add_stream_index2(dst, dst_prog->id, i) < 0) + return ret; + } + } + + if (ret = av_dict_copy(&dst_prog->metadata, src_prog->metadata, 0) < 0) + return ret; + + return 0; +} + AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s) { for (unsigned i = 0; i < ic->nb_programs; i++) { diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 33ab0bc8ba..46b4d177c3 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1886,6 +1886,28 @@ uint8_t *av_stream_get_side_data(const AVStream *stream, AVProgram *av_new_program(AVFormatContext *s, int id); +/** + * Copy an AVProgram from one AVFormatContext to another. + * + * Streams in the destination context whose IDs match the IDs of the streams in the + * source AVProgram index are added to the stream index of the copied AVProgram. + * + * If a new program has to be added, the function expects and requires any existing buffer + * holding the array of pointers to AVPrograms in the destination context to have its size + * be a power-of-two value. This should be the case if all earlier programs were created + * using av_new_program or this function. + * + * @param dst pointer to the target muxer context + * @param src pointer to the source muxer context + * @param progid ID of the program to be copied + * @param overwrite whether to overwrite if target muxer already + * contains a program with the same ID + * + * @return >= 0 in case of success, a negative AVERROR code in case of + * failure + */ +int av_program_copy(AVFormatContext *dst, const AVFormatContext *src, int progid, int overwrite); + /** * @} */ diff --git a/libavformat/version.h b/libavformat/version.h index 7ff1483912..62fa908659 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,8 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 3 +#define LIBAVFORMAT_VERSION_MINOR 4 + #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ From patchwork Sat Feb 18 04:49:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 40438 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp344387pzk; Fri, 17 Feb 2023 20:50:54 -0800 (PST) X-Google-Smtp-Source: AK7set/s2iLqMZfWcgSokTW7pGd9IXgkKvATBGv9xDkFC/Pqn5DiVxwYBDzJRKD9Y/o2qvgEgQIt X-Received: by 2002:a17:906:40c9:b0:8b1:75a0:57fa with SMTP id a9-20020a17090640c900b008b175a057famr6863997ejk.43.1676695854683; Fri, 17 Feb 2023 20:50:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676695854; cv=none; d=google.com; s=arc-20160816; b=ec/C0chI3TT3KssC2gWOk+PpQBdogObUaQzrZAPzLD7lYLUu486CR9VXMSuVrmrnqy +8S9MX6C/L9ffpSSkykpQaijficPd1Cb5tVu9aZ75/75Fei371PV7JRYoJFytp0gc+0t aO3Yki/Ewzc0miFSxJ0mqqvK/Y5JvLSlhOvN0EOLSF5ODd3y6QV+Ege5rSCDcTkHbU8X vAsrXxKKOr8dqj/A4uisTVmfrYRIHxXN+HyccyqPxqvIbTOa4VBAOBXQ/XCGOMmG62sz mVd1cOboDJvJ0Xmo7EAY/Tk7SkxxGBJqcrKFdsmoLvE7/kA5urpi2W9MJecw9CODEBdt ELvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=F5cIwuFt9gG89wU9HoJ8xp2LdQCLOgiNkTezv/QexfQ=; b=PqMEqQ32btbQ8DsBU9ZnLmTsmJMA/9U9j4DdhZfbTRQnFJSdEWlhSYJaytfvcR2n4D zxjB9BDQr1NPeHyOpT9P2UCtIlkpFnqJSyoe8y2jkwvAcia+YJ/Mb8mISKmEwaGl1otz zZamkyqmAF/TKZ6m8i7Bs2ycfXixA9nUxlIL0vCwF4fi7DRcVm6t5KH41DJEBTaufIKi QpkcKEaMY/BfFQ1TahOy1p4oYDyYXSTxtGXcWm8wFwrPIoP8gwOY6E/p+Vg/dgy6W3To Ybe8OCKa35bEoUTebe8CsIzQ45mJuT7g6dYI7lFuSgakl5hGUaZuMSSOaKKl4mowwiHf WfkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f4-20020a1709063f4400b008b1730d0139si6401150ejj.321.2023.02.17.20.50.54; Fri, 17 Feb 2023 20:50:54 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C6BDF68BE72; Sat, 18 Feb 2023 06:50:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ABA3968BE6B for ; Sat, 18 Feb 2023 06:50:25 +0200 (EET) Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (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-102.mailbox.org (Postfix) with ESMTPS id 4PJbpR1fQkz9sR1 for ; Sat, 18 Feb 2023 05:50:23 +0100 (CET) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 Feb 2023 10:19:47 +0530 Message-Id: <20230218044949.1179-3-ffmpeg@gyani.pro> In-Reply-To: <20230218044949.1179-1-ffmpeg@gyani.pro> References: <20230218044949.1179-1-ffmpeg@gyani.pro> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 3/5] avformat/hls: relay programs to child muxers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: sVfGQMI9a2g5 --- libavformat/hlsenc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index e1f96feda3..74db447085 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -911,6 +911,14 @@ FF_ENABLE_DEPRECATION_WARNINGS st->id = vs->streams[i]->id; } + for (i = 0; i < s->nb_programs; i++) { + ret = av_program_copy(oc, (const AVFormatContext *)s, s->programs[i]->id, 0); + if (ret < 0) { + av_log(s, AV_LOG_ERROR, "unable to transfer program %d to child muxer\n", s->programs[i]->id); + return ret; + } + } + vs->start_pos = 0; vs->new_start = 1; From patchwork Sat Feb 18 04:49:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 40439 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp344443pzk; Fri, 17 Feb 2023 20:51:03 -0800 (PST) X-Google-Smtp-Source: AK7set8XSBdmbmkWOT3NIv5OtZWcLAdsRBobtNw9TAfB1IdABA6XKhfSt0Ak4YXHcHQ6BRc039qK X-Received: by 2002:a17:906:1b12:b0:86a:316:d107 with SMTP id o18-20020a1709061b1200b0086a0316d107mr1095079ejg.72.1676695863003; Fri, 17 Feb 2023 20:51:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676695862; cv=none; d=google.com; s=arc-20160816; b=c925XlIJge429QR26nGCr8fOuHChvOpfyn1AJByiltFeASagnXoRwZf94i/uzIs6lt Zn1HKL/Phrpz/ot1MbV4uboq0om81FtHGEU/S/KmRf11q8bZyyGEs1F30rz53z9TZdVp 9kaUUQPJVleWXrqKkml6lt17ExQ89ZzAaGLq8qXV0RMBIcFJzry1/FOJHJgQT+ezUJ1F sO5kmXcK6SnImD5eMbrTT/s2+4nBlUAmdsEJhnmgKkYFPNYp6+mJOplO1lbtr2WiIndQ G+gcFeu24IPP1S3D/lBJVsMYs9HQdQLjm0d+WbjaTqHbrrdJBebQ5TC7fy2N9X7fp80f m9cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=YXQSRoa2gQaBe9Z0Z/2rNsK2yOCJq1ElCVLHO8sQgQs=; b=KgIbPN+69QSnV9twABVu02p+j+ourTQdj7y272fmlHdAZVZ2QV7ilVmBwhWDf3d9FL ZvKJPVzms2FuUOBVKY+xN7KRJ5zYKCbKHYJfssdz04rvv4DbylV6Gk4DRtvGZ/ij/li7 7DfdxedWpLFJoLvtDNR2wgKd4uWLBtLqJIl5oGM5hGLyHWDdtNRhXDiE5LBhyhKoNsjh WjO7domgJ2bnsNtrWiiwMi1lglbs0L4kLJubqukW0rw0+/VOVW7g3YrFY0Ds5NrdFShF HdvFiUKsJDktMxXLaRtVL2ZCgU8dOwBMsR7DAbppjtrBPJpr2xpoh2/PgspZzHpsKUK9 QQ+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fx14-20020a1709069e8e00b008af3df2c2c8si6746991ejc.214.2023.02.17.20.51.02; Fri, 17 Feb 2023 20:51:02 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 17F0B68BE7C; Sat, 18 Feb 2023 06:50:34 +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 F3B0268AC05 for ; Sat, 18 Feb 2023 06:50:26 +0200 (EET) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (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 4PJbpS3l17z9sV3 for ; Sat, 18 Feb 2023 05:50:24 +0100 (CET) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 Feb 2023 10:19:48 +0530 Message-Id: <20230218044949.1179-4-ffmpeg@gyani.pro> In-Reply-To: <20230218044949.1179-1-ffmpeg@gyani.pro> References: <20230218044949.1179-1-ffmpeg@gyani.pro> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4PJbpS3l17z9sV3 Subject: [FFmpeg-devel] [PATCH v4 4/5] avformat/segment: relay programs to child muxers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: 72FUpBse7zEZ --- libavformat/segment.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavformat/segment.c b/libavformat/segment.c index 2a82f39f31..d7f3fb5deb 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -186,6 +186,14 @@ FF_ENABLE_DEPRECATION_WARNINGS } } + for (i = 0; i < s->nb_programs; i++) { + ret = av_program_copy(oc, (const AVFormatContext *)s, s->programs[i]->id, 0); + if (ret < 0) { + av_log(s, AV_LOG_ERROR, "unable to transfer program %d to child muxer\n", s->programs[i]->id); + return ret; + } + } + return 0; } From patchwork Sat Feb 18 04:49:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 40440 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp344512pzk; Fri, 17 Feb 2023 20:51:12 -0800 (PST) X-Google-Smtp-Source: AK7set8yfm9J9zBHG3Z8G/2db02wOarAXRIW0UtxZsoUgxdo2D1YvYdKMpyzQR85YU7iGrABSBQ4 X-Received: by 2002:a17:907:808:b0:8b1:4507:ef0 with SMTP id wv8-20020a170907080800b008b145070ef0mr4509612ejb.10.1676695871754; Fri, 17 Feb 2023 20:51:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676695871; cv=none; d=google.com; s=arc-20160816; b=VexZoMnShR3TKroFDq3CKPsu2KlhEneIQsoy293oeYnBr9yuFbl2+fFrCB/skyXRKk Z3mVvQ7ZMBl8Bm72i5N+8Qqw4O4Fa6dtRO/ZdO0qNynDGp6P3exeBAfPYGuPUoKsx3oR lVCeDzVxIJaVv0OesgGLTbSmsU90/VDwV98acygXSjsT/wwJNdYOScdARY+wCiDQkHEA TUlqqNaS89Qhp0fOfP6tTfRJmZl1RKnETH+so0Gh2qpxB8BnkItWiTy6kbSY+8KUa7r0 +PDsS6TdUx6IFRYKp4AOw3oq3wFFROkEXnyfiK7Rz2U+E+rs/0tpxQ9wG4itzK3V4wo2 BSbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=0BQu3vjWcC0zMKxqqgeWrOMX9jYWV7wcXxez6Acv9/M=; b=yCdrvtXD2W4grEv7I/Bf8S6es/rN6E1ZUTt2IQs1sUODFxH6V7v2kwhiweHfU27/gU p4tljUMe7dH7veSFFFQGjfoBO7EopNKO0LszETOfX1S1KqbIOGobfST0OrQ3r2ScFOOg +Ye28cbutSPyGst9/nqkar0jYeyY4c/dfKvoe0DmI/dBnLKG4PwPzIbY6pHj695LHtMs eYWpY/mhTl2r8bkzxFPvJI40XgDidye98j1dZGxmRRQ3byU58lHhNS1nKGPK37eBUrIc sPIrQcOtnkzEg1Q00AAuuxohdIVf25Y0KN9yILUDclCLbBig4G8QAN3uMxzLMoqvmzG+ aGtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 20-20020a170906021400b008c349e2ca96si9447ejd.719.2023.02.17.20.51.11; Fri, 17 Feb 2023 20:51:11 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4B31068BEBA; Sat, 18 Feb 2023 06:50:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 282D968BE82 for ; Sat, 18 Feb 2023 06:50:28 +0200 (EET) Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (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-201.mailbox.org (Postfix) with ESMTPS id 4PJbpT54xVz9sTd for ; Sat, 18 Feb 2023 05:50:25 +0100 (CET) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 Feb 2023 10:19:49 +0530 Message-Id: <20230218044949.1179-5-ffmpeg@gyani.pro> In-Reply-To: <20230218044949.1179-1-ffmpeg@gyani.pro> References: <20230218044949.1179-1-ffmpeg@gyani.pro> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 5/5] avformat/tee: relay programs to child muxers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: 4NJffRrCwoQQ --- libavformat/tee.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavformat/tee.c b/libavformat/tee.c index cb555f52fd..e81f9ba706 100644 --- a/libavformat/tee.c +++ b/libavformat/tee.c @@ -295,6 +295,14 @@ FF_ENABLE_DEPRECATION_WARNINGS } } + for (i = 0; i < avf->nb_programs; i++) { + ret = av_program_copy(avf2, (const AVFormatContext *)avf, avf->programs[i]->id, 0); + if (ret < 0) { + av_log(avf, AV_LOG_ERROR, "unable to transfer program %d to child muxer\n", avf->programs[i]->id); + return ret; + } + } + ret = ff_format_output_open(avf2, filename, &options); if (ret < 0) { av_log(avf, AV_LOG_ERROR, "Slave '%s': error opening: %s\n", slave,