Commit 2c746c6b by samrobinson Committed by Oliver Woodman

Generalise the SlowMotion Metadata.Entry naming.

PiperOrigin-RevId: 339352447
parent c0a0708f
/* /*
* Copyright (C) 2020 The Android Open Source Project * Copyright 2020 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -25,7 +25,7 @@ import java.util.ArrayList; ...@@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** Holds information about the segments of slow motion playback within a track. */ /** Holds information about the segments of slow motion playback within a track. */
public final class SefSlowMotion implements Metadata.Entry { public final class SlowMotionData implements Metadata.Entry {
/** Holds information about a single segment of slow motion playback within a track. */ /** Holds information about a single segment of slow motion playback within a track. */
public static final class Segment implements Parcelable { public static final class Segment implements Parcelable {
...@@ -114,13 +114,13 @@ public final class SefSlowMotion implements Metadata.Entry { ...@@ -114,13 +114,13 @@ public final class SefSlowMotion implements Metadata.Entry {
public final List<Segment> segments; public final List<Segment> segments;
/** Creates an instance with a list of {@link Segment}s. */ /** Creates an instance with a list of {@link Segment}s. */
public SefSlowMotion(List<Segment> segments) { public SlowMotionData(List<Segment> segments) {
this.segments = segments; this.segments = segments;
} }
@Override @Override
public String toString() { public String toString() {
return "SefSlowMotion: segments=" + segments; return "SlowMotion: segments=" + segments;
} }
@Override @Override
...@@ -131,7 +131,7 @@ public final class SefSlowMotion implements Metadata.Entry { ...@@ -131,7 +131,7 @@ public final class SefSlowMotion implements Metadata.Entry {
if (o == null || getClass() != o.getClass()) { if (o == null || getClass() != o.getClass()) {
return false; return false;
} }
SefSlowMotion that = (SefSlowMotion) o; SlowMotionData that = (SlowMotionData) o;
return segments.equals(that.segments); return segments.equals(that.segments);
} }
...@@ -150,18 +150,18 @@ public final class SefSlowMotion implements Metadata.Entry { ...@@ -150,18 +150,18 @@ public final class SefSlowMotion implements Metadata.Entry {
dest.writeList(segments); dest.writeList(segments);
} }
public static final Creator<SefSlowMotion> CREATOR = public static final Creator<SlowMotionData> CREATOR =
new Creator<SefSlowMotion>() { new Creator<SlowMotionData>() {
@Override @Override
public SefSlowMotion createFromParcel(Parcel in) { public SlowMotionData createFromParcel(Parcel in) {
List<Segment> slowMotionSegments = new ArrayList<>(); List<Segment> slowMotionSegments = new ArrayList<>();
in.readList(slowMotionSegments, Segment.class.getClassLoader()); in.readList(slowMotionSegments, Segment.class.getClassLoader());
return new SefSlowMotion(slowMotionSegments); return new SlowMotionData(slowMotionSegments);
} }
@Override @Override
public SefSlowMotion[] newArray(int size) { public SlowMotionData[] newArray(int size) {
return new SefSlowMotion[size]; return new SlowMotionData[size];
} }
}; };
} }
...@@ -41,7 +41,7 @@ import com.google.android.exoplayer2.extractor.TrackOutput; ...@@ -41,7 +41,7 @@ import com.google.android.exoplayer2.extractor.TrackOutput;
import com.google.android.exoplayer2.extractor.mp4.Atom.ContainerAtom; import com.google.android.exoplayer2.extractor.mp4.Atom.ContainerAtom;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata; import com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata;
import com.google.android.exoplayer2.metadata.mp4.SefSlowMotion; import com.google.android.exoplayer2.metadata.mp4.SlowMotionData;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.NalUnitUtil; import com.google.android.exoplayer2.util.NalUnitUtil;
...@@ -90,7 +90,7 @@ public final class Mp4Extractor implements Extractor, SeekMap { ...@@ -90,7 +90,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
*/ */
public static final int FLAG_READ_MOTION_PHOTO_METADATA = 1 << 1; public static final int FLAG_READ_MOTION_PHOTO_METADATA = 1 << 1;
/** /**
* Flag to extract {@link SefSlowMotion} metadata from Samsung Extension Format (SEF) slow motion * Flag to extract {@link SlowMotionData} metadata from Samsung Extension Format (SEF) slow motion
* videos. * videos.
*/ */
public static final int FLAG_READ_SEF_DATA = 1 << 2; public static final int FLAG_READ_SEF_DATA = 1 << 2;
......
/* /*
* Copyright (C) 2020 The Android Open Source Project * Copyright 2020 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -26,7 +26,7 @@ import com.google.android.exoplayer2.extractor.Extractor; ...@@ -26,7 +26,7 @@ import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.ExtractorInput; import com.google.android.exoplayer2.extractor.ExtractorInput;
import com.google.android.exoplayer2.extractor.PositionHolder; import com.google.android.exoplayer2.extractor.PositionHolder;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.mp4.SefSlowMotion; import com.google.android.exoplayer2.metadata.mp4.SlowMotionData;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import java.io.IOException; import java.io.IOException;
...@@ -184,7 +184,7 @@ import java.util.List; ...@@ -184,7 +184,7 @@ import java.util.List;
DataReference dataReference = dataReferences.get(i); DataReference dataReference = dataReferences.get(i);
if (dataReference.dataType == TYPE_SLOW_MOTION_DATA) { if (dataReference.dataType == TYPE_SLOW_MOTION_DATA) {
scratch.skipBytes(23); // data type (2), data sub info (2), name len (4), name (15). scratch.skipBytes(23); // data type (2), data sub info (2), name len (4), name (15).
List<SefSlowMotion.Segment> segments = new ArrayList<>(); List<SlowMotionData.Segment> segments = new ArrayList<>();
int dataReferenceEndPosition = totalDataReferenceBytesConsumed + dataReference.size; int dataReferenceEndPosition = totalDataReferenceBytesConsumed + dataReference.size;
while (scratch.getPosition() < dataReferenceEndPosition) { while (scratch.getPosition() < dataReferenceEndPosition) {
@Nullable String data = scratch.readDelimiterTerminatedString('*'); @Nullable String data = scratch.readDelimiterTerminatedString('*');
...@@ -197,13 +197,13 @@ import java.util.List; ...@@ -197,13 +197,13 @@ import java.util.List;
int endTimeMs = Integer.parseInt(values.get(1)); int endTimeMs = Integer.parseInt(values.get(1));
int speedMode = Integer.parseInt(values.get(2)); int speedMode = Integer.parseInt(values.get(2));
int speedDivisor = 1 << (speedMode - 1); int speedDivisor = 1 << (speedMode - 1);
segments.add(new SefSlowMotion.Segment(startTimeMs, endTimeMs, speedDivisor)); segments.add(new SlowMotionData.Segment(startTimeMs, endTimeMs, speedDivisor));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new ParserException(e); throw new ParserException(e);
} }
} }
totalDataReferenceBytesConsumed += dataReference.size; totalDataReferenceBytesConsumed += dataReference.size;
slowMotionMetadataEntries.add(new SefSlowMotion(segments)); slowMotionMetadataEntries.add(new SlowMotionData(segments));
} }
} }
} }
......
/* /*
* Copyright (C) 2020 The Android Open Source Project * Copyright 2020 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -19,52 +19,52 @@ import static com.google.common.truth.Truth.assertThat; ...@@ -19,52 +19,52 @@ import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel; import android.os.Parcel;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.metadata.mp4.SefSlowMotion; import com.google.android.exoplayer2.metadata.mp4.SlowMotionData;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
/** Unit test for {@link SefSlowMotion} */ /** Unit test for {@link SlowMotionData} */
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class SefSlowMotionTest { public class SlowMotionDataTest {
@Test @Test
public void parcelable() { public void parcelable() {
List<SefSlowMotion.Segment> segments = new ArrayList<>(); List<SlowMotionData.Segment> segments = new ArrayList<>();
segments.add( segments.add(
new SefSlowMotion.Segment( new SlowMotionData.Segment(
/* startTimeMs= */ 1000, /* endTimeMs= */ 2000, /* speedDivisor= */ 4)); /* startTimeMs= */ 1000, /* endTimeMs= */ 2000, /* speedDivisor= */ 4));
segments.add( segments.add(
new SefSlowMotion.Segment( new SlowMotionData.Segment(
/* startTimeMs= */ 2600, /* endTimeMs= */ 4000, /* speedDivisor= */ 8)); /* startTimeMs= */ 2600, /* endTimeMs= */ 4000, /* speedDivisor= */ 8));
segments.add( segments.add(
new SefSlowMotion.Segment( new SlowMotionData.Segment(
/* startTimeMs= */ 8765, /* endTimeMs= */ 12485, /* speedDivisor= */ 16)); /* startTimeMs= */ 8765, /* endTimeMs= */ 12485, /* speedDivisor= */ 16));
SefSlowMotion sefSlowMotionToParcel = new SefSlowMotion(segments); SlowMotionData slowMotionDataToParcel = new SlowMotionData(segments);
Parcel parcel = Parcel.obtain(); Parcel parcel = Parcel.obtain();
sefSlowMotionToParcel.writeToParcel(parcel, /* flags= */ 0); slowMotionDataToParcel.writeToParcel(parcel, /* flags= */ 0);
parcel.setDataPosition(0); parcel.setDataPosition(0);
SefSlowMotion sefSlowMotionFromParcel = SefSlowMotion.CREATOR.createFromParcel(parcel); SlowMotionData slowMotionDataFromParcel = SlowMotionData.CREATOR.createFromParcel(parcel);
assertThat(sefSlowMotionFromParcel).isEqualTo(sefSlowMotionToParcel); assertThat(slowMotionDataFromParcel).isEqualTo(slowMotionDataToParcel);
parcel.recycle(); parcel.recycle();
} }
@Test @Test
public void segment_parcelable() { public void segment_parcelable() {
SefSlowMotion.Segment segmentToParcel = SlowMotionData.Segment segmentToParcel =
new SefSlowMotion.Segment( new SlowMotionData.Segment(
/* startTimeMs= */ 1000, /* endTimeMs= */ 2000, /* speedDivisor= */ 4); /* startTimeMs= */ 1000, /* endTimeMs= */ 2000, /* speedDivisor= */ 4);
Parcel parcel = Parcel.obtain(); Parcel parcel = Parcel.obtain();
segmentToParcel.writeToParcel(parcel, /* flags= */ 0); segmentToParcel.writeToParcel(parcel, /* flags= */ 0);
parcel.setDataPosition(0); parcel.setDataPosition(0);
SefSlowMotion.Segment segmentFromParcel = SlowMotionData.Segment segmentFromParcel =
SefSlowMotion.Segment.CREATOR.createFromParcel(parcel); SlowMotionData.Segment.CREATOR.createFromParcel(parcel);
assertThat(segmentFromParcel).isEqualTo(segmentToParcel); assertThat(segmentFromParcel).isEqualTo(segmentToParcel);
parcel.recycle(); parcel.recycle();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment