-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFFInputStream.h
73 lines (64 loc) · 1.9 KB
/
FFInputStream.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
72
73
#pragma once
#include "base/CCRef.h"
#include "VideoCommon.h"
#include "FFInfo.h"
#include "FFFrameReceiver.h"
#include "FFCodec.h"
namespace ffmpeg
{
struct ContainerInfo;
class InputStream : public cocos2d::Ref
{
protected:
InputStream();
virtual ~InputStream();
bool init(Decoder* decoder, AVFormatContext* format, AVStream* stream);
public:
void setFrameReceiver(FrameReceiver* newReceiver);
FrameReceiver* getFrameReceiver() const { return receiver; }
void end();
bool prepare();
void onSeek();
virtual void addToContainerInfo(ContainerInfo* info) = 0;
Decoder* getDecoder() const { return decoder; }
AVStream* getStream() const { return stream; }
virtual bool decodePacket(AVPacket* pkt);
protected:
virtual bool sendPacket(AVPacket* pkt);
virtual void configureCodecContext();
static int64_t calculateBitRate(AVCodecContext* ctx);
void discoverMetaData();
virtual void clean();
AVCodecContext* codecContext = nullptr;
AVFormatContext* format = nullptr;
AVStream* stream = nullptr;
AVRational timeBaseCorrectedByTicksPerFrame;
FrameReceiver* receiver = nullptr;
Decoder* decoder = nullptr;
AVFrame* frame = nullptr;
MetaData* metaData = nullptr;
};
class VideoInputStream : public InputStream
{
virtual ~VideoInputStream();
public:
static VideoInputStream* create(
VideoDecoder* decoder, AVFormatContext* format, AVStream* stream);
bool decodePacket(AVPacket* pkt) override;
void addToContainerInfo(ContainerInfo* info) override;
protected:
void configureCodecContext() override;
void clean() override;
AVFrame* frameSW = nullptr;
};
class AudioInputStream : public InputStream
{
virtual ~AudioInputStream() = default;
public:
static AudioInputStream* create(
AudioDecoder* decoder, AVFormatContext* format, AVStream* stream);
void addToContainerInfo(ContainerInfo* info) override;
protected:
void configureCodecContext() override;
};
}