aboutsummaryrefslogtreecommitdiff
path: root/sdk/android/api/org
diff options
context:
space:
mode:
Diffstat (limited to 'sdk/android/api/org')
-rw-r--r--sdk/android/api/org/webrtc/Camera2Enumerator.java10
-rw-r--r--sdk/android/api/org/webrtc/DataChannel.java1
-rw-r--r--sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java13
-rw-r--r--sdk/android/api/org/webrtc/LibaomAv1Decoder.java22
-rw-r--r--sdk/android/api/org/webrtc/LibaomAv1Encoder.java27
-rw-r--r--sdk/android/api/org/webrtc/PeerConnection.java9
-rw-r--r--sdk/android/api/org/webrtc/RTCStats.java1
-rw-r--r--sdk/android/api/org/webrtc/SoftwareVideoDecoderFactory.java25
-rw-r--r--sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java20
-rw-r--r--sdk/android/api/org/webrtc/VideoCodecInfo.java5
-rw-r--r--sdk/android/api/org/webrtc/VideoDecoderFactory.java13
-rw-r--r--sdk/android/api/org/webrtc/VideoEncoder.java2
-rw-r--r--sdk/android/api/org/webrtc/YuvConverter.java16
13 files changed, 123 insertions, 41 deletions
diff --git a/sdk/android/api/org/webrtc/Camera2Enumerator.java b/sdk/android/api/org/webrtc/Camera2Enumerator.java
index b32b3ad302..2c6bb57b68 100644
--- a/sdk/android/api/org/webrtc/Camera2Enumerator.java
+++ b/sdk/android/api/org/webrtc/Camera2Enumerator.java
@@ -55,7 +55,7 @@ public class Camera2Enumerator implements CameraEnumerator {
// catch statement with an Exception from a newer API, even if the code is never executed.
// https://code.google.com/p/android/issues/detail?id=209129
} catch (/* CameraAccessException */ AndroidException e) {
- Logging.e(TAG, "Camera access exception: " + e);
+ Logging.e(TAG, "Camera access exception", e);
return new String[] {};
}
}
@@ -97,7 +97,7 @@ public class Camera2Enumerator implements CameraEnumerator {
// catch statement with an Exception from a newer API, even if the code is never executed.
// https://code.google.com/p/android/issues/detail?id=209129
} catch (/* CameraAccessException */ AndroidException e) {
- Logging.e(TAG, "Camera access exception: " + e);
+ Logging.e(TAG, "Camera access exception", e);
return null;
}
}
@@ -123,8 +123,8 @@ public class Camera2Enumerator implements CameraEnumerator {
// On Android OS pre 4.4.2, a class will not load because of VerifyError if it contains a
// catch statement with an Exception from a newer API, even if the code is never executed.
// https://code.google.com/p/android/issues/detail?id=209129
- } catch (/* CameraAccessException */ AndroidException e) {
- Logging.e(TAG, "Camera access exception: " + e);
+ } catch (/* CameraAccessException */ AndroidException | RuntimeException e) {
+ Logging.e(TAG, "Failed to check if camera2 is supported", e);
return false;
}
return true;
@@ -186,7 +186,7 @@ public class Camera2Enumerator implements CameraEnumerator {
try {
cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId);
} catch (Exception ex) {
- Logging.e(TAG, "getCameraCharacteristics(): " + ex);
+ Logging.e(TAG, "getCameraCharacteristics()", ex);
return new ArrayList<CaptureFormat>();
}
diff --git a/sdk/android/api/org/webrtc/DataChannel.java b/sdk/android/api/org/webrtc/DataChannel.java
index f51dab97af..bcbf6f093f 100644
--- a/sdk/android/api/org/webrtc/DataChannel.java
+++ b/sdk/android/api/org/webrtc/DataChannel.java
@@ -123,6 +123,7 @@ public class DataChannel {
public void unregisterObserver() {
checkDataChannelExists();
nativeUnregisterObserver(nativeObserver);
+ nativeObserver = 0;
}
public String label() {
diff --git a/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java b/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java
index 8fe8b36909..c9831c1843 100644
--- a/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java
+++ b/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java
@@ -94,7 +94,7 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
return null;
}
- VideoCodecMimeType type = VideoCodecMimeType.valueOf(input.name);
+ VideoCodecMimeType type = VideoCodecMimeType.fromSdpCodecName(input.getName());
MediaCodecInfo info = findCodecForType(type);
if (info == null) {
@@ -137,12 +137,12 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
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();
+ String name = type.toSdpCodecName();
// TODO(sakal): Always add H264 HP once WebRTC correctly removes codecs that are not
// supported by the decoder.
if (type == VideoCodecMimeType.H264 && isH264HighProfileSupported(codec)) {
@@ -202,6 +202,8 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
return isHardwareSupportedInCurrentSdkVp9(info);
case H264:
return isHardwareSupportedInCurrentSdkH264(info);
+ case AV1:
+ return false;
}
return false;
}
@@ -248,6 +250,7 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
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 0000000000..609203fe3f
--- /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 0000000000..26648c589e
--- /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/PeerConnection.java b/sdk/android/api/org/webrtc/PeerConnection.java
index 38d2d38deb..67705ba3d5 100644
--- a/sdk/android/api/org/webrtc/PeerConnection.java
+++ b/sdk/android/api/org/webrtc/PeerConnection.java
@@ -141,7 +141,14 @@ public class PeerConnection {
* Triggered when a new track is signaled by the remote peer, as a result of
* setRemoteDescription.
*/
- @CalledByNative("Observer") void onAddTrack(RtpReceiver receiver, MediaStream[] mediaStreams);
+ @CalledByNative("Observer")
+ default void onAddTrack(RtpReceiver receiver, MediaStream[] mediaStreams){};
+
+ /**
+ * Triggered when a previously added remote track is removed by the remote
+ * peer, as a result of setRemoteDescription.
+ */
+ @CalledByNative("Observer") default void onRemoveTrack(RtpReceiver receiver){};
/**
* Triggered when the signaling from SetRemoteDescription indicates that a transceiver
diff --git a/sdk/android/api/org/webrtc/RTCStats.java b/sdk/android/api/org/webrtc/RTCStats.java
index 7ad7634c82..573d95300f 100644
--- a/sdk/android/api/org/webrtc/RTCStats.java
+++ b/sdk/android/api/org/webrtc/RTCStats.java
@@ -62,6 +62,7 @@ public class RTCStats {
* - Double
* - String
* - The array form of any of the above (e.g., Integer[])
+ * - Map of String keys to BigInteger / Double values
*/
public Map<String, Object> getMembers() {
return members;
diff --git a/sdk/android/api/org/webrtc/SoftwareVideoDecoderFactory.java b/sdk/android/api/org/webrtc/SoftwareVideoDecoderFactory.java
index 7abe3505a6..c59db3b47b 100644
--- a/sdk/android/api/org/webrtc/SoftwareVideoDecoderFactory.java
+++ b/sdk/android/api/org/webrtc/SoftwareVideoDecoderFactory.java
@@ -16,22 +16,22 @@ import java.util.HashMap;
import java.util.List;
public class SoftwareVideoDecoderFactory implements VideoDecoderFactory {
- @Deprecated
@Nullable
@Override
- public VideoDecoder createDecoder(String codecType) {
- return createDecoder(new VideoCodecInfo(codecType, new HashMap<>()));
- }
+ public VideoDecoder createDecoder(VideoCodecInfo codecInfo) {
+ String codecName = codecInfo.getName();
- @Nullable
- @Override
- public VideoDecoder createDecoder(VideoCodecInfo codecType) {
- if (codecType.getName().equalsIgnoreCase("VP8")) {
+ if (codecName.equalsIgnoreCase(VideoCodecMimeType.VP8.toSdpCodecName())) {
return new LibvpxVp8Decoder();
}
- if (codecType.getName().equalsIgnoreCase("VP9") && LibvpxVp9Decoder.nativeIsSupported()) {
+ if (codecName.equalsIgnoreCase(VideoCodecMimeType.VP9.toSdpCodecName())
+ && LibvpxVp9Decoder.nativeIsSupported()) {
return new LibvpxVp9Decoder();
}
+ if (codecName.equalsIgnoreCase(VideoCodecMimeType.AV1.toSdpCodecName())
+ && LibaomAv1Decoder.nativeIsSupported()) {
+ return new LibaomAv1Decoder();
+ }
return null;
}
@@ -44,9 +44,12 @@ public class SoftwareVideoDecoderFactory implements VideoDecoderFactory {
static VideoCodecInfo[] supportedCodecs() {
List<VideoCodecInfo> codecs = new ArrayList<VideoCodecInfo>();
- codecs.add(new VideoCodecInfo("VP8", new HashMap<>()));
+ codecs.add(new VideoCodecInfo(VideoCodecMimeType.VP8.toSdpCodecName(), new HashMap<>()));
if (LibvpxVp9Decoder.nativeIsSupported()) {
- codecs.add(new VideoCodecInfo("VP9", new HashMap<>()));
+ codecs.add(new VideoCodecInfo(VideoCodecMimeType.VP9.toSdpCodecName(), new HashMap<>()));
+ }
+ if (LibaomAv1Decoder.nativeIsSupported()) {
+ codecs.add(new VideoCodecInfo(VideoCodecMimeType.AV1.toSdpCodecName(), 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 ed70d228ef..4de39dcdba 100644
--- a/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java
+++ b/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java
@@ -18,13 +18,20 @@ import java.util.List;
public class SoftwareVideoEncoderFactory implements VideoEncoderFactory {
@Nullable
@Override
- public VideoEncoder createEncoder(VideoCodecInfo info) {
- if (info.name.equalsIgnoreCase("VP8")) {
+ public VideoEncoder createEncoder(VideoCodecInfo codecInfo) {
+ String codecName = codecInfo.getName();
+
+ if (codecName.equalsIgnoreCase(VideoCodecMimeType.VP8.toSdpCodecName())) {
return new LibvpxVp8Encoder();
}
- if (info.name.equalsIgnoreCase("VP9") && LibvpxVp9Encoder.nativeIsSupported()) {
+ if (codecName.equalsIgnoreCase(VideoCodecMimeType.VP9.toSdpCodecName())
+ && LibvpxVp9Encoder.nativeIsSupported()) {
return new LibvpxVp9Encoder();
}
+ if (codecName.equalsIgnoreCase(VideoCodecMimeType.AV1.toSdpCodecName())
+ && LibaomAv1Encoder.nativeIsSupported()) {
+ return new LibaomAv1Encoder();
+ }
return null;
}
@@ -37,9 +44,12 @@ public class SoftwareVideoEncoderFactory implements VideoEncoderFactory {
static VideoCodecInfo[] supportedCodecs() {
List<VideoCodecInfo> codecs = new ArrayList<VideoCodecInfo>();
- codecs.add(new VideoCodecInfo("VP8", new HashMap<>()));
+ codecs.add(new VideoCodecInfo(VideoCodecMimeType.VP8.toSdpCodecName(), new HashMap<>()));
if (LibvpxVp9Encoder.nativeIsSupported()) {
- codecs.add(new VideoCodecInfo("VP9", new HashMap<>()));
+ codecs.add(new VideoCodecInfo(VideoCodecMimeType.VP9.toSdpCodecName(), new HashMap<>()));
+ }
+ if (LibaomAv1Encoder.nativeIsSupported()) {
+ codecs.add(new VideoCodecInfo(VideoCodecMimeType.AV1.toSdpCodecName(), new HashMap<>()));
}
return codecs.toArray(new VideoCodecInfo[codecs.size()]);
diff --git a/sdk/android/api/org/webrtc/VideoCodecInfo.java b/sdk/android/api/org/webrtc/VideoCodecInfo.java
index 8dd9295fd7..e11782dedd 100644
--- a/sdk/android/api/org/webrtc/VideoCodecInfo.java
+++ b/sdk/android/api/org/webrtc/VideoCodecInfo.java
@@ -69,6 +69,11 @@ public class VideoCodecInfo {
return Arrays.hashCode(values);
}
+ @Override
+ public String toString() {
+ return "VideoCodec{" + name + " " + params + "}";
+ }
+
@CalledByNative
String getName() {
return name;
diff --git a/sdk/android/api/org/webrtc/VideoDecoderFactory.java b/sdk/android/api/org/webrtc/VideoDecoderFactory.java
index 2dd09670bd..3f0168f23e 100644
--- a/sdk/android/api/org/webrtc/VideoDecoderFactory.java
+++ b/sdk/android/api/org/webrtc/VideoDecoderFactory.java
@@ -18,18 +18,7 @@ public interface VideoDecoderFactory {
* Creates a VideoDecoder for the given codec. Supports the same codecs supported by
* VideoEncoderFactory.
*/
- @Deprecated
- @Nullable
- default VideoDecoder createDecoder(String codecType) {
- throw new UnsupportedOperationException("Deprecated and not implemented.");
- }
-
- /** Creates a decoder for the given video codec. */
- @Nullable
- @CalledByNative
- default VideoDecoder createDecoder(VideoCodecInfo info) {
- return createDecoder(info.getName());
- }
+ @Nullable @CalledByNative VideoDecoder createDecoder(VideoCodecInfo info);
/**
* Enumerates the list of supported video codecs.
diff --git a/sdk/android/api/org/webrtc/VideoEncoder.java b/sdk/android/api/org/webrtc/VideoEncoder.java
index cb8eb81767..460428192d 100644
--- a/sdk/android/api/org/webrtc/VideoEncoder.java
+++ b/sdk/android/api/org/webrtc/VideoEncoder.java
@@ -86,6 +86,8 @@ public interface VideoEncoder {
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.
diff --git a/sdk/android/api/org/webrtc/YuvConverter.java b/sdk/android/api/org/webrtc/YuvConverter.java
index 0e2d5055f7..9c00678900 100644
--- a/sdk/android/api/org/webrtc/YuvConverter.java
+++ b/sdk/android/api/org/webrtc/YuvConverter.java
@@ -12,6 +12,8 @@ package org.webrtc;
import android.graphics.Matrix;
import android.opengl.GLES20;
+import android.opengl.GLException;
+import android.support.annotation.Nullable;
import java.nio.ByteBuffer;
import org.webrtc.VideoFrame.I420Buffer;
import org.webrtc.VideoFrame.TextureBuffer;
@@ -20,7 +22,9 @@ import org.webrtc.VideoFrame.TextureBuffer;
* Class for converting OES textures to a YUV ByteBuffer. It can be constructed on any thread, but
* should only be operated from a single thread with an active EGL context.
*/
-public class YuvConverter {
+public final class YuvConverter {
+ private static final String TAG = "YuvConverter";
+
private static final String FRAGMENT_SHADER =
// Difference in texture coordinate corresponding to one
// sub-pixel in the x direction.
@@ -122,9 +126,17 @@ public class YuvConverter {
}
/** Converts the texture buffer to I420. */
+ @Nullable
public I420Buffer convert(TextureBuffer inputTextureBuffer) {
- threadChecker.checkIsOnValidThread();
+ try {
+ return convertInternal(inputTextureBuffer);
+ } catch (GLException e) {
+ Logging.w(TAG, "Failed to convert TextureBuffer", e);
+ }
+ return null;
+ }
+ private I420Buffer convertInternal(TextureBuffer inputTextureBuffer) {
TextureBuffer preparedBuffer = (TextureBuffer) videoFrameDrawer.prepareBufferForViewportSize(
inputTextureBuffer, inputTextureBuffer.getWidth(), inputTextureBuffer.getHeight());