|
3 | 3 | * |
4 | 4 | * Created on: Oct 26.2018 |
5 | 5 | * |
6 | | - * Version 2.0.5c |
7 | | - * Updated on: Jul 31.2022 |
| 6 | + * Version 2.0.5d |
| 7 | + * Updated on: Aug 01.2022 |
8 | 8 | * Author: Wolle (schreibfaul1) |
9 | 9 | * |
10 | 10 | */ |
@@ -303,6 +303,7 @@ void Audio::setDefaults() { |
303 | 303 | if(m_m3u8_lastEntry) {free(m_m3u8_lastEntry); m_m3u8_lastEntry = NULL;} // free if stream is not m3u8 |
304 | 304 | vector_clear_and_shrink(m_playlistURL); |
305 | 305 | vector_clear_and_shrink(m_playlistContent); |
| 306 | + m_hashQueue.clear(); m_hashQueue.shrink_to_fit(); // uint32_t vector |
306 | 307 | client.stop(); |
307 | 308 | client.flush(); // release memory |
308 | 309 | clientsecure.stop(); |
@@ -582,6 +583,7 @@ bool Audio::httpPrint(const char* host) { |
582 | 583 |
|
583 | 584 | setDatamode(HTTP_RESPONSE_HEADER); // Handle header |
584 | 585 | m_streamType = ST_WEBSTREAM; |
| 586 | + m_contentlength = 0; |
585 | 587 |
|
586 | 588 | if(hostwoext) {free(hostwoext); hostwoext = NULL;} |
587 | 589 | if(extension) {free(extension); extension = NULL;} |
@@ -2322,8 +2324,8 @@ void Audio::loop() { |
2322 | 2324 | } |
2323 | 2325 | break; |
2324 | 2326 | case AUDIO_DATA: |
2325 | | - if(m_f_ts) processWebStreamTS(); |
2326 | | - else processWebStreamHLS(); |
| 2327 | + if(m_f_ts) processWebStreamTS(); // aac or aacp with ts packets |
| 2328 | + else processWebStreamHLS(); // aac or aacp normal stream |
2327 | 2329 | if(f_noNewHost){ |
2328 | 2330 | m_f_continue = false; |
2329 | 2331 | if(timestamp2 < millis()) { |
@@ -2369,9 +2371,10 @@ bool Audio::readPlayListData() { |
2369 | 2371 | pl[pos] = _client->read(); |
2370 | 2372 | if(pl[pos] == '\n') {pl[pos] = '\0'; pos++; break;} |
2371 | 2373 | // if(pl[pos] == '&' ) {pl[pos] = '\0'; pos++; break;} |
2372 | | - if(pl[pos] == '\r') {pl[pos] = '\0'; pos++; break;} |
| 2374 | + if(pl[pos] == '\r') {pl[pos] = '\0'; pos++; continue;;} |
2373 | 2375 | pos++; |
2374 | | - if(pos == 510) {pl[pos] = '\0'; break;} |
| 2376 | + if(pos == 511){ pos--; ctl++; continue;} |
| 2377 | + if(pos == 510) {pl[pos] = '\0';} |
2375 | 2378 | } |
2376 | 2379 | ctl += pos; |
2377 | 2380 | if(pos) {pl[pos] = '\0'; break;} |
@@ -2629,26 +2632,30 @@ const char* Audio::parsePlaylist_M3U8(){ |
2629 | 2632 | tmp = strdup(m_playlistContent[i]); |
2630 | 2633 | } |
2631 | 2634 |
|
2632 | | - if(!m_m3u8_lastEntry){ // first init |
2633 | | - m_playlistURL.insert(m_playlistURL.begin(), strdup((const char*)(tmp))); |
2634 | | - m_m3u8_lastEntry = strdup(tmp); |
2635 | | - if(m_f_Log) log_i("insert %s", tmp); |
2636 | | - continue; |
2637 | | - } |
2638 | | - if(strcmp(tmp, m_m3u8_lastEntry) > 0 || strlen(tmp) > strlen(m_m3u8_lastEntry)){ // next sequence?, |
2639 | | - //strcmp: '2.aac'>'1.aac' or strlen '10.aac'>'9.aac' |
2640 | | - m_playlistURL.insert(m_playlistURL.begin(), strdup((const char*)(tmp))); |
2641 | | - if(m_m3u8_lastEntry){free(m_m3u8_lastEntry); m_m3u8_lastEntry = strdup(tmp);} |
2642 | | - assert(m_m3u8_lastEntry != tmp); // no free space in task? |
2643 | | - if(m_f_Log) log_i("insert %s", tmp); |
| 2635 | + uint32_t hash = simpleHash(tmp); |
| 2636 | + if(m_hashQueue.size() == 0){ |
| 2637 | + m_hashQueue.insert(m_hashQueue.begin(), hash); |
| 2638 | + m_playlistURL.insert(m_playlistURL.begin(), strdup(tmp)); |
2644 | 2639 | } |
2645 | 2640 | else{ |
2646 | | - if(m_f_Log) log_i("file already known %s", m_playlistContent[i]); |
| 2641 | + bool known = false; |
| 2642 | + for(int i = 0; i< m_hashQueue.size(); i++){ |
| 2643 | + if(hash == m_hashQueue[i]){ |
| 2644 | + if(m_f_Log) log_i("file already known %s", tmp); |
| 2645 | + known = true; |
| 2646 | + } |
| 2647 | + } |
| 2648 | + if(!known){ |
| 2649 | + m_hashQueue.insert(m_hashQueue.begin(), hash); |
| 2650 | + m_playlistURL.insert(m_playlistURL.begin(), strdup(tmp)); |
| 2651 | + } |
2647 | 2652 | } |
2648 | 2653 |
|
| 2654 | + if(m_hashQueue.size() > 20) m_hashQueue.pop_back(); |
| 2655 | + |
2649 | 2656 | if(tmp){free(tmp); tmp = NULL;} |
2650 | 2657 |
|
2651 | | - if(m_playlistURL.size() == 100){ |
| 2658 | + if(m_playlistURL.size() == 20){ |
2652 | 2659 | ESP_LOGD("", "can't stuff anymore"); |
2653 | 2660 | break; |
2654 | 2661 | } |
@@ -3445,10 +3452,10 @@ bool Audio::parseHttpResponseHeader() { // this is the response to a GET / reque |
3445 | 3452 | if(b < 0x20) continue; |
3446 | 3453 | rhl[pos] = b; |
3447 | 3454 | pos++; |
| 3455 | + if(pos == 511){pos = 510; continue;} |
3448 | 3456 | if(pos == 510){ |
3449 | 3457 | rhl[pos] = '\0'; |
3450 | 3458 | if(m_f_Log) log_i("responseHeaderline overflow"); |
3451 | | - break; |
3452 | 3459 | } |
3453 | 3460 | } // inner while |
3454 | 3461 |
|
|
0 commit comments