-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo_decoder.hpp
61 lines (48 loc) · 1.76 KB
/
video_decoder.hpp
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
#ifndef VIDEO_DECODER_HPP
#define VIDEO_DECODER_HPP
#ifdef TESTS
#include "gtest/gtest.h"
#endif
#include <vector>
#include <memory>
#include <cstddef>
#include "exceptions/av_exception.hpp"
#include <algorithm>
#include "video.hpp"
#include "../config.h"
//! @namespace decoder
//! @brief Decoder Video namespace
namespace decoder {
//! @class VideoDecoder
//! @brief Use Libav/Ffmpeg to decode some kind of video (format full keyframes)
class VideoDecoder {
private:
std::vector<std::shared_ptr<entities::VideoFrame>> decoded_vector;
DecoderContext& m_context;
public:
VideoDecoder(DecoderContext& context);
~VideoDecoder();
private:
void updateVideoBuffer(std::size_t writes); //!< For now we always clean the full array
void seek(unsigned int position);
//! @brief Decode the next frame in the video
void nextFrame(AVFrame* frame); //!< Can Throw AVException
//! @brief Check where we need to decode from
int getDecodeIndex(const DeBuffer<std::shared_ptr<entities::VideoFrame>>& buffer);
#ifdef TESTS //! @brief Some Google Tests
//! @brief Unit Tests
FRIEND_TEST(VideoDecoderTest, Decode_Normal);
FRIEND_TEST(VideoDecoderTest, Decode_Reverse);
FRIEND_TEST(VideoDecoderTest, Decode_Index);
FRIEND_TEST(VideoDecoderTest, Decode_EOF);
FRIEND_TEST(VideoDecoderTest, NextFrame);
FRIEND_TEST(VideoDecoderTest, StartFrameNumber);
#endif
public:
//! @brief Decode one array of frame
void decode(unsigned int next);
//! @brief Decode and write one array into the buffer
void decodeAndWrite(DeBuffer<std::shared_ptr<entities::VideoFrame>>& buffer);
};
}
#endif