FastLED 3.9.3
Loading...
Searching...
No Matches
data_stream.h
1#pragma once
2
3#include "namespace.h"
4#include "crgb.h"
5#include "ref.h"
6#include "fx/storage/filebuffer.h"
7#include "fx/storage/bytestream.h"
8#include "fx/frame.h"
9#include "file_system.h"
10
11FASTLED_NAMESPACE_BEGIN
12
13FASTLED_SMART_REF(DataStream);
14FASTLED_SMART_REF(ByteStream);
15FASTLED_SMART_REF(FileHandle);
16FASTLED_SMART_REF(FileBuffer);
17
18// DataStream takes either a file handle or a byte stream
19// and reads frames from it in order to serve data to the
20// video system.
21class DataStream: public Referent {
22 public:
23
24 enum Type {
25 kStreaming,
26 kFile,
27 };
28
29 explicit DataStream(int bytes_per_frame);
30
31 bool begin(FileHandleRef h);
32 bool beginStream(ByteStreamRef s);
33 void close();
34 int32_t bytesPerFrame();
35 bool readPixel(CRGB* dst); // Convenience function to read a pixel
36 size_t readBytes(uint8_t* dst, size_t len);
37
38 bool readFrame(Frame* frame);
39 int32_t framesRemaining() const;
40 int32_t framesDisplayed() const;
41 bool available() const;
42
43 int32_t bytesRemaining() const;
44 int32_t bytesRemainingInFrame() const;
45 bool rewind(); // Returns false on failure, which can happen for streaming mode.
46 Type getType() const; // Returns the type of the video stream (kStreaming or kFile)
47
48 private:
49 void init(int bytes_per_frame);
50 int32_t mbytesPerFrame;
51 FileHandleRef mFileHandle;
52 FileBufferRef mFileBuffer;
53 ByteStreamRef mByteStream;
54 bool mUsingByteStream;
55
56protected:
57 virtual ~DataStream();
58};
59
60FASTLED_NAMESPACE_END
Definition frame.h:18
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:39