use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksWithinCapabilitiesAndForceHighestBitrateSelectHigherBitrate.
/**
* Tests that track selector will select the highest bitrate supported audio track when {@link
* Parameters#forceHighestSupportedBitrate} is set.
*/
@Test
public void selectTracksWithinCapabilitiesAndForceHighestBitrateSelectHigherBitrate() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format lowerBitrateFormat = formatBuilder.setId("5000").setAverageBitrate(5000).build();
Format higherBitrateFormat = formatBuilder.setId("15000").setAverageBitrate(15000).build();
Format exceedsBitrateFormat = formatBuilder.setId("30000").setAverageBitrate(30000).build();
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(defaultParameters.buildUpon().setForceHighestSupportedBitrate(true));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { mappedAudioRendererCapabilities }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, higherBitrateFormat);
}
use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksPreferTrackWithinCapabilitiesOverPreferredLanguage.
/**
* Tests that track selector will prefer tracks that are within renderer's capabilities over track
* that have language matching preferred audio given by {@link Parameters} but exceed renderer's
* capabilities.
*/
@Test
public void selectTracksPreferTrackWithinCapabilitiesOverPreferredLanguage() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format exceededEnFormat = formatBuilder.setId("exceededFormat").setLanguage("eng").build();
Format supportedFrFormat = formatBuilder.setId("supportedFormat").setLanguage("fra").build();
TrackGroupArray trackGroups = wrapFormats(exceededEnFormat, supportedFrFormat);
Map<String, Integer> mappedCapabilities = new HashMap<>();
mappedCapabilities.put(exceededEnFormat.id, FORMAT_EXCEEDS_CAPABILITIES);
mappedCapabilities.put(supportedFrFormat.id, FORMAT_HANDLED);
RendererCapabilities mappedAudioRendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_AUDIO, mappedCapabilities);
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioLanguage("eng"));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { mappedAudioRendererCapabilities }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, supportedFrFormat);
}
use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class DefaultTrackSelectorTest method parameters_buildUponThenBuild_isEqual.
@Test
public void parameters_buildUponThenBuild_isEqual() {
Parameters parameters = buildParametersForEqualsTest();
assertThat(parameters.buildUpon().build()).isEqualTo(parameters);
}
use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class DefaultTrackSelectorTest method roundTripViaBundle_ofParameters_yieldsEqualInstance.
/**
* Tests {@link Parameters} {@link Bundleable} implementation.
*/
@Test
public void roundTripViaBundle_ofParameters_yieldsEqualInstance() {
Parameters parametersToBundle = buildParametersForEqualsTest();
Parameters parametersFromBundle = Parameters.CREATOR.fromBundle(parametersToBundle.toBundle());
assertThat(parametersFromBundle).isEqualTo(parametersToBundle);
}
use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class ExtractorAsserts method assertAllBehaviors.
/**
* Asserts that an extractor behaves correctly given valid input data:
*
* <ul>
* <li>Calls {@link Extractor#seek(long, long)} and {@link Extractor#release()} without calling
* {@link Extractor#init(ExtractorOutput)} to check these calls do not fail.
* <li>Calls {@link #assertOutput(Extractor, String, byte[], Context, boolean, boolean, boolean,
* boolean, boolean)} with all possible combinations of "simulate" parameters.
* </ul>
*
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
* class which is to be tested.
* @param file The path to the input sample.
* @param dumpFilesPrefix The dump files prefix appended to the dump files path.
* @throws IOException If reading from the input fails.
*/
public static void assertAllBehaviors(ExtractorFactory factory, String file, String dumpFilesPrefix) throws IOException {
// Check behavior prior to initialization.
Extractor extractor = factory.create();
extractor.seek(0, 0);
extractor.release();
// Assert output.
Context context = ApplicationProvider.getApplicationContext();
byte[] fileData = TestUtil.getByteArray(context, file);
assertOutput(factory.create(), dumpFilesPrefix, fileData, context, false, true, false, false, false);
assertOutput(factory.create(), dumpFilesPrefix, fileData, context, false, true, false, false, true);
assertOutput(factory.create(), dumpFilesPrefix, fileData, context, false, true, false, true, false);
assertOutput(factory.create(), dumpFilesPrefix, fileData, context, false, true, false, true, true);
assertOutput(factory.create(), dumpFilesPrefix, fileData, context, false, true, true, false, false);
assertOutput(factory.create(), dumpFilesPrefix, fileData, context, false, true, true, false, true);
assertOutput(factory.create(), dumpFilesPrefix, fileData, context, false, true, true, true, false);
assertOutput(factory.create(), dumpFilesPrefix, fileData, context, false, true, true, true, true);
assertOutput(factory.create(), dumpFilesPrefix, fileData, context, false, false, false, false, false);
}
Aggregations