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
dedf6071
authored
Jan 18, 2021
by
samrobinson
Committed by
Oliver Woodman
Jan 18, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Enforce stricter SlowMotionData and Segment initialisation checks.
PiperOrigin-RevId: 352389366
parent
4cfb3aff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
2 deletions
library/common/src/main/java/com/google/android/exoplayer2/metadata/mp4/SlowMotionData.java
library/common/src/main/java/com/google/android/exoplayer2/metadata/mp4/SlowMotionData.java
View file @
dedf6071
...
...
@@ -15,6 +15,8 @@
*/
package
com
.
google
.
android
.
exoplayer2
.
metadata
.
mp4
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkArgument
;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
androidx.annotation.Nullable
;
...
...
@@ -45,11 +47,12 @@ public final class SlowMotionData implements Metadata.Entry {
/**
* Creates an instance.
*
* @param startTimeMs See {@link #startTimeMs}.
* @param startTimeMs See {@link #startTimeMs}.
Must be less than endTimeMs.
* @param endTimeMs See {@link #endTimeMs}.
* @param speedDivisor See {@link #speedDivisor}.
*/
public
Segment
(
long
startTimeMs
,
long
endTimeMs
,
int
speedDivisor
)
{
checkArgument
(
startTimeMs
<
endTimeMs
);
this
.
startTimeMs
=
startTimeMs
;
this
.
endTimeMs
=
endTimeMs
;
this
.
speedDivisor
=
speedDivisor
;
...
...
@@ -113,9 +116,15 @@ public final class SlowMotionData implements Metadata.Entry {
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.
*
* <p>The segments must not overlap, that is that the start time of a segment can not be between
* the start and end time of another segment.
*/
public
SlowMotionData
(
List
<
Segment
>
segments
)
{
this
.
segments
=
segments
;
checkArgument
(!
doSegmentsOverlap
(
segments
));
}
@Override
...
...
@@ -164,4 +173,19 @@ public final class SlowMotionData implements Metadata.Entry {
return
new
SlowMotionData
[
size
];
}
};
private
static
boolean
doSegmentsOverlap
(
List
<
Segment
>
segments
)
{
if
(
segments
.
isEmpty
())
{
return
false
;
}
long
previousEndTimeMs
=
segments
.
get
(
0
).
endTimeMs
;
for
(
int
i
=
1
;
i
<
segments
.
size
();
i
++)
{
if
(
segments
.
get
(
i
).
startTimeMs
<
previousEndTimeMs
)
{
return
true
;
}
previousEndTimeMs
=
segments
.
get
(
i
).
endTimeMs
;
}
return
false
;
}
}
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