mirror of
https://github.com/samsonjs/media.git
synced 2026-04-04 11:05:47 +00:00
Generalise the SlowMotion Metadata.Entry naming.
PiperOrigin-RevId: 339352447
This commit is contained in:
parent
c0a0708fc3
commit
2c746c6b6b
4 changed files with 34 additions and 34 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* 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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -25,7 +25,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
/** 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. */
|
||||
public static final class Segment implements Parcelable {
|
||||
|
|
@ -114,13 +114,13 @@ public final class SefSlowMotion implements Metadata.Entry {
|
|||
public final List<Segment> segments;
|
||||
|
||||
/** Creates an instance with a list of {@link Segment}s. */
|
||||
public SefSlowMotion(List<Segment> segments) {
|
||||
public SlowMotionData(List<Segment> segments) {
|
||||
this.segments = segments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SefSlowMotion: segments=" + segments;
|
||||
return "SlowMotion: segments=" + segments;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -131,7 +131,7 @@ public final class SefSlowMotion implements Metadata.Entry {
|
|||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SefSlowMotion that = (SefSlowMotion) o;
|
||||
SlowMotionData that = (SlowMotionData) o;
|
||||
return segments.equals(that.segments);
|
||||
}
|
||||
|
||||
|
|
@ -150,18 +150,18 @@ public final class SefSlowMotion implements Metadata.Entry {
|
|||
dest.writeList(segments);
|
||||
}
|
||||
|
||||
public static final Creator<SefSlowMotion> CREATOR =
|
||||
new Creator<SefSlowMotion>() {
|
||||
public static final Creator<SlowMotionData> CREATOR =
|
||||
new Creator<SlowMotionData>() {
|
||||
@Override
|
||||
public SefSlowMotion createFromParcel(Parcel in) {
|
||||
public SlowMotionData createFromParcel(Parcel in) {
|
||||
List<Segment> slowMotionSegments = new ArrayList<>();
|
||||
in.readList(slowMotionSegments, Segment.class.getClassLoader());
|
||||
return new SefSlowMotion(slowMotionSegments);
|
||||
return new SlowMotionData(slowMotionSegments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SefSlowMotion[] newArray(int size) {
|
||||
return new SefSlowMotion[size];
|
||||
public SlowMotionData[] newArray(int size) {
|
||||
return new SlowMotionData[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -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.metadata.Metadata;
|
||||
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.MimeTypes;
|
||||
import com.google.android.exoplayer2.util.NalUnitUtil;
|
||||
|
|
@ -90,7 +90,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
public static final int FLAG_READ_SEF_DATA = 1 << 2;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* 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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -26,7 +26,7 @@ import com.google.android.exoplayer2.extractor.Extractor;
|
|||
import com.google.android.exoplayer2.extractor.ExtractorInput;
|
||||
import com.google.android.exoplayer2.extractor.PositionHolder;
|
||||
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.common.base.Splitter;
|
||||
import java.io.IOException;
|
||||
|
|
@ -184,7 +184,7 @@ import java.util.List;
|
|||
DataReference dataReference = dataReferences.get(i);
|
||||
if (dataReference.dataType == TYPE_SLOW_MOTION_DATA) {
|
||||
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;
|
||||
while (scratch.getPosition() < dataReferenceEndPosition) {
|
||||
@Nullable String data = scratch.readDelimiterTerminatedString('*');
|
||||
|
|
@ -197,13 +197,13 @@ import java.util.List;
|
|||
int endTimeMs = Integer.parseInt(values.get(1));
|
||||
int speedMode = Integer.parseInt(values.get(2));
|
||||
int speedDivisor = 1 << (speedMode - 1);
|
||||
segments.add(new SefSlowMotion.Segment(startTimeMs, endTimeMs, speedDivisor));
|
||||
segments.add(new SlowMotionData.Segment(startTimeMs, endTimeMs, speedDivisor));
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ParserException(e);
|
||||
}
|
||||
}
|
||||
totalDataReferenceBytesConsumed += dataReference.size;
|
||||
slowMotionMetadataEntries.add(new SefSlowMotion(segments));
|
||||
slowMotionMetadataEntries.add(new SlowMotionData(segments));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* 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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -19,52 +19,52 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
|
||||
import android.os.Parcel;
|
||||
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.List;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/** Unit test for {@link SefSlowMotion} */
|
||||
/** Unit test for {@link SlowMotionData} */
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class SefSlowMotionTest {
|
||||
public class SlowMotionDataTest {
|
||||
|
||||
@Test
|
||||
public void parcelable() {
|
||||
List<SefSlowMotion.Segment> segments = new ArrayList<>();
|
||||
List<SlowMotionData.Segment> segments = new ArrayList<>();
|
||||
segments.add(
|
||||
new SefSlowMotion.Segment(
|
||||
new SlowMotionData.Segment(
|
||||
/* startTimeMs= */ 1000, /* endTimeMs= */ 2000, /* speedDivisor= */ 4));
|
||||
segments.add(
|
||||
new SefSlowMotion.Segment(
|
||||
new SlowMotionData.Segment(
|
||||
/* startTimeMs= */ 2600, /* endTimeMs= */ 4000, /* speedDivisor= */ 8));
|
||||
segments.add(
|
||||
new SefSlowMotion.Segment(
|
||||
new SlowMotionData.Segment(
|
||||
/* startTimeMs= */ 8765, /* endTimeMs= */ 12485, /* speedDivisor= */ 16));
|
||||
|
||||
SefSlowMotion sefSlowMotionToParcel = new SefSlowMotion(segments);
|
||||
SlowMotionData slowMotionDataToParcel = new SlowMotionData(segments);
|
||||
Parcel parcel = Parcel.obtain();
|
||||
sefSlowMotionToParcel.writeToParcel(parcel, /* flags= */ 0);
|
||||
slowMotionDataToParcel.writeToParcel(parcel, /* flags= */ 0);
|
||||
parcel.setDataPosition(0);
|
||||
|
||||
SefSlowMotion sefSlowMotionFromParcel = SefSlowMotion.CREATOR.createFromParcel(parcel);
|
||||
assertThat(sefSlowMotionFromParcel).isEqualTo(sefSlowMotionToParcel);
|
||||
SlowMotionData slowMotionDataFromParcel = SlowMotionData.CREATOR.createFromParcel(parcel);
|
||||
assertThat(slowMotionDataFromParcel).isEqualTo(slowMotionDataToParcel);
|
||||
|
||||
parcel.recycle();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void segment_parcelable() {
|
||||
SefSlowMotion.Segment segmentToParcel =
|
||||
new SefSlowMotion.Segment(
|
||||
SlowMotionData.Segment segmentToParcel =
|
||||
new SlowMotionData.Segment(
|
||||
/* startTimeMs= */ 1000, /* endTimeMs= */ 2000, /* speedDivisor= */ 4);
|
||||
|
||||
Parcel parcel = Parcel.obtain();
|
||||
segmentToParcel.writeToParcel(parcel, /* flags= */ 0);
|
||||
parcel.setDataPosition(0);
|
||||
|
||||
SefSlowMotion.Segment segmentFromParcel =
|
||||
SefSlowMotion.Segment.CREATOR.createFromParcel(parcel);
|
||||
SlowMotionData.Segment segmentFromParcel =
|
||||
SlowMotionData.Segment.CREATOR.createFromParcel(parcel);
|
||||
assertThat(segmentFromParcel).isEqualTo(segmentToParcel);
|
||||
|
||||
parcel.recycle();
|
||||
Loading…
Reference in a new issue