Commit 6157c615 by ibaker Committed by Christos Tsilopoulos

Standardise API-level specific nested classes

This change aligns all the names for classes that are 'holders of static
methods' to be `ApiNN`. Classes that hold state are named meaningfully
based on that state.

PiperOrigin-RevId: 388641064
parent 5e4cd129
...@@ -93,7 +93,7 @@ public final class AudioCapabilities { ...@@ -93,7 +93,7 @@ public final class AudioCapabilities {
// it on TV devices, which generally shouldn't support audio offload for surround encodings. // it on TV devices, which generally shouldn't support audio offload for surround encodings.
if (Util.SDK_INT >= 29 && Util.isTv(context)) { if (Util.SDK_INT >= 29 && Util.isTv(context)) {
return new AudioCapabilities( return new AudioCapabilities(
Api29.getDirectPlaybackSupportedEncodingsV29(), DEFAULT_MAX_CHANNEL_COUNT); Api29.getDirectPlaybackSupportedEncodings(), DEFAULT_MAX_CHANNEL_COUNT);
} }
if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) { if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) {
return DEFAULT_AUDIO_CAPABILITIES; return DEFAULT_AUDIO_CAPABILITIES;
...@@ -190,7 +190,7 @@ public final class AudioCapabilities { ...@@ -190,7 +190,7 @@ public final class AudioCapabilities {
@RequiresApi(29) @RequiresApi(29)
private static final class Api29 { private static final class Api29 {
@DoNotInline @DoNotInline
public static int[] getDirectPlaybackSupportedEncodingsV29() { public static int[] getDirectPlaybackSupportedEncodings() {
ImmutableList.Builder<Integer> supportedEncodingsListBuilder = ImmutableList.builder(); ImmutableList.Builder<Integer> supportedEncodingsListBuilder = ImmutableList.builder();
for (int encoding : ALL_SURROUND_ENCODINGS) { for (int encoding : ALL_SURROUND_ENCODINGS) {
if (AudioTrack.isDirectPlaybackSupported( if (AudioTrack.isDirectPlaybackSupported(
......
...@@ -64,16 +64,13 @@ public final class DrmUtil { ...@@ -64,16 +64,13 @@ public final class DrmUtil {
@PlaybackException.ErrorCode @PlaybackException.ErrorCode
public static int getErrorCodeForMediaDrmException( public static int getErrorCodeForMediaDrmException(
Exception exception, @ErrorSource int errorSource) { Exception exception, @ErrorSource int errorSource) {
if (Util.SDK_INT >= 21 && PlatformOperationsWrapperV21.isMediaDrmStateException(exception)) { if (Util.SDK_INT >= 21 && Api21.isMediaDrmStateException(exception)) {
return PlatformOperationsWrapperV21.mediaDrmStateExceptionToErrorCode(exception); return Api21.mediaDrmStateExceptionToErrorCode(exception);
} else if (Util.SDK_INT >= 23 } else if (Util.SDK_INT >= 23 && Api23.isMediaDrmResetException(exception)) {
&& PlatformOperationsWrapperV23.isMediaDrmResetException(exception)) {
return PlaybackException.ERROR_CODE_DRM_SYSTEM_ERROR; return PlaybackException.ERROR_CODE_DRM_SYSTEM_ERROR;
} else if (Util.SDK_INT >= 18 } else if (Util.SDK_INT >= 18 && Api18.isNotProvisionedException(exception)) {
&& PlatformOperationsWrapperV18.isNotProvisionedException(exception)) {
return PlaybackException.ERROR_CODE_DRM_PROVISIONING_FAILED; return PlaybackException.ERROR_CODE_DRM_PROVISIONING_FAILED;
} else if (Util.SDK_INT >= 18 } else if (Util.SDK_INT >= 18 && Api18.isDeniedByServerException(exception)) {
&& PlatformOperationsWrapperV18.isDeniedByServerException(exception)) {
return PlaybackException.ERROR_CODE_DRM_DEVICE_REVOKED; return PlaybackException.ERROR_CODE_DRM_DEVICE_REVOKED;
} else if (exception instanceof UnsupportedDrmException) { } else if (exception instanceof UnsupportedDrmException) {
return PlaybackException.ERROR_CODE_DRM_SCHEME_UNSUPPORTED; return PlaybackException.ERROR_CODE_DRM_SCHEME_UNSUPPORTED;
...@@ -98,7 +95,7 @@ public final class DrmUtil { ...@@ -98,7 +95,7 @@ public final class DrmUtil {
// Internal classes. // Internal classes.
@RequiresApi(18) @RequiresApi(18)
private static final class PlatformOperationsWrapperV18 { private static final class Api18 {
@DoNotInline @DoNotInline
public static boolean isNotProvisionedException(@Nullable Throwable throwable) { public static boolean isNotProvisionedException(@Nullable Throwable throwable) {
...@@ -112,7 +109,7 @@ public final class DrmUtil { ...@@ -112,7 +109,7 @@ public final class DrmUtil {
} }
@RequiresApi(21) @RequiresApi(21)
private static final class PlatformOperationsWrapperV21 { private static final class Api21 {
@DoNotInline @DoNotInline
public static boolean isMediaDrmStateException(@Nullable Throwable throwable) { public static boolean isMediaDrmStateException(@Nullable Throwable throwable) {
...@@ -130,7 +127,7 @@ public final class DrmUtil { ...@@ -130,7 +127,7 @@ public final class DrmUtil {
} }
@RequiresApi(23) @RequiresApi(23)
private static final class PlatformOperationsWrapperV23 { private static final class Api23 {
@DoNotInline @DoNotInline
public static boolean isMediaDrmResetException(@Nullable Throwable throwable) { public static boolean isMediaDrmResetException(@Nullable Throwable throwable) {
......
...@@ -192,7 +192,7 @@ public final class FileDataSource extends BaseDataSource { ...@@ -192,7 +192,7 @@ public final class FileDataSource extends BaseDataSource {
// different SDK versions. // different SDK versions.
throw new FileDataSourceException( throw new FileDataSourceException(
e, e,
Util.SDK_INT >= 21 && PlatformOperationsWrapperV21.isPermissionError(e.getCause()) Util.SDK_INT >= 21 && Api21.isPermissionError(e.getCause())
? PlaybackException.ERROR_CODE_IO_NO_PERMISSION ? PlaybackException.ERROR_CODE_IO_NO_PERMISSION
: PlaybackException.ERROR_CODE_IO_FILE_NOT_FOUND); : PlaybackException.ERROR_CODE_IO_FILE_NOT_FOUND);
} catch (SecurityException e) { } catch (SecurityException e) {
...@@ -203,7 +203,7 @@ public final class FileDataSource extends BaseDataSource { ...@@ -203,7 +203,7 @@ public final class FileDataSource extends BaseDataSource {
} }
@RequiresApi(21) @RequiresApi(21)
private static final class PlatformOperationsWrapperV21 { private static final class Api21 {
@DoNotInline @DoNotInline
private static boolean isPermissionError(@Nullable Throwable e) { private static boolean isPermissionError(@Nullable Throwable e) {
return e instanceof ErrnoException && ((ErrnoException) e).errno == OsConstants.EACCES; return e instanceof ErrnoException && ((ErrnoException) e).errno == OsConstants.EACCES;
......
...@@ -347,7 +347,7 @@ public final class VideoFrameReleaseHelper { ...@@ -347,7 +347,7 @@ public final class VideoFrameReleaseHelper {
return; return;
} }
this.surfacePlaybackFrameRate = surfacePlaybackFrameRate; this.surfacePlaybackFrameRate = surfacePlaybackFrameRate;
SurfaceApi30.setFrameRate(surface, surfacePlaybackFrameRate); Api30.setSurfaceFrameRate(surface, surfacePlaybackFrameRate);
} }
/** Clears the frame-rate of the current {@link #surface}. */ /** Clears the frame-rate of the current {@link #surface}. */
...@@ -356,7 +356,7 @@ public final class VideoFrameReleaseHelper { ...@@ -356,7 +356,7 @@ public final class VideoFrameReleaseHelper {
return; return;
} }
surfacePlaybackFrameRate = 0; surfacePlaybackFrameRate = 0;
SurfaceApi30.setFrameRate(surface, /* frameRate= */ 0); Api30.setSurfaceFrameRate(surface, /* frameRate= */ 0);
} }
// Display refresh rate and vsync logic. // Display refresh rate and vsync logic.
...@@ -408,9 +408,9 @@ public final class VideoFrameReleaseHelper { ...@@ -408,9 +408,9 @@ public final class VideoFrameReleaseHelper {
// Nested classes. // Nested classes.
@RequiresApi(30) @RequiresApi(30)
private static final class SurfaceApi30 { private static final class Api30 {
@DoNotInline @DoNotInline
public static void setFrameRate(Surface surface, float frameRate) { public static void setSurfaceFrameRate(Surface surface, float frameRate) {
int compatibility = int compatibility =
frameRate == 0 frameRate == 0
? Surface.FRAME_RATE_COMPATIBILITY_DEFAULT ? Surface.FRAME_RATE_COMPATIBILITY_DEFAULT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment