Skip to content

Commit bfa95b5

Browse files
committed
Chain ADTS and MTS
1 parent fbc9e89 commit bfa95b5

File tree

2 files changed

+58
-4
lines changed

2 files changed

+58
-4
lines changed

src/AudioTools/AudioCodecs/CodecADTS.h

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class ADTSParser {
5959
header.num_rawdata_blocks = (hdr[6]) & 0b11;
6060

6161
LOGD("id:%d layer:%d profile:%d freq:%d channel:%d frame_length:%d",
62-
header.id, header.layer, header.profile, getSampleRate(), header.channel_cfg,
63-
header.frame_length);
62+
header.id, header.layer, header.profile, getSampleRate(),
63+
header.channel_cfg, header.frame_length);
6464

6565
// check
6666
is_valid = check();
@@ -71,8 +71,8 @@ class ADTSParser {
7171

7272
void log() {
7373
LOGI("%s id:%d layer:%d profile:%d freq:%d channel:%d frame_length:%d",
74-
is_valid ? "+" : "-", header.id, header.layer, header.profile, getSampleRate(),
75-
header.channel_cfg, header.frame_length);
74+
is_valid ? "+" : "-", header.id, header.layer, header.profile,
75+
getSampleRate(), header.channel_cfg, header.frame_length);
7676
}
7777

7878
int getSampleRate() {
@@ -210,6 +210,33 @@ class ADTSDecoder : public AudioDecoder {
210210
/// Defines the parse buffer size: default is 1024
211211
void setParseBufferSize(int size) { buffer.resize(size); }
212212

213+
/// Defines where the decoded result is written to
214+
virtual void setOutput(AudioStream &out_stream) {
215+
if (p_dec) {
216+
p_dec->setOutput(out_stream);
217+
} else {
218+
AudioDecoder::setOutput(out_stream);
219+
}
220+
}
221+
222+
/// Defines where the decoded result is written to
223+
virtual void setOutput(AudioOutput &out_stream) {
224+
if (p_dec) {
225+
p_dec->setOutput(out_stream);
226+
} else {
227+
AudioDecoder::setOutput(out_stream);
228+
}
229+
}
230+
231+
/// Defines where the decoded result is written to
232+
virtual void setOutput(Print &out_stream) override {
233+
if (p_dec) {
234+
p_dec->setOutput(out_stream);
235+
} else {
236+
AudioDecoder::setOutput(out_stream);
237+
}
238+
}
239+
213240
protected:
214241
SingleBuffer<uint8_t> buffer{DEFAULT_BUFFER_SIZE};
215242
SingleBuffer<uint8_t> out_buffer;

src/AudioTools/AudioCodecs/CodecMTS.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,33 @@ class MTSDecoder : public AudioDecoder {
163163
}
164164
return false;
165165
}
166+
167+
/// Defines where the decoded result is written to
168+
virtual void setOutput(AudioStream &out_stream) {
169+
if (p_dec) {
170+
p_dec->setOutput(out_stream);
171+
} else {
172+
AudioDecoder::setOutput(out_stream);
173+
}
174+
}
175+
176+
/// Defines where the decoded result is written to
177+
virtual void setOutput(AudioOutput &out_stream) {
178+
if (p_dec) {
179+
p_dec->setOutput(out_stream);
180+
} else {
181+
AudioDecoder::setOutput(out_stream);
182+
}
183+
}
184+
185+
/// Defines where the decoded result is written to
186+
virtual void setOutput(Print &out_stream) override {
187+
if (p_dec) {
188+
p_dec->setOutput(out_stream);
189+
} else {
190+
AudioDecoder::setOutput(out_stream);
191+
}
192+
}
166193

167194
protected:
168195
bool is_active = false;

0 commit comments

Comments
 (0)