Unverified Commit 84e97632 authored by Wolle's avatar Wolle Committed by GitHub

peparations for RTSP

parent 6f82d6d5
......@@ -2,7 +2,7 @@
* Audio.cpp
*
* Created on: Oct 26,2018
* Updated on: Aug 29b,2021
* Updated on: Aug 30,2021
* Author: Wolle (schreibfaul1)
*
*/
......@@ -289,6 +289,7 @@ void Audio::setDefaults() {
m_f_loop = false; // Set if audio file should loop
m_f_unsync = false; // set within ID3 tag but not used
m_f_exthdr = false; // ID3 extended header
m_f_rtsp = false; // RTSP (m3u8)stream
m_codec = CODEC_NONE;
m_playlistFormat = FORMAT_NONE;
......@@ -359,12 +360,13 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) {
}
// Is it a playlist?
if(endsWith(host, ".m3u")) {m_playlistFormat = FORMAT_M3U; m_datamode = AUDIO_PLAYLISTINIT;}
if(endsWith(host, ".pls")) {m_playlistFormat = FORMAT_PLS; m_datamode = AUDIO_PLAYLISTINIT;}
if(endsWith(host, ".asx")) {m_playlistFormat = FORMAT_ASX; m_datamode = AUDIO_PLAYLISTINIT;}
if(endsWith(host, ".m3u" )) {m_playlistFormat = FORMAT_M3U; m_datamode = AUDIO_PLAYLISTINIT;}
if(endsWith(host, ".pls" )) {m_playlistFormat = FORMAT_PLS; m_datamode = AUDIO_PLAYLISTINIT;}
if(endsWith(host, ".asx" )) {m_playlistFormat = FORMAT_ASX; m_datamode = AUDIO_PLAYLISTINIT;}
// if url ...=asx www.fantasyfoxradio.de/infusions/gr_radiostatus_panel/gr_radiostatus_player.php?id=2&p=asx
if(endsWith(host, "=asx")) {m_playlistFormat = FORMAT_ASX; m_datamode = AUDIO_PLAYLISTINIT;}
if(endsWith(host, "=pls")) {m_playlistFormat = FORMAT_PLS; m_datamode = AUDIO_PLAYLISTINIT;}
if(endsWith(host, "=asx" )) {m_playlistFormat = FORMAT_ASX; m_datamode = AUDIO_PLAYLISTINIT;}
if(endsWith(host, "=pls" )) {m_playlistFormat = FORMAT_PLS; m_datamode = AUDIO_PLAYLISTINIT;}
if(endsWith(host, ".m3u8")) {m_playlistFormat = FORMAT_M3U8; m_datamode = AUDIO_PLAYLISTINIT;}
// In the URL there may be an extension, like noisefm.ru:8000/play.m3u&t=.m3u
pos_slash = indexOf(host, "/", 0);
......@@ -423,7 +425,8 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) {
sprintf(chbuf, "Connected to server in %u ms", dt);
if(audio_info) audio_info(chbuf);
memcpy(m_lastHost, host, strlen(host) + 1); // Remember the current s_host
strcpy(m_lastHost, "http://");
memcpy(m_lastHost + 7, host, strlen(host) + 1); // Remember the current s_host
trim(m_lastHost);
m_f_running = true;
if(hostwoext) free(hostwoext);
......@@ -443,7 +446,9 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) {
uint32_t dt = millis() - t;
sprintf(chbuf, "SSL has been established in %u ms, free Heap: %u bytes", dt, ESP.getFreeHeap());
if(audio_info) audio_info(chbuf);
memcpy(m_lastHost, host, strlen(host) + 1); // Remember the current s_host
strcpy(m_lastHost, "https://");
memcpy(m_lastHost + 8, host, strlen(host) + 1); // Remember the current s_host
m_f_running = true;
if(hostwoext) free(hostwoext);
if(extension) free(extension);
......@@ -2371,8 +2376,34 @@ void Audio::processPlayListData() {
if(f_end) { //we have both StationName and StationURL
connecttohost(m_lastHost); // Connect to it
}
return;
} //asx
return;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(m_playlistFormat == FORMAT_M3U8) {
pos = indexOf(pl, "nimblesessionid=", 0); // we have a nimbleserver
if(pos > 0){
uint64_t nimbleseSessionId = atoi(pl + pos + 16);
log_i("nimbesessionid=%d", nimbleseSessionId);
uint8_t pos1 = 8; // assume http
if(m_f_ssl) pos1++; // is https
int pos2 = indexOf(pl, "/", pos1);
if(pos2 > pos1){
memcpy(&m_lastHost[pos1 + pos2], pl, strlen(pl));
log_i("%s", m_lastHost);
m_f_rtsp = true;
// todo
// establish UDP via werserver
// send DESCRIBE to get the contentType
// send SETUP
// send PLAY
// send TEARDOWN to terminate the session
}
}
if(f_end)connecttohost(m_lastHost);
return;
}
} // end AUDIO_PLAYLISTDATA
}
//---------------------------------------------------------------------------------------------------------------------
......
......@@ -321,7 +321,7 @@ private:
enum : int { EXTERNAL_I2S = 0, INTERNAL_DAC = 1, INTERNAL_PDM = 2 };
enum : int { CODEC_NONE, CODEC_WAV, CODEC_MP3, CODEC_AAC, CODEC_M4A, CODEC_FLAC, CODEC_OGG,
CODEC_OGG_FLAC, CODEC_OGG_OPUS};
enum : int { FORMAT_NONE = 0, FORMAT_M3U = 1, FORMAT_PLS = 2, FORMAT_ASX = 3};
enum : int { FORMAT_NONE = 0, FORMAT_M3U = 1, FORMAT_PLS = 2, FORMAT_ASX = 3, FORMAT_M3U8 = 4};
enum : int { AUDIO_NONE, AUDIO_HEADER, AUDIO_DATA,
AUDIO_PLAYLISTINIT, AUDIO_PLAYLISTHEADER, AUDIO_PLAYLISTDATA};
enum : int { FLAC_BEGIN = 0, FLAC_MAGIC = 1, FLAC_MBH =2, FLAC_SINFO = 3, FLAC_PADDING = 4, FLAC_APP = 5,
......@@ -407,6 +407,7 @@ private:
bool m_f_loop = false; // Set if audio file should loop
bool m_f_forceMono = false; // if true stereo -> mono
bool m_f_internalDAC = false; // false: output vis I2S, true output via internal DAC
bool m_f_rtsp = false; // set if RTSP is used (m3u8 stream)
i2s_dac_mode_t m_f_channelEnabled = I2S_DAC_CHANNEL_LEFT_EN; // internal DAC on GPIO26 for M5StickC/Plus
uint32_t m_audioFileDuration = 0;
float m_audioCurrentTime = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment