FastLED 3.9.12
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 void setFade(uint32_t fadeInTime, uint32_t fadeOutTime);
37 bool draw(uint32_t now, CRGB *leds);
38 void end();
39 bool rewind();
40 // internal use
41 bool draw(uint32_t now, Frame *frame);
42 bool full() const;
43 void setTimeScale(float timeScale);
44 float timeScale() const { return mTimeScale; }
45 size_t pixelsPerFrame() const { return mPixelsPerFrame; }
46 void pause(uint32_t now);
47 void resume(uint32_t now);
48 bool needsFrame(uint32_t now) const;
49 int32_t durationMicros() const; // -1 if this is a stream.
50
51
52 private:
53 bool updateBufferIfNecessary(uint32_t prev, uint32_t now);
54 bool updateBufferFromFile(uint32_t now, bool forward);
55 bool updateBufferFromStream(uint32_t now);
56 uint32_t mPixelsPerFrame = 0;
57 PixelStreamPtr mStream;
58 uint32_t mPrevNow = 0;
59 FrameInterpolatorPtr mFrameInterpolator;
60 TimeScalePtr mTime;
61 uint32_t mFadeInTime = 1000;
62 uint32_t mFadeOutTime = 1000;
63 float mTimeScale = 1.0f;
64};
65
66} // 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