mirror of
https://github.com/androidx/media.git
synced 2025-05-06 23:20:42 +08:00
Format.Builder: Simplify some test classes
PiperOrigin-RevId: 297865356
This commit is contained in:
parent
3730639c95
commit
4c1f0c40ce
@ -96,22 +96,11 @@ public final class MediaCodecUtilTest {
|
|||||||
/* colorTransfer= */ C.COLOR_TRANSFER_SDR,
|
/* colorTransfer= */ C.COLOR_TRANSFER_SDR,
|
||||||
/* hdrStaticInfo= */ new byte[] {1, 2, 3, 4, 5, 6, 7});
|
/* hdrStaticInfo= */ new byte[] {1, 2, 3, 4, 5, 6, 7});
|
||||||
Format format =
|
Format format =
|
||||||
Format.createVideoSampleFormat(
|
new Format.Builder()
|
||||||
/* id= */ null,
|
.setSampleMimeType(MimeTypes.VIDEO_AV1)
|
||||||
MimeTypes.VIDEO_AV1,
|
.setCodecs("av01.0.21M.10")
|
||||||
/* codecs= */ "av01.0.21M.10",
|
.setColorInfo(colorInfo)
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
.build();
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* width= */ 1024,
|
|
||||||
/* height= */ 768,
|
|
||||||
/* frameRate= */ Format.NO_VALUE,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* rotationDegrees= */ Format.NO_VALUE,
|
|
||||||
/* pixelWidthHeightRatio= */ 0,
|
|
||||||
/* projectionData= */ null,
|
|
||||||
/* stereoMode= */ Format.NO_VALUE,
|
|
||||||
/* colorInfo= */ colorInfo,
|
|
||||||
/* drmInitData */ null);
|
|
||||||
assertCodecProfileAndLevelForFormat(
|
assertCodecProfileAndLevelForFormat(
|
||||||
format,
|
format,
|
||||||
MediaCodecInfo.CodecProfileLevel.AV1ProfileMain10HDR10,
|
MediaCodecInfo.CodecProfileLevel.AV1ProfileMain10HDR10,
|
||||||
@ -127,22 +116,11 @@ public final class MediaCodecUtilTest {
|
|||||||
/* colorTransfer= */ C.COLOR_TRANSFER_HLG,
|
/* colorTransfer= */ C.COLOR_TRANSFER_HLG,
|
||||||
/* hdrStaticInfo= */ null);
|
/* hdrStaticInfo= */ null);
|
||||||
Format format =
|
Format format =
|
||||||
Format.createVideoSampleFormat(
|
new Format.Builder()
|
||||||
/* id= */ null,
|
.setSampleMimeType(MimeTypes.VIDEO_AV1)
|
||||||
MimeTypes.VIDEO_AV1,
|
.setCodecs("av01.0.21M.10")
|
||||||
/* codecs= */ "av01.0.21M.10",
|
.setColorInfo(colorInfo)
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
.build();
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* width= */ 1024,
|
|
||||||
/* height= */ 768,
|
|
||||||
/* frameRate= */ Format.NO_VALUE,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* rotationDegrees= */ Format.NO_VALUE,
|
|
||||||
/* pixelWidthHeightRatio= */ 0,
|
|
||||||
/* projectionData= */ null,
|
|
||||||
/* stereoMode= */ Format.NO_VALUE,
|
|
||||||
/* colorInfo= */ colorInfo,
|
|
||||||
/* drmInitData */ null);
|
|
||||||
assertCodecProfileAndLevelForFormat(
|
assertCodecProfileAndLevelForFormat(
|
||||||
format,
|
format,
|
||||||
MediaCodecInfo.CodecProfileLevel.AV1ProfileMain10HDR10,
|
MediaCodecInfo.CodecProfileLevel.AV1ProfileMain10HDR10,
|
||||||
@ -161,52 +139,20 @@ public final class MediaCodecUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getCodecProfileAndLevel_rejectsNullCodecString() {
|
public void getCodecProfileAndLevel_rejectsNullCodecString() {
|
||||||
Format format =
|
Format format = new Format.Builder().setCodecs(null).build();
|
||||||
Format.createVideoSampleFormat(
|
|
||||||
/* id= */ null,
|
|
||||||
/* sampleMimeType= */ MimeTypes.VIDEO_UNKNOWN,
|
|
||||||
/* codecs= */ null,
|
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* width= */ 1024,
|
|
||||||
/* height= */ 768,
|
|
||||||
/* frameRate= */ Format.NO_VALUE,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* drmInitData= */ null);
|
|
||||||
assertThat(MediaCodecUtil.getCodecProfileAndLevel(format)).isNull();
|
assertThat(MediaCodecUtil.getCodecProfileAndLevel(format)).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getCodecProfileAndLevel_rejectsEmptyCodecString() {
|
public void getCodecProfileAndLevel_rejectsEmptyCodecString() {
|
||||||
Format format =
|
Format format = new Format.Builder().setCodecs("").build();
|
||||||
Format.createVideoSampleFormat(
|
|
||||||
/* id= */ null,
|
|
||||||
/* sampleMimeType= */ MimeTypes.VIDEO_UNKNOWN,
|
|
||||||
/* codecs= */ "",
|
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* width= */ 1024,
|
|
||||||
/* height= */ 768,
|
|
||||||
/* frameRate= */ Format.NO_VALUE,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* drmInitData= */ null);
|
|
||||||
assertThat(MediaCodecUtil.getCodecProfileAndLevel(format)).isNull();
|
assertThat(MediaCodecUtil.getCodecProfileAndLevel(format)).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertCodecProfileAndLevelForCodecsString(
|
private static void assertCodecProfileAndLevelForCodecsString(
|
||||||
String mimeType, String codecs, int profile, int level) {
|
String sampleMimeType, String codecs, int profile, int level) {
|
||||||
Format format =
|
Format format =
|
||||||
Format.createVideoSampleFormat(
|
new Format.Builder().setSampleMimeType(sampleMimeType).setCodecs(codecs).build();
|
||||||
/* id= */ null,
|
|
||||||
mimeType,
|
|
||||||
/* codecs= */ codecs,
|
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* width= */ 1024,
|
|
||||||
/* height= */ 768,
|
|
||||||
/* frameRate= */ Format.NO_VALUE,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* drmInitData= */ null);
|
|
||||||
assertCodecProfileAndLevelForFormat(format, profile, level);
|
assertCodecProfileAndLevelForFormat(format, profile, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +79,21 @@ public final class DefaultTrackSelectorTest {
|
|||||||
private static final RendererCapabilities[] RENDERER_CAPABILITIES_WITH_NO_SAMPLE_RENDERER =
|
private static final RendererCapabilities[] RENDERER_CAPABILITIES_WITH_NO_SAMPLE_RENDERER =
|
||||||
new RendererCapabilities[] {VIDEO_CAPABILITIES, NO_SAMPLE_CAPABILITIES};
|
new RendererCapabilities[] {VIDEO_CAPABILITIES, NO_SAMPLE_CAPABILITIES};
|
||||||
|
|
||||||
private static final Format VIDEO_FORMAT = buildVideoFormat("video");
|
private static final Format VIDEO_FORMAT =
|
||||||
private static final Format AUDIO_FORMAT = buildAudioFormat("audio");
|
new Format.Builder()
|
||||||
|
.setSampleMimeType(MimeTypes.VIDEO_H264)
|
||||||
|
.setWidth(1024)
|
||||||
|
.setHeight(768)
|
||||||
|
.build();
|
||||||
|
private static final Format AUDIO_FORMAT =
|
||||||
|
new Format.Builder()
|
||||||
|
.setSampleMimeType(MimeTypes.AUDIO_AAC)
|
||||||
|
.setChannelCount(2)
|
||||||
|
.setSampleRate(44100)
|
||||||
|
.build();
|
||||||
|
private static final Format TEXT_FORMAT =
|
||||||
|
new Format.Builder().setSampleMimeType(MimeTypes.TEXT_VTT).build();
|
||||||
|
|
||||||
private static final TrackGroup VIDEO_TRACK_GROUP = new TrackGroup(VIDEO_FORMAT);
|
private static final TrackGroup VIDEO_TRACK_GROUP = new TrackGroup(VIDEO_FORMAT);
|
||||||
private static final TrackGroup AUDIO_TRACK_GROUP = new TrackGroup(AUDIO_FORMAT);
|
private static final TrackGroup AUDIO_TRACK_GROUP = new TrackGroup(AUDIO_FORMAT);
|
||||||
private static final TrackGroupArray TRACK_GROUPS =
|
private static final TrackGroupArray TRACK_GROUPS =
|
||||||
@ -328,12 +341,10 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksSelectTrackWithSelectionFlag() throws Exception {
|
public void selectTracksSelectTrackWithSelectionFlag() throws Exception {
|
||||||
Format audioFormat =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
buildAudioFormatWithLanguageAndFlags(
|
Format audioFormat = formatBuilder.setSelectionFlags(0).build();
|
||||||
"audio", /* language= */ null, /* selectionFlags= */ 0);
|
|
||||||
Format formatWithSelectionFlag =
|
Format formatWithSelectionFlag =
|
||||||
buildAudioFormatWithLanguageAndFlags(
|
formatBuilder.setSelectionFlags(C.SELECTION_FLAG_DEFAULT).build();
|
||||||
"audio", /* language= */ null, C.SELECTION_FLAG_DEFAULT);
|
|
||||||
TrackGroupArray trackGroups = wrapFormats(audioFormat, formatWithSelectionFlag);
|
TrackGroupArray trackGroups = wrapFormats(audioFormat, formatWithSelectionFlag);
|
||||||
|
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
@ -348,45 +359,10 @@ public final class DefaultTrackSelectorTest {
|
|||||||
/** Tests that adaptive audio track selections respect the maximum audio bitrate. */
|
/** Tests that adaptive audio track selections respect the maximum audio bitrate. */
|
||||||
@Test
|
@Test
|
||||||
public void selectAdaptiveAudioTrackGroupWithMaxBitrate() throws ExoPlaybackException {
|
public void selectAdaptiveAudioTrackGroupWithMaxBitrate() throws ExoPlaybackException {
|
||||||
Format format128k =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format.createAudioSampleFormat(
|
Format format128k = formatBuilder.setAverageBitrate(128 * 1024).build();
|
||||||
/* id= */ "128",
|
Format format192k = formatBuilder.setAverageBitrate(192 * 1024).build();
|
||||||
/* sampleMimeType= */ MimeTypes.AUDIO_AAC,
|
Format format256k = formatBuilder.setAverageBitrate(256 * 1024).build();
|
||||||
/* codecs= */ "mp4a.40.2",
|
|
||||||
/* bitrate= */ 128 * 1024,
|
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* channelCount= */ 2,
|
|
||||||
/* sampleRate= */ 44100,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* drmInitData= */ null,
|
|
||||||
/* selectionFlags= */ 0,
|
|
||||||
/* language= */ null);
|
|
||||||
Format format192k =
|
|
||||||
Format.createAudioSampleFormat(
|
|
||||||
/* id= */ "192",
|
|
||||||
/* sampleMimeType= */ MimeTypes.AUDIO_AAC,
|
|
||||||
/* codecs= */ "mp4a.40.2",
|
|
||||||
/* bitrate= */ 192 * 1024,
|
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* channelCount= */ 2,
|
|
||||||
/* sampleRate= */ 44100,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* drmInitData= */ null,
|
|
||||||
/* selectionFlags= */ 0,
|
|
||||||
/* language= */ null);
|
|
||||||
Format format256k =
|
|
||||||
Format.createAudioSampleFormat(
|
|
||||||
/* id= */ "256",
|
|
||||||
/* sampleMimeType= */ MimeTypes.AUDIO_AAC,
|
|
||||||
/* codecs= */ "mp4a.40.2",
|
|
||||||
/* bitrate= */ 256 * 1024,
|
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* channelCount= */ 2,
|
|
||||||
/* sampleRate= */ 44100,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* drmInitData= */ null,
|
|
||||||
/* selectionFlags= */ 0,
|
|
||||||
/* language= */ null);
|
|
||||||
RendererCapabilities[] rendererCapabilities = {
|
RendererCapabilities[] rendererCapabilities = {
|
||||||
ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES
|
ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES
|
||||||
};
|
};
|
||||||
@ -422,12 +398,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksSelectPreferredAudioLanguage() throws Exception {
|
public void selectTracksSelectPreferredAudioLanguage() throws Exception {
|
||||||
Format frAudioFormat =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format.createAudioSampleFormat("audio", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
Format frAudioFormat = formatBuilder.setLanguage("fra").build();
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, "fra");
|
Format enAudioFormat = formatBuilder.setLanguage("eng").build();
|
||||||
Format enAudioFormat =
|
|
||||||
Format.createAudioSampleFormat("audio", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, "eng");
|
|
||||||
TrackGroupArray trackGroups = wrapFormats(frAudioFormat, enAudioFormat);
|
TrackGroupArray trackGroups = wrapFormats(frAudioFormat, enAudioFormat);
|
||||||
|
|
||||||
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioLanguage("eng"));
|
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioLanguage("eng"));
|
||||||
@ -446,13 +419,11 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksSelectPreferredAudioLanguageOverSelectionFlag() throws Exception {
|
public void selectTracksSelectPreferredAudioLanguageOverSelectionFlag() throws Exception {
|
||||||
Format frAudioFormat =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format.createAudioSampleFormat("audio", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
Format frDefaultFormat =
|
||||||
Format.NO_VALUE, 2, 44100, null, null, C.SELECTION_FLAG_DEFAULT, "fra");
|
formatBuilder.setLanguage("fra").setSelectionFlags(C.SELECTION_FLAG_DEFAULT).build();
|
||||||
Format enAudioFormat =
|
Format enNonDefaultFormat = formatBuilder.setLanguage("eng").setSelectionFlags(0).build();
|
||||||
Format.createAudioSampleFormat("audio", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
TrackGroupArray trackGroups = wrapFormats(frDefaultFormat, enNonDefaultFormat);
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, "eng");
|
|
||||||
TrackGroupArray trackGroups = wrapFormats(frAudioFormat, enAudioFormat);
|
|
||||||
|
|
||||||
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioLanguage("eng"));
|
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioLanguage("eng"));
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
@ -461,7 +432,7 @@ public final class DefaultTrackSelectorTest {
|
|||||||
trackGroups,
|
trackGroups,
|
||||||
periodId,
|
periodId,
|
||||||
TIMELINE);
|
TIMELINE);
|
||||||
assertFixedSelection(result.selections.get(0), trackGroups, enAudioFormat);
|
assertFixedSelection(result.selections.get(0), trackGroups, enNonDefaultFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -470,8 +441,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksPreferTrackWithinCapabilities() throws Exception {
|
public void selectTracksPreferTrackWithinCapabilities() throws Exception {
|
||||||
Format supportedFormat = buildAudioFormat("supportedFormat");
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format exceededFormat = buildAudioFormat("exceededFormat");
|
Format supportedFormat = formatBuilder.setId("supportedFormat").build();
|
||||||
|
Format exceededFormat = formatBuilder.setId("exceededFormat").build();
|
||||||
TrackGroupArray trackGroups = wrapFormats(exceededFormat, supportedFormat);
|
TrackGroupArray trackGroups = wrapFormats(exceededFormat, supportedFormat);
|
||||||
|
|
||||||
Map<String, Integer> mappedCapabilities = new HashMap<>();
|
Map<String, Integer> mappedCapabilities = new HashMap<>();
|
||||||
@ -496,10 +468,7 @@ public final class DefaultTrackSelectorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void selectTracksWithNoTrackWithinCapabilitiesSelectExceededCapabilityTrack()
|
public void selectTracksWithNoTrackWithinCapabilitiesSelectExceededCapabilityTrack()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Format audioFormat =
|
TrackGroupArray trackGroups = singleTrackGroup(AUDIO_FORMAT);
|
||||||
Format.createAudioSampleFormat("audio", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, null);
|
|
||||||
TrackGroupArray trackGroups = singleTrackGroup(audioFormat);
|
|
||||||
|
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
trackSelector.selectTracks(
|
trackSelector.selectTracks(
|
||||||
@ -507,7 +476,7 @@ public final class DefaultTrackSelectorTest {
|
|||||||
trackGroups,
|
trackGroups,
|
||||||
periodId,
|
periodId,
|
||||||
TIMELINE);
|
TIMELINE);
|
||||||
assertFixedSelection(result.selections.get(0), trackGroups, audioFormat);
|
assertFixedSelection(result.selections.get(0), trackGroups, AUDIO_FORMAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -518,10 +487,7 @@ public final class DefaultTrackSelectorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void selectTracksWithNoTrackWithinCapabilitiesAndSetByParamsReturnNoSelection()
|
public void selectTracksWithNoTrackWithinCapabilitiesAndSetByParamsReturnNoSelection()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Format audioFormat =
|
TrackGroupArray trackGroups = singleTrackGroup(AUDIO_FORMAT);
|
||||||
Format.createAudioSampleFormat("audio", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, null);
|
|
||||||
TrackGroupArray trackGroups = singleTrackGroup(audioFormat);
|
|
||||||
|
|
||||||
trackSelector.setParameters(
|
trackSelector.setParameters(
|
||||||
defaultParameters.buildUpon().setExceedRendererCapabilitiesIfNecessary(false));
|
defaultParameters.buildUpon().setExceedRendererCapabilitiesIfNecessary(false));
|
||||||
@ -540,22 +506,10 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksPreferTrackWithinCapabilitiesOverSelectionFlag() throws Exception {
|
public void selectTracksPreferTrackWithinCapabilitiesOverSelectionFlag() throws Exception {
|
||||||
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format exceededWithSelectionFlagFormat =
|
Format exceededWithSelectionFlagFormat =
|
||||||
Format.createAudioSampleFormat(
|
formatBuilder.setId("exceededFormat").setSelectionFlags(C.SELECTION_FLAG_DEFAULT).build();
|
||||||
"exceededFormat",
|
Format supportedFormat = formatBuilder.setId("supportedFormat").setSelectionFlags(0).build();
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
null,
|
|
||||||
Format.NO_VALUE,
|
|
||||||
Format.NO_VALUE,
|
|
||||||
2,
|
|
||||||
44100,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
C.SELECTION_FLAG_DEFAULT,
|
|
||||||
null);
|
|
||||||
Format supportedFormat =
|
|
||||||
Format.createAudioSampleFormat("supportedFormat", MimeTypes.AUDIO_AAC, null,
|
|
||||||
Format.NO_VALUE, Format.NO_VALUE, 2, 44100, null, null, 0, null);
|
|
||||||
TrackGroupArray trackGroups = wrapFormats(exceededWithSelectionFlagFormat, supportedFormat);
|
TrackGroupArray trackGroups = wrapFormats(exceededWithSelectionFlagFormat, supportedFormat);
|
||||||
|
|
||||||
Map<String, Integer> mappedCapabilities = new HashMap<>();
|
Map<String, Integer> mappedCapabilities = new HashMap<>();
|
||||||
@ -580,22 +534,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksPreferTrackWithinCapabilitiesOverPreferredLanguage() throws Exception {
|
public void selectTracksPreferTrackWithinCapabilitiesOverPreferredLanguage() throws Exception {
|
||||||
Format exceededEnFormat =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format.createAudioSampleFormat(
|
Format exceededEnFormat = formatBuilder.setId("exceededFormat").setLanguage("eng").build();
|
||||||
"exceededFormat",
|
Format supportedFrFormat = formatBuilder.setId("supportedFormat").setLanguage("fra").build();
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
null,
|
|
||||||
Format.NO_VALUE,
|
|
||||||
Format.NO_VALUE,
|
|
||||||
2,
|
|
||||||
44100,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
0,
|
|
||||||
"eng");
|
|
||||||
Format supportedFrFormat =
|
|
||||||
Format.createAudioSampleFormat("supportedFormat", MimeTypes.AUDIO_AAC, null,
|
|
||||||
Format.NO_VALUE, Format.NO_VALUE, 2, 44100, null, null, 0, "fra");
|
|
||||||
TrackGroupArray trackGroups = wrapFormats(exceededEnFormat, supportedFrFormat);
|
TrackGroupArray trackGroups = wrapFormats(exceededEnFormat, supportedFrFormat);
|
||||||
|
|
||||||
Map<String, Integer> mappedCapabilities = new HashMap<>();
|
Map<String, Integer> mappedCapabilities = new HashMap<>();
|
||||||
@ -622,22 +563,15 @@ public final class DefaultTrackSelectorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void selectTracksPreferTrackWithinCapabilitiesOverSelectionFlagAndPreferredLanguage()
|
public void selectTracksPreferTrackWithinCapabilitiesOverSelectionFlagAndPreferredLanguage()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format exceededDefaultSelectionEnFormat =
|
Format exceededDefaultSelectionEnFormat =
|
||||||
Format.createAudioSampleFormat(
|
formatBuilder
|
||||||
"exceededFormat",
|
.setId("exceededFormat")
|
||||||
MimeTypes.AUDIO_AAC,
|
.setSelectionFlags(C.SELECTION_FLAG_DEFAULT)
|
||||||
null,
|
.setLanguage("eng")
|
||||||
Format.NO_VALUE,
|
.build();
|
||||||
Format.NO_VALUE,
|
|
||||||
2,
|
|
||||||
44100,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
C.SELECTION_FLAG_DEFAULT,
|
|
||||||
"eng");
|
|
||||||
Format supportedFrFormat =
|
Format supportedFrFormat =
|
||||||
Format.createAudioSampleFormat("supportedFormat", MimeTypes.AUDIO_AAC, null,
|
formatBuilder.setId("supportedFormat").setSelectionFlags(0).setLanguage("fra").build();
|
||||||
Format.NO_VALUE, Format.NO_VALUE, 2, 44100, null, null, 0, "fra");
|
|
||||||
TrackGroupArray trackGroups = wrapFormats(exceededDefaultSelectionEnFormat, supportedFrFormat);
|
TrackGroupArray trackGroups = wrapFormats(exceededDefaultSelectionEnFormat, supportedFrFormat);
|
||||||
|
|
||||||
Map<String, Integer> mappedCapabilities = new HashMap<>();
|
Map<String, Integer> mappedCapabilities = new HashMap<>();
|
||||||
@ -662,22 +596,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksWithinCapabilitiesSelectHigherNumChannel() throws Exception {
|
public void selectTracksWithinCapabilitiesSelectHigherNumChannel() throws Exception {
|
||||||
Format higherChannelFormat =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format.createAudioSampleFormat(
|
Format higherChannelFormat = formatBuilder.setChannelCount(6).build();
|
||||||
"audioFormat",
|
Format lowerChannelFormat = formatBuilder.setChannelCount(2).build();
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
null,
|
|
||||||
Format.NO_VALUE,
|
|
||||||
Format.NO_VALUE,
|
|
||||||
6,
|
|
||||||
44100,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
0,
|
|
||||||
null);
|
|
||||||
Format lowerChannelFormat =
|
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, null);
|
|
||||||
TrackGroupArray trackGroups = wrapFormats(higherChannelFormat, lowerChannelFormat);
|
TrackGroupArray trackGroups = wrapFormats(higherChannelFormat, lowerChannelFormat);
|
||||||
|
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
@ -695,12 +616,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksWithinCapabilitiesSelectHigherSampleRate() throws Exception {
|
public void selectTracksWithinCapabilitiesSelectHigherSampleRate() throws Exception {
|
||||||
Format higherSampleRateFormat =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
Format higherSampleRateFormat = formatBuilder.setSampleRate(44100).build();
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, null);
|
Format lowerSampleRateFormat = formatBuilder.setSampleRate(22050).build();
|
||||||
Format lowerSampleRateFormat =
|
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
|
||||||
Format.NO_VALUE, 2, 22050, null, null, 0, null);
|
|
||||||
TrackGroupArray trackGroups = wrapFormats(higherSampleRateFormat, lowerSampleRateFormat);
|
TrackGroupArray trackGroups = wrapFormats(higherSampleRateFormat, lowerSampleRateFormat);
|
||||||
|
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
@ -719,32 +637,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void selectAudioTracks_withinCapabilities_andSameLanguage_selectsHigherBitrate()
|
public void selectAudioTracks_withinCapabilities_andSameLanguage_selectsHigherBitrate()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Format lowerBitrateFormat =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon().setLanguage("en");
|
||||||
Format.createAudioSampleFormat(
|
Format lowerBitrateFormat = formatBuilder.setAverageBitrate(15000).build();
|
||||||
"audioFormat",
|
Format higherBitrateFormat = formatBuilder.setAverageBitrate(30000).build();
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
/* codecs= */ null,
|
|
||||||
/* bitrate= */ 15000,
|
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* channelCount= */ 2,
|
|
||||||
/* sampleRate= */ 44100,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* drmInitData= */ null,
|
|
||||||
/* selectionFlags= */ 0,
|
|
||||||
/* language= */ "hi");
|
|
||||||
Format higherBitrateFormat =
|
|
||||||
Format.createAudioSampleFormat(
|
|
||||||
"audioFormat",
|
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
/* codecs= */ null,
|
|
||||||
/* bitrate= */ 30000,
|
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* channelCount= */ 2,
|
|
||||||
/* sampleRate= */ 44100,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* drmInitData= */ null,
|
|
||||||
/* selectionFlags= */ 0,
|
|
||||||
/* language= */ "hi");
|
|
||||||
TrackGroupArray trackGroups = wrapFormats(lowerBitrateFormat, higherBitrateFormat);
|
TrackGroupArray trackGroups = wrapFormats(lowerBitrateFormat, higherBitrateFormat);
|
||||||
|
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
@ -764,32 +659,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void selectAudioTracks_withinCapabilities_andDifferentLanguage_selectsFirstTrack()
|
public void selectAudioTracks_withinCapabilities_andDifferentLanguage_selectsFirstTrack()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Format firstLanguageFormat =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format.createAudioSampleFormat(
|
Format firstLanguageFormat = formatBuilder.setAverageBitrate(15000).setLanguage("hi").build();
|
||||||
"audioFormat",
|
Format higherBitrateFormat = formatBuilder.setAverageBitrate(30000).setLanguage("te").build();
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
/* codecs= */ null,
|
|
||||||
/* bitrate= */ 15000,
|
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* channelCount= */ 2,
|
|
||||||
/* sampleRate= */ 44100,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* drmInitData= */ null,
|
|
||||||
/* selectionFlags= */ 0,
|
|
||||||
/* language= */ "hi");
|
|
||||||
Format higherBitrateFormat =
|
|
||||||
Format.createAudioSampleFormat(
|
|
||||||
"audioFormat",
|
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
/* codecs= */ null,
|
|
||||||
/* bitrate= */ 30000,
|
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* channelCount= */ 2,
|
|
||||||
/* sampleRate= */ 44100,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* drmInitData= */ null,
|
|
||||||
/* selectionFlags= */ 0,
|
|
||||||
/* language= */ "te");
|
|
||||||
TrackGroupArray trackGroups = wrapFormats(firstLanguageFormat, higherBitrateFormat);
|
TrackGroupArray trackGroups = wrapFormats(firstLanguageFormat, higherBitrateFormat);
|
||||||
|
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
@ -808,22 +680,11 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksPreferHigherNumChannelBeforeSampleRate() throws Exception {
|
public void selectTracksPreferHigherNumChannelBeforeSampleRate() throws Exception {
|
||||||
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format higherChannelLowerSampleRateFormat =
|
Format higherChannelLowerSampleRateFormat =
|
||||||
Format.createAudioSampleFormat(
|
formatBuilder.setChannelCount(6).setSampleRate(22050).build();
|
||||||
"audioFormat",
|
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
null,
|
|
||||||
Format.NO_VALUE,
|
|
||||||
Format.NO_VALUE,
|
|
||||||
6,
|
|
||||||
22050,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
0,
|
|
||||||
null);
|
|
||||||
Format lowerChannelHigherSampleRateFormat =
|
Format lowerChannelHigherSampleRateFormat =
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
formatBuilder.setChannelCount(2).setSampleRate(44100).build();
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, null);
|
|
||||||
TrackGroupArray trackGroups =
|
TrackGroupArray trackGroups =
|
||||||
wrapFormats(higherChannelLowerSampleRateFormat, lowerChannelHigherSampleRateFormat);
|
wrapFormats(higherChannelLowerSampleRateFormat, lowerChannelHigherSampleRateFormat);
|
||||||
|
|
||||||
@ -842,12 +703,11 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksPreferHigherSampleRateBeforeBitrate() throws Exception {
|
public void selectTracksPreferHigherSampleRateBeforeBitrate() throws Exception {
|
||||||
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format higherSampleRateLowerBitrateFormat =
|
Format higherSampleRateLowerBitrateFormat =
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, 15000,
|
formatBuilder.setAverageBitrate(15000).setSampleRate(44100).build();
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, null);
|
|
||||||
Format lowerSampleRateHigherBitrateFormat =
|
Format lowerSampleRateHigherBitrateFormat =
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, 30000,
|
formatBuilder.setAverageBitrate(30000).setSampleRate(22050).build();
|
||||||
Format.NO_VALUE, 2, 22050, null, null, 0, null);
|
|
||||||
TrackGroupArray trackGroups =
|
TrackGroupArray trackGroups =
|
||||||
wrapFormats(higherSampleRateLowerBitrateFormat, lowerSampleRateHigherBitrateFormat);
|
wrapFormats(higherSampleRateLowerBitrateFormat, lowerSampleRateHigherBitrateFormat);
|
||||||
|
|
||||||
@ -866,22 +726,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksExceedingCapabilitiesSelectLowerNumChannel() throws Exception {
|
public void selectTracksExceedingCapabilitiesSelectLowerNumChannel() throws Exception {
|
||||||
Format higherChannelFormat =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format.createAudioSampleFormat(
|
Format higherChannelFormat = formatBuilder.setChannelCount(6).build();
|
||||||
"audioFormat",
|
Format lowerChannelFormat = formatBuilder.setChannelCount(2).build();
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
null,
|
|
||||||
Format.NO_VALUE,
|
|
||||||
Format.NO_VALUE,
|
|
||||||
6,
|
|
||||||
44100,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
0,
|
|
||||||
null);
|
|
||||||
Format lowerChannelFormat =
|
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, null);
|
|
||||||
TrackGroupArray trackGroups = wrapFormats(higherChannelFormat, lowerChannelFormat);
|
TrackGroupArray trackGroups = wrapFormats(higherChannelFormat, lowerChannelFormat);
|
||||||
|
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
@ -899,12 +746,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksExceedingCapabilitiesSelectLowerSampleRate() throws Exception {
|
public void selectTracksExceedingCapabilitiesSelectLowerSampleRate() throws Exception {
|
||||||
Format lowerSampleRateFormat =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
Format lowerSampleRateFormat = formatBuilder.setSampleRate(22050).build();
|
||||||
Format.NO_VALUE, 2, 22050, null, null, 0, null);
|
Format higherSampleRateFormat = formatBuilder.setSampleRate(44100).build();
|
||||||
Format higherSampleRateFormat =
|
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, null);
|
|
||||||
TrackGroupArray trackGroups = wrapFormats(higherSampleRateFormat, lowerSampleRateFormat);
|
TrackGroupArray trackGroups = wrapFormats(higherSampleRateFormat, lowerSampleRateFormat);
|
||||||
|
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
@ -922,12 +766,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksExceedingCapabilitiesSelectLowerBitrate() throws Exception {
|
public void selectTracksExceedingCapabilitiesSelectLowerBitrate() throws Exception {
|
||||||
Format lowerBitrateFormat =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, 15000,
|
Format lowerBitrateFormat = formatBuilder.setAverageBitrate(15000).build();
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, null);
|
Format higherBitrateFormat = formatBuilder.setAverageBitrate(30000).build();
|
||||||
Format higherBitrateFormat =
|
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, 30000,
|
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, null);
|
|
||||||
TrackGroupArray trackGroups = wrapFormats(lowerBitrateFormat, higherBitrateFormat);
|
TrackGroupArray trackGroups = wrapFormats(lowerBitrateFormat, higherBitrateFormat);
|
||||||
|
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
@ -947,12 +788,11 @@ public final class DefaultTrackSelectorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void selectTracksExceedingCapabilitiesPreferLowerNumChannelBeforeSampleRate()
|
public void selectTracksExceedingCapabilitiesPreferLowerNumChannelBeforeSampleRate()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format lowerChannelHigherSampleRateFormat =
|
Format lowerChannelHigherSampleRateFormat =
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
formatBuilder.setChannelCount(2).setSampleRate(44100).build();
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, null);
|
|
||||||
Format higherChannelLowerSampleRateFormat =
|
Format higherChannelLowerSampleRateFormat =
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE,
|
formatBuilder.setChannelCount(6).setSampleRate(22050).build();
|
||||||
Format.NO_VALUE, 6, 22050, null, null, 0, null);
|
|
||||||
TrackGroupArray trackGroups =
|
TrackGroupArray trackGroups =
|
||||||
wrapFormats(higherChannelLowerSampleRateFormat, lowerChannelHigherSampleRateFormat);
|
wrapFormats(higherChannelLowerSampleRateFormat, lowerChannelHigherSampleRateFormat);
|
||||||
|
|
||||||
@ -972,12 +812,11 @@ public final class DefaultTrackSelectorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void selectTracksExceedingCapabilitiesPreferLowerSampleRateBeforeBitrate()
|
public void selectTracksExceedingCapabilitiesPreferLowerSampleRateBeforeBitrate()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format higherSampleRateLowerBitrateFormat =
|
Format higherSampleRateLowerBitrateFormat =
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, 15000,
|
formatBuilder.setAverageBitrate(15000).setSampleRate(44100).build();
|
||||||
Format.NO_VALUE, 2, 44100, null, null, 0, null);
|
|
||||||
Format lowerSampleRateHigherBitrateFormat =
|
Format lowerSampleRateHigherBitrateFormat =
|
||||||
Format.createAudioSampleFormat("audioFormat", MimeTypes.AUDIO_AAC, null, 30000,
|
formatBuilder.setAverageBitrate(30000).setSampleRate(22050).build();
|
||||||
Format.NO_VALUE, 2, 22050, null, null, 0, null);
|
|
||||||
TrackGroupArray trackGroups =
|
TrackGroupArray trackGroups =
|
||||||
wrapFormats(higherSampleRateLowerBitrateFormat, lowerSampleRateHigherBitrateFormat);
|
wrapFormats(higherSampleRateLowerBitrateFormat, lowerSampleRateHigherBitrateFormat);
|
||||||
|
|
||||||
@ -993,11 +832,12 @@ public final class DefaultTrackSelectorTest {
|
|||||||
/** Tests text track selection flags. */
|
/** Tests text track selection flags. */
|
||||||
@Test
|
@Test
|
||||||
public void textTrackSelectionFlags() throws ExoPlaybackException {
|
public void textTrackSelectionFlags() throws ExoPlaybackException {
|
||||||
Format forcedOnly = buildTextFormat("forcedOnly", "eng", C.SELECTION_FLAG_FORCED);
|
Format.Builder formatBuilder = TEXT_FORMAT.buildUpon().setLanguage("eng");
|
||||||
|
Format forcedOnly = formatBuilder.setSelectionFlags(C.SELECTION_FLAG_FORCED).build();
|
||||||
Format forcedDefault =
|
Format forcedDefault =
|
||||||
buildTextFormat("forcedDefault", "eng", C.SELECTION_FLAG_FORCED | C.SELECTION_FLAG_DEFAULT);
|
formatBuilder.setSelectionFlags(C.SELECTION_FLAG_FORCED | C.SELECTION_FLAG_DEFAULT).build();
|
||||||
Format defaultOnly = buildTextFormat("defaultOnly", "eng", C.SELECTION_FLAG_DEFAULT);
|
Format defaultOnly = formatBuilder.setSelectionFlags(C.SELECTION_FLAG_DEFAULT).build();
|
||||||
Format noFlag = buildTextFormat("noFlag", "eng");
|
Format noFlag = formatBuilder.setSelectionFlags(0).build();
|
||||||
|
|
||||||
RendererCapabilities[] textRendererCapabilities =
|
RendererCapabilities[] textRendererCapabilities =
|
||||||
new RendererCapabilities[] {ALL_TEXT_FORMAT_SUPPORTED_RENDERER_CAPABILITIES};
|
new RendererCapabilities[] {ALL_TEXT_FORMAT_SUPPORTED_RENDERER_CAPABILITIES};
|
||||||
@ -1058,25 +898,14 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectingForcedTextTrackMatchesAudioLanguage() throws ExoPlaybackException {
|
public void selectingForcedTextTrackMatchesAudioLanguage() throws ExoPlaybackException {
|
||||||
Format forcedEnglish =
|
Format.Builder formatBuilder =
|
||||||
buildTextFormat(/* id= */ "forcedEnglish", /* language= */ "eng", C.SELECTION_FLAG_FORCED);
|
TEXT_FORMAT.buildUpon().setSelectionFlags(C.SELECTION_FLAG_FORCED);
|
||||||
Format forcedGerman =
|
Format forcedEnglish = formatBuilder.setLanguage("eng").build();
|
||||||
buildTextFormat(/* id= */ "forcedGerman", /* language= */ "deu", C.SELECTION_FLAG_FORCED);
|
Format forcedGerman = formatBuilder.setLanguage("deu").build();
|
||||||
Format forcedNoLanguage =
|
Format forcedNoLanguage = formatBuilder.setLanguage(C.LANGUAGE_UNDETERMINED).build();
|
||||||
buildTextFormat(
|
|
||||||
/* id= */ "forcedNoLanguage",
|
Format noLanguageAudio = AUDIO_FORMAT.buildUpon().setLanguage(null).build();
|
||||||
/* language= */ C.LANGUAGE_UNDETERMINED,
|
Format germanAudio = AUDIO_FORMAT.buildUpon().setLanguage("deu").build();
|
||||||
C.SELECTION_FLAG_FORCED);
|
|
||||||
Format audio = buildAudioFormat(/* id= */ "audio");
|
|
||||||
Format germanAudio =
|
|
||||||
buildAudioFormat(
|
|
||||||
/* id= */ "germanAudio",
|
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
|
||||||
"deu",
|
|
||||||
/* selectionFlags= */ 0,
|
|
||||||
/* channelCount= */ Format.NO_VALUE,
|
|
||||||
/* sampleRate= */ Format.NO_VALUE);
|
|
||||||
|
|
||||||
RendererCapabilities[] rendererCapabilities =
|
RendererCapabilities[] rendererCapabilities =
|
||||||
new RendererCapabilities[] {
|
new RendererCapabilities[] {
|
||||||
@ -1086,14 +915,14 @@ public final class DefaultTrackSelectorTest {
|
|||||||
|
|
||||||
// Neither the audio nor the forced text track define a language. We select them both under the
|
// Neither the audio nor the forced text track define a language. We select them both under the
|
||||||
// assumption that they have matching language.
|
// assumption that they have matching language.
|
||||||
TrackGroupArray trackGroups = wrapFormats(audio, forcedNoLanguage);
|
TrackGroupArray trackGroups = wrapFormats(noLanguageAudio, forcedNoLanguage);
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
|
trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
|
||||||
assertFixedSelection(result.selections.get(1), trackGroups, forcedNoLanguage);
|
assertFixedSelection(result.selections.get(1), trackGroups, forcedNoLanguage);
|
||||||
|
|
||||||
// No forced text track should be selected because none of the forced text tracks' languages
|
// No forced text track should be selected because none of the forced text tracks' languages
|
||||||
// matches the selected audio language.
|
// matches the selected audio language.
|
||||||
trackGroups = wrapFormats(audio, forcedEnglish, forcedGerman);
|
trackGroups = wrapFormats(noLanguageAudio, forcedEnglish, forcedGerman);
|
||||||
result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
|
result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
|
||||||
assertNoSelection(result.selections.get(1));
|
assertNoSelection(result.selections.get(1));
|
||||||
|
|
||||||
@ -1115,10 +944,11 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void selectUndeterminedTextLanguageAsFallback() throws ExoPlaybackException {
|
public void selectUndeterminedTextLanguageAsFallback() throws ExoPlaybackException {
|
||||||
Format spanish = buildTextFormat("spanish", "spa");
|
Format.Builder formatBuilder = TEXT_FORMAT.buildUpon();
|
||||||
Format german = buildTextFormat("german", "de");
|
Format spanish = formatBuilder.setLanguage("spa").build();
|
||||||
Format undeterminedUnd = buildTextFormat("undeterminedUnd", "und");
|
Format german = formatBuilder.setLanguage("de").build();
|
||||||
Format undeterminedNull = buildTextFormat("undeterminedNull", null);
|
Format undeterminedUnd = formatBuilder.setLanguage(C.LANGUAGE_UNDETERMINED).build();
|
||||||
|
Format undeterminedNull = formatBuilder.setLanguage(null).build();
|
||||||
|
|
||||||
RendererCapabilities[] textRendererCapabilites =
|
RendererCapabilities[] textRendererCapabilites =
|
||||||
new RendererCapabilities[] {ALL_TEXT_FORMAT_SUPPORTED_RENDERER_CAPABILITIES};
|
new RendererCapabilities[] {ALL_TEXT_FORMAT_SUPPORTED_RENDERER_CAPABILITIES};
|
||||||
@ -1159,8 +989,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
/** Tests audio track selection when there are multiple audio renderers. */
|
/** Tests audio track selection when there are multiple audio renderers. */
|
||||||
@Test
|
@Test
|
||||||
public void selectPreferredTextTrackMultipleRenderers() throws Exception {
|
public void selectPreferredTextTrackMultipleRenderers() throws Exception {
|
||||||
Format english = buildTextFormat("en", "en");
|
Format.Builder formatBuilder = TEXT_FORMAT.buildUpon();
|
||||||
Format german = buildTextFormat("de", "de");
|
Format english = formatBuilder.setId("en").setLanguage("en").build();
|
||||||
|
Format german = formatBuilder.setId("de").setLanguage("de").build();
|
||||||
|
|
||||||
// First renderer handles english.
|
// First renderer handles english.
|
||||||
Map<String, Integer> firstRendererMappedCapabilities = new HashMap<>();
|
Map<String, Integer> firstRendererMappedCapabilities = new HashMap<>();
|
||||||
@ -1206,9 +1037,11 @@ public final class DefaultTrackSelectorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void selectTracksWithinCapabilitiesAndForceLowestBitrateSelectLowerBitrate()
|
public void selectTracksWithinCapabilitiesAndForceLowestBitrateSelectLowerBitrate()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Format unsupportedLowBitrateFormat = buildAudioFormatWithBitrate("unsupportedLowBitrate", 5000);
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format lowerBitrateFormat = buildAudioFormatWithBitrate("lowBitrate", 15000);
|
Format unsupportedLowBitrateFormat =
|
||||||
Format higherBitrateFormat = buildAudioFormatWithBitrate("highBitrate", 30000);
|
formatBuilder.setId("unsupported").setAverageBitrate(5000).build();
|
||||||
|
Format lowerBitrateFormat = formatBuilder.setId("lower").setAverageBitrate(15000).build();
|
||||||
|
Format higherBitrateFormat = formatBuilder.setId("higher").setAverageBitrate(30000).build();
|
||||||
TrackGroupArray trackGroups =
|
TrackGroupArray trackGroups =
|
||||||
wrapFormats(unsupportedLowBitrateFormat, lowerBitrateFormat, higherBitrateFormat);
|
wrapFormats(unsupportedLowBitrateFormat, lowerBitrateFormat, higherBitrateFormat);
|
||||||
|
|
||||||
@ -1236,9 +1069,10 @@ public final class DefaultTrackSelectorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void selectTracksWithinCapabilitiesAndForceHighestBitrateSelectHigherBitrate()
|
public void selectTracksWithinCapabilitiesAndForceHighestBitrateSelectHigherBitrate()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Format lowerBitrateFormat = buildAudioFormatWithBitrate("lowerBitrateFormat", 5000);
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format higherBitrateFormat = buildAudioFormatWithBitrate("higherBitrateFormat", 15000);
|
Format lowerBitrateFormat = formatBuilder.setId("5000").setAverageBitrate(5000).build();
|
||||||
Format exceedsBitrateFormat = buildAudioFormatWithBitrate("exceedsBitrateFormat", 30000);
|
Format higherBitrateFormat = formatBuilder.setId("15000").setAverageBitrate(15000).build();
|
||||||
|
Format exceedsBitrateFormat = formatBuilder.setId("30000").setAverageBitrate(30000).build();
|
||||||
TrackGroupArray trackGroups =
|
TrackGroupArray trackGroups =
|
||||||
wrapFormats(lowerBitrateFormat, higherBitrateFormat, exceedsBitrateFormat);
|
wrapFormats(lowerBitrateFormat, higherBitrateFormat, exceedsBitrateFormat);
|
||||||
|
|
||||||
@ -1262,7 +1096,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksWithMultipleAudioTracks() throws Exception {
|
public void selectTracksWithMultipleAudioTracks() throws Exception {
|
||||||
TrackGroupArray trackGroups = singleTrackGroup(buildAudioFormat("0"), buildAudioFormat("1"));
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
|
TrackGroupArray trackGroups =
|
||||||
|
singleTrackGroup(formatBuilder.setId("0").build(), formatBuilder.setId("1").build());
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
trackSelector.selectTracks(
|
trackSelector.selectTracks(
|
||||||
new RendererCapabilities[] {AUDIO_CAPABILITIES}, trackGroups, periodId, TIMELINE);
|
new RendererCapabilities[] {AUDIO_CAPABILITIES}, trackGroups, periodId, TIMELINE);
|
||||||
@ -1304,10 +1140,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksWithMultipleAudioTracksWithMixedSampleRates() throws Exception {
|
public void selectTracksWithMultipleAudioTracksWithMixedSampleRates() throws Exception {
|
||||||
Format highSampleRateAudioFormat =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
buildAudioFormatWithSampleRate("44100", /* sampleRate= */ 44100);
|
Format highSampleRateAudioFormat = formatBuilder.setSampleRate(44100).build();
|
||||||
Format lowSampleRateAudioFormat =
|
Format lowSampleRateAudioFormat = formatBuilder.setSampleRate(22050).build();
|
||||||
buildAudioFormatWithSampleRate("22050", /* sampleRate= */ 22050);
|
|
||||||
|
|
||||||
// Should not adapt between mixed sample rates by default, so we expect a fixed selection
|
// Should not adapt between mixed sample rates by default, so we expect a fixed selection
|
||||||
// containing the higher sample rate stream.
|
// containing the higher sample rate stream.
|
||||||
@ -1339,8 +1174,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksWithMultipleAudioTracksWithMixedMimeTypes() throws Exception {
|
public void selectTracksWithMultipleAudioTracksWithMixedMimeTypes() throws Exception {
|
||||||
Format aacAudioFormat = buildAudioFormatWithMimeType("aac", MimeTypes.AUDIO_AAC);
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format opusAudioFormat = buildAudioFormatWithMimeType("opus", MimeTypes.AUDIO_OPUS);
|
Format aacAudioFormat = formatBuilder.setSampleMimeType(MimeTypes.AUDIO_AAC).build();
|
||||||
|
Format opusAudioFormat = formatBuilder.setSampleMimeType(MimeTypes.AUDIO_OPUS).build();
|
||||||
|
|
||||||
// Should not adapt between mixed mime types by default, so we expect a fixed selection
|
// Should not adapt between mixed mime types by default, so we expect a fixed selection
|
||||||
// containing the first stream.
|
// containing the first stream.
|
||||||
@ -1371,10 +1207,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksWithMultipleAudioTracksWithMixedChannelCounts() throws Exception {
|
public void selectTracksWithMultipleAudioTracksWithMixedChannelCounts() throws Exception {
|
||||||
Format stereoAudioFormat =
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
buildAudioFormatWithChannelCount("2-channels", /* channelCount= */ 2);
|
Format stereoAudioFormat = formatBuilder.setChannelCount(2).build();
|
||||||
Format surroundAudioFormat =
|
Format surroundAudioFormat = formatBuilder.setChannelCount(5).build();
|
||||||
buildAudioFormatWithChannelCount("5-channels", /* channelCount= */ 5);
|
|
||||||
|
|
||||||
// Should not adapt between different channel counts, so we expect a fixed selection containing
|
// Should not adapt between different channel counts, so we expect a fixed selection containing
|
||||||
// the track with more channels.
|
// the track with more channels.
|
||||||
@ -1436,8 +1271,12 @@ public final class DefaultTrackSelectorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void selectTracksWithMultipleAudioTracksOverrideReturnsAdaptiveTrackSelection()
|
public void selectTracksWithMultipleAudioTracksOverrideReturnsAdaptiveTrackSelection()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
TrackGroupArray trackGroups =
|
TrackGroupArray trackGroups =
|
||||||
singleTrackGroup(buildAudioFormat("0"), buildAudioFormat("1"), buildAudioFormat("2"));
|
singleTrackGroup(
|
||||||
|
formatBuilder.setId("0").build(),
|
||||||
|
formatBuilder.setId("1").build(),
|
||||||
|
formatBuilder.setId("2").build());
|
||||||
trackSelector.setParameters(
|
trackSelector.setParameters(
|
||||||
trackSelector
|
trackSelector
|
||||||
.buildUponParameters()
|
.buildUponParameters()
|
||||||
@ -1456,8 +1295,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
/** Tests audio track selection when there are multiple audio renderers. */
|
/** Tests audio track selection when there are multiple audio renderers. */
|
||||||
@Test
|
@Test
|
||||||
public void selectPreferredAudioTrackMultipleRenderers() throws Exception {
|
public void selectPreferredAudioTrackMultipleRenderers() throws Exception {
|
||||||
Format english = buildAudioFormatWithLanguage("en", "en");
|
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
|
||||||
Format german = buildAudioFormatWithLanguage("de", "de");
|
Format english = formatBuilder.setId("en").setLanguage("en").build();
|
||||||
|
Format german = formatBuilder.setId("de").setLanguage("de").build();
|
||||||
|
|
||||||
// First renderer handles english.
|
// First renderer handles english.
|
||||||
Map<String, Integer> firstRendererMappedCapabilities = new HashMap<>();
|
Map<String, Integer> firstRendererMappedCapabilities = new HashMap<>();
|
||||||
@ -1498,7 +1338,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksWithMultipleVideoTracks() throws Exception {
|
public void selectTracksWithMultipleVideoTracks() throws Exception {
|
||||||
TrackGroupArray trackGroups = singleTrackGroup(buildVideoFormat("0"), buildVideoFormat("1"));
|
Format.Builder formatBuilder = VIDEO_FORMAT.buildUpon();
|
||||||
|
TrackGroupArray trackGroups =
|
||||||
|
singleTrackGroup(formatBuilder.setId("0").build(), formatBuilder.setId("1").build());
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
trackSelector.selectTracks(
|
trackSelector.selectTracks(
|
||||||
new RendererCapabilities[] {VIDEO_CAPABILITIES}, trackGroups, periodId, TIMELINE);
|
new RendererCapabilities[] {VIDEO_CAPABILITIES}, trackGroups, periodId, TIMELINE);
|
||||||
@ -1513,7 +1355,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
new FakeRendererCapabilities(C.TRACK_TYPE_VIDEO, FORMAT_HANDLED | ADAPTIVE_NOT_SEAMLESS);
|
new FakeRendererCapabilities(C.TRACK_TYPE_VIDEO, FORMAT_HANDLED | ADAPTIVE_NOT_SEAMLESS);
|
||||||
|
|
||||||
// Should do non-seamless adaptiveness by default, so expect an adaptive selection.
|
// Should do non-seamless adaptiveness by default, so expect an adaptive selection.
|
||||||
TrackGroupArray trackGroups = singleTrackGroup(buildVideoFormat("0"), buildVideoFormat("1"));
|
Format.Builder formatBuilder = VIDEO_FORMAT.buildUpon();
|
||||||
|
TrackGroupArray trackGroups =
|
||||||
|
singleTrackGroup(formatBuilder.setId("0").build(), formatBuilder.setId("1").build());
|
||||||
trackSelector.setParameters(
|
trackSelector.setParameters(
|
||||||
defaultParameters.buildUpon().setAllowVideoNonSeamlessAdaptiveness(true));
|
defaultParameters.buildUpon().setAllowVideoNonSeamlessAdaptiveness(true));
|
||||||
TrackSelectorResult result =
|
TrackSelectorResult result =
|
||||||
@ -1540,8 +1384,9 @@ public final class DefaultTrackSelectorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectTracksWithMultipleVideoTracksWithMixedMimeTypes() throws Exception {
|
public void selectTracksWithMultipleVideoTracksWithMixedMimeTypes() throws Exception {
|
||||||
Format h264VideoFormat = buildVideoFormatWithMimeType("h264", MimeTypes.VIDEO_H264);
|
Format.Builder formatBuilder = VIDEO_FORMAT.buildUpon();
|
||||||
Format h265VideoFormat = buildVideoFormatWithMimeType("h265", MimeTypes.VIDEO_H265);
|
Format h264VideoFormat = formatBuilder.setSampleMimeType(MimeTypes.VIDEO_H264).build();
|
||||||
|
Format h265VideoFormat = formatBuilder.setSampleMimeType(MimeTypes.VIDEO_H265).build();
|
||||||
|
|
||||||
// Should not adapt between mixed mime types by default, so we expect a fixed selection
|
// Should not adapt between mixed mime types by default, so we expect a fixed selection
|
||||||
// containing the first stream.
|
// containing the first stream.
|
||||||
@ -1573,8 +1418,12 @@ public final class DefaultTrackSelectorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void selectTracksWithMultipleVideoTracksOverrideReturnsAdaptiveTrackSelection()
|
public void selectTracksWithMultipleVideoTracksOverrideReturnsAdaptiveTrackSelection()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
Format.Builder formatBuilder = VIDEO_FORMAT.buildUpon();
|
||||||
TrackGroupArray trackGroups =
|
TrackGroupArray trackGroups =
|
||||||
singleTrackGroup(buildVideoFormat("0"), buildVideoFormat("1"), buildVideoFormat("2"));
|
singleTrackGroup(
|
||||||
|
formatBuilder.setId("0").build(),
|
||||||
|
formatBuilder.setId("1").build(),
|
||||||
|
formatBuilder.setId("2").build());
|
||||||
trackSelector.setParameters(
|
trackSelector.setParameters(
|
||||||
trackSelector
|
trackSelector
|
||||||
.buildUponParameters()
|
.buildUponParameters()
|
||||||
@ -1650,144 +1499,14 @@ public final class DefaultTrackSelectorTest {
|
|||||||
return new TrackGroupArray(trackGroups);
|
return new TrackGroupArray(trackGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Format buildVideoFormatWithMimeType(String id, String mimeType) {
|
|
||||||
return Format.createVideoSampleFormat(
|
|
||||||
id,
|
|
||||||
mimeType,
|
|
||||||
null,
|
|
||||||
Format.NO_VALUE,
|
|
||||||
Format.NO_VALUE,
|
|
||||||
1024,
|
|
||||||
768,
|
|
||||||
Format.NO_VALUE,
|
|
||||||
null,
|
|
||||||
null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Format buildVideoFormat(String id) {
|
|
||||||
return buildVideoFormatWithMimeType(id, MimeTypes.VIDEO_H264);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Format buildAudioFormatWithLanguage(String id, String language) {
|
|
||||||
return buildAudioFormatWithLanguageAndFlags(id, language, /* selectionFlags= */ 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Format buildAudioFormatWithLanguageAndFlags(
|
|
||||||
String id, String language, int selectionFlags) {
|
|
||||||
return buildAudioFormat(
|
|
||||||
id,
|
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
|
||||||
language,
|
|
||||||
selectionFlags,
|
|
||||||
/* channelCount= */ 2,
|
|
||||||
/* 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) {
|
|
||||||
return buildAudioFormat(
|
|
||||||
id,
|
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
|
||||||
/* language= */ null,
|
|
||||||
/* selectionFlags= */ 0,
|
|
||||||
/* channelCount= */ 2,
|
|
||||||
sampleRate);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Format buildAudioFormatWithChannelCount(String id, int channelCount) {
|
|
||||||
return buildAudioFormat(
|
|
||||||
id,
|
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
|
||||||
/* language= */ null,
|
|
||||||
/* selectionFlags= */ 0,
|
|
||||||
channelCount,
|
|
||||||
/* sampleRate= */ 44100);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Format buildAudioFormatWithMimeType(String id, String mimeType) {
|
|
||||||
return buildAudioFormat(
|
|
||||||
id,
|
|
||||||
mimeType,
|
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
|
||||||
/* language= */ null,
|
|
||||||
/* selectionFlags= */ 0,
|
|
||||||
/* channelCount= */ 2,
|
|
||||||
/* sampleRate= */ 44100);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Format buildAudioFormatWithConfiguration(
|
private static Format buildAudioFormatWithConfiguration(
|
||||||
String id, int channelCount, String mimeType, int sampleRate) {
|
String id, int channelCount, String mimeType, int sampleRate) {
|
||||||
return buildAudioFormat(
|
return new Format.Builder()
|
||||||
id,
|
.setId(id)
|
||||||
mimeType,
|
.setSampleMimeType(mimeType)
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
.setChannelCount(channelCount)
|
||||||
/* language= */ null,
|
.setSampleRate(sampleRate)
|
||||||
/* selectionFlags= */ 0,
|
.build();
|
||||||
channelCount,
|
|
||||||
sampleRate);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Format buildAudioFormat(String id) {
|
|
||||||
return buildAudioFormat(
|
|
||||||
id,
|
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
|
||||||
/* language= */ null,
|
|
||||||
/* selectionFlags= */ 0,
|
|
||||||
/* channelCount= */ 2,
|
|
||||||
/* sampleRate= */ 44100);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Format buildAudioFormat(
|
|
||||||
String id,
|
|
||||||
String mimeType,
|
|
||||||
int bitrate,
|
|
||||||
String language,
|
|
||||||
int selectionFlags,
|
|
||||||
int channelCount,
|
|
||||||
int sampleRate) {
|
|
||||||
return Format.createAudioSampleFormat(
|
|
||||||
id,
|
|
||||||
mimeType,
|
|
||||||
/* codecs= */ null,
|
|
||||||
bitrate,
|
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
channelCount,
|
|
||||||
sampleRate,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* drmInitData= */ null,
|
|
||||||
selectionFlags,
|
|
||||||
language);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Format buildTextFormat(String id, String language) {
|
|
||||||
return buildTextFormat(id, language, /* selectionFlags= */ 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Format buildTextFormat(String id, String language, int selectionFlags) {
|
|
||||||
return Format.createTextContainerFormat(
|
|
||||||
id,
|
|
||||||
/* label= */ null,
|
|
||||||
/* containerMimeType= */ null,
|
|
||||||
/* sampleMimeType= */ MimeTypes.TEXT_VTT,
|
|
||||||
/* codecs= */ null,
|
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
|
||||||
selectionFlags,
|
|
||||||
/* roleFlags= */ 0,
|
|
||||||
language);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,35 +47,9 @@ public final class MappingTrackSelectorTest {
|
|||||||
private static final RendererCapabilities METADATA_CAPABILITIES =
|
private static final RendererCapabilities METADATA_CAPABILITIES =
|
||||||
new FakeRendererCapabilities(C.TRACK_TYPE_METADATA);
|
new FakeRendererCapabilities(C.TRACK_TYPE_METADATA);
|
||||||
|
|
||||||
private static final TrackGroup VIDEO_TRACK_GROUP =
|
private static final TrackGroup VIDEO_TRACK_GROUP = buildTrackGroup(MimeTypes.VIDEO_H264);
|
||||||
new TrackGroup(
|
private static final TrackGroup AUDIO_TRACK_GROUP = buildTrackGroup(MimeTypes.AUDIO_AAC);
|
||||||
Format.createVideoSampleFormat(
|
private static final TrackGroup METADATA_TRACK_GROUP = buildTrackGroup(MimeTypes.APPLICATION_ID3);
|
||||||
"video",
|
|
||||||
MimeTypes.VIDEO_H264,
|
|
||||||
/* codecs= */ null,
|
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* width= */ 1024,
|
|
||||||
/* height= */ 768,
|
|
||||||
/* frameRate= */ Format.NO_VALUE,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* drmInitData= */ null));
|
|
||||||
private static final TrackGroup AUDIO_TRACK_GROUP =
|
|
||||||
new TrackGroup(
|
|
||||||
Format.createAudioSampleFormat(
|
|
||||||
"audio",
|
|
||||||
MimeTypes.AUDIO_AAC,
|
|
||||||
/* codecs= */ null,
|
|
||||||
/* bitrate= */ Format.NO_VALUE,
|
|
||||||
/* maxInputSize= */ Format.NO_VALUE,
|
|
||||||
/* channelCount= */ 2,
|
|
||||||
/* sampleRate= */ 44100,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* drmInitData= */ null,
|
|
||||||
/* selectionFlags= */ 0,
|
|
||||||
/* language= */ null));
|
|
||||||
private static final TrackGroup METADATA_TRACK_GROUP =
|
|
||||||
new TrackGroup(Format.createSampleFormat("metadata", MimeTypes.APPLICATION_ID3));
|
|
||||||
|
|
||||||
private static final Timeline TIMELINE = new FakeTimeline(/* windowCount= */ 1);
|
private static final Timeline TIMELINE = new FakeTimeline(/* windowCount= */ 1);
|
||||||
|
|
||||||
@ -150,6 +124,10 @@ public final class MappingTrackSelectorTest {
|
|||||||
trackSelector.assertMappedTrackGroups(2, METADATA_TRACK_GROUP);
|
trackSelector.assertMappedTrackGroups(2, METADATA_TRACK_GROUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static TrackGroup buildTrackGroup(String sampleMimeType) {
|
||||||
|
return new TrackGroup(new Format.Builder().setSampleMimeType(sampleMimeType).build());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link MappingTrackSelector} that stashes the {@link MappedTrackInfo} passed to {@link
|
* A {@link MappingTrackSelector} that stashes the {@link MappedTrackInfo} passed to {@link
|
||||||
* #selectTracks(MappedTrackInfo, int[][][], int[])}.
|
* #selectTracks(MappedTrackInfo, int[][][], int[])}.
|
||||||
@ -209,7 +187,5 @@ public final class MappingTrackSelectorTest {
|
|||||||
public int supportsMixedMimeTypeAdaptation() throws ExoPlaybackException {
|
public int supportsMixedMimeTypeAdaptation() throws ExoPlaybackException {
|
||||||
return ADAPTIVE_SEAMLESS;
|
return ADAPTIVE_SEAMLESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user