diff --git a/library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java b/library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java index b9e3ad89a4..6e92122202 100644 --- a/library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java +++ b/library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java @@ -647,6 +647,7 @@ public abstract class MediaCodecTrackRenderer extends SampleSourceTrackRenderer inputIndex = -1; codecHasQueuedBuffers = true; codecReconfigurationState = RECONFIGURATION_STATE_NONE; + onQueuedInputBuffer(presentationTimeUs); } catch (CryptoException e) { notifyCryptoError(e); throw ExoPlaybackException.createForRenderer(e, getIndex()); @@ -733,6 +734,28 @@ public abstract class MediaCodecTrackRenderer extends SampleSourceTrackRenderer // Do nothing. } + /** + * Invoked when an input buffer is queued into the codec. + *

+ * The default implementation is a no-op. + * + * @param presentationTimeUs The timestamp associated with the input buffer. + */ + protected void onQueuedInputBuffer(long presentationTimeUs) { + // Do nothing. + } + + /** + * Invoked when an output buffer is successfully processed. + *

+ * The default implementation is a no-op. + * + * @param presentationTimeUs The timestamp associated with the output buffer. + */ + protected void onProcessedOutputBuffer(long presentationTimeUs) { + // Do nothing. + } + /** * Determines whether the existing {@link MediaCodec} should be reconfigured for a new format by * sending codec specific initialization data at the start of the next input buffer. If true is @@ -827,6 +850,7 @@ public abstract class MediaCodecTrackRenderer extends SampleSourceTrackRenderer int decodeOnlyIndex = getDecodeOnlyIndex(outputBufferInfo.presentationTimeUs); if (processOutputBuffer(positionUs, elapsedRealtimeUs, codec, outputBuffers[outputIndex], outputBufferInfo, outputIndex, decodeOnlyIndex != -1)) { + onProcessedOutputBuffer(outputBufferInfo.presentationTimeUs); if (decodeOnlyIndex != -1) { decodeOnlyPresentationTimestamps.remove(decodeOnlyIndex); }