Java Code Examples for com.google.android.exoplayer2.util.Util#toLowerInvariant()
The following examples show how to use
com.google.android.exoplayer2.util.Util#toLowerInvariant() .
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: SsaStyle.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Parses the format info from a 'Format:' line in the [V4+ Styles] section. * * @return the parsed info, or null if {@code styleFormatLine} doesn't contain 'name'. */ @Nullable public static Format fromFormatLine(String styleFormatLine) { int nameIndex = C.INDEX_UNSET; int alignmentIndex = C.INDEX_UNSET; String[] keys = TextUtils.split(styleFormatLine.substring(SsaDecoder.FORMAT_LINE_PREFIX.length()), ","); for (int i = 0; i < keys.length; i++) { switch (Util.toLowerInvariant(keys[i].trim())) { case "name": nameIndex = i; break; case "alignment": alignmentIndex = i; break; } } return nameIndex != C.INDEX_UNSET ? new Format(nameIndex, alignmentIndex, keys.length) : null; }
Example 2
Source File: IcyDecoder.java From MediaSDK with Apache License 2.0 | 6 votes |
@VisibleForTesting /* package */ Metadata decode(String metadata) { @Nullable String name = null; @Nullable String url = null; int index = 0; Matcher matcher = METADATA_ELEMENT.matcher(metadata); while (matcher.find(index)) { String key = Util.toLowerInvariant(matcher.group(1)); String value = matcher.group(2); switch (key) { case STREAM_KEY_NAME: name = value; break; case STREAM_KEY_URL: url = value; break; } index = matcher.end(); } return new Metadata(new IcyInfo(metadata, name, url)); }
Example 3
Source File: IcyDecoder.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@VisibleForTesting /* package */ Metadata decode(String metadata) { String name = null; String url = null; int index = 0; Matcher matcher = METADATA_ELEMENT.matcher(metadata); while (matcher.find(index)) { String key = Util.toLowerInvariant(matcher.group(1)); String value = matcher.group(2); switch (key) { case STREAM_KEY_NAME: name = value; break; case STREAM_KEY_URL: url = value; break; } index = matcher.end(); } return new Metadata(new IcyInfo(metadata, name, url)); }
Example 4
Source File: ExoSourceManager.java From GSYVideoPlayer with Apache License 2.0 | 5 votes |
@SuppressLint("WrongConstant") @C.ContentType public static int inferContentType(String fileName, @Nullable String overrideExtension) { fileName = Util.toLowerInvariant(fileName); if (fileName.startsWith("rtmp:")) { return TYPE_RTMP; } else { return inferContentType(Uri.parse(fileName), overrideExtension); } }
Example 5
Source File: Id3Decoder.java From Telegram with GNU General Public License v2.0 | 5 votes |
private static ApicFrame decodeApicFrame(ParsableByteArray id3Data, int frameSize, int majorVersion) throws UnsupportedEncodingException { int encoding = id3Data.readUnsignedByte(); String charset = getCharsetName(encoding); byte[] data = new byte[frameSize - 1]; id3Data.readBytes(data, 0, frameSize - 1); String mimeType; int mimeTypeEndIndex; if (majorVersion == 2) { mimeTypeEndIndex = 2; mimeType = "image/" + Util.toLowerInvariant(new String(data, 0, 3, "ISO-8859-1")); if ("image/jpg".equals(mimeType)) { mimeType = "image/jpeg"; } } else { mimeTypeEndIndex = indexOfZeroByte(data, 0); mimeType = Util.toLowerInvariant(new String(data, 0, mimeTypeEndIndex, "ISO-8859-1")); if (mimeType.indexOf('/') == -1) { mimeType = "image/" + mimeType; } } int pictureType = data[mimeTypeEndIndex + 1] & 0xFF; int descriptionStartIndex = mimeTypeEndIndex + 2; int descriptionEndIndex = indexOfEos(data, descriptionStartIndex, encoding); String description = new String(data, descriptionStartIndex, descriptionEndIndex - descriptionStartIndex, charset); int pictureDataStartIndex = descriptionEndIndex + delimiterLength(encoding); byte[] pictureData = copyOfRangeIfValid(data, pictureDataStartIndex, data.length); return new ApicFrame(mimeType, description, pictureType, pictureData); }
Example 6
Source File: Id3Decoder.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static ApicFrame decodeApicFrame(ParsableByteArray id3Data, int frameSize, int majorVersion) throws UnsupportedEncodingException { int encoding = id3Data.readUnsignedByte(); String charset = getCharsetName(encoding); byte[] data = new byte[frameSize - 1]; id3Data.readBytes(data, 0, frameSize - 1); String mimeType; int mimeTypeEndIndex; if (majorVersion == 2) { mimeTypeEndIndex = 2; mimeType = "image/" + Util.toLowerInvariant(new String(data, 0, 3, "ISO-8859-1")); if ("image/jpg".equals(mimeType)) { mimeType = "image/jpeg"; } } else { mimeTypeEndIndex = indexOfZeroByte(data, 0); mimeType = Util.toLowerInvariant(new String(data, 0, mimeTypeEndIndex, "ISO-8859-1")); if (mimeType.indexOf('/') == -1) { mimeType = "image/" + mimeType; } } int pictureType = data[mimeTypeEndIndex + 1] & 0xFF; int descriptionStartIndex = mimeTypeEndIndex + 2; int descriptionEndIndex = indexOfEos(data, descriptionStartIndex, encoding); String description = new String(data, descriptionStartIndex, descriptionEndIndex - descriptionStartIndex, charset); int pictureDataStartIndex = descriptionEndIndex + delimiterLength(encoding); byte[] pictureData = copyOfRangeIfValid(data, pictureDataStartIndex, data.length); return new ApicFrame(mimeType, description, pictureType, pictureData); }
Example 7
Source File: SsaDecoder.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Parses a format line. * * @param formatLine The line to parse. */ private void parseFormatLine(String formatLine) { String[] values = TextUtils.split(formatLine.substring(FORMAT_LINE_PREFIX.length()), ","); formatKeyCount = values.length; formatStartIndex = C.INDEX_UNSET; formatEndIndex = C.INDEX_UNSET; formatTextIndex = C.INDEX_UNSET; for (int i = 0; i < formatKeyCount; i++) { String key = Util.toLowerInvariant(values[i].trim()); switch (key) { case "start": formatStartIndex = i; break; case "end": formatEndIndex = i; break; case "text": formatTextIndex = i; break; default: // Do nothing. break; } } if (formatStartIndex == C.INDEX_UNSET || formatEndIndex == C.INDEX_UNSET || formatTextIndex == C.INDEX_UNSET) { // Set to 0 so that parseDialogueLine skips lines until a complete format line is found. formatKeyCount = 0; } }
Example 8
Source File: HttpDataSource.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public boolean evaluate(String contentType) { contentType = Util.toLowerInvariant(contentType); return !TextUtils.isEmpty(contentType) && (!contentType.contains("text") || contentType.contains("text/vtt")) && !contentType.contains("html") && !contentType.contains("xml"); }
Example 9
Source File: SsaDecoder.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Parses a format line. * * @param formatLine The line to parse. */ private void parseFormatLine(String formatLine) { String[] values = TextUtils.split(formatLine.substring(FORMAT_LINE_PREFIX.length()), ","); formatKeyCount = values.length; formatStartIndex = C.INDEX_UNSET; formatEndIndex = C.INDEX_UNSET; formatTextIndex = C.INDEX_UNSET; for (int i = 0; i < formatKeyCount; i++) { String key = Util.toLowerInvariant(values[i].trim()); switch (key) { case "start": formatStartIndex = i; break; case "end": formatEndIndex = i; break; case "text": formatTextIndex = i; break; default: // Do nothing. break; } } if (formatStartIndex == C.INDEX_UNSET || formatEndIndex == C.INDEX_UNSET || formatTextIndex == C.INDEX_UNSET) { // Set to 0 so that parseDialogueLine skips lines until a complete format line is found. formatKeyCount = 0; } }
Example 10
Source File: HttpDataSource.java From K-Sonic with MIT License | 5 votes |
@Override public boolean evaluate(String contentType) { contentType = Util.toLowerInvariant(contentType); return !TextUtils.isEmpty(contentType) && (!contentType.contains("text") || contentType.contains("text/vtt")) && !contentType.contains("html") && !contentType.contains("xml"); }
Example 11
Source File: Id3Decoder.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private static ApicFrame decodeApicFrame(ParsableByteArray id3Data, int frameSize, int majorVersion) throws UnsupportedEncodingException { int encoding = id3Data.readUnsignedByte(); String charset = getCharsetName(encoding); byte[] data = new byte[frameSize - 1]; id3Data.readBytes(data, 0, frameSize - 1); String mimeType; int mimeTypeEndIndex; if (majorVersion == 2) { mimeTypeEndIndex = 2; mimeType = "image/" + Util.toLowerInvariant(new String(data, 0, 3, "ISO-8859-1")); if ("image/jpg".equals(mimeType)) { mimeType = "image/jpeg"; } } else { mimeTypeEndIndex = indexOfZeroByte(data, 0); mimeType = Util.toLowerInvariant(new String(data, 0, mimeTypeEndIndex, "ISO-8859-1")); if (mimeType.indexOf('/') == -1) { mimeType = "image/" + mimeType; } } int pictureType = data[mimeTypeEndIndex + 1] & 0xFF; int descriptionStartIndex = mimeTypeEndIndex + 2; int descriptionEndIndex = indexOfEos(data, descriptionStartIndex, encoding); String description = new String(data, descriptionStartIndex, descriptionEndIndex - descriptionStartIndex, charset); int pictureDataStartIndex = descriptionEndIndex + delimiterLength(encoding); byte[] pictureData = copyOfRangeIfValid(data, pictureDataStartIndex, data.length); return new ApicFrame(mimeType, description, pictureType, pictureData); }
Example 12
Source File: SsaDialogueFormat.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Parses the format info from a 'Format:' line in the [Events] section. * * @return the parsed info, or null if {@code formatLine} doesn't contain both 'start' and 'end'. */ @Nullable public static SsaDialogueFormat fromFormatLine(String formatLine) { int startTimeIndex = C.INDEX_UNSET; int endTimeIndex = C.INDEX_UNSET; int styleIndex = C.INDEX_UNSET; int textIndex = C.INDEX_UNSET; Assertions.checkArgument(formatLine.startsWith(FORMAT_LINE_PREFIX)); String[] keys = TextUtils.split(formatLine.substring(FORMAT_LINE_PREFIX.length()), ","); for (int i = 0; i < keys.length; i++) { switch (Util.toLowerInvariant(keys[i].trim())) { case "start": startTimeIndex = i; break; case "end": endTimeIndex = i; break; case "style": styleIndex = i; break; case "text": textIndex = i; break; } } return (startTimeIndex != C.INDEX_UNSET && endTimeIndex != C.INDEX_UNSET) ? new SsaDialogueFormat(startTimeIndex, endTimeIndex, styleIndex, textIndex, keys.length) : null; }
Example 13
Source File: WebvttCssStyle.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public WebvttCssStyle setFontFamily(String fontFamily) { this.fontFamily = Util.toLowerInvariant(fontFamily); return this; }
Example 14
Source File: WebvttCssStyle.java From Telegram with GNU General Public License v2.0 | 4 votes |
public WebvttCssStyle setFontFamily(String fontFamily) { this.fontFamily = Util.toLowerInvariant(fontFamily); return this; }
Example 15
Source File: DashManifestParser.java From Telegram with GNU General Public License v2.0 | 4 votes |
/** * Parses a ContentProtection element. * * @param xpp The parser from which to read. * @throws XmlPullParserException If an error occurs parsing the element. * @throws IOException If an error occurs reading the element. * @return The scheme type and/or {@link SchemeData} parsed from the ContentProtection element. * Either or both may be null, depending on the ContentProtection element being parsed. */ protected Pair<String, SchemeData> parseContentProtection(XmlPullParser xpp) throws XmlPullParserException, IOException { String schemeType = null; String licenseServerUrl = null; byte[] data = null; UUID uuid = null; boolean requiresSecureDecoder = false; String schemeIdUri = xpp.getAttributeValue(null, "schemeIdUri"); if (schemeIdUri != null) { switch (Util.toLowerInvariant(schemeIdUri)) { case "urn:mpeg:dash:mp4protection:2011": schemeType = xpp.getAttributeValue(null, "value"); String defaultKid = XmlPullParserUtil.getAttributeValueIgnorePrefix(xpp, "default_KID"); if (!TextUtils.isEmpty(defaultKid) && !"00000000-0000-0000-0000-000000000000".equals(defaultKid)) { String[] defaultKidStrings = defaultKid.split("\\s+"); UUID[] defaultKids = new UUID[defaultKidStrings.length]; for (int i = 0; i < defaultKidStrings.length; i++) { defaultKids[i] = UUID.fromString(defaultKidStrings[i]); } data = PsshAtomUtil.buildPsshAtom(C.COMMON_PSSH_UUID, defaultKids, null); uuid = C.COMMON_PSSH_UUID; } break; case "urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95": uuid = C.PLAYREADY_UUID; break; case "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed": uuid = C.WIDEVINE_UUID; break; default: break; } } do { xpp.next(); if (XmlPullParserUtil.isStartTag(xpp, "ms:laurl")) { licenseServerUrl = xpp.getAttributeValue(null, "licenseUrl"); } else if (XmlPullParserUtil.isStartTag(xpp, "widevine:license")) { String robustnessLevel = xpp.getAttributeValue(null, "robustness_level"); requiresSecureDecoder = robustnessLevel != null && robustnessLevel.startsWith("HW"); } else if (data == null && XmlPullParserUtil.isStartTagIgnorePrefix(xpp, "pssh") && xpp.next() == XmlPullParser.TEXT) { // The cenc:pssh element is defined in 23001-7:2015. data = Base64.decode(xpp.getText(), Base64.DEFAULT); uuid = PsshAtomUtil.parseUuid(data); if (uuid == null) { Log.w(TAG, "Skipping malformed cenc:pssh data"); data = null; } } else if (data == null && C.PLAYREADY_UUID.equals(uuid) && XmlPullParserUtil.isStartTag(xpp, "mspr:pro") && xpp.next() == XmlPullParser.TEXT) { // The mspr:pro element is defined in DASH Content Protection using Microsoft PlayReady. data = PsshAtomUtil.buildPsshAtom( C.PLAYREADY_UUID, Base64.decode(xpp.getText(), Base64.DEFAULT)); } else { maybeSkipTag(xpp); } } while (!XmlPullParserUtil.isEndTag(xpp, "ContentProtection")); SchemeData schemeData = uuid != null ? new SchemeData( uuid, licenseServerUrl, MimeTypes.VIDEO_MP4, data, requiresSecureDecoder) : null; return Pair.create(schemeType, schemeData); }
Example 16
Source File: WebvttCssStyle.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public WebvttCssStyle setFontFamily(String fontFamily) { this.fontFamily = Util.toLowerInvariant(fontFamily); return this; }
Example 17
Source File: WebvttCssStyle.java From K-Sonic with MIT License | 4 votes |
public WebvttCssStyle setFontFamily(String fontFamily) { this.fontFamily = Util.toLowerInvariant(fontFamily); return this; }
Example 18
Source File: WebvttCssStyle.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public WebvttCssStyle setFontFamily(String fontFamily) { this.fontFamily = Util.toLowerInvariant(fontFamily); return this; }
Example 19
Source File: DashManifestParser.java From MediaSDK with Apache License 2.0 | 4 votes |
/** * Parses a ContentProtection element. * * @param xpp The parser from which to read. * @throws XmlPullParserException If an error occurs parsing the element. * @throws IOException If an error occurs reading the element. * @return The scheme type and/or {@link SchemeData} parsed from the ContentProtection element. * Either or both may be null, depending on the ContentProtection element being parsed. */ protected Pair<@NullableType String, @NullableType SchemeData> parseContentProtection( XmlPullParser xpp) throws XmlPullParserException, IOException { String schemeType = null; String licenseServerUrl = null; byte[] data = null; UUID uuid = null; String schemeIdUri = xpp.getAttributeValue(null, "schemeIdUri"); if (schemeIdUri != null) { switch (Util.toLowerInvariant(schemeIdUri)) { case "urn:mpeg:dash:mp4protection:2011": schemeType = xpp.getAttributeValue(null, "value"); String defaultKid = XmlPullParserUtil.getAttributeValueIgnorePrefix(xpp, "default_KID"); if (!TextUtils.isEmpty(defaultKid) && !"00000000-0000-0000-0000-000000000000".equals(defaultKid)) { String[] defaultKidStrings = defaultKid.split("\\s+"); UUID[] defaultKids = new UUID[defaultKidStrings.length]; for (int i = 0; i < defaultKidStrings.length; i++) { defaultKids[i] = UUID.fromString(defaultKidStrings[i]); } data = PsshAtomUtil.buildPsshAtom(C.COMMON_PSSH_UUID, defaultKids, null); uuid = C.COMMON_PSSH_UUID; } break; case "urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95": uuid = C.PLAYREADY_UUID; break; case "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed": uuid = C.WIDEVINE_UUID; break; default: break; } } do { xpp.next(); if (XmlPullParserUtil.isStartTag(xpp, "ms:laurl")) { licenseServerUrl = xpp.getAttributeValue(null, "licenseUrl"); } else if (data == null && XmlPullParserUtil.isStartTagIgnorePrefix(xpp, "pssh") && xpp.next() == XmlPullParser.TEXT) { // The cenc:pssh element is defined in 23001-7:2015. data = Base64.decode(xpp.getText(), Base64.DEFAULT); uuid = PsshAtomUtil.parseUuid(data); if (uuid == null) { Log.w(TAG, "Skipping malformed cenc:pssh data"); data = null; } } else if (data == null && C.PLAYREADY_UUID.equals(uuid) && XmlPullParserUtil.isStartTag(xpp, "mspr:pro") && xpp.next() == XmlPullParser.TEXT) { // The mspr:pro element is defined in DASH Content Protection using Microsoft PlayReady. data = PsshAtomUtil.buildPsshAtom( C.PLAYREADY_UUID, Base64.decode(xpp.getText(), Base64.DEFAULT)); } else { maybeSkipTag(xpp); } } while (!XmlPullParserUtil.isEndTag(xpp, "ContentProtection")); SchemeData schemeData = uuid != null ? new SchemeData(uuid, licenseServerUrl, MimeTypes.VIDEO_MP4, data) : null; return Pair.create(schemeType, schemeData); }
Example 20
Source File: WebvttCssStyle.java From MediaSDK with Apache License 2.0 | 4 votes |
public WebvttCssStyle setFontFamily(@Nullable String fontFamily) { this.fontFamily = Util.toLowerInvariant(fontFamily); return this; }