Commit 08c882a6 by olly Committed by bachinger

Trigger reconfiguration on newly obtained MediaCodecAdapters

Add the `needsReconfiguration` API on the `MediaCodecAdapter` interface so that `MediaCodecRenderer` can reconfigure the `MediaCodec` in case a `MediaCodecAdapter` needs to be reconfigured immediately after being obtained from the `MediaCodecAdapter.Factory`.

PiperOrigin-RevId: 376944334
parent 2fb61b8a
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
* Fix gradle config to allow specifying a relative path for * Fix gradle config to allow specifying a relative path for
`exoplayerRoot` when [depending on ExoPlayer locally](README.md#locally) `exoplayerRoot` when [depending on ExoPlayer locally](README.md#locally)
([#8927](https://github.com/google/ExoPlayer/issues/8927)). ([#8927](https://github.com/google/ExoPlayer/issues/8927)).
* Add `needsReconfiguration` API to the `MediaCodecAdapter` interface.
* Update `MediaItem.Builder` javadoc to discourage calling setters that * Update `MediaItem.Builder` javadoc to discourage calling setters that
will be (currently) ignored if another setter is not also called. will be (currently) ignored if another setter is not also called.
* Extractors: * Extractors:
......
...@@ -185,6 +185,11 @@ import java.nio.ByteBuffer; ...@@ -185,6 +185,11 @@ import java.nio.ByteBuffer;
} }
@Override @Override
public boolean needsReconfiguration() {
return false;
}
@Override
public void queueInputBuffer( public void queueInputBuffer(
int index, int offset, int size, long presentationTimeUs, int flags) { int index, int offset, int size, long presentationTimeUs, int flags) {
bufferEnqueuer.queueInputBuffer(index, offset, size, presentationTimeUs, flags); bufferEnqueuer.queueInputBuffer(index, offset, size, presentationTimeUs, flags);
......
...@@ -214,4 +214,7 @@ public interface MediaCodecAdapter { ...@@ -214,4 +214,7 @@ public interface MediaCodecAdapter {
* @see MediaCodec#setVideoScalingMode(int) * @see MediaCodec#setVideoScalingMode(int)
*/ */
void setVideoScalingMode(@C.VideoScalingMode int scalingMode); void setVideoScalingMode(@C.VideoScalingMode int scalingMode);
/** Whether the adapter needs to be reconfigured before it is used. */
boolean needsReconfiguration();
} }
...@@ -1141,6 +1141,12 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -1141,6 +1141,12 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
codecNeedsMonoChannelCountWorkaround(codecName, codecInputFormat); codecNeedsMonoChannelCountWorkaround(codecName, codecInputFormat);
codecNeedsEosPropagation = codecNeedsEosPropagation =
codecNeedsEosPropagationWorkaround(codecInfo) || getCodecNeedsEosPropagation(); codecNeedsEosPropagationWorkaround(codecInfo) || getCodecNeedsEosPropagation();
if (codecAdapter.needsReconfiguration()) {
this.codecReconfigured = true;
this.codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING;
this.codecNeedsAdaptationWorkaroundBuffer =
codecAdaptationWorkaroundMode != ADAPTATION_WORKAROUND_MODE_NEVER;
}
if ("c2.android.mp3.decoder".equals(codecInfo.name)) { if ("c2.android.mp3.decoder".equals(codecInfo.name)) {
c2Mp3TimestampTracker = new C2Mp3TimestampTracker(); c2Mp3TimestampTracker = new C2Mp3TimestampTracker();
} }
......
...@@ -89,6 +89,11 @@ public class SynchronousMediaCodecAdapter implements MediaCodecAdapter { ...@@ -89,6 +89,11 @@ public class SynchronousMediaCodecAdapter implements MediaCodecAdapter {
} }
@Override @Override
public boolean needsReconfiguration() {
return false;
}
@Override
public int dequeueInputBufferIndex() { public int dequeueInputBufferIndex() {
return codec.dequeueInputBuffer(0); return codec.dequeueInputBuffer(0);
} }
......
...@@ -278,6 +278,11 @@ public class CapturingRenderersFactory implements RenderersFactory, Dumper.Dumpa ...@@ -278,6 +278,11 @@ public class CapturingRenderersFactory implements RenderersFactory, Dumper.Dumpa
dumper.endBlock(); dumper.endBlock();
} }
@Override
public boolean needsReconfiguration() {
return false;
}
private static byte[] peekBytes(ByteBuffer buffer, int offset, int size) { private static byte[] peekBytes(ByteBuffer buffer, int offset, int size) {
int originalPosition = buffer.position(); int originalPosition = buffer.position();
buffer.position(offset); buffer.position(offset);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment