Reland "Expose AV1 encoder&decoder from Android SDK."
This is a reland of fedd5029c584e9dc1352434b62a30cd8af2889d8
Original change's description:
> Expose AV1 encoder&decoder from Android SDK.
>
> Bug: None
> Change-Id: Ie32be36da498d4bed2a3cf51aa6abc8838e42da1
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212024
> Reviewed-by: Xavier Lepaul <xalep@webrtc.org>
> Commit-Queue: Yura Yaroshevich <yura.yaroshevich@gmail.com>
> Cr-Commit-Position: refs/heads/master@{#33743}
Bug: None
Change-Id: Ibfc7b860bd2314cf997444c7ab0d94d2b186e576
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215586
Reviewed-by: Xavier Lepaul <xalep@webrtc.org>
Commit-Queue: Yura Yaroshevich <yura.yaroshevich@gmail.com>
Cr-Commit-Position: refs/heads/master@{#33882}
diff --git a/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java b/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java
index 8fe8b36..17ba76a 100644
--- a/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java
+++ b/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java
@@ -137,9 +137,9 @@
List<VideoCodecInfo> supportedCodecInfos = new ArrayList<VideoCodecInfo>();
// Generate a list of supported codecs in order of preference:
- // VP8, VP9, H264 (high profile), and H264 (baseline profile).
- for (VideoCodecMimeType type : new VideoCodecMimeType[] {
- VideoCodecMimeType.VP8, VideoCodecMimeType.VP9, VideoCodecMimeType.H264}) {
+ // VP8, VP9, H264 (high profile), H264 (baseline profile) and AV1.
+ for (VideoCodecMimeType type : new VideoCodecMimeType[] {VideoCodecMimeType.VP8,
+ VideoCodecMimeType.VP9, VideoCodecMimeType.H264, VideoCodecMimeType.AV1}) {
MediaCodecInfo codec = findCodecForType(type);
if (codec != null) {
String name = type.name();
@@ -202,6 +202,8 @@
return isHardwareSupportedInCurrentSdkVp9(info);
case H264:
return isHardwareSupportedInCurrentSdkH264(info);
+ case AV1:
+ return false;
}
return false;
}
@@ -248,6 +250,7 @@
switch (type) {
case VP8: // Fallthrough intended.
case VP9:
+ case AV1:
return 100;
case H264:
return 20;
diff --git a/sdk/android/api/org/webrtc/LibaomAv1Decoder.java b/sdk/android/api/org/webrtc/LibaomAv1Decoder.java
new file mode 100644
index 0000000..609203f
--- /dev/null
+++ b/sdk/android/api/org/webrtc/LibaomAv1Decoder.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+package org.webrtc;
+
+public class LibaomAv1Decoder extends WrappedNativeVideoDecoder {
+ @Override
+ public long createNativeVideoDecoder() {
+ return nativeCreateDecoder();
+ }
+
+ static native long nativeCreateDecoder();
+
+ static native boolean nativeIsSupported();
+}
diff --git a/sdk/android/api/org/webrtc/LibaomAv1Encoder.java b/sdk/android/api/org/webrtc/LibaomAv1Encoder.java
new file mode 100644
index 0000000..26648c5
--- /dev/null
+++ b/sdk/android/api/org/webrtc/LibaomAv1Encoder.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+package org.webrtc;
+
+public class LibaomAv1Encoder extends WrappedNativeVideoEncoder {
+ @Override
+ public long createNativeVideoEncoder() {
+ return nativeCreateEncoder();
+ }
+
+ static native long nativeCreateEncoder();
+
+ @Override
+ public boolean isHardwareEncoder() {
+ return false;
+ }
+
+ static native boolean nativeIsSupported();
+}
diff --git a/sdk/android/api/org/webrtc/SoftwareVideoDecoderFactory.java b/sdk/android/api/org/webrtc/SoftwareVideoDecoderFactory.java
index 7abe350..da11e87 100644
--- a/sdk/android/api/org/webrtc/SoftwareVideoDecoderFactory.java
+++ b/sdk/android/api/org/webrtc/SoftwareVideoDecoderFactory.java
@@ -32,6 +32,9 @@
if (codecType.getName().equalsIgnoreCase("VP9") && LibvpxVp9Decoder.nativeIsSupported()) {
return new LibvpxVp9Decoder();
}
+ if (codecType.getName().equalsIgnoreCase("AV1") && LibaomAv1Decoder.nativeIsSupported()) {
+ return new LibaomAv1Decoder();
+ }
return null;
}
@@ -48,6 +51,9 @@
if (LibvpxVp9Decoder.nativeIsSupported()) {
codecs.add(new VideoCodecInfo("VP9", new HashMap<>()));
}
+ if (LibaomAv1Decoder.nativeIsSupported()) {
+ codecs.add(new VideoCodecInfo("AV1", new HashMap<>()));
+ }
return codecs.toArray(new VideoCodecInfo[codecs.size()]);
}
diff --git a/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java b/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java
index ed70d22..528adab 100644
--- a/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java
+++ b/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java
@@ -25,6 +25,9 @@
if (info.name.equalsIgnoreCase("VP9") && LibvpxVp9Encoder.nativeIsSupported()) {
return new LibvpxVp9Encoder();
}
+ if (info.name.equalsIgnoreCase("AV1") && LibaomAv1Encoder.nativeIsSupported()) {
+ return new LibaomAv1Encoder();
+ }
return null;
}
@@ -41,6 +44,9 @@
if (LibvpxVp9Encoder.nativeIsSupported()) {
codecs.add(new VideoCodecInfo("VP9", new HashMap<>()));
}
+ if (LibaomAv1Encoder.nativeIsSupported()) {
+ codecs.add(new VideoCodecInfo("AV1", new HashMap<>()));
+ }
return codecs.toArray(new VideoCodecInfo[codecs.size()]);
}
diff --git a/sdk/android/api/org/webrtc/VideoEncoder.java b/sdk/android/api/org/webrtc/VideoEncoder.java
index cb8eb81..4604281 100644
--- a/sdk/android/api/org/webrtc/VideoEncoder.java
+++ b/sdk/android/api/org/webrtc/VideoEncoder.java
@@ -86,6 +86,8 @@
public class CodecSpecificInfoH264 extends CodecSpecificInfo {}
+ public class CodecSpecificInfoAV1 extends CodecSpecificInfo {}
+
/**
* Represents bitrate allocated for an encoder to produce frames. Bitrate can be divided between
* spatial and temporal layers.