FastLED 3.9.7
Loading...
Searching...
No Matches
video_impl.h
1#pragma once
2
3#include <stdint.h>
4#include "fl/bytestream.h"
5#include "fx/video/pixel_stream.h"
6#include "fx/video/frame_interpolator.h"
7#include "fl/file_system.h"
8
9#include "fl/namespace.h"
10
11namespace fl {
12FASTLED_SMART_PTR(FileHandle);
13FASTLED_SMART_PTR(ByteStream);
14}
15
16namespace fl {
17
18FASTLED_SMART_PTR(VideoImpl);
19FASTLED_SMART_PTR(FrameInterpolator);
20FASTLED_SMART_PTR(PixelStream)
21
22class VideoImpl : public fl::Referent {
23 public:
24 enum {
25 kSizeRGB8 = 3,
26 };
27 // frameHistoryCount is the number of frames to keep in the buffer after
28 // draw. This allows for time based effects like syncing video speed to
29 // audio triggers.
30 VideoImpl(size_t pixelsPerFrame, float fpsVideo,
31 size_t frameHistoryCount = 0);
32 ~VideoImpl();
33 // Api
34 void begin(fl::FileHandlePtr h);
35 void beginStream(fl::ByteStreamPtr s);
36 bool draw(uint32_t now, CRGB *leds);
37 void end();
38 bool rewind();
39 // internal use
40 bool draw(uint32_t now, Frame *frame);
41 bool full() const;
42 void setTimeScale(float timeScale);
43 float timeScale() const { return mTimeScale ? mTimeScale->scale() : 1.0f; }
44 size_t pixelsPerFrame() const { return mPixelsPerFrame; }
45 void pause(uint32_t now);
46 void resume(uint32_t now);
47 bool needsFrame(uint32_t now) const;
48
49 private:
50 bool updateBufferIfNecessary(uint32_t prev, uint32_t now);
51 bool updateBufferFromFile(uint32_t now, bool forward);
52 bool updateBufferFromStream(uint32_t now);
53 uint32_t mPixelsPerFrame = 0;
54 PixelStreamPtr mStream;
55 uint32_t mPrevNow = 0;
56 FrameInterpolatorPtr mFrameInterpolator;
57 TimeScalePtr mTimeScale;
58};
59
60} // namespace fl
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54