Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2c746c6b
authored
Oct 27, 2020
by
samrobinson
Committed by
Oliver Woodman
Nov 02, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Generalise the SlowMotion Metadata.Entry naming.
PiperOrigin-RevId: 339352447
parent
c0a0708f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
34 deletions
library/common/src/main/java/com/google/android/exoplayer2/metadata/mp4/SefSlowMotion.java → library/common/src/main/java/com/google/android/exoplayer2/metadata/mp4/SlowMotionData.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/SefReader.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/SefSlowMotionTest.java → library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/SlowMotionDataTest.java
library/common/src/main/java/com/google/android/exoplayer2/metadata/mp4/S
efSlowMotion
.java
→
library/common/src/main/java/com/google/android/exoplayer2/metadata/mp4/S
lowMotionData
.java
View file @
2c746c6b
/*
/*
* 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
S
efSlowMotion
implements
Metadata
.
Entry
{
public
final
class
S
lowMotionData
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
S
efSlowMotion
(
List
<
Segment
>
segments
)
{
public
S
lowMotionData
(
List
<
Segment
>
segments
)
{
this
.
segments
=
segments
;
this
.
segments
=
segments
;
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"S
efS
lowMotion: 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
;
}
}
S
efSlowMotion
that
=
(
SefSlowMotion
)
o
;
S
lowMotionData
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
<
S
efSlowMotion
>
CREATOR
=
public
static
final
Creator
<
S
lowMotionData
>
CREATOR
=
new
Creator
<
S
efSlowMotion
>()
{
new
Creator
<
S
lowMotionData
>()
{
@Override
@Override
public
S
efSlowMotion
createFromParcel
(
Parcel
in
)
{
public
S
lowMotionData
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
S
efSlowMotion
(
slowMotionSegments
);
return
new
S
lowMotionData
(
slowMotionSegments
);
}
}
@Override
@Override
public
S
efSlowMotion
[]
newArray
(
int
size
)
{
public
S
lowMotionData
[]
newArray
(
int
size
)
{
return
new
S
efSlowMotion
[
size
];
return
new
S
lowMotionData
[
size
];
}
}
};
};
}
}
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java
View file @
2c746c6b
...
@@ -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.S
efSlowMotion
;
import
com.google.android.exoplayer2.metadata.mp4.S
lowMotionData
;
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 S
efSlowMotion
} metadata from Samsung Extension Format (SEF) slow motion
* Flag to extract {@link S
lowMotionData
} 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
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/SefReader.java
View file @
2c746c6b
/*
/*
* 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.S
efSlowMotion
;
import
com.google.android.exoplayer2.metadata.mp4.S
lowMotionData
;
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
<
S
efSlowMotion
.
Segment
>
segments
=
new
ArrayList
<>();
List
<
S
lowMotionData
.
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
S
efSlowMotion
.
Segment
(
startTimeMs
,
endTimeMs
,
speedDivisor
));
segments
.
add
(
new
S
lowMotionData
.
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
S
efSlowMotion
(
segments
));
slowMotionMetadataEntries
.
add
(
new
S
lowMotionData
(
segments
));
}
}
}
}
}
}
...
...
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/S
efSlowMotion
Test.java
→
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/S
lowMotionData
Test.java
View file @
2c746c6b
/*
/*
* 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.S
efSlowMotion
;
import
com.google.android.exoplayer2.metadata.mp4.S
lowMotionData
;
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 S
efSlowMotion
} */
/** Unit test for {@link S
lowMotionData
} */
@RunWith
(
AndroidJUnit4
.
class
)
@RunWith
(
AndroidJUnit4
.
class
)
public
class
S
efSlowMotion
Test
{
public
class
S
lowMotionData
Test
{
@Test
@Test
public
void
parcelable
()
{
public
void
parcelable
()
{
List
<
S
efSlowMotion
.
Segment
>
segments
=
new
ArrayList
<>();
List
<
S
lowMotionData
.
Segment
>
segments
=
new
ArrayList
<>();
segments
.
add
(
segments
.
add
(
new
S
efSlowMotion
.
Segment
(
new
S
lowMotionData
.
Segment
(
/* startTimeMs= */
1000
,
/* endTimeMs= */
2000
,
/* speedDivisor= */
4
));
/* startTimeMs= */
1000
,
/* endTimeMs= */
2000
,
/* speedDivisor= */
4
));
segments
.
add
(
segments
.
add
(
new
S
efSlowMotion
.
Segment
(
new
S
lowMotionData
.
Segment
(
/* startTimeMs= */
2600
,
/* endTimeMs= */
4000
,
/* speedDivisor= */
8
));
/* startTimeMs= */
2600
,
/* endTimeMs= */
4000
,
/* speedDivisor= */
8
));
segments
.
add
(
segments
.
add
(
new
S
efSlowMotion
.
Segment
(
new
S
lowMotionData
.
Segment
(
/* startTimeMs= */
8765
,
/* endTimeMs= */
12485
,
/* speedDivisor= */
16
));
/* startTimeMs= */
8765
,
/* endTimeMs= */
12485
,
/* speedDivisor= */
16
));
S
efSlowMotion
sefSlowMotionToParcel
=
new
SefSlowMotion
(
segments
);
S
lowMotionData
slowMotionDataToParcel
=
new
SlowMotionData
(
segments
);
Parcel
parcel
=
Parcel
.
obtain
();
Parcel
parcel
=
Parcel
.
obtain
();
s
efSlowMotion
ToParcel
.
writeToParcel
(
parcel
,
/* flags= */
0
);
s
lowMotionData
ToParcel
.
writeToParcel
(
parcel
,
/* flags= */
0
);
parcel
.
setDataPosition
(
0
);
parcel
.
setDataPosition
(
0
);
S
efSlowMotion
sefSlowMotionFromParcel
=
SefSlowMotion
.
CREATOR
.
createFromParcel
(
parcel
);
S
lowMotionData
slowMotionDataFromParcel
=
SlowMotionData
.
CREATOR
.
createFromParcel
(
parcel
);
assertThat
(
s
efSlowMotionFromParcel
).
isEqualTo
(
sefSlowMotion
ToParcel
);
assertThat
(
s
lowMotionDataFromParcel
).
isEqualTo
(
slowMotionData
ToParcel
);
parcel
.
recycle
();
parcel
.
recycle
();
}
}
@Test
@Test
public
void
segment_parcelable
()
{
public
void
segment_parcelable
()
{
S
efSlowMotion
.
Segment
segmentToParcel
=
S
lowMotionData
.
Segment
segmentToParcel
=
new
S
efSlowMotion
.
Segment
(
new
S
lowMotionData
.
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
);
S
efSlowMotion
.
Segment
segmentFromParcel
=
S
lowMotionData
.
Segment
segmentFromParcel
=
S
efSlowMotion
.
Segment
.
CREATOR
.
createFromParcel
(
parcel
);
S
lowMotionData
.
Segment
.
CREATOR
.
createFromParcel
(
parcel
);
assertThat
(
segmentFromParcel
).
isEqualTo
(
segmentToParcel
);
assertThat
(
segmentFromParcel
).
isEqualTo
(
segmentToParcel
);
parcel
.
recycle
();
parcel
.
recycle
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment