mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add allowAudioMixedChannelCountAdaptiveness parameter to DefaultTrackSelector.
We already allow mixed mime type and mixed sample rate adaptation on request, so for completeness, we can also allow mixed channel count adaptation. Issue:#6257 PiperOrigin-RevId: 261930046
This commit is contained in:
parent
fd803a39a3
commit
6617862f0b
3 changed files with 51 additions and 9 deletions
|
|
@ -27,6 +27,10 @@
|
||||||
over other selection parameters.
|
over other selection parameters.
|
||||||
* Remove `AnalyticsCollector.Factory`. Instances can be created directly and
|
* Remove `AnalyticsCollector.Factory`. Instances can be created directly and
|
||||||
the `Player` set later using `AnalyticsCollector.setPlayer`.
|
the `Player` set later using `AnalyticsCollector.setPlayer`.
|
||||||
|
* Add `allowAudioMixedChannelCountAdaptiveness` parameter to
|
||||||
|
`DefaultTrackSelector` to allow adaptive selections of audio tracks with
|
||||||
|
different channel counts
|
||||||
|
([#6257](https://github.com/google/ExoPlayer/issues/6257)).
|
||||||
|
|
||||||
### 2.10.4 ###
|
### 2.10.4 ###
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
private boolean exceedAudioConstraintsIfNecessary;
|
private boolean exceedAudioConstraintsIfNecessary;
|
||||||
private boolean allowAudioMixedMimeTypeAdaptiveness;
|
private boolean allowAudioMixedMimeTypeAdaptiveness;
|
||||||
private boolean allowAudioMixedSampleRateAdaptiveness;
|
private boolean allowAudioMixedSampleRateAdaptiveness;
|
||||||
|
private boolean allowAudioMixedChannelCountAdaptiveness;
|
||||||
// General
|
// General
|
||||||
private boolean forceLowestBitrate;
|
private boolean forceLowestBitrate;
|
||||||
private boolean forceHighestSupportedBitrate;
|
private boolean forceHighestSupportedBitrate;
|
||||||
|
|
@ -227,6 +228,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
exceedAudioConstraintsIfNecessary = initialValues.exceedAudioConstraintsIfNecessary;
|
exceedAudioConstraintsIfNecessary = initialValues.exceedAudioConstraintsIfNecessary;
|
||||||
allowAudioMixedMimeTypeAdaptiveness = initialValues.allowAudioMixedMimeTypeAdaptiveness;
|
allowAudioMixedMimeTypeAdaptiveness = initialValues.allowAudioMixedMimeTypeAdaptiveness;
|
||||||
allowAudioMixedSampleRateAdaptiveness = initialValues.allowAudioMixedSampleRateAdaptiveness;
|
allowAudioMixedSampleRateAdaptiveness = initialValues.allowAudioMixedSampleRateAdaptiveness;
|
||||||
|
allowAudioMixedChannelCountAdaptiveness =
|
||||||
|
initialValues.allowAudioMixedChannelCountAdaptiveness;
|
||||||
// General
|
// General
|
||||||
forceLowestBitrate = initialValues.forceLowestBitrate;
|
forceLowestBitrate = initialValues.forceLowestBitrate;
|
||||||
forceHighestSupportedBitrate = initialValues.forceHighestSupportedBitrate;
|
forceHighestSupportedBitrate = initialValues.forceHighestSupportedBitrate;
|
||||||
|
|
@ -424,6 +427,17 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See {@link Parameters#allowAudioMixedChannelCountAdaptiveness}.
|
||||||
|
*
|
||||||
|
* @return This builder.
|
||||||
|
*/
|
||||||
|
public ParametersBuilder setAllowAudioMixedChannelCountAdaptiveness(
|
||||||
|
boolean allowAudioMixedChannelCountAdaptiveness) {
|
||||||
|
this.allowAudioMixedChannelCountAdaptiveness = allowAudioMixedChannelCountAdaptiveness;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -640,6 +654,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
exceedAudioConstraintsIfNecessary,
|
exceedAudioConstraintsIfNecessary,
|
||||||
allowAudioMixedMimeTypeAdaptiveness,
|
allowAudioMixedMimeTypeAdaptiveness,
|
||||||
allowAudioMixedSampleRateAdaptiveness,
|
allowAudioMixedSampleRateAdaptiveness,
|
||||||
|
allowAudioMixedChannelCountAdaptiveness,
|
||||||
// Text
|
// Text
|
||||||
preferredTextLanguage,
|
preferredTextLanguage,
|
||||||
selectUndeterminedTextLanguage,
|
selectUndeterminedTextLanguage,
|
||||||
|
|
@ -775,6 +790,12 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
* different sample rates may not be completely seamless. The default value is {@code false}.
|
* different sample rates may not be completely seamless. The default value is {@code false}.
|
||||||
*/
|
*/
|
||||||
public final boolean allowAudioMixedSampleRateAdaptiveness;
|
public final boolean allowAudioMixedSampleRateAdaptiveness;
|
||||||
|
/**
|
||||||
|
* Whether to allow adaptive audio selections containing mixed channel counts. Adaptations
|
||||||
|
* between different channel counts may not be completely seamless. The default value is {@code
|
||||||
|
* false}.
|
||||||
|
*/
|
||||||
|
public final boolean allowAudioMixedChannelCountAdaptiveness;
|
||||||
|
|
||||||
// General
|
// General
|
||||||
/**
|
/**
|
||||||
|
|
@ -835,6 +856,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
/* exceedAudioConstraintsIfNecessary= */ true,
|
/* exceedAudioConstraintsIfNecessary= */ true,
|
||||||
/* allowAudioMixedMimeTypeAdaptiveness= */ false,
|
/* allowAudioMixedMimeTypeAdaptiveness= */ false,
|
||||||
/* allowAudioMixedSampleRateAdaptiveness= */ false,
|
/* allowAudioMixedSampleRateAdaptiveness= */ false,
|
||||||
|
/* allowAudioMixedChannelCountAdaptiveness= */ false,
|
||||||
// Text
|
// Text
|
||||||
TrackSelectionParameters.DEFAULT.preferredTextLanguage,
|
TrackSelectionParameters.DEFAULT.preferredTextLanguage,
|
||||||
TrackSelectionParameters.DEFAULT.selectUndeterminedTextLanguage,
|
TrackSelectionParameters.DEFAULT.selectUndeterminedTextLanguage,
|
||||||
|
|
@ -867,6 +889,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
boolean exceedAudioConstraintsIfNecessary,
|
boolean exceedAudioConstraintsIfNecessary,
|
||||||
boolean allowAudioMixedMimeTypeAdaptiveness,
|
boolean allowAudioMixedMimeTypeAdaptiveness,
|
||||||
boolean allowAudioMixedSampleRateAdaptiveness,
|
boolean allowAudioMixedSampleRateAdaptiveness,
|
||||||
|
boolean allowAudioMixedChannelCountAdaptiveness,
|
||||||
// Text
|
// Text
|
||||||
@Nullable String preferredTextLanguage,
|
@Nullable String preferredTextLanguage,
|
||||||
boolean selectUndeterminedTextLanguage,
|
boolean selectUndeterminedTextLanguage,
|
||||||
|
|
@ -901,6 +924,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
this.exceedAudioConstraintsIfNecessary = exceedAudioConstraintsIfNecessary;
|
this.exceedAudioConstraintsIfNecessary = exceedAudioConstraintsIfNecessary;
|
||||||
this.allowAudioMixedMimeTypeAdaptiveness = allowAudioMixedMimeTypeAdaptiveness;
|
this.allowAudioMixedMimeTypeAdaptiveness = allowAudioMixedMimeTypeAdaptiveness;
|
||||||
this.allowAudioMixedSampleRateAdaptiveness = allowAudioMixedSampleRateAdaptiveness;
|
this.allowAudioMixedSampleRateAdaptiveness = allowAudioMixedSampleRateAdaptiveness;
|
||||||
|
this.allowAudioMixedChannelCountAdaptiveness = allowAudioMixedChannelCountAdaptiveness;
|
||||||
// General
|
// General
|
||||||
this.forceLowestBitrate = forceLowestBitrate;
|
this.forceLowestBitrate = forceLowestBitrate;
|
||||||
this.forceHighestSupportedBitrate = forceHighestSupportedBitrate;
|
this.forceHighestSupportedBitrate = forceHighestSupportedBitrate;
|
||||||
|
|
@ -934,6 +958,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
this.exceedAudioConstraintsIfNecessary = Util.readBoolean(in);
|
this.exceedAudioConstraintsIfNecessary = Util.readBoolean(in);
|
||||||
this.allowAudioMixedMimeTypeAdaptiveness = Util.readBoolean(in);
|
this.allowAudioMixedMimeTypeAdaptiveness = Util.readBoolean(in);
|
||||||
this.allowAudioMixedSampleRateAdaptiveness = Util.readBoolean(in);
|
this.allowAudioMixedSampleRateAdaptiveness = Util.readBoolean(in);
|
||||||
|
this.allowAudioMixedChannelCountAdaptiveness = Util.readBoolean(in);
|
||||||
// General
|
// General
|
||||||
this.forceLowestBitrate = Util.readBoolean(in);
|
this.forceLowestBitrate = Util.readBoolean(in);
|
||||||
this.forceHighestSupportedBitrate = Util.readBoolean(in);
|
this.forceHighestSupportedBitrate = Util.readBoolean(in);
|
||||||
|
|
@ -1015,6 +1040,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
&& exceedAudioConstraintsIfNecessary == other.exceedAudioConstraintsIfNecessary
|
&& exceedAudioConstraintsIfNecessary == other.exceedAudioConstraintsIfNecessary
|
||||||
&& allowAudioMixedMimeTypeAdaptiveness == other.allowAudioMixedMimeTypeAdaptiveness
|
&& allowAudioMixedMimeTypeAdaptiveness == other.allowAudioMixedMimeTypeAdaptiveness
|
||||||
&& allowAudioMixedSampleRateAdaptiveness == other.allowAudioMixedSampleRateAdaptiveness
|
&& allowAudioMixedSampleRateAdaptiveness == other.allowAudioMixedSampleRateAdaptiveness
|
||||||
|
&& allowAudioMixedChannelCountAdaptiveness
|
||||||
|
== other.allowAudioMixedChannelCountAdaptiveness
|
||||||
// General
|
// General
|
||||||
&& forceLowestBitrate == other.forceLowestBitrate
|
&& forceLowestBitrate == other.forceLowestBitrate
|
||||||
&& forceHighestSupportedBitrate == other.forceHighestSupportedBitrate
|
&& forceHighestSupportedBitrate == other.forceHighestSupportedBitrate
|
||||||
|
|
@ -1045,6 +1072,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
result = 31 * result + (exceedAudioConstraintsIfNecessary ? 1 : 0);
|
result = 31 * result + (exceedAudioConstraintsIfNecessary ? 1 : 0);
|
||||||
result = 31 * result + (allowAudioMixedMimeTypeAdaptiveness ? 1 : 0);
|
result = 31 * result + (allowAudioMixedMimeTypeAdaptiveness ? 1 : 0);
|
||||||
result = 31 * result + (allowAudioMixedSampleRateAdaptiveness ? 1 : 0);
|
result = 31 * result + (allowAudioMixedSampleRateAdaptiveness ? 1 : 0);
|
||||||
|
result = 31 * result + (allowAudioMixedChannelCountAdaptiveness ? 1 : 0);
|
||||||
// General
|
// General
|
||||||
result = 31 * result + (forceLowestBitrate ? 1 : 0);
|
result = 31 * result + (forceLowestBitrate ? 1 : 0);
|
||||||
result = 31 * result + (forceHighestSupportedBitrate ? 1 : 0);
|
result = 31 * result + (forceHighestSupportedBitrate ? 1 : 0);
|
||||||
|
|
@ -1081,6 +1109,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
Util.writeBoolean(dest, exceedAudioConstraintsIfNecessary);
|
Util.writeBoolean(dest, exceedAudioConstraintsIfNecessary);
|
||||||
Util.writeBoolean(dest, allowAudioMixedMimeTypeAdaptiveness);
|
Util.writeBoolean(dest, allowAudioMixedMimeTypeAdaptiveness);
|
||||||
Util.writeBoolean(dest, allowAudioMixedSampleRateAdaptiveness);
|
Util.writeBoolean(dest, allowAudioMixedSampleRateAdaptiveness);
|
||||||
|
Util.writeBoolean(dest, allowAudioMixedChannelCountAdaptiveness);
|
||||||
// General
|
// General
|
||||||
Util.writeBoolean(dest, forceLowestBitrate);
|
Util.writeBoolean(dest, forceLowestBitrate);
|
||||||
Util.writeBoolean(dest, forceHighestSupportedBitrate);
|
Util.writeBoolean(dest, forceHighestSupportedBitrate);
|
||||||
|
|
@ -1989,7 +2018,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
formatSupports[selectedGroupIndex],
|
formatSupports[selectedGroupIndex],
|
||||||
params.maxAudioBitrate,
|
params.maxAudioBitrate,
|
||||||
params.allowAudioMixedMimeTypeAdaptiveness,
|
params.allowAudioMixedMimeTypeAdaptiveness,
|
||||||
params.allowAudioMixedSampleRateAdaptiveness);
|
params.allowAudioMixedSampleRateAdaptiveness,
|
||||||
|
params.allowAudioMixedChannelCountAdaptiveness);
|
||||||
if (adaptiveTracks.length > 0) {
|
if (adaptiveTracks.length > 0) {
|
||||||
definition = new TrackSelection.Definition(selectedGroup, adaptiveTracks);
|
definition = new TrackSelection.Definition(selectedGroup, adaptiveTracks);
|
||||||
}
|
}
|
||||||
|
|
@ -2007,7 +2037,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
int[] formatSupport,
|
int[] formatSupport,
|
||||||
int maxAudioBitrate,
|
int maxAudioBitrate,
|
||||||
boolean allowMixedMimeTypeAdaptiveness,
|
boolean allowMixedMimeTypeAdaptiveness,
|
||||||
boolean allowMixedSampleRateAdaptiveness) {
|
boolean allowMixedSampleRateAdaptiveness,
|
||||||
|
boolean allowAudioMixedChannelCountAdaptiveness) {
|
||||||
int selectedConfigurationTrackCount = 0;
|
int selectedConfigurationTrackCount = 0;
|
||||||
AudioConfigurationTuple selectedConfiguration = null;
|
AudioConfigurationTuple selectedConfiguration = null;
|
||||||
HashSet<AudioConfigurationTuple> seenConfigurationTuples = new HashSet<>();
|
HashSet<AudioConfigurationTuple> seenConfigurationTuples = new HashSet<>();
|
||||||
|
|
@ -2024,7 +2055,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
configuration,
|
configuration,
|
||||||
maxAudioBitrate,
|
maxAudioBitrate,
|
||||||
allowMixedMimeTypeAdaptiveness,
|
allowMixedMimeTypeAdaptiveness,
|
||||||
allowMixedSampleRateAdaptiveness);
|
allowMixedSampleRateAdaptiveness,
|
||||||
|
allowAudioMixedChannelCountAdaptiveness);
|
||||||
if (configurationCount > selectedConfigurationTrackCount) {
|
if (configurationCount > selectedConfigurationTrackCount) {
|
||||||
selectedConfiguration = configuration;
|
selectedConfiguration = configuration;
|
||||||
selectedConfigurationTrackCount = configurationCount;
|
selectedConfigurationTrackCount = configurationCount;
|
||||||
|
|
@ -2044,7 +2076,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
selectedConfiguration,
|
selectedConfiguration,
|
||||||
maxAudioBitrate,
|
maxAudioBitrate,
|
||||||
allowMixedMimeTypeAdaptiveness,
|
allowMixedMimeTypeAdaptiveness,
|
||||||
allowMixedSampleRateAdaptiveness)) {
|
allowMixedSampleRateAdaptiveness,
|
||||||
|
allowAudioMixedChannelCountAdaptiveness)) {
|
||||||
adaptiveIndices[index++] = i;
|
adaptiveIndices[index++] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2059,7 +2092,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
AudioConfigurationTuple configuration,
|
AudioConfigurationTuple configuration,
|
||||||
int maxAudioBitrate,
|
int maxAudioBitrate,
|
||||||
boolean allowMixedMimeTypeAdaptiveness,
|
boolean allowMixedMimeTypeAdaptiveness,
|
||||||
boolean allowMixedSampleRateAdaptiveness) {
|
boolean allowMixedSampleRateAdaptiveness,
|
||||||
|
boolean allowAudioMixedChannelCountAdaptiveness) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < group.length; i++) {
|
for (int i = 0; i < group.length; i++) {
|
||||||
if (isSupportedAdaptiveAudioTrack(
|
if (isSupportedAdaptiveAudioTrack(
|
||||||
|
|
@ -2068,7 +2102,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
configuration,
|
configuration,
|
||||||
maxAudioBitrate,
|
maxAudioBitrate,
|
||||||
allowMixedMimeTypeAdaptiveness,
|
allowMixedMimeTypeAdaptiveness,
|
||||||
allowMixedSampleRateAdaptiveness)) {
|
allowMixedSampleRateAdaptiveness,
|
||||||
|
allowAudioMixedChannelCountAdaptiveness)) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2081,11 +2116,13 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||||
AudioConfigurationTuple configuration,
|
AudioConfigurationTuple configuration,
|
||||||
int maxAudioBitrate,
|
int maxAudioBitrate,
|
||||||
boolean allowMixedMimeTypeAdaptiveness,
|
boolean allowMixedMimeTypeAdaptiveness,
|
||||||
boolean allowMixedSampleRateAdaptiveness) {
|
boolean allowMixedSampleRateAdaptiveness,
|
||||||
|
boolean allowAudioMixedChannelCountAdaptiveness) {
|
||||||
return isSupported(formatSupport, false)
|
return isSupported(formatSupport, false)
|
||||||
&& (format.bitrate == Format.NO_VALUE || format.bitrate <= maxAudioBitrate)
|
&& (format.bitrate == Format.NO_VALUE || format.bitrate <= maxAudioBitrate)
|
||||||
&& (format.channelCount != Format.NO_VALUE
|
&& (allowAudioMixedChannelCountAdaptiveness
|
||||||
&& format.channelCount == configuration.channelCount)
|
|| (format.channelCount != Format.NO_VALUE
|
||||||
|
&& format.channelCount == configuration.channelCount))
|
||||||
&& (allowMixedMimeTypeAdaptiveness
|
&& (allowMixedMimeTypeAdaptiveness
|
||||||
|| (format.sampleMimeType != null
|
|| (format.sampleMimeType != null
|
||||||
&& TextUtils.equals(format.sampleMimeType, configuration.mimeType)))
|
&& TextUtils.equals(format.sampleMimeType, configuration.mimeType)))
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,7 @@ public final class DefaultTrackSelectorTest {
|
||||||
/* exceedAudioConstraintsIfNecessary= */ false,
|
/* exceedAudioConstraintsIfNecessary= */ false,
|
||||||
/* allowAudioMixedMimeTypeAdaptiveness= */ true,
|
/* allowAudioMixedMimeTypeAdaptiveness= */ true,
|
||||||
/* allowAudioMixedSampleRateAdaptiveness= */ false,
|
/* allowAudioMixedSampleRateAdaptiveness= */ false,
|
||||||
|
/* allowAudioMixedChannelCountAdaptiveness= */ true,
|
||||||
// Text
|
// Text
|
||||||
/* preferredTextLanguage= */ "de",
|
/* preferredTextLanguage= */ "de",
|
||||||
/* selectUndeterminedTextLanguage= */ true,
|
/* selectUndeterminedTextLanguage= */ true,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue