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
988225cd
authored
Oct 31, 2018
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'Comcast-task/add_force_highest_bitrate_test' into dev-v2
parents
02573297
097c045b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
11 deletions
library/core/src/test/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelectorTest.java
library/core/src/test/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelectorTest.java
View file @
988225cd
...
@@ -1061,30 +1061,66 @@ public final class DefaultTrackSelectorTest {
...
@@ -1061,30 +1061,66 @@ public final class DefaultTrackSelectorTest {
}
}
/**
/**
* Tests that track selector will select
audio tracks with lower bitrate when {@link Parameters}
* Tests that track selector will select
the lowest bitrate supported audio track when {@link
*
indicate lowest bitrate preference, even when tracks are within capabilities
.
*
Parameters#forceLowestBitrate} is set
.
*/
*/
@Test
@Test
public
void
testSelectTracksWithinCapabilitiesAndForceLowestBitrateSelectLowerBitrate
()
public
void
testSelectTracksWithinCapabilitiesAndForceLowestBitrateSelectLowerBitrate
()
throws
Exception
{
throws
Exception
{
Format
lowerBitrateFormat
=
Format
unsupportedLowBitrateFormat
=
buildAudioFormatWithBitrate
(
"unsupportedLowBitrate"
,
5000
);
Format
.
createAudioSampleFormat
(
"audioFormat"
,
MimeTypes
.
AUDIO_AAC
,
null
,
15000
,
Format
lowerBitrateFormat
=
buildAudioFormatWithBitrate
(
"lowBitrate"
,
15000
);
Format
.
NO_VALUE
,
2
,
44100
,
null
,
null
,
0
,
null
);
Format
higherBitrateFormat
=
buildAudioFormatWithBitrate
(
"highBitrate"
,
30000
);
Format
higherBitrateFormat
=
TrackGroupArray
trackGroups
=
Format
.
createAudioSampleFormat
(
"audioFormat"
,
MimeTypes
.
AUDIO_AAC
,
null
,
30000
,
wrapFormats
(
unsupportedLowBitrateFormat
,
lowerBitrateFormat
,
higherBitrateFormat
);
Format
.
NO_VALUE
,
2
,
44100
,
null
,
null
,
0
,
null
);
TrackGroupArray
trackGroups
=
wrapFormats
(
lowerBitrateFormat
,
higherBitrateFormat
);
Map
<
String
,
Integer
>
mappedCapabilities
=
new
HashMap
<>();
mappedCapabilities
.
put
(
unsupportedLowBitrateFormat
.
id
,
FORMAT_EXCEEDS_CAPABILITIES
);
mappedCapabilities
.
put
(
lowerBitrateFormat
.
id
,
FORMAT_HANDLED
);
mappedCapabilities
.
put
(
higherBitrateFormat
.
id
,
FORMAT_HANDLED
);
RendererCapabilities
mappedAudioRendererCapabilities
=
new
FakeMappedRendererCapabilities
(
C
.
TRACK_TYPE_AUDIO
,
mappedCapabilities
);
trackSelector
.
setParameters
(
Parameters
.
DEFAULT
.
buildUpon
().
setForceLowestBitrate
(
true
).
build
());
trackSelector
.
setParameters
(
Parameters
.
DEFAULT
.
buildUpon
().
setForceLowestBitrate
(
true
).
build
());
TrackSelectorResult
result
=
TrackSelectorResult
result
=
trackSelector
.
selectTracks
(
trackSelector
.
selectTracks
(
new
RendererCapabilities
[]
{
ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES
},
new
RendererCapabilities
[]
{
mappedAudioRendererCapabilities
},
trackGroups
,
trackGroups
,
periodId
,
periodId
,
TIMELINE
);
TIMELINE
);
assertFixedSelection
(
result
.
selections
.
get
(
0
),
trackGroups
,
lowerBitrateFormat
);
assertFixedSelection
(
result
.
selections
.
get
(
0
),
trackGroups
,
lowerBitrateFormat
);
}
}
/**
* Tests that track selector will select the highest bitrate supported audio track when {@link
* Parameters#forceHighestSupportedBitrate} is set.
*/
@Test
public
void
testSelectTracksWithinCapabilitiesAndForceHighestBitrateSelectHigherBitrate
()
throws
Exception
{
Format
lowerBitrateFormat
=
buildAudioFormatWithBitrate
(
"lowerBitrateFormat"
,
5000
);
Format
higherBitrateFormat
=
buildAudioFormatWithBitrate
(
"higherBitrateFormat"
,
15000
);
Format
exceedsBitrateFormat
=
buildAudioFormatWithBitrate
(
"exceedsBitrateFormat"
,
30000
);
TrackGroupArray
trackGroups
=
wrapFormats
(
lowerBitrateFormat
,
higherBitrateFormat
,
exceedsBitrateFormat
);
Map
<
String
,
Integer
>
mappedCapabilities
=
new
HashMap
<>();
mappedCapabilities
.
put
(
lowerBitrateFormat
.
id
,
FORMAT_HANDLED
);
mappedCapabilities
.
put
(
higherBitrateFormat
.
id
,
FORMAT_HANDLED
);
mappedCapabilities
.
put
(
exceedsBitrateFormat
.
id
,
FORMAT_EXCEEDS_CAPABILITIES
);
RendererCapabilities
mappedAudioRendererCapabilities
=
new
FakeMappedRendererCapabilities
(
C
.
TRACK_TYPE_AUDIO
,
mappedCapabilities
);
trackSelector
.
setParameters
(
new
ParametersBuilder
().
setForceHighestSupportedBitrate
(
true
).
build
());
TrackSelectorResult
result
=
trackSelector
.
selectTracks
(
new
RendererCapabilities
[]
{
mappedAudioRendererCapabilities
},
singleTrackGroup
(
lowerBitrateFormat
,
higherBitrateFormat
,
exceedsBitrateFormat
),
periodId
,
TIMELINE
);
assertFixedSelection
(
result
.
selections
.
get
(
0
),
trackGroups
,
higherBitrateFormat
);
}
@Test
@Test
public
void
testSelectTracksWithMultipleAudioTracks
()
throws
Exception
{
public
void
testSelectTracksWithMultipleAudioTracks
()
throws
Exception
{
TrackGroupArray
trackGroups
=
singleTrackGroup
(
buildAudioFormat
(
"0"
),
buildAudioFormat
(
"1"
));
TrackGroupArray
trackGroups
=
singleTrackGroup
(
buildAudioFormat
(
"0"
),
buildAudioFormat
(
"1"
));
...
@@ -1472,16 +1508,29 @@ public final class DefaultTrackSelectorTest {
...
@@ -1472,16 +1508,29 @@ public final class DefaultTrackSelectorTest {
return
buildAudioFormat
(
return
buildAudioFormat
(
id
,
id
,
MimeTypes
.
AUDIO_AAC
,
MimeTypes
.
AUDIO_AAC
,
/* bitrate= */
Format
.
NO_VALUE
,
language
,
language
,
selectionFlags
,
selectionFlags
,
/* channelCount= */
2
,
/* channelCount= */
2
,
/* sampleRate= */
44100
);
/* sampleRate= */
44100
);
}
}
private
static
Format
buildAudioFormatWithBitrate
(
String
id
,
int
bitrate
)
{
return
buildAudioFormat
(
id
,
MimeTypes
.
AUDIO_AAC
,
bitrate
,
/* language= */
null
,
/* selectionFlags= */
0
,
/* channelCount= */
2
,
/* sampleRate= */
44100
);
}
private
static
Format
buildAudioFormatWithSampleRate
(
String
id
,
int
sampleRate
)
{
private
static
Format
buildAudioFormatWithSampleRate
(
String
id
,
int
sampleRate
)
{
return
buildAudioFormat
(
return
buildAudioFormat
(
id
,
id
,
MimeTypes
.
AUDIO_AAC
,
MimeTypes
.
AUDIO_AAC
,
/* bitrate= */
Format
.
NO_VALUE
,
/* language= */
null
,
/* language= */
null
,
/* selectionFlags= */
0
,
/* selectionFlags= */
0
,
/* channelCount= */
2
,
/* channelCount= */
2
,
...
@@ -1492,6 +1541,7 @@ public final class DefaultTrackSelectorTest {
...
@@ -1492,6 +1541,7 @@ public final class DefaultTrackSelectorTest {
return
buildAudioFormat
(
return
buildAudioFormat
(
id
,
id
,
MimeTypes
.
AUDIO_AAC
,
MimeTypes
.
AUDIO_AAC
,
/* bitrate= */
Format
.
NO_VALUE
,
/* language= */
null
,
/* language= */
null
,
/* selectionFlags= */
0
,
/* selectionFlags= */
0
,
channelCount
,
channelCount
,
...
@@ -1502,6 +1552,7 @@ public final class DefaultTrackSelectorTest {
...
@@ -1502,6 +1552,7 @@ public final class DefaultTrackSelectorTest {
return
buildAudioFormat
(
return
buildAudioFormat
(
id
,
id
,
mimeType
,
mimeType
,
/* bitrate= */
Format
.
NO_VALUE
,
/* language= */
null
,
/* language= */
null
,
/* selectionFlags= */
0
,
/* selectionFlags= */
0
,
/* channelCount= */
2
,
/* channelCount= */
2
,
...
@@ -1512,6 +1563,7 @@ public final class DefaultTrackSelectorTest {
...
@@ -1512,6 +1563,7 @@ public final class DefaultTrackSelectorTest {
return
buildAudioFormat
(
return
buildAudioFormat
(
id
,
id
,
MimeTypes
.
AUDIO_AAC
,
MimeTypes
.
AUDIO_AAC
,
/* bitrate= */
Format
.
NO_VALUE
,
/* language= */
null
,
/* language= */
null
,
/* selectionFlags= */
0
,
/* selectionFlags= */
0
,
/* channelCount= */
2
,
/* channelCount= */
2
,
...
@@ -1521,6 +1573,7 @@ public final class DefaultTrackSelectorTest {
...
@@ -1521,6 +1573,7 @@ public final class DefaultTrackSelectorTest {
private
static
Format
buildAudioFormat
(
private
static
Format
buildAudioFormat
(
String
id
,
String
id
,
String
mimeType
,
String
mimeType
,
int
bitrate
,
String
language
,
String
language
,
int
selectionFlags
,
int
selectionFlags
,
int
channelCount
,
int
channelCount
,
...
@@ -1529,7 +1582,7 @@ public final class DefaultTrackSelectorTest {
...
@@ -1529,7 +1582,7 @@ public final class DefaultTrackSelectorTest {
id
,
id
,
mimeType
,
mimeType
,
/* codecs= */
null
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
bitrate
,
/* maxInputSize= */
Format
.
NO_VALUE
,
/* maxInputSize= */
Format
.
NO_VALUE
,
channelCount
,
channelCount
,
sampleRate
,
sampleRate
,
...
...
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