Unverified Commit ade460f9 authored by Wolle's avatar Wolle Committed by GitHub

add m4a atom 'isom'

parent d23a2471
......@@ -712,8 +712,51 @@ bool Audio::connecttoFS(fs::FS &fs, const char* path) {
}
//---------------------------------------------------------------------------------------------------------------------
bool Audio::connecttospeech(const char* speech, const char* lang){
log_e("GoogleTTS is no longer available due to restrictions");
return false;
setDefaults();
char host[] = "translate.google.com.vn";
char path[] = "/translate_tts";
uint16_t speechLen = strlen(speech);
uint16_t speechBuffLen = speechLen + 300;
memcpy(m_lastHost, speech, 256);
char* speechBuff = (char*)malloc(speechBuffLen);
if(!speechBuff) {log_e("out of memory"); return false;}
memcpy(speechBuff, speech, speechLen);
speechBuff[speechLen] = '\0';
urlencode(speechBuff, speechBuffLen);
char resp[strlen(speechBuff) + 200] = "";
strcat(resp, "GET ");
strcat(resp, path);
strcat(resp, "?ie=UTF-8&tl=");
strcat(resp, lang);
strcat(resp, "&client=tw-ob&q=");
strcat(resp, speechBuff);
strcat(resp, " HTTP/1.1\r\n");
strcat(resp, "Host: ");
strcat(resp, host);
strcat(resp, "\r\n");
strcat(resp, "User-Agent: Mozilla/5.0 \r\n");
strcat(resp, "Accept-Encoding: identity\r\n");
strcat(resp, "Accept: text/html\r\n");
strcat(resp, "Connection: close\r\n\r\n");
free(speechBuff);
_client = static_cast<WiFiClient*>(&client);
if(!_client->connect(host, 80)) {
log_e("Connection failed");
return false;
}
_client->print(resp);
m_f_webstream = true;
m_f_running = true;
m_f_ssl = false;
m_f_tts = true;
setDatamode(AUDIO_HEADER);
return true;
}
//---------------------------------------------------------------------------------------------------------------------
void Audio::urlencode(char* buff, uint16_t buffLen, bool spacesOnly) {
......@@ -1587,11 +1630,15 @@ int Audio::read_M4A_Header(uint8_t *data, size_t len) {
stopSong();
return -1;
}
if(specialIndexOf(data, "M4A ", 20) != 8) {
log_e("subtype 'MA4 ' expected, but found '%s '", (data + 8));
int m4a = specialIndexOf(data, "M4A ", 20);
int isom = specialIndexOf(data, "isom", 20);
if((m4a !=8) && (isom != 8)){
log_e("subtype 'MA4 ' or 'isom' expected, but found '%s '", (data + 8));
stopSong();
return -1;
}
m_controlCounter = M4A_CHK;
retvalue = atomsize;
headerSize = atomsize;
......
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