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
ab559eb3
authored
May 05, 2020
by
bachinger
Committed by
Oliver Woodman
May 05, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add media item property to Timeline.Window
PiperOrigin-RevId: 309949800
parent
81a13a63
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
20 deletions
library/core/src/main/java/com/google/android/exoplayer2/Timeline.java
library/core/src/test/java/com/google/android/exoplayer2/TimelineTest.java
library/core/src/main/java/com/google/android/exoplayer2/Timeline.java
View file @
ab559eb3
...
...
@@ -129,8 +129,11 @@ public abstract class Timeline {
*/
public
Object
uid
;
/** A tag for the window. Not necessarily unique. */
@Nullable
public
Object
tag
;
/** @deprecated Use {@link #mediaItem} instead. */
@Deprecated
@Nullable
public
Object
tag
;
/** The {@link MediaItem} associated to the window. Not necessarily unique. */
@Nullable
public
MediaItem
mediaItem
;
/** The manifest of the window. May be {@code null}. */
@Nullable
public
Object
manifest
;
...
...
@@ -214,7 +217,12 @@ public abstract class Timeline {
uid
=
SINGLE_WINDOW_UID
;
}
/** Sets the data held by this window. */
/**
* @deprecated Use {@link #set(Object, MediaItem, Object, long, long, long, boolean, boolean,
* boolean, long, long, int, int, long)} instead.
*/
@SuppressWarnings
(
"deprecation"
)
@Deprecated
public
Window
set
(
Object
uid
,
@Nullable
Object
tag
,
...
...
@@ -230,8 +238,48 @@ public abstract class Timeline {
int
firstPeriodIndex
,
int
lastPeriodIndex
,
long
positionInFirstPeriodUs
)
{
this
.
uid
=
uid
;
set
(
uid
,
/* mediaItem= */
null
,
manifest
,
presentationStartTimeMs
,
windowStartTimeMs
,
elapsedRealtimeEpochOffsetMs
,
isSeekable
,
isDynamic
,
isLive
,
defaultPositionUs
,
durationUs
,
firstPeriodIndex
,
lastPeriodIndex
,
positionInFirstPeriodUs
);
this
.
tag
=
tag
;
return
this
;
}
/** Sets the data held by this window. */
@SuppressWarnings
(
"deprecation"
)
public
Window
set
(
Object
uid
,
@Nullable
MediaItem
mediaItem
,
@Nullable
Object
manifest
,
long
presentationStartTimeMs
,
long
windowStartTimeMs
,
long
elapsedRealtimeEpochOffsetMs
,
boolean
isSeekable
,
boolean
isDynamic
,
boolean
isLive
,
long
defaultPositionUs
,
long
durationUs
,
int
firstPeriodIndex
,
int
lastPeriodIndex
,
long
positionInFirstPeriodUs
)
{
this
.
uid
=
uid
;
this
.
mediaItem
=
mediaItem
;
this
.
tag
=
mediaItem
!=
null
&&
mediaItem
.
playbackProperties
!=
null
?
mediaItem
.
playbackProperties
.
tag
:
null
;
this
.
manifest
=
manifest
;
this
.
presentationStartTimeMs
=
presentationStartTimeMs
;
this
.
windowStartTimeMs
=
windowStartTimeMs
;
...
...
@@ -319,6 +367,7 @@ public abstract class Timeline {
Window
that
=
(
Window
)
obj
;
return
Util
.
areEqual
(
uid
,
that
.
uid
)
&&
Util
.
areEqual
(
tag
,
that
.
tag
)
&&
Util
.
areEqual
(
mediaItem
,
that
.
mediaItem
)
&&
Util
.
areEqual
(
manifest
,
that
.
manifest
)
&&
presentationStartTimeMs
==
that
.
presentationStartTimeMs
&&
windowStartTimeMs
==
that
.
windowStartTimeMs
...
...
@@ -339,6 +388,7 @@ public abstract class Timeline {
int
result
=
7
;
result
=
31
*
result
+
uid
.
hashCode
();
result
=
31
*
result
+
(
tag
==
null
?
0
:
tag
.
hashCode
());
result
=
31
*
result
+
(
mediaItem
==
null
?
0
:
mediaItem
.
hashCode
());
result
=
31
*
result
+
(
manifest
==
null
?
0
:
manifest
.
hashCode
());
result
=
31
*
result
+
(
int
)
(
presentationStartTimeMs
^
(
presentationStartTimeMs
>>>
32
));
result
=
31
*
result
+
(
int
)
(
windowStartTimeMs
^
(
windowStartTimeMs
>>>
32
));
...
...
library/core/src/test/java/com/google/android/exoplayer2/TimelineTest.java
View file @
ab559eb3
...
...
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
androidx.annotation.Nullable
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.testutil.FakeTimeline
;
import
com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition
;
...
...
@@ -61,13 +62,19 @@ public class TimelineTest {
TimelineAsserts
.
assertNextWindowIndices
(
timeline
,
Player
.
REPEAT_MODE_ALL
,
false
,
0
);
}
@SuppressWarnings
(
"deprecation"
)
// Tests the deprecated window.tag property.
@Test
public
void
windowEquals
()
{
MediaItem
mediaItem
=
new
MediaItem
.
Builder
().
setUri
(
"uri"
).
setTag
(
new
Object
()).
build
();
Timeline
.
Window
window
=
new
Timeline
.
Window
();
assertThat
(
window
).
isEqualTo
(
new
Timeline
.
Window
());
Timeline
.
Window
otherWindow
=
new
Timeline
.
Window
();
otherWindow
.
tag
=
new
Object
();
otherWindow
.
mediaItem
=
mediaItem
;
assertThat
(
window
).
isNotEqualTo
(
otherWindow
);
otherWindow
=
new
Timeline
.
Window
();
otherWindow
.
tag
=
mediaItem
.
playbackProperties
.
tag
;
assertThat
(
window
).
isNotEqualTo
(
otherWindow
);
otherWindow
=
new
Timeline
.
Window
();
...
...
@@ -118,19 +125,31 @@ public class TimelineTest {
otherWindow
.
positionInFirstPeriodUs
=
C
.
TIME_UNSET
;
assertThat
(
window
).
isNotEqualTo
(
otherWindow
);
window
.
uid
=
new
Object
();
window
.
tag
=
new
Object
();
window
.
manifest
=
new
Object
();
window
.
presentationStartTimeMs
=
C
.
TIME_UNSET
;
window
.
windowStartTimeMs
=
C
.
TIME_UNSET
;
window
.
isSeekable
=
true
;
window
.
isDynamic
=
true
;
window
.
isLive
=
true
;
window
.
defaultPositionUs
=
C
.
TIME_UNSET
;
window
.
durationUs
=
C
.
TIME_UNSET
;
window
.
firstPeriodIndex
=
1
;
window
.
lastPeriodIndex
=
1
;
window
.
positionInFirstPeriodUs
=
C
.
TIME_UNSET
;
window
=
populateWindow
(
mediaItem
,
mediaItem
.
playbackProperties
.
tag
);
otherWindow
=
otherWindow
.
set
(
window
.
uid
,
window
.
mediaItem
,
window
.
manifest
,
window
.
presentationStartTimeMs
,
window
.
windowStartTimeMs
,
window
.
elapsedRealtimeEpochOffsetMs
,
window
.
isSeekable
,
window
.
isDynamic
,
window
.
isLive
,
window
.
defaultPositionUs
,
window
.
durationUs
,
window
.
firstPeriodIndex
,
window
.
lastPeriodIndex
,
window
.
positionInFirstPeriodUs
);
assertThat
(
window
).
isEqualTo
(
otherWindow
);
}
@SuppressWarnings
(
"deprecation"
)
@Test
public
void
windowSet_withTag
()
{
Timeline
.
Window
window
=
populateWindow
(
/* mediaItem= */
null
,
new
Object
());
Timeline
.
Window
otherWindow
=
new
Timeline
.
Window
();
otherWindow
=
otherWindow
.
set
(
window
.
uid
,
...
...
@@ -156,9 +175,9 @@ public class TimelineTest {
Timeline
.
Window
otherWindow
=
new
Timeline
.
Window
();
assertThat
(
window
.
hashCode
()).
isEqualTo
(
otherWindow
.
hashCode
());
window
.
tag
=
new
Object
();
window
.
mediaItem
=
new
MediaItem
.
Builder
().
setMediaId
(
"mediaId"
).
setTag
(
new
Object
()).
build
();
assertThat
(
window
.
hashCode
()).
isNotEqualTo
(
otherWindow
.
hashCode
());
otherWindow
.
tag
=
window
.
tag
;
otherWindow
.
mediaItem
=
window
.
mediaItem
;
assertThat
(
window
.
hashCode
()).
isEqualTo
(
otherWindow
.
hashCode
());
}
...
...
@@ -209,4 +228,25 @@ public class TimelineTest {
otherPeriod
.
windowIndex
=
period
.
windowIndex
;
assertThat
(
period
.
hashCode
()).
isEqualTo
(
otherPeriod
.
hashCode
());
}
@SuppressWarnings
(
"deprecation"
)
// Populates the deprecated window.tag property.
private
static
Timeline
.
Window
populateWindow
(
@Nullable
MediaItem
mediaItem
,
@Nullable
Object
tag
)
{
Timeline
.
Window
window
=
new
Timeline
.
Window
();
window
.
uid
=
new
Object
();
window
.
tag
=
tag
;
window
.
mediaItem
=
mediaItem
;
window
.
manifest
=
new
Object
();
window
.
presentationStartTimeMs
=
C
.
TIME_UNSET
;
window
.
windowStartTimeMs
=
C
.
TIME_UNSET
;
window
.
isSeekable
=
true
;
window
.
isDynamic
=
true
;
window
.
isLive
=
true
;
window
.
defaultPositionUs
=
C
.
TIME_UNSET
;
window
.
durationUs
=
C
.
TIME_UNSET
;
window
.
firstPeriodIndex
=
1
;
window
.
lastPeriodIndex
=
1
;
window
.
positionInFirstPeriodUs
=
C
.
TIME_UNSET
;
return
window
;
}
}
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