arduino-audio-tools
Loading...
Searching...
No Matches
VideoOutput.h
Go to the documentation of this file.
1#pragma once
3#include "stdint.h"
4
5namespace audio_tools {
6
29enum class VideoFormat {
30 H264,
31 MJPEG,
32 MPEG4,
33 RAW,
34 YUV422,
35 RGB565,
36 RGB666,
37 RGB888,
38 I420,
39 MPEG1,
41};
42
49struct VideoInfo {
51 uint16_t width = 0;
53 uint16_t height = 0;
56 float fps = 0;
62 uint32_t frame_size = 0;
68 uint32_t total_file_size = 0;
69
70 bool operator==(const VideoInfo& alt) const {
71 return width == alt.width && height == alt.height && fps == alt.fps &&
72 format == alt.format && frame_size == alt.frame_size &&
74 }
75 bool operator!=(const VideoInfo& alt) const { return !(*this == alt); }
77 operator bool() const { return width > 0 && height > 0; }
78 void logInfo(const char* source = "") {
79 LOGI(
80 "%s width: %d / height: %d / fps: %f / format: %d / frame_size: %d / "
81 "total_file_size: %d",
82 source, (int)width, (int)height, fps, (int)format, (int)frame_size,
83 (int)total_file_size);
84 }
85};
86
93 public:
94 virtual VideoInfo videoInfo() = 0;
95};
96
108 public:
109 virtual size_t write(const uint8_t* data, size_t len) = 0;
113 virtual void flush() {}
121 virtual void setSkipRender(bool skip) {}
122
135 virtual bool isKeyFrame(const uint8_t* data, size_t len) { return false; }
136
138 virtual uint32_t getWriteTimeMs() const { return 0; }
139
152 virtual bool hadOutput() const { return true; }
153
161 virtual void setVideoInfoSource(VideoInfoSource& source) {}
162
170 virtual uint64_t totalDecodeMs() const { return 0; }
171};
172
173} // namespace audio_tools
#define LOGI(...)
Definition AudioLoggerIDF.h:28
Provider of VideoInfo (width/height/fps/format) for whoever needs to size buffers/panel setup against...
Definition VideoOutput.h:92
virtual VideoInfo videoInfo()=0
Abstract class for video playback. This class is used to assemble a complete video frame in memory....
Definition VideoOutput.h:107
virtual void setVideoInfoSource(VideoInfoSource &source)
Definition VideoOutput.h:161
virtual size_t write(const uint8_t *data, size_t len)=0
virtual uint64_t totalDecodeMs() const
Definition VideoOutput.h:170
virtual bool hadOutput() const
Definition VideoOutput.h:152
virtual uint32_t getWriteTimeMs() const
Optional: returns the time (ms) spent in the last write() call.
Definition VideoOutput.h:138
virtual void setSkipRender(bool skip)
Definition VideoOutput.h:121
virtual void flush()
Definition VideoOutput.h:113
virtual bool isKeyFrame(const uint8_t *data, size_t len)
Definition VideoOutput.h:135
VideoFormat
Video codec/pixel-format identifier, shared by two unrelated uses: the (single) video stream of a con...
Definition VideoOutput.h:29
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition LMSEchoCancellationStream.h:6
Basic video information (width/height/codec/frame size), analogous to AudioInfo - common to both Demu...
Definition VideoOutput.h:49
uint32_t frame_size
Definition VideoOutput.h:62
bool operator==(const VideoInfo &alt) const
Definition VideoOutput.h:70
uint32_t total_file_size
Definition VideoOutput.h:68
float fps
Definition VideoOutput.h:56
uint16_t height
Frame height in pixels.
Definition VideoOutput.h:53
bool operator!=(const VideoInfo &alt) const
Definition VideoOutput.h:75
uint16_t width
Frame width in pixels.
Definition VideoOutput.h:51
VideoFormat format
Video codec - VideoFormat::UNKNOWN if not (yet) determined.
Definition VideoOutput.h:58
void logInfo(const char *source="")
Definition VideoOutput.h:78