Merge Boxes.moov() into Mp4MoovStucture.moov()

Boxes.moov() simply wraps the subboxes and this logic can be
put into main method which has all the logic of creating moov box.
This is to eventually move Mp4MoovStucture.moov() into
Boxes.java where all other box creation methods are already present.

PiperOrigin-RevId: 653319292
This commit is contained in:
sheenachhabra 2024-07-17 12:13:09 -07:00 committed by Copybara-Service
parent 01dda6d3e5
commit 51d27d7575
2 changed files with 10 additions and 29 deletions

View File

@ -487,27 +487,6 @@ import java.util.List;
"uuid", ImmutableList.of(ByteBuffer.wrap(Bytes.toArray(uuid)), contents));
}
/**
* Returns the moov box.
*
* <p>This box is a top level movie descriptor box (there is a single one of this per Mp4 file).
*/
public static ByteBuffer moov(
ByteBuffer mvhdBox,
ByteBuffer udtaBox,
ByteBuffer metaBox,
List<ByteBuffer> trakBoxes,
ByteBuffer mvexBox) {
List<ByteBuffer> subBoxes = new ArrayList<>();
subBoxes.add(mvhdBox);
subBoxes.add(udtaBox);
subBoxes.add(metaBox);
subBoxes.addAll(trakBoxes);
subBoxes.add(mvexBox);
return BoxUtils.wrapBoxesIntoBox("moov", subBoxes);
}
/** Returns an audio sample entry box based on the MIME type. */
public static ByteBuffer audioSampleEntry(Format format) {
String fourcc = codecSpecificFourcc(format);

View File

@ -192,14 +192,16 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
Boxes.keys(Lists.newArrayList(metadataCollector.metadataEntries)),
Boxes.ilst(Lists.newArrayList(metadataCollector.metadataEntries)));
ByteBuffer moovBox;
moovBox =
Boxes.moov(
mvhdBox,
udtaBox,
metaBox,
trakBoxes,
isFragmentedMp4 ? Boxes.mvex(trexBoxes) : ByteBuffer.allocate(0));
List<ByteBuffer> subBoxes = new ArrayList<>();
subBoxes.add(mvhdBox);
subBoxes.add(udtaBox);
subBoxes.add(metaBox);
subBoxes.addAll(trakBoxes);
if (isFragmentedMp4) {
subBoxes.add(Boxes.mvex(trexBoxes));
}
ByteBuffer moovBox = BoxUtils.wrapBoxesIntoBox("moov", subBoxes);
// Also add XMP if needed
if (metadataCollector.xmpData != null) {