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
41c4295a
authored
Jan 16, 2017
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix build break + cleanup
parent
a418b132
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
17 deletions
library/src/main/java/com/google/android/exoplayer2/extractor/DefaultTrackOutput.java
library/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java
library/src/main/java/com/google/android/exoplayer2/extractor/DefaultTrackOutput.java
View file @
41c4295a
...
@@ -226,29 +226,37 @@ public final class DefaultTrackOutput implements TrackOutput {
...
@@ -226,29 +226,37 @@ public final class DefaultTrackOutput implements TrackOutput {
}
}
/**
/**
* Attempts to skip to the keyframe before the specified time, if it's present in the buffer.
* Attempts to skip to the keyframe before or at the specified time. Succeeds only if the buffer
* contains a keyframe with a timestamp of {@code timeUs} or earlier, and if {@code timeUs} falls
* within the currently buffered media.
* <p>
* This method is equivalent to {@code skipToKeyframeBefore(timeUs, false)}.
*
*
* @param timeUs The seek time.
* @param timeUs The seek time.
* @param skipToLastKey Skip to last key regardless the seek time is out of range .
* @return Whether the skip was successful.
* @return Whether the skip was successful.
*/
*/
public
boolean
skipToKeyframeBefore
(
long
timeUs
,
boolean
skipToLastKey
)
{
public
boolean
skipToKeyframeBefore
(
long
timeUs
)
{
long
nextOffset
=
infoQueue
.
skipToKeyframeBefore
(
timeUs
,
skipToLastKey
);
return
skipToKeyframeBefore
(
timeUs
,
false
);
if
(
nextOffset
==
C
.
POSITION_UNSET
)
{
return
false
;
}
dropDownstreamTo
(
nextOffset
);
return
true
;
}
}
/**
/**
* Attempts to skip to the keyframe before the specified time, if it's present in the buffer.
* Attempts to skip to the keyframe before or at the specified time. Succeeds only if the buffer
* contains a keyframe with a timestamp of {@code timeUs} or earlier. If
* {@code allowTimeBeyondBuffer} is {@code false} then it is also required that {@code timeUs}
* falls within the buffer.
*
*
* @param timeUs The seek time.
* @param timeUs The seek time.
* @param allowTimeBeyondBuffer Whether the skip can succeed if {@code timeUs} is beyond the end
* of the buffer.
* @return Whether the skip was successful.
* @return Whether the skip was successful.
*/
*/
public
boolean
skipToKeyframeBefore
(
long
timeUs
)
{
public
boolean
skipToKeyframeBefore
(
long
timeUs
,
boolean
allowTimeBeyondBuffer
)
{
return
infoQueue
.
skipToKeyframeBefore
(
timeUs
,
false
);
long
nextOffset
=
infoQueue
.
skipToKeyframeBefore
(
timeUs
,
allowTimeBeyondBuffer
);
if
(
nextOffset
==
C
.
POSITION_UNSET
)
{
return
false
;
}
dropDownstreamTo
(
nextOffset
);
return
true
;
}
}
/**
/**
...
@@ -786,18 +794,22 @@ public final class DefaultTrackOutput implements TrackOutput {
...
@@ -786,18 +794,22 @@ public final class DefaultTrackOutput implements TrackOutput {
}
}
/**
/**
* Attempts to locate the keyframe before the specified time, if it's present in the buffer.
* Attempts to locate the keyframe before or at the specified time. If
* {@code allowTimeBeyondBuffer} is {@code false} then it is also required that {@code timeUs}
* falls within the buffer.
*
*
* @param timeUs The seek time.
* @param timeUs The seek time.
* @param allowTimeBeyondBuffer Whether the skip can succeed if {@code timeUs} is beyond the end
* of the buffer.
* @return The offset of the keyframe's data if the keyframe was present.
* @return The offset of the keyframe's data if the keyframe was present.
* {@link C#POSITION_UNSET} otherwise.
* {@link C#POSITION_UNSET} otherwise.
*/
*/
public
synchronized
long
skipToKeyframeBefore
(
long
timeUs
,
boolean
skipToLastKey
)
{
public
synchronized
long
skipToKeyframeBefore
(
long
timeUs
,
boolean
allowTimeBeyondBuffer
)
{
if
(
queueSize
==
0
||
timeUs
<
timesUs
[
relativeReadIndex
])
{
if
(
queueSize
==
0
||
timeUs
<
timesUs
[
relativeReadIndex
])
{
return
C
.
POSITION_UNSET
;
return
C
.
POSITION_UNSET
;
}
}
if
(
timeUs
>
largestQueuedTimestampUs
&&
!
skipToLastKey
)
{
if
(
timeUs
>
largestQueuedTimestampUs
&&
!
allowTimeBeyondBuffer
)
{
return
C
.
POSITION_UNSET
;
return
C
.
POSITION_UNSET
;
}
}
...
...
library/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java
View file @
41c4295a
...
@@ -122,8 +122,8 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
...
@@ -122,8 +122,8 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
public
void
seekToUs
(
long
positionUs
)
{
public
void
seekToUs
(
long
positionUs
)
{
lastSeekPositionUs
=
positionUs
;
lastSeekPositionUs
=
positionUs
;
// If we're not pending a reset, see if we can seek within the sample queue.
// If we're not pending a reset, see if we can seek within the sample queue.
boolean
seekInsideBuffer
=
!
isPendingReset
()
&&
boolean
seekInsideBuffer
=
!
isPendingReset
()
sampleQueue
.
skipToKeyframeBefore
(
positionUs
,
(
positionUs
<
getNextLoadPositionUs
()
));
&&
sampleQueue
.
skipToKeyframeBefore
(
positionUs
,
positionUs
<
getNextLoadPositionUs
(
));
if
(
seekInsideBuffer
)
{
if
(
seekInsideBuffer
)
{
// We succeeded. All we need to do is discard any chunks that we've moved past.
// We succeeded. All we need to do is discard any chunks that we've moved past.
while
(
mediaChunks
.
size
()
>
1
while
(
mediaChunks
.
size
()
>
1
...
...
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