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 "ffmpeg_sched.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 |
|
|
|
36 |
|
|
typedef struct MuxStream { |
37 |
|
|
OutputStream ost; |
38 |
|
|
|
39 |
|
|
/** |
40 |
|
|
* Codec parameters for packets submitted to the muxer (i.e. before |
41 |
|
|
* bitstream filtering, if any). |
42 |
|
|
*/ |
43 |
|
|
AVCodecParameters *par_in; |
44 |
|
|
|
45 |
|
|
// name used for logging |
46 |
|
|
char log_name[32]; |
47 |
|
|
|
48 |
|
|
AVBSFContext *bsf_ctx; |
49 |
|
|
AVPacket *bsf_pkt; |
50 |
|
|
|
51 |
|
|
AVPacket *pkt; |
52 |
|
|
|
53 |
|
|
EncStats stats; |
54 |
|
|
|
55 |
|
|
int sch_idx; |
56 |
|
|
int sch_idx_enc; |
57 |
|
|
int sch_idx_src; |
58 |
|
|
|
59 |
|
|
int sq_idx_mux; |
60 |
|
|
|
61 |
|
|
int64_t max_frames; |
62 |
|
|
|
63 |
|
|
// timestamp from which the streamcopied streams should start, |
64 |
|
|
// in AV_TIME_BASE_Q; |
65 |
|
|
// everything before it should be discarded |
66 |
|
|
int64_t ts_copy_start; |
67 |
|
|
|
68 |
|
|
/* dts of the last packet sent to the muxer, in the stream timebase |
69 |
|
|
* used for making up missing dts values */ |
70 |
|
|
int64_t last_mux_dts; |
71 |
|
|
|
72 |
|
|
int64_t stream_duration; |
73 |
|
|
AVRational stream_duration_tb; |
74 |
|
|
|
75 |
|
|
// state for av_rescale_delta() call for audio in write_packet() |
76 |
|
|
int64_t ts_rescale_delta_last; |
77 |
|
|
|
78 |
|
|
// combined size of all the packets sent to the muxer |
79 |
|
|
uint64_t data_size_mux; |
80 |
|
|
|
81 |
|
|
int copy_initial_nonkeyframes; |
82 |
|
|
int copy_prior_start; |
83 |
|
|
int streamcopy_started; |
84 |
|
|
#if FFMPEG_OPT_VSYNC_DROP |
85 |
|
|
int ts_drop; |
86 |
|
|
#endif |
87 |
|
|
|
88 |
|
|
AVRational frame_rate; |
89 |
|
|
AVRational max_frame_rate; |
90 |
|
|
int force_fps; |
91 |
|
|
|
92 |
|
|
const char *apad; |
93 |
|
|
} MuxStream; |
94 |
|
|
|
95 |
|
|
typedef struct Muxer { |
96 |
|
|
OutputFile of; |
97 |
|
|
|
98 |
|
|
// name used for logging |
99 |
|
|
char log_name[32]; |
100 |
|
|
|
101 |
|
|
AVFormatContext *fc; |
102 |
|
|
|
103 |
|
|
Scheduler *sch; |
104 |
|
|
unsigned sch_idx; |
105 |
|
|
|
106 |
|
|
// OutputStream indices indexed by scheduler stream indices |
107 |
|
|
int *sch_stream_idx; |
108 |
|
|
int nb_sch_stream_idx; |
109 |
|
|
|
110 |
|
|
AVDictionary *opts; |
111 |
|
|
|
112 |
|
|
// used to validate that all encoder avoptions have been actually used |
113 |
|
|
AVDictionary *enc_opts_used; |
114 |
|
|
|
115 |
|
|
/* filesize limit expressed in bytes */ |
116 |
|
|
int64_t limit_filesize; |
117 |
|
|
atomic_int_least64_t last_filesize; |
118 |
|
|
int header_written; |
119 |
|
|
|
120 |
|
|
SyncQueue *sq_mux; |
121 |
|
|
AVPacket *sq_pkt; |
122 |
|
|
} Muxer; |
123 |
|
|
|
124 |
|
|
int mux_check_init(void *arg); |
125 |
|
|
|
126 |
|
1131562 |
static MuxStream *ms_from_ost(OutputStream *ost) |
127 |
|
|
{ |
128 |
|
1131562 |
return (MuxStream*)ost; |
129 |
|
|
} |
130 |
|
|
|
131 |
|
|
#endif /* FFTOOLS_FFMPEG_MUX_H */ |
132 |
|
|
|