FastLED 3.10.8
Loading...
Searching...
No Matches
video_impl.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/stdint.h"
4#include "fl/stl/shared_ptr.h"
5#include "fl/stl/span.h"
6#include "fl/stl/noexcept.h"
7#include "fl/stl/string.h" // For fl::string return type on embeddedScreenMapJson()
8
9// Forward declarations - actual includes moved to cpp
10namespace fl {
11class filebuf;
12class Frame;
13class TimeWarp;
14
15using filebuf_ptr = fl::shared_ptr<filebuf>;
17} // namespace fl
18
19namespace fl {
20namespace video {
21
23class PixelStream;
24struct PixelSample;
25
29
30class VideoImpl {
31 public:
32 enum {
34 };
35 // frameHistoryCount is the number of frames to keep in the buffer after
36 // draw. This allows for time based effects like syncing video speed to
37 // audio triggers.
38 VideoImpl(size_t pixelsPerFrame, float fpsVideo,
39 size_t frameHistoryCount = 0) FL_NO_EXCEPT;
41 // Api
43 void setBestEffortFled(bool enabled) FL_NO_EXCEPT { mBestEffortFled = enabled; }
44 void setFade(fl::u32 fadeInTime, fl::u32 fadeOutTime) FL_NO_EXCEPT;
45 bool draw(fl::u32 now, fl::span<CRGB> leds) FL_NO_EXCEPT;
46 void end() FL_NO_EXCEPT;
47 bool rewind() FL_NO_EXCEPT;
48 // internal use
49 bool draw(fl::u32 now, Frame *frame) FL_NO_EXCEPT;
50 bool full() const FL_NO_EXCEPT;
52 float timeScale() const FL_NO_EXCEPT { return mTimeScale; }
53 size_t pixelsPerFrame() const FL_NO_EXCEPT { return mPixelsPerFrame; }
54 void pause(fl::u32 now) FL_NO_EXCEPT;
55 void resume(fl::u32 now) FL_NO_EXCEPT;
56 bool needsFrame(fl::u32 now) const FL_NO_EXCEPT;
57 i32 durationMicros() const FL_NO_EXCEPT; // -1 if this is a stream.
58
59 // FLED v1 container accessors. Forwards to the underlying PixelStream;
60 // empty / false for legacy headerless `.rgb` files.
62 const fl::string &embeddedScreenMapJson() const FL_NO_EXCEPT;
63 bool videoColor(fled::VideoColor *out) const FL_NO_EXCEPT;
64 bool pixelStorage(fled::PixelStorage *out) const FL_NO_EXCEPT;
66
67 private:
68 bool updateBufferIfNecessary(fl::u32 prev, fl::u32 now) FL_NO_EXCEPT;
69 bool updateBufferFromFile(fl::u32 now, bool forward) FL_NO_EXCEPT;
73 fl::u32 mPrevNow = 0;
74 FrameInterpolatorPtr mFrameInterpolator;
75 fl::TimeWarpPtr mTime;
76 fl::u32 mFadeInTime = 1000;
77 fl::u32 mFadeOutTime = 1000;
78 float mTimeScale = 1.0f;
79 bool mBestEffortFled = false;
80};
81
82} // namespace video
85} // namespace fl
CRGB leds[1]
fl::TimeWarp timeScale(0, 1.0f)
bool full() const FL_NO_EXCEPT
bool hasEmbeddedScreenMap() const FL_NO_EXCEPT
float timeScale() const FL_NO_EXCEPT
Definition video_impl.h:52
VideoImpl(size_t pixelsPerFrame, float fpsVideo, size_t frameHistoryCount=0) FL_NO_EXCEPT
bool needsFrame(fl::u32 now) const FL_NO_EXCEPT
const fl::string & embeddedScreenMapJson() const FL_NO_EXCEPT
bool updateBufferFromStream(fl::u32 now) FL_NO_EXCEPT
fl::TimeWarpPtr mTime
Definition video_impl.h:75
void resume(fl::u32 now) FL_NO_EXCEPT
bool updateBufferIfNecessary(fl::u32 prev, fl::u32 now) FL_NO_EXCEPT
bool draw(fl::u32 now, fl::span< CRGB > leds) FL_NO_EXCEPT
bool videoColor(fled::VideoColor *out) const FL_NO_EXCEPT
bool pixelStorage(fled::PixelStorage *out) const FL_NO_EXCEPT
void pause(fl::u32 now) FL_NO_EXCEPT
void setFade(fl::u32 fadeInTime, fl::u32 fadeOutTime) FL_NO_EXCEPT
FrameInterpolatorPtr mFrameInterpolator
Definition video_impl.h:74
void setBestEffortFled(bool enabled) FL_NO_EXCEPT
Definition video_impl.h:43
bool updateBufferFromFile(fl::u32 now, bool forward) FL_NO_EXCEPT
i32 durationMicros() const FL_NO_EXCEPT
void setTimeScale(float timeScale) FL_NO_EXCEPT
bool rewind() FL_NO_EXCEPT
size_t pixelsPerFrame() const FL_NO_EXCEPT
Definition video_impl.h:53
PixelStreamPtr mStream
Definition video_impl.h:72
bool readSample(PixelSample *out) FL_NO_EXCEPT
void end() FL_NO_EXCEPT
void draw(float pos)
Definition curr.h:526
constexpr T * begin(T(&array)[N]) FL_NO_EXCEPT
constexpr T && forward(typename remove_reference< T >::type &t) FL_NO_EXCEPT
video::VideoImpl VideoImpl
Definition video.h:30
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
fl::shared_ptr< filebuf > filebuf_ptr
Definition idecoder.h:15
fl::shared_ptr< VideoImpl > VideoImplPtr
Definition video.h:31
video::PixelStreamPtr PixelStreamPtr
Base definition for an LED controller.
Definition crgb.hpp:179
#define FASTLED_SHARED_PTR(type)
Definition shared_ptr.h:577