- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
147 lines
5.8 KiB
Java
147 lines
5.8 KiB
Java
package com.mbridge.msdk.playercommon.exoplayer2.metadata;
|
|
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import android.os.Message;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlaybackException;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.Format;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.FormatHolder;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
|
|
import java.util.Arrays;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public final class MetadataRenderer extends BaseRenderer implements Handler.Callback {
|
|
private static final int MAX_PENDING_METADATA_COUNT = 5;
|
|
private static final int MSG_INVOKE_RENDERER = 0;
|
|
private final MetadataInputBuffer buffer;
|
|
private MetadataDecoder decoder;
|
|
private final MetadataDecoderFactory decoderFactory;
|
|
private final FormatHolder formatHolder;
|
|
private boolean inputStreamEnded;
|
|
private final MetadataOutput output;
|
|
private final Handler outputHandler;
|
|
private final Metadata[] pendingMetadata;
|
|
private int pendingMetadataCount;
|
|
private int pendingMetadataIndex;
|
|
private final long[] pendingMetadataTimestamps;
|
|
|
|
@Deprecated
|
|
public interface Output extends MetadataOutput {
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.Renderer
|
|
public final boolean isEnded() {
|
|
return this.inputStreamEnded;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.Renderer
|
|
public final boolean isReady() {
|
|
return true;
|
|
}
|
|
|
|
public MetadataRenderer(MetadataOutput metadataOutput, Looper looper) {
|
|
this(metadataOutput, looper, MetadataDecoderFactory.DEFAULT);
|
|
}
|
|
|
|
public MetadataRenderer(MetadataOutput metadataOutput, Looper looper, MetadataDecoderFactory metadataDecoderFactory) {
|
|
super(4);
|
|
this.output = (MetadataOutput) Assertions.checkNotNull(metadataOutput);
|
|
this.outputHandler = looper == null ? null : new Handler(looper, this);
|
|
this.decoderFactory = (MetadataDecoderFactory) Assertions.checkNotNull(metadataDecoderFactory);
|
|
this.formatHolder = new FormatHolder();
|
|
this.buffer = new MetadataInputBuffer();
|
|
this.pendingMetadata = new Metadata[5];
|
|
this.pendingMetadataTimestamps = new long[5];
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.RendererCapabilities
|
|
public final int supportsFormat(Format format) {
|
|
if (this.decoderFactory.supportsFormat(format)) {
|
|
return BaseRenderer.supportsFormatDrm(null, format.drmInitData) ? 4 : 2;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
|
|
public final void onStreamChanged(Format[] formatArr, long j) throws ExoPlaybackException {
|
|
this.decoder = this.decoderFactory.createDecoder(formatArr[0]);
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
|
|
public final void onPositionReset(long j, boolean z) {
|
|
flushPendingMetadata();
|
|
this.inputStreamEnded = false;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.Renderer
|
|
public final void render(long j, long j2) throws ExoPlaybackException {
|
|
if (!this.inputStreamEnded && this.pendingMetadataCount < 5) {
|
|
this.buffer.clear();
|
|
if (readSource(this.formatHolder, this.buffer, false) == -4) {
|
|
if (this.buffer.isEndOfStream()) {
|
|
this.inputStreamEnded = true;
|
|
} else if (!this.buffer.isDecodeOnly()) {
|
|
MetadataInputBuffer metadataInputBuffer = this.buffer;
|
|
metadataInputBuffer.subsampleOffsetUs = this.formatHolder.format.subsampleOffsetUs;
|
|
metadataInputBuffer.flip();
|
|
try {
|
|
int i = (this.pendingMetadataIndex + this.pendingMetadataCount) % 5;
|
|
this.pendingMetadata[i] = this.decoder.decode(this.buffer);
|
|
this.pendingMetadataTimestamps[i] = this.buffer.timeUs;
|
|
this.pendingMetadataCount++;
|
|
} catch (MetadataDecoderException e) {
|
|
throw ExoPlaybackException.createForRenderer(e, getIndex());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (this.pendingMetadataCount > 0) {
|
|
long[] jArr = this.pendingMetadataTimestamps;
|
|
int i2 = this.pendingMetadataIndex;
|
|
if (jArr[i2] <= j) {
|
|
invokeRenderer(this.pendingMetadata[i2]);
|
|
Metadata[] metadataArr = this.pendingMetadata;
|
|
int i3 = this.pendingMetadataIndex;
|
|
metadataArr[i3] = null;
|
|
this.pendingMetadataIndex = (i3 + 1) % 5;
|
|
this.pendingMetadataCount--;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
|
|
public final void onDisabled() {
|
|
flushPendingMetadata();
|
|
this.decoder = null;
|
|
}
|
|
|
|
private void invokeRenderer(Metadata metadata) {
|
|
Handler handler = this.outputHandler;
|
|
if (handler != null) {
|
|
handler.obtainMessage(0, metadata).sendToTarget();
|
|
} else {
|
|
invokeRendererInternal(metadata);
|
|
}
|
|
}
|
|
|
|
private void flushPendingMetadata() {
|
|
Arrays.fill(this.pendingMetadata, (Object) null);
|
|
this.pendingMetadataIndex = 0;
|
|
this.pendingMetadataCount = 0;
|
|
}
|
|
|
|
@Override // android.os.Handler.Callback
|
|
public final boolean handleMessage(Message message) {
|
|
if (message.what == 0) {
|
|
invokeRendererInternal((Metadata) message.obj);
|
|
return true;
|
|
}
|
|
throw new IllegalStateException();
|
|
}
|
|
|
|
private void invokeRendererInternal(Metadata metadata) {
|
|
this.output.onMetadata(metadata);
|
|
}
|
|
}
|