Remove unnecessary runtime API-level checks.
APIs below level 16 are not supported by WebRTC. BUG=webrtc:7549 TBR=henrika@webrtc.org Review-Url: https://codereview.webrtc.org/2848323003 Cr-Commit-Position: refs/heads/master@{#17980}
This commit is contained in:
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
package org.appspot.apprtc;
|
package org.appspot.apprtc;
|
||||||
|
|
||||||
import org.appspot.apprtc.util.AppRTCUtils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.Sensor;
|
import android.hardware.Sensor;
|
||||||
import android.hardware.SensorEvent;
|
import android.hardware.SensorEvent;
|
||||||
@ -19,7 +17,7 @@ import android.hardware.SensorEventListener;
|
|||||||
import android.hardware.SensorManager;
|
import android.hardware.SensorManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import org.appspot.apprtc.util.AppRTCUtils;
|
||||||
import org.webrtc.ThreadUtils;
|
import org.webrtc.ThreadUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,10 +147,7 @@ public class AppRTCProximitySensor implements SensorEventListener {
|
|||||||
info.append(", power: ").append(proximitySensor.getPower());
|
info.append(", power: ").append(proximitySensor.getPower());
|
||||||
info.append(", resolution: ").append(proximitySensor.getResolution());
|
info.append(", resolution: ").append(proximitySensor.getResolution());
|
||||||
info.append(", max range: ").append(proximitySensor.getMaximumRange());
|
info.append(", max range: ").append(proximitySensor.getMaximumRange());
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
|
info.append(", min delay: ").append(proximitySensor.getMinDelay());
|
||||||
// Added in API level 9.
|
|
||||||
info.append(", min delay: ").append(proximitySensor.getMinDelay());
|
|
||||||
}
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
|
||||||
// Added in API level 20.
|
// Added in API level 20.
|
||||||
info.append(", type: ").append(proximitySensor.getStringType());
|
info.append(", type: ").append(proximitySensor.getStringType());
|
||||||
|
|||||||
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
package org.webrtc.voiceengine;
|
package org.webrtc.voiceengine;
|
||||||
|
|
||||||
import org.webrtc.Logging;
|
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.media.audiofx.AcousticEchoCanceler;
|
import android.media.audiofx.AcousticEchoCanceler;
|
||||||
import android.media.audiofx.AudioEffect;
|
import android.media.audiofx.AudioEffect;
|
||||||
@ -19,9 +17,9 @@ import android.media.audiofx.AudioEffect.Descriptor;
|
|||||||
import android.media.audiofx.AutomaticGainControl;
|
import android.media.audiofx.AutomaticGainControl;
|
||||||
import android.media.audiofx.NoiseSuppressor;
|
import android.media.audiofx.NoiseSuppressor;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import org.webrtc.Logging;
|
||||||
|
|
||||||
// This class wraps control of three different platform effects. Supported
|
// This class wraps control of three different platform effects. Supported
|
||||||
// effects are: AcousticEchoCanceler (AEC) and NoiseSuppressor (NS).
|
// effects are: AcousticEchoCanceler (AEC) and NoiseSuppressor (NS).
|
||||||
@ -63,7 +61,7 @@ class WebRtcAudioEffects {
|
|||||||
// Note: we're using isAcousticEchoCancelerEffectAvailable() instead of
|
// Note: we're using isAcousticEchoCancelerEffectAvailable() instead of
|
||||||
// AcousticEchoCanceler.isAvailable() to avoid the expensive getEffects()
|
// AcousticEchoCanceler.isAvailable() to avoid the expensive getEffects()
|
||||||
// OS API call.
|
// OS API call.
|
||||||
return WebRtcAudioUtils.runningOnJellyBeanOrHigher() && isAcousticEchoCancelerEffectAvailable();
|
return isAcousticEchoCancelerEffectAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if the device implements Noise Suppression (NS).
|
// Checks if the device implements Noise Suppression (NS).
|
||||||
@ -72,7 +70,7 @@ class WebRtcAudioEffects {
|
|||||||
// Note: we're using isNoiseSuppressorEffectAvailable() instead of
|
// Note: we're using isNoiseSuppressorEffectAvailable() instead of
|
||||||
// NoiseSuppressor.isAvailable() to avoid the expensive getEffects()
|
// NoiseSuppressor.isAvailable() to avoid the expensive getEffects()
|
||||||
// OS API call.
|
// OS API call.
|
||||||
return WebRtcAudioUtils.runningOnJellyBeanOrHigher() && isNoiseSuppressorEffectAvailable();
|
return isNoiseSuppressorEffectAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the device is blacklisted for HW AEC usage.
|
// Returns true if the device is blacklisted for HW AEC usage.
|
||||||
@ -153,11 +151,6 @@ class WebRtcAudioEffects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static WebRtcAudioEffects create() {
|
static WebRtcAudioEffects create() {
|
||||||
// Return null if VoIP effects (AEC, AGC and NS) are not supported.
|
|
||||||
if (!WebRtcAudioUtils.runningOnJellyBeanOrHigher()) {
|
|
||||||
Logging.w(TAG, "API level 16 or higher is required!");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new WebRtcAudioEffects();
|
return new WebRtcAudioEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -229,8 +229,7 @@ public class WebRtcAudioManager {
|
|||||||
|
|
||||||
// Returns true if low-latency audio output is supported.
|
// Returns true if low-latency audio output is supported.
|
||||||
private boolean isLowLatencyOutputSupported() {
|
private boolean isLowLatencyOutputSupported() {
|
||||||
return isOpenSLESSupported()
|
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY);
|
||||||
&& context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if low-latency audio input is supported.
|
// Returns true if low-latency audio input is supported.
|
||||||
@ -341,12 +340,6 @@ public class WebRtcAudioManager {
|
|||||||
/ bytesPerFrame;
|
/ bytesPerFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if OpenSL ES audio is supported.
|
|
||||||
private static boolean isOpenSLESSupported() {
|
|
||||||
// Check for API level 9 or higher, to confirm use of OpenSL ES.
|
|
||||||
return WebRtcAudioUtils.runningOnGingerBreadOrHigher();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper method which throws an exception when an assertion has failed.
|
// Helper method which throws an exception when an assertion has failed.
|
||||||
private static void assertTrue(boolean condition) {
|
private static void assertTrue(boolean condition) {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
|
|||||||
@ -10,16 +10,14 @@
|
|||||||
|
|
||||||
package org.webrtc.voiceengine;
|
package org.webrtc.voiceengine;
|
||||||
|
|
||||||
import org.webrtc.Logging;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
|
|
||||||
import java.lang.Thread;
|
import java.lang.Thread;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.webrtc.Logging;
|
||||||
|
|
||||||
public final class WebRtcAudioUtils {
|
public final class WebRtcAudioUtils {
|
||||||
private static final String TAG = "WebRtcAudioUtils";
|
private static final String TAG = "WebRtcAudioUtils";
|
||||||
@ -129,16 +127,6 @@ public final class WebRtcAudioUtils {
|
|||||||
return Arrays.asList(WebRtcAudioUtils.BLACKLISTED_NS_MODELS);
|
return Arrays.asList(WebRtcAudioUtils.BLACKLISTED_NS_MODELS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean runningOnGingerBreadOrHigher() {
|
|
||||||
// November 2010: Android 2.3, API Level 9.
|
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean runningOnJellyBeanOrHigher() {
|
|
||||||
// June 2012: Android 4.1. API Level 16.
|
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean runningOnJellyBeanMR1OrHigher() {
|
public static boolean runningOnJellyBeanMR1OrHigher() {
|
||||||
// November 2012: Android 4.2. API Level 17.
|
// November 2012: Android 4.2. API Level 17.
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1;
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1;
|
||||||
|
|||||||
@ -17,7 +17,6 @@ import android.os.Build;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@ -259,9 +258,7 @@ public class SurfaceTextureHelper {
|
|||||||
|
|
||||||
final float[] transformMatrix = new float[16];
|
final float[] transformMatrix = new float[16];
|
||||||
surfaceTexture.getTransformMatrix(transformMatrix);
|
surfaceTexture.getTransformMatrix(transformMatrix);
|
||||||
final long timestampNs = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
final long timestampNs = surfaceTexture.getTimestamp();
|
||||||
? surfaceTexture.getTimestamp()
|
|
||||||
: TimeUnit.MILLISECONDS.toNanos(SystemClock.elapsedRealtime());
|
|
||||||
listener.onTextureFrameAvailable(oesTextureId, transformMatrix, timestampNs);
|
listener.onTextureFrameAvailable(oesTextureId, transformMatrix, timestampNs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user