Update track selection to prefer content over technical preferences.
Currently we prefer technical preferences set in the Parameters over content preferences implied by the media. It proably makes more sense in the opposite order to avoid the situation where a non-default track (e.g. commentary) is selected just because it better matches some technical criteria. Also add comments explaining the track selection logic stages. PiperOrigin-RevId: 412840962
This commit is contained in:
parent
fb0768e0d2
commit
805d3b763d
@ -2566,14 +2566,18 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||||||
: FORMAT_VALUE_ORDERING.reverse();
|
: FORMAT_VALUE_ORDERING.reverse();
|
||||||
return ComparisonChain.start()
|
return ComparisonChain.start()
|
||||||
.compareFalseFirst(this.isWithinRendererCapabilities, other.isWithinRendererCapabilities)
|
.compareFalseFirst(this.isWithinRendererCapabilities, other.isWithinRendererCapabilities)
|
||||||
|
// 1. Compare match with specific content preferences set by the parameters.
|
||||||
.compare(this.preferredRoleFlagsScore, other.preferredRoleFlagsScore)
|
.compare(this.preferredRoleFlagsScore, other.preferredRoleFlagsScore)
|
||||||
|
// 2. Compare match with implicit content preferences set by the media.
|
||||||
.compareFalseFirst(this.hasMainOrNoRoleFlag, other.hasMainOrNoRoleFlag)
|
.compareFalseFirst(this.hasMainOrNoRoleFlag, other.hasMainOrNoRoleFlag)
|
||||||
|
// 3. Compare match with technical preferences set by the parameters.
|
||||||
.compareFalseFirst(this.isWithinMaxConstraints, other.isWithinMaxConstraints)
|
.compareFalseFirst(this.isWithinMaxConstraints, other.isWithinMaxConstraints)
|
||||||
.compareFalseFirst(this.isWithinMinConstraints, other.isWithinMinConstraints)
|
.compareFalseFirst(this.isWithinMinConstraints, other.isWithinMinConstraints)
|
||||||
.compare(
|
.compare(
|
||||||
this.preferredMimeTypeMatchIndex,
|
this.preferredMimeTypeMatchIndex,
|
||||||
other.preferredMimeTypeMatchIndex,
|
other.preferredMimeTypeMatchIndex,
|
||||||
Ordering.natural().reverse())
|
Ordering.natural().reverse())
|
||||||
|
// 4. Compare technical quality.
|
||||||
.compare(
|
.compare(
|
||||||
this.bitrate,
|
this.bitrate,
|
||||||
other.bitrate,
|
other.bitrate,
|
||||||
@ -2683,13 +2687,22 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||||||
: FORMAT_VALUE_ORDERING.reverse();
|
: FORMAT_VALUE_ORDERING.reverse();
|
||||||
return ComparisonChain.start()
|
return ComparisonChain.start()
|
||||||
.compareFalseFirst(this.isWithinRendererCapabilities, other.isWithinRendererCapabilities)
|
.compareFalseFirst(this.isWithinRendererCapabilities, other.isWithinRendererCapabilities)
|
||||||
|
// 1. Compare match with specific content preferences set by the parameters.
|
||||||
.compare(
|
.compare(
|
||||||
this.preferredLanguageIndex,
|
this.preferredLanguageIndex,
|
||||||
other.preferredLanguageIndex,
|
other.preferredLanguageIndex,
|
||||||
Ordering.natural().reverse())
|
Ordering.natural().reverse())
|
||||||
.compare(this.preferredLanguageScore, other.preferredLanguageScore)
|
.compare(this.preferredLanguageScore, other.preferredLanguageScore)
|
||||||
.compare(this.preferredRoleFlagsScore, other.preferredRoleFlagsScore)
|
.compare(this.preferredRoleFlagsScore, other.preferredRoleFlagsScore)
|
||||||
|
// 2. Compare match with implicit content preferences set by the media or the system.
|
||||||
|
.compareFalseFirst(this.isDefaultSelectionFlag, other.isDefaultSelectionFlag)
|
||||||
.compareFalseFirst(this.hasMainOrNoRoleFlag, other.hasMainOrNoRoleFlag)
|
.compareFalseFirst(this.hasMainOrNoRoleFlag, other.hasMainOrNoRoleFlag)
|
||||||
|
.compare(
|
||||||
|
this.localeLanguageMatchIndex,
|
||||||
|
other.localeLanguageMatchIndex,
|
||||||
|
Ordering.natural().reverse())
|
||||||
|
.compare(this.localeLanguageScore, other.localeLanguageScore)
|
||||||
|
// 3. Compare match with technical preferences set by the parameters.
|
||||||
.compareFalseFirst(this.isWithinConstraints, other.isWithinConstraints)
|
.compareFalseFirst(this.isWithinConstraints, other.isWithinConstraints)
|
||||||
.compare(
|
.compare(
|
||||||
this.preferredMimeTypeMatchIndex,
|
this.preferredMimeTypeMatchIndex,
|
||||||
@ -2699,12 +2712,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||||||
this.bitrate,
|
this.bitrate,
|
||||||
other.bitrate,
|
other.bitrate,
|
||||||
parameters.forceLowestBitrate ? FORMAT_VALUE_ORDERING.reverse() : NO_ORDER)
|
parameters.forceLowestBitrate ? FORMAT_VALUE_ORDERING.reverse() : NO_ORDER)
|
||||||
.compareFalseFirst(this.isDefaultSelectionFlag, other.isDefaultSelectionFlag)
|
// 4. Compare technical quality.
|
||||||
.compare(
|
|
||||||
this.localeLanguageMatchIndex,
|
|
||||||
other.localeLanguageMatchIndex,
|
|
||||||
Ordering.natural().reverse())
|
|
||||||
.compare(this.localeLanguageScore, other.localeLanguageScore)
|
|
||||||
.compare(this.channelCount, other.channelCount, qualityOrdering)
|
.compare(this.channelCount, other.channelCount, qualityOrdering)
|
||||||
.compare(this.sampleRate, other.sampleRate, qualityOrdering)
|
.compare(this.sampleRate, other.sampleRate, qualityOrdering)
|
||||||
.compare(
|
.compare(
|
||||||
@ -2793,12 +2801,14 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||||||
ComparisonChain.start()
|
ComparisonChain.start()
|
||||||
.compareFalseFirst(
|
.compareFalseFirst(
|
||||||
this.isWithinRendererCapabilities, other.isWithinRendererCapabilities)
|
this.isWithinRendererCapabilities, other.isWithinRendererCapabilities)
|
||||||
|
// 1. Compare match with specific content preferences set by the parameters.
|
||||||
.compare(
|
.compare(
|
||||||
this.preferredLanguageIndex,
|
this.preferredLanguageIndex,
|
||||||
other.preferredLanguageIndex,
|
other.preferredLanguageIndex,
|
||||||
Ordering.natural().reverse())
|
Ordering.natural().reverse())
|
||||||
.compare(this.preferredLanguageScore, other.preferredLanguageScore)
|
.compare(this.preferredLanguageScore, other.preferredLanguageScore)
|
||||||
.compare(this.preferredRoleFlagsScore, other.preferredRoleFlagsScore)
|
.compare(this.preferredRoleFlagsScore, other.preferredRoleFlagsScore)
|
||||||
|
// 2. Compare match with implicit content preferences set by the media.
|
||||||
.compareFalseFirst(this.isDefault, other.isDefault)
|
.compareFalseFirst(this.isDefault, other.isDefault)
|
||||||
.compare(
|
.compare(
|
||||||
this.isForced,
|
this.isForced,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user