@@ -131,19 +131,24 @@ class ContainerMP4 : public AudioDecoder {
131
131
stream_atom = streamAtom;
132
132
}
133
133
134
+ // / starts the processing
134
135
void begin () override {
135
136
current_pos = 0 ;
136
137
assert (p_print!=nullptr );
137
138
decoder.setOutput (*p_print);
138
139
decoder.begin ();
140
+ is_active = true ;
139
141
}
140
142
141
- void end () override { decoder.end (); }
142
-
143
- operator bool () override { return true ; }
143
+ // / ends the processing
144
+ void end () override {
145
+ decoder.end ();
146
+ is_active = false ;
147
+ }
144
148
149
+ operator bool () override { return is_active; }
145
150
146
- // / writes the next atom
151
+ // / writes the data to be parsed into atoms
147
152
size_t write (const void *in, size_t length) override {
148
153
TRACED ();
149
154
uint8_t *data = (uint8_t *)in;
@@ -183,17 +188,15 @@ class ContainerMP4 : public AudioDecoder {
183
188
data_callback = cb;
184
189
}
185
190
186
- // / Defines the callback which is used to determine if an atom is a header
187
- // / atom
191
+ // / Defines the callback which is used to determine if an atom is a header atom
188
192
void setIsHeaderCallback (bool (*cb)(MP4Atom *atom, const uint8_t *data)) {
189
193
is_header_callback = cb;
190
194
}
191
195
192
196
// / Provides the content atom name which will be written incrementally
193
197
const char *streamAtom () { return stream_atom; }
194
198
195
- // / Checks if the indicated atom is a header atom: you can define your custom
196
- // / method with setIsHeaderCallback()
199
+ // / Checks if the indicated atom is a header atom: you can define your custom method with setIsHeaderCallback()
197
200
bool isHeader (MP4Atom *atom, const uint8_t *data) {
198
201
return is_header_callback (atom, data);
199
202
}
@@ -209,6 +212,7 @@ class ContainerMP4 : public AudioDecoder {
209
212
MP4ParseBuffer buffer{this };
210
213
int stream_out_open = 0 ;
211
214
bool is_sound = false ;
215
+ bool is_active = false ;
212
216
AACDecoderHelix decoder{false };
213
217
const char *stream_atom;
214
218
int current_pos = 0 ;
@@ -218,12 +222,12 @@ class ContainerMP4 : public AudioDecoder {
218
222
bool (*is_header_callback)(MP4Atom *atom,
219
223
const uint8_t *data) = default_is_header_callback;
220
224
221
- // / output of mdat to decoder;
225
+ // / output of audio mdat to helix decoder;
222
226
size_t decode (const uint8_t *data, size_t len) {
223
227
return decoder.write (data, len);
224
228
}
225
229
226
-
230
+ // / Defines the size of open data that will be written directly w/o parsing
227
231
void setStreamOutputSize (int size) { stream_out_open = size; }
228
232
229
233
// / Default logic to determine if a atom is a header
0 commit comments