This program plays QuickTime movies on GR-Peach
Dependencies: AsciiFont GR-PEACH_video GraphicsFramework LCD_shield_config R_BSP TLV320_RBSP mbed-rtos mbed
Requirements
- GR-Peach
- GR-Peach Audio Camera Shield or I²S compatible audio DAC
- GR-Peach LCD Shield
- USB memory stick
How to play movie files
- Encode movie files
encode movies with ffmpeg
$ ffmpeg -i <input -ar 44100 -acodec pcm_s16le -s 480x270 -vcodec mjpeg -q:v 3 -movflags faststart -threads 4 -vf fps=30 <output>.mov
- Copy movies to the root directory of USB memory
- Build and upload this program
- Run it
Diff: MovPlayer.hpp
- Revision:
- 0:d0f130e27d32
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MovPlayer.hpp Fri Mar 10 11:30:02 2017 +0000 @@ -0,0 +1,46 @@ +#ifndef __MovPlayer__ +#define __MovPlayer__ + +#include "rtos.h" +#include "LCD.hpp" +#include "R_BSP_Ssif.h" +#include "MovFile.hpp" +#include "CppStandardHelper.hpp" + +class MovPlayer { +public: + static constexpr int BufferLength = 20; + typedef mbed::Callback<int32_t (void * const, uint32_t, const rbsp_data_conf_t *)> AudioCallback; + +private: + struct VideoBuffer { + char MBED_ALIGN(0x20) buf[65535]; + }; + struct AudioBuffer { + char MBED_ALIGN(4) buf[0x1B90]; + uint32_t size; + }; + static VideoBuffer videoBuf[BufferLength]; + static AudioBuffer __attribute__((section("NC_BSS"))) audioBuf[BufferLength]; + static MovPlayer singleton; + static unsigned char audioThreadStack[DEFAULT_STACK_SIZE]; + rtos::Thread audioThread; + rtos::RtosTimer frameTimer; + rtos::Semaphore frameSemaphore; + rtos::Queue<VideoBuffer, BufferLength - 2> videoQueue; + MovFile *mov; + AudioCallback output; + volatile uint32_t queueTimeout; + MovPlayer(); + void frameTimerCallback(); + void audioProcessor(); + +public: + static MovPlayer *defaultPlayer() { + return &singleton; + } + void play(MovFile *mov, LCD *lcd, AudioCallback callback); +}; + +#endif +