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
56c1c3f6
authored
Nov 22, 2017
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Revert "Make ExtractorMediaSource timeline dynamic until duration is set"
This reverts commit
b688a562
.
parent
74569bba
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
102 deletions
library/core/src/androidTest/java/com/google/android/exoplayer2/source/ClippingMediaSourceTest.java
library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaSource.java
library/core/src/main/java/com/google/android/exoplayer2/source/SinglePeriodTimeline.java
library/core/src/main/java/com/google/android/exoplayer2/source/SingleSampleMediaSource.java
library/core/src/test/java/com/google/android/exoplayer2/source/SinglePeriodTimelineTest.java
library/core/src/androidTest/java/com/google/android/exoplayer2/source/ClippingMediaSourceTest.java
View file @
56c1c3f6
...
...
@@ -45,7 +45,7 @@ public final class ClippingMediaSourceTest extends InstrumentationTestCase {
}
public
void
testNoClipping
()
{
Timeline
timeline
=
new
SinglePeriodTimeline
(
C
.
msToUs
(
TEST_PERIOD_DURATION_US
),
true
,
false
);
Timeline
timeline
=
new
SinglePeriodTimeline
(
C
.
msToUs
(
TEST_PERIOD_DURATION_US
),
true
);
Timeline
clippedTimeline
=
getClippedTimeline
(
timeline
,
0
,
TEST_PERIOD_DURATION_US
);
...
...
@@ -56,7 +56,7 @@ public final class ClippingMediaSourceTest extends InstrumentationTestCase {
}
public
void
testClippingUnseekableWindowThrows
()
{
Timeline
timeline
=
new
SinglePeriodTimeline
(
C
.
msToUs
(
TEST_PERIOD_DURATION_US
),
false
,
false
);
Timeline
timeline
=
new
SinglePeriodTimeline
(
C
.
msToUs
(
TEST_PERIOD_DURATION_US
),
false
);
// If the unseekable window isn't clipped, clipping succeeds.
getClippedTimeline
(
timeline
,
0
,
TEST_PERIOD_DURATION_US
);
...
...
@@ -70,7 +70,7 @@ public final class ClippingMediaSourceTest extends InstrumentationTestCase {
}
public
void
testClippingStart
()
{
Timeline
timeline
=
new
SinglePeriodTimeline
(
C
.
msToUs
(
TEST_PERIOD_DURATION_US
),
true
,
false
);
Timeline
timeline
=
new
SinglePeriodTimeline
(
C
.
msToUs
(
TEST_PERIOD_DURATION_US
),
true
);
Timeline
clippedTimeline
=
getClippedTimeline
(
timeline
,
TEST_CLIP_AMOUNT_US
,
TEST_PERIOD_DURATION_US
);
...
...
@@ -81,7 +81,7 @@ public final class ClippingMediaSourceTest extends InstrumentationTestCase {
}
public
void
testClippingEnd
()
{
Timeline
timeline
=
new
SinglePeriodTimeline
(
C
.
msToUs
(
TEST_PERIOD_DURATION_US
),
true
,
false
);
Timeline
timeline
=
new
SinglePeriodTimeline
(
C
.
msToUs
(
TEST_PERIOD_DURATION_US
),
true
);
Timeline
clippedTimeline
=
getClippedTimeline
(
timeline
,
0
,
TEST_PERIOD_DURATION_US
-
TEST_CLIP_AMOUNT_US
);
...
...
@@ -92,7 +92,7 @@ public final class ClippingMediaSourceTest extends InstrumentationTestCase {
}
public
void
testClippingStartAndEnd
()
{
Timeline
timeline
=
new
SinglePeriodTimeline
(
C
.
msToUs
(
TEST_PERIOD_DURATION_US
),
true
,
false
);
Timeline
timeline
=
new
SinglePeriodTimeline
(
C
.
msToUs
(
TEST_PERIOD_DURATION_US
),
true
);
Timeline
clippedTimeline
=
getClippedTimeline
(
timeline
,
TEST_CLIP_AMOUNT_US
,
TEST_PERIOD_DURATION_US
-
TEST_CLIP_AMOUNT_US
*
2
);
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaSource.java
View file @
56c1c3f6
...
...
@@ -204,11 +204,8 @@ public final class ExtractorMediaSource implements MediaSource, ExtractorMediaPe
private
void
notifySourceInfoRefreshed
(
long
durationUs
,
boolean
isSeekable
)
{
timelineDurationUs
=
durationUs
;
timelineIsSeekable
=
isSeekable
;
// If the duration is currently unset, we expect to be able to update the window when its
// duration eventually becomes known.
boolean
isDynamic
=
timelineDurationUs
==
C
.
TIME_UNSET
;
sourceListener
.
onSourceInfoRefreshed
(
this
,
new
SinglePeriodTimeline
(
timelineDurationUs
,
timelineIsSeekable
,
isDynamic
),
null
);
sourceListener
.
onSourceInfoRefreshed
(
this
,
new
SinglePeriodTimeline
(
timelineDurationUs
,
timelineIsSeekable
),
null
);
}
}
library/core/src/main/java/com/google/android/exoplayer2/source/SinglePeriodTimeline.java
View file @
56c1c3f6
...
...
@@ -36,14 +36,14 @@ public final class SinglePeriodTimeline extends Timeline {
private
final
boolean
isDynamic
;
/**
* Creates a timeline containing a single period and a window that spans it.
* Creates a timeline of one period of known duration, and a static window starting at zero and
* extending to that duration.
*
* @param durationUs The duration of the period, in microseconds.
* @param isSeekable Whether seeking is supported within the period.
* @param isDynamic Whether the window may change when the timeline is updated.
*/
public
SinglePeriodTimeline
(
long
durationUs
,
boolean
isSeekable
,
boolean
isDynamic
)
{
this
(
durationUs
,
durationUs
,
0
,
0
,
isSeekable
,
isDynamic
);
public
SinglePeriodTimeline
(
long
durationUs
,
boolean
isSeekable
)
{
this
(
durationUs
,
durationUs
,
0
,
0
,
isSeekable
,
false
);
}
/**
...
...
@@ -63,7 +63,7 @@ public final class SinglePeriodTimeline extends Timeline {
long
windowPositionInPeriodUs
,
long
windowDefaultStartPositionUs
,
boolean
isSeekable
,
boolean
isDynamic
)
{
this
(
C
.
TIME_UNSET
,
C
.
TIME_UNSET
,
periodDurationUs
,
windowDurationUs
,
windowPositionInPeriodUs
,
windowDefaultStartPositionUs
,
isSeekable
,
isDynamic
);
windowDefaultStartPositionUs
,
isSeekable
,
isDynamic
);
}
/**
...
...
@@ -106,16 +106,11 @@ public final class SinglePeriodTimeline extends Timeline {
Assertions
.
checkIndex
(
windowIndex
,
0
,
1
);
Object
id
=
setIds
?
ID
:
null
;
long
windowDefaultStartPositionUs
=
this
.
windowDefaultStartPositionUs
;
if
(
isDynamic
&&
defaultPositionProjectionUs
!=
0
)
{
if
(
windowDurationUs
==
C
.
TIME_UNSET
)
{
// Don't allow projection into a window that has an unknown duration.
if
(
isDynamic
)
{
windowDefaultStartPositionUs
+=
defaultPositionProjectionUs
;
if
(
windowDefaultStartPositionUs
>
windowDurationUs
)
{
// The projection takes us beyond the end of the live window.
windowDefaultStartPositionUs
=
C
.
TIME_UNSET
;
}
else
{
windowDefaultStartPositionUs
+=
defaultPositionProjectionUs
;
if
(
windowDefaultStartPositionUs
>
windowDurationUs
)
{
// The projection takes us beyond the end of the window.
windowDefaultStartPositionUs
=
C
.
TIME_UNSET
;
}
}
}
return
window
.
set
(
id
,
presentationStartTimeMs
,
windowStartTimeMs
,
isSeekable
,
isDynamic
,
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/SingleSampleMediaSource.java
View file @
56c1c3f6
...
...
@@ -110,7 +110,7 @@ public final class SingleSampleMediaSource implements MediaSource {
this
.
eventListener
=
eventListener
;
this
.
eventSourceId
=
eventSourceId
;
this
.
treatLoadErrorsAsEndOfStream
=
treatLoadErrorsAsEndOfStream
;
timeline
=
new
SinglePeriodTimeline
(
durationUs
,
true
,
false
);
timeline
=
new
SinglePeriodTimeline
(
durationUs
,
true
);
}
// MediaSource implementation.
...
...
library/core/src/test/java/com/google/android/exoplayer2/source/SinglePeriodTimelineTest.java
deleted
100644 → 0
View file @
74569bba
/*
* Copyright (C) 2017 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
.
source
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Timeline.Period
;
import
com.google.android.exoplayer2.Timeline.Window
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.robolectric.RobolectricTestRunner
;
import
org.robolectric.annotation.Config
;
/**
* Unit test for {@link SinglePeriodTimeline}.
*/
@RunWith
(
RobolectricTestRunner
.
class
)
@Config
(
sdk
=
Config
.
TARGET_SDK
,
manifest
=
Config
.
NONE
)
public
final
class
SinglePeriodTimelineTest
{
private
Window
window
;
private
Period
period
;
@Before
public
void
setUp
()
throws
Exception
{
window
=
new
Window
();
period
=
new
Period
();
}
@Test
public
void
testGetPeriodPositionDynamicWindowUnknownDuration
()
{
SinglePeriodTimeline
timeline
=
new
SinglePeriodTimeline
(
C
.
TIME_UNSET
,
false
,
true
);
// Should return null with any positive position projection.
Pair
<
Integer
,
Long
>
position
=
timeline
.
getPeriodPosition
(
window
,
period
,
0
,
C
.
TIME_UNSET
,
1
);
assertThat
(
position
).
isNull
();
// Should return (0, 0) without a position projection.
position
=
timeline
.
getPeriodPosition
(
window
,
period
,
0
,
C
.
TIME_UNSET
,
0
);
assertThat
(
position
.
first
).
isEqualTo
(
0
);
assertThat
(
position
.
second
).
isEqualTo
(
0
);
}
@Test
public
void
testGetPeriodPositionDynamicWindowKnownDuration
()
{
long
windowDurationUs
=
1000
;
SinglePeriodTimeline
timeline
=
new
SinglePeriodTimeline
(
windowDurationUs
,
windowDurationUs
,
0
,
0
,
false
,
true
);
// Should return null with a positive position projection beyond window duration.
Pair
<
Integer
,
Long
>
position
=
timeline
.
getPeriodPosition
(
window
,
period
,
0
,
C
.
TIME_UNSET
,
windowDurationUs
+
1
);
assertThat
(
position
).
isNull
();
// Should return (0, duration) with a projection equal to window duration.
position
=
timeline
.
getPeriodPosition
(
window
,
period
,
0
,
C
.
TIME_UNSET
,
windowDurationUs
);
assertThat
(
position
.
first
).
isEqualTo
(
0
);
assertThat
(
position
.
second
).
isEqualTo
(
windowDurationUs
);
// Should return (0, 0) without a position projection.
position
=
timeline
.
getPeriodPosition
(
window
,
period
,
0
,
C
.
TIME_UNSET
,
0
);
assertThat
(
position
.
first
).
isEqualTo
(
0
);
assertThat
(
position
.
second
).
isEqualTo
(
0
);
}
}
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