|
2 | 2 | #define _AVPLAYER_AVREADER_
|
3 | 3 |
|
4 | 4 | #include <AvTranscoder/file/InputFile.hpp>
|
5 |
| -#include <AvTranscoder/progress/ConsoleProgress.hpp> |
6 |
| -#include <AvTranscoder/mediaProperty/print.hpp> |
7 |
| - |
8 | 5 | #include <AvTranscoder/decoder/VideoDecoder.hpp>
|
9 |
| - |
| 6 | +#include <AvTranscoder/frame/VideoFrame.hpp> |
10 | 7 | #include <AvTranscoder/transform/VideoTransform.hpp>
|
11 | 8 |
|
12 | 9 | #include "Reader.hpp"
|
13 | 10 |
|
14 | 11 | class AvReader : public Reader
|
15 | 12 | {
|
16 | 13 | public:
|
17 |
| - AvReader( const std::string& filename ) |
18 |
| - : _inputFile( filename ) |
19 |
| - , _inputVideo( NULL ) |
20 |
| - , _sourceImage( NULL ) |
21 |
| - , _imageToDisplay( NULL ) |
22 |
| - { |
23 |
| - avtranscoder::ConsoleProgress p; |
24 |
| - |
25 |
| - _inputFile.analyse( p ); |
26 |
| - _videoStream = _inputFile.getProperties().getVideoProperties().at(0).getStreamId(); |
27 |
| - _inputFile.activateStream( _videoStream ); |
28 |
| - |
29 |
| - _inputVideo = new avtranscoder::VideoDecoder( _inputFile.getStream( _videoStream ) ); |
30 |
| - _inputVideo->setup(); |
31 |
| - |
32 |
| - _sourceImage = new avtranscoder::VideoFrame( _inputFile.getStream( _videoStream ).getVideoCodec().getVideoFrameDesc() ); |
33 |
| - |
34 |
| - avtranscoder::VideoFrameDesc videoFrameDescToDisplay( _sourceImage->desc().getWidth(), _sourceImage->desc().getHeight(), "rgb24" ); |
35 |
| - _imageToDisplay = new avtranscoder::VideoFrame( videoFrameDescToDisplay ); |
36 |
| - } |
37 |
| - |
38 |
| - ~AvReader() |
39 |
| - { |
40 |
| - delete _inputVideo; |
41 |
| - delete _sourceImage; |
42 |
| - delete _imageToDisplay; |
43 |
| - } |
44 |
| - |
45 |
| - size_t getWidth() |
46 |
| - { |
47 |
| - return _inputFile.getProperties().getVideoProperties().at(0).getWidth(); |
48 |
| - }; |
49 |
| - |
50 |
| - size_t getHeight() |
51 |
| - { |
52 |
| - return _inputFile.getProperties().getVideoProperties().at(0).getHeight(); |
53 |
| - } |
54 |
| - |
55 |
| - size_t getComponents() |
56 |
| - { |
57 |
| - return _inputFile.getProperties().getVideoProperties().at(0).getPixelProperties().getNbComponents(); |
58 |
| - } |
59 |
| - |
60 |
| - size_t getBitDepth() |
61 |
| - { |
62 |
| - return _inputFile.getProperties().getVideoProperties().at(0).getPixelProperties().getBitsPerPixel(); |
63 |
| - } |
64 |
| - |
65 |
| - AVPixelFormat getPixelFormat() |
66 |
| - { |
67 |
| - return _inputFile.getProperties().getVideoProperties().at(0).getPixelProperties().getAVPixelFormat(); |
68 |
| - } |
69 |
| - |
70 |
| - const char* readNextFrame() |
71 |
| - { |
72 |
| - ++_currentFrame; |
73 |
| - _inputVideo->decodeNextFrame( *_sourceImage ); |
74 |
| - _videoTransform.convert( *_sourceImage, *_imageToDisplay ); |
75 |
| - return (const char*)_imageToDisplay->getPtr(); |
76 |
| - } |
| 14 | + AvReader( const std::string& filename ); |
| 15 | + ~AvReader(); |
77 | 16 |
|
78 |
| - const char* readPrevFrame() |
79 |
| - { |
80 |
| - --_currentFrame; |
81 |
| - return readFrameAt( _currentFrame ); |
82 |
| - } |
| 17 | + size_t getWidth(); |
| 18 | + size_t getHeight(); |
| 19 | + size_t getComponents(); |
| 20 | + size_t getBitDepth(); |
| 21 | + AVPixelFormat getPixelFormat(); |
83 | 22 |
|
84 |
| - const char* readFrameAt( const size_t frame ) |
85 |
| - { |
86 |
| - // /std::cout << "seek at " << frame << std::endl; |
87 |
| - _inputFile.seekAtFrame( frame ); |
88 |
| - _inputVideo->flushDecoder(); |
89 |
| - return readNextFrame(); |
90 |
| - } |
| 23 | + const char* readNextFrame(); |
| 24 | + const char* readPrevFrame(); |
| 25 | + const char* readFrameAt( const size_t frame ); |
91 | 26 |
|
92 |
| - void printMetadatas() |
93 |
| - { |
94 |
| - std::cout << _inputFile << std::endl; |
95 |
| - } |
| 27 | + void printMetadatas(); |
96 | 28 |
|
97 | 29 | private:
|
98 | 30 | avtranscoder::InputFile _inputFile;
|
|
0 commit comments