AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IReader.hpp
Go to the documentation of this file.
1 #ifndef _AV_TRANSCODER_IREADER_HPP
2 #define _AV_TRANSCODER_IREADER_HPP
3 
5 
11 
12 namespace avtranscoder
13 {
14 
15 /**
16  * @brief Based class to read a stream.
17  */
18 class AvExport IReader
19 {
20 public:
21  /**
22  * @brief Create a new InputFile and prepare to read the stream at the given index
23  * @param streamIndex by default read the first stream
24  * @param channelIndex by default -1 (all channels of the stream)
25  */
26  IReader(const std::string& filename, const size_t streamIndex = 0, const int channelIndex = -1);
27 
28  /**
29  * @brief Get the existing InputFile and prepare to read the stream at the given index
30  * @note This constructor can improve performances when you create several readers from one InputFile.
31  */
32  IReader(InputFile& inputFile, const size_t streamIndex = 0, const int channelIndex = -1);
33 
34  virtual ~IReader() = 0;
35 
36  /**
37  * @return Get next frame after decoding
38  * @see readFrameAt
39  */
40  Frame* readNextFrame();
41 
42  /**
43  * @return Get previous frame after decoding
44  * @see readFrameAt
45  */
46  Frame* readPrevFrame();
47 
48  /**
49  * @return Get indicated frame after decoding
50  * @warn Returns NULL if there is no more frame to read.
51  * @see continueWithGenerator
52  */
53  Frame* readFrameAt(const size_t frame);
54 
55  /**
56  * @brief Get the properties of the source stream read.
57  */
58  const StreamProperties* getSourceProperties() const { return _streamProperties; }
59 
60  /**
61  * @brief Set the reader state to generate data (ie silence or black) when there is no more data to decode.
62  * @note By default, the reader returns an empty frame.
63  */
64  void continueWithGenerator(const bool continueWithGenerator = true) { _continueWithGenerator = continueWithGenerator; }
65 
66 protected:
71  IDecoder* _currentDecoder; ///< Link to _inputDecoder or _generator
72 
75 
77 
78  size_t _streamIndex;
80 
81 private:
82  int _currentFrame; ///< The current decoded frame.
83  bool _inputFileAllocated; ///< Does the InputFile is held by the class or not (depends on the constructor called)
84  bool _continueWithGenerator; ///< If there is no more data to decode, complete with generated data
85 };
86 }
87 
88 #endif
IDecoder * _generator
Definition: IReader.hpp:70
bool _inputFileAllocated
Does the InputFile is held by the class or not (depends on the constructor called) ...
Definition: IReader.hpp:83
IDecoder * _decoder
Definition: IReader.hpp:69
Based class to read a stream.
Definition: IReader.hpp:18
int _currentFrame
The current decoded frame.
Definition: IReader.hpp:82
void continueWithGenerator(const bool continueWithGenerator=true)
Set the reader state to generate data (ie silence or black) when there is no more data to decode...
Definition: IReader.hpp:64
InputFile * _inputFile
Definition: IReader.hpp:67
This class describes decoded (raw) audio or video data.
Definition: Frame.hpp:16
ITransform * _transform
Definition: IReader.hpp:76
Virtual based class of properties for all types of stream.
const StreamProperties * getSourceProperties() const
Get the properties of the source stream read.
Definition: IReader.hpp:58
const StreamProperties * _streamProperties
Definition: IReader.hpp:68
IDecoder * _currentDecoder
Link to _inputDecoder or _generator.
Definition: IReader.hpp:71
bool _continueWithGenerator
If there is no more data to decode, complete with generated data.
Definition: IReader.hpp:84