Require 16x16 alignment when using HardwareVideoEncoder for encoding.
It seems the Android CTS tests only verify that 16x16 aligned resolutions
are supported.
This change checks the validity of input frame's size when initialing
or encoding processes are about to start using H/W MediaCodec.
This change has additional APIs to retrieve
|requested_resolution_alignment| and |apply_alignment_to_all_simulcast_layers|
from JAVA VideoEncoder class and its inherited classes. HardwareVideoEncoder
using MediaCodec has values of 16 and true for above variables.
Bug: webrtc:13089
Change-Id: I0c4ebf94eb36da29c2e384a3edf85b82e779b7f9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/229460
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35169}
diff --git a/sdk/android/api/org/webrtc/VideoEncoder.java b/sdk/android/api/org/webrtc/VideoEncoder.java
index 89a9bfd..0d8cf83 100644
--- a/sdk/android/api/org/webrtc/VideoEncoder.java
+++ b/sdk/android/api/org/webrtc/VideoEncoder.java
@@ -258,6 +258,39 @@
}
}
+ /**
+ * Metadata about the Encoder.
+ */
+ public class EncoderInfo {
+ /**
+ * The width and height of the incoming video frames should be divisible by
+ * |requested_resolution_alignment|
+ */
+ public final int requestedResolutionAlignment;
+
+ /**
+ * Same as above but if true, each simulcast layer should also be divisible by
+ * |requested_resolution_alignment|.
+ */
+ public final boolean applyAlignmentToAllSimulcastLayers;
+
+ public EncoderInfo(
+ int requestedResolutionAlignment, boolean applyAlignmentToAllSimulcastLayers) {
+ this.requestedResolutionAlignment = requestedResolutionAlignment;
+ this.applyAlignmentToAllSimulcastLayers = applyAlignmentToAllSimulcastLayers;
+ }
+
+ @CalledByNative("EncoderInfo")
+ public int getRequestedResolutionAlignment() {
+ return requestedResolutionAlignment;
+ }
+
+ @CalledByNative("EncoderInfo")
+ public boolean getApplyAlignmentToAllSimulcastLayers() {
+ return applyAlignmentToAllSimulcastLayers;
+ }
+ }
+
public interface Callback {
/**
* Old encoders assume that the byte buffer held by `frame` is not accessed after the call to
@@ -343,4 +376,10 @@
* called from arbitrary thread.
*/
@CalledByNative String getImplementationName();
+
+ @CalledByNative
+ default EncoderInfo getEncoderInfo() {
+ return new EncoderInfo(
+ /* requestedResolutionAlignment= */ 1, /* applyAlignmentToAllSimulcastLayers= */ false);
+ }
}