Skip to content

Commit a08dba1

Browse files
rbouqueauDenizUgur
andauthored
fix: tfra box parsing didn't allow to display all information (#543)
* fix: tfra box parsing didn't allow to display all information - see #541 * Create bumpy-rice-train.md * tidbits --------- Co-authored-by: Deniz Uğur <7467169+DenizUgur@users.noreply.github.com> Co-authored-by: DenizUgur <DenizUgur@users.noreply.github.com>
1 parent fdbdf11 commit a08dba1

2 files changed

Lines changed: 23 additions & 14 deletions

File tree

.changeset/bumpy-rice-train.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"mp4box": patch
3+
---
4+
5+
fix: tfra box parsing didn't allow to display all information

src/boxes/tfra.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { FullBox } from '#/box';
22
import type { MultiBufferStream } from '#/buffer';
3-
import type { SampleEntry } from './sampleentries/base';
3+
4+
class TfraEntry {
5+
time: number;
6+
moof_offset: number;
7+
traf_number: number;
8+
trun_number: number;
9+
sample_delta: number;
10+
}
411

512
export class tfraBox extends FullBox {
613
static override readonly fourcc = 'tfra' as const;
@@ -10,12 +17,7 @@ export class tfraBox extends FullBox {
1017
length_size_of_traf_num: number;
1118
length_size_of_trun_num: number;
1219
length_size_of_sample_num: number;
13-
entries: Array<SampleEntry>;
14-
time: number;
15-
moof_offset: number;
16-
traf_number: number;
17-
trun_number: number;
18-
sample_number: number;
20+
entries: Array<TfraEntry>;
1921

2022
parse(stream: MultiBufferStream) {
2123
this.parseFullHeader(stream);
@@ -28,16 +30,18 @@ export class tfraBox extends FullBox {
2830
this.entries = [];
2931
const number_of_entries = stream.readUint32();
3032
for (let i = 0; i < number_of_entries; i++) {
33+
const entry = new TfraEntry();
3134
if (this.version === 1) {
32-
this.time = stream.readUint64();
33-
this.moof_offset = stream.readUint64();
35+
entry.time = stream.readUint64();
36+
entry.moof_offset = stream.readUint64();
3437
} else {
35-
this.time = stream.readUint32();
36-
this.moof_offset = stream.readUint32();
38+
entry.time = stream.readUint32();
39+
entry.moof_offset = stream.readUint32();
3740
}
38-
this.traf_number = stream['readUint' + 8 * (this.length_size_of_traf_num + 1)]();
39-
this.trun_number = stream['readUint' + 8 * (this.length_size_of_trun_num + 1)]();
40-
this.sample_number = stream['readUint' + 8 * (this.length_size_of_sample_num + 1)]();
41+
entry.traf_number = stream['readUint' + 8 * (this.length_size_of_traf_num + 1)]();
42+
entry.trun_number = stream['readUint' + 8 * (this.length_size_of_trun_num + 1)]();
43+
entry.sample_delta = stream['readUint' + 8 * (this.length_size_of_sample_num + 1)]();
44+
this.entries.push(entry);
4145
}
4246
}
4347
}

0 commit comments

Comments
 (0)