MCPcopy Create free account
hub / github.com/AbyssEngine/AbyssEngineOld / VideoStream

Class VideoStream

src/Abyss/Streams/VideoStream.h:31–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29constexpr int DecodeBufferSize = 1024;
30
31class VideoStream {
32 FileSystem::InputStream _stream;
33 std::unique_ptr<AudioStream> _separateAudio;
34 Common::RingBuffer<uint8_t> _ringBuffer;
35
36 std::unique_ptr<SDL_Texture, void (*)(SDL_Texture *)> _texture;
37
38 AVFormatContext *_avFormatContext;
39 AVIOContext *_avioContext;
40 SwrContext *_resampleContext;
41 AVCodecContext *_videoCodecContext;
42 AVCodecContext *_audioCodecContext;
43 AVFrame *_avFrame;
44
45 unsigned char *_avBuffer;
46 std::vector<uint8_t> _yPlane;
47 std::vector<uint8_t> _uPlane;
48 std::vector<uint8_t> _vPlane;
49 SwsContext *_swsContext;
50
51 SDL_Rect _sourceRect;
52 SDL_Rect _targetRect;
53
54 int _videoStreamIdx = -1;
55 int _audioStreamIdx = -1;
56 int _uvPitch;
57 uint64_t _microsPerFrame;
58 uint64_t _videoTimestamp;
59 bool _isPlaying = true;
60 bool _framesReady = false;
61 uint32_t _totalTicks = 0;
62 uint8_t _audioOutBuffer[1024 * 16] = {};
63
64 static std::string avErrorCodeToString(int avError);
65 int videoStreamRead(uint8_t *buffer, int size);
66 bool processFrame();
67 int64_t videoStreamSeek(int64_t offset, int whence);
68
69 public:
70 VideoStream(Abyss::FileSystem::InputStream stream, std::optional<Abyss::FileSystem::InputStream> separateAudio);
71 ~VideoStream();
72 void update(uint32_t ticks);
73 void render() const;
74 void stopVideo();
75 short getAudioSample();
76 bool getIsPlaying() const;
77};
78
79} // namespace Abyss::Streams

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected