mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Remove unnecessary SDK_INT
checks
This commit is contained in:
parent
7289764a65
commit
28edfcbb69
@ -2613,11 +2613,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||||||
* buffer with {@link MediaCodec#BUFFER_FLAG_END_OF_STREAM} set. False otherwise.
|
* buffer with {@link MediaCodec#BUFFER_FLAG_END_OF_STREAM} set. False otherwise.
|
||||||
*/
|
*/
|
||||||
private static boolean codecNeedsEosFlushWorkaround(String name) {
|
private static boolean codecNeedsEosFlushWorkaround(String name) {
|
||||||
return (Util.SDK_INT <= 23 && "OMX.google.vorbis.decoder".equals(name))
|
return Util.SDK_INT <= 23 && "OMX.google.vorbis.decoder".equals(name);
|
||||||
|| (Util.SDK_INT == 19
|
|
||||||
&& ("hb2000".equals(Util.DEVICE) || "stvm8".equals(Util.DEVICE))
|
|
||||||
&& ("OMX.amlogic.avc.decoder.awesome".equals(name)
|
|
||||||
|| "OMX.amlogic.avc.decoder.awesome.secure".equals(name)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -366,12 +366,6 @@ public class DefaultMediaNotificationProvider implements MediaNotification.Provi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.isCommandAvailable(COMMAND_STOP)) {
|
|
||||||
// We must include a cancel intent for pre-L devices.
|
|
||||||
mediaStyle.setCancelButtonIntent(
|
|
||||||
actionFactory.createMediaActionPendingIntent(mediaSession, COMMAND_STOP));
|
|
||||||
}
|
|
||||||
|
|
||||||
long playbackStartTimeMs = getPlaybackStartTimeEpochMs(player);
|
long playbackStartTimeMs = getPlaybackStartTimeEpochMs(player);
|
||||||
boolean displayElapsedTimeWithChronometer = playbackStartTimeMs != C.TIME_UNSET;
|
boolean displayElapsedTimeWithChronometer = playbackStartTimeMs != C.TIME_UNSET;
|
||||||
builder
|
builder
|
||||||
|
@ -308,10 +308,9 @@ public class AudioAttributesCompat {
|
|||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= 26) {
|
if (Build.VERSION.SDK_INT >= 26) {
|
||||||
return new AudioAttributesCompat(new AudioAttributesImplApi26((AudioAttributes) aa));
|
return new AudioAttributesCompat(new AudioAttributesImplApi26((AudioAttributes) aa));
|
||||||
} else if (Build.VERSION.SDK_INT >= 21) {
|
} else {
|
||||||
return new AudioAttributesCompat(new AudioAttributesImplApi21((AudioAttributes) aa));
|
return new AudioAttributesCompat(new AudioAttributesImplApi21((AudioAttributes) aa));
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The rest of this file implements an approximation to AudioAttributes using old stream types
|
// The rest of this file implements an approximation to AudioAttributes using old stream types
|
||||||
@ -377,10 +376,8 @@ public class AudioAttributesCompat {
|
|||||||
mBuilderImpl = new AudioAttributesImplBase.Builder();
|
mBuilderImpl = new AudioAttributesImplBase.Builder();
|
||||||
} else if (Build.VERSION.SDK_INT >= 26) {
|
} else if (Build.VERSION.SDK_INT >= 26) {
|
||||||
mBuilderImpl = new AudioAttributesImplApi26.Builder();
|
mBuilderImpl = new AudioAttributesImplApi26.Builder();
|
||||||
} else if (Build.VERSION.SDK_INT >= 21) {
|
|
||||||
mBuilderImpl = new AudioAttributesImplApi21.Builder();
|
|
||||||
} else {
|
} else {
|
||||||
mBuilderImpl = new AudioAttributesImplBase.Builder();
|
mBuilderImpl = new AudioAttributesImplApi21.Builder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,10 +391,8 @@ public class AudioAttributesCompat {
|
|||||||
mBuilderImpl = new AudioAttributesImplBase.Builder(aa);
|
mBuilderImpl = new AudioAttributesImplBase.Builder(aa);
|
||||||
} else if (Build.VERSION.SDK_INT >= 26) {
|
} else if (Build.VERSION.SDK_INT >= 26) {
|
||||||
mBuilderImpl = new AudioAttributesImplApi26.Builder(checkNotNull(aa.unwrap()));
|
mBuilderImpl = new AudioAttributesImplApi26.Builder(checkNotNull(aa.unwrap()));
|
||||||
} else if (Build.VERSION.SDK_INT >= 21) {
|
|
||||||
mBuilderImpl = new AudioAttributesImplApi21.Builder(checkNotNull(aa.unwrap()));
|
|
||||||
} else {
|
} else {
|
||||||
mBuilderImpl = new AudioAttributesImplBase.Builder(aa);
|
mBuilderImpl = new AudioAttributesImplApi21.Builder(checkNotNull(aa.unwrap()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ public final class LegacyParcelableUtil {
|
|||||||
// TODO: b/335804969 - Remove this workaround once the bug fix is in the androidx.media dependency
|
// TODO: b/335804969 - Remove this workaround once the bug fix is in the androidx.media dependency
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static <T> T maybeApplyMediaDescriptionParcelableBugWorkaround(T value) {
|
private static <T> T maybeApplyMediaDescriptionParcelableBugWorkaround(T value) {
|
||||||
if (Util.SDK_INT < 21 || Util.SDK_INT >= 23) {
|
if (Util.SDK_INT >= 23) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
if (value instanceof android.support.v4.media.MediaBrowserCompat.MediaItem) {
|
if (value instanceof android.support.v4.media.MediaBrowserCompat.MediaItem) {
|
||||||
|
@ -73,6 +73,7 @@ import android.support.v4.os.ResultReceiver;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.annotation.RestrictTo;
|
import androidx.annotation.RestrictTo;
|
||||||
@ -203,10 +204,8 @@ public final class MediaBrowserCompat {
|
|||||||
mImpl = new MediaBrowserImplApi26(context, serviceComponent, callback, rootHints);
|
mImpl = new MediaBrowserImplApi26(context, serviceComponent, callback, rootHints);
|
||||||
} else if (Build.VERSION.SDK_INT >= 23) {
|
} else if (Build.VERSION.SDK_INT >= 23) {
|
||||||
mImpl = new MediaBrowserImplApi23(context, serviceComponent, callback, rootHints);
|
mImpl = new MediaBrowserImplApi23(context, serviceComponent, callback, rootHints);
|
||||||
} else if (Build.VERSION.SDK_INT >= 21) {
|
|
||||||
mImpl = new MediaBrowserImplApi21(context, serviceComponent, callback, rootHints);
|
|
||||||
} else {
|
} else {
|
||||||
mImpl = new MediaBrowserImplBase(context, serviceComponent, callback, rootHints);
|
mImpl = new MediaBrowserImplApi21(context, serviceComponent, callback, rootHints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +462,7 @@ public final class MediaBrowserCompat {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static MediaItem fromMediaItem(@Nullable Object itemObj) {
|
public static MediaItem fromMediaItem(@Nullable Object itemObj) {
|
||||||
if (itemObj == null || Build.VERSION.SDK_INT < 21) {
|
if (itemObj == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
MediaBrowser.MediaItem itemFwk = (MediaBrowser.MediaItem) itemObj;
|
MediaBrowser.MediaItem itemFwk = (MediaBrowser.MediaItem) itemObj;
|
||||||
@ -484,7 +483,7 @@ public final class MediaBrowserCompat {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static List<MediaItem> fromMediaItemList(@Nullable List<?> itemList) {
|
public static List<MediaItem> fromMediaItemList(@Nullable List<?> itemList) {
|
||||||
if (itemList == null || Build.VERSION.SDK_INT < 21) {
|
if (itemList == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<MediaItem> items = new ArrayList<>(itemList.size());
|
List<MediaItem> items = new ArrayList<>(itemList.size());
|
||||||
@ -599,11 +598,7 @@ public final class MediaBrowserCompat {
|
|||||||
@Nullable ConnectionCallbackInternal mConnectionCallbackInternal;
|
@Nullable ConnectionCallbackInternal mConnectionCallbackInternal;
|
||||||
|
|
||||||
public ConnectionCallback() {
|
public ConnectionCallback() {
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
mConnectionCallbackFwk = new ConnectionCallbackApi21();
|
||||||
mConnectionCallbackFwk = new ConnectionCallbackApi21();
|
|
||||||
} else {
|
|
||||||
mConnectionCallbackFwk = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -676,7 +671,7 @@ public final class MediaBrowserCompat {
|
|||||||
|
|
||||||
/** Callbacks for subscription related events. */
|
/** Callbacks for subscription related events. */
|
||||||
public abstract static class SubscriptionCallback {
|
public abstract static class SubscriptionCallback {
|
||||||
@Nullable final MediaBrowser.SubscriptionCallback mSubscriptionCallbackFwk;
|
@NonNull final MediaBrowser.SubscriptionCallback mSubscriptionCallbackFwk;
|
||||||
final IBinder mToken;
|
final IBinder mToken;
|
||||||
@Nullable WeakReference<Subscription> mSubscriptionRef;
|
@Nullable WeakReference<Subscription> mSubscriptionRef;
|
||||||
|
|
||||||
@ -684,10 +679,8 @@ public final class MediaBrowserCompat {
|
|||||||
mToken = new Binder();
|
mToken = new Binder();
|
||||||
if (Build.VERSION.SDK_INT >= 26) {
|
if (Build.VERSION.SDK_INT >= 26) {
|
||||||
mSubscriptionCallbackFwk = new SubscriptionCallbackApi26();
|
mSubscriptionCallbackFwk = new SubscriptionCallbackApi26();
|
||||||
} else if (Build.VERSION.SDK_INT >= 21) {
|
|
||||||
mSubscriptionCallbackFwk = new SubscriptionCallbackApi21();
|
|
||||||
} else {
|
} else {
|
||||||
mSubscriptionCallbackFwk = null;
|
mSubscriptionCallbackFwk = new SubscriptionCallbackApi21();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1739,7 +1732,7 @@ public final class MediaBrowserCompat {
|
|||||||
if (mServiceBinderWrapper == null) {
|
if (mServiceBinderWrapper == null) {
|
||||||
// TODO: When MediaBrowser is connected to framework's MediaBrowserService,
|
// TODO: When MediaBrowser is connected to framework's MediaBrowserService,
|
||||||
// subscribe with options won't work properly.
|
// subscribe with options won't work properly.
|
||||||
mBrowserFwk.subscribe(parentId, checkNotNull(callback.mSubscriptionCallbackFwk));
|
mBrowserFwk.subscribe(parentId, callback.mSubscriptionCallbackFwk);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
mServiceBinderWrapper.addSubscription(
|
mServiceBinderWrapper.addSubscription(
|
||||||
@ -2087,9 +2080,9 @@ public final class MediaBrowserCompat {
|
|||||||
// This is to prevent ClassNotFoundException when options has Parcelable in it.
|
// This is to prevent ClassNotFoundException when options has Parcelable in it.
|
||||||
if (mServiceBinderWrapper == null || mServiceVersion < SERVICE_VERSION_2) {
|
if (mServiceBinderWrapper == null || mServiceVersion < SERVICE_VERSION_2) {
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
mBrowserFwk.subscribe(parentId, checkNotNull(callback.mSubscriptionCallbackFwk));
|
mBrowserFwk.subscribe(parentId, callback.mSubscriptionCallbackFwk);
|
||||||
} else {
|
} else {
|
||||||
mBrowserFwk.subscribe(parentId, options, checkNotNull(callback.mSubscriptionCallbackFwk));
|
mBrowserFwk.subscribe(parentId, options, callback.mSubscriptionCallbackFwk);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
super.subscribe(parentId, options, callback);
|
super.subscribe(parentId, options, callback);
|
||||||
@ -2104,7 +2097,7 @@ public final class MediaBrowserCompat {
|
|||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
mBrowserFwk.unsubscribe(parentId);
|
mBrowserFwk.unsubscribe(parentId);
|
||||||
} else {
|
} else {
|
||||||
mBrowserFwk.unsubscribe(parentId, checkNotNull(callback.mSubscriptionCallbackFwk));
|
mBrowserFwk.unsubscribe(parentId, callback.mSubscriptionCallbackFwk);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
super.unsubscribe(parentId, callback);
|
super.unsubscribe(parentId, callback);
|
||||||
|
@ -1328,10 +1328,8 @@ public abstract class MediaBrowserServiceCompat extends Service {
|
|||||||
mImpl = new MediaBrowserServiceImplApi26();
|
mImpl = new MediaBrowserServiceImplApi26();
|
||||||
} else if (Build.VERSION.SDK_INT >= 23) {
|
} else if (Build.VERSION.SDK_INT >= 23) {
|
||||||
mImpl = new MediaBrowserServiceImplApi23();
|
mImpl = new MediaBrowserServiceImplApi23();
|
||||||
} else if (Build.VERSION.SDK_INT >= 21) {
|
|
||||||
mImpl = new MediaBrowserServiceImplApi21();
|
|
||||||
} else {
|
} else {
|
||||||
mImpl = new MediaBrowserServiceImplBase();
|
mImpl = new MediaBrowserServiceImplApi21();
|
||||||
}
|
}
|
||||||
mImpl.onCreate();
|
mImpl.onCreate();
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ import android.text.TextUtils;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import androidx.annotation.GuardedBy;
|
import androidx.annotation.GuardedBy;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.annotation.RestrictTo;
|
import androidx.annotation.RestrictTo;
|
||||||
@ -142,9 +143,12 @@ public final class MediaControllerCompat {
|
|||||||
.getWindow()
|
.getWindow()
|
||||||
.getDecorView()
|
.getDecorView()
|
||||||
.setTag(R.id.media_controller_compat_view_tag, mediaController);
|
.setTag(R.id.media_controller_compat_view_tag, mediaController);
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
MediaController controllerFwk = null;
|
||||||
MediaControllerImplApi21.setMediaController(activity, mediaController);
|
if (mediaController != null) {
|
||||||
|
Object sessionTokenObj = mediaController.getSessionToken().getToken();
|
||||||
|
controllerFwk = new MediaController(activity, (MediaSession.Token) sessionTokenObj);
|
||||||
}
|
}
|
||||||
|
activity.setMediaController(controllerFwk);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,10 +166,15 @@ public final class MediaControllerCompat {
|
|||||||
Object tag = activity.getWindow().getDecorView().getTag(R.id.media_controller_compat_view_tag);
|
Object tag = activity.getWindow().getDecorView().getTag(R.id.media_controller_compat_view_tag);
|
||||||
if (tag instanceof MediaControllerCompat) {
|
if (tag instanceof MediaControllerCompat) {
|
||||||
return (MediaControllerCompat) tag;
|
return (MediaControllerCompat) tag;
|
||||||
} else if (android.os.Build.VERSION.SDK_INT >= 21) {
|
} else {
|
||||||
return MediaControllerImplApi21.getMediaController(activity);
|
MediaController controllerFwk = activity.getMediaController();
|
||||||
|
if (controllerFwk == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MediaSession.Token sessionTokenFwk = controllerFwk.getSessionToken();
|
||||||
|
return new MediaControllerCompat(
|
||||||
|
activity, MediaSessionCompat.Token.fromToken(sessionTokenFwk));
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess") /* synthetic access */
|
@SuppressWarnings("WeakerAccess") /* synthetic access */
|
||||||
@ -221,10 +230,8 @@ public final class MediaControllerCompat {
|
|||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 29) {
|
if (Build.VERSION.SDK_INT >= 29) {
|
||||||
mImpl = new MediaControllerImplApi29(context, sessionToken);
|
mImpl = new MediaControllerImplApi29(context, sessionToken);
|
||||||
} else if (Build.VERSION.SDK_INT >= 21) {
|
|
||||||
mImpl = new MediaControllerImplApi21(context, sessionToken);
|
|
||||||
} else {
|
} else {
|
||||||
mImpl = new MediaControllerImplBase(sessionToken);
|
mImpl = new MediaControllerImplApi21(context, sessionToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,19 +656,14 @@ public final class MediaControllerCompat {
|
|||||||
* #registerCallback}
|
* #registerCallback}
|
||||||
*/
|
*/
|
||||||
public abstract static class Callback implements IBinder.DeathRecipient {
|
public abstract static class Callback implements IBinder.DeathRecipient {
|
||||||
@Nullable final MediaController.Callback mCallbackFwk;
|
@NonNull final MediaController.Callback mCallbackFwk;
|
||||||
@Nullable MessageHandler mHandler;
|
@Nullable MessageHandler mHandler;
|
||||||
@Nullable IMediaControllerCallback mIControllerCallback;
|
@Nullable IMediaControllerCallback mIControllerCallback;
|
||||||
|
|
||||||
// Sharing this in constructor
|
// Sharing this in constructor
|
||||||
@SuppressWarnings({"assignment.type.incompatible", "argument.type.incompatible"})
|
@SuppressWarnings({"assignment.type.incompatible", "argument.type.incompatible"})
|
||||||
public Callback() {
|
public Callback() {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
mCallbackFwk = new MediaControllerCallbackApi21(this);
|
||||||
mCallbackFwk = new MediaControllerCallbackApi21(this);
|
|
||||||
} else {
|
|
||||||
mCallbackFwk = null;
|
|
||||||
mIControllerCallback = new StubCompat(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2000,7 +2002,7 @@ public final class MediaControllerCompat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void registerCallback(Callback callback, Handler handler) {
|
public final void registerCallback(Callback callback, Handler handler) {
|
||||||
mControllerFwk.registerCallback(checkNotNull(callback.mCallbackFwk), handler);
|
mControllerFwk.registerCallback(callback.mCallbackFwk, handler);
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
IMediaSession extraBinder = mSessionToken.getExtraBinder();
|
IMediaSession extraBinder = mSessionToken.getExtraBinder();
|
||||||
if (extraBinder != null) {
|
if (extraBinder != null) {
|
||||||
@ -2022,7 +2024,7 @@ public final class MediaControllerCompat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void unregisterCallback(Callback callback) {
|
public final void unregisterCallback(Callback callback) {
|
||||||
mControllerFwk.unregisterCallback(checkNotNull(callback.mCallbackFwk));
|
mControllerFwk.unregisterCallback(callback.mCallbackFwk);
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
IMediaSession extraBinder = mSessionToken.getExtraBinder();
|
IMediaSession extraBinder = mSessionToken.getExtraBinder();
|
||||||
if (extraBinder != null) {
|
if (extraBinder != null) {
|
||||||
@ -2149,7 +2151,7 @@ public final class MediaControllerCompat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRatingType() {
|
public int getRatingType() {
|
||||||
if (android.os.Build.VERSION.SDK_INT < 22) {
|
if (android.os.Build.VERSION.SDK_INT == 21) {
|
||||||
try {
|
try {
|
||||||
IMediaSession extraBinder = mSessionToken.getExtraBinder();
|
IMediaSession extraBinder = mSessionToken.getExtraBinder();
|
||||||
if (extraBinder != null) {
|
if (extraBinder != null) {
|
||||||
@ -2302,27 +2304,6 @@ public final class MediaControllerCompat {
|
|||||||
mPendingCallbacks.clear();
|
mPendingCallbacks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("argument.type.incompatible") // Activity.setMediaController is not annotated
|
|
||||||
static void setMediaController(Activity activity, MediaControllerCompat mediaControllerCompat) {
|
|
||||||
MediaController controllerFwk = null;
|
|
||||||
if (mediaControllerCompat != null) {
|
|
||||||
Object sessionTokenObj = mediaControllerCompat.getSessionToken().getToken();
|
|
||||||
controllerFwk = new MediaController(activity, (MediaSession.Token) sessionTokenObj);
|
|
||||||
}
|
|
||||||
activity.setMediaController(controllerFwk);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
static MediaControllerCompat getMediaController(Activity activity) {
|
|
||||||
MediaController controllerFwk = activity.getMediaController();
|
|
||||||
if (controllerFwk == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
MediaSession.Token sessionTokenFwk = controllerFwk.getSessionToken();
|
|
||||||
return new MediaControllerCompat(
|
|
||||||
activity, MediaSessionCompat.Token.fromToken(sessionTokenFwk));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ExtraBinderRequestResultReceiver extends ResultReceiver {
|
private static class ExtraBinderRequestResultReceiver extends ResultReceiver {
|
||||||
private WeakReference<MediaControllerImplApi21> mMediaControllerImpl;
|
private WeakReference<MediaControllerImplApi21> mMediaControllerImpl;
|
||||||
|
|
||||||
|
@ -294,18 +294,7 @@ public final class MediaDescriptionCompat implements Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
if (Build.VERSION.SDK_INT < 21) {
|
((MediaDescription) getMediaDescription()).writeToParcel(dest, flags);
|
||||||
dest.writeString(mMediaId);
|
|
||||||
TextUtils.writeToParcel(mTitle, dest, flags);
|
|
||||||
TextUtils.writeToParcel(mSubtitle, dest, flags);
|
|
||||||
TextUtils.writeToParcel(mDescription, dest, flags);
|
|
||||||
dest.writeParcelable(mIcon, flags);
|
|
||||||
dest.writeParcelable(mIconUri, flags);
|
|
||||||
dest.writeBundle(mExtras);
|
|
||||||
dest.writeParcelable(mMediaUri, flags);
|
|
||||||
} else {
|
|
||||||
((MediaDescription) getMediaDescription()).writeToParcel(dest, flags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -365,7 +354,7 @@ public final class MediaDescriptionCompat implements Parcelable {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static MediaDescriptionCompat fromMediaDescription(Object descriptionObj) {
|
public static MediaDescriptionCompat fromMediaDescription(Object descriptionObj) {
|
||||||
if (descriptionObj != null && Build.VERSION.SDK_INT >= 21) {
|
if (descriptionObj != null) {
|
||||||
Builder bob = new Builder();
|
Builder bob = new Builder();
|
||||||
MediaDescription description = (MediaDescription) descriptionObj;
|
MediaDescription description = (MediaDescription) descriptionObj;
|
||||||
bob.setMediaId(description.getMediaId());
|
bob.setMediaId(description.getMediaId());
|
||||||
@ -416,12 +405,8 @@ public final class MediaDescriptionCompat implements Parcelable {
|
|||||||
new Parcelable.Creator<MediaDescriptionCompat>() {
|
new Parcelable.Creator<MediaDescriptionCompat>() {
|
||||||
@Override
|
@Override
|
||||||
public MediaDescriptionCompat createFromParcel(Parcel in) {
|
public MediaDescriptionCompat createFromParcel(Parcel in) {
|
||||||
if (Build.VERSION.SDK_INT < 21) {
|
return checkNotNull(
|
||||||
return new MediaDescriptionCompat(in);
|
fromMediaDescription(MediaDescription.CREATOR.createFromParcel(in)));
|
||||||
} else {
|
|
||||||
return checkNotNull(
|
|
||||||
fromMediaDescription(MediaDescription.CREATOR.createFromParcel(in)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,7 +22,6 @@ import android.annotation.SuppressLint;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.media.MediaMetadata;
|
import android.media.MediaMetadata;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
@ -563,7 +562,7 @@ public final class MediaMetadataCompat implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static MediaMetadataCompat fromMediaMetadata(@Nullable Object metadataObj) {
|
public static MediaMetadataCompat fromMediaMetadata(@Nullable Object metadataObj) {
|
||||||
if (metadataObj != null && Build.VERSION.SDK_INT >= 21) {
|
if (metadataObj != null) {
|
||||||
Parcel p = Parcel.obtain();
|
Parcel p = Parcel.obtain();
|
||||||
((MediaMetadata) metadataObj).writeToParcel(p, 0);
|
((MediaMetadata) metadataObj).writeToParcel(p, 0);
|
||||||
p.setDataPosition(0);
|
p.setDataPosition(0);
|
||||||
|
@ -47,7 +47,6 @@ import android.os.Binder;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
@ -459,26 +458,20 @@ public class MediaSessionCompat {
|
|||||||
Build.VERSION.SDK_INT >= 31 ? PendingIntent.FLAG_MUTABLE : 0);
|
Build.VERSION.SDK_INT >= 31 ? PendingIntent.FLAG_MUTABLE : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
if (android.os.Build.VERSION.SDK_INT >= 29) {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 29) {
|
mImpl = new MediaSessionImplApi29(context, tag, session2Token, sessionInfo);
|
||||||
mImpl = new MediaSessionImplApi29(context, tag, session2Token, sessionInfo);
|
} else if (android.os.Build.VERSION.SDK_INT >= 28) {
|
||||||
} else if (android.os.Build.VERSION.SDK_INT >= 28) {
|
mImpl = new MediaSessionImplApi28(context, tag, session2Token, sessionInfo);
|
||||||
mImpl = new MediaSessionImplApi28(context, tag, session2Token, sessionInfo);
|
} else if (android.os.Build.VERSION.SDK_INT >= 22) {
|
||||||
} else if (android.os.Build.VERSION.SDK_INT >= 22) {
|
mImpl = new MediaSessionImplApi22(context, tag, session2Token, sessionInfo);
|
||||||
mImpl = new MediaSessionImplApi22(context, tag, session2Token, sessionInfo);
|
|
||||||
} else {
|
|
||||||
mImpl = new MediaSessionImplApi21(context, tag, session2Token, sessionInfo);
|
|
||||||
}
|
|
||||||
// Set default callback to respond to controllers' extra binder requests.
|
|
||||||
Looper myLooper = Looper.myLooper();
|
|
||||||
Handler handler = new Handler(myLooper != null ? myLooper : Looper.getMainLooper());
|
|
||||||
setCallback(new Callback() {}, handler);
|
|
||||||
mImpl.setMediaButtonReceiver(mbrIntent);
|
|
||||||
} else {
|
} else {
|
||||||
mImpl =
|
mImpl = new MediaSessionImplApi21(context, tag, session2Token, sessionInfo);
|
||||||
new MediaSessionImplApi19(
|
|
||||||
context, tag, mbrComponent, mbrIntent, session2Token, sessionInfo);
|
|
||||||
}
|
}
|
||||||
|
// Set default callback to respond to controllers' extra binder requests.
|
||||||
|
Looper myLooper = Looper.myLooper();
|
||||||
|
Handler handler = new Handler(myLooper != null ? myLooper : Looper.getMainLooper());
|
||||||
|
setCallback(new Callback() {}, handler);
|
||||||
|
mImpl.setMediaButtonReceiver(mbrIntent);
|
||||||
mController = new MediaControllerCompat(context, this);
|
mController = new MediaControllerCompat(context, this);
|
||||||
|
|
||||||
if (sMaxBitmapSize == 0) {
|
if (sMaxBitmapSize == 0) {
|
||||||
@ -915,7 +908,7 @@ public class MediaSessionCompat {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static MediaSessionCompat fromMediaSession(
|
public static MediaSessionCompat fromMediaSession(
|
||||||
@Nullable Context context, @Nullable Object mediaSession) {
|
@Nullable Context context, @Nullable Object mediaSession) {
|
||||||
if (Build.VERSION.SDK_INT < 21 || context == null || mediaSession == null) {
|
if (context == null || mediaSession == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
MediaSessionImpl impl;
|
MediaSessionImpl impl;
|
||||||
@ -1001,7 +994,8 @@ public class MediaSessionCompat {
|
|||||||
*/
|
*/
|
||||||
public abstract static class Callback {
|
public abstract static class Callback {
|
||||||
final Object mLock = new Object();
|
final Object mLock = new Object();
|
||||||
@Nullable final MediaSession.Callback mCallbackFwk;
|
@androidx.annotation.NonNull
|
||||||
|
final MediaSession.Callback mCallbackFwk;
|
||||||
private boolean mMediaPlayPausePendingOnHandler;
|
private boolean mMediaPlayPausePendingOnHandler;
|
||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
@ -1013,11 +1007,7 @@ public class MediaSessionCompat {
|
|||||||
CallbackHandler mCallbackHandler;
|
CallbackHandler mCallbackHandler;
|
||||||
|
|
||||||
public Callback() {
|
public Callback() {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
mCallbackFwk = new MediaSessionCallbackApi21();
|
||||||
mCallbackFwk = new MediaSessionCallbackApi21();
|
|
||||||
} else {
|
|
||||||
mCallbackFwk = null;
|
|
||||||
}
|
|
||||||
mSessionImpl = new WeakReference<>(null);
|
mSessionImpl = new WeakReference<>(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1845,11 +1835,7 @@ public class MediaSessionCompat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
dest.writeParcelable((Parcelable) mInner, flags);
|
||||||
dest.writeParcelable((Parcelable) mInner, flags);
|
|
||||||
} else {
|
|
||||||
dest.writeStrongBinder((IBinder) mInner);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1963,12 +1949,7 @@ public class MediaSessionCompat {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public Token createFromParcel(Parcel in) {
|
public Token createFromParcel(Parcel in) {
|
||||||
Object inner;
|
Object inner = in.readParcelable(null);
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
|
||||||
inner = in.readParcelable(null);
|
|
||||||
} else {
|
|
||||||
inner = in.readStrongBinder();
|
|
||||||
}
|
|
||||||
return new Token(checkNotNull(inner));
|
return new Token(checkNotNull(inner));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2048,13 +2029,11 @@ public class MediaSessionCompat {
|
|||||||
/**
|
/**
|
||||||
* Gets the underlying {@link android.media.session.MediaSession.QueueItem}.
|
* Gets the underlying {@link android.media.session.MediaSession.QueueItem}.
|
||||||
*
|
*
|
||||||
* <p>On builds before {@link android.os.Build.VERSION_CODES#LOLLIPOP} null is returned.
|
* @return The underlying {@link android.media.session.MediaSession.QueueItem}.
|
||||||
*
|
|
||||||
* @return The underlying {@link android.media.session.MediaSession.QueueItem} or null.
|
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@androidx.annotation.NonNull
|
||||||
public Object getQueueItem() {
|
public Object getQueueItem() {
|
||||||
if (mItemFwk != null || android.os.Build.VERSION.SDK_INT < 21) {
|
if (mItemFwk != null) {
|
||||||
return mItemFwk;
|
return mItemFwk;
|
||||||
}
|
}
|
||||||
mItemFwk =
|
mItemFwk =
|
||||||
@ -2082,15 +2061,13 @@ public class MediaSessionCompat {
|
|||||||
* Creates a list of {@link QueueItem} objects from a framework {@link
|
* Creates a list of {@link QueueItem} objects from a framework {@link
|
||||||
* android.media.session.MediaSession.QueueItem} object list.
|
* android.media.session.MediaSession.QueueItem} object list.
|
||||||
*
|
*
|
||||||
* <p>This method is only supported on API 21+. On API 20 and below, it returns null.
|
|
||||||
*
|
|
||||||
* @param itemList A list of {@link android.media.session.MediaSession.QueueItem} objects.
|
* @param itemList A list of {@link android.media.session.MediaSession.QueueItem} objects.
|
||||||
* @return An equivalent list of {@link QueueItem} objects, or null if none.
|
* @return An equivalent list of {@link QueueItem} objects, or null if none.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static List<QueueItem> fromQueueItemList(
|
public static List<QueueItem> fromQueueItemList(
|
||||||
@Nullable List<? extends @NonNull Object> itemList) {
|
@Nullable List<? extends @NonNull Object> itemList) {
|
||||||
if (itemList == null || Build.VERSION.SDK_INT < 21) {
|
if (itemList == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<QueueItem> items = new ArrayList<>(itemList.size());
|
List<QueueItem> items = new ArrayList<>(itemList.size());
|
||||||
|
@ -71,10 +71,8 @@ public final class MediaSessionManager {
|
|||||||
private MediaSessionManager(Context context) {
|
private MediaSessionManager(Context context) {
|
||||||
if (Build.VERSION.SDK_INT >= 28) {
|
if (Build.VERSION.SDK_INT >= 28) {
|
||||||
mImpl = new MediaSessionManagerImplApi28(context);
|
mImpl = new MediaSessionManagerImplApi28(context);
|
||||||
} else if (Build.VERSION.SDK_INT >= 21) {
|
|
||||||
mImpl = new MediaSessionManagerImplApi21(context);
|
|
||||||
} else {
|
} else {
|
||||||
mImpl = new MediaSessionManagerImplBase(context);
|
mImpl = new MediaSessionManagerImplApi21(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -847,7 +847,7 @@ public final class PlaybackStateCompat implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static PlaybackStateCompat fromPlaybackState(@Nullable Object stateObj) {
|
public static PlaybackStateCompat fromPlaybackState(@Nullable Object stateObj) {
|
||||||
if (stateObj != null && Build.VERSION.SDK_INT >= 21) {
|
if (stateObj != null) {
|
||||||
PlaybackState stateFwk = (PlaybackState) stateObj;
|
PlaybackState stateFwk = (PlaybackState) stateObj;
|
||||||
List<PlaybackState.CustomAction> customActionFwks = stateFwk.getCustomActions();
|
List<PlaybackState.CustomAction> customActionFwks = stateFwk.getCustomActions();
|
||||||
List<PlaybackStateCompat.CustomAction> customActions = null;
|
List<PlaybackStateCompat.CustomAction> customActions = null;
|
||||||
@ -896,7 +896,7 @@ public final class PlaybackStateCompat implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Object getPlaybackState() {
|
public Object getPlaybackState() {
|
||||||
if (mStateFwk == null && Build.VERSION.SDK_INT >= 21) {
|
if (mStateFwk == null) {
|
||||||
PlaybackState.Builder builder = new PlaybackState.Builder()
|
PlaybackState.Builder builder = new PlaybackState.Builder()
|
||||||
.setState(mState, mPosition, mSpeed, mUpdateTime)
|
.setState(mState, mPosition, mSpeed, mUpdateTime)
|
||||||
.setBufferedPosition(mBufferedPosition)
|
.setBufferedPosition(mBufferedPosition)
|
||||||
@ -998,14 +998,12 @@ public final class PlaybackStateCompat implements Parcelable {
|
|||||||
* Gets the underlying framework {@link android.media.session.PlaybackState.CustomAction}
|
* Gets the underlying framework {@link android.media.session.PlaybackState.CustomAction}
|
||||||
* object.
|
* object.
|
||||||
*
|
*
|
||||||
* <p>This method is only supported on API 21+.
|
|
||||||
*
|
|
||||||
* @return An equivalent {@link android.media.session.PlaybackState.CustomAction} object, or
|
* @return An equivalent {@link android.media.session.PlaybackState.CustomAction} object, or
|
||||||
* null if none.
|
* null if none.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Object getCustomAction() {
|
public Object getCustomAction() {
|
||||||
if (mCustomActionFwk != null || Build.VERSION.SDK_INT < 21) {
|
if (mCustomActionFwk != null) {
|
||||||
return mCustomActionFwk;
|
return mCustomActionFwk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,10 +130,8 @@ public abstract class VolumeProviderCompat {
|
|||||||
*/
|
*/
|
||||||
public final void setCurrentVolume(int currentVolume) {
|
public final void setCurrentVolume(int currentVolume) {
|
||||||
mCurrentVolume = currentVolume;
|
mCurrentVolume = currentVolume;
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
VolumeProvider volumeProviderFwk = (VolumeProvider) getVolumeProvider();
|
||||||
VolumeProvider volumeProviderFwk = (VolumeProvider) getVolumeProvider();
|
volumeProviderFwk.setCurrentVolume(currentVolume);
|
||||||
volumeProviderFwk.setCurrentVolume(currentVolume);
|
|
||||||
}
|
|
||||||
if (mCallback != null) {
|
if (mCallback != null) {
|
||||||
mCallback.onVolumeChanged(this);
|
mCallback.onVolumeChanged(this);
|
||||||
}
|
}
|
||||||
|
@ -237,16 +237,10 @@ import java.util.ArrayList;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderOutputBuffer(MediaCodecAdapter codec, int index, long presentationTimeUs) {
|
protected void renderOutputBuffer(
|
||||||
skipToPositionBeforeRenderingFirstFrame = false;
|
|
||||||
super.renderOutputBuffer(codec, index, presentationTimeUs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderOutputBufferV21(
|
|
||||||
MediaCodecAdapter codec, int index, long presentationTimeUs, long releaseTimeNs) {
|
MediaCodecAdapter codec, int index, long presentationTimeUs, long releaseTimeNs) {
|
||||||
skipToPositionBeforeRenderingFirstFrame = false;
|
skipToPositionBeforeRenderingFirstFrame = false;
|
||||||
super.renderOutputBufferV21(codec, index, presentationTimeUs, releaseTimeNs);
|
super.renderOutputBuffer(codec, index, presentationTimeUs, releaseTimeNs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,6 @@ import static org.hamcrest.core.IsNot.not;
|
|||||||
|
|
||||||
import android.media.AudioAttributes;
|
import android.media.AudioAttributes;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.Build;
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import androidx.test.filters.SdkSuppress;
|
import androidx.test.filters.SdkSuppress;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@ -54,9 +53,6 @@ public class AudioAttributesCompatTest {
|
|||||||
@Before
|
@Before
|
||||||
@SdkSuppress(minSdkVersion = 21)
|
@SdkSuppress(minSdkVersion = 21)
|
||||||
public void setUpApi21() {
|
public void setUpApi21() {
|
||||||
if (Build.VERSION.SDK_INT < 21) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mMediaAA =
|
mMediaAA =
|
||||||
new AudioAttributes.Builder()
|
new AudioAttributes.Builder()
|
||||||
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
|
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
|
||||||
|
@ -35,7 +35,6 @@ import androidx.media3.common.Format;
|
|||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
import androidx.media3.common.util.MediaFormatUtil;
|
import androidx.media3.common.util.MediaFormatUtil;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.common.util.Util;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
@ -209,7 +208,7 @@ public final class DecodeOneFrameUtil {
|
|||||||
// Format must not include KEY_FRAME_RATE on API21.
|
// Format must not include KEY_FRAME_RATE on API21.
|
||||||
// https://developer.android.com/reference/android/media/MediaCodecList#findDecoderForFormat(android.media.MediaFormat)
|
// https://developer.android.com/reference/android/media/MediaCodecList#findDecoderForFormat(android.media.MediaFormat)
|
||||||
float frameRate = Format.NO_VALUE;
|
float frameRate = Format.NO_VALUE;
|
||||||
if (Util.SDK_INT == 21 && format.containsKey(MediaFormat.KEY_FRAME_RATE)) {
|
if (format.containsKey(MediaFormat.KEY_FRAME_RATE)) {
|
||||||
try {
|
try {
|
||||||
frameRate = format.getFloat(MediaFormat.KEY_FRAME_RATE);
|
frameRate = format.getFloat(MediaFormat.KEY_FRAME_RATE);
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
@ -221,9 +220,7 @@ public final class DecodeOneFrameUtil {
|
|||||||
|
|
||||||
@Nullable String mediaCodecName = mediaCodecList.findDecoderForFormat(format);
|
@Nullable String mediaCodecName = mediaCodecList.findDecoderForFormat(format);
|
||||||
|
|
||||||
if (Util.SDK_INT == 21) {
|
MediaFormatUtil.maybeSetInteger(format, MediaFormat.KEY_FRAME_RATE, round(frameRate));
|
||||||
MediaFormatUtil.maybeSetInteger(format, MediaFormat.KEY_FRAME_RATE, round(frameRate));
|
|
||||||
}
|
|
||||||
return mediaCodecName;
|
return mediaCodecName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,16 +102,15 @@ public final class ExoplayerEffectPlaybackSeekTest {
|
|||||||
new MediaCodecVideoRenderer(context, MediaCodecSelector.DEFAULT) {
|
new MediaCodecVideoRenderer(context, MediaCodecSelector.DEFAULT) {
|
||||||
private int numberOfFramesRendered;
|
private int numberOfFramesRendered;
|
||||||
|
|
||||||
// Overriding V21 is sufficient as we don't have test running below API26.
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderOutputBufferV21(
|
protected void renderOutputBuffer(
|
||||||
MediaCodecAdapter codec, int index, long presentationTimeUs, long releaseTimeNs) {
|
MediaCodecAdapter codec, int index, long presentationTimeUs, long releaseTimeNs) {
|
||||||
numberOfFramesRendered++;
|
numberOfFramesRendered++;
|
||||||
if (numberOfFramesRendered == frameIndexToSkip) {
|
if (numberOfFramesRendered == frameIndexToSkip) {
|
||||||
frameSkippedCondition.open();
|
frameSkippedCondition.open();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.renderOutputBufferV21(codec, index, presentationTimeUs, releaseTimeNs);
|
super.renderOutputBuffer(codec, index, presentationTimeUs, releaseTimeNs);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ public final class EncoderUtil {
|
|||||||
// Format must not include KEY_FRAME_RATE on API21.
|
// Format must not include KEY_FRAME_RATE on API21.
|
||||||
// https://developer.android.com/reference/android/media/MediaCodecList#findDecoderForFormat(android.media.MediaFormat)
|
// https://developer.android.com/reference/android/media/MediaCodecList#findDecoderForFormat(android.media.MediaFormat)
|
||||||
float frameRate = Format.NO_VALUE;
|
float frameRate = Format.NO_VALUE;
|
||||||
if (Util.SDK_INT == 21 && format.containsKey(MediaFormat.KEY_FRAME_RATE)) {
|
if (format.containsKey(MediaFormat.KEY_FRAME_RATE)) {
|
||||||
try {
|
try {
|
||||||
frameRate = format.getFloat(MediaFormat.KEY_FRAME_RATE);
|
frameRate = format.getFloat(MediaFormat.KEY_FRAME_RATE);
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
@ -328,9 +328,7 @@ public final class EncoderUtil {
|
|||||||
? mediaCodecList.findDecoderForFormat(format)
|
? mediaCodecList.findDecoderForFormat(format)
|
||||||
: mediaCodecList.findEncoderForFormat(format);
|
: mediaCodecList.findEncoderForFormat(format);
|
||||||
|
|
||||||
if (Util.SDK_INT == 21) {
|
MediaFormatUtil.maybeSetInteger(format, MediaFormat.KEY_FRAME_RATE, round(frameRate));
|
||||||
MediaFormatUtil.maybeSetInteger(format, MediaFormat.KEY_FRAME_RATE, round(frameRate));
|
|
||||||
}
|
|
||||||
return mediaCodecName;
|
return mediaCodecName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ import android.content.ComponentName
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.media.session.MediaSessionManager as ActiveSessionManager
|
import android.media.session.MediaSessionManager as ActiveSessionManager
|
||||||
import android.os.Build
|
|
||||||
import android.os.Build.VERSION_CODES
|
import android.os.Build.VERSION_CODES
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.service.notification.NotificationListenerService
|
import android.service.notification.NotificationListenerService
|
||||||
@ -75,10 +74,7 @@ class LaunchActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
|
activeSessionListener = ActiveSessionListener()
|
||||||
activeSessionListener = ActiveSessionListener()
|
|
||||||
}
|
|
||||||
|
|
||||||
mediaSessionApps = mediaAppListAdapter.addSection(R.string.media_app_header_media_service)
|
mediaSessionApps = mediaAppListAdapter.addSection(R.string.media_app_header_media_service)
|
||||||
|
|
||||||
val mediaAppsList: RecyclerView? = findViewById(R.id.app_list)
|
val mediaAppsList: RecyclerView? = findViewById(R.id.app_list)
|
||||||
@ -90,9 +86,7 @@ class LaunchActivity : AppCompatActivity() {
|
|||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
|
activeSessionListener!!.onStart()
|
||||||
activeSessionListener!!.onStart()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finds apps that implement MediaSessionService, MediaLibraryService, or
|
// Finds apps that implement MediaSessionService, MediaLibraryService, or
|
||||||
// MediaBrowserServiceCompat.
|
// MediaBrowserServiceCompat.
|
||||||
@ -102,9 +96,7 @@ class LaunchActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
super.onStop()
|
super.onStop()
|
||||||
if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
|
activeSessionListener!!.onStop()
|
||||||
activeSessionListener!!.onStop()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user