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
74050210
authored
Aug 01, 2019
by
olly
Committed by
Oliver Woodman
Aug 01, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Some no-op cleanup for DefaultOggSeeker
PiperOrigin-RevId: 261102008
parent
4438cdb2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
60 deletions
library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java
View file @
74050210
...
@@ -21,6 +21,7 @@ import com.google.android.exoplayer2.extractor.ExtractorInput;
...
@@ -21,6 +21,7 @@ import com.google.android.exoplayer2.extractor.ExtractorInput;
import
com.google.android.exoplayer2.extractor.SeekMap
;
import
com.google.android.exoplayer2.extractor.SeekMap
;
import
com.google.android.exoplayer2.extractor.SeekPoint
;
import
com.google.android.exoplayer2.extractor.SeekPoint
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Util
;
import
java.io.EOFException
;
import
java.io.EOFException
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -206,39 +207,32 @@ import java.io.IOException;
...
@@ -206,39 +207,32 @@ import java.io.IOException;
return
-(
pageHeader
.
granulePosition
+
2
);
return
-(
pageHeader
.
granulePosition
+
2
);
}
}
private
long
getEstimatedPosition
(
long
position
,
long
granuleDistance
,
long
offset
)
{
/**
position
+=
(
granuleDistance
*
(
endPosition
-
startPosition
)
/
totalGranules
)
-
offset
;
* Skips to the position of the start of the page containing the {@code targetGranule} and returns
if
(
position
<
startPosition
)
{
* the granule of the page previous to the target page.
position
=
startPosition
;
*
}
* @param input The {@link ExtractorInput} to read from.
if
(
position
>=
endPosition
)
{
* @param targetGranule The target granule.
position
=
endPosition
-
1
;
* @param currentGranule The current granule or -1 if it's unknown.
}
* @return The granule of the prior page or the {@code currentGranule} if there isn't a prior
return
position
;
* page.
}
* @throws ParserException If populating the page header fails.
* @throws IOException If reading from the input fails.
private
class
OggSeekMap
implements
SeekMap
{
* @throws InterruptedException If interrupted while reading from the input.
*/
@Override
@VisibleForTesting
public
boolean
isSeekable
()
{
long
skipToPageOfGranule
(
ExtractorInput
input
,
long
targetGranule
,
long
currentGranule
)
return
true
;
throws
IOException
,
InterruptedException
{
}
pageHeader
.
populate
(
input
,
false
);
while
(
pageHeader
.
granulePosition
<
targetGranule
)
{
@Override
input
.
skipFully
(
pageHeader
.
headerSize
+
pageHeader
.
bodySize
);
public
SeekPoints
getSeekPoints
(
long
timeUs
)
{
// Store in a member field to be able to resume after IOExceptions.
if
(
timeUs
==
0
)
{
currentGranule
=
pageHeader
.
granulePosition
;
return
new
SeekPoints
(
new
SeekPoint
(
0
,
startPosition
));
// Peek next header.
}
pageHeader
.
populate
(
input
,
false
);
long
granule
=
streamReader
.
convertTimeToGranule
(
timeUs
);
long
estimatedPosition
=
getEstimatedPosition
(
startPosition
,
granule
,
DEFAULT_OFFSET
);
return
new
SeekPoints
(
new
SeekPoint
(
timeUs
,
estimatedPosition
));
}
@Override
public
long
getDurationUs
()
{
return
streamReader
.
convertGranuleToTime
(
totalGranules
);
}
}
input
.
resetPeekPosition
();
return
currentGranule
;
}
}
/**
/**
...
@@ -266,8 +260,7 @@ import java.io.IOException;
...
@@ -266,8 +260,7 @@ import java.io.IOException;
* @throws IOException If peeking/reading from the input fails.
* @throws IOException If peeking/reading from the input fails.
* @throws InterruptedException If interrupted while peeking/reading from the input.
* @throws InterruptedException If interrupted while peeking/reading from the input.
*/
*/
@VisibleForTesting
private
boolean
skipToNextPage
(
ExtractorInput
input
,
long
limit
)
boolean
skipToNextPage
(
ExtractorInput
input
,
long
limit
)
throws
IOException
,
InterruptedException
{
throws
IOException
,
InterruptedException
{
limit
=
Math
.
min
(
limit
+
3
,
endPosition
);
limit
=
Math
.
min
(
limit
+
3
,
endPosition
);
byte
[]
buffer
=
new
byte
[
2048
];
byte
[]
buffer
=
new
byte
[
2048
];
...
@@ -317,32 +310,27 @@ import java.io.IOException;
...
@@ -317,32 +310,27 @@ import java.io.IOException;
return
pageHeader
.
granulePosition
;
return
pageHeader
.
granulePosition
;
}
}
/**
private
final
class
OggSeekMap
implements
SeekMap
{
* Skips to the position of the start of the page containing the {@code targetGranule} and returns
* the granule of the page previous to the target page.
@Override
*
public
boolean
isSeekable
()
{
* @param input The {@link ExtractorInput} to read from.
return
true
;
* @param targetGranule The target granule.
* @param currentGranule The current granule or -1 if it's unknown.
* @return The granule of the prior page or the {@code currentGranule} if there isn't a prior
* page.
* @throws ParserException If populating the page header fails.
* @throws IOException If reading from the input fails.
* @throws InterruptedException If interrupted while reading from the input.
*/
@VisibleForTesting
long
skipToPageOfGranule
(
ExtractorInput
input
,
long
targetGranule
,
long
currentGranule
)
throws
IOException
,
InterruptedException
{
pageHeader
.
populate
(
input
,
false
);
while
(
pageHeader
.
granulePosition
<
targetGranule
)
{
input
.
skipFully
(
pageHeader
.
headerSize
+
pageHeader
.
bodySize
);
// Store in a member field to be able to resume after IOExceptions.
currentGranule
=
pageHeader
.
granulePosition
;
// Peek next header.
pageHeader
.
populate
(
input
,
false
);
}
}
input
.
resetPeekPosition
();
return
currentGranule
;
}
@Override
public
SeekPoints
getSeekPoints
(
long
timeUs
)
{
long
targetGranule
=
streamReader
.
convertTimeToGranule
(
timeUs
);
long
estimatedPosition
=
startPosition
+
(
targetGranule
*
(
endPosition
-
startPosition
)
/
totalGranules
)
-
DEFAULT_OFFSET
;
estimatedPosition
=
Util
.
constrainValue
(
estimatedPosition
,
startPosition
,
endPosition
-
1
);
return
new
SeekPoints
(
new
SeekPoint
(
timeUs
,
estimatedPosition
));
}
@Override
public
long
getDurationUs
()
{
return
streamReader
.
convertGranuleToTime
(
totalGranules
);
}
}
}
}
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