FastLED 3.9.15
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;
24
28
29class VideoImpl {
30 public:
31 enum {
33 };
34 // frameHistoryCount is the number of frames to keep in the buffer after
35 // draw. This allows for time based effects like syncing video speed to
36 // audio triggers.
37 VideoImpl(size_t pixelsPerFrame, float fpsVideo,
38 size_t frameHistoryCount = 0);
40 // Api
41 void begin(fl::filebuf_ptr h);
42 void setFade(fl::u32 fadeInTime, fl::u32 fadeOutTime);
43 bool draw(fl::u32 now, fl::span<CRGB> leds);
44 void end();
45 bool rewind();
46 // internal use
47 bool draw(fl::u32 now, Frame *frame);
48 bool full() const;
49 void setTimeScale(float timeScale);
50 float timeScale() const { return mTimeScale; }
51 size_t pixelsPerFrame() const { return mPixelsPerFrame; }
52 void pause(fl::u32 now);
53 void resume(fl::u32 now);
54 bool needsFrame(fl::u32 now) const;
55 i32 durationMicros() const; // -1 if this is a stream.
56
57 // FLED v1 container accessors. Forwards to the underlying PixelStream;
58 // empty / false for legacy headerless `.rgb` files.
60 const fl::string &embeddedScreenMapJson() const FL_NOEXCEPT;
61
62 private:
63 bool updateBufferIfNecessary(fl::u32 prev, fl::u32 now);
64 bool updateBufferFromFile(fl::u32 now, bool forward);
65 bool updateBufferFromStream(fl::u32 now);
68 fl::u32 mPrevNow = 0;
69 FrameInterpolatorPtr mFrameInterpolator;
70 fl::TimeWarpPtr mTime;
71 fl::u32 mFadeInTime = 1000;
72 fl::u32 mFadeOutTime = 1000;
73 float mTimeScale = 1.0f;
74};
75
76} // namespace video
79} // namespace fl
fl::CRGB leds[NUM_LEDS]
fl::TimeWarp timeScale(0, 1.0f)
bool updateBufferFromStream(fl::u32 now)
fl::TimeWarpPtr mTime
Definition video_impl.h:70
void setFade(fl::u32 fadeInTime, fl::u32 fadeOutTime)
size_t pixelsPerFrame() const
Definition video_impl.h:51
bool updateBufferFromFile(fl::u32 now, bool forward)
float timeScale() const
Definition video_impl.h:50
FrameInterpolatorPtr mFrameInterpolator
Definition video_impl.h:69
VideoImpl(size_t pixelsPerFrame, float fpsVideo, size_t frameHistoryCount=0)
void resume(fl::u32 now)
void pause(fl::u32 now)
bool needsFrame(fl::u32 now) const
bool hasEmbeddedScreenMap() const FL_NOEXCEPT
void setTimeScale(float timeScale)
const fl::string & embeddedScreenMapJson() const FL_NOEXCEPT
PixelStreamPtr mStream
Definition video_impl.h:67
bool updateBufferIfNecessary(fl::u32 prev, fl::u32 now)
void draw(float pos)
Definition curr.h:526
video::VideoImpl VideoImpl
Definition video.h:27
constexpr T * begin(T(&array)[N]) FL_NOEXCEPT
constexpr T * end(T(&array)[N]) FL_NOEXCEPT
fl::shared_ptr< filebuf > filebuf_ptr
Definition idecoder.h:15
fl::shared_ptr< VideoImpl > VideoImplPtr
Definition video.h:28
video::PixelStreamPtr PixelStreamPtr
constexpr T && forward(typename remove_reference< T >::type &t) FL_NOEXCEPT
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT
#define FASTLED_SHARED_PTR(type)
Definition shared_ptr.h:535
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38