Unverified Commit 8e0b7406 authored by Wolle's avatar Wolle Committed by GitHub

memory for var tmp was too small

parent 4253190d
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
* *
* Created on: Oct 26.2018 * Created on: Oct 26.2018
* *
* Version 3.0.7m * Version 3.0.7n
* Updated on: Oct 20.2023 * Updated on: Oct 21.2023
* Author: Wolle (schreibfaul1) * Author: Wolle (schreibfaul1)
* *
*/ */
...@@ -2496,13 +2496,13 @@ const char* Audio::parsePlaylist_M3U8() { ...@@ -2496,13 +2496,13 @@ const char* Audio::parsePlaylist_M3U8() {
// http://n3fa-e2.revma.ihrhls.com/zc7729/63_sdtszizjcjbz02/main/163374039.aac // http://n3fa-e2.revma.ihrhls.com/zc7729/63_sdtszizjcjbz02/main/163374039.aac
static uint64_t xMedSeq = 0; static uint64_t xMedSeq = 0;
static boolean f_medSeq_found = false; static boolean f_mediaSeq_found = false;
boolean f_EXTINF_found = false; boolean f_EXTINF_found = false;
char llasc[21]; // uint64_t max = 18,446,744,073,709,551,615 thats 20 chars + \0 char llasc[21]; // uint64_t max = 18,446,744,073,709,551,615 thats 20 chars + \0
if(m_f_firstM3U8call){ if(m_f_firstM3U8call){
m_f_firstM3U8call = false; m_f_firstM3U8call = false;
xMedSeq = 0; xMedSeq = 0;
f_medSeq_found = false; f_mediaSeq_found = false;
} }
uint8_t lines = m_playlistContent.size(); uint8_t lines = m_playlistContent.size();
...@@ -2525,22 +2525,17 @@ const char* Audio::parsePlaylist_M3U8() { ...@@ -2525,22 +2525,17 @@ const char* Audio::parsePlaylist_M3U8() {
if (startsWith(m_playlistContent[i], "#EXT-X-ALLOW-CACHE:")) continue; if (startsWith(m_playlistContent[i], "#EXT-X-ALLOW-CACHE:")) continue;
if (startsWith(m_playlistContent[i], "##")) continue; if (startsWith(m_playlistContent[i], "##")) continue;
if (startsWith(m_playlistContent[i], "#EXT-X-INDEPENDENT-SEGMENTS")) continue; if (startsWith(m_playlistContent[i], "#EXT-X-INDEPENDENT-SEGMENTS")) continue;
// (startsWith(m_playlistContent[i],#EXT-X-PROGRAM-DATE-TIME:)) continue; if (startsWith(m_playlistContent[i], "#EXT-X-PROGRAM-DATE-TIME:")) continue;
if(!f_medSeq_found){ if(!f_mediaSeq_found){
xMedSeq = m3u8_findMediaSeqInURL(); xMedSeq = m3u8_findMediaSeqInURL();
if(xMedSeq > 0) f_medSeq_found = true; if(xMedSeq > 0) f_mediaSeq_found = true;
if(xMedSeq == 0){ if(xMedSeq == 0){
log_e("X MEDIA SEQUENCE NUMBER not found"); log_e("X MEDIA SEQUENCE NUMBER not found");
return NULL; return NULL;
} }
} }
// if(startsWith(m_playlistContent[i], "#EXT-X-TARGETDURATION:")) {
// m_m3u8_targetDuration = atoi(m_playlistContent[i] + 22);
// if(m_f_Log) log_i("m_m3u8_targetDuration %d", m_m3u8_targetDuration);
// }
if(startsWith(m_playlistContent[i], "#EXTINF")) { if(startsWith(m_playlistContent[i], "#EXTINF")) {
f_EXTINF_found = true; f_EXTINF_found = true;
if(STfromEXTINF(m_playlistContent[i])) {showstreamtitle(m_chbuf);} if(STfromEXTINF(m_playlistContent[i])) {showstreamtitle(m_chbuf);}
...@@ -2552,31 +2547,28 @@ const char* Audio::parsePlaylist_M3U8() { ...@@ -2552,31 +2547,28 @@ const char* Audio::parsePlaylist_M3U8() {
// http://livees.com/prog_index.m3u8 and prog_index48347.aac --> // http://livees.com/prog_index.m3u8 and prog_index48347.aac -->
// http://livees.com/prog_index48347.aac // http://livees.com/prog_index48347.aac
if(m_lastM3U8host != 0){ if(m_lastM3U8host != 0){
tmp = strdup(m_lastM3U8host); tmp = (char*) malloc(strlen(m_lastM3U8host) + strlen(m_playlistContent[i]) + 1);
strcpy(tmp, m_lastM3U8host);
} }
else{ else{
tmp = strdup(m_lastHost); tmp = (char*) malloc(strlen(m_lastHost) + strlen(m_playlistContent[i]) + 1);
strcpy(tmp, m_lastHost);
} }
int idx = lastIndexOf(tmp, "/"); int idx = lastIndexOf(tmp, "/");
strcpy(tmp + idx + 1, m_playlistContent[i]); strcpy(tmp + idx + 1, m_playlistContent[i]);
} }
else { tmp = strdup(m_playlistContent[i]); } else { tmp = strdup(m_playlistContent[i]); }
lltoa(xMedSeq, llasc, 10); if(f_mediaSeq_found){
if(indexOf(tmp, llasc) > 0){ lltoa(xMedSeq, llasc, 10);
m_playlistURL.insert(m_playlistURL.begin(), strdup(tmp)); if(indexOf(tmp, llasc) > 0){
xMedSeq++; m_playlistURL.insert(m_playlistURL.begin(), strdup(tmp));
xMedSeq++;
}
} }
if(tmp) { if(tmp) {free(tmp); tmp = NULL;}
free(tmp);
tmp = NULL;
}
// if(m_playlistURL.size() == 20) {
// ESP_LOGD("", "can't stuff anymore");
// break;
// }
continue; continue;
} }
} }
...@@ -2598,41 +2590,42 @@ const char* Audio::parsePlaylist_M3U8() { ...@@ -2598,41 +2590,42 @@ const char* Audio::parsePlaylist_M3U8() {
} }
if(m_f_Log) log_i("now playing %s", m_playlistBuff); if(m_f_Log) log_i("now playing %s", m_playlistBuff);
if(endsWith(m_playlistBuff, "ts")) m_f_ts = true; if(endsWith(m_playlistBuff, "ts")) m_f_ts = true;
if(indexOf(m_playlistBuff, ".ts?") > 0) m_f_ts = true;
return m_playlistBuff; return m_playlistBuff;
} }
else { else {
if(f_EXTINF_found){ if(f_EXTINF_found){
uint64_t mediaSeq = m3u8_findMediaSeqInURL(); if(f_mediaSeq_found){
if(xMedSeq == 0) {log_e("xMediaSequence not found"); connecttohost(m_lastHost);} uint64_t mediaSeq = m3u8_findMediaSeqInURL();
if(mediaSeq < xMedSeq){ if(xMedSeq == 0) {log_e("xMediaSequence not found"); connecttohost(m_lastHost);}
uint64_t diff = xMedSeq - mediaSeq; if(mediaSeq < xMedSeq){
if(diff < 10) {;} uint64_t diff = xMedSeq - mediaSeq;
else { if(diff < 10) {;}
if(m_playlistContent.size() > 0){ else {
for(int j = 0; j < lines; j++){ if(m_playlistContent.size() > 0){
log_w("lines %i, %s",lines, m_playlistContent[j]); for(int j = 0; j < lines; j++){
log_w("lines %i, %s",lines, m_playlistContent[j]);
}
} }
} else{;}
else{;}
if(m_playlistURL.size() > 0){ if(m_playlistURL.size() > 0){
for(int j = 0; j < m_playlistURL.size(); j++){ for(int j = 0; j < m_playlistURL.size(); j++){
log_w("m_playlistURL lines %i, %s",j, m_playlistURL[j]); log_w("m_playlistURL lines %i, %s",j, m_playlistURL[j]);
}
} }
} else{;}
else{;}
if(m_playlistURL.size() == 0) {connecttohost(m_lastHost);} if(m_playlistURL.size() == 0) {connecttohost(m_lastHost);}
}
} }
} else{
else{ log_e("err, %u packets lost from %u, to %u", mediaSeq - xMedSeq, xMedSeq, mediaSeq);
log_e("err, %u packets lost from %u, to %u", mediaSeq - xMedSeq, xMedSeq, mediaSeq); xMedSeq = mediaSeq;
xMedSeq = mediaSeq; }
} } // f_medSeq_found
} }
return NULL;
} }
return NULL; return NULL;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
...@@ -2756,10 +2749,10 @@ uint64_t Audio::m3u8_findMediaSeqInURL(){ // We have no clue what the media sequ ...@@ -2756,10 +2749,10 @@ uint64_t Audio::m3u8_findMediaSeqInURL(){ // We have no clue what the media sequ
b = a + 1; b = a + 1;
c = b + 1; c = b + 1;
lltoa(b, llasc, 10); lltoa(b, llasc, 10);
int16_t idx_b = indexOf(m_playlistContent[linesWithURL[1]], llasc); int16_t idx_b = indexOf(m_playlistContent[linesWithURL[1]], llasc, pos - 1);
lltoa(c, llasc, 10); lltoa(c, llasc, 10);
int16_t idx_c = indexOf(m_playlistContent[linesWithURL[2]], llasc); int16_t idx_c = indexOf(m_playlistContent[linesWithURL[2]], llasc, pos - 1);
if(idx_b > 0 && idx_c > 0){ if(idx_b > 0 && idx_c > 0 && idx_b - pos < 3 && idx_c - pos < 3){ // idx_b and idx_c must be positive and near pos
MediaSeq = a; MediaSeq = a;
AUDIO_INFO("media sequence number: %llu", MediaSeq); AUDIO_INFO("media sequence number: %llu", MediaSeq);
break; break;
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
* *
* Created on: Oct 28,2018 * Created on: Oct 28,2018
* *
* Version 3.0.7m * Version 3.0.7n
* Updated on: Oct 20.2023 * Updated on: Oct 21.2023
* Author: Wolle (schreibfaul1) * Author: Wolle (schreibfaul1)
*/ */
......
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