Skip to content

Commit fc6df15

Browse files
Support variable length sgpd boxes in fMPEG
For `sgpd` boxes with version >= 1, `the default_length` field is zero if the length of the following sample group entries is variable. Since the `FragmentedMp4Extractor` only supports one entry, skip the `description_length` field if applicable (e.g. when version >= 1 and `default_length` == 0), instead of throwing an error. For parsing the following CencSampleEncryptionInformationGroupEntry, this should make no difference. Issue: #3177
1 parent 7ce3aa2 commit fc6df15

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

libraries/extractor/src/main/java/androidx/media3/extractor/mp4/FragmentedMp4Extractor.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,18 +1477,17 @@ private static void parseSampleGroups(
14771477
sgpd.setPosition(Mp4Box.HEADER_SIZE);
14781478
int sgpdVersion = BoxParser.parseFullBoxVersion(sgpd.readInt());
14791479
sgpd.skipBytes(4); // grouping_type == seig.
1480-
if (sgpdVersion == 1) {
1481-
if (sgpd.readUnsignedInt() == 0) {
1482-
throw ParserException.createForUnsupportedContainerFeature(
1483-
"Variable length description in sgpd found (unsupported)");
1484-
}
1485-
} else if (sgpdVersion >= 2) {
1480+
long default_length = sgpdVersion >= 1 ? sgpd.readUnsignedInt() : 0;
1481+
if (sgpdVersion >= 2) {
14861482
sgpd.skipBytes(4); // default_sample_description_index.
14871483
}
14881484
if (sgpd.readUnsignedInt() != 1) { // entry_count.
14891485
throw ParserException.createForUnsupportedContainerFeature(
14901486
"Entry count in sgpd != 1 (unsupported).");
14911487
}
1488+
if (sgpdVersion >= 1 && default_length == 0) {
1489+
sgpd.skipBytes(4); // description_length.
1490+
}
14921491

14931492
// CencSampleEncryptionInformationGroupEntry
14941493
sgpd.skipBytes(1); // reserved = 0.

0 commit comments

Comments
 (0)