From 3f615040c033a37f81b1d73605cd1f7d420b47b5 Mon Sep 17 00:00:00 2001 From: claincly Date: Fri, 4 Mar 2022 17:15:16 +0000 Subject: [PATCH] Add method to disable passthrough. PiperOrigin-RevId: 432461547 --- .../com/google/android/exoplayer2/transformer/Codec.java | 5 +++++ .../exoplayer2/transformer/TransformerVideoRenderer.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Codec.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Codec.java index 8c1c27f4843..8b60eb20e5e 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Codec.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Codec.java @@ -104,6 +104,11 @@ Codec createForAudioEncoding(Format format, List allowedMimeTypes) */ Codec createForVideoEncoding(Format format, List allowedMimeTypes) throws TransformationException; + + /** Returns whether the video needs to be encoded because of encoder specific configuration. */ + default boolean videoNeedsEncoding() { + return false; + } } /** diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerVideoRenderer.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerVideoRenderer.java index 4e05bf91317..4c064b44eb8 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerVideoRenderer.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerVideoRenderer.java @@ -99,6 +99,9 @@ protected boolean ensureConfigured() throws TransformationException { } private boolean shouldPassthrough(Format inputFormat) { + if (encoderFactory.videoNeedsEncoding()) { + return false; + } if (transformationRequest.enableHdrEditing) { return false; }