Skip to content

Commit 018ff2e

Browse files
committed
ContainerMP4 commends
1 parent 79aa2e6 commit 018ff2e

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/AudioCodecs/ContainerMPEG4.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,24 @@ class ContainerMP4 : public AudioDecoder {
131131
stream_atom = streamAtom;
132132
}
133133

134+
/// starts the processing
134135
void begin() override {
135136
current_pos = 0;
136137
assert(p_print!=nullptr);
137138
decoder.setOutput(*p_print);
138139
decoder.begin();
140+
is_active = true;
139141
}
140142

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+
}
144148

149+
operator bool() override { return is_active; }
145150

146-
/// writes the next atom
151+
/// writes the data to be parsed into atoms
147152
size_t write(const void *in, size_t length) override {
148153
TRACED();
149154
uint8_t *data = (uint8_t *)in;
@@ -183,17 +188,15 @@ class ContainerMP4 : public AudioDecoder {
183188
data_callback = cb;
184189
}
185190

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
188192
void setIsHeaderCallback(bool (*cb)(MP4Atom *atom, const uint8_t *data)) {
189193
is_header_callback = cb;
190194
}
191195

192196
/// Provides the content atom name which will be written incrementally
193197
const char *streamAtom() { return stream_atom; }
194198

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()
197200
bool isHeader(MP4Atom *atom, const uint8_t *data) {
198201
return is_header_callback(atom, data);
199202
}
@@ -209,6 +212,7 @@ class ContainerMP4 : public AudioDecoder {
209212
MP4ParseBuffer buffer{this};
210213
int stream_out_open = 0;
211214
bool is_sound = false;
215+
bool is_active = false;
212216
AACDecoderHelix decoder{false};
213217
const char *stream_atom;
214218
int current_pos = 0;
@@ -218,12 +222,12 @@ class ContainerMP4 : public AudioDecoder {
218222
bool (*is_header_callback)(MP4Atom *atom,
219223
const uint8_t *data) = default_is_header_callback;
220224

221-
/// output of mdat to decoder;
225+
/// output of audio mdat to helix decoder;
222226
size_t decode(const uint8_t *data, size_t len) {
223227
return decoder.write(data, len);
224228
}
225229

226-
230+
/// Defines the size of open data that will be written directly w/o parsing
227231
void setStreamOutputSize(int size) { stream_out_open = size; }
228232

229233
/// Default logic to determine if a atom is a header

0 commit comments

Comments
 (0)