@@ -14,28 +14,28 @@ namespace audio_tools {
14
14
*/
15
15
class MP4ParserIncremental : public MP4Parser {
16
16
public:
17
- using DataCallback = std::function<void (Box&, const uint8_t * data, size_t len,
17
+ using IncrementalDataCallback = std::function<void (Box&, const uint8_t * data, size_t len,
18
18
bool is_final, void * ref)>;
19
19
20
20
/* *
21
21
* @brief Defines the callback for all incremental box data.
22
22
* @param cb Callback function for all boxes.
23
23
*/
24
- void setIncrementalDataCallback (DataCallback cb) { data_callback = cb; }
24
+ void setIncrementalDataCallback (IncrementalDataCallback cb) { incremental_data_callback = cb; }
25
25
26
26
/* *
27
27
* @brief Defines a specific callback for incremental data of a box type.
28
28
* @param type 4-character box type (e.g. "mdat").
29
29
* @param cb Callback function for this box type.
30
30
* @param callGeneric If true, the generic callback will also be called after the type-specific callback.
31
31
*/
32
- void setIncrementalDataCallback (const char * type, DataCallback cb, bool callGeneric = true ) {
32
+ void setIncrementalDataCallback (const char * type, IncrementalDataCallback cb, bool callGeneric = true ) {
33
33
CallbackEntry entry;
34
34
strncpy (entry.type , type, 4 );
35
35
entry.type [4 ] = ' \0 ' ; // Ensure null-termination
36
36
entry.cb = cb;
37
37
entry.callGeneric = callGeneric;
38
- data_callbacks .push_back (entry);
38
+ incremental_data_callbacks .push_back (entry);
39
39
}
40
40
41
41
/* *
@@ -59,12 +59,12 @@ class MP4ParserIncremental : public MP4Parser {
59
59
*/
60
60
struct CallbackEntry {
61
61
char type[5 ]; // /< 4-character box type
62
- DataCallback cb; // /< Callback function
62
+ IncrementalDataCallback cb; // /< Callback function
63
63
bool callGeneric = true ; // /< If true, also call the generic callback after this one
64
64
};
65
65
66
- DataCallback data_callback = defaultDataCallback ; // /< Generic incremental data callback
67
- Vector<CallbackEntry> data_callbacks ; // /< List of type-specific incremental data callbacks
66
+ IncrementalDataCallback incremental_data_callback = defaultIncrementalDataCallback ; // /< Generic incremental data callback
67
+ Vector<CallbackEntry> incremental_data_callbacks ; // /< List of type-specific incremental data callbacks
68
68
bool box_in_progress = false ; // /< True if currently parsing a box incrementally
69
69
size_t box_bytes_received = 0 ; // /< Bytes received so far for the current box
70
70
size_t box_bytes_expected = 0 ; // /< Total expected bytes for the current box
@@ -80,7 +80,7 @@ class MP4ParserIncremental : public MP4Parser {
80
80
* @param is_final True if this is the last chunk for this box.
81
81
* @param ref Optional reference pointer.
82
82
*/
83
- static void defaultDataCallback (Box& box, const uint8_t * data, size_t len,
83
+ static void defaultIncrementalDataCallback (Box& box, const uint8_t * data, size_t len,
84
84
bool is_final, void * ref) {
85
85
char space[box.level * 2 + 1 ];
86
86
memset (space, ' ' , box.level * 2 );
@@ -221,7 +221,7 @@ class MP4ParserIncremental : public MP4Parser {
221
221
222
222
if (available_payload > 0 ) {
223
223
box_bytes_received += available_payload;
224
- if (data_callback ) {
224
+ if (incremental_data_callback ) {
225
225
strcpy (box.type , box_type);
226
226
box.id = ++this ->box .id ;
227
227
box.data = nullptr ;
@@ -239,7 +239,7 @@ class MP4ParserIncremental : public MP4Parser {
239
239
// incremental callback
240
240
box.size = box_bytes_expected;
241
241
box.data_size = available_payload;
242
- processDataCallback (box, p + headerSize, available_payload, false , ref);
242
+ processIncrementalDataCallback (box, p + headerSize, available_payload, false , ref);
243
243
}
244
244
}
245
245
fileOffset += (bufferSize - buffer.available ());
@@ -255,7 +255,7 @@ class MP4ParserIncremental : public MP4Parser {
255
255
size_t to_read = std::min ((size_t )box_bytes_expected - box_bytes_received,
256
256
(size_t )buffer.available ());
257
257
if (to_read == 0 ) return false ;
258
- if (data_callback ) {
258
+ if (incremental_data_callback ) {
259
259
strcpy (box.type , box_type);
260
260
box.id = ++this ->box .id ;
261
261
box.data = nullptr ;
@@ -265,7 +265,7 @@ class MP4ParserIncremental : public MP4Parser {
265
265
box.offset = box_offset + box_bytes_received;
266
266
box.is_complete = (box_bytes_received + to_read == box_bytes_expected);
267
267
box.is_container = false ;
268
- processDataCallback (box, buffer.data (), to_read, box.is_complete , ref);
268
+ processIncrementalDataCallback (box, buffer.data (), to_read, box.is_complete , ref);
269
269
}
270
270
box_bytes_received += to_read;
271
271
fileOffset += to_read;
@@ -286,20 +286,20 @@ class MP4ParserIncremental : public MP4Parser {
286
286
* @param is_final True if this is the last chunk for this box.
287
287
* @param ref Optional reference pointer.
288
288
*/
289
- void processDataCallback (Box& box, const uint8_t * data, size_t len,
289
+ void processIncrementalDataCallback (Box& box, const uint8_t * data, size_t len,
290
290
bool is_final, void * ref) {
291
291
bool is_called = false ;
292
292
bool call_generic = true ;
293
- for (auto & entry : data_callbacks ) {
293
+ for (auto & entry : incremental_data_callbacks ) {
294
294
if (StrView (entry.type ) == box.type ) {
295
295
entry.cb (box, data, len, is_final, ref);
296
296
is_called = true ;
297
297
if (!entry.callGeneric ) call_generic = false ;
298
298
break ;
299
299
}
300
300
}
301
- if ((!is_called || call_generic) && data_callback ) {
302
- data_callback (box, data, len, is_final, ref);
301
+ if ((!is_called || call_generic) && incremental_data_callback ) {
302
+ incremental_data_callback (box, data, len, is_final, ref);
303
303
}
304
304
}
305
305
0 commit comments