-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmuxer.h
58 lines (44 loc) · 1.1 KB
/
muxer.h
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
#ifndef MUXER_H
#define MUXER_H
#include <thread>
#include <atomic>
#include "util.h"
#include "properties.h"
#include "packet_queue.hpp"
#include "av_publish_time.h"
class Muxer
{
public:
Muxer();
~Muxer();
bool Init(const Properties& properties,
AVCodecContext* codec_ctx1,
AVCodecContext* codec_ctx2);
bool Run();
void Stop();
bool PushQueue(std::shared_ptr<AVPacket> pkt, MediaType media_type);
int GetVideoIndex();
int GetAudioIndex();
private:
bool Open();
bool Close();
bool AddStream(AVCodecContext* codec_ctx);
bool Send(AVPacket* pkt);
void DebugPacketStats();
void Loop();
private:
std::string url_;
std::string proto_type_;
AVCodecContext* video_codec_ctx_ = NULL;
AVCodecContext* audio_codec_ctx_ = NULL;
AVStream* video_st_ = NULL;
AVStream* audio_st_ = NULL;
int video_index_ = -1;
int audio_index_ = -1;
AVFormatContext* fmt_ctx_ = NULL;
std::thread looper_;
std::atomic<bool> exit_ = true;
int64_t pre_debug_time_ = 0;
PacketQueue pkt_queue_;
};
#endif // MUXER_H