Rename Muxer.addMetadata to addMetadataEntry
This is to make it clear that the method adds a single metadata entry, not a collection of metadata entries. PiperOrigin-RevId: 629398485
This commit is contained in:
parent
bc77cef403
commit
6956d8099a
@ -67,7 +67,7 @@ public class FragmentedMp4MuxerEndToEndAndroidTest {
|
||||
|
||||
try {
|
||||
fragmentedMp4Muxer = new FragmentedMp4Muxer.Builder(checkNotNull(outputStream)).build();
|
||||
fragmentedMp4Muxer.addMetadata(
|
||||
fragmentedMp4Muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 100_000_000L,
|
||||
/* modificationTimestampSeconds= */ 500_000_000L));
|
||||
@ -94,7 +94,7 @@ public class FragmentedMp4MuxerEndToEndAndroidTest {
|
||||
|
||||
try {
|
||||
fragmentedMp4Muxer = new FragmentedMp4Muxer.Builder(checkNotNull(outputStream)).build();
|
||||
fragmentedMp4Muxer.addMetadata(
|
||||
fragmentedMp4Muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 100_000_000L,
|
||||
/* modificationTimestampSeconds= */ 500_000_000L));
|
||||
|
@ -78,7 +78,7 @@ public class Mp4MuxerEndToEndAndroidTest {
|
||||
|
||||
try {
|
||||
mp4Muxer = new Mp4Muxer.Builder(checkNotNull(outputStream)).build();
|
||||
mp4Muxer.addMetadata(
|
||||
mp4Muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 100_000_000L,
|
||||
/* modificationTimestampSeconds= */ 500_000_000L));
|
||||
@ -102,7 +102,7 @@ public class Mp4MuxerEndToEndAndroidTest {
|
||||
// ensure some data has been written after taking all the inputs but before closing the muxer.
|
||||
assumeTrue(checkNotNull(inputFile).equals(H265_HDR10_MP4));
|
||||
Mp4Muxer mp4Muxer = new Mp4Muxer.Builder(checkNotNull(outputStream)).build();
|
||||
mp4Muxer.addMetadata(
|
||||
mp4Muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 100_000_000L,
|
||||
/* modificationTimestampSeconds= */ 500_000_000L));
|
||||
|
@ -179,13 +179,14 @@ public final class FragmentedMp4Muxer implements Muxer {
|
||||
* <li>{@link XmpData}
|
||||
* </ul>
|
||||
*
|
||||
* @param metadata The {@linkplain Metadata.Entry metadata}. An {@link IllegalArgumentException}
|
||||
* is thrown if the {@linkplain Metadata.Entry metadata} is not supported.
|
||||
* @param metadataEntry The {@linkplain Metadata.Entry metadata}. An {@link
|
||||
* IllegalArgumentException} is thrown if the {@linkplain Metadata.Entry metadata} is not
|
||||
* supported.
|
||||
*/
|
||||
@Override
|
||||
public void addMetadata(Metadata.Entry metadata) {
|
||||
checkArgument(Mp4Utils.isMetadataSupported(metadata), "Unsupported metadata");
|
||||
metadataCollector.addMetadata(metadata);
|
||||
public void addMetadataEntry(Metadata.Entry metadataEntry) {
|
||||
checkArgument(Mp4Utils.isMetadataSupported(metadataEntry), "Unsupported metadata");
|
||||
metadataCollector.addMetadata(metadataEntry);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -244,13 +244,14 @@ public final class Mp4Muxer implements Muxer {
|
||||
* <li>{@link XmpData}
|
||||
* </ul>
|
||||
*
|
||||
* @param metadata The {@linkplain Metadata.Entry metadata}. An {@link IllegalArgumentException}
|
||||
* is thrown if the {@linkplain Metadata.Entry metadata} is not supported.
|
||||
* @param metadataEntry The {@linkplain Metadata.Entry metadata}. An {@link
|
||||
* IllegalArgumentException} is thrown if the {@linkplain Metadata.Entry metadata} is not
|
||||
* supported.
|
||||
*/
|
||||
@Override
|
||||
public void addMetadata(Metadata.Entry metadata) {
|
||||
checkArgument(Mp4Utils.isMetadataSupported(metadata), "Unsupported metadata");
|
||||
metadataCollector.addMetadata(metadata);
|
||||
public void addMetadataEntry(Metadata.Entry metadataEntry) {
|
||||
checkArgument(Mp4Utils.isMetadataSupported(metadataEntry), "Unsupported metadata");
|
||||
metadataCollector.addMetadata(metadataEntry);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,7 +36,7 @@ public interface Muxer {
|
||||
throws IOException;
|
||||
|
||||
/** Adds {@linkplain Metadata.Entry metadata} about the output file. */
|
||||
void addMetadata(Metadata.Entry metadata);
|
||||
void addMetadataEntry(Metadata.Entry metadataEntry);
|
||||
|
||||
/** Closes the file. */
|
||||
void close() throws IOException;
|
||||
|
@ -60,8 +60,8 @@ public class Mp4MuxerEndToEndTest {
|
||||
|
||||
try {
|
||||
mp4Muxer.addTrack(/* sortKey= */ 0, FAKE_VIDEO_FORMAT);
|
||||
mp4Muxer.addMetadata(new Mp4OrientationData(/* orientation= */ 90));
|
||||
mp4Muxer.addMetadata(
|
||||
mp4Muxer.addMetadataEntry(new Mp4OrientationData(/* orientation= */ 90));
|
||||
mp4Muxer.addMetadataEntry(
|
||||
new MdtaMetadataEntry(
|
||||
"key",
|
||||
/* value= */ Util.getUtf8Bytes("value"),
|
||||
@ -78,7 +78,7 @@ public class Mp4MuxerEndToEndTest {
|
||||
public void createMp4File_withSameTracksOffset_matchesExpected() throws IOException {
|
||||
String outputFilePath = temporaryFolder.newFile().getPath();
|
||||
Mp4Muxer mp4Muxer = new Mp4Muxer.Builder(new FileOutputStream(outputFilePath)).build();
|
||||
mp4Muxer.addMetadata(
|
||||
mp4Muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 100_000_000L,
|
||||
/* modificationTimestampSeconds= */ 500_000_000L));
|
||||
@ -121,7 +121,7 @@ public class Mp4MuxerEndToEndTest {
|
||||
public void createMp4File_withDifferentTracksOffset_matchesExpected() throws IOException {
|
||||
String outputFilePath = temporaryFolder.newFile().getPath();
|
||||
Mp4Muxer mp4Muxer = new Mp4Muxer.Builder(new FileOutputStream(outputFilePath)).build();
|
||||
mp4Muxer.addMetadata(
|
||||
mp4Muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 100_000_000L,
|
||||
/* modificationTimestampSeconds= */ 500_000_000L));
|
||||
@ -183,7 +183,7 @@ public class Mp4MuxerEndToEndTest {
|
||||
public void createMp4File_withOneTrackEmpty_doesNotWriteEmptyTrack() throws Exception {
|
||||
String outputFilePath = temporaryFolder.newFile().getPath();
|
||||
Mp4Muxer mp4Muxer = new Mp4Muxer.Builder(new FileOutputStream(outputFilePath)).build();
|
||||
mp4Muxer.addMetadata(
|
||||
mp4Muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 100_000_000L,
|
||||
/* modificationTimestampSeconds= */ 500_000_000L));
|
||||
@ -220,24 +220,24 @@ public class Mp4MuxerEndToEndTest {
|
||||
byte[] xmpBytes = TestUtil.getByteArray(context, XMP_SAMPLE_DATA);
|
||||
|
||||
try {
|
||||
muxer.addMetadata(new Mp4OrientationData(/* orientation= */ 90));
|
||||
muxer.addMetadata(new Mp4LocationData(/* latitude= */ 33.0f, /* longitude= */ -120f));
|
||||
muxer.addMetadataEntry(new Mp4OrientationData(/* orientation= */ 90));
|
||||
muxer.addMetadataEntry(new Mp4LocationData(/* latitude= */ 33.0f, /* longitude= */ -120f));
|
||||
float captureFps = 120.0f;
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new MdtaMetadataEntry(
|
||||
MdtaMetadataEntry.KEY_ANDROID_CAPTURE_FPS,
|
||||
/* value= */ Util.toByteArray(captureFps),
|
||||
MdtaMetadataEntry.TYPE_INDICATOR_FLOAT32));
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 1_000_000L,
|
||||
/* modificationTimestampSeconds= */ 5_000_000L));
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new MdtaMetadataEntry(
|
||||
"StringKey1",
|
||||
/* value= */ Util.getUtf8Bytes("StringValue"),
|
||||
MdtaMetadataEntry.TYPE_INDICATOR_STRING));
|
||||
muxer.addMetadata(new XmpData(xmpBytes));
|
||||
muxer.addMetadataEntry(new XmpData(xmpBytes));
|
||||
TrackToken token = muxer.addTrack(/* sortKey= */ 0, FAKE_VIDEO_FORMAT);
|
||||
muxer.writeSampleData(token, sampleAndSampleInfo.first, sampleAndSampleInfo.second);
|
||||
} finally {
|
||||
|
@ -61,7 +61,7 @@ public class Mp4MuxerMetadataTest {
|
||||
Mp4Muxer muxer = new Mp4Muxer.Builder(new FileOutputStream(outputFilePath)).build();
|
||||
|
||||
try {
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 1_000_000L,
|
||||
/* modificationTimestampSeconds= */ 5_000_000L));
|
||||
@ -87,14 +87,14 @@ public class Mp4MuxerMetadataTest {
|
||||
Mp4Muxer muxer = new Mp4Muxer.Builder(new FileOutputStream(outputFilePath)).build();
|
||||
|
||||
try {
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 1_000_000L,
|
||||
/* modificationTimestampSeconds= */ 5_000_000L));
|
||||
TrackToken token = muxer.addTrack(/* sortKey= */ 0, FAKE_VIDEO_FORMAT);
|
||||
muxer.writeSampleData(token, sampleAndSampleInfo.first, sampleAndSampleInfo.second);
|
||||
|
||||
muxer.addMetadata(new Mp4OrientationData(/* orientation= */ 90));
|
||||
muxer.addMetadataEntry(new Mp4OrientationData(/* orientation= */ 90));
|
||||
} finally {
|
||||
muxer.close();
|
||||
}
|
||||
@ -115,14 +115,14 @@ public class Mp4MuxerMetadataTest {
|
||||
Mp4Muxer muxer = new Mp4Muxer.Builder(new FileOutputStream(outputFilePath)).build();
|
||||
|
||||
try {
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 1_000_000L,
|
||||
/* modificationTimestampSeconds= */ 5_000_000L));
|
||||
TrackToken token = muxer.addTrack(/* sortKey= */ 0, FAKE_VIDEO_FORMAT);
|
||||
muxer.writeSampleData(token, sampleAndSampleInfo.first, sampleAndSampleInfo.second);
|
||||
|
||||
muxer.addMetadata(new Mp4OrientationData(/* orientation= */ 180));
|
||||
muxer.addMetadataEntry(new Mp4OrientationData(/* orientation= */ 180));
|
||||
} finally {
|
||||
muxer.close();
|
||||
}
|
||||
@ -143,14 +143,14 @@ public class Mp4MuxerMetadataTest {
|
||||
Mp4Muxer muxer = new Mp4Muxer.Builder(new FileOutputStream(outputFilePath)).build();
|
||||
|
||||
try {
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 1_000_000L,
|
||||
/* modificationTimestampSeconds= */ 5_000_000L));
|
||||
TrackToken token = muxer.addTrack(/* sortKey= */ 0, FAKE_VIDEO_FORMAT);
|
||||
muxer.writeSampleData(token, sampleAndSampleInfo.first, sampleAndSampleInfo.second);
|
||||
|
||||
muxer.addMetadata(new Mp4OrientationData(/* orientation= */ 270));
|
||||
muxer.addMetadataEntry(new Mp4OrientationData(/* orientation= */ 270));
|
||||
} finally {
|
||||
muxer.close();
|
||||
}
|
||||
@ -171,13 +171,13 @@ public class Mp4MuxerMetadataTest {
|
||||
Mp4Muxer muxer = new Mp4Muxer.Builder(new FileOutputStream(outputFilePath)).build();
|
||||
|
||||
try {
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 1_000_000L,
|
||||
/* modificationTimestampSeconds= */ 5_000_000L));
|
||||
TrackToken token = muxer.addTrack(/* sortKey= */ 0, FAKE_VIDEO_FORMAT);
|
||||
muxer.writeSampleData(token, sampleAndSampleInfo.first, sampleAndSampleInfo.second);
|
||||
muxer.addMetadata(new Mp4LocationData(/* latitude= */ 33.0f, /* longitude= */ -120f));
|
||||
muxer.addMetadataEntry(new Mp4LocationData(/* latitude= */ 33.0f, /* longitude= */ -120f));
|
||||
} finally {
|
||||
muxer.close();
|
||||
}
|
||||
@ -198,7 +198,7 @@ public class Mp4MuxerMetadataTest {
|
||||
Mp4Muxer muxer = new Mp4Muxer.Builder(new FileOutputStream(outputFilePath)).build();
|
||||
|
||||
try {
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 1_000_000L,
|
||||
/* modificationTimestampSeconds= */ 5_000_000L));
|
||||
@ -224,12 +224,12 @@ public class Mp4MuxerMetadataTest {
|
||||
Mp4Muxer muxer = new Mp4Muxer.Builder(new FileOutputStream(outputFilePath)).build();
|
||||
|
||||
try {
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 1_000_000L,
|
||||
/* modificationTimestampSeconds= */ 5_000_000L));
|
||||
float captureFps = 120.0f;
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new MdtaMetadataEntry(
|
||||
KEY_ANDROID_CAPTURE_FPS, Util.toByteArray(captureFps), TYPE_INDICATOR_FLOAT32));
|
||||
TrackToken token = muxer.addTrack(/* sortKey= */ 0, FAKE_VIDEO_FORMAT);
|
||||
@ -254,11 +254,11 @@ public class Mp4MuxerMetadataTest {
|
||||
Mp4Muxer muxer = new Mp4Muxer.Builder(new FileOutputStream(outputFilePath)).build();
|
||||
|
||||
try {
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 1_000_000L,
|
||||
/* modificationTimestampSeconds= */ 5_000_000L));
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new MdtaMetadataEntry(
|
||||
"SomeStringKey", Util.getUtf8Bytes("Some Random String"), TYPE_INDICATOR_STRING));
|
||||
TrackToken token = muxer.addTrack(/* sortKey= */ 0, FAKE_VIDEO_FORMAT);
|
||||
@ -283,12 +283,12 @@ public class Mp4MuxerMetadataTest {
|
||||
Mp4Muxer muxer = new Mp4Muxer.Builder(new FileOutputStream(outputFilePath)).build();
|
||||
|
||||
try {
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 1_000_000L,
|
||||
/* modificationTimestampSeconds= */ 5_000_000L));
|
||||
float floatValue = 10.0f;
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new MdtaMetadataEntry(
|
||||
"SomeStringKey", Util.toByteArray(floatValue), TYPE_INDICATOR_FLOAT32));
|
||||
TrackToken token = muxer.addTrack(/* sortKey= */ 0, FAKE_VIDEO_FORMAT);
|
||||
@ -313,13 +313,13 @@ public class Mp4MuxerMetadataTest {
|
||||
Mp4Muxer muxer = new Mp4Muxer.Builder(new FileOutputStream(outputFilePath)).build();
|
||||
|
||||
try {
|
||||
muxer.addMetadata(
|
||||
muxer.addMetadataEntry(
|
||||
new Mp4TimestampData(
|
||||
/* creationTimestampSeconds= */ 1_000_000L,
|
||||
/* modificationTimestampSeconds= */ 5_000_000L));
|
||||
Context context = ApplicationProvider.getApplicationContext();
|
||||
byte[] xmpBytes = TestUtil.getByteArray(context, XMP_SAMPLE_DATA);
|
||||
muxer.addMetadata(new XmpData(xmpBytes));
|
||||
muxer.addMetadataEntry(new XmpData(xmpBytes));
|
||||
TrackToken token = muxer.addTrack(0, FAKE_VIDEO_FORMAT);
|
||||
muxer.writeSampleData(token, sampleAndSampleInfo.first, sampleAndSampleInfo.second);
|
||||
} finally {
|
||||
|
@ -49,7 +49,8 @@ public final class InAppMuxer implements Muxer {
|
||||
* <p>A {@link Metadata.Entry} can be added or removed. To modify an existing {@link
|
||||
* Metadata.Entry}, first remove it and then add a new one.
|
||||
*
|
||||
* <p>For the list of supported metadata refer to {@link Mp4Muxer#addMetadata(Metadata.Entry)}.
|
||||
* <p>For the list of supported metadata refer to {@link
|
||||
* Mp4Muxer#addMetadataEntry(Metadata.Entry)}.
|
||||
*/
|
||||
void updateMetadataEntries(Set<Metadata.Entry> metadataEntries);
|
||||
}
|
||||
@ -172,7 +173,7 @@ public final class InAppMuxer implements Muxer {
|
||||
public TrackToken addTrack(Format format) {
|
||||
TrackToken trackToken = muxer.addTrack(format);
|
||||
if (MimeTypes.isVideo(format.sampleMimeType)) {
|
||||
muxer.addMetadata(new Mp4OrientationData(format.rotationDegrees));
|
||||
muxer.addMetadataEntry(new Mp4OrientationData(format.rotationDegrees));
|
||||
}
|
||||
return trackToken;
|
||||
}
|
||||
@ -220,7 +221,7 @@ public final class InAppMuxer implements Muxer {
|
||||
}
|
||||
|
||||
for (Metadata.Entry entry : metadataEntries) {
|
||||
muxer.addMetadata(entry);
|
||||
muxer.addMetadataEntry(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user