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
f25bcedf
authored
Dec 05, 2019
by
bachinger
Committed by
Oliver Woodman
Dec 06, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Playlist API: submit ahead some files of the playlist API CL
PiperOrigin-RevId: 283988536
parent
aa2e9ffc
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
105 additions
and
8 deletions
extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/FakePlayer.java
extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoaderTest.java
library/core/src/main/java/com/google/android/exoplayer2/Timeline.java
library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaSource.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoHostedTest.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/NoUidTimeline.java
extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/FakePlayer.java
View file @
f25bcedf
...
...
@@ -30,7 +30,6 @@ import java.util.ArrayList;
private
final
Timeline
.
Period
period
;
private
final
Timeline
timeline
;
private
boolean
prepared
;
@Player
.
State
private
int
state
;
private
boolean
playWhenReady
;
private
long
position
;
...
...
@@ -48,12 +47,10 @@ import java.util.ArrayList;
}
/** Sets the timeline on this fake player, which notifies listeners with the changed timeline. */
public
void
updateTimeline
(
Timeline
timeline
)
{
public
void
updateTimeline
(
Timeline
timeline
,
@TimelineChangeReason
int
reason
)
{
for
(
Player
.
EventListener
listener
:
listeners
)
{
listener
.
onTimelineChanged
(
timeline
,
prepared
?
TIMELINE_CHANGE_REASON_DYNAMIC
:
TIMELINE_CHANGE_REASON_PREPARED
);
listener
.
onTimelineChanged
(
timeline
,
reason
);
}
prepared
=
true
;
}
/**
...
...
extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoaderTest.java
View file @
f25bcedf
...
...
@@ -286,7 +286,9 @@ public class ImaAdsLoaderTest {
public
void
onAdPlaybackState
(
AdPlaybackState
adPlaybackState
)
{
adPlaybackState
=
adPlaybackState
.
withAdDurationsUs
(
adDurationsUs
);
this
.
adPlaybackState
=
adPlaybackState
;
fakeExoPlayer
.
updateTimeline
(
new
SinglePeriodAdTimeline
(
contentTimeline
,
adPlaybackState
));
fakeExoPlayer
.
updateTimeline
(
new
SinglePeriodAdTimeline
(
contentTimeline
,
adPlaybackState
),
Player
.
TIMELINE_CHANGE_REASON_DYNAMIC
);
}
@Override
...
...
library/core/src/main/java/com/google/android/exoplayer2/Timeline.java
View file @
f25bcedf
...
...
@@ -905,4 +905,50 @@ public abstract class Timeline {
* @return The unique id of the period.
*/
public
abstract
Object
getUidOfPeriod
(
int
periodIndex
);
@Override
public
boolean
equals
(
@Nullable
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(!(
obj
instanceof
Timeline
))
{
return
false
;
}
Timeline
other
=
(
Timeline
)
obj
;
if
(
other
.
getWindowCount
()
!=
getWindowCount
()
||
other
.
getPeriodCount
()
!=
getPeriodCount
())
{
return
false
;
}
Timeline
.
Window
window
=
new
Timeline
.
Window
();
Timeline
.
Period
period
=
new
Timeline
.
Period
();
Timeline
.
Window
otherWindow
=
new
Timeline
.
Window
();
Timeline
.
Period
otherPeriod
=
new
Timeline
.
Period
();
for
(
int
i
=
0
;
i
<
getWindowCount
();
i
++)
{
if
(!
getWindow
(
i
,
window
).
equals
(
other
.
getWindow
(
i
,
otherWindow
)))
{
return
false
;
}
}
for
(
int
i
=
0
;
i
<
getPeriodCount
();
i
++)
{
if
(!
getPeriod
(
i
,
period
,
/* setIds= */
true
)
.
equals
(
other
.
getPeriod
(
i
,
otherPeriod
,
/* setIds= */
true
)))
{
return
false
;
}
}
return
true
;
}
@Override
public
int
hashCode
()
{
Window
window
=
new
Window
();
Period
period
=
new
Period
();
int
result
=
7
;
result
=
31
*
result
+
getWindowCount
();
for
(
int
i
=
0
;
i
<
getWindowCount
();
i
++)
{
result
=
31
*
result
+
getWindow
(
i
,
window
).
hashCode
();
}
result
=
31
*
result
+
getPeriodCount
();
for
(
int
i
=
0
;
i
<
getPeriodCount
();
i
++)
{
result
=
31
*
result
+
getPeriod
(
i
,
period
,
/* setIds= */
true
).
hashCode
();
}
return
result
;
}
}
library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaSource.java
View file @
f25bcedf
...
...
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source;
import
android.util.Pair
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.VisibleForTesting
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.Timeline.Window
;
...
...
@@ -314,7 +315,8 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
}
/** Dummy placeholder timeline with one dynamic window with a period of indeterminate duration. */
private
static
final
class
DummyTimeline
extends
Timeline
{
@VisibleForTesting
public
static
final
class
DummyTimeline
extends
Timeline
{
@Nullable
private
final
Object
tag
;
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoHostedTest.java
View file @
f25bcedf
...
...
@@ -141,7 +141,8 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
pendingSchedule
=
null
;
}
DrmSessionManager
<
FrameworkMediaCrypto
>
drmSessionManager
=
buildDrmSessionManager
(
userAgent
);
player
.
prepare
(
buildSource
(
host
,
Util
.
getUserAgent
(
host
,
userAgent
),
drmSessionManager
));
player
.
setMediaItem
(
buildSource
(
host
,
Util
.
getUserAgent
(
host
,
userAgent
),
drmSessionManager
));
player
.
prepare
();
}
@Override
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/NoUidTimeline.java
0 → 100644
View file @
f25bcedf
/*
* Copyright (C) 2019 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
google
.
android
.
exoplayer2
.
testutil
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.source.ForwardingTimeline
;
/**
* A timeline which wraps another timeline and overrides all window and period uids to 0. This is
* useful for testing timeline equality without taking uids into account.
*/
/* package */
class
NoUidTimeline
extends
ForwardingTimeline
{
/**
* Creates an instance.
*
* @param timeline The underlying timeline.
*/
public
NoUidTimeline
(
Timeline
timeline
)
{
super
(
timeline
);
}
@Override
public
Window
getWindow
(
int
windowIndex
,
Window
window
,
long
defaultPositionProjectionUs
)
{
timeline
.
getWindow
(
windowIndex
,
window
,
defaultPositionProjectionUs
);
window
.
uid
=
0
;
return
window
;
}
@Override
public
Period
getPeriod
(
int
periodIndex
,
Period
period
,
boolean
setIds
)
{
timeline
.
getPeriod
(
periodIndex
,
period
,
setIds
);
period
.
uid
=
0
;
return
period
;
}
}
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