CrackMe.apk
Download file
package com.google.android.exoplayer2.extractor.ts;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.extractor.ExtractorInput;
import com.google.android.exoplayer2.extractor.PositionHolder;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.android.exoplayer2.util.TimestampAdjuster;
import com.google.android.exoplayer2.util.Util;
import java.io.IOException;
final class TsDurationReader {
private static final String TAG = "TsDurationReader";
private long durationUs = C.TIME_UNSET;
private long firstPcrValue = C.TIME_UNSET;
private boolean isDurationRead;
private boolean isFirstPcrValueRead;
private boolean isLastPcrValueRead;
private long lastPcrValue = C.TIME_UNSET;
private final ParsableByteArray packetBuffer = new ParsableByteArray();
private final TimestampAdjuster pcrTimestampAdjuster = new TimestampAdjuster(0);
private final int timestampSearchBytes;
TsDurationReader(int i) {
this.timestampSearchBytes = i;
}
public boolean isDurationReadFinished() {
return this.isDurationRead;
}
public int readDuration(ExtractorInput extractorInput, PositionHolder positionHolder, int i) throws IOException {
if (i <= 0) {
return finishReadDuration(extractorInput);
}
if (!this.isLastPcrValueRead) {
return readLastPcrValue(extractorInput, positionHolder, i);
}
if (this.lastPcrValue == C.TIME_UNSET) {
return finishReadDuration(extractorInput);
}
if (!this.isFirstPcrValueRead) {
return readFirstPcrValue(extractorInput, positionHolder, i);
}
long j = this.firstPcrValue;
if (j == C.TIME_UNSET) {
return finishReadDuration(extractorInput);
}
long adjustTsTimestamp = this.pcrTimestampAdjuster.adjustTsTimestamp(this.lastPcrValue) - this.pcrTimestampAdjuster.adjustTsTimestamp(j);
this.durationUs = adjustTsTimestamp;
if (adjustTsTimestamp < 0) {
Log.w(TAG, "Invalid duration: " + this.durationUs + ". Using TIME_UNSET instead.");
this.durationUs = C.TIME_UNSET;
}
return finishReadDuration(extractorInput);
}
public long getDurationUs() {
return this.durationUs;
}
public TimestampAdjuster getPcrTimestampAdjuster() {
return this.pcrTimestampAdjuster;
}
private int finishReadDuration(ExtractorInput extractorInput) {
this.packetBuffer.reset(Util.EMPTY_BYTE_ARRAY);
this.isDurationRead = true;
extractorInput.resetPeekPosition();
return 0;
}
private int readFirstPcrValue(ExtractorInput extractorInput, PositionHolder positionHolder, int i) throws IOException {
int min = (int) Math.min((long) this.timestampSearchBytes, extractorInput.getLength());
long j = (long) 0;
if (extractorInput.getPosition() != j) {
positionHolder.position = j;
return 1;
}
this.packetBuffer.reset(min);
extractorInput.resetPeekPosition();
extractorInput.peekFully(this.packetBuffer.getData(), 0, min);
this.firstPcrValue = readFirstPcrValueFromBuffer(this.packetBuffer, i);
this.isFirstPcrValueRead = true;
return 0;
}
private long readFirstPcrValueFromBuffer(ParsableByteArray parsableByteArray, int i) {
int limit = parsableByteArray.limit();
for (int position = parsableByteArray.getPosition(); position < limit; position++) {
if (parsableByteArray.getData()[position] == 71) {
long readPcrFromPacket = TsUtil.readPcrFromPacket(parsableByteArray, position, i);
if (readPcrFromPacket != C.TIME_UNSET) {
return readPcrFromPacket;
}
}
}
return C.TIME_UNSET;
}
private int readLastPcrValue(ExtractorInput extractorInput, PositionHolder positionHolder, int i) throws IOException {
long length = extractorInput.getLength();
int min = (int) Math.min((long) this.timestampSearchBytes, length);
long j = length - ((long) min);
if (extractorInput.getPosition() != j) {
positionHolder.position = j;
return 1;
}
this.packetBuffer.reset(min);
extractorInput.resetPeekPosition();
extractorInput.peekFully(this.packetBuffer.getData(), 0, min);
this.lastPcrValue = readLastPcrValueFromBuffer(this.packetBuffer, i);
this.isLastPcrValueRead = true;
return 0;
}
private long readLastPcrValueFromBuffer(ParsableByteArray parsableByteArray, int i) {
int position = parsableByteArray.getPosition();
int limit = parsableByteArray.limit();
for (int i2 = limit - 188; i2 >= position; i2--) {
if (TsUtil.isStartOfTsPacket(parsableByteArray.getData(), position, limit, i2)) {
long readPcrFromPacket = TsUtil.readPcrFromPacket(parsableByteArray, i2, i);
if (readPcrFromPacket != C.TIME_UNSET) {
return readPcrFromPacket;
}
}
}
return C.TIME_UNSET;
}
}
Download file