Replace most usages of @TargetApi with @RequiresApi
We keep @TargetApi where the method is a safe no-op on older versions due to an in-line version check. PiperOrigin-RevId: 292878727
This commit is contained in:
parent
dd10d96a3f
commit
b6bd57ab12
@ -15,9 +15,9 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.ext.workmanager;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.work.Constraints;
|
||||
import androidx.work.Data;
|
||||
import androidx.work.ExistingWorkPolicy;
|
||||
@ -92,7 +92,7 @@ public final class WorkManagerScheduler implements Scheduler {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
@RequiresApi(23)
|
||||
private static void setRequiresDeviceIdle(Constraints.Builder builder) {
|
||||
builder.setRequiresDeviceIdle(true);
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.AudioFormat;
|
||||
@ -23,6 +22,7 @@ import android.media.AudioManager;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaFormat;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
@ -1047,7 +1047,7 @@ public final class C {
|
||||
*
|
||||
* @see AudioManager#generateAudioSessionId()
|
||||
*/
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
public static int generateAudioSessionIdV21(Context context) {
|
||||
return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE))
|
||||
.generateAudioSessionId();
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.decoder;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
|
||||
@ -111,7 +111,7 @@ public final class CryptoInfo {
|
||||
return getFrameworkCryptoInfo();
|
||||
}
|
||||
|
||||
@TargetApi(24)
|
||||
@RequiresApi(24)
|
||||
private static final class PatternHolderV24 {
|
||||
|
||||
private final android.media.MediaCodec.CryptoInfo frameworkCryptoInfo;
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.util;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
|
||||
|
||||
/**
|
||||
@ -49,12 +49,12 @@ public final class TraceUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(18)
|
||||
@RequiresApi(18)
|
||||
private static void beginSectionV18(String sectionName) {
|
||||
android.os.Trace.beginSection(sectionName);
|
||||
}
|
||||
|
||||
@TargetApi(18)
|
||||
@RequiresApi(18)
|
||||
private static void endSectionV18() {
|
||||
android.os.Trace.endSection();
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ import android.view.Display;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.WindowManager;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
@ -2058,14 +2059,14 @@ public final class Util {
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
@RequiresApi(23)
|
||||
private static void getDisplaySizeV23(Display display, Point outSize) {
|
||||
Display.Mode mode = display.getMode();
|
||||
outSize.x = mode.getPhysicalWidth();
|
||||
outSize.y = mode.getPhysicalHeight();
|
||||
}
|
||||
|
||||
@TargetApi(17)
|
||||
@RequiresApi(17)
|
||||
private static void getDisplaySizeV17(Display display, Point outSize) {
|
||||
display.getRealSize(outSize);
|
||||
}
|
||||
@ -2081,12 +2082,12 @@ public final class Util {
|
||||
: new String[] {getLocaleLanguageTag(config.locale)};
|
||||
}
|
||||
|
||||
@TargetApi(24)
|
||||
@RequiresApi(24)
|
||||
private static String[] getSystemLocalesV24(Configuration config) {
|
||||
return Util.split(config.getLocales().toLanguageTags(), ",");
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
private static String getLocaleLanguageTagV21(Locale locale) {
|
||||
return locale.toLanguageTag();
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.SurfaceTexture;
|
||||
@ -28,6 +27,7 @@ import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.TextureView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import com.google.android.exoplayer2.analytics.AnalyticsCollector;
|
||||
import com.google.android.exoplayer2.analytics.AnalyticsListener;
|
||||
@ -852,7 +852,7 @@ public class SimpleExoPlayer extends BasePlayer
|
||||
* @param params The {@link PlaybackParams}, or null to clear any previously set parameters.
|
||||
*/
|
||||
@Deprecated
|
||||
@TargetApi(23)
|
||||
@RequiresApi(23)
|
||||
public void setPlaybackParams(@Nullable PlaybackParams params) {
|
||||
PlaybackParameters playbackParameters;
|
||||
if (params != null) {
|
||||
|
@ -15,8 +15,8 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.audio;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
|
||||
@ -118,7 +118,7 @@ public final class AudioAttributes {
|
||||
*
|
||||
* <p>Field {@link AudioAttributes#allowedCapturePolicy} is ignored for API levels prior to 29.
|
||||
*/
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
public android.media.AudioAttributes getAudioAttributesV21() {
|
||||
if (audioAttributesV21 == null) {
|
||||
android.media.AudioAttributes.Builder builder =
|
||||
|
@ -16,7 +16,6 @@
|
||||
package com.google.android.exoplayer2.audio;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
@ -29,7 +28,6 @@ import com.google.android.exoplayer2.util.Util;
|
||||
import java.util.Arrays;
|
||||
|
||||
/** Represents the set of audio formats that a device is capable of playing. */
|
||||
@TargetApi(21)
|
||||
public final class AudioCapabilities {
|
||||
|
||||
private static final int DEFAULT_MAX_CHANNEL_COUNT = 8;
|
||||
|
@ -15,11 +15,11 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.audio;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.media.AudioTimestamp;
|
||||
import android.media.AudioTrack;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.lang.annotation.Documented;
|
||||
@ -257,7 +257,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(19)
|
||||
@RequiresApi(19)
|
||||
private static final class AudioTimestampV19 {
|
||||
|
||||
private final AudioTrack audioTrack;
|
||||
|
@ -16,13 +16,13 @@
|
||||
package com.google.android.exoplayer2.audio;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.media.AudioFormat;
|
||||
import android.media.AudioManager;
|
||||
import android.media.AudioTrack;
|
||||
import android.os.ConditionVariable;
|
||||
import android.os.SystemClock;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.PlaybackParameters;
|
||||
@ -1169,14 +1169,14 @@ public final class DefaultAudioSink implements AudioSink {
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
private static int writeNonBlockingV21(AudioTrack audioTrack, ByteBuffer buffer, int size) {
|
||||
return audioTrack.write(buffer, size, WRITE_NON_BLOCKING);
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
private int writeNonBlockingWithAvSyncV21(AudioTrack audioTrack, ByteBuffer buffer, int size,
|
||||
long presentationTimeUs) {
|
||||
@RequiresApi(21)
|
||||
private int writeNonBlockingWithAvSyncV21(
|
||||
AudioTrack audioTrack, ByteBuffer buffer, int size, long presentationTimeUs) {
|
||||
if (Util.SDK_INT >= 26) {
|
||||
// The underlying platform AudioTrack writes AV sync headers directly.
|
||||
return audioTrack.write(buffer, size, WRITE_NON_BLOCKING, presentationTimeUs * 1000);
|
||||
@ -1212,7 +1212,7 @@ public final class DefaultAudioSink implements AudioSink {
|
||||
return result;
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
private static void setVolumeInternalV21(AudioTrack audioTrack, float volume) {
|
||||
audioTrack.setVolume(volume);
|
||||
}
|
||||
@ -1416,7 +1416,7 @@ public final class DefaultAudioSink implements AudioSink {
|
||||
return audioTrack;
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
private AudioTrack createAudioTrackV21(
|
||||
boolean tunneling, AudioAttributes audioAttributes, int audioSessionId) {
|
||||
android.media.AudioAttributes attributes;
|
||||
|
@ -16,7 +16,6 @@
|
||||
package com.google.android.exoplayer2.drm;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.media.NotProvisionedException;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
@ -25,6 +24,7 @@ import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Pair;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.drm.DrmInitData.SchemeData;
|
||||
import com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest;
|
||||
@ -46,7 +46,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
|
||||
/** A {@link DrmSession} that supports playbacks using {@link ExoMediaDrm}. */
|
||||
@TargetApi(18)
|
||||
@RequiresApi(18)
|
||||
/* package */ class DefaultDrmSession<T extends ExoMediaCrypto> implements DrmSession<T> {
|
||||
|
||||
/** Thrown when an unexpected exception or error is thrown during provisioning or key requests. */
|
||||
|
@ -16,12 +16,12 @@
|
||||
package com.google.android.exoplayer2.drm;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.drm.DrmInitData.SchemeData;
|
||||
import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException;
|
||||
@ -43,7 +43,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/** A {@link DrmSessionManager} that supports playbacks using {@link ExoMediaDrm}. */
|
||||
@TargetApi(18)
|
||||
@RequiresApi(18)
|
||||
public class DefaultDrmSessionManager<T extends ExoMediaCrypto> implements DrmSessionManager<T> {
|
||||
|
||||
/**
|
||||
|
@ -15,10 +15,10 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.drm;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest;
|
||||
import com.google.android.exoplayer2.drm.ExoMediaDrm.ProvisionRequest;
|
||||
@ -34,10 +34,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A {@link MediaDrmCallback} that makes requests using {@link HttpDataSource} instances.
|
||||
*/
|
||||
@TargetApi(18)
|
||||
/** A {@link MediaDrmCallback} that makes requests using {@link HttpDataSource} instances. */
|
||||
@RequiresApi(18)
|
||||
public final class HttpMediaDrmCallback implements MediaDrmCallback {
|
||||
|
||||
private static final int MAX_MANUAL_REDIRECTS = 5;
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.drm;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.media.MediaDrm;
|
||||
import android.os.ConditionVariable;
|
||||
import android.os.Handler;
|
||||
@ -34,7 +33,6 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/** Helper class to download, renew and release offline licenses. */
|
||||
@TargetApi(18)
|
||||
@RequiresApi(18)
|
||||
public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.mediacodec;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.graphics.Point;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaCodecInfo.AudioCapabilities;
|
||||
@ -24,6 +23,7 @@ import android.media.MediaCodecInfo.CodecProfileLevel;
|
||||
import android.media.MediaCodecInfo.VideoCapabilities;
|
||||
import android.util.Pair;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.Log;
|
||||
@ -393,7 +393,7 @@ public final class MediaCodecInfo {
|
||||
* Format#NO_VALUE} or any value less than or equal to 0.
|
||||
* @return Whether the decoder supports video with the given width, height and frame rate.
|
||||
*/
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
public boolean isVideoSizeAndRateSupportedV21(int width, int height, double frameRate) {
|
||||
if (capabilities == null) {
|
||||
logNoSupport("sizeAndRate.caps");
|
||||
@ -419,8 +419,8 @@ public final class MediaCodecInfo {
|
||||
/**
|
||||
* Returns the smallest video size greater than or equal to a specified size that also satisfies
|
||||
* the {@link MediaCodec}'s width and height alignment requirements.
|
||||
* <p>
|
||||
* Must not be called if the device SDK version is less than 21.
|
||||
*
|
||||
* <p>Must not be called if the device SDK version is less than 21.
|
||||
*
|
||||
* @param width Width in pixels.
|
||||
* @param height Height in pixels.
|
||||
@ -428,7 +428,7 @@ public final class MediaCodecInfo {
|
||||
* the {@link MediaCodec}'s width and height alignment requirements, or null if not a video
|
||||
* codec.
|
||||
*/
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
public Point alignVideoSizeV21(int width, int height) {
|
||||
if (capabilities == null) {
|
||||
return null;
|
||||
@ -442,13 +442,13 @@ public final class MediaCodecInfo {
|
||||
|
||||
/**
|
||||
* Whether the decoder supports audio with a given sample rate.
|
||||
* <p>
|
||||
* Must not be called if the device SDK version is less than 21.
|
||||
*
|
||||
* <p>Must not be called if the device SDK version is less than 21.
|
||||
*
|
||||
* @param sampleRate The sample rate in Hz.
|
||||
* @return Whether the decoder supports audio with the given sample rate.
|
||||
*/
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
public boolean isAudioSampleRateSupportedV21(int sampleRate) {
|
||||
if (capabilities == null) {
|
||||
logNoSupport("sampleRate.caps");
|
||||
@ -468,13 +468,13 @@ public final class MediaCodecInfo {
|
||||
|
||||
/**
|
||||
* Whether the decoder supports audio with a given channel count.
|
||||
* <p>
|
||||
* Must not be called if the device SDK version is less than 21.
|
||||
*
|
||||
* <p>Must not be called if the device SDK version is less than 21.
|
||||
*
|
||||
* @param channelCount The channel count.
|
||||
* @return Whether the decoder supports audio with the given channel count.
|
||||
*/
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
public boolean isAudioChannelCountSupportedV21(int channelCount) {
|
||||
if (capabilities == null) {
|
||||
logNoSupport("channelCount.caps");
|
||||
@ -542,7 +542,7 @@ public final class MediaCodecInfo {
|
||||
return Util.SDK_INT >= 19 && isAdaptiveV19(capabilities);
|
||||
}
|
||||
|
||||
@TargetApi(19)
|
||||
@RequiresApi(19)
|
||||
private static boolean isAdaptiveV19(CodecCapabilities capabilities) {
|
||||
return capabilities.isFeatureSupported(CodecCapabilities.FEATURE_AdaptivePlayback);
|
||||
}
|
||||
@ -551,7 +551,7 @@ public final class MediaCodecInfo {
|
||||
return Util.SDK_INT >= 21 && isTunnelingV21(capabilities);
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
private static boolean isTunnelingV21(CodecCapabilities capabilities) {
|
||||
return capabilities.isFeatureSupported(CodecCapabilities.FEATURE_TunneledPlayback);
|
||||
}
|
||||
@ -560,14 +560,14 @@ public final class MediaCodecInfo {
|
||||
return Util.SDK_INT >= 21 && isSecureV21(capabilities);
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
private static boolean isSecureV21(CodecCapabilities capabilities) {
|
||||
return capabilities.isFeatureSupported(CodecCapabilities.FEATURE_SecurePlayback);
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
private static boolean areSizeAndRateSupportedV21(VideoCapabilities capabilities, int width,
|
||||
int height, double frameRate) {
|
||||
@RequiresApi(21)
|
||||
private static boolean areSizeAndRateSupportedV21(
|
||||
VideoCapabilities capabilities, int width, int height, double frameRate) {
|
||||
// Don't ever fail due to alignment. See: https://github.com/google/ExoPlayer/issues/6551.
|
||||
Point alignedSize = alignVideoSizeV21(capabilities, width, height);
|
||||
width = alignedSize.x;
|
||||
@ -584,7 +584,7 @@ public final class MediaCodecInfo {
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
private static Point alignVideoSizeV21(VideoCapabilities capabilities, int width, int height) {
|
||||
int widthAlignment = capabilities.getWidthAlignment();
|
||||
int heightAlignment = capabilities.getHeightAlignment();
|
||||
@ -593,7 +593,7 @@ public final class MediaCodecInfo {
|
||||
Util.ceilDivide(height, heightAlignment) * heightAlignment);
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
@RequiresApi(23)
|
||||
private static int getMaxSupportedInstancesV23(CodecCapabilities capabilities) {
|
||||
return capabilities.getMaxSupportedInstances();
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.mediacodec;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaCodec.CodecException;
|
||||
import android.media.MediaCodec.CryptoException;
|
||||
@ -28,6 +27,7 @@ import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.CheckResult;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.BaseRenderer;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||
@ -192,7 +192,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||
fallbackException);
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
private static String getDiagnosticInfoV21(Throwable cause) {
|
||||
if (cause instanceof CodecException) {
|
||||
return ((CodecException) cause).getDiagnosticInfo();
|
||||
@ -223,7 +223,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||
diagnosticInfo = Util.SDK_INT >= 21 ? getDiagnosticInfoV21(cause) : null;
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
private static String getDiagnosticInfoV21(Throwable cause) {
|
||||
if (cause instanceof CodecException) {
|
||||
return ((CodecException) cause).getDiagnosticInfo();
|
||||
@ -1794,7 +1794,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||
maybeInitCodec();
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
@RequiresApi(23)
|
||||
private void updateDrmSessionOrReinitializeCodecV23() throws ExoPlaybackException {
|
||||
FrameworkMediaCrypto sessionMediaCrypto = sourceDrmSession.getMediaCrypto();
|
||||
if (sessionMediaCrypto == null) {
|
||||
@ -1867,7 +1867,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||
return stackTrace.length > 0 && stackTrace[0].getClassName().equals("android.media.MediaCodec");
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
private static boolean isMediaCodecExceptionV21(IllegalStateException error) {
|
||||
return error instanceof MediaCodec.CodecException;
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
package com.google.android.exoplayer2.mediacodec;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.media.MediaCodecInfo.CodecCapabilities;
|
||||
import android.media.MediaCodecInfo.CodecProfileLevel;
|
||||
import android.media.MediaCodecList;
|
||||
@ -25,6 +24,7 @@ import android.util.Pair;
|
||||
import android.util.SparseIntArray;
|
||||
import androidx.annotation.CheckResult;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.util.Log;
|
||||
@ -604,7 +604,7 @@ public final class MediaCodecUtil {
|
||||
return !isSoftwareOnly(codecInfo);
|
||||
}
|
||||
|
||||
@TargetApi(29)
|
||||
@RequiresApi(29)
|
||||
private static boolean isHardwareAcceleratedV29(android.media.MediaCodecInfo codecInfo) {
|
||||
return codecInfo.isHardwareAccelerated();
|
||||
}
|
||||
@ -630,7 +630,7 @@ public final class MediaCodecUtil {
|
||||
|| (!codecName.startsWith("omx.") && !codecName.startsWith("c2."));
|
||||
}
|
||||
|
||||
@TargetApi(29)
|
||||
@RequiresApi(29)
|
||||
private static boolean isSoftwareOnlyV29(android.media.MediaCodecInfo codecInfo) {
|
||||
return codecInfo.isSoftwareOnly();
|
||||
}
|
||||
@ -649,7 +649,7 @@ public final class MediaCodecUtil {
|
||||
&& !codecName.startsWith("c2.google.");
|
||||
}
|
||||
|
||||
@TargetApi(29)
|
||||
@RequiresApi(29)
|
||||
private static boolean isVendorV29(android.media.MediaCodecInfo codecInfo) {
|
||||
return codecInfo.isVendor();
|
||||
}
|
||||
@ -947,7 +947,7 @@ public final class MediaCodecUtil {
|
||||
boolean isFeatureRequired(String feature, String mimeType, CodecCapabilities capabilities);
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
private static final class MediaCodecListCompatV21 implements MediaCodecListCompat {
|
||||
|
||||
private final int codecKind;
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.scheduler;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.job.JobInfo;
|
||||
import android.app.job.JobParameters;
|
||||
import android.app.job.JobScheduler;
|
||||
@ -24,6 +23,7 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.PersistableBundle;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.annotation.RequiresPermission;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.Log;
|
||||
@ -42,7 +42,7 @@ import com.google.android.exoplayer2.util.Util;
|
||||
* android:exported="true"/>
|
||||
* }</pre>
|
||||
*/
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
public final class PlatformScheduler implements Scheduler {
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.scheduler;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -124,7 +123,7 @@ public final class RequirementsWatcher {
|
||||
return requirements;
|
||||
}
|
||||
|
||||
@TargetApi(24)
|
||||
@RequiresApi(24)
|
||||
private void registerNetworkCallbackV24() {
|
||||
ConnectivityManager connectivityManager =
|
||||
Assertions.checkNotNull(
|
||||
@ -133,7 +132,7 @@ public final class RequirementsWatcher {
|
||||
connectivityManager.registerDefaultNetworkCallback(networkCallback);
|
||||
}
|
||||
|
||||
@TargetApi(24)
|
||||
@RequiresApi(24)
|
||||
private void unregisterNetworkCallbackV24() {
|
||||
ConnectivityManager connectivityManager =
|
||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
@ -15,13 +15,13 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.text;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.accessibility.CaptioningManager;
|
||||
import android.view.accessibility.CaptioningManager.CaptionStyle;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
@ -124,7 +124,7 @@ public final class CaptionStyleCompat {
|
||||
* @param captionStyle A {@link CaptionStyle}.
|
||||
* @return The equivalent {@link CaptionStyleCompat}.
|
||||
*/
|
||||
@TargetApi(19)
|
||||
@RequiresApi(19)
|
||||
public static CaptionStyleCompat createFromCaptionStyle(
|
||||
CaptioningManager.CaptionStyle captionStyle) {
|
||||
if (Util.SDK_INT >= 21) {
|
||||
@ -159,7 +159,7 @@ public final class CaptionStyleCompat {
|
||||
this.typeface = typeface;
|
||||
}
|
||||
|
||||
@TargetApi(19)
|
||||
@RequiresApi(19)
|
||||
@SuppressWarnings("ResourceType")
|
||||
private static CaptionStyleCompat createFromCaptionStyleV19(
|
||||
CaptioningManager.CaptionStyle captionStyle) {
|
||||
@ -168,7 +168,7 @@ public final class CaptionStyleCompat {
|
||||
captionStyle.edgeType, captionStyle.edgeColor, captionStyle.getTypeface());
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
@SuppressWarnings("ResourceType")
|
||||
private static CaptionStyleCompat createFromCaptionStyleV21(
|
||||
CaptioningManager.CaptionStyle captionStyle) {
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.trackselection;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Looper;
|
||||
import android.os.Parcel;
|
||||
@ -23,6 +22,7 @@ import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.accessibility.CaptioningManager;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.util.Locale;
|
||||
@ -169,7 +169,7 @@ public class TrackSelectionParameters implements Parcelable {
|
||||
disabledTextTrackSelectionFlags);
|
||||
}
|
||||
|
||||
@TargetApi(19)
|
||||
@RequiresApi(19)
|
||||
private void setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettingsV19(
|
||||
Context context) {
|
||||
if (Util.SDK_INT < 23 && Looper.myLooper() == null) {
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.util;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.opengl.EGL14;
|
||||
import android.opengl.EGLConfig;
|
||||
@ -26,12 +25,13 @@ import android.opengl.GLES20;
|
||||
import android.os.Handler;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/** Generates a {@link SurfaceTexture} using EGL/GLES functions. */
|
||||
@TargetApi(17)
|
||||
@RequiresApi(17)
|
||||
public final class EGLSurfaceTexture implements SurfaceTexture.OnFrameAvailableListener, Runnable {
|
||||
|
||||
/** Listener to be called when the texture image on {@link SurfaceTexture} has been updated. */
|
||||
|
@ -19,7 +19,6 @@ import static com.google.android.exoplayer2.util.EGLSurfaceTexture.SECURE_MODE_N
|
||||
import static com.google.android.exoplayer2.util.EGLSurfaceTexture.SECURE_MODE_PROTECTED_PBUFFER;
|
||||
import static com.google.android.exoplayer2.util.EGLSurfaceTexture.SECURE_MODE_SURFACELESS_CONTEXT;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.SurfaceTexture;
|
||||
@ -31,6 +30,7 @@ import android.os.HandlerThread;
|
||||
import android.os.Message;
|
||||
import android.view.Surface;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.EGLSurfaceTexture;
|
||||
import com.google.android.exoplayer2.util.EGLSurfaceTexture.SecureMode;
|
||||
@ -39,10 +39,8 @@ import com.google.android.exoplayer2.util.Util;
|
||||
import javax.microedition.khronos.egl.EGL10;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
|
||||
/**
|
||||
* A dummy {@link Surface}.
|
||||
*/
|
||||
@TargetApi(17)
|
||||
/** A dummy {@link Surface}. */
|
||||
@RequiresApi(17)
|
||||
public final class DummySurface extends Surface {
|
||||
|
||||
private static final String TAG = "DummySurface";
|
||||
@ -121,7 +119,7 @@ public final class DummySurface extends Surface {
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(24)
|
||||
@RequiresApi(24)
|
||||
private static @SecureMode int getSecureModeV24(Context context) {
|
||||
if (Util.SDK_INT < 26 && ("samsung".equals(Util.MANUFACTURER) || "XT1650".equals(Util.MODEL))) {
|
||||
// Samsung devices running Nougat are known to be broken. See
|
||||
|
@ -16,7 +16,6 @@
|
||||
package com.google.android.exoplayer2.video;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.media.MediaCodec;
|
||||
@ -32,6 +31,7 @@ import android.util.Pair;
|
||||
import android.view.Surface;
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||
import com.google.android.exoplayer2.ExoPlayer;
|
||||
@ -1180,7 +1180,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||
* @param presentationTimeUs The presentation time of the output buffer, in microseconds.
|
||||
* @param releaseTimeNs The wallclock time at which the frame should be displayed, in nanoseconds.
|
||||
*/
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
protected void renderOutputBufferV21(
|
||||
MediaCodec codec, int index, long presentationTimeUs, long releaseTimeNs) {
|
||||
maybeNotifyVideoSizeChanged();
|
||||
@ -1281,19 +1281,19 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||
return earlyUs < -500000;
|
||||
}
|
||||
|
||||
@TargetApi(29)
|
||||
@RequiresApi(29)
|
||||
private static void setHdr10PlusInfoV29(MediaCodec codec, byte[] hdr10PlusInfo) {
|
||||
Bundle codecParameters = new Bundle();
|
||||
codecParameters.putByteArray(MediaCodec.PARAMETER_KEY_HDR10_PLUS_INFO, hdr10PlusInfo);
|
||||
codec.setParameters(codecParameters);
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
@RequiresApi(23)
|
||||
private static void setOutputSurfaceV23(MediaCodec codec, Surface surface) {
|
||||
codec.setOutputSurface(surface);
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
private static void configureTunnelingV21(MediaFormat mediaFormat, int tunnelingAudioSessionId) {
|
||||
mediaFormat.setFeatureEnabled(CodecCapabilities.FEATURE_TunneledPlayback, true);
|
||||
mediaFormat.setInteger(MediaFormat.KEY_AUDIO_SESSION_ID, tunnelingAudioSessionId);
|
||||
@ -1797,7 +1797,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
@RequiresApi(23)
|
||||
private final class OnFrameRenderedListenerV23
|
||||
implements MediaCodec.OnFrameRenderedListener, Handler.Callback {
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.video;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.os.Handler;
|
||||
@ -26,6 +25,7 @@ import android.view.Choreographer.FrameCallback;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
|
||||
@ -187,7 +187,7 @@ public final class VideoFrameReleaseTimeHelper {
|
||||
return snappedTimeNs - vsyncOffsetNs;
|
||||
}
|
||||
|
||||
@TargetApi(17)
|
||||
@RequiresApi(17)
|
||||
private DefaultDisplayListener maybeBuildDefaultDisplayListenerV17(Context context) {
|
||||
DisplayManager manager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
|
||||
return manager == null ? null : new DefaultDisplayListener(manager);
|
||||
@ -226,7 +226,7 @@ public final class VideoFrameReleaseTimeHelper {
|
||||
return snappedAfterDiff < snappedBeforeDiff ? snappedAfterNs : snappedBeforeNs;
|
||||
}
|
||||
|
||||
@TargetApi(17)
|
||||
@RequiresApi(17)
|
||||
private final class DefaultDisplayListener implements DisplayManager.DisplayListener {
|
||||
|
||||
private final DisplayManager displayManager;
|
||||
|
@ -16,7 +16,6 @@
|
||||
package com.google.android.exoplayer2.ui;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
@ -40,6 +39,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.ControlDispatcher;
|
||||
@ -1419,7 +1419,7 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
@RequiresApi(23)
|
||||
private static void configureEditModeLogoV23(Resources resources, ImageView logo) {
|
||||
logo.setImageDrawable(resources.getDrawable(R.drawable.exo_edit_mode_logo, null));
|
||||
logo.setBackgroundColor(resources.getColor(R.color.exo_edit_mode_background_color, null));
|
||||
|
@ -18,7 +18,6 @@ package com.google.android.exoplayer2.ui;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.AttributeSet;
|
||||
@ -29,6 +28,7 @@ import android.view.accessibility.CaptioningManager;
|
||||
import androidx.annotation.Dimension;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.text.CaptionStyleCompat;
|
||||
import com.google.android.exoplayer2.text.Cue;
|
||||
import com.google.android.exoplayer2.text.TextOutput;
|
||||
@ -266,21 +266,21 @@ public final class SubtitleView extends ViewGroup implements TextOutput {
|
||||
output.setBottomPaddingFraction(bottomPaddingFraction);
|
||||
}
|
||||
|
||||
@TargetApi(19)
|
||||
@RequiresApi(19)
|
||||
private boolean isCaptionManagerEnabled() {
|
||||
CaptioningManager captioningManager =
|
||||
(CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE);
|
||||
return captioningManager.isEnabled();
|
||||
}
|
||||
|
||||
@TargetApi(19)
|
||||
@RequiresApi(19)
|
||||
private float getUserCaptionFontScaleV19() {
|
||||
CaptioningManager captioningManager =
|
||||
(CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE);
|
||||
return captioningManager.getFontScale();
|
||||
}
|
||||
|
||||
@TargetApi(19)
|
||||
@RequiresApi(19)
|
||||
private CaptionStyleCompat getUserCaptionStyleV19() {
|
||||
CaptioningManager captioningManager =
|
||||
(CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE);
|
||||
|
@ -17,11 +17,11 @@ package com.google.android.exoplayer2.playbacktests.gts;
|
||||
|
||||
import static com.google.android.exoplayer2.C.WIDEVINE_UUID;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.media.MediaDrm;
|
||||
import android.media.UnsupportedSchemeException;
|
||||
import android.net.Uri;
|
||||
import android.view.Surface;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.RendererCapabilities;
|
||||
@ -458,10 +458,10 @@ import java.util.List;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code MediaDrm} object. The encapsulation ensures that the tests can be
|
||||
* executed for API level < 18.
|
||||
* Creates a new {@code MediaDrm} object. The encapsulation ensures that the tests can be executed
|
||||
* for API level < 18.
|
||||
*/
|
||||
@TargetApi(18)
|
||||
@RequiresApi(18)
|
||||
private static final class MediaDrmBuilder {
|
||||
|
||||
public static MediaDrm build () {
|
||||
|
@ -15,12 +15,12 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.playbacktests.gts;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaCrypto;
|
||||
import android.os.Handler;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
@ -189,10 +189,10 @@ import java.util.ArrayList;
|
||||
super.renderOutputBuffer(codec, index, presentationTimeUs);
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
@RequiresApi(21)
|
||||
@Override
|
||||
protected void renderOutputBufferV21(MediaCodec codec, int index, long presentationTimeUs,
|
||||
long releaseTimeNs) {
|
||||
protected void renderOutputBufferV21(
|
||||
MediaCodec codec, int index, long presentationTimeUs, long releaseTimeNs) {
|
||||
skipToPositionBeforeRenderingFirstFrame = false;
|
||||
super.renderOutputBufferV21(codec, index, presentationTimeUs, releaseTimeNs);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user