Remove checks for SDK <= 21

WebRTC’s minSdk is 21, so all those checks are dead code.

Change-Id: I26497fd92259b66d9e5ac6afbb393adf4d904c77
Bug: webrtc:13780
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253124
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Linus Nilsson <lnilsson@webrtc.org>
Commit-Queue: Xavier Lepaul‎ <xalep@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36140}
This commit is contained in:
Xavier Lepaul
2022-03-07 10:23:23 +01:00
committed by WebRTC LUCI CQ
parent 7befe8e5e4
commit 0f50cc2849
27 changed files with 55 additions and 295 deletions

View File

@ -10,12 +10,10 @@
package org.webrtc;
import android.annotation.TargetApi;
import android.content.Context;
import android.hardware.camera2.CameraManager;
import androidx.annotation.Nullable;
@TargetApi(21)
public class Camera2Capturer extends CameraCapturer {
private final Context context;
@Nullable private final CameraManager cameraManager;

View File

@ -10,7 +10,6 @@
package org.webrtc;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
@ -30,7 +29,6 @@ import java.util.List;
import java.util.Map;
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
@TargetApi(21)
public class Camera2Enumerator implements CameraEnumerator {
private final static String TAG = "Camera2Enumerator";
private final static double NANO_SECONDS_PER_SECOND = 1.0e9;
@ -107,10 +105,6 @@ public class Camera2Enumerator implements CameraEnumerator {
* Checks if API is supported and all cameras have better than legacy support.
*/
public static boolean isSupported(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return false;
}
CameraManager cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
try {
String[] cameraIds = cameraManager.getCameraIdList();

View File

@ -147,13 +147,11 @@ public interface EglBase {
/**
* Create a new context with the specified config attributes, sharing data with `sharedContext`.
* If `sharedContext` is null, a root context is created. This function will try to create an EGL
* 1.4 context if possible, and an EGL 1.0 context otherwise.
* If `sharedContext` is null, a root EGL 1.4 context is created.
*/
public static EglBase create(@Nullable Context sharedContext, int[] configAttributes) {
if (sharedContext == null) {
return EglBase14Impl.isEGL14Supported() ? createEgl14(configAttributes)
: createEgl10(configAttributes);
return createEgl14(configAttributes);
} else if (sharedContext instanceof EglBase14.Context) {
return createEgl14((EglBase14.Context) sharedContext, configAttributes);
} else if (sharedContext instanceof EglBase10.Context) {

View File

@ -94,11 +94,6 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
@Nullable
@Override
public VideoEncoder createEncoder(VideoCodecInfo input) {
// HW encoding is not supported below Android Kitkat.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return null;
}
VideoCodecMimeType type = VideoCodecMimeType.valueOf(input.getName());
MediaCodecInfo info = findCodecForType(type);
@ -135,11 +130,6 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
@Override
public VideoCodecInfo[] getSupportedCodecs() {
// HW encoding is not supported below Android Kitkat.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return new VideoCodecInfo[0];
}
List<VideoCodecInfo> supportedCodecInfos = new ArrayList<VideoCodecInfo>();
// Generate a list of supported codecs in order of preference:
// VP8, VP9, H264 (high profile), H264 (baseline profile) and AV1.
@ -219,13 +209,12 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
private boolean isHardwareSupportedInCurrentSdkVp8(MediaCodecInfo info) {
String name = info.getName();
// QCOM Vp8 encoder is supported in KITKAT or later.
return (name.startsWith(QCOM_PREFIX) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
// QCOM Vp8 encoder is always supported.
return name.startsWith(QCOM_PREFIX)
// Exynos VP8 encoder is supported in M or later.
|| (name.startsWith(EXYNOS_PREFIX) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
// Intel Vp8 encoder is supported in LOLLIPOP or later, with the intel encoder enabled.
|| (name.startsWith(INTEL_PREFIX) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
&& enableIntelVp8Encoder);
// Intel Vp8 encoder is always supported, with the intel encoder enabled.
|| (name.startsWith(INTEL_PREFIX) && enableIntelVp8Encoder);
}
private boolean isHardwareSupportedInCurrentSdkVp9(MediaCodecInfo info) {
@ -241,11 +230,8 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
return false;
}
String name = info.getName();
// QCOM H264 encoder is supported in KITKAT or later.
return (name.startsWith(QCOM_PREFIX) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
// Exynos H264 encoder is supported in LOLLIPOP or later.
|| (name.startsWith(EXYNOS_PREFIX)
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
// QCOM and Exynos H264 encoders are always supported.
return name.startsWith(QCOM_PREFIX) || name.startsWith(EXYNOS_PREFIX);
}
private boolean isMediaCodecAllowed(MediaCodecInfo info) {
@ -257,14 +243,13 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
private int getForcedKeyFrameIntervalMs(VideoCodecMimeType type, String codecName) {
if (type == VideoCodecMimeType.VP8 && codecName.startsWith(QCOM_PREFIX)) {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP
|| Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return QCOM_VP8_KEY_FRAME_INTERVAL_ANDROID_L_MS;
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
return QCOM_VP8_KEY_FRAME_INTERVAL_ANDROID_M_MS;
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
return QCOM_VP8_KEY_FRAME_INTERVAL_ANDROID_N_MS;
}
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
return QCOM_VP8_KEY_FRAME_INTERVAL_ANDROID_M_MS;
}
return QCOM_VP8_KEY_FRAME_INTERVAL_ANDROID_N_MS;
}
// Other codecs don't need key frame forcing.
return 0;

View File

@ -10,7 +10,6 @@
package org.webrtc;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@ -31,10 +30,7 @@ import androidx.annotation.Nullable;
* place on the HandlerThread of the given {@code SurfaceTextureHelper}. When done with each frame,
* the native code returns the buffer to the {@code SurfaceTextureHelper} to be used for new
* frames. At any time, at most one frame is being processed.
*
* @note This class is only supported on Android Lollipop and above.
*/
@TargetApi(21)
public class ScreenCapturerAndroid implements VideoCapturer, VideoSink {
private static final int DISPLAY_FLAGS =
DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION;

View File

@ -198,7 +198,7 @@ public class SurfaceTextureHelper {
oesTextureId = GlUtil.generateTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES);
surfaceTexture = new SurfaceTexture(oesTextureId);
setOnFrameAvailableListener(surfaceTexture, (SurfaceTexture st) -> {
surfaceTexture.setOnFrameAvailableListener(st -> {
if (hasPendingTexture) {
Logging.d(TAG, "A frame is already pending, dropping frame.");
}
@ -208,20 +208,6 @@ public class SurfaceTextureHelper {
}, handler);
}
@TargetApi(21)
private static void setOnFrameAvailableListener(SurfaceTexture surfaceTexture,
SurfaceTexture.OnFrameAvailableListener listener, Handler handler) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
surfaceTexture.setOnFrameAvailableListener(listener, handler);
} else {
// The documentation states that the listener will be called on an arbitrary thread, but in
// pratice, it is always the thread on which the SurfaceTexture was constructed. There are
// assertions in place in case this ever changes. For API >= 21, we use the new API to
// explicitly specify the handler.
surfaceTexture.setOnFrameAvailableListener(listener);
}
}
/**
* Start to stream textures to the given `listener`. If you need to change listener, you need to
* call stopListening() first.