Skip to content

Commit ef96b1f

Browse files
committed
ContainerMP4 add codec
1 parent 09773b0 commit ef96b1f

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/AudioCodecs/ContainerMP4.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,28 @@ class ContainerMP4 : public AudioDecoder {
131131
stream_atom = streamAtom;
132132
}
133133

134+
ContainerMP4(AudioDecoder &decoder, const char *streamAtom = "mdat") {
135+
stream_atom = streamAtom;
136+
p_decoder = &decoder;
137+
}
138+
139+
ContainerMP4(AudioDecoder *decoder, const char *streamAtom = "mdat") {
140+
stream_atom = streamAtom;
141+
p_decoder = decoder;
142+
}
143+
134144
/// starts the processing
135145
void begin() override {
136146
current_pos = 0;
137147
assert(p_print!=nullptr);
138-
decoder.setOutput(*p_print);
139-
decoder.begin();
148+
p_decoder->setOutput(*p_print);
149+
p_decoder->begin();
140150
is_active = true;
141151
}
142152

143153
/// ends the processing
144154
void end() override {
145-
decoder.end();
155+
p_decoder->end();
146156
is_active = false;
147157
}
148158

@@ -213,7 +223,8 @@ class ContainerMP4 : public AudioDecoder {
213223
int stream_out_open = 0;
214224
bool is_sound = false;
215225
bool is_active = false;
216-
AACDecoderHelix decoder{false};
226+
AACDecoderHelix aac_decoder{false};
227+
AudioDecoder* p_decoder = &aac_decoder;
217228
const char *stream_atom;
218229
int current_pos = 0;
219230
const char *current_atom = nullptr;
@@ -224,7 +235,7 @@ class ContainerMP4 : public AudioDecoder {
224235

225236
/// output of audio mdat to helix decoder;
226237
size_t decode(const uint8_t *data, size_t len) {
227-
return decoder.write(data, len);
238+
return p_decoder->write(data, len);
228239
}
229240

230241
/// Defines the size of open data that will be written directly w/o parsing
@@ -273,7 +284,7 @@ class ContainerMP4 : public AudioDecoder {
273284
info.logInfo();
274285
container.setAudioInfo(info);
275286
// init raw output
276-
container.decoder.setAudioInfo(info);
287+
container.p_decoder->setAudioInfo(info);
277288
}
278289

279290
/// output of mdat to decoder;
@@ -303,6 +314,9 @@ void MP4Atom::setHeader(uint8_t *data, int len) {
303314
total_size = ntohl(*p_size);
304315
data_size = total_size - 8;
305316
memcpy(atom, data + 4, 4);
317+
if (total_size==1){
318+
319+
}
306320

307321
is_header_atom = container->isHeader(this, data);
308322
}

tests-cmake/codec/container-m4a/container-m4a.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
#include "AudioTools.h"
1212
#include "AudioCodecs/ContainerMP4.h"
1313
//#include "AudioLibs/StdioStream.h"
14-
15-
auto file = SD.open("/home/pschatzmann/Development/Mp4Parser/sample-1.m4a", FILE_READ);
14+
//const char *file = "/home/pschatzmann/Development/Mp4Parser/sample-1.m4a";
15+
const char* file_str = "/home/pschatzmann/Downloads/test.m4a";
16+
auto file = SD.open(file_str, FILE_READ);
1617
CsvOutput<int16_t> out(Serial);
1718
ContainerMP4 mp4;
1819
EncodedAudioStream codec(&out, &mp4);

0 commit comments

Comments
 (0)