diff mbox series

[FFmpeg-devel,07/13] fftools/ffmpeg_mux: move Muxer and MuxStream to a new header

Message ID 20221013134904.10104-7-anton@khirnov.net
State Accepted
Commit 24098c6c8d124cd471ec0badb596e42ba6711b82
Headers show
Series [FFmpeg-devel,01/13] fftools/ffmpeg_mux: do not unref a NULL packet | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Oct. 13, 2022, 1:48 p.m. UTC
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 mbox series

Patch

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 <string.h>
 
 #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 <stdatomic.h>
+#include <stdint.h>
+
+#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 */