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/bytestream.h"
4#include "fl/file_system.h"
7#include "fl/stdint.h"
8
9#include "fl/namespace.h"
10
11namespace fl {
14} // namespace fl
15
16namespace fl {
17
18FASTLED_SMART_PTR(VideoImpl);
21
22class VideoImpl {
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(fl::u32 fadeInTime, fl::u32 fadeOutTime);
37 bool draw(fl::u32 now, CRGB *leds);
38 void end();
39 bool rewind();
40 // internal use
41 bool draw(fl::u32 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(fl::u32 now);
47 void resume(fl::u32 now);
48 bool needsFrame(fl::u32 now) const;
49 int32_t durationMicros() const; // -1 if this is a stream.
50
51 private:
52 bool updateBufferIfNecessary(fl::u32 prev, fl::u32 now);
53 bool updateBufferFromFile(fl::u32 now, bool forward);
54 bool updateBufferFromStream(fl::u32 now);
55 fl::u32 mPixelsPerFrame = 0;
56 PixelStreamPtr mStream;
57 fl::u32 mPrevNow = 0;
58 FrameInterpolatorPtr mFrameInterpolator;
59 TimeWarpPtr mTime;
60 fl::u32 mFadeInTime = 1000;
61 fl::u32 mFadeOutTime = 1000;
62 float mTimeScale = 1.0f;
63};
64
65} // namespace fl
CRGB leds[NUM_LEDS]
TimeWarp timeScale(0, 1.0f)
void draw(float pos)
Definition curr.h:538
Implements the FastLED namespace macros.
constexpr T * begin(T(&array)[N]) noexcept
Definition range_access.h:9
constexpr T * end(T(&array)[N]) noexcept
constexpr T && forward(typename remove_reference< T >::type &t) noexcept
IMPORTANT!
Definition crgb.h:20
#define FASTLED_SMART_PTR(type)
Definition ptr.h:33
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86