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
5aeaa6e8
authored
Jun 18, 2019
by
aquilescanta
Committed by
Oliver Woodman
Jun 18, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix application of maxAudioBitrate for adaptive audio track groups
Issue:#6006 PiperOrigin-RevId: 253781533
parent
b89dc8fb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
2 deletions
RELEASENOTES.md
library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java
library/core/src/test/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelectorTest.java
RELEASENOTES.md
View file @
5aeaa6e8
...
...
@@ -23,6 +23,8 @@
(
[
#6036
](
https://github.com/google/ExoPlayer/pull/6036
)
).
*
Gracefully handle revoked
`ACCESS_NETWORK_STATE`
permission
(
[
#6019
](
https://github.com/google/ExoPlayer/issues/6019
)
).
*
Fix application of
`maxAudioBitrate`
for adaptive audio track groups
(
[
#6006
](
https://github.com/google/ExoPlayer/issues/6006
)
).
### 2.10.2 ###
...
...
library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java
View file @
5aeaa6e8
...
...
@@ -1934,6 +1934,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
getAdaptiveAudioTracks
(
selectedGroup
,
formatSupports
[
selectedGroupIndex
],
params
.
maxAudioBitrate
,
params
.
allowAudioMixedMimeTypeAdaptiveness
,
params
.
allowAudioMixedSampleRateAdaptiveness
);
if
(
adaptiveTracks
.
length
>
0
)
{
...
...
@@ -1951,6 +1952,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
private
static
int
[]
getAdaptiveAudioTracks
(
TrackGroup
group
,
int
[]
formatSupport
,
int
maxAudioBitrate
,
boolean
allowMixedMimeTypeAdaptiveness
,
boolean
allowMixedSampleRateAdaptiveness
)
{
int
selectedConfigurationTrackCount
=
0
;
...
...
@@ -1967,6 +1969,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
group
,
formatSupport
,
configuration
,
maxAudioBitrate
,
allowMixedMimeTypeAdaptiveness
,
allowMixedSampleRateAdaptiveness
);
if
(
configurationCount
>
selectedConfigurationTrackCount
)
{
...
...
@@ -1977,13 +1980,16 @@ public class DefaultTrackSelector extends MappingTrackSelector {
}
if
(
selectedConfigurationTrackCount
>
1
)
{
Assertions
.
checkNotNull
(
selectedConfiguration
);
int
[]
adaptiveIndices
=
new
int
[
selectedConfigurationTrackCount
];
int
index
=
0
;
for
(
int
i
=
0
;
i
<
group
.
length
;
i
++)
{
Format
format
=
group
.
getFormat
(
i
);
if
(
isSupportedAdaptiveAudioTrack
(
group
.
getFormat
(
i
)
,
format
,
formatSupport
[
i
],
Assertions
.
checkNotNull
(
selectedConfiguration
),
selectedConfiguration
,
maxAudioBitrate
,
allowMixedMimeTypeAdaptiveness
,
allowMixedSampleRateAdaptiveness
))
{
adaptiveIndices
[
index
++]
=
i
;
...
...
@@ -1998,6 +2004,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
TrackGroup
group
,
int
[]
formatSupport
,
AudioConfigurationTuple
configuration
,
int
maxAudioBitrate
,
boolean
allowMixedMimeTypeAdaptiveness
,
boolean
allowMixedSampleRateAdaptiveness
)
{
int
count
=
0
;
...
...
@@ -2006,6 +2013,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
group
.
getFormat
(
i
),
formatSupport
[
i
],
configuration
,
maxAudioBitrate
,
allowMixedMimeTypeAdaptiveness
,
allowMixedSampleRateAdaptiveness
))
{
count
++;
...
...
@@ -2018,9 +2026,11 @@ public class DefaultTrackSelector extends MappingTrackSelector {
Format
format
,
int
formatSupport
,
AudioConfigurationTuple
configuration
,
int
maxAudioBitrate
,
boolean
allowMixedMimeTypeAdaptiveness
,
boolean
allowMixedSampleRateAdaptiveness
)
{
return
isSupported
(
formatSupport
,
false
)
&&
(
format
.
bitrate
==
Format
.
NO_VALUE
||
format
.
bitrate
<=
maxAudioBitrate
)
&&
(
format
.
channelCount
!=
Format
.
NO_VALUE
&&
format
.
channelCount
==
configuration
.
channelCount
)
&&
(
allowMixedMimeTypeAdaptiveness
...
...
library/core/src/test/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelectorTest.java
View file @
5aeaa6e8
...
...
@@ -341,6 +341,76 @@ public final class DefaultTrackSelectorTest {
assertFixedSelection
(
result
.
selections
.
get
(
0
),
trackGroups
,
formatWithSelectionFlag
);
}
/** Tests that adaptive audio track selections respect the maximum audio bitrate. */
public
void
testSelectAdaptiveAudioTrackGroupWithMaxBitrate
()
throws
ExoPlaybackException
{
Format
format128k
=
Format
.
createAudioSampleFormat
(
/* id= */
"128"
,
/* sampleMimeType= */
MimeTypes
.
AUDIO_AAC
,
/* codecs= */
"mp4a.40.2"
,
/* bitrate= */
128
*
1024
,
/* maxInputSize= */
Format
.
NO_VALUE
,
/* channelCount= */
2
,
/* sampleRate= */
44100
,
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
);
Format
format192k
=
Format
.
createAudioSampleFormat
(
/* id= */
"192"
,
/* sampleMimeType= */
MimeTypes
.
AUDIO_AAC
,
/* codecs= */
"mp4a.40.2"
,
/* bitrate= */
192
*
1024
,
/* maxInputSize= */
Format
.
NO_VALUE
,
/* channelCount= */
2
,
/* sampleRate= */
44100
,
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
);
Format
format256k
=
Format
.
createAudioSampleFormat
(
/* id= */
"256"
,
/* sampleMimeType= */
MimeTypes
.
AUDIO_AAC
,
/* codecs= */
"mp4a.40.2"
,
/* bitrate= */
256
*
1024
,
/* maxInputSize= */
Format
.
NO_VALUE
,
/* channelCount= */
2
,
/* sampleRate= */
44100
,
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
);
RendererCapabilities
[]
rendererCapabilities
=
{
ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES
};
TrackGroupArray
trackGroups
=
new
TrackGroupArray
(
new
TrackGroup
(
format192k
,
format128k
,
format256k
));
TrackSelectorResult
result
=
trackSelector
.
selectTracks
(
rendererCapabilities
,
trackGroups
,
periodId
,
TIMELINE
);
assertAdaptiveSelection
(
result
.
selections
.
get
(
0
),
trackGroups
.
get
(
0
),
0
,
1
,
2
);
trackSelector
.
setParameters
(
trackSelector
.
buildUponParameters
().
setMaxAudioBitrate
(
256
*
1024
-
1
));
result
=
trackSelector
.
selectTracks
(
rendererCapabilities
,
trackGroups
,
periodId
,
TIMELINE
);
assertAdaptiveSelection
(
result
.
selections
.
get
(
0
),
trackGroups
.
get
(
0
),
0
,
1
);
trackSelector
.
setParameters
(
trackSelector
.
buildUponParameters
().
setMaxAudioBitrate
(
192
*
1024
));
result
=
trackSelector
.
selectTracks
(
rendererCapabilities
,
trackGroups
,
periodId
,
TIMELINE
);
assertAdaptiveSelection
(
result
.
selections
.
get
(
0
),
trackGroups
.
get
(
0
),
0
,
1
);
trackSelector
.
setParameters
(
trackSelector
.
buildUponParameters
().
setMaxAudioBitrate
(
192
*
1024
-
1
));
result
=
trackSelector
.
selectTracks
(
rendererCapabilities
,
trackGroups
,
periodId
,
TIMELINE
);
assertAdaptiveSelection
(
result
.
selections
.
get
(
0
),
trackGroups
.
get
(
0
),
1
);
trackSelector
.
setParameters
(
trackSelector
.
buildUponParameters
().
setMaxAudioBitrate
(
10
));
result
=
trackSelector
.
selectTracks
(
rendererCapabilities
,
trackGroups
,
periodId
,
TIMELINE
);
assertAdaptiveSelection
(
result
.
selections
.
get
(
0
),
trackGroups
.
get
(
0
),
1
);
}
/**
* Tests that track selector will select audio track with language that match preferred language
* given by {@link Parameters}.
...
...
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