48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
|
|
#include "AudioTools.h"
|
||
|
|
#include "AudioTools/Disk/AudioSourceSTD.h"
|
||
|
|
#include "AudioTools/AudioCodecs/MP3Parser.h"
|
||
|
|
#include "AudioTools/Communication/RTSP/RTSPPlatformWiFi.h"
|
||
|
|
#include "AudioTools/Communication/RTSP.h"
|
||
|
|
|
||
|
|
int port = 8554;
|
||
|
|
|
||
|
|
// rtsp
|
||
|
|
MP3ParserEncoder enc; // mp3 packaging
|
||
|
|
RTSPFormatMP3 mp3format(enc); // RTSP mp3
|
||
|
|
MetaDataFilterEncoder filter(enc);
|
||
|
|
RTSPOutput<RTSPPlatformWiFi> rtsp_out(mp3format, filter);
|
||
|
|
AudioSourceSTD source("/home/pschatzmann/Music/Elvis Costello/Best Of/", ".mp3");
|
||
|
|
CopyDecoder decoder; // no decoding, just copy
|
||
|
|
AudioPlayer player(source, rtsp_out, decoder);
|
||
|
|
RTSPServer<RTSPPlatformWiFi> rtsp(rtsp_out.streamer(), port);
|
||
|
|
|
||
|
|
|
||
|
|
void setup() {
|
||
|
|
Serial.begin(115200);
|
||
|
|
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||
|
|
|
||
|
|
// ffmpeg/ffplay expect the optional RFC 2250 4-byte MPEG-audio header on
|
||
|
|
// payload type 14 (VLC doesn't need it); without it every frame boundary
|
||
|
|
// is off by 4 bytes and decodes as garbage.
|
||
|
|
mp3format.setUseRfc2250Header(true);
|
||
|
|
|
||
|
|
// delay between mp3 files
|
||
|
|
source.setTimeoutAutoNext(1000);
|
||
|
|
|
||
|
|
// start the player
|
||
|
|
player.begin();
|
||
|
|
|
||
|
|
// Start Output Stream
|
||
|
|
rtsp_out.begin();
|
||
|
|
|
||
|
|
// Start Wifi & rtsp server
|
||
|
|
rtsp.begin();
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void loop() {
|
||
|
|
if (rtsp_out && rtsp) {
|
||
|
|
player.copy();
|
||
|
|
}
|
||
|
|
}
|