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
6f62b499
authored
Nov 25, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Merge seek/playback positions in ChunkSource interface.
parent
f11a204b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
22 deletions
library/src/androidTest/java/com/google/android/exoplayer/dash/DashChunkSourceTest.java
library/src/main/java/com/google/android/exoplayer/chunk/ChunkSampleSource.java
library/src/main/java/com/google/android/exoplayer/chunk/ChunkSource.java
library/src/main/java/com/google/android/exoplayer/chunk/SingleSampleChunkSource.java
library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java
library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java
library/src/androidTest/java/com/google/android/exoplayer/dash/DashChunkSourceTest.java
View file @
6f62b499
...
@@ -128,7 +128,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase {
...
@@ -128,7 +128,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase {
ChunkOperationHolder
out
=
new
ChunkOperationHolder
();
ChunkOperationHolder
out
=
new
ChunkOperationHolder
();
// request first chunk; should get back initialization chunk
// request first chunk; should get back initialization chunk
chunkSource
.
getChunkOperation
(
queue
,
0
,
0
,
out
);
chunkSource
.
getChunkOperation
(
queue
,
0
,
out
);
assertNotNull
(
out
.
chunk
);
assertNotNull
(
out
.
chunk
);
assertNotNull
(((
InitializationChunk
)
out
.
chunk
).
dataSpec
);
assertNotNull
(((
InitializationChunk
)
out
.
chunk
).
dataSpec
);
...
@@ -386,7 +386,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase {
...
@@ -386,7 +386,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase {
private
static
void
checkLiveEdgeConsistency
(
DashChunkSource
chunkSource
,
List
<
MediaChunk
>
queue
,
private
static
void
checkLiveEdgeConsistency
(
DashChunkSource
chunkSource
,
List
<
MediaChunk
>
queue
,
ChunkOperationHolder
out
,
long
seekPositionMs
,
long
availableRangeStartMs
,
ChunkOperationHolder
out
,
long
seekPositionMs
,
long
availableRangeStartMs
,
long
availableRangeEndMs
,
long
chunkStartTimeMs
,
long
chunkEndTimeMs
)
{
long
availableRangeEndMs
,
long
chunkStartTimeMs
,
long
chunkEndTimeMs
)
{
chunkSource
.
getChunkOperation
(
queue
,
seekPositionMs
*
1000
,
0
,
out
);
chunkSource
.
getChunkOperation
(
queue
,
seekPositionMs
*
1000
,
out
);
TimeRange
availableRange
=
chunkSource
.
getAvailableRange
();
TimeRange
availableRange
=
chunkSource
.
getAvailableRange
();
checkAvailableRange
(
availableRange
,
availableRangeStartMs
*
1000
,
availableRangeEndMs
*
1000
);
checkAvailableRange
(
availableRange
,
availableRangeStartMs
*
1000
,
availableRangeEndMs
*
1000
);
if
(
chunkStartTimeMs
<
availableRangeEndMs
)
{
if
(
chunkStartTimeMs
<
availableRangeEndMs
)
{
...
@@ -487,7 +487,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase {
...
@@ -487,7 +487,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase {
// request "eleventh" chunk; this chunk isn't available yet, so we should get null
// request "eleventh" chunk; this chunk isn't available yet, so we should get null
out
.
chunk
=
null
;
out
.
chunk
=
null
;
chunkSource
.
getChunkOperation
(
queue
,
seekPositionMs
*
1000
,
0
,
out
);
chunkSource
.
getChunkOperation
(
queue
,
seekPositionMs
*
1000
,
out
);
assertNull
(
out
.
chunk
);
assertNull
(
out
.
chunk
);
}
}
...
...
library/src/main/java/com/google/android/exoplayer/chunk/ChunkSampleSource.java
View file @
6f62b499
...
@@ -533,7 +533,8 @@ public class ChunkSampleSource implements SampleSource, SampleSourceReader, Load
...
@@ -533,7 +533,8 @@ public class ChunkSampleSource implements SampleSource, SampleSourceReader, Load
private
void
doChunkOperation
()
{
private
void
doChunkOperation
()
{
currentLoadableHolder
.
endOfStream
=
false
;
currentLoadableHolder
.
endOfStream
=
false
;
currentLoadableHolder
.
queueSize
=
readOnlyMediaChunks
.
size
();
currentLoadableHolder
.
queueSize
=
readOnlyMediaChunks
.
size
();
chunkSource
.
getChunkOperation
(
readOnlyMediaChunks
,
pendingResetPositionUs
,
downstreamPositionUs
,
chunkSource
.
getChunkOperation
(
readOnlyMediaChunks
,
pendingResetPositionUs
!=
NO_RESET_PENDING
?
pendingResetPositionUs
:
downstreamPositionUs
,
currentLoadableHolder
);
currentLoadableHolder
);
loadingFinished
=
currentLoadableHolder
.
endOfStream
;
loadingFinished
=
currentLoadableHolder
.
endOfStream
;
}
}
...
...
library/src/main/java/com/google/android/exoplayer/chunk/ChunkSource.java
View file @
6f62b499
...
@@ -92,9 +92,9 @@ public interface ChunkSource {
...
@@ -92,9 +92,9 @@ public interface ChunkSource {
* This method should only be called when the source is enabled.
* This method should only be called when the source is enabled.
*
*
* @param queue A representation of the currently buffered {@link MediaChunk}s.
* @param queue A representation of the currently buffered {@link MediaChunk}s.
* @param
seekPositionUs If the queue is empty, this parameter must specify the seek position. If
* @param
playbackPositionUs The current playback position. If the queue is empty then this
*
the queue is non-empty then this parameter is ignored.
*
parameter is the position from which playback is expected to start (or restart) and hence
*
@param playbackPositionUs The current playbac
k position.
*
should be interpreted as a see
k position.
* @param out A holder for the next operation, whose {@link ChunkOperationHolder#endOfStream} is
* @param out A holder for the next operation, whose {@link ChunkOperationHolder#endOfStream} is
* initially set to false, whose {@link ChunkOperationHolder#queueSize} is initially equal to
* initially set to false, whose {@link ChunkOperationHolder#queueSize} is initially equal to
* the length of the queue, and whose {@link ChunkOperationHolder#chunk} is initially equal to
* the length of the queue, and whose {@link ChunkOperationHolder#chunk} is initially equal to
...
@@ -103,8 +103,8 @@ public interface ChunkSource {
...
@@ -103,8 +103,8 @@ public interface ChunkSource {
* unchanged. Note that leaving the chunk unchanged is both preferred and more efficient than
* unchanged. Note that leaving the chunk unchanged is both preferred and more efficient than
* replacing it with a new but identical chunk.
* replacing it with a new but identical chunk.
*/
*/
void
getChunkOperation
(
List
<?
extends
MediaChunk
>
queue
,
long
see
kPositionUs
,
void
getChunkOperation
(
List
<?
extends
MediaChunk
>
queue
,
long
playbac
kPositionUs
,
long
playbackPositionUs
,
ChunkOperationHolder
out
);
ChunkOperationHolder
out
);
/**
/**
* Invoked when the {@link ChunkSampleSource} has finished loading a chunk obtained from this
* Invoked when the {@link ChunkSampleSource} has finished loading a chunk obtained from this
...
...
library/src/main/java/com/google/android/exoplayer/chunk/SingleSampleChunkSource.java
View file @
6f62b499
...
@@ -80,8 +80,8 @@ public final class SingleSampleChunkSource implements ChunkSource {
...
@@ -80,8 +80,8 @@ public final class SingleSampleChunkSource implements ChunkSource {
}
}
@Override
@Override
public
void
getChunkOperation
(
List
<?
extends
MediaChunk
>
queue
,
long
see
kPositionUs
,
public
void
getChunkOperation
(
List
<?
extends
MediaChunk
>
queue
,
long
playbac
kPositionUs
,
long
playbackPositionUs
,
ChunkOperationHolder
out
)
{
ChunkOperationHolder
out
)
{
if
(!
queue
.
isEmpty
())
{
if
(!
queue
.
isEmpty
())
{
// We've already provided the single sample.
// We've already provided the single sample.
out
.
endOfStream
=
true
;
out
.
endOfStream
=
true
;
...
...
library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java
View file @
6f62b499
...
@@ -346,8 +346,8 @@ public class DashChunkSource implements ChunkSource, Output {
...
@@ -346,8 +346,8 @@ public class DashChunkSource implements ChunkSource, Output {
}
}
@Override
@Override
public
final
void
getChunkOperation
(
List
<?
extends
MediaChunk
>
queue
,
long
see
kPositionUs
,
public
final
void
getChunkOperation
(
List
<?
extends
MediaChunk
>
queue
,
long
playbac
kPositionUs
,
long
playbackPositionUs
,
ChunkOperationHolder
out
)
{
ChunkOperationHolder
out
)
{
if
(
fatalError
!=
null
)
{
if
(
fatalError
!=
null
)
{
out
.
chunk
=
null
;
out
.
chunk
=
null
;
return
;
return
;
...
@@ -389,16 +389,16 @@ public class DashChunkSource implements ChunkSource, Output {
...
@@ -389,16 +389,16 @@ public class DashChunkSource implements ChunkSource, Output {
if
(
startAtLiveEdge
)
{
if
(
startAtLiveEdge
)
{
// We want live streams to start at the live edge instead of the beginning of the
// We want live streams to start at the live edge instead of the beginning of the
// manifest
// manifest
see
kPositionUs
=
Math
.
max
(
availableRangeValues
[
0
],
playbac
kPositionUs
=
Math
.
max
(
availableRangeValues
[
0
],
availableRangeValues
[
1
]
-
liveEdgeLatencyUs
);
availableRangeValues
[
1
]
-
liveEdgeLatencyUs
);
}
else
{
}
else
{
// we subtract 1 from the upper bound because it's exclusive for that bound
// we subtract 1 from the upper bound because it's exclusive for that bound
seekPositionUs
=
Math
.
min
(
see
kPositionUs
,
availableRangeValues
[
1
]
-
1
);
playbackPositionUs
=
Math
.
min
(
playbac
kPositionUs
,
availableRangeValues
[
1
]
-
1
);
seekPositionUs
=
Math
.
max
(
see
kPositionUs
,
availableRangeValues
[
0
]);
playbackPositionUs
=
Math
.
max
(
playbac
kPositionUs
,
availableRangeValues
[
0
]);
}
}
}
}
periodHolder
=
findPeriodHolder
(
see
kPositionUs
);
periodHolder
=
findPeriodHolder
(
playbac
kPositionUs
);
startingNewPeriod
=
true
;
startingNewPeriod
=
true
;
}
else
{
}
else
{
if
(
startAtLiveEdge
)
{
if
(
startAtLiveEdge
)
{
...
@@ -476,7 +476,7 @@ public class DashChunkSource implements ChunkSource, Output {
...
@@ -476,7 +476,7 @@ public class DashChunkSource implements ChunkSource, Output {
return
;
return
;
}
}
int
segmentNum
=
queue
.
isEmpty
()
?
representationHolder
.
getSegmentNum
(
see
kPositionUs
)
int
segmentNum
=
queue
.
isEmpty
()
?
representationHolder
.
getSegmentNum
(
playbac
kPositionUs
)
:
startingNewPeriod
?
representationHolder
.
getFirstAvailableSegmentNum
()
:
startingNewPeriod
?
representationHolder
.
getFirstAvailableSegmentNum
()
:
queue
.
get
(
out
.
queueSize
-
1
).
chunkIndex
+
1
;
:
queue
.
get
(
out
.
queueSize
-
1
).
chunkIndex
+
1
;
Chunk
nextMediaChunk
=
newMediaChunk
(
periodHolder
,
representationHolder
,
dataSource
,
Chunk
nextMediaChunk
=
newMediaChunk
(
periodHolder
,
representationHolder
,
dataSource
,
...
...
library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java
View file @
6f62b499
...
@@ -236,8 +236,8 @@ public class SmoothStreamingChunkSource implements ChunkSource,
...
@@ -236,8 +236,8 @@ public class SmoothStreamingChunkSource implements ChunkSource,
}
}
@Override
@Override
public
final
void
getChunkOperation
(
List
<?
extends
MediaChunk
>
queue
,
long
see
kPositionUs
,
public
final
void
getChunkOperation
(
List
<?
extends
MediaChunk
>
queue
,
long
playbac
kPositionUs
,
long
playbackPositionUs
,
ChunkOperationHolder
out
)
{
ChunkOperationHolder
out
)
{
if
(
fatalError
!=
null
)
{
if
(
fatalError
!=
null
)
{
out
.
chunk
=
null
;
out
.
chunk
=
null
;
return
;
return
;
...
@@ -281,9 +281,9 @@ public class SmoothStreamingChunkSource implements ChunkSource,
...
@@ -281,9 +281,9 @@ public class SmoothStreamingChunkSource implements ChunkSource,
int
chunkIndex
;
int
chunkIndex
;
if
(
queue
.
isEmpty
())
{
if
(
queue
.
isEmpty
())
{
if
(
live
)
{
if
(
live
)
{
see
kPositionUs
=
getLiveSeekPosition
(
currentManifest
,
liveEdgeLatencyUs
);
playbac
kPositionUs
=
getLiveSeekPosition
(
currentManifest
,
liveEdgeLatencyUs
);
}
}
chunkIndex
=
streamElement
.
getChunkIndex
(
see
kPositionUs
);
chunkIndex
=
streamElement
.
getChunkIndex
(
playbac
kPositionUs
);
}
else
{
}
else
{
MediaChunk
previous
=
queue
.
get
(
out
.
queueSize
-
1
);
MediaChunk
previous
=
queue
.
get
(
out
.
queueSize
-
1
);
chunkIndex
=
previous
.
chunkIndex
+
1
-
currentManifestChunkOffset
;
chunkIndex
=
previous
.
chunkIndex
+
1
-
currentManifestChunkOffset
;
...
...
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