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
f5025bfc
authored
Feb 13, 2020
by
kimvde
Committed by
Oliver Woodman
Feb 13, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Share seek tests between FLAC extractors
PiperOrigin-RevId: 294893303
parent
ebce903a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
105 deletions
extensions/flac/src/androidTest/java/com/google/android/exoplayer2/ext/flac/FlacBinarySearchSeekerTest.java
extensions/flac/src/androidTest/java/com/google/android/exoplayer2/ext/flac/FlacExtractorSeekTest.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/flac/FlacExtractorSeekTest.java
extensions/flac/src/androidTest/java/com/google/android/exoplayer2/ext/flac/FlacBinarySearchSeekerTest.java
deleted
100644 → 0
View file @
ebce903a
/*
* Copyright (C) 2018 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
.
ext
.
flac
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
org
.
junit
.
Assert
.
fail
;
import
androidx.test.core.app.ApplicationProvider
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.ext.flac.FlacBinarySearchSeeker.OutputFrameHolder
;
import
com.google.android.exoplayer2.extractor.SeekMap
;
import
com.google.android.exoplayer2.testutil.FakeExtractorInput
;
import
com.google.android.exoplayer2.testutil.TestUtil
;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
/** Unit test for {@link FlacBinarySearchSeeker}. */
@RunWith
(
AndroidJUnit4
.
class
)
public
final
class
FlacBinarySearchSeekerTest
{
private
static
final
String
NOSEEKTABLE_FLAC
=
"flac/bear_one_metadata_block.flac"
;
private
static
final
int
DURATION_US
=
2_741_000
;
@Before
public
void
setUp
()
{
if
(!
FlacLibrary
.
isAvailable
())
{
fail
(
"Flac library not available."
);
}
}
@Test
public
void
testGetSeekMap_returnsSeekMapWithCorrectDuration
()
throws
IOException
,
FlacDecoderException
,
InterruptedException
{
byte
[]
data
=
TestUtil
.
getByteArray
(
ApplicationProvider
.
getApplicationContext
(),
NOSEEKTABLE_FLAC
);
FakeExtractorInput
input
=
new
FakeExtractorInput
.
Builder
().
setData
(
data
).
build
();
FlacDecoderJni
decoderJni
=
new
FlacDecoderJni
();
decoderJni
.
setData
(
input
);
OutputFrameHolder
outputFrameHolder
=
new
OutputFrameHolder
(
ByteBuffer
.
allocateDirect
(
0
));
FlacBinarySearchSeeker
seeker
=
new
FlacBinarySearchSeeker
(
decoderJni
.
decodeStreamMetadata
(),
/* firstFramePosition= */
0
,
data
.
length
,
decoderJni
,
outputFrameHolder
);
SeekMap
seekMap
=
seeker
.
getSeekMap
();
assertThat
(
seekMap
).
isNotNull
();
assertThat
(
seekMap
.
getDurationUs
()).
isEqualTo
(
DURATION_US
);
assertThat
(
seekMap
.
isSeekable
()).
isTrue
();
}
@Test
public
void
testSetSeekTargetUs_returnsSeekPending
()
throws
IOException
,
FlacDecoderException
,
InterruptedException
{
byte
[]
data
=
TestUtil
.
getByteArray
(
ApplicationProvider
.
getApplicationContext
(),
NOSEEKTABLE_FLAC
);
FakeExtractorInput
input
=
new
FakeExtractorInput
.
Builder
().
setData
(
data
).
build
();
FlacDecoderJni
decoderJni
=
new
FlacDecoderJni
();
decoderJni
.
setData
(
input
);
OutputFrameHolder
outputFrameHolder
=
new
OutputFrameHolder
(
ByteBuffer
.
allocateDirect
(
0
));
FlacBinarySearchSeeker
seeker
=
new
FlacBinarySearchSeeker
(
decoderJni
.
decodeStreamMetadata
(),
/* firstFramePosition= */
0
,
data
.
length
,
decoderJni
,
outputFrameHolder
);
seeker
.
setSeekTargetUs
(
/* timeUs= */
1000
);
assertThat
(
seeker
.
isSeeking
()).
isTrue
();
}
}
extensions/flac/src/androidTest/java/com/google/android/exoplayer2/ext/flac/FlacExtractorSeekTest.java
View file @
f5025bfc
This diff is collapsed.
Click to expand it.
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/flac/FlacExtractorSeekTest.java
View file @
f5025bfc
...
...
@@ -30,7 +30,6 @@ import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import
com.google.android.exoplayer2.util.Util
;
import
java.io.IOException
;
import
java.util.List
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -43,18 +42,11 @@ public class FlacExtractorSeekTest {
private
static
final
String
TEST_FILE_UNSEEKABLE
=
"flac/bear_no_seek_table_no_num_samples.flac"
;
private
static
final
int
DURATION_US
=
2_741_000
;
private
FlacExtractor
extractor
;
private
FakeExtractorOutput
extractorOutput
;
private
DefaultDataSource
dataSource
;
@Before
public
void
setUp
()
throws
Exception
{
extractor
=
new
FlacExtractor
();
extractorOutput
=
new
FakeExtractorOutput
();
dataSource
=
new
DefaultDataSourceFactory
(
ApplicationProvider
.
getApplicationContext
(),
"UserAgent"
)
.
createDataSource
();
}
private
FlacExtractor
extractor
=
new
FlacExtractor
();
private
FakeExtractorOutput
extractorOutput
=
new
FakeExtractorOutput
();
private
DefaultDataSource
dataSource
=
new
DefaultDataSourceFactory
(
ApplicationProvider
.
getApplicationContext
(),
"UserAgent"
)
.
createDataSource
();
@Test
public
void
flacExtractorReads_seekTable_returnSeekableSeekMap
()
...
...
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