Fix MCVR is not able to find FrameProcessor.Factory constructor.

The constructor is removed in 316a2ce0ee.

PiperOrigin-RevId: 526068585
This commit is contained in:
claincly 2023-04-21 18:04:30 +01:00 committed by Rohit Singh
parent 0bac4e24e4
commit bb0c4a468a

View File

@ -2315,12 +2315,12 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
private static final class VideoFrameProcessorAccessor {
private static @MonotonicNonNull Constructor<?>
scaleAndRotateTransformationBuilderConstructor;
private static @MonotonicNonNull Method setRotationMethod;
private static @MonotonicNonNull Method buildScaleAndRotateTransformationMethod;
private static @MonotonicNonNull Constructor<?> videoFrameProcessorFactoryConstructor;
private static @MonotonicNonNull Constructor<?> videoFrameProcessorFactoryBuilderConstructor;
private static @MonotonicNonNull Method buildVideoFrameProcessorFactoryMethod;
public static Effect createRotationEffect(float rotationDegrees) throws Exception {
prepare();
@ -2331,14 +2331,17 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
public static VideoFrameProcessor.Factory getFrameProcessorFactory() throws Exception {
prepare();
return (VideoFrameProcessor.Factory) videoFrameProcessorFactoryConstructor.newInstance();
Object builder = videoFrameProcessorFactoryBuilderConstructor.newInstance();
return (VideoFrameProcessor.Factory)
checkNotNull(buildVideoFrameProcessorFactoryMethod.invoke(builder));
}
@EnsuresNonNull({
"ScaleAndRotateEffectBuilder",
"SetRotationMethod",
"SetRotationMethod",
"VideoFrameProcessorFactoryClass"
"scaleAndRotateTransformationBuilderConstructor",
"setRotationMethod",
"buildScaleAndRotateTransformationMethod",
"videoFrameProcessorFactoryBuilderConstructor",
"buildVideoFrameProcessorFactoryMethod"
})
private static void prepare() throws Exception {
if (scaleAndRotateTransformationBuilderConstructor == null
@ -2353,10 +2356,14 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
buildScaleAndRotateTransformationMethod =
scaleAndRotateTransformationBuilderClass.getMethod("build");
}
if (videoFrameProcessorFactoryConstructor == null) {
videoFrameProcessorFactoryConstructor =
Class.forName("androidx.media3.effect.DefaultVideoFrameProcessor$Factory")
.getConstructor();
if (videoFrameProcessorFactoryBuilderConstructor == null
|| buildVideoFrameProcessorFactoryMethod == null) {
Class<?> videoFrameProcessorFactoryBuilderClass =
Class.forName("androidx.media3.effect.DefaultVideoFrameProcessor$Factory$Builder");
videoFrameProcessorFactoryBuilderConstructor =
videoFrameProcessorFactoryBuilderClass.getConstructor();
buildVideoFrameProcessorFactoryMethod =
videoFrameProcessorFactoryBuilderClass.getMethod("build");
}
}
}