mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Resolve conflicts
This commit is contained in:
parent
02573297f4
commit
097c045bef
1 changed files with 64 additions and 11 deletions
|
|
@ -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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
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,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue