FastLED 3.9.15
Loading...
Searching...
No Matches

◆ processMpeg1()

void CodecProcessor::processMpeg1 ( )

Definition at line 148 of file codec_processor.cpp.

148 {
149 Serial.println("\n=== Processing MPEG1 ===");
150
151 if (!fl::Mpeg1::isSupported()) {
152 Serial.println("MPEG1 decoding not supported on this platform");
153 return;
154 }
155
156 // Copy data from PROGMEM to RAM
159
160 // Configure MPEG1 decoder
161 fl::Mpeg1Config config;
163 config.targetFps = TARGET_FPS;
164 config.looping = false;
165 config.skipAudio = true;
166
167 // Create decoder
168 fl::string error_msg;
169 fl::shared_ptr<fl::IDecoder> decoder = fl::Mpeg1::createDecoder(config, &error_msg);
170
171 if (!decoder) {
172 Serial.print("Failed to create MPEG1 decoder: ");
173 Serial.println(error_msg.c_str());
174 return;
175 }
176
177 // Create byte stream from data
178 auto stream = fl::make_shared<fl::memorybuf>(mpegData.size());
179 stream->write(mpegData);
180
181 // Begin decoding
182 if (!decoder->begin(stream)) {
183 fl::string error;
184 decoder->hasError(&error);
185 Serial.print("Failed to begin MPEG1 decoding: ");
186 Serial.println(error.c_str());
187 return;
188 }
189
190 // Decode first frame
191 fl::DecodeResult result = decoder->decode();
192
193 if (result == fl::DecodeResult::Success) {
194 fl::Frame frame = decoder->getCurrentFrame();
195 if (frame.isValid()) {
196 displayFrameOnLEDs(frame);
197 showDecodedMessage("MPEG1 decoded successfully!");
198 } else {
199 Serial.println("Invalid MPEG1 frame received");
200 }
201 } else {
202 fl::string error;
203 decoder->hasError(&error);
204 Serial.print("MPEG1 frame decode error: ");
205 Serial.println(error.c_str());
206 }
207
208 decoder->end();
209}
bool isValid() const
static bool isSupported()
Definition mpeg1.cpp.hpp:14
static IDecoderPtr createDecoder(const Mpeg1Config &config, fl::string *error_message=nullptr)
Definition mpeg1.cpp.hpp:8
const char * c_str() const FL_NOEXCEPT
const uint8_t sampleMpeg1Data[]
const size_t sampleMpeg1DataLength
void displayFrameOnLEDs(const fl::Frame &frame)
void showDecodedMessage(const char *format)
void * memcopy(void *dest, const void *src, size_t n) FL_NOEXCEPT
Definition cstring.h:103
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
third_party::Mpeg1Config Mpeg1Config
Definition mpeg1.h:29
DecodeResult
Definition idecoder.h:18
#define Serial
Definition serial.h:304

References fl::basic_string::c_str(), fl::Mpeg1::createDecoder(), fl::vector< T >::data(), displayFrameOnLEDs(), fl::Mpeg1::isSupported(), fl::Frame::isValid(), fl::third_party::Mpeg1Config::looping, fl::make_shared(), fl::memcopy(), fl::third_party::Mpeg1Config::mode, CodecData::sampleMpeg1Data, CodecData::sampleMpeg1DataLength, Serial, showDecodedMessage(), fl::third_party::Mpeg1Config::SingleFrame, fl::vector_basic::size(), fl::third_party::Mpeg1Config::skipAudio, fl::Success, TARGET_FPS, and fl::third_party::Mpeg1Config::targetFps.

Referenced by loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: