Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ESP32-audioI2S
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ESP32-audioI2S
Commits
dc137c5e
Unverified
Commit
dc137c5e
authored
Jun 23, 2023
by
Wolle
Committed by
GitHub
Jun 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
looking for audioitems if mp4a data behind audioblock
parent
669e61d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
src/Audio.cpp
src/Audio.cpp
+22
-3
No files found.
src/Audio.cpp
View file @
dc137c5e
...
...
@@ -5346,7 +5346,6 @@ void Audio::seek_m4a_ilst(){
size_t temp = strlen((const char*)data + offset);
if(temp > 254) temp = 254;
memcpy(value, (data + offset), temp);
log_w("value %s, temp %i", value, temp);
value[temp] = '\0';
m_chbuf[0] = '\0';
if(i == 0) sprintf(m_chbuf, "Title: %s", value);
...
...
@@ -5402,7 +5401,6 @@ void Audio::seek_m4a_stsz(){
char temp[5] = {0};
audiofile.seek(startPos);
audiofile.readBytes(temp, 4);
log_w("be1");
atom.size = bigEndian((uint8_t*)temp, 4);
if(!atom.size) atom.size = 4; // has no data, length is 0
audiofile.readBytes(atom.name, 4);
...
...
@@ -5412,6 +5410,8 @@ void Audio::seek_m4a_stsz(){
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uint32_t stsdPos = 0;
uint16_t stsdSize = 0;
boolean found = false;
uint32_t seekpos = 0;
uint32_t filesize = getFileSize();
...
...
@@ -5431,6 +5431,10 @@ void Audio::seek_m4a_stsz(){
seekpos += tmp.size;
if(strcmp(tmp.name, name[i]) == 0) {memcpy((void*)&at, (void*)&tmp, sizeof(tmp)); found = true;}
if(m_f_Log) log_i("name %s pos %d, size %d", tmp.name, tmp.pos, tmp.size);
if(strcmp(tmp.name, "stsd") == 0){ // in stsd we can found mp4a atom that contains the audioitems
stsdPos = tmp.pos;
stsdSize = tmp.size;
}
}
if(!found) goto noSuccess;
seekpos = at.pos + 8; // 4 bytes size + 4 bytes name
...
...
@@ -5439,10 +5443,25 @@ void Audio::seek_m4a_stsz(){
seekpos += 8; // 1 byte version + 3 bytes flags + 4 bytes sample size
audiofile.seek(seekpos);
audiofile.readBytes(noe, 4); //number of entries
log_w("be1");
m_stsz_numEntries = bigEndian((uint8_t*)noe, 4);
if(m_f_Log) log_i("number of entries in stsz: %d", m_stsz_numEntries);
m_stsz_position = seekpos + 4;
if(stsdSize){
audiofile.seek(stsdPos);
uint8_t data[stsdSize];
audiofile.readBytes((char*)data, stsdSize);
int offset = specialIndexOf(data, "mp4a", stsdSize);
if(offset >0){
int channel = bigEndian(data + offset + 20, 2); // audio parameter must be set before starting
int bps = bigEndian(data + offset + 22, 2); // the aac decoder. There are RAW blocks only in m4a
int srate = bigEndian(data + offset + 26, 4); //
setBitsPerSample(bps);
setChannels(channel);
setSampleRate(srate);
setBitrate(bps * channel * srate);
AUDIO_INFO("ch; %i, bps: %i, sr: %i", channel, bps, srate);
}
}
audiofile.seek(0);
return;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment