Java Code Examples for com.google.android.exoplayer2.C#SELECTION_FLAG_FORCED
The following examples show how to use
com.google.android.exoplayer2.C#SELECTION_FLAG_FORCED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultTrackSelector.java From MediaSDK with Apache License 2.0 | 5 votes |
public TextTrackScore( Format format, Parameters parameters, @Capabilities int trackFormatSupport, @Nullable String selectedAudioLanguage) { isWithinRendererCapabilities = isSupported(trackFormatSupport, /* allowExceedsCapabilities= */ false); int maskedSelectionFlags = format.selectionFlags & ~parameters.disabledTextTrackSelectionFlags; isDefault = (maskedSelectionFlags & C.SELECTION_FLAG_DEFAULT) != 0; boolean isForced = (maskedSelectionFlags & C.SELECTION_FLAG_FORCED) != 0; preferredLanguageScore = getFormatLanguageScore( format, parameters.preferredTextLanguage, parameters.selectUndeterminedTextLanguage); preferredRoleFlagsScore = Integer.bitCount(format.roleFlags & parameters.preferredTextRoleFlags); hasCaptionRoleFlags = (format.roleFlags & (C.ROLE_FLAG_CAPTION | C.ROLE_FLAG_DESCRIBES_MUSIC_AND_SOUND)) != 0; // Prefer non-forced to forced if a preferred text language has been matched. Where both are // provided the non-forced track will usually contain the forced subtitles as a subset. // Otherwise, prefer a forced track. hasPreferredIsForcedFlag = (preferredLanguageScore > 0 && !isForced) || (preferredLanguageScore == 0 && isForced); boolean selectedAudioLanguageUndetermined = normalizeUndeterminedLanguageToNull(selectedAudioLanguage) == null; selectedAudioLanguageScore = getFormatLanguageScore(format, selectedAudioLanguage, selectedAudioLanguageUndetermined); isWithinConstraints = preferredLanguageScore > 0 || (parameters.preferredTextLanguage == null && preferredRoleFlagsScore > 0) || isDefault || (isForced && selectedAudioLanguageScore > 0); }
Example 2
Source File: HlsPlaylistParser.java From MediaSDK with Apache License 2.0 | 5 votes |
@C.SelectionFlags private static int parseSelectionFlags(String line) { int flags = 0; if (parseOptionalBooleanAttribute(line, REGEX_DEFAULT, false)) { flags |= C.SELECTION_FLAG_DEFAULT; } if (parseOptionalBooleanAttribute(line, REGEX_FORCED, false)) { flags |= C.SELECTION_FLAG_FORCED; } if (parseOptionalBooleanAttribute(line, REGEX_AUTOSELECT, false)) { flags |= C.SELECTION_FLAG_AUTOSELECT; } return flags; }
Example 3
Source File: HlsPlaylistParser.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@C.SelectionFlags private static int parseSelectionFlags(String line) { int flags = 0; if (parseOptionalBooleanAttribute(line, REGEX_DEFAULT, false)) { flags |= C.SELECTION_FLAG_DEFAULT; } if (parseOptionalBooleanAttribute(line, REGEX_FORCED, false)) { flags |= C.SELECTION_FLAG_FORCED; } if (parseOptionalBooleanAttribute(line, REGEX_AUTOSELECT, false)) { flags |= C.SELECTION_FLAG_AUTOSELECT; } return flags; }
Example 4
Source File: HlsPlaylistParser.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@C.SelectionFlags private static int parseSelectionFlags(String line) { int flags = 0; if (parseOptionalBooleanAttribute(line, REGEX_DEFAULT, false)) { flags |= C.SELECTION_FLAG_DEFAULT; } if (parseOptionalBooleanAttribute(line, REGEX_FORCED, false)) { flags |= C.SELECTION_FLAG_FORCED; } if (parseOptionalBooleanAttribute(line, REGEX_AUTOSELECT, false)) { flags |= C.SELECTION_FLAG_AUTOSELECT; } return flags; }
Example 5
Source File: DefaultTrackSelector.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public TextTrackScore( Format format, Parameters parameters, int trackFormatSupport, @Nullable String selectedAudioLanguage) { isWithinRendererCapabilities = isSupported(trackFormatSupport, /* allowExceedsCapabilities= */ false); int maskedSelectionFlags = format.selectionFlags & ~parameters.disabledTextTrackSelectionFlags; isDefault = (maskedSelectionFlags & C.SELECTION_FLAG_DEFAULT) != 0; boolean isForced = (maskedSelectionFlags & C.SELECTION_FLAG_FORCED) != 0; preferredLanguageScore = getFormatLanguageScore( format, parameters.preferredTextLanguage, parameters.selectUndeterminedTextLanguage); preferredRoleFlagsScore = Integer.bitCount(format.roleFlags & parameters.preferredTextRoleFlags); hasCaptionRoleFlags = (format.roleFlags & (C.ROLE_FLAG_CAPTION | C.ROLE_FLAG_DESCRIBES_MUSIC_AND_SOUND)) != 0; // Prefer non-forced to forced if a preferred text language has been matched. Where both are // provided the non-forced track will usually contain the forced subtitles as a subset. // Otherwise, prefer a forced track. hasPreferredIsForcedFlag = (preferredLanguageScore > 0 && !isForced) || (preferredLanguageScore == 0 && isForced); boolean selectedAudioLanguageUndetermined = normalizeUndeterminedLanguageToNull(selectedAudioLanguage) == null; selectedAudioLanguageScore = getFormatLanguageScore(format, selectedAudioLanguage, selectedAudioLanguageUndetermined); isWithinConstraints = preferredLanguageScore > 0 || (parameters.preferredTextLanguage == null && preferredRoleFlagsScore > 0) || isDefault || (isForced && selectedAudioLanguageScore > 0); }
Example 6
Source File: HlsPlaylistParser.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@C.SelectionFlags private static int parseSelectionFlags(String line) { int flags = 0; if (parseOptionalBooleanAttribute(line, REGEX_DEFAULT, false)) { flags |= C.SELECTION_FLAG_DEFAULT; } if (parseOptionalBooleanAttribute(line, REGEX_FORCED, false)) { flags |= C.SELECTION_FLAG_FORCED; } if (parseOptionalBooleanAttribute(line, REGEX_AUTOSELECT, false)) { flags |= C.SELECTION_FLAG_AUTOSELECT; } return flags; }
Example 7
Source File: DefaultTrackSelector.java From Telegram with GNU General Public License v2.0 | 5 votes |
public TextTrackScore( Format format, Parameters parameters, int trackFormatSupport, @Nullable String selectedAudioLanguage) { isWithinRendererCapabilities = isSupported(trackFormatSupport, /* allowExceedsCapabilities= */ false); int maskedSelectionFlags = format.selectionFlags & ~parameters.disabledTextTrackSelectionFlags; isDefault = (maskedSelectionFlags & C.SELECTION_FLAG_DEFAULT) != 0; boolean isForced = (maskedSelectionFlags & C.SELECTION_FLAG_FORCED) != 0; preferredLanguageScore = getFormatLanguageScore( format, parameters.preferredTextLanguage, parameters.selectUndeterminedTextLanguage); preferredRoleFlagsScore = Integer.bitCount(format.roleFlags & parameters.preferredTextRoleFlags); hasCaptionRoleFlags = (format.roleFlags & (C.ROLE_FLAG_CAPTION | C.ROLE_FLAG_DESCRIBES_MUSIC_AND_SOUND)) != 0; // Prefer non-forced to forced if a preferred text language has been matched. Where both are // provided the non-forced track will usually contain the forced subtitles as a subset. // Otherwise, prefer a forced track. hasPreferredIsForcedFlag = (preferredLanguageScore > 0 && !isForced) || (preferredLanguageScore == 0 && isForced); boolean selectedAudioLanguageUndetermined = normalizeUndeterminedLanguageToNull(selectedAudioLanguage) == null; selectedAudioLanguageScore = getFormatLanguageScore(format, selectedAudioLanguage, selectedAudioLanguageUndetermined); isWithinConstraints = preferredLanguageScore > 0 || (parameters.preferredTextLanguage == null && preferredRoleFlagsScore > 0) || isDefault || (isForced && selectedAudioLanguageScore > 0); }
Example 8
Source File: HlsPlaylistParser.java From Telegram with GNU General Public License v2.0 | 5 votes |
@C.SelectionFlags private static int parseSelectionFlags(String line) { int flags = 0; if (parseOptionalBooleanAttribute(line, REGEX_DEFAULT, false)) { flags |= C.SELECTION_FLAG_DEFAULT; } if (parseOptionalBooleanAttribute(line, REGEX_FORCED, false)) { flags |= C.SELECTION_FLAG_FORCED; } if (parseOptionalBooleanAttribute(line, REGEX_AUTOSELECT, false)) { flags |= C.SELECTION_FLAG_AUTOSELECT; } return flags; }
Example 9
Source File: DefaultTrackSelector.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
/** * Called by {@link #selectAllTracks(MappedTrackInfo, int[][][], int[], Parameters)} to create a * {@link TrackSelection} for a text renderer. * * @param groups The {@link TrackGroupArray} mapped to the renderer. * @param formatSupport The result of {@link RendererCapabilities#supportsFormat} for each mapped * track, indexed by track group index and track index (in that order). * @param params The selector's current constraint parameters. * @return The {@link TrackSelection} for the renderer, or null if no selection was made. * @throws ExoPlaybackException If an error occurs while selecting the tracks. */ protected @Nullable TrackSelection selectTextTrack( TrackGroupArray groups, int[][] formatSupport, Parameters params) throws ExoPlaybackException { TrackGroup selectedGroup = null; int selectedTrackIndex = 0; int selectedTrackScore = 0; for (int groupIndex = 0; groupIndex < groups.length; groupIndex++) { TrackGroup trackGroup = groups.get(groupIndex); int[] trackFormatSupport = formatSupport[groupIndex]; for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) { if (isSupported(trackFormatSupport[trackIndex], params.exceedRendererCapabilitiesIfNecessary)) { Format format = trackGroup.getFormat(trackIndex); int maskedSelectionFlags = format.selectionFlags & ~params.disabledTextTrackSelectionFlags; boolean isDefault = (maskedSelectionFlags & C.SELECTION_FLAG_DEFAULT) != 0; boolean isForced = (maskedSelectionFlags & C.SELECTION_FLAG_FORCED) != 0; int trackScore; boolean preferredLanguageFound = formatHasLanguage(format, params.preferredTextLanguage); if (preferredLanguageFound || (params.selectUndeterminedTextLanguage && formatHasNoLanguage(format))) { if (isDefault) { trackScore = 8; } else if (!isForced) { // Prefer non-forced to forced if a preferred text language has been specified. Where // both are provided the non-forced track will usually contain the forced subtitles as // a subset. trackScore = 6; } else { trackScore = 4; } trackScore += preferredLanguageFound ? 1 : 0; } else if (isDefault) { trackScore = 3; } else if (isForced) { if (formatHasLanguage(format, params.preferredAudioLanguage)) { trackScore = 2; } else { trackScore = 1; } } else { // Track should not be selected. continue; } if (isSupported(trackFormatSupport[trackIndex], false)) { trackScore += WITHIN_RENDERER_CAPABILITIES_BONUS; } if (trackScore > selectedTrackScore) { selectedGroup = trackGroup; selectedTrackIndex = trackIndex; selectedTrackScore = trackScore; } } } } return selectedGroup == null ? null : new FixedTrackSelection(selectedGroup, selectedTrackIndex); }
Example 10
Source File: DefaultTrackSelector.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
/** * Called by {@link #selectAllTracks(MappedTrackInfo, int[][][], int[], Parameters)} to create a * {@link TrackSelection} for a text renderer. * * @param groups The {@link TrackGroupArray} mapped to the renderer. * @param formatSupport The result of {@link RendererCapabilities#supportsFormat} for each mapped * track, indexed by track group index and track index (in that order). * @param params The selector's current constraint parameters. * @return The {@link TrackSelection} for the renderer, or null if no selection was made. * @throws ExoPlaybackException If an error occurs while selecting the tracks. */ protected @Nullable TrackSelection selectTextTrack( TrackGroupArray groups, int[][] formatSupport, Parameters params) throws ExoPlaybackException { TrackGroup selectedGroup = null; int selectedTrackIndex = 0; int selectedTrackScore = 0; for (int groupIndex = 0; groupIndex < groups.length; groupIndex++) { TrackGroup trackGroup = groups.get(groupIndex); int[] trackFormatSupport = formatSupport[groupIndex]; for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) { if (isSupported(trackFormatSupport[trackIndex], params.exceedRendererCapabilitiesIfNecessary)) { Format format = trackGroup.getFormat(trackIndex); int maskedSelectionFlags = format.selectionFlags & ~params.disabledTextTrackSelectionFlags; boolean isDefault = (maskedSelectionFlags & C.SELECTION_FLAG_DEFAULT) != 0; boolean isForced = (maskedSelectionFlags & C.SELECTION_FLAG_FORCED) != 0; int trackScore; boolean preferredLanguageFound = formatHasLanguage(format, params.preferredTextLanguage); if (preferredLanguageFound || (params.selectUndeterminedTextLanguage && formatHasNoLanguage(format))) { if (isDefault) { trackScore = 8; } else if (!isForced) { // Prefer non-forced to forced if a preferred text language has been specified. Where // both are provided the non-forced track will usually contain the forced subtitles as // a subset. trackScore = 6; } else { trackScore = 4; } trackScore += preferredLanguageFound ? 1 : 0; } else if (isDefault) { trackScore = 3; } else if (isForced) { if (formatHasLanguage(format, params.preferredAudioLanguage)) { trackScore = 2; } else { trackScore = 1; } } else { // Track should not be selected. continue; } if (isSupported(trackFormatSupport[trackIndex], false)) { trackScore += WITHIN_RENDERER_CAPABILITIES_BONUS; } if (trackScore > selectedTrackScore) { selectedGroup = trackGroup; selectedTrackIndex = trackIndex; selectedTrackScore = trackScore; } } } } return selectedGroup == null ? null : new FixedTrackSelection(selectedGroup, selectedTrackIndex); }
Example 11
Source File: DefaultTrackSelector.java From K-Sonic with MIT License | 4 votes |
protected TrackSelection selectTextTrack(TrackGroupArray groups, int[][] formatSupport, String preferredTextLanguage, String preferredAudioLanguage, boolean exceedRendererCapabilitiesIfNecessary) { TrackGroup selectedGroup = null; int selectedTrackIndex = 0; int selectedTrackScore = 0; for (int groupIndex = 0; groupIndex < groups.length; groupIndex++) { TrackGroup trackGroup = groups.get(groupIndex); int[] trackFormatSupport = formatSupport[groupIndex]; for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) { if (isSupported(trackFormatSupport[trackIndex], exceedRendererCapabilitiesIfNecessary)) { Format format = trackGroup.getFormat(trackIndex); boolean isDefault = (format.selectionFlags & C.SELECTION_FLAG_DEFAULT) != 0; boolean isForced = (format.selectionFlags & C.SELECTION_FLAG_FORCED) != 0; int trackScore; if (formatHasLanguage(format, preferredTextLanguage)) { if (isDefault) { trackScore = 6; } else if (!isForced) { // Prefer non-forced to forced if a preferred text language has been specified. Where // both are provided the non-forced track will usually contain the forced subtitles as // a subset. trackScore = 5; } else { trackScore = 4; } } else if (isDefault) { trackScore = 3; } else if (isForced) { if (formatHasLanguage(format, preferredAudioLanguage)) { trackScore = 2; } else { trackScore = 1; } } else { // Track should not be selected. continue; } if (isSupported(trackFormatSupport[trackIndex], false)) { trackScore += WITHIN_RENDERER_CAPABILITIES_BONUS; } if (trackScore > selectedTrackScore) { selectedGroup = trackGroup; selectedTrackIndex = trackIndex; selectedTrackScore = trackScore; } } } } return selectedGroup == null ? null : new FixedTrackSelection(selectedGroup, selectedTrackIndex); }
Example 12
Source File: HlsPlaylistParser.java From K-Sonic with MIT License | 4 votes |
@C.SelectionFlags private static int parseSelectionFlags(String line) { return (parseBooleanAttribute(line, REGEX_DEFAULT, false) ? C.SELECTION_FLAG_DEFAULT : 0) | (parseBooleanAttribute(line, REGEX_FORCED, false) ? C.SELECTION_FLAG_FORCED : 0) | (parseBooleanAttribute(line, REGEX_AUTOSELECT, false) ? C.SELECTION_FLAG_AUTOSELECT : 0); }