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
4b33d3c8
authored
Sep 20, 2018
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Cleanup
parent
2a235184
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
63 deletions
library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java
library/core/src/test/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelectorTest.java
library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java
View file @
4b33d3c8
...
@@ -174,6 +174,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -174,6 +174,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
private
boolean
allowNonSeamlessAdaptiveness
;
private
boolean
allowNonSeamlessAdaptiveness
;
private
int
maxVideoWidth
;
private
int
maxVideoWidth
;
private
int
maxVideoHeight
;
private
int
maxVideoHeight
;
private
int
maxVideoFrameRate
;
private
int
maxVideoBitrate
;
private
int
maxVideoBitrate
;
private
boolean
exceedVideoConstraintsIfNecessary
;
private
boolean
exceedVideoConstraintsIfNecessary
;
private
boolean
exceedRendererCapabilitiesIfNecessary
;
private
boolean
exceedRendererCapabilitiesIfNecessary
;
...
@@ -181,7 +182,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -181,7 +182,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
private
int
viewportHeight
;
private
int
viewportHeight
;
private
boolean
viewportOrientationMayChange
;
private
boolean
viewportOrientationMayChange
;
private
int
tunnelingAudioSessionId
;
private
int
tunnelingAudioSessionId
;
private
int
maxFrameRate
;
/** Creates a builder with default initial values. */
/** Creates a builder with default initial values. */
public
ParametersBuilder
()
{
public
ParametersBuilder
()
{
...
@@ -205,6 +205,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -205,6 +205,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
allowNonSeamlessAdaptiveness
=
initialValues
.
allowNonSeamlessAdaptiveness
;
allowNonSeamlessAdaptiveness
=
initialValues
.
allowNonSeamlessAdaptiveness
;
maxVideoWidth
=
initialValues
.
maxVideoWidth
;
maxVideoWidth
=
initialValues
.
maxVideoWidth
;
maxVideoHeight
=
initialValues
.
maxVideoHeight
;
maxVideoHeight
=
initialValues
.
maxVideoHeight
;
maxVideoFrameRate
=
initialValues
.
maxVideoFrameRate
;
maxVideoBitrate
=
initialValues
.
maxVideoBitrate
;
maxVideoBitrate
=
initialValues
.
maxVideoBitrate
;
exceedVideoConstraintsIfNecessary
=
initialValues
.
exceedVideoConstraintsIfNecessary
;
exceedVideoConstraintsIfNecessary
=
initialValues
.
exceedVideoConstraintsIfNecessary
;
exceedRendererCapabilitiesIfNecessary
=
initialValues
.
exceedRendererCapabilitiesIfNecessary
;
exceedRendererCapabilitiesIfNecessary
=
initialValues
.
exceedRendererCapabilitiesIfNecessary
;
...
@@ -212,7 +213,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -212,7 +213,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
viewportHeight
=
initialValues
.
viewportHeight
;
viewportHeight
=
initialValues
.
viewportHeight
;
viewportOrientationMayChange
=
initialValues
.
viewportOrientationMayChange
;
viewportOrientationMayChange
=
initialValues
.
viewportOrientationMayChange
;
tunnelingAudioSessionId
=
initialValues
.
tunnelingAudioSessionId
;
tunnelingAudioSessionId
=
initialValues
.
tunnelingAudioSessionId
;
maxFrameRate
=
initialValues
.
maxFrameRate
;
}
}
/**
/**
...
@@ -327,6 +327,16 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -327,6 +327,16 @@ public class DefaultTrackSelector extends MappingTrackSelector {
}
}
/**
/**
* See {@link Parameters#maxVideoFrameRate}.
*
* @return This builder.
*/
public
ParametersBuilder
setMaxVideoFrameRate
(
int
maxVideoFrameRate
)
{
this
.
maxVideoFrameRate
=
maxVideoFrameRate
;
return
this
;
}
/**
* See {@link Parameters#maxVideoBitrate}.
* See {@link Parameters#maxVideoBitrate}.
*
*
* @return This builder.
* @return This builder.
...
@@ -524,16 +534,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -524,16 +534,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
}
}
/**
/**
* See {@link Parameters#maxFrameRate}.
*
* @return This builder.
*/
public
ParametersBuilder
setMaxFrameRate
(
int
maxFrameRate
)
{
this
.
maxFrameRate
=
maxFrameRate
;
return
this
;
}
/**
* Builds a {@link Parameters} instance with the selected values.
* Builds a {@link Parameters} instance with the selected values.
*/
*/
public
Parameters
build
()
{
public
Parameters
build
()
{
...
@@ -550,14 +550,14 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -550,14 +550,14 @@ public class DefaultTrackSelector extends MappingTrackSelector {
allowNonSeamlessAdaptiveness
,
allowNonSeamlessAdaptiveness
,
maxVideoWidth
,
maxVideoWidth
,
maxVideoHeight
,
maxVideoHeight
,
maxVideoFrameRate
,
maxVideoBitrate
,
maxVideoBitrate
,
exceedVideoConstraintsIfNecessary
,
exceedVideoConstraintsIfNecessary
,
exceedRendererCapabilitiesIfNecessary
,
exceedRendererCapabilitiesIfNecessary
,
viewportWidth
,
viewportWidth
,
viewportHeight
,
viewportHeight
,
viewportOrientationMayChange
,
viewportOrientationMayChange
,
tunnelingAudioSessionId
,
tunnelingAudioSessionId
);
maxFrameRate
);
}
}
private
static
SparseArray
<
Map
<
TrackGroupArray
,
SelectionOverride
>>
cloneSelectionOverrides
(
private
static
SparseArray
<
Map
<
TrackGroupArray
,
SelectionOverride
>>
cloneSelectionOverrides
(
...
@@ -627,6 +627,11 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -627,6 +627,11 @@ public class DefaultTrackSelector extends MappingTrackSelector {
*/
*/
public
final
int
maxVideoHeight
;
public
final
int
maxVideoHeight
;
/**
/**
* Maximum allowed video frame rate. The default value is {@link Integer#MAX_VALUE} (i.e. no
* constraint).
*/
public
final
int
maxVideoFrameRate
;
/**
* Maximum video bitrate. The default value is {@link Integer#MAX_VALUE} (i.e. no constraint).
* Maximum video bitrate. The default value is {@link Integer#MAX_VALUE} (i.e. no constraint).
*/
*/
public
final
int
maxVideoBitrate
;
public
final
int
maxVideoBitrate
;
...
@@ -654,10 +659,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -654,10 +659,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
* The default value is {@code true}.
* The default value is {@code true}.
*/
*/
public
final
boolean
viewportOrientationMayChange
;
public
final
boolean
viewportOrientationMayChange
;
/**
* Maximum video frame rate. The default value is {@link Integer#MAX_VALUE} (i.e. no constraint).
*/
public
final
int
maxFrameRate
;
// General
// General
/**
/**
...
@@ -711,14 +712,14 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -711,14 +712,14 @@ public class DefaultTrackSelector extends MappingTrackSelector {
/* allowNonSeamlessAdaptiveness= */
true
,
/* allowNonSeamlessAdaptiveness= */
true
,
/* maxVideoWidth= */
Integer
.
MAX_VALUE
,
/* maxVideoWidth= */
Integer
.
MAX_VALUE
,
/* maxVideoHeight= */
Integer
.
MAX_VALUE
,
/* maxVideoHeight= */
Integer
.
MAX_VALUE
,
/* maxVideoFrameRate= */
Integer
.
MAX_VALUE
,
/* maxVideoBitrate= */
Integer
.
MAX_VALUE
,
/* maxVideoBitrate= */
Integer
.
MAX_VALUE
,
/* exceedVideoConstraintsIfNecessary= */
true
,
/* exceedVideoConstraintsIfNecessary= */
true
,
/* exceedRendererCapabilitiesIfNecessary= */
true
,
/* exceedRendererCapabilitiesIfNecessary= */
true
,
/* viewportWidth= */
Integer
.
MAX_VALUE
,
/* viewportWidth= */
Integer
.
MAX_VALUE
,
/* viewportHeight= */
Integer
.
MAX_VALUE
,
/* viewportHeight= */
Integer
.
MAX_VALUE
,
/* viewportOrientationMayChange= */
true
,
/* viewportOrientationMayChange= */
true
,
/* tunnelingAudioSessionId= */
C
.
AUDIO_SESSION_ID_UNSET
,
/* tunnelingAudioSessionId= */
C
.
AUDIO_SESSION_ID_UNSET
);
/* maxFrameRate= */
Integer
.
MAX_VALUE
);
}
}
/* package */
Parameters
(
/* package */
Parameters
(
...
@@ -734,14 +735,14 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -734,14 +735,14 @@ public class DefaultTrackSelector extends MappingTrackSelector {
boolean
allowNonSeamlessAdaptiveness
,
boolean
allowNonSeamlessAdaptiveness
,
int
maxVideoWidth
,
int
maxVideoWidth
,
int
maxVideoHeight
,
int
maxVideoHeight
,
int
maxVideoFrameRate
,
int
maxVideoBitrate
,
int
maxVideoBitrate
,
boolean
exceedVideoConstraintsIfNecessary
,
boolean
exceedVideoConstraintsIfNecessary
,
boolean
exceedRendererCapabilitiesIfNecessary
,
boolean
exceedRendererCapabilitiesIfNecessary
,
int
viewportWidth
,
int
viewportWidth
,
int
viewportHeight
,
int
viewportHeight
,
boolean
viewportOrientationMayChange
,
boolean
viewportOrientationMayChange
,
int
tunnelingAudioSessionId
,
int
tunnelingAudioSessionId
)
{
int
maxFrameRate
)
{
this
.
selectionOverrides
=
selectionOverrides
;
this
.
selectionOverrides
=
selectionOverrides
;
this
.
rendererDisabledFlags
=
rendererDisabledFlags
;
this
.
rendererDisabledFlags
=
rendererDisabledFlags
;
this
.
preferredAudioLanguage
=
Util
.
normalizeLanguageCode
(
preferredAudioLanguage
);
this
.
preferredAudioLanguage
=
Util
.
normalizeLanguageCode
(
preferredAudioLanguage
);
...
@@ -754,6 +755,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -754,6 +755,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
this
.
allowNonSeamlessAdaptiveness
=
allowNonSeamlessAdaptiveness
;
this
.
allowNonSeamlessAdaptiveness
=
allowNonSeamlessAdaptiveness
;
this
.
maxVideoWidth
=
maxVideoWidth
;
this
.
maxVideoWidth
=
maxVideoWidth
;
this
.
maxVideoHeight
=
maxVideoHeight
;
this
.
maxVideoHeight
=
maxVideoHeight
;
this
.
maxVideoFrameRate
=
maxVideoFrameRate
;
this
.
maxVideoBitrate
=
maxVideoBitrate
;
this
.
maxVideoBitrate
=
maxVideoBitrate
;
this
.
exceedVideoConstraintsIfNecessary
=
exceedVideoConstraintsIfNecessary
;
this
.
exceedVideoConstraintsIfNecessary
=
exceedVideoConstraintsIfNecessary
;
this
.
exceedRendererCapabilitiesIfNecessary
=
exceedRendererCapabilitiesIfNecessary
;
this
.
exceedRendererCapabilitiesIfNecessary
=
exceedRendererCapabilitiesIfNecessary
;
...
@@ -761,7 +763,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -761,7 +763,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
this
.
viewportHeight
=
viewportHeight
;
this
.
viewportHeight
=
viewportHeight
;
this
.
viewportOrientationMayChange
=
viewportOrientationMayChange
;
this
.
viewportOrientationMayChange
=
viewportOrientationMayChange
;
this
.
tunnelingAudioSessionId
=
tunnelingAudioSessionId
;
this
.
tunnelingAudioSessionId
=
tunnelingAudioSessionId
;
this
.
maxFrameRate
=
maxFrameRate
;
}
}
/* package */
Parameters
(
Parcel
in
)
{
/* package */
Parameters
(
Parcel
in
)
{
...
@@ -777,6 +778,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -777,6 +778,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
this
.
allowNonSeamlessAdaptiveness
=
Util
.
readBoolean
(
in
);
this
.
allowNonSeamlessAdaptiveness
=
Util
.
readBoolean
(
in
);
this
.
maxVideoWidth
=
in
.
readInt
();
this
.
maxVideoWidth
=
in
.
readInt
();
this
.
maxVideoHeight
=
in
.
readInt
();
this
.
maxVideoHeight
=
in
.
readInt
();
this
.
maxVideoFrameRate
=
in
.
readInt
();
this
.
maxVideoBitrate
=
in
.
readInt
();
this
.
maxVideoBitrate
=
in
.
readInt
();
this
.
exceedVideoConstraintsIfNecessary
=
Util
.
readBoolean
(
in
);
this
.
exceedVideoConstraintsIfNecessary
=
Util
.
readBoolean
(
in
);
this
.
exceedRendererCapabilitiesIfNecessary
=
Util
.
readBoolean
(
in
);
this
.
exceedRendererCapabilitiesIfNecessary
=
Util
.
readBoolean
(
in
);
...
@@ -784,7 +786,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -784,7 +786,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
this
.
viewportHeight
=
in
.
readInt
();
this
.
viewportHeight
=
in
.
readInt
();
this
.
viewportOrientationMayChange
=
Util
.
readBoolean
(
in
);
this
.
viewportOrientationMayChange
=
Util
.
readBoolean
(
in
);
this
.
tunnelingAudioSessionId
=
in
.
readInt
();
this
.
tunnelingAudioSessionId
=
in
.
readInt
();
this
.
maxFrameRate
=
in
.
readInt
();
}
}
/**
/**
...
@@ -846,6 +847,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -846,6 +847,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
&&
allowNonSeamlessAdaptiveness
==
other
.
allowNonSeamlessAdaptiveness
&&
allowNonSeamlessAdaptiveness
==
other
.
allowNonSeamlessAdaptiveness
&&
maxVideoWidth
==
other
.
maxVideoWidth
&&
maxVideoWidth
==
other
.
maxVideoWidth
&&
maxVideoHeight
==
other
.
maxVideoHeight
&&
maxVideoHeight
==
other
.
maxVideoHeight
&&
maxVideoFrameRate
==
other
.
maxVideoFrameRate
&&
exceedVideoConstraintsIfNecessary
==
other
.
exceedVideoConstraintsIfNecessary
&&
exceedVideoConstraintsIfNecessary
==
other
.
exceedVideoConstraintsIfNecessary
&&
exceedRendererCapabilitiesIfNecessary
==
other
.
exceedRendererCapabilitiesIfNecessary
&&
exceedRendererCapabilitiesIfNecessary
==
other
.
exceedRendererCapabilitiesIfNecessary
&&
viewportOrientationMayChange
==
other
.
viewportOrientationMayChange
&&
viewportOrientationMayChange
==
other
.
viewportOrientationMayChange
...
@@ -853,7 +855,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -853,7 +855,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
&&
viewportHeight
==
other
.
viewportHeight
&&
viewportHeight
==
other
.
viewportHeight
&&
maxVideoBitrate
==
other
.
maxVideoBitrate
&&
maxVideoBitrate
==
other
.
maxVideoBitrate
&&
tunnelingAudioSessionId
==
other
.
tunnelingAudioSessionId
&&
tunnelingAudioSessionId
==
other
.
tunnelingAudioSessionId
&&
maxFrameRate
==
other
.
maxFrameRate
&&
TextUtils
.
equals
(
preferredAudioLanguage
,
other
.
preferredAudioLanguage
)
&&
TextUtils
.
equals
(
preferredAudioLanguage
,
other
.
preferredAudioLanguage
)
&&
TextUtils
.
equals
(
preferredTextLanguage
,
other
.
preferredTextLanguage
)
&&
TextUtils
.
equals
(
preferredTextLanguage
,
other
.
preferredTextLanguage
)
&&
areRendererDisabledFlagsEqual
(
rendererDisabledFlags
,
other
.
rendererDisabledFlags
)
&&
areRendererDisabledFlagsEqual
(
rendererDisabledFlags
,
other
.
rendererDisabledFlags
)
...
@@ -870,6 +871,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -870,6 +871,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
result
=
31
*
result
+
(
allowNonSeamlessAdaptiveness
?
1
:
0
);
result
=
31
*
result
+
(
allowNonSeamlessAdaptiveness
?
1
:
0
);
result
=
31
*
result
+
maxVideoWidth
;
result
=
31
*
result
+
maxVideoWidth
;
result
=
31
*
result
+
maxVideoHeight
;
result
=
31
*
result
+
maxVideoHeight
;
result
=
31
*
result
+
maxVideoFrameRate
;
result
=
31
*
result
+
(
exceedVideoConstraintsIfNecessary
?
1
:
0
);
result
=
31
*
result
+
(
exceedVideoConstraintsIfNecessary
?
1
:
0
);
result
=
31
*
result
+
(
exceedRendererCapabilitiesIfNecessary
?
1
:
0
);
result
=
31
*
result
+
(
exceedRendererCapabilitiesIfNecessary
?
1
:
0
);
result
=
31
*
result
+
(
viewportOrientationMayChange
?
1
:
0
);
result
=
31
*
result
+
(
viewportOrientationMayChange
?
1
:
0
);
...
@@ -877,7 +879,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -877,7 +879,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
result
=
31
*
result
+
viewportHeight
;
result
=
31
*
result
+
viewportHeight
;
result
=
31
*
result
+
maxVideoBitrate
;
result
=
31
*
result
+
maxVideoBitrate
;
result
=
31
*
result
+
tunnelingAudioSessionId
;
result
=
31
*
result
+
tunnelingAudioSessionId
;
result
=
31
*
result
+
maxFrameRate
;
result
=
result
=
31
*
result
+
(
preferredAudioLanguage
==
null
?
0
:
preferredAudioLanguage
.
hashCode
());
31
*
result
+
(
preferredAudioLanguage
==
null
?
0
:
preferredAudioLanguage
.
hashCode
());
result
=
31
*
result
+
(
preferredTextLanguage
==
null
?
0
:
preferredTextLanguage
.
hashCode
());
result
=
31
*
result
+
(
preferredTextLanguage
==
null
?
0
:
preferredTextLanguage
.
hashCode
());
...
@@ -905,6 +906,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -905,6 +906,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
Util
.
writeBoolean
(
dest
,
allowNonSeamlessAdaptiveness
);
Util
.
writeBoolean
(
dest
,
allowNonSeamlessAdaptiveness
);
dest
.
writeInt
(
maxVideoWidth
);
dest
.
writeInt
(
maxVideoWidth
);
dest
.
writeInt
(
maxVideoHeight
);
dest
.
writeInt
(
maxVideoHeight
);
dest
.
writeInt
(
maxVideoFrameRate
);
dest
.
writeInt
(
maxVideoBitrate
);
dest
.
writeInt
(
maxVideoBitrate
);
Util
.
writeBoolean
(
dest
,
exceedVideoConstraintsIfNecessary
);
Util
.
writeBoolean
(
dest
,
exceedVideoConstraintsIfNecessary
);
Util
.
writeBoolean
(
dest
,
exceedRendererCapabilitiesIfNecessary
);
Util
.
writeBoolean
(
dest
,
exceedRendererCapabilitiesIfNecessary
);
...
@@ -912,7 +914,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -912,7 +914,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
dest
.
writeInt
(
viewportHeight
);
dest
.
writeInt
(
viewportHeight
);
Util
.
writeBoolean
(
dest
,
viewportOrientationMayChange
);
Util
.
writeBoolean
(
dest
,
viewportOrientationMayChange
);
dest
.
writeInt
(
tunnelingAudioSessionId
);
dest
.
writeInt
(
tunnelingAudioSessionId
);
dest
.
writeInt
(
maxFrameRate
);
}
}
public
static
final
Parcelable
.
Creator
<
Parameters
>
CREATOR
=
public
static
final
Parcelable
.
Creator
<
Parameters
>
CREATOR
=
...
@@ -1457,10 +1458,19 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -1457,10 +1458,19 @@ public class DefaultTrackSelector extends MappingTrackSelector {
&&
(
mixedMimeTypeAdaptationSupports
&
requiredAdaptiveSupport
)
!=
0
;
&&
(
mixedMimeTypeAdaptationSupports
&
requiredAdaptiveSupport
)
!=
0
;
for
(
int
i
=
0
;
i
<
groups
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
groups
.
length
;
i
++)
{
TrackGroup
group
=
groups
.
get
(
i
);
TrackGroup
group
=
groups
.
get
(
i
);
int
[]
adaptiveTracks
=
getAdaptiveVideoTracksForGroup
(
group
,
formatSupport
[
i
],
int
[]
adaptiveTracks
=
allowMixedMimeTypes
,
requiredAdaptiveSupport
,
params
.
maxVideoWidth
,
params
.
maxVideoHeight
,
getAdaptiveVideoTracksForGroup
(
params
.
maxVideoBitrate
,
params
.
maxFrameRate
,
params
.
viewportWidth
,
params
.
viewportHeight
,
group
,
params
.
viewportOrientationMayChange
);
formatSupport
[
i
],
allowMixedMimeTypes
,
requiredAdaptiveSupport
,
params
.
maxVideoWidth
,
params
.
maxVideoHeight
,
params
.
maxVideoFrameRate
,
params
.
maxVideoBitrate
,
params
.
viewportWidth
,
params
.
viewportHeight
,
params
.
viewportOrientationMayChange
);
if
(
adaptiveTracks
.
length
>
0
)
{
if
(
adaptiveTracks
.
length
>
0
)
{
return
Assertions
.
checkNotNull
(
adaptiveTrackSelectionFactory
)
return
Assertions
.
checkNotNull
(
adaptiveTrackSelectionFactory
)
.
createTrackSelection
(
group
,
bandwidthMeter
,
adaptiveTracks
);
.
createTrackSelection
(
group
,
bandwidthMeter
,
adaptiveTracks
);
...
@@ -1469,10 +1479,18 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -1469,10 +1479,18 @@ public class DefaultTrackSelector extends MappingTrackSelector {
return
null
;
return
null
;
}
}
private
static
int
[]
getAdaptiveVideoTracksForGroup
(
TrackGroup
group
,
int
[]
formatSupport
,
private
static
int
[]
getAdaptiveVideoTracksForGroup
(
boolean
allowMixedMimeTypes
,
int
requiredAdaptiveSupport
,
int
maxVideoWidth
,
TrackGroup
group
,
int
maxVideoHeight
,
int
maxVideoBitrate
,
int
maxFrameRate
,
int
viewportWidth
,
int
[]
formatSupport
,
int
viewportHeight
,
boolean
viewportOrientationMayChange
)
{
boolean
allowMixedMimeTypes
,
int
requiredAdaptiveSupport
,
int
maxVideoWidth
,
int
maxVideoHeight
,
int
maxVideoFrameRate
,
int
maxVideoBitrate
,
int
viewportWidth
,
int
viewportHeight
,
boolean
viewportOrientationMayChange
)
{
if
(
group
.
length
<
2
)
{
if
(
group
.
length
<
2
)
{
return
NO_TRACKS
;
return
NO_TRACKS
;
}
}
...
@@ -1492,9 +1510,17 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -1492,9 +1510,17 @@ public class DefaultTrackSelector extends MappingTrackSelector {
int
trackIndex
=
selectedTrackIndices
.
get
(
i
);
int
trackIndex
=
selectedTrackIndices
.
get
(
i
);
String
sampleMimeType
=
group
.
getFormat
(
trackIndex
).
sampleMimeType
;
String
sampleMimeType
=
group
.
getFormat
(
trackIndex
).
sampleMimeType
;
if
(
seenMimeTypes
.
add
(
sampleMimeType
))
{
if
(
seenMimeTypes
.
add
(
sampleMimeType
))
{
int
countForMimeType
=
getAdaptiveVideoTrackCountForMimeType
(
group
,
formatSupport
,
int
countForMimeType
=
requiredAdaptiveSupport
,
sampleMimeType
,
maxVideoWidth
,
maxVideoHeight
,
getAdaptiveVideoTrackCountForMimeType
(
maxVideoBitrate
,
maxFrameRate
,
selectedTrackIndices
);
group
,
formatSupport
,
requiredAdaptiveSupport
,
sampleMimeType
,
maxVideoWidth
,
maxVideoHeight
,
maxVideoFrameRate
,
maxVideoBitrate
,
selectedTrackIndices
);
if
(
countForMimeType
>
selectedMimeTypeTrackCount
)
{
if
(
countForMimeType
>
selectedMimeTypeTrackCount
)
{
selectedMimeType
=
sampleMimeType
;
selectedMimeType
=
sampleMimeType
;
selectedMimeTypeTrackCount
=
countForMimeType
;
selectedMimeTypeTrackCount
=
countForMimeType
;
...
@@ -1504,8 +1530,15 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -1504,8 +1530,15 @@ public class DefaultTrackSelector extends MappingTrackSelector {
}
}
// Filter by the selected mime type.
// Filter by the selected mime type.
filterAdaptiveVideoTrackCountForMimeType
(
group
,
formatSupport
,
requiredAdaptiveSupport
,
filterAdaptiveVideoTrackCountForMimeType
(
selectedMimeType
,
maxVideoWidth
,
maxVideoHeight
,
maxVideoBitrate
,
maxFrameRate
,
group
,
formatSupport
,
requiredAdaptiveSupport
,
selectedMimeType
,
maxVideoWidth
,
maxVideoHeight
,
maxVideoFrameRate
,
maxVideoBitrate
,
selectedTrackIndices
);
selectedTrackIndices
);
return
selectedTrackIndices
.
size
()
<
2
?
NO_TRACKS
:
Util
.
toArray
(
selectedTrackIndices
);
return
selectedTrackIndices
.
size
()
<
2
?
NO_TRACKS
:
Util
.
toArray
(
selectedTrackIndices
);
...
@@ -1518,15 +1551,21 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -1518,15 +1551,21 @@ public class DefaultTrackSelector extends MappingTrackSelector {
@Nullable
String
mimeType
,
@Nullable
String
mimeType
,
int
maxVideoWidth
,
int
maxVideoWidth
,
int
maxVideoHeight
,
int
maxVideoHeight
,
int
maxVideoFrameRate
,
int
maxVideoBitrate
,
int
maxVideoBitrate
,
int
maxFrameRate
,
List
<
Integer
>
selectedTrackIndices
)
{
List
<
Integer
>
selectedTrackIndices
)
{
int
adaptiveTrackCount
=
0
;
int
adaptiveTrackCount
=
0
;
for
(
int
i
=
0
;
i
<
selectedTrackIndices
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
selectedTrackIndices
.
size
();
i
++)
{
int
trackIndex
=
selectedTrackIndices
.
get
(
i
);
int
trackIndex
=
selectedTrackIndices
.
get
(
i
);
if
(
isSupportedAdaptiveVideoTrack
(
group
.
getFormat
(
trackIndex
),
mimeType
,
if
(
isSupportedAdaptiveVideoTrack
(
formatSupport
[
trackIndex
],
requiredAdaptiveSupport
,
maxVideoWidth
,
maxVideoHeight
,
group
.
getFormat
(
trackIndex
),
maxVideoBitrate
,
maxFrameRate
))
{
mimeType
,
formatSupport
[
trackIndex
],
requiredAdaptiveSupport
,
maxVideoWidth
,
maxVideoHeight
,
maxVideoFrameRate
,
maxVideoBitrate
))
{
adaptiveTrackCount
++;
adaptiveTrackCount
++;
}
}
}
}
...
@@ -1540,14 +1579,20 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -1540,14 +1579,20 @@ public class DefaultTrackSelector extends MappingTrackSelector {
@Nullable
String
mimeType
,
@Nullable
String
mimeType
,
int
maxVideoWidth
,
int
maxVideoWidth
,
int
maxVideoHeight
,
int
maxVideoHeight
,
int
maxVideoFrameRate
,
int
maxVideoBitrate
,
int
maxVideoBitrate
,
int
maxFrameRate
,
List
<
Integer
>
selectedTrackIndices
)
{
List
<
Integer
>
selectedTrackIndices
)
{
for
(
int
i
=
selectedTrackIndices
.
size
()
-
1
;
i
>=
0
;
i
--)
{
for
(
int
i
=
selectedTrackIndices
.
size
()
-
1
;
i
>=
0
;
i
--)
{
int
trackIndex
=
selectedTrackIndices
.
get
(
i
);
int
trackIndex
=
selectedTrackIndices
.
get
(
i
);
if
(!
isSupportedAdaptiveVideoTrack
(
group
.
getFormat
(
trackIndex
),
mimeType
,
if
(!
isSupportedAdaptiveVideoTrack
(
formatSupport
[
trackIndex
],
requiredAdaptiveSupport
,
maxVideoWidth
,
maxVideoHeight
,
group
.
getFormat
(
trackIndex
),
maxVideoBitrate
,
maxFrameRate
))
{
mimeType
,
formatSupport
[
trackIndex
],
requiredAdaptiveSupport
,
maxVideoWidth
,
maxVideoHeight
,
maxVideoFrameRate
,
maxVideoBitrate
))
{
selectedTrackIndices
.
remove
(
i
);
selectedTrackIndices
.
remove
(
i
);
}
}
}
}
...
@@ -1560,14 +1605,15 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -1560,14 +1605,15 @@ public class DefaultTrackSelector extends MappingTrackSelector {
int
requiredAdaptiveSupport
,
int
requiredAdaptiveSupport
,
int
maxVideoWidth
,
int
maxVideoWidth
,
int
maxVideoHeight
,
int
maxVideoHeight
,
int
maxVideoBitrate
,
int
maxVideoFrameRate
,
int
maxFrameRate
)
{
int
maxVideoBitrate
)
{
return
isSupported
(
formatSupport
,
false
)
&&
((
formatSupport
&
requiredAdaptiveSupport
)
!=
0
)
return
isSupported
(
formatSupport
,
false
)
&&
((
formatSupport
&
requiredAdaptiveSupport
)
!=
0
)
&&
(
mimeType
==
null
||
Util
.
areEqual
(
format
.
sampleMimeType
,
mimeType
))
&&
(
mimeType
==
null
||
Util
.
areEqual
(
format
.
sampleMimeType
,
mimeType
))
&&
(
format
.
width
==
Format
.
NO_VALUE
||
format
.
width
<=
maxVideoWidth
)
&&
(
format
.
width
==
Format
.
NO_VALUE
||
format
.
width
<=
maxVideoWidth
)
&&
(
format
.
height
==
Format
.
NO_VALUE
||
format
.
height
<=
maxVideoHeight
)
&&
(
format
.
height
==
Format
.
NO_VALUE
||
format
.
height
<=
maxVideoHeight
)
&&
(
format
.
bitrate
==
Format
.
NO_VALUE
||
format
.
bitrate
<=
maxVideoBitr
ate
)
&&
(
format
.
frameRate
==
Format
.
NO_VALUE
||
format
.
frameRate
<=
maxVideoFrameR
ate
)
&&
(
format
.
frameRate
==
Format
.
NO_VALUE
||
format
.
frameRate
<=
maxFrameR
ate
);
&&
(
format
.
bitrate
==
Format
.
NO_VALUE
||
format
.
bitrate
<=
maxVideoBitr
ate
);
}
}
private
static
@Nullable
TrackSelection
selectFixedVideoTrack
(
private
static
@Nullable
TrackSelection
selectFixedVideoTrack
(
...
@@ -1586,11 +1632,14 @@ public class DefaultTrackSelector extends MappingTrackSelector {
...
@@ -1586,11 +1632,14 @@ public class DefaultTrackSelector extends MappingTrackSelector {
if
(
isSupported
(
trackFormatSupport
[
trackIndex
],
if
(
isSupported
(
trackFormatSupport
[
trackIndex
],
params
.
exceedRendererCapabilitiesIfNecessary
))
{
params
.
exceedRendererCapabilitiesIfNecessary
))
{
Format
format
=
trackGroup
.
getFormat
(
trackIndex
);
Format
format
=
trackGroup
.
getFormat
(
trackIndex
);
boolean
isWithinConstraints
=
selectedTrackIndices
.
contains
(
trackIndex
)
boolean
isWithinConstraints
=
&&
(
format
.
width
==
Format
.
NO_VALUE
||
format
.
width
<=
params
.
maxVideoWidth
)
selectedTrackIndices
.
contains
(
trackIndex
)
&&
(
format
.
height
==
Format
.
NO_VALUE
||
format
.
height
<=
params
.
maxVideoHeight
)
&&
(
format
.
width
==
Format
.
NO_VALUE
||
format
.
width
<=
params
.
maxVideoWidth
)
&&
(
format
.
bitrate
==
Format
.
NO_VALUE
||
format
.
bitrate
<=
params
.
maxVideoBitrate
)
&&
(
format
.
height
==
Format
.
NO_VALUE
||
format
.
height
<=
params
.
maxVideoHeight
)
&&
(
format
.
frameRate
==
Format
.
NO_VALUE
||
format
.
frameRate
<=
params
.
maxFrameRate
);
&&
(
format
.
frameRate
==
Format
.
NO_VALUE
||
format
.
frameRate
<=
params
.
maxVideoFrameRate
)
&&
(
format
.
bitrate
==
Format
.
NO_VALUE
||
format
.
bitrate
<=
params
.
maxVideoBitrate
);
if
(!
isWithinConstraints
&&
!
params
.
exceedVideoConstraintsIfNecessary
)
{
if
(!
isWithinConstraints
&&
!
params
.
exceedVideoConstraintsIfNecessary
)
{
// Track should not be selected.
// Track should not be selected.
continue
;
continue
;
...
...
library/core/src/test/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelectorTest.java
View file @
4b33d3c8
...
@@ -130,14 +130,14 @@ public final class DefaultTrackSelectorTest {
...
@@ -130,14 +130,14 @@ public final class DefaultTrackSelectorTest {
/* allowNonSeamlessAdaptiveness= */
true
,
/* allowNonSeamlessAdaptiveness= */
true
,
/* maxVideoWidth= */
1
,
/* maxVideoWidth= */
1
,
/* maxVideoHeight= */
2
,
/* maxVideoHeight= */
2
,
/* maxVideoBitrate= */
3
,
/* maxVideoFrameRate= */
3
,
/* maxVideoBitrate= */
4
,
/* exceedVideoConstraintsIfNecessary= */
false
,
/* exceedVideoConstraintsIfNecessary= */
false
,
/* exceedRendererCapabilitiesIfNecessary= */
true
,
/* exceedRendererCapabilitiesIfNecessary= */
true
,
/* viewportWidth= */
4
,
/* viewportWidth= */
5
,
/* viewportHeight= */
5
,
/* viewportHeight= */
6
,
/* viewportOrientationMayChange= */
false
,
/* viewportOrientationMayChange= */
false
,
/* tunnelingAudioSessionId= */
C
.
AUDIO_SESSION_ID_UNSET
,
/* tunnelingAudioSessionId= */
C
.
AUDIO_SESSION_ID_UNSET
);
/* maxFrameRate= */
6
);
Parcel
parcel
=
Parcel
.
obtain
();
Parcel
parcel
=
Parcel
.
obtain
();
parametersToParcel
.
writeToParcel
(
parcel
,
0
);
parametersToParcel
.
writeToParcel
(
parcel
,
0
);
...
...
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