FastLED 3.9.3
Loading...
Searching...
No Matches
video.h
1#pragma once
2
3#include <stdint.h>
4
5#include "namespace.h"
6#include "ref.h"
7#include "fx/fx2d.h"
8
9
10FASTLED_NAMESPACE_BEGIN
11
12// Forward declare dependencies.
13FASTLED_SMART_REF(VideoImpl);
14FASTLED_SMART_REF(ByteStream);
15FASTLED_SMART_REF(FileHandle);
16FASTLED_SMART_REF(VideoFx);
17FASTLED_SMART_REF(Frame);
18struct CRGB;
19
20// Video represents a video file that can be played back on a LED strip.
21// The video file is expected to be a sequence of frames. You can either use
22// a file handle or a byte stream to read the video data.
23class Video {
24public:
25 // frameHistoryCount is the number of frames to keep in the buffer after draw. This
26 // allows for time based effects like syncing video speed to audio triggers.
27 Video(); // Please use FileSytem to construct a Video.
28 Video(FileHandleRef h, size_t pixelsPerFrame, float fps = 30.0f, size_t frameHistoryCount = 0);
29 Video(ByteStreamRef s, size_t pixelsPerFrame, float fps = 30.0f, size_t frameHistoryCount = 0);
30 ~Video();
31 Video(const Video&);
32 Video& operator=(const Video&);
33 // Api
34 void begin(FileHandleRef h, size_t pixelsPerFrame, float fps = 30.0f, size_t frameHistoryCount = 0);
35 void beginStream(ByteStreamRef s, size_t pixelsPerFrame, float fps = 30.0f, size_t frameHistoryCount = 0);
36 bool draw(uint32_t now, CRGB* leds, uint8_t* alpha = nullptr);
37 bool draw(uint32_t now, Frame* frame);
38 void end();
39 bool finished();
40 bool rewind();
41
42 // make compatible with if statements
43 operator bool() const { return mImpl.get(); }
44private:
45 bool mFinished = false;
46 VideoImplRef mImpl;
47};
48
49
50class VideoFx : public FxGrid {
51 public:
52 VideoFx(Video video, XYMap xymap);
53 void draw(DrawContext context) override;
54 const char *fxName(int) const override;
55
56 private:
57 Video mVideo;
58 FrameRef mFrame;
59};
60
61FASTLED_NAMESPACE_END
62
Definition frame.h:18
Definition fx2d.h:16
void draw(DrawContext context) override
Definition video.cpp:234
Definition video.h:23
Definition xymap.h:39
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:39