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
b1b6c8df
authored
Feb 17, 2020
by
kimvde
Committed by
Ian Baker
Feb 17, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add test for seek map duration correction in MP3 index seeker
PiperOrigin-RevId: 295543916
parent
74443f47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
10 deletions
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp3/IndexSeekerTest.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp3/IndexSeekerTest.java
View file @
b1b6c8df
...
...
@@ -16,6 +16,7 @@
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
mp3
;
import
static
com
.
google
.
android
.
exoplayer2
.
extractor
.
mp3
.
Mp3Extractor
.
FLAG_ENABLE_INDEX_SEEKING
;
import
static
com
.
google
.
android
.
exoplayer2
.
testutil
.
TestUtil
.
extractAllSamplesFromFile
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
android.net.Uri
;
...
...
@@ -39,7 +40,8 @@ import org.junit.runner.RunWith;
@RunWith
(
AndroidJUnit4
.
class
)
public
class
IndexSeekerTest
{
private
static
final
String
TEST_FILE
=
"mp3/bear-vbr-xing-header.mp3"
;
private
static
final
String
TEST_FILE_NO_SEEK_TABLE
=
"mp3/bear-vbr-no-seek-table.mp3"
;
private
static
final
int
TEST_FILE_NO_SEEK_TABLE_DURATION
=
2_808_000
;
private
Mp3Extractor
extractor
;
private
FakeExtractorOutput
extractorOutput
;
...
...
@@ -55,18 +57,28 @@ public class IndexSeekerTest {
}
@Test
public
void
mp3ExtractorReads_returnSeekableSeekMap
()
throws
Exception
{
Uri
fileUri
=
TestUtil
.
buildAssetUri
(
TEST_FILE
);
public
void
mp3ExtractorReads_return
s
SeekableSeekMap
()
throws
Exception
{
Uri
fileUri
=
TestUtil
.
buildAssetUri
(
TEST_FILE
_NO_SEEK_TABLE
);
SeekMap
seekMap
=
TestUtil
.
extractSeekMap
(
extractor
,
extractorOutput
,
dataSource
,
fileUri
);
assertThat
(
seekMap
.
getDurationUs
()).
isEqualTo
(
2_808_000
);
assertThat
(
seekMap
.
isSeekable
()).
isTrue
();
}
@Test
public
void
mp3ExtractorReads_correctsInexactDuration
()
throws
Exception
{
FakeExtractorOutput
extractorOutput
=
TestUtil
.
extractAllSamplesFromFile
(
extractor
,
ApplicationProvider
.
getApplicationContext
(),
TEST_FILE_NO_SEEK_TABLE
);
SeekMap
seekMap
=
extractorOutput
.
seekMap
;
assertThat
(
seekMap
.
getDurationUs
()).
isEqualTo
(
TEST_FILE_NO_SEEK_TABLE_DURATION
);
}
@Test
public
void
seeking_handlesSeekToZero
()
throws
Exception
{
String
fileName
=
TEST_FILE
;
String
fileName
=
TEST_FILE
_NO_SEEK_TABLE
;
Uri
fileUri
=
TestUtil
.
buildAssetUri
(
fileName
);
SeekMap
seekMap
=
TestUtil
.
extractSeekMap
(
extractor
,
extractorOutput
,
dataSource
,
fileUri
);
FakeTrackOutput
trackOutput
=
extractorOutput
.
trackOutputs
.
get
(
0
);
...
...
@@ -84,12 +96,12 @@ public class IndexSeekerTest {
@Test
public
void
seeking_handlesSeekToEof
()
throws
Exception
{
String
fileName
=
TEST_FILE
;
String
fileName
=
TEST_FILE
_NO_SEEK_TABLE
;
Uri
fileUri
=
TestUtil
.
buildAssetUri
(
fileName
);
SeekMap
seekMap
=
TestUtil
.
extractSeekMap
(
extractor
,
extractorOutput
,
dataSource
,
fileUri
);
FakeTrackOutput
trackOutput
=
extractorOutput
.
trackOutputs
.
get
(
0
);
long
targetSeekTimeUs
=
seekMap
.
getDurationUs
()
;
long
targetSeekTimeUs
=
TEST_FILE_NO_SEEK_TABLE_DURATION
;
int
extractedFrameIndex
=
TestUtil
.
seekToTimeUs
(
extractor
,
seekMap
,
targetSeekTimeUs
,
dataSource
,
trackOutput
,
fileUri
);
...
...
@@ -102,7 +114,7 @@ public class IndexSeekerTest {
@Test
public
void
seeking_handlesSeekingBackward
()
throws
Exception
{
String
fileName
=
TEST_FILE
;
String
fileName
=
TEST_FILE
_NO_SEEK_TABLE
;
Uri
fileUri
=
TestUtil
.
buildAssetUri
(
fileName
);
SeekMap
seekMap
=
TestUtil
.
extractSeekMap
(
extractor
,
extractorOutput
,
dataSource
,
fileUri
);
FakeTrackOutput
trackOutput
=
extractorOutput
.
trackOutputs
.
get
(
0
);
...
...
@@ -122,7 +134,7 @@ public class IndexSeekerTest {
@Test
public
void
seeking_handlesSeekingForward
()
throws
Exception
{
String
fileName
=
TEST_FILE
;
String
fileName
=
TEST_FILE
_NO_SEEK_TABLE
;
Uri
fileUri
=
TestUtil
.
buildAssetUri
(
fileName
);
SeekMap
seekMap
=
TestUtil
.
extractSeekMap
(
extractor
,
extractorOutput
,
dataSource
,
fileUri
);
FakeTrackOutput
trackOutput
=
extractorOutput
.
trackOutputs
.
get
(
0
);
...
...
@@ -171,7 +183,7 @@ public class IndexSeekerTest {
private
static
FakeTrackOutput
getExpectedTrackOutput
(
String
fileName
)
throws
IOException
,
InterruptedException
{
return
TestUtil
.
extractAllSamplesFromFile
(
return
extractAllSamplesFromFile
(
new
Mp3Extractor
(
FLAG_ENABLE_INDEX_SEEKING
),
ApplicationProvider
.
getApplicationContext
(),
fileName
)
...
...
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