Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
* Muxer internal APIs - should not be included outside of ffmpeg_mux* |
3 |
|
|
* |
4 |
|
|
* This file is part of FFmpeg. |
5 |
|
|
* |
6 |
|
|
* FFmpeg is free software; you can redistribute it and/or |
7 |
|
|
* modify it under the terms of the GNU Lesser General Public |
8 |
|
|
* License as published by the Free Software Foundation; either |
9 |
|
|
* version 2.1 of the License, or (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* FFmpeg is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
|
|
* Lesser General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU Lesser General Public |
17 |
|
|
* License along with FFmpeg; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#ifndef FFTOOLS_FFMPEG_MUX_H |
22 |
|
|
#define FFTOOLS_FFMPEG_MUX_H |
23 |
|
|
|
24 |
|
|
#include <stdatomic.h> |
25 |
|
|
#include <stdint.h> |
26 |
|
|
|
27 |
|
|
#include "thread_queue.h" |
28 |
|
|
|
29 |
|
|
#include "libavformat/avformat.h" |
30 |
|
|
|
31 |
|
|
#include "libavcodec/packet.h" |
32 |
|
|
|
33 |
|
|
#include "libavutil/dict.h" |
34 |
|
|
#include "libavutil/fifo.h" |
35 |
|
|
#include "libavutil/thread.h" |
36 |
|
|
|
37 |
|
|
typedef struct MuxStream { |
38 |
|
|
OutputStream ost; |
39 |
|
|
|
40 |
|
|
// name used for logging |
41 |
|
|
char log_name[32]; |
42 |
|
|
|
43 |
|
|
/* the packets are buffered here until the muxer is ready to be initialized */ |
44 |
|
|
AVFifo *muxing_queue; |
45 |
|
|
|
46 |
|
|
AVBSFContext *bsf_ctx; |
47 |
|
|
|
48 |
|
|
EncStats stats; |
49 |
|
|
|
50 |
|
|
int64_t max_frames; |
51 |
|
|
|
52 |
|
|
/* |
53 |
|
|
* The size of the AVPackets' buffers in queue. |
54 |
|
|
* Updated when a packet is either pushed or pulled from the queue. |
55 |
|
|
*/ |
56 |
|
|
size_t muxing_queue_data_size; |
57 |
|
|
|
58 |
|
|
int max_muxing_queue_size; |
59 |
|
|
|
60 |
|
|
/* Threshold after which max_muxing_queue_size will be in effect */ |
61 |
|
|
size_t muxing_queue_data_threshold; |
62 |
|
|
|
63 |
|
|
/* dts of the last packet sent to the muxer, in the stream timebase |
64 |
|
|
* used for making up missing dts values */ |
65 |
|
|
int64_t last_mux_dts; |
66 |
|
|
} MuxStream; |
67 |
|
|
|
68 |
|
|
typedef struct Muxer { |
69 |
|
|
OutputFile of; |
70 |
|
|
|
71 |
|
|
// name used for logging |
72 |
|
|
char log_name[32]; |
73 |
|
|
|
74 |
|
|
AVFormatContext *fc; |
75 |
|
|
|
76 |
|
|
pthread_t thread; |
77 |
|
|
ThreadQueue *tq; |
78 |
|
|
|
79 |
|
|
AVDictionary *opts; |
80 |
|
|
|
81 |
|
|
int thread_queue_size; |
82 |
|
|
|
83 |
|
|
/* filesize limit expressed in bytes */ |
84 |
|
|
int64_t limit_filesize; |
85 |
|
|
atomic_int_least64_t last_filesize; |
86 |
|
|
int header_written; |
87 |
|
|
|
88 |
|
|
SyncQueue *sq_mux; |
89 |
|
|
AVPacket *sq_pkt; |
90 |
|
|
} Muxer; |
91 |
|
|
|
92 |
|
|
/* whether we want to print an SDP, set in of_open() */ |
93 |
|
|
extern int want_sdp; |
94 |
|
|
|
95 |
|
|
int mux_check_init(Muxer *mux); |
96 |
|
|
|
97 |
|
1005699 |
static MuxStream *ms_from_ost(OutputStream *ost) |
98 |
|
|
{ |
99 |
|
1005699 |
return (MuxStream*)ost; |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
#endif /* FFTOOLS_FFMPEG_MUX_H */ |
103 |
|
|
|