forked from avTranscoder/avTranscoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIReader.hpp
More file actions
88 lines (71 loc) · 2.63 KB
/
Copy pathIReader.hpp
File metadata and controls
88 lines (71 loc) · 2.63 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
#ifndef _AV_TRANSCODER_IREADER_HPP
#define _AV_TRANSCODER_IREADER_HPP
#include <AvTranscoder/common.hpp>
#include <AvTranscoder/file/InputFile.hpp>
#include <AvTranscoder/properties/StreamProperties.hpp>
#include <AvTranscoder/decoder/IDecoder.hpp>
#include <AvTranscoder/data/decoded/IFrame.hpp>
#include <AvTranscoder/transform/ITransform.hpp>
namespace avtranscoder
{
/**
* @brief Based class to read a stream.
*/
class AvExport IReader
{
public:
/**
* @brief Create a new InputFile and prepare to read the stream at the given index
* @param streamIndex by default read the first stream
* @param channelIndex by default -1 (all channels of the stream)
*/
IReader(const std::string& filename, const size_t streamIndex = 0, const int channelIndex = -1);
/**
* @brief Get the existing InputFile and prepare to read the stream at the given index
* @note This constructor can improve performances when you create several readers from one InputFile.
*/
IReader(InputFile& inputFile, const size_t streamIndex = 0, const int channelIndex = -1);
virtual ~IReader() = 0;
/**
* @return Get next frame after decoding
* @see readFrameAt
*/
IFrame* readNextFrame();
/**
* @return Get previous frame after decoding
* @see readFrameAt
*/
IFrame* readPrevFrame();
/**
* @return Get indicated frame after decoding
* @warn Returns NULL if there is no more frame to read.
* @see continueWithGenerator
*/
IFrame* readFrameAt(const size_t frame);
/**
* @brief Get the properties of the source stream read.
*/
const StreamProperties* getSourceProperties() const { return _streamProperties; }
/**
* @brief Set the reader state to generate data (ie silence or black) when there is no more data to decode.
* @note By default, the reader returns an empty frame.
*/
void continueWithGenerator(const bool continueWithGenerator = true) { _continueWithGenerator = continueWithGenerator; }
protected:
InputFile* _inputFile;
const StreamProperties* _streamProperties;
IDecoder* _decoder;
IDecoder* _generator;
IDecoder* _currentDecoder; ///< Link to _inputDecoder or _generator
IFrame* _srcFrame;
IFrame* _dstFrame;
ITransform* _transform;
size_t _streamIndex;
int _channelIndex;
private:
int _currentFrame; ///< The current decoded frame.
bool _inputFileAllocated; ///< Does the InputFile is held by the class or not (depends on the constructor called)
bool _continueWithGenerator; ///< If there is no more data to decode, complete with generated data
};
}
#endif