-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathmuxer.h
More file actions
90 lines (71 loc) · 1.95 KB
/
Copy pathmuxer.h
File metadata and controls
90 lines (71 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef _MUXER_H
#define _MUXER_H
#include <string>
#include <mutex>
#include <memory>
#include <map>
struct AVFormatContext;
struct AVStream;
struct AVCodecContext;
struct AVCodec;
struct AVIOInterruptCB;
namespace jt
{
class Muxer;
int InterruptCallBack(void*);
std::string FFmpegErrorString(int code);
class Muxer {
public:
Muxer(const std::string &format, const std::string &output_file);
~Muxer() noexcept {
Close();
}
/*
* @param options: set context opt
*
*/
bool Open(const std::map<std::string, std::string> &options);
void Interrupt() {
io_interrupt_result_ = true;
}
bool Close();
/*
* @param options: set stream dict
*
*/
bool AddVideoStream(int width,
int height,
const uint8_t *video_headrer,
int header_size,
const std::map<std::string, std::string> &options);
bool AddAudioStream(const uint8_t *aac_header,
int header_size,
int sample_rate,
int channels,
int bitrate);
bool SetMetaData(const char *key, const char *val);
bool WriteHeader();
bool WriteH264Nalu(const uint8_t *nalu, int nalu_len, int64_t pts, int64_t dts, bool is_key);
bool WriteAAC(const uint8_t *aac, int size, int64_t pts);
private:
friend int InterruptCallBack(void*);
bool WriteVideoPacket(const uint8_t *nalu,
int nalu_len,
int64_t pts,
int64_t dts,
bool is_key);
private:
std::string output_format_;
std::string output_file_;
AVFormatContext *out_context_ = nullptr;
AVStream *video_stream_ = nullptr;
AVStream *audio_stream_ = nullptr;
std::shared_ptr<AVIOInterruptCB> interrupt_cb_;
bool is_first_video_ = false;
int64_t last_video_pkt_pts_ = 0;
bool open_ = false;
bool io_interrupt_result_ = false;
std::mutex write_mtx_;
};
}
#endif