Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,423 @@
package com.mbridge.msdk.playercommon.exoplayer2.text.ttml;
import android.util.Log;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.text.SimpleSubtitleDecoder;
import com.mbridge.msdk.playercommon.exoplayer2.text.SubtitleDecoderException;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import com.mbridge.msdk.playercommon.exoplayer2.util.XmlPullParserUtil;
import csdk.gluads.Consts;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
/* loaded from: classes4.dex */
public final class TtmlDecoder extends SimpleSubtitleDecoder {
private static final String ATTR_BEGIN = "begin";
private static final String ATTR_DURATION = "dur";
private static final String ATTR_END = "end";
private static final String ATTR_REGION = "region";
private static final String ATTR_STYLE = "style";
private static final int DEFAULT_FRAME_RATE = 30;
private static final String TAG = "TtmlDecoder";
private static final String TTP = "http://www.w3.org/ns/ttml#parameter";
private final XmlPullParserFactory xmlParserFactory;
private static final Pattern CLOCK_TIME = Pattern.compile("^([0-9][0-9]+):([0-9][0-9]):([0-9][0-9])(?:(\\.[0-9]+)|:([0-9][0-9])(?:\\.([0-9]+))?)?$");
private static final Pattern OFFSET_TIME = Pattern.compile("^([0-9]+(?:\\.[0-9]+)?)(h|m|s|ms|f|t)$");
private static final Pattern FONT_SIZE = Pattern.compile("^(([0-9]*.)?[0-9]+)(px|em|%)$");
private static final Pattern PERCENTAGE_COORDINATES = Pattern.compile("^(\\d+\\.?\\d*?)% (\\d+\\.?\\d*?)%$");
private static final Pattern CELL_RESOLUTION = Pattern.compile("^(\\d+) (\\d+)$");
private static final FrameAndTickRate DEFAULT_FRAME_AND_TICK_RATE = new FrameAndTickRate(30.0f, 1, 1);
private static final CellResolution DEFAULT_CELL_RESOLUTION = new CellResolution(32, 15);
public TtmlDecoder() {
super(TAG);
try {
XmlPullParserFactory newInstance = XmlPullParserFactory.newInstance();
this.xmlParserFactory = newInstance;
newInstance.setNamespaceAware(true);
} catch (XmlPullParserException e) {
throw new RuntimeException("Couldn't create XmlPullParserFactory instance", e);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.text.SimpleSubtitleDecoder
public final TtmlSubtitle decode(byte[] bArr, int i, boolean z) throws SubtitleDecoderException {
try {
XmlPullParser newPullParser = this.xmlParserFactory.newPullParser();
HashMap hashMap = new HashMap();
HashMap hashMap2 = new HashMap();
TtmlSubtitle ttmlSubtitle = null;
hashMap2.put("", new TtmlRegion(null));
int i2 = 0;
newPullParser.setInput(new ByteArrayInputStream(bArr, 0, i), null);
ArrayDeque arrayDeque = new ArrayDeque();
FrameAndTickRate frameAndTickRate = DEFAULT_FRAME_AND_TICK_RATE;
CellResolution cellResolution = DEFAULT_CELL_RESOLUTION;
for (int eventType = newPullParser.getEventType(); eventType != 1; eventType = newPullParser.getEventType()) {
TtmlNode ttmlNode = (TtmlNode) arrayDeque.peek();
if (i2 == 0) {
String name = newPullParser.getName();
if (eventType == 2) {
if (TtmlNode.TAG_TT.equals(name)) {
frameAndTickRate = parseFrameAndTickRates(newPullParser);
cellResolution = parseCellResolution(newPullParser, DEFAULT_CELL_RESOLUTION);
}
if (!isSupportedTag(name)) {
StringBuilder sb = new StringBuilder();
sb.append("Ignoring unsupported tag: ");
sb.append(newPullParser.getName());
} else if (TtmlNode.TAG_HEAD.equals(name)) {
parseHeader(newPullParser, hashMap, hashMap2, cellResolution);
} else {
try {
TtmlNode parseNode = parseNode(newPullParser, ttmlNode, hashMap2, frameAndTickRate);
arrayDeque.push(parseNode);
if (ttmlNode != null) {
ttmlNode.addChild(parseNode);
}
} catch (SubtitleDecoderException e) {
Log.w(TAG, "Suppressing parser error", e);
}
}
i2++;
} else if (eventType == 4) {
ttmlNode.addChild(TtmlNode.buildTextNode(newPullParser.getText()));
} else if (eventType == 3) {
if (newPullParser.getName().equals(TtmlNode.TAG_TT)) {
ttmlSubtitle = new TtmlSubtitle((TtmlNode) arrayDeque.peek(), hashMap, hashMap2);
}
arrayDeque.pop();
}
} else {
if (eventType != 2) {
if (eventType == 3) {
i2--;
}
}
i2++;
}
newPullParser.next();
}
return ttmlSubtitle;
} catch (IOException e2) {
throw new IllegalStateException("Unexpected error when reading input.", e2);
} catch (XmlPullParserException e3) {
throw new SubtitleDecoderException("Unable to decode source", e3);
}
}
private FrameAndTickRate parseFrameAndTickRates(XmlPullParser xmlPullParser) throws SubtitleDecoderException {
float f;
String attributeValue = xmlPullParser.getAttributeValue(TTP, "frameRate");
int parseInt = attributeValue != null ? Integer.parseInt(attributeValue) : 30;
String attributeValue2 = xmlPullParser.getAttributeValue(TTP, "frameRateMultiplier");
if (attributeValue2 != null) {
if (Util.split(attributeValue2, " ").length != 2) {
throw new SubtitleDecoderException("frameRateMultiplier doesn't have 2 parts");
}
f = Integer.parseInt(r2[0]) / Integer.parseInt(r2[1]);
} else {
f = 1.0f;
}
FrameAndTickRate frameAndTickRate = DEFAULT_FRAME_AND_TICK_RATE;
int i = frameAndTickRate.subFrameRate;
String attributeValue3 = xmlPullParser.getAttributeValue(TTP, "subFrameRate");
if (attributeValue3 != null) {
i = Integer.parseInt(attributeValue3);
}
int i2 = frameAndTickRate.tickRate;
String attributeValue4 = xmlPullParser.getAttributeValue(TTP, "tickRate");
if (attributeValue4 != null) {
i2 = Integer.parseInt(attributeValue4);
}
return new FrameAndTickRate(parseInt * f, i, i2);
}
private CellResolution parseCellResolution(XmlPullParser xmlPullParser, CellResolution cellResolution) throws SubtitleDecoderException {
String attributeValue = xmlPullParser.getAttributeValue(TTP, "cellResolution");
if (attributeValue == null) {
return cellResolution;
}
Matcher matcher = CELL_RESOLUTION.matcher(attributeValue);
if (!matcher.matches()) {
Log.w(TAG, "Ignoring malformed cell resolution: " + attributeValue);
return cellResolution;
}
try {
int parseInt = Integer.parseInt(matcher.group(1));
int parseInt2 = Integer.parseInt(matcher.group(2));
if (parseInt == 0 || parseInt2 == 0) {
throw new SubtitleDecoderException("Invalid cell resolution " + parseInt + " " + parseInt2);
}
return new CellResolution(parseInt, parseInt2);
} catch (NumberFormatException unused) {
Log.w(TAG, "Ignoring malformed cell resolution: " + attributeValue);
return cellResolution;
}
}
private Map<String, TtmlStyle> parseHeader(XmlPullParser xmlPullParser, Map<String, TtmlStyle> map, Map<String, TtmlRegion> map2, CellResolution cellResolution) throws IOException, XmlPullParserException {
TtmlRegion parseRegionAttributes;
do {
xmlPullParser.next();
if (XmlPullParserUtil.isStartTag(xmlPullParser, "style")) {
String attributeValue = XmlPullParserUtil.getAttributeValue(xmlPullParser, "style");
TtmlStyle parseStyleAttributes = parseStyleAttributes(xmlPullParser, new TtmlStyle());
if (attributeValue != null) {
for (String str : parseStyleIds(attributeValue)) {
parseStyleAttributes.chain(map.get(str));
}
}
if (parseStyleAttributes.getId() != null) {
map.put(parseStyleAttributes.getId(), parseStyleAttributes);
}
} else if (XmlPullParserUtil.isStartTag(xmlPullParser, "region") && (parseRegionAttributes = parseRegionAttributes(xmlPullParser, cellResolution)) != null) {
map2.put(parseRegionAttributes.id, parseRegionAttributes);
}
} while (!XmlPullParserUtil.isEndTag(xmlPullParser, TtmlNode.TAG_HEAD));
return map;
}
private TtmlRegion parseRegionAttributes(XmlPullParser xmlPullParser, CellResolution cellResolution) {
float f;
String attributeValue = XmlPullParserUtil.getAttributeValue(xmlPullParser, "id");
if (attributeValue == null) {
return null;
}
String attributeValue2 = XmlPullParserUtil.getAttributeValue(xmlPullParser, "origin");
if (attributeValue2 != null) {
Pattern pattern = PERCENTAGE_COORDINATES;
Matcher matcher = pattern.matcher(attributeValue2);
if (matcher.matches()) {
int i = 1;
try {
float parseFloat = Float.parseFloat(matcher.group(1)) / 100.0f;
float parseFloat2 = Float.parseFloat(matcher.group(2)) / 100.0f;
String attributeValue3 = XmlPullParserUtil.getAttributeValue(xmlPullParser, TtmlNode.ATTR_TTS_EXTENT);
if (attributeValue3 != null) {
Matcher matcher2 = pattern.matcher(attributeValue3);
if (matcher2.matches()) {
try {
float parseFloat3 = Float.parseFloat(matcher2.group(1)) / 100.0f;
float parseFloat4 = Float.parseFloat(matcher2.group(2)) / 100.0f;
String attributeValue4 = XmlPullParserUtil.getAttributeValue(xmlPullParser, TtmlNode.ATTR_TTS_DISPLAY_ALIGN);
if (attributeValue4 != null) {
String lowerInvariant = Util.toLowerInvariant(attributeValue4);
lowerInvariant.hashCode();
if (lowerInvariant.equals("center")) {
parseFloat2 += parseFloat4 / 2.0f;
f = parseFloat2;
return new TtmlRegion(attributeValue, parseFloat, f, 0, i, parseFloat3, 1, 1.0f / cellResolution.rows);
}
if (lowerInvariant.equals("after")) {
f = parseFloat2 + parseFloat4;
i = 2;
return new TtmlRegion(attributeValue, parseFloat, f, 0, i, parseFloat3, 1, 1.0f / cellResolution.rows);
}
}
i = 0;
f = parseFloat2;
return new TtmlRegion(attributeValue, parseFloat, f, 0, i, parseFloat3, 1, 1.0f / cellResolution.rows);
} catch (NumberFormatException unused) {
Log.w(TAG, "Ignoring region with malformed extent: " + attributeValue2);
return null;
}
}
Log.w(TAG, "Ignoring region with unsupported extent: " + attributeValue2);
return null;
}
Log.w(TAG, "Ignoring region without an extent");
return null;
} catch (NumberFormatException unused2) {
Log.w(TAG, "Ignoring region with malformed origin: " + attributeValue2);
return null;
}
}
Log.w(TAG, "Ignoring region with unsupported origin: " + attributeValue2);
return null;
}
Log.w(TAG, "Ignoring region without an origin");
return null;
}
private String[] parseStyleIds(String str) {
String trim = str.trim();
return trim.isEmpty() ? new String[0] : Util.split(trim, "\\s+");
}
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
/* JADX WARN: Code restructure failed: missing block: B:44:0x012e, code lost:
if (r3.equals(com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlNode.LINETHROUGH) == false) goto L63;
*/
/* JADX WARN: Code restructure failed: missing block: B:70:0x0194, code lost:
if (r3.equals("start") == false) goto L87;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlStyle parseStyleAttributes(org.xmlpull.v1.XmlPullParser r12, com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlStyle r13) {
/*
Method dump skipped, instructions count: 664
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlDecoder.parseStyleAttributes(org.xmlpull.v1.XmlPullParser, com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlStyle):com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlStyle");
}
private TtmlStyle createIfNull(TtmlStyle ttmlStyle) {
return ttmlStyle == null ? new TtmlStyle() : ttmlStyle;
}
private TtmlNode parseNode(XmlPullParser xmlPullParser, TtmlNode ttmlNode, Map<String, TtmlRegion> map, FrameAndTickRate frameAndTickRate) throws SubtitleDecoderException {
long j;
String attributeValue;
int attributeCount = xmlPullParser.getAttributeCount();
TtmlStyle parseStyleAttributes = parseStyleAttributes(xmlPullParser, null);
String[] strArr = null;
long j2 = -9223372036854775807L;
long j3 = -9223372036854775807L;
long j4 = -9223372036854775807L;
String str = "";
for (int i = 0; i < attributeCount; i++) {
String attributeName = xmlPullParser.getAttributeName(i);
attributeValue = xmlPullParser.getAttributeValue(i);
attributeName.hashCode();
switch (attributeName) {
case "region":
if (!map.containsKey(attributeValue)) {
break;
} else {
str = attributeValue;
continue;
}
case "dur":
j4 = parseTimeExpression(attributeValue, frameAndTickRate);
break;
case "end":
j3 = parseTimeExpression(attributeValue, frameAndTickRate);
break;
case "begin":
j2 = parseTimeExpression(attributeValue, frameAndTickRate);
break;
case "style":
String[] parseStyleIds = parseStyleIds(attributeValue);
if (parseStyleIds.length > 0) {
strArr = parseStyleIds;
break;
}
break;
}
}
if (ttmlNode != null) {
long j5 = ttmlNode.startTimeUs;
if (j5 != C.TIME_UNSET) {
if (j2 != C.TIME_UNSET) {
j2 += j5;
}
if (j3 != C.TIME_UNSET) {
j3 += j5;
}
}
}
if (j3 == C.TIME_UNSET) {
if (j4 != C.TIME_UNSET) {
j = j2 + j4;
} else if (ttmlNode != null) {
long j6 = ttmlNode.endTimeUs;
if (j6 != C.TIME_UNSET) {
j = j6;
}
}
return TtmlNode.buildNode(xmlPullParser.getName(), j2, j, parseStyleAttributes, strArr, str);
}
j = j3;
return TtmlNode.buildNode(xmlPullParser.getName(), j2, j, parseStyleAttributes, strArr, str);
}
private static boolean isSupportedTag(String str) {
return str.equals(TtmlNode.TAG_TT) || str.equals(TtmlNode.TAG_HEAD) || str.equals("body") || str.equals(TtmlNode.TAG_DIV) || str.equals(TtmlNode.TAG_P) || str.equals(TtmlNode.TAG_SPAN) || str.equals(TtmlNode.TAG_BR) || str.equals("style") || str.equals(TtmlNode.TAG_STYLING) || str.equals(TtmlNode.TAG_LAYOUT) || str.equals("region") || str.equals("metadata") || str.equals(TtmlNode.TAG_SMPTE_IMAGE) || str.equals(TtmlNode.TAG_SMPTE_DATA) || str.equals(TtmlNode.TAG_SMPTE_INFORMATION);
}
private static void parseFontSize(String str, TtmlStyle ttmlStyle) throws SubtitleDecoderException {
Matcher matcher;
String group;
String[] split = Util.split(str, "\\s+");
if (split.length == 1) {
matcher = FONT_SIZE.matcher(str);
} else if (split.length == 2) {
matcher = FONT_SIZE.matcher(split[1]);
Log.w(TAG, "Multiple values in fontSize attribute. Picking the second value for vertical font size and ignoring the first.");
} else {
throw new SubtitleDecoderException("Invalid number of entries for fontSize: " + split.length + Consts.STRING_PERIOD);
}
if (matcher.matches()) {
group = matcher.group(3);
group.hashCode();
switch (group) {
case "%":
ttmlStyle.setFontSizeUnit(3);
break;
case "em":
ttmlStyle.setFontSizeUnit(2);
break;
case "px":
ttmlStyle.setFontSizeUnit(1);
break;
default:
throw new SubtitleDecoderException("Invalid unit for fontSize: '" + group + "'.");
}
ttmlStyle.setFontSize(Float.valueOf(matcher.group(1)).floatValue());
return;
}
throw new SubtitleDecoderException("Invalid expression for fontSize: '" + str + "'.");
}
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
/* JADX WARN: Code restructure failed: missing block: B:33:0x009e, code lost:
if (r13.equals("ms") == false) goto L21;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private static long parseTimeExpression(java.lang.String r13, com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlDecoder.FrameAndTickRate r14) throws com.mbridge.msdk.playercommon.exoplayer2.text.SubtitleDecoderException {
/*
Method dump skipped, instructions count: 296
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlDecoder.parseTimeExpression(java.lang.String, com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlDecoder$FrameAndTickRate):long");
}
public static final class FrameAndTickRate {
final float effectiveFrameRate;
final int subFrameRate;
final int tickRate;
public FrameAndTickRate(float f, int i, int i2) {
this.effectiveFrameRate = f;
this.subFrameRate = i;
this.tickRate = i2;
}
}
public static final class CellResolution {
final int columns;
final int rows;
public CellResolution(int i, int i2) {
this.columns = i;
this.rows = i2;
}
}
}

View File

@@ -0,0 +1,299 @@
package com.mbridge.msdk.playercommon.exoplayer2.text.ttml;
import android.text.Layout;
import android.text.SpannableStringBuilder;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.text.Cue;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
/* loaded from: classes4.dex */
final class TtmlNode {
public static final String ANONYMOUS_REGION_ID = "";
public static final String ATTR_ID = "id";
public static final String ATTR_TTS_BACKGROUND_COLOR = "backgroundColor";
public static final String ATTR_TTS_COLOR = "color";
public static final String ATTR_TTS_DISPLAY_ALIGN = "displayAlign";
public static final String ATTR_TTS_EXTENT = "extent";
public static final String ATTR_TTS_FONT_FAMILY = "fontFamily";
public static final String ATTR_TTS_FONT_SIZE = "fontSize";
public static final String ATTR_TTS_FONT_STYLE = "fontStyle";
public static final String ATTR_TTS_FONT_WEIGHT = "fontWeight";
public static final String ATTR_TTS_ORIGIN = "origin";
public static final String ATTR_TTS_TEXT_ALIGN = "textAlign";
public static final String ATTR_TTS_TEXT_DECORATION = "textDecoration";
public static final String BOLD = "bold";
public static final String CENTER = "center";
public static final String END = "end";
public static final String ITALIC = "italic";
public static final String LEFT = "left";
public static final String LINETHROUGH = "linethrough";
public static final String NO_LINETHROUGH = "nolinethrough";
public static final String NO_UNDERLINE = "nounderline";
public static final String RIGHT = "right";
public static final String START = "start";
public static final String TAG_BODY = "body";
public static final String TAG_BR = "br";
public static final String TAG_DIV = "div";
public static final String TAG_HEAD = "head";
public static final String TAG_LAYOUT = "layout";
public static final String TAG_METADATA = "metadata";
public static final String TAG_P = "p";
public static final String TAG_REGION = "region";
public static final String TAG_SMPTE_DATA = "smpte:data";
public static final String TAG_SMPTE_IMAGE = "smpte:image";
public static final String TAG_SMPTE_INFORMATION = "smpte:information";
public static final String TAG_SPAN = "span";
public static final String TAG_STYLE = "style";
public static final String TAG_STYLING = "styling";
public static final String TAG_TT = "tt";
public static final String UNDERLINE = "underline";
private List<TtmlNode> children;
public final long endTimeUs;
public final boolean isTextNode;
private final HashMap<String, Integer> nodeEndsByRegion;
private final HashMap<String, Integer> nodeStartsByRegion;
public final String regionId;
public final long startTimeUs;
public final TtmlStyle style;
private final String[] styleIds;
public final String tag;
public final String text;
public final String[] getStyleIds() {
return this.styleIds;
}
public final boolean isActive(long j) {
long j2 = this.startTimeUs;
return (j2 == C.TIME_UNSET && this.endTimeUs == C.TIME_UNSET) || (j2 <= j && this.endTimeUs == C.TIME_UNSET) || ((j2 == C.TIME_UNSET && j < this.endTimeUs) || (j2 <= j && j < this.endTimeUs));
}
public static TtmlNode buildTextNode(String str) {
return new TtmlNode(null, TtmlRenderUtil.applyTextElementSpacePolicy(str), C.TIME_UNSET, C.TIME_UNSET, null, null, "");
}
public static TtmlNode buildNode(String str, long j, long j2, TtmlStyle ttmlStyle, String[] strArr, String str2) {
return new TtmlNode(str, null, j, j2, ttmlStyle, strArr, str2);
}
private TtmlNode(String str, String str2, long j, long j2, TtmlStyle ttmlStyle, String[] strArr, String str3) {
this.tag = str;
this.text = str2;
this.style = ttmlStyle;
this.styleIds = strArr;
this.isTextNode = str2 != null;
this.startTimeUs = j;
this.endTimeUs = j2;
this.regionId = (String) Assertions.checkNotNull(str3);
this.nodeStartsByRegion = new HashMap<>();
this.nodeEndsByRegion = new HashMap<>();
}
public final void addChild(TtmlNode ttmlNode) {
if (this.children == null) {
this.children = new ArrayList();
}
this.children.add(ttmlNode);
}
public final TtmlNode getChild(int i) {
List<TtmlNode> list = this.children;
if (list == null) {
throw new IndexOutOfBoundsException();
}
return list.get(i);
}
public final int getChildCount() {
List<TtmlNode> list = this.children;
if (list == null) {
return 0;
}
return list.size();
}
public final long[] getEventTimesUs() {
TreeSet<Long> treeSet = new TreeSet<>();
int i = 0;
getEventTimes(treeSet, false);
long[] jArr = new long[treeSet.size()];
Iterator<Long> it = treeSet.iterator();
while (it.hasNext()) {
jArr[i] = it.next().longValue();
i++;
}
return jArr;
}
private void getEventTimes(TreeSet<Long> treeSet, boolean z) {
boolean equals = TAG_P.equals(this.tag);
if (z || equals) {
long j = this.startTimeUs;
if (j != C.TIME_UNSET) {
treeSet.add(Long.valueOf(j));
}
long j2 = this.endTimeUs;
if (j2 != C.TIME_UNSET) {
treeSet.add(Long.valueOf(j2));
}
}
if (this.children == null) {
return;
}
for (int i = 0; i < this.children.size(); i++) {
this.children.get(i).getEventTimes(treeSet, z || equals);
}
}
public final List<Cue> getCues(long j, Map<String, TtmlStyle> map, Map<String, TtmlRegion> map2) {
TreeMap treeMap = new TreeMap();
traverseForText(j, false, this.regionId, treeMap);
traverseForStyle(j, map, treeMap);
ArrayList arrayList = new ArrayList();
for (Map.Entry entry : treeMap.entrySet()) {
TtmlRegion ttmlRegion = map2.get(entry.getKey());
arrayList.add(new Cue(cleanUpText((SpannableStringBuilder) entry.getValue()), (Layout.Alignment) null, ttmlRegion.line, ttmlRegion.lineType, ttmlRegion.lineAnchor, ttmlRegion.position, Integer.MIN_VALUE, ttmlRegion.width, ttmlRegion.textSizeType, ttmlRegion.textSize));
}
return arrayList;
}
private void traverseForText(long j, boolean z, String str, Map<String, SpannableStringBuilder> map) {
this.nodeStartsByRegion.clear();
this.nodeEndsByRegion.clear();
if ("metadata".equals(this.tag)) {
return;
}
if (!"".equals(this.regionId)) {
str = this.regionId;
}
if (this.isTextNode && z) {
getRegionOutput(str, map).append((CharSequence) this.text);
return;
}
if (TAG_BR.equals(this.tag) && z) {
getRegionOutput(str, map).append('\n');
return;
}
if (isActive(j)) {
for (Map.Entry<String, SpannableStringBuilder> entry : map.entrySet()) {
this.nodeStartsByRegion.put(entry.getKey(), Integer.valueOf(entry.getValue().length()));
}
boolean equals = TAG_P.equals(this.tag);
for (int i = 0; i < getChildCount(); i++) {
getChild(i).traverseForText(j, z || equals, str, map);
}
if (equals) {
TtmlRenderUtil.endParagraph(getRegionOutput(str, map));
}
for (Map.Entry<String, SpannableStringBuilder> entry2 : map.entrySet()) {
this.nodeEndsByRegion.put(entry2.getKey(), Integer.valueOf(entry2.getValue().length()));
}
}
}
private static SpannableStringBuilder getRegionOutput(String str, Map<String, SpannableStringBuilder> map) {
if (!map.containsKey(str)) {
map.put(str, new SpannableStringBuilder());
}
return map.get(str);
}
private void traverseForStyle(long j, Map<String, TtmlStyle> map, Map<String, SpannableStringBuilder> map2) {
int i;
if (isActive(j)) {
Iterator<Map.Entry<String, Integer>> it = this.nodeEndsByRegion.entrySet().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
Map.Entry<String, Integer> next = it.next();
String key = next.getKey();
i = this.nodeStartsByRegion.containsKey(key) ? this.nodeStartsByRegion.get(key).intValue() : 0;
int intValue = next.getValue().intValue();
if (i != intValue) {
applyStyleToOutput(map, map2.get(key), i, intValue);
}
}
while (i < getChildCount()) {
getChild(i).traverseForStyle(j, map, map2);
i++;
}
}
}
private void applyStyleToOutput(Map<String, TtmlStyle> map, SpannableStringBuilder spannableStringBuilder, int i, int i2) {
TtmlStyle resolveStyle = TtmlRenderUtil.resolveStyle(this.style, this.styleIds, map);
if (resolveStyle != null) {
TtmlRenderUtil.applyStylesToSpan(spannableStringBuilder, i, i2, resolveStyle);
}
}
private SpannableStringBuilder cleanUpText(SpannableStringBuilder spannableStringBuilder) {
int i;
int i2;
int length = spannableStringBuilder.length();
int i3 = 0;
for (int i4 = 0; i4 < length; i4++) {
if (spannableStringBuilder.charAt(i4) == ' ') {
int i5 = i4 + 1;
int i6 = i5;
while (i6 < spannableStringBuilder.length() && spannableStringBuilder.charAt(i6) == ' ') {
i6++;
}
int i7 = i6 - i5;
if (i7 > 0) {
spannableStringBuilder.delete(i4, i4 + i7);
length -= i7;
}
}
}
if (length > 0 && spannableStringBuilder.charAt(0) == ' ') {
spannableStringBuilder.delete(0, 1);
length--;
}
int i8 = 0;
while (true) {
i = length - 1;
if (i8 >= i) {
break;
}
if (spannableStringBuilder.charAt(i8) == '\n') {
int i9 = i8 + 1;
if (spannableStringBuilder.charAt(i9) == ' ') {
spannableStringBuilder.delete(i9, i8 + 2);
length--;
}
}
i8++;
}
if (length > 0 && spannableStringBuilder.charAt(i) == ' ') {
spannableStringBuilder.delete(i, length);
length--;
}
while (true) {
i2 = length - 1;
if (i3 >= i2) {
break;
}
if (spannableStringBuilder.charAt(i3) == ' ') {
int i10 = i3 + 1;
if (spannableStringBuilder.charAt(i10) == '\n') {
spannableStringBuilder.delete(i3, i10);
length--;
}
}
i3++;
}
if (length > 0 && spannableStringBuilder.charAt(i2) == '\n') {
spannableStringBuilder.delete(i2, length);
}
return spannableStringBuilder;
}
}

View File

@@ -0,0 +1,28 @@
package com.mbridge.msdk.playercommon.exoplayer2.text.ttml;
/* loaded from: classes4.dex */
final class TtmlRegion {
public final String id;
public final float line;
public final int lineAnchor;
public final int lineType;
public final float position;
public final float textSize;
public final int textSizeType;
public final float width;
public TtmlRegion(String str) {
this(str, Float.MIN_VALUE, Float.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, Float.MIN_VALUE, Integer.MIN_VALUE, Float.MIN_VALUE);
}
public TtmlRegion(String str, float f, float f2, int i, int i2, float f3, int i3, float f4) {
this.id = str;
this.position = f;
this.line = f2;
this.lineType = i;
this.lineAnchor = i2;
this.width = f3;
this.textSizeType = i3;
this.textSize = f4;
}
}

View File

@@ -0,0 +1,99 @@
package com.mbridge.msdk.playercommon.exoplayer2.text.ttml;
import android.text.SpannableStringBuilder;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.AlignmentSpan;
import android.text.style.BackgroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan;
import android.text.style.TypefaceSpan;
import android.text.style.UnderlineSpan;
import java.util.Map;
/* loaded from: classes4.dex */
final class TtmlRenderUtil {
private TtmlRenderUtil() {
}
public static TtmlStyle resolveStyle(TtmlStyle ttmlStyle, String[] strArr, Map<String, TtmlStyle> map) {
if (ttmlStyle == null && strArr == null) {
return null;
}
int i = 0;
if (ttmlStyle == null && strArr.length == 1) {
return map.get(strArr[0]);
}
if (ttmlStyle == null && strArr.length > 1) {
TtmlStyle ttmlStyle2 = new TtmlStyle();
int length = strArr.length;
while (i < length) {
ttmlStyle2.chain(map.get(strArr[i]));
i++;
}
return ttmlStyle2;
}
if (ttmlStyle != null && strArr != null && strArr.length == 1) {
return ttmlStyle.chain(map.get(strArr[0]));
}
if (ttmlStyle != null && strArr != null && strArr.length > 1) {
int length2 = strArr.length;
while (i < length2) {
ttmlStyle.chain(map.get(strArr[i]));
i++;
}
}
return ttmlStyle;
}
public static void applyStylesToSpan(SpannableStringBuilder spannableStringBuilder, int i, int i2, TtmlStyle ttmlStyle) {
if (ttmlStyle.getStyle() != -1) {
spannableStringBuilder.setSpan(new StyleSpan(ttmlStyle.getStyle()), i, i2, 33);
}
if (ttmlStyle.isLinethrough()) {
spannableStringBuilder.setSpan(new StrikethroughSpan(), i, i2, 33);
}
if (ttmlStyle.isUnderline()) {
spannableStringBuilder.setSpan(new UnderlineSpan(), i, i2, 33);
}
if (ttmlStyle.hasFontColor()) {
spannableStringBuilder.setSpan(new ForegroundColorSpan(ttmlStyle.getFontColor()), i, i2, 33);
}
if (ttmlStyle.hasBackgroundColor()) {
spannableStringBuilder.setSpan(new BackgroundColorSpan(ttmlStyle.getBackgroundColor()), i, i2, 33);
}
if (ttmlStyle.getFontFamily() != null) {
spannableStringBuilder.setSpan(new TypefaceSpan(ttmlStyle.getFontFamily()), i, i2, 33);
}
if (ttmlStyle.getTextAlign() != null) {
spannableStringBuilder.setSpan(new AlignmentSpan.Standard(ttmlStyle.getTextAlign()), i, i2, 33);
}
int fontSizeUnit = ttmlStyle.getFontSizeUnit();
if (fontSizeUnit == 1) {
spannableStringBuilder.setSpan(new AbsoluteSizeSpan((int) ttmlStyle.getFontSize(), true), i, i2, 33);
} else if (fontSizeUnit == 2) {
spannableStringBuilder.setSpan(new RelativeSizeSpan(ttmlStyle.getFontSize()), i, i2, 33);
} else {
if (fontSizeUnit != 3) {
return;
}
spannableStringBuilder.setSpan(new RelativeSizeSpan(ttmlStyle.getFontSize() / 100.0f), i, i2, 33);
}
}
public static void endParagraph(SpannableStringBuilder spannableStringBuilder) {
int length = spannableStringBuilder.length() - 1;
while (length >= 0 && spannableStringBuilder.charAt(length) == ' ') {
length--;
}
if (length < 0 || spannableStringBuilder.charAt(length) == '\n') {
return;
}
spannableStringBuilder.append('\n');
}
public static String applyTextElementSpacePolicy(String str) {
return str.replaceAll("\r\n", "\n").replaceAll(" *\n *", "\n").replaceAll("\n", " ").replaceAll("[ \t\\x0B\f\r]+", " ");
}
}

View File

@@ -0,0 +1,209 @@
package com.mbridge.msdk.playercommon.exoplayer2.text.ttml;
import android.text.Layout;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/* loaded from: classes4.dex */
final class TtmlStyle {
public static final int FONT_SIZE_UNIT_EM = 2;
public static final int FONT_SIZE_UNIT_PERCENT = 3;
public static final int FONT_SIZE_UNIT_PIXEL = 1;
private static final int OFF = 0;
private static final int ON = 1;
public static final int STYLE_BOLD = 1;
public static final int STYLE_BOLD_ITALIC = 3;
public static final int STYLE_ITALIC = 2;
public static final int STYLE_NORMAL = 0;
public static final int UNSPECIFIED = -1;
private int backgroundColor;
private int fontColor;
private String fontFamily;
private float fontSize;
private boolean hasBackgroundColor;
private boolean hasFontColor;
private String id;
private TtmlStyle inheritableStyle;
private Layout.Alignment textAlign;
private int linethrough = -1;
private int underline = -1;
private int bold = -1;
private int italic = -1;
private int fontSizeUnit = -1;
@Retention(RetentionPolicy.SOURCE)
public @interface FontSizeUnit {
}
@Retention(RetentionPolicy.SOURCE)
public @interface OptionalBoolean {
}
@Retention(RetentionPolicy.SOURCE)
public @interface StyleFlags {
}
public final String getFontFamily() {
return this.fontFamily;
}
public final float getFontSize() {
return this.fontSize;
}
public final int getFontSizeUnit() {
return this.fontSizeUnit;
}
public final String getId() {
return this.id;
}
public final int getStyle() {
int i = this.bold;
if (i == -1 && this.italic == -1) {
return -1;
}
return (i == 1 ? 1 : 0) | (this.italic == 1 ? 2 : 0);
}
public final Layout.Alignment getTextAlign() {
return this.textAlign;
}
public final boolean hasBackgroundColor() {
return this.hasBackgroundColor;
}
public final boolean hasFontColor() {
return this.hasFontColor;
}
public final boolean isLinethrough() {
return this.linethrough == 1;
}
public final boolean isUnderline() {
return this.underline == 1;
}
public final TtmlStyle setBackgroundColor(int i) {
this.backgroundColor = i;
this.hasBackgroundColor = true;
return this;
}
public final TtmlStyle setFontSize(float f) {
this.fontSize = f;
return this;
}
public final TtmlStyle setFontSizeUnit(int i) {
this.fontSizeUnit = i;
return this;
}
public final TtmlStyle setId(String str) {
this.id = str;
return this;
}
public final TtmlStyle setTextAlign(Layout.Alignment alignment) {
this.textAlign = alignment;
return this;
}
public final TtmlStyle setLinethrough(boolean z) {
Assertions.checkState(this.inheritableStyle == null);
this.linethrough = z ? 1 : 0;
return this;
}
public final TtmlStyle setUnderline(boolean z) {
Assertions.checkState(this.inheritableStyle == null);
this.underline = z ? 1 : 0;
return this;
}
public final TtmlStyle setBold(boolean z) {
Assertions.checkState(this.inheritableStyle == null);
this.bold = z ? 1 : 0;
return this;
}
public final TtmlStyle setItalic(boolean z) {
Assertions.checkState(this.inheritableStyle == null);
this.italic = z ? 1 : 0;
return this;
}
public final TtmlStyle setFontFamily(String str) {
Assertions.checkState(this.inheritableStyle == null);
this.fontFamily = str;
return this;
}
public final int getFontColor() {
if (this.hasFontColor) {
return this.fontColor;
}
throw new IllegalStateException("Font color has not been defined.");
}
public final TtmlStyle setFontColor(int i) {
Assertions.checkState(this.inheritableStyle == null);
this.fontColor = i;
this.hasFontColor = true;
return this;
}
public final int getBackgroundColor() {
if (this.hasBackgroundColor) {
return this.backgroundColor;
}
throw new IllegalStateException("Background color has not been defined.");
}
public final TtmlStyle inherit(TtmlStyle ttmlStyle) {
return inherit(ttmlStyle, false);
}
public final TtmlStyle chain(TtmlStyle ttmlStyle) {
return inherit(ttmlStyle, true);
}
private TtmlStyle inherit(TtmlStyle ttmlStyle, boolean z) {
if (ttmlStyle != null) {
if (!this.hasFontColor && ttmlStyle.hasFontColor) {
setFontColor(ttmlStyle.fontColor);
}
if (this.bold == -1) {
this.bold = ttmlStyle.bold;
}
if (this.italic == -1) {
this.italic = ttmlStyle.italic;
}
if (this.fontFamily == null) {
this.fontFamily = ttmlStyle.fontFamily;
}
if (this.linethrough == -1) {
this.linethrough = ttmlStyle.linethrough;
}
if (this.underline == -1) {
this.underline = ttmlStyle.underline;
}
if (this.textAlign == null) {
this.textAlign = ttmlStyle.textAlign;
}
if (this.fontSizeUnit == -1) {
this.fontSizeUnit = ttmlStyle.fontSizeUnit;
this.fontSize = ttmlStyle.fontSize;
}
if (z && !this.hasBackgroundColor && ttmlStyle.hasBackgroundColor) {
setBackgroundColor(ttmlStyle.backgroundColor);
}
}
return this;
}
}

View File

@@ -0,0 +1,55 @@
package com.mbridge.msdk.playercommon.exoplayer2.text.ttml;
import com.mbridge.msdk.playercommon.exoplayer2.text.Cue;
import com.mbridge.msdk.playercommon.exoplayer2.text.Subtitle;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/* loaded from: classes4.dex */
final class TtmlSubtitle implements Subtitle {
private final long[] eventTimesUs;
private final Map<String, TtmlStyle> globalStyles;
private final Map<String, TtmlRegion> regionMap;
private final TtmlNode root;
public final Map<String, TtmlStyle> getGlobalStyles() {
return this.globalStyles;
}
public final TtmlNode getRoot() {
return this.root;
}
public TtmlSubtitle(TtmlNode ttmlNode, Map<String, TtmlStyle> map, Map<String, TtmlRegion> map2) {
this.root = ttmlNode;
this.regionMap = map2;
this.globalStyles = map != null ? Collections.unmodifiableMap(map) : Collections.emptyMap();
this.eventTimesUs = ttmlNode.getEventTimesUs();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.text.Subtitle
public final int getNextEventTimeIndex(long j) {
int binarySearchCeil = Util.binarySearchCeil(this.eventTimesUs, j, false, false);
if (binarySearchCeil < this.eventTimesUs.length) {
return binarySearchCeil;
}
return -1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.text.Subtitle
public final int getEventTimeCount() {
return this.eventTimesUs.length;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.text.Subtitle
public final long getEventTime(int i) {
return this.eventTimesUs[i];
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.text.Subtitle
public final List<Cue> getCues(long j) {
return this.root.getCues(j, this.globalStyles, this.regionMap);
}
}