From patchwork Thu Oct 13 13:48:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38723 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp349233pzb; Thu, 13 Oct 2022 06:50:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4mdAHhwPuPwwejHnZUVXc5Xz5RI7PA+rlZjf23fbe8n6E2gs2Uyz/jxGPtkZf44YXx75Lz X-Received: by 2002:a17:907:75f1:b0:78a:f935:647d with SMTP id jz17-20020a17090775f100b0078af935647dmr25801007ejc.587.1665669032503; Thu, 13 Oct 2022 06:50:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665669032; cv=none; d=google.com; s=arc-20160816; b=NrFi1MJSOlEA3BRe+lG7eYtOdLjlrUKP5gKAQzM15r3+p5FHwsL97ow/dc1MqT8M54 DKOza5traMqvvAi+OcspRkpM7vM9YpEDLn7lkMwsiSrmWBFV9lphlwlmbzkCvN7MmRb1 6OrhOTh18wV2wkwMbqZX7EV+SUV8MjW8Ugru6Ly5kagOF+I/Ebs3xev8DXym1q12+kh7 awiAbBJgWzS/Wt1nbczI3IdtCLDgha89EuE22mjY43n+ScWI1AinChf8P1sJz+Vivsj2 IXQpQAieGgAm4IIPDy2Rf6Iib/etMlmuPUgTFPkNERT12QLmsIrK8uEvYD77XRy+Qasp DX9g== 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=oTpLd9EcB3wLqyoVfuJ0ASmvVeg57K2BRZMDNQy0t54=; b=KyuawvBCc/Qr6V5RvSPxZQ5tXqOhGpKpYNKF/82CVLGg1raMxDCGoYQfgEdSTxqeqh wsPpHup4ULs45n5tnUdqFltDbmmXs+KFi+Tj16Odk7JgXa6XYJRzSL+OZoq3F8AqdgOi 9GjopZL9Oywro3guCLjG2sd9wrlUZ8pa4kFtwFE6TlFHu/J5ooGbNlzYz1KW1vj9yt0C XnEuI0AoizvdghJ8Pomd92CdZJJBnYvH8sbkKdrlqzvJ46qUHTMSudZ0JHarTqwTVAp0 gA1EQnX1xCwhoxSjCZcLUqRvHmiNKKJ9TVUvBwGK43efW1BVoyZ5c7HXyPH38bGWQhTC XNlg== 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 hc18-20020a170907169200b0078de57da349si7288957ejc.463.2022.10.13.06.50.32; Thu, 13 Oct 2022 06:50:32 -0700 (PDT) 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 0995268BD85; Thu, 13 Oct 2022 16:49:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7754068BD5F for ; Thu, 13 Oct 2022 16:49:19 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 210D1240591 for ; Thu, 13 Oct 2022 15:49:16 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id OibgCzmM9NWy for ; Thu, 13 Oct 2022 15:49:15 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 5877A2405F9 for ; Thu, 13 Oct 2022 15:49:13 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 20C013A1767 for ; Thu, 13 Oct 2022 15:49:08 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Oct 2022 15:48:58 +0200 Message-Id: <20221013134904.10104-7-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221013134904.10104-1-anton@khirnov.net> References: <20221013134904.10104-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/13] fftools/ffmpeg_mux: move Muxer and MuxStream to a new header 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: 76e7k+TIV9Tq This will allow ffmpeg_mux_init.c to see work with these structs. --- fftools/ffmpeg_mux.c | 36 +--------------------- fftools/ffmpeg_mux.h | 72 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 35 deletions(-) create mode 100644 fftools/ffmpeg_mux.h diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 7bc25c6175..09213472a6 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -21,6 +21,7 @@ #include #include "ffmpeg.h" +#include "ffmpeg_mux.h" #include "objpool.h" #include "sync_queue.h" #include "thread_queue.h" @@ -37,41 +38,6 @@ #include "libavformat/avformat.h" #include "libavformat/avio.h" -typedef struct MuxStream { - /* the packets are buffered here until the muxer is ready to be initialized */ - AVFifo *muxing_queue; - - /* - * The size of the AVPackets' buffers in queue. - * Updated when a packet is either pushed or pulled from the queue. - */ - size_t muxing_queue_data_size; - - /* dts of the last packet sent to the muxer, in the stream timebase - * used for making up missing dts values */ - int64_t last_mux_dts; -} MuxStream; - -struct Muxer { - AVFormatContext *fc; - - pthread_t thread; - ThreadQueue *tq; - - MuxStream *streams; - - AVDictionary *opts; - - int thread_queue_size; - - /* filesize limit expressed in bytes */ - int64_t limit_filesize; - atomic_int_least64_t last_filesize; - int header_written; - - AVPacket *sq_pkt; -}; - static int want_sdp = 1; static int64_t filesize(AVIOContext *pb) diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h new file mode 100644 index 0000000000..920e4ff7ab --- /dev/null +++ b/fftools/ffmpeg_mux.h @@ -0,0 +1,72 @@ +/* + * Muxer internal APIs - should not be included outside of ffmpeg_mux* + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef FFTOOLS_FFMPEG_MUX_H +#define FFTOOLS_FFMPEG_MUX_H + +#include +#include + +#include "thread_queue.h" + +#include "libavformat/avformat.h" + +#include "libavcodec/packet.h" + +#include "libavutil/dict.h" +#include "libavutil/fifo.h" +#include "libavutil/thread.h" + +typedef struct MuxStream { + /* the packets are buffered here until the muxer is ready to be initialized */ + AVFifo *muxing_queue; + + /* + * The size of the AVPackets' buffers in queue. + * Updated when a packet is either pushed or pulled from the queue. + */ + size_t muxing_queue_data_size; + + /* dts of the last packet sent to the muxer, in the stream timebase + * used for making up missing dts values */ + int64_t last_mux_dts; +} MuxStream; + +struct Muxer { + AVFormatContext *fc; + + pthread_t thread; + ThreadQueue *tq; + + MuxStream *streams; + + AVDictionary *opts; + + int thread_queue_size; + + /* filesize limit expressed in bytes */ + int64_t limit_filesize; + atomic_int_least64_t last_filesize; + int header_written; + + AVPacket *sq_pkt; +}; + +#endif /* FFTOOLS_FFMPEG_MUX_H */