-
Notifications
You must be signed in to change notification settings - Fork 0
/
prober.h
71 lines (55 loc) · 1.13 KB
/
prober.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
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include <string>
#include <cstdint>
#include <vector>
#include <memory>
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}
#include "packet.h"
namespace avprobe
{
struct ReadResult
{
int status {-1};
Packet *packet {nullptr};
};
class InputStream
{
public:
InputStream(const AVStream *stream, AVCodecContext *codecCtx, AVCodecParserContext *parserCtx);
~InputStream();
const AVStream *getAVStream() const
{
return mStream;
}
AVCodecContext *getAVCodecContext()
{
return mCodecCtx;
}
public:
AVCodecParserContext *mParserCxt {nullptr};
private:
const AVStream *mStream {nullptr};
AVCodecContext *mCodecCtx {nullptr};
};
class Prober
{
public:
Prober();
~Prober();
void setLogLevel(int);
bool open(const char *path);
ReadResult readNextPacket();
int decode(AVPacket &packet);
int parse(AVPacket &packet);
private:
bool openCodecs();
std::string mUrl;
AVFormatContext *mFormatCtx{nullptr};
std::vector<std::shared_ptr<InputStream>> mStreams;
int mLogLevel {AV_LOG_ERROR};
};
}