2022-10-13 12:50:19 +02:00
|
|
|
/*
|
|
|
|
* 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 {
|
2022-10-13 13:14:34 +02:00
|
|
|
OutputStream ost;
|
|
|
|
|
2022-10-13 12:50:19 +02:00
|
|
|
/* the packets are buffered here until the muxer is ready to be initialized */
|
|
|
|
AVFifo *muxing_queue;
|
|
|
|
|
2022-10-14 11:34:26 +02:00
|
|
|
AVBSFContext *bsf_ctx;
|
|
|
|
|
2022-10-25 22:37:13 +02:00
|
|
|
int64_t max_frames;
|
|
|
|
|
2022-10-13 12:50:19 +02:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
2022-10-14 11:34:26 +02:00
|
|
|
int max_muxing_queue_size;
|
|
|
|
|
|
|
|
/* Threshold after which max_muxing_queue_size will be in effect */
|
|
|
|
size_t muxing_queue_data_threshold;
|
|
|
|
|
2022-10-13 12:50:19 +02:00
|
|
|
/* 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;
|
|
|
|
|
2022-10-13 13:14:34 +02:00
|
|
|
typedef struct Muxer {
|
|
|
|
OutputFile of;
|
|
|
|
|
2022-10-13 12:50:19 +02:00
|
|
|
AVFormatContext *fc;
|
|
|
|
|
|
|
|
pthread_t thread;
|
|
|
|
ThreadQueue *tq;
|
|
|
|
|
|
|
|
AVDictionary *opts;
|
|
|
|
|
|
|
|
int thread_queue_size;
|
|
|
|
|
|
|
|
/* filesize limit expressed in bytes */
|
|
|
|
int64_t limit_filesize;
|
|
|
|
atomic_int_least64_t last_filesize;
|
|
|
|
int header_written;
|
|
|
|
|
2022-10-13 15:29:29 +02:00
|
|
|
SyncQueue *sq_mux;
|
2022-10-13 12:50:19 +02:00
|
|
|
AVPacket *sq_pkt;
|
2022-10-13 13:14:34 +02:00
|
|
|
} Muxer;
|
2022-10-13 12:50:19 +02:00
|
|
|
|
2022-10-13 15:24:33 +02:00
|
|
|
/* whether we want to print an SDP, set in of_open() */
|
|
|
|
extern int want_sdp;
|
|
|
|
|
|
|
|
int mux_check_init(Muxer *mux);
|
|
|
|
|
2022-10-25 22:37:13 +02:00
|
|
|
static MuxStream *ms_from_ost(OutputStream *ost)
|
|
|
|
{
|
|
|
|
return (MuxStream*)ost;
|
|
|
|
}
|
|
|
|
|
2022-10-13 12:50:19 +02:00
|
|
|
#endif /* FFTOOLS_FFMPEG_MUX_H */
|