Remove incomplete media router API. (DO NOT MERGE)
Change-Id: I310fadafb5a6b8190a32e5d87f3e1823c87bcef7
This commit is contained in:
@@ -330,12 +330,6 @@ LOCAL_SRC_FILES += \
|
||||
media/java/android/media/projection/IMediaProjectionCallback.aidl \
|
||||
media/java/android/media/projection/IMediaProjectionManager.aidl \
|
||||
media/java/android/media/projection/IMediaProjectionWatcherCallback.aidl \
|
||||
media/java/android/media/routing/IMediaRouteService.aidl \
|
||||
media/java/android/media/routing/IMediaRouteClientCallback.aidl \
|
||||
media/java/android/media/routing/IMediaRouter.aidl \
|
||||
media/java/android/media/routing/IMediaRouterDelegate.aidl \
|
||||
media/java/android/media/routing/IMediaRouterRoutingCallback.aidl \
|
||||
media/java/android/media/routing/IMediaRouterStateCallback.aidl \
|
||||
media/java/android/media/session/IActiveSessionsListener.aidl \
|
||||
media/java/android/media/session/ISessionController.aidl \
|
||||
media/java/android/media/session/ISessionControllerCallback.aidl \
|
||||
@@ -497,7 +491,6 @@ aidl_files := \
|
||||
frameworks/base/location/java/com/android/internal/location/ProviderRequest.aidl \
|
||||
frameworks/base/media/java/android/media/MediaMetadata.aidl \
|
||||
frameworks/base/media/java/android/media/Rating.aidl \
|
||||
frameworks/base/media/java/android/media/routing/MediaRouteSelector.aidl \
|
||||
frameworks/base/media/java/android/media/session/MediaSession.aidl \
|
||||
frameworks/base/media/java/android/media/session/PlaybackState.aidl \
|
||||
frameworks/base/telephony/java/android/telephony/ServiceState.aidl \
|
||||
|
||||
239
api/current.txt
239
api/current.txt
@@ -23,7 +23,6 @@ package android {
|
||||
field public static final java.lang.String BIND_DEVICE_ADMIN = "android.permission.BIND_DEVICE_ADMIN";
|
||||
field public static final java.lang.String BIND_DREAM_SERVICE = "android.permission.BIND_DREAM_SERVICE";
|
||||
field public static final java.lang.String BIND_INPUT_METHOD = "android.permission.BIND_INPUT_METHOD";
|
||||
field public static final java.lang.String BIND_MEDIA_ROUTE_SERVICE = "android.permission.BIND_MEDIA_ROUTE_SERVICE";
|
||||
field public static final java.lang.String BIND_NFC_SERVICE = "android.permission.BIND_NFC_SERVICE";
|
||||
field public static final java.lang.String BIND_NOTIFICATION_LISTENER_SERVICE = "android.permission.BIND_NOTIFICATION_LISTENER_SERVICE";
|
||||
field public static final java.lang.String BIND_PRINT_SERVICE = "android.permission.BIND_PRINT_SERVICE";
|
||||
@@ -16380,242 +16379,6 @@ package android.media.projection {
|
||||
|
||||
}
|
||||
|
||||
package android.media.routing {
|
||||
|
||||
public final class MediaRouteSelector implements android.os.Parcelable {
|
||||
method public boolean containsProtocol(java.lang.Class<?>);
|
||||
method public boolean containsProtocol(java.lang.String);
|
||||
method public int describeContents();
|
||||
method public android.os.Bundle getExtras();
|
||||
method public int getOptionalFeatures();
|
||||
method public java.util.List<java.lang.String> getOptionalProtocols();
|
||||
method public int getRequiredFeatures();
|
||||
method public java.util.List<java.lang.String> getRequiredProtocols();
|
||||
method public java.lang.String getServicePackageName();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator CREATOR;
|
||||
}
|
||||
|
||||
public static final class MediaRouteSelector.Builder {
|
||||
ctor public MediaRouteSelector.Builder();
|
||||
method public android.media.routing.MediaRouteSelector.Builder addOptionalProtocol(java.lang.Class<?>);
|
||||
method public android.media.routing.MediaRouteSelector.Builder addOptionalProtocol(java.lang.String);
|
||||
method public android.media.routing.MediaRouteSelector.Builder addRequiredProtocol(java.lang.Class<?>);
|
||||
method public android.media.routing.MediaRouteSelector.Builder addRequiredProtocol(java.lang.String);
|
||||
method public android.media.routing.MediaRouteSelector build();
|
||||
method public android.media.routing.MediaRouteSelector.Builder setExtras(android.os.Bundle);
|
||||
method public android.media.routing.MediaRouteSelector.Builder setOptionalFeatures(int);
|
||||
method public android.media.routing.MediaRouteSelector.Builder setRequiredFeatures(int);
|
||||
method public android.media.routing.MediaRouteSelector.Builder setServicePackageName(java.lang.String);
|
||||
}
|
||||
|
||||
public abstract class MediaRouteService extends android.app.Service {
|
||||
ctor public MediaRouteService();
|
||||
method public android.media.routing.MediaRouter.ServiceMetadata getServiceMetadata();
|
||||
method public android.os.IBinder onBind(android.content.Intent);
|
||||
method public abstract android.media.routing.MediaRouteService.ClientSession onCreateClientSession(android.media.routing.MediaRouteService.ClientInfo);
|
||||
field public static final java.lang.String SERVICE_INTERFACE = "android.media.routing.MediaRouteService";
|
||||
}
|
||||
|
||||
public static final class MediaRouteService.ClientInfo {
|
||||
method public java.lang.String getPackageName();
|
||||
method public int getUid();
|
||||
}
|
||||
|
||||
public static abstract class MediaRouteService.ClientSession {
|
||||
ctor public MediaRouteService.ClientSession();
|
||||
method public abstract boolean onConnect(android.media.routing.MediaRouter.ConnectionRequest, android.media.routing.MediaRouteService.ConnectionCallback);
|
||||
method public abstract void onDisconnect();
|
||||
method public void onPauseStream();
|
||||
method public void onRelease();
|
||||
method public void onResumeStream();
|
||||
method public abstract boolean onStartDiscovery(android.media.routing.MediaRouter.DiscoveryRequest, android.media.routing.MediaRouteService.DiscoveryCallback);
|
||||
method public abstract void onStopDiscovery();
|
||||
}
|
||||
|
||||
public final class MediaRouteService.ConnectionCallback {
|
||||
method public void onConnected(android.media.routing.MediaRouter.ConnectionInfo);
|
||||
method public void onConnectionFailed(int, java.lang.CharSequence, android.os.Bundle);
|
||||
method public void onDisconnected();
|
||||
}
|
||||
|
||||
public final class MediaRouteService.DiscoveryCallback {
|
||||
method public void onDestinationFound(android.media.routing.MediaRouter.DestinationInfo, java.util.List<android.media.routing.MediaRouter.RouteInfo>);
|
||||
method public void onDestinationLost(android.media.routing.MediaRouter.DestinationInfo);
|
||||
method public void onDiscoveryFailed(int, java.lang.CharSequence, android.os.Bundle);
|
||||
}
|
||||
|
||||
public final class MediaRouter {
|
||||
ctor public MediaRouter(android.content.Context);
|
||||
method public void addSelector(android.media.routing.MediaRouteSelector);
|
||||
method public void clearSelectors();
|
||||
method public android.media.routing.MediaRouter.Delegate createDelegate();
|
||||
method public android.media.routing.MediaRouter.ConnectionInfo getConnection();
|
||||
method public int getConnectionState();
|
||||
method public java.util.List<android.media.routing.MediaRouter.DestinationInfo> getDiscoveredDestinations();
|
||||
method public java.util.List<android.media.routing.MediaRouter.RouteInfo> getDiscoveredRoutes(android.media.routing.MediaRouter.DestinationInfo);
|
||||
method public int getDiscoveryState();
|
||||
method public android.media.AudioAttributes getPreferredAudioAttributes();
|
||||
method public android.view.Display getPreferredPresentationDisplay();
|
||||
method public android.media.VolumeProvider getPreferredVolumeProvider();
|
||||
method public android.media.routing.MediaRouter.DestinationInfo getSelectedDestination();
|
||||
method public android.media.routing.MediaRouter.RouteInfo getSelectedRoute();
|
||||
method public java.util.List<android.media.routing.MediaRouteSelector> getSelectors();
|
||||
method public boolean isReleased();
|
||||
method public void pauseStream();
|
||||
method public void release();
|
||||
method public void removeSelector(android.media.routing.MediaRouteSelector);
|
||||
method public void resumeStream();
|
||||
method public void setRoutingCallback(android.media.routing.MediaRouter.RoutingCallback, android.os.Handler);
|
||||
field public static final int CONNECTION_ERROR_ABORTED = 1; // 0x1
|
||||
field public static final int CONNECTION_ERROR_BARGED = 7; // 0x7
|
||||
field public static final int CONNECTION_ERROR_BROKEN = 6; // 0x6
|
||||
field public static final int CONNECTION_ERROR_BUSY = 4; // 0x4
|
||||
field public static final int CONNECTION_ERROR_TIMEOUT = 5; // 0x5
|
||||
field public static final int CONNECTION_ERROR_UNAUTHORIZED = 2; // 0x2
|
||||
field public static final int CONNECTION_ERROR_UNKNOWN = 0; // 0x0
|
||||
field public static final int CONNECTION_ERROR_UNREACHABLE = 3; // 0x3
|
||||
field public static final int CONNECTION_FLAG_BARGE = 1; // 0x1
|
||||
field public static final int CONNECTION_STATE_CONNECTED = 2; // 0x2
|
||||
field public static final int CONNECTION_STATE_CONNECTING = 1; // 0x1
|
||||
field public static final int CONNECTION_STATE_DISCONNECTED = 0; // 0x0
|
||||
field public static final int DISCONNECTION_REASON_APPLICATION_REQUEST = 0; // 0x0
|
||||
field public static final int DISCONNECTION_REASON_ERROR = 2; // 0x2
|
||||
field public static final int DISCONNECTION_REASON_USER_REQUEST = 1; // 0x1
|
||||
field public static final int DISCOVERY_ERROR_ABORTED = 1; // 0x1
|
||||
field public static final int DISCOVERY_ERROR_NO_CONNECTIVITY = 2; // 0x2
|
||||
field public static final int DISCOVERY_ERROR_UNKNOWN = 0; // 0x0
|
||||
field public static final int DISCOVERY_FLAG_BACKGROUND = 1; // 0x1
|
||||
field public static final int DISCOVERY_STATE_STARTED = 1; // 0x1
|
||||
field public static final int DISCOVERY_STATE_STOPPED = 0; // 0x0
|
||||
field public static final int ROUTE_FEATURE_LIVE_AUDIO = 1; // 0x1
|
||||
field public static final int ROUTE_FEATURE_LIVE_VIDEO = 2; // 0x2
|
||||
}
|
||||
|
||||
public static final class MediaRouter.ConnectionInfo {
|
||||
method public android.media.AudioAttributes getAudioAttributes();
|
||||
method public android.os.Bundle getExtras();
|
||||
method public int getFeatures();
|
||||
method public android.view.Display getPresentationDisplay();
|
||||
method public android.os.IBinder getProtocolBinder(java.lang.String);
|
||||
method public android.os.IBinder getProtocolBinder(int);
|
||||
method public T getProtocolObject(java.lang.Class<T>);
|
||||
method public java.util.List<java.lang.String> getProtocols();
|
||||
method public android.media.routing.MediaRouter.RouteInfo getRoute();
|
||||
method public android.media.VolumeProvider getVolumeProvider();
|
||||
}
|
||||
|
||||
public static final class MediaRouter.ConnectionInfo.Builder {
|
||||
ctor public MediaRouter.ConnectionInfo.Builder(android.media.routing.MediaRouter.RouteInfo);
|
||||
method public android.media.routing.MediaRouter.ConnectionInfo build();
|
||||
method public android.media.routing.MediaRouter.ConnectionInfo.Builder setAudioAttributes(android.media.AudioAttributes);
|
||||
method public android.media.routing.MediaRouter.ConnectionInfo.Builder setExtras(android.os.Bundle);
|
||||
method public android.media.routing.MediaRouter.ConnectionInfo.Builder setPresentationDisplay(android.view.Display);
|
||||
method public android.media.routing.MediaRouter.ConnectionInfo.Builder setProtocolBinder(java.lang.String, android.os.IBinder);
|
||||
method public android.media.routing.MediaRouter.ConnectionInfo.Builder setProtocolStub(java.lang.Class<?>, android.os.IInterface);
|
||||
method public android.media.routing.MediaRouter.ConnectionInfo.Builder setVolumeProvider(android.media.VolumeProvider);
|
||||
}
|
||||
|
||||
public static final class MediaRouter.ConnectionRequest {
|
||||
method public android.os.Bundle getExtras();
|
||||
method public int getFlags();
|
||||
method public android.media.routing.MediaRouter.RouteInfo getRoute();
|
||||
method public void setExtras(android.os.Bundle);
|
||||
method public void setFlags(int);
|
||||
method public void setRoute(android.media.routing.MediaRouter.RouteInfo);
|
||||
}
|
||||
|
||||
public static final class MediaRouter.Delegate {
|
||||
ctor public MediaRouter.Delegate();
|
||||
method public void addStateCallback(android.media.routing.MediaRouter.StateCallback, android.os.Handler);
|
||||
method public void connect(android.media.routing.MediaRouter.DestinationInfo, int);
|
||||
method public void disconnect(int);
|
||||
method public int getConnectionState();
|
||||
method public java.util.List<android.media.routing.MediaRouter.DestinationInfo> getDiscoveredDestinations();
|
||||
method public int getDiscoveryState();
|
||||
method public android.media.routing.MediaRouter.DestinationInfo getSelectedDestination();
|
||||
method public boolean isReleased();
|
||||
method public void removeStateCallback(android.media.routing.MediaRouter.StateCallback);
|
||||
method public void startDiscovery(int);
|
||||
method public void stopDiscovery();
|
||||
}
|
||||
|
||||
public static final class MediaRouter.DestinationInfo {
|
||||
method public java.lang.CharSequence getDescription();
|
||||
method public android.os.Bundle getExtras();
|
||||
method public int getIconResourceId();
|
||||
method public java.lang.String getId();
|
||||
method public java.lang.CharSequence getName();
|
||||
method public android.media.routing.MediaRouter.ServiceMetadata getServiceMetadata();
|
||||
method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager);
|
||||
}
|
||||
|
||||
public static final class MediaRouter.DestinationInfo.Builder {
|
||||
ctor public MediaRouter.DestinationInfo.Builder(java.lang.String, android.media.routing.MediaRouter.ServiceMetadata, java.lang.CharSequence);
|
||||
method public android.media.routing.MediaRouter.DestinationInfo build();
|
||||
method public android.media.routing.MediaRouter.DestinationInfo.Builder setDescription(java.lang.CharSequence);
|
||||
method public android.media.routing.MediaRouter.DestinationInfo.Builder setExtras(android.os.Bundle);
|
||||
method public android.media.routing.MediaRouter.DestinationInfo.Builder setIconResourceId(int);
|
||||
}
|
||||
|
||||
public static final class MediaRouter.DiscoveryRequest {
|
||||
method public int getFlags();
|
||||
method public java.util.List<android.media.routing.MediaRouteSelector> getSelectors();
|
||||
method public void setFlags(int);
|
||||
method public void setSelectors(java.util.List<android.media.routing.MediaRouteSelector>);
|
||||
}
|
||||
|
||||
public static final class MediaRouter.RouteInfo {
|
||||
method public android.media.routing.MediaRouter.DestinationInfo getDestination();
|
||||
method public android.os.Bundle getExtras();
|
||||
method public int getFeatures();
|
||||
method public java.lang.String getId();
|
||||
method public java.util.List<java.lang.String> getProtocols();
|
||||
method public android.media.routing.MediaRouteSelector getSelector();
|
||||
}
|
||||
|
||||
public static final class MediaRouter.RouteInfo.Builder {
|
||||
ctor public MediaRouter.RouteInfo.Builder(java.lang.String, android.media.routing.MediaRouter.DestinationInfo, android.media.routing.MediaRouteSelector);
|
||||
method public android.media.routing.MediaRouter.RouteInfo.Builder addProtocol(java.lang.Class<T>);
|
||||
method public android.media.routing.MediaRouter.RouteInfo.Builder addProtocol(java.lang.String);
|
||||
method public android.media.routing.MediaRouter.RouteInfo build();
|
||||
method public android.media.routing.MediaRouter.RouteInfo.Builder setExtras(android.os.Bundle);
|
||||
method public android.media.routing.MediaRouter.RouteInfo.Builder setFeatures(int);
|
||||
}
|
||||
|
||||
public static abstract class MediaRouter.RoutingCallback extends android.media.routing.MediaRouter.StateCallback {
|
||||
ctor public MediaRouter.RoutingCallback();
|
||||
method public boolean onPrepareConnectionRequest(android.media.routing.MediaRouter.ConnectionRequest, android.media.routing.MediaRouter.DestinationInfo, java.util.List<android.media.routing.MediaRouter.RouteInfo>);
|
||||
method public boolean onPrepareDiscoveryRequest(android.media.routing.MediaRouter.DiscoveryRequest, java.util.List<android.media.routing.MediaRouteSelector>);
|
||||
}
|
||||
|
||||
public static final class MediaRouter.ServiceMetadata {
|
||||
method public android.content.ComponentName getComponentName();
|
||||
method public android.graphics.drawable.Drawable getIcon(android.content.pm.PackageManager);
|
||||
method public java.lang.CharSequence getLabel(android.content.pm.PackageManager);
|
||||
method public java.lang.String getPackageName();
|
||||
method public android.content.pm.ServiceInfo getService();
|
||||
}
|
||||
|
||||
public static abstract class MediaRouter.StateCallback {
|
||||
ctor public MediaRouter.StateCallback();
|
||||
method public void onConnected();
|
||||
method public void onConnecting();
|
||||
method public void onConnectionFailed(int, java.lang.CharSequence, android.os.Bundle);
|
||||
method public void onConnectionStateChanged(int);
|
||||
method public void onDestinationFound(android.media.routing.MediaRouter.DestinationInfo);
|
||||
method public void onDestinationLost(android.media.routing.MediaRouter.DestinationInfo);
|
||||
method public void onDisconnected();
|
||||
method public void onDiscoveryFailed(int, java.lang.CharSequence, android.os.Bundle);
|
||||
method public void onDiscoveryStarted();
|
||||
method public void onDiscoveryStateChanged(int);
|
||||
method public void onDiscoveryStopped();
|
||||
method public void onReleased();
|
||||
method public void onSelectedDestinationChanged(android.media.routing.MediaRouter.DestinationInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.media.session {
|
||||
|
||||
public final class MediaController {
|
||||
@@ -16623,7 +16386,6 @@ package android.media.session {
|
||||
method public void addCallback(android.media.session.MediaController.Callback);
|
||||
method public void addCallback(android.media.session.MediaController.Callback, android.os.Handler);
|
||||
method public void adjustVolume(int, int);
|
||||
method public android.media.routing.MediaRouter.Delegate createMediaRouterDelegate();
|
||||
method public boolean dispatchMediaButtonEvent(android.view.KeyEvent);
|
||||
method public android.media.session.MediaController.AudioInfo getAudioInfo();
|
||||
method public android.os.Bundle getExtras();
|
||||
@@ -16693,7 +16455,6 @@ package android.media.session {
|
||||
method public void setFlags(int);
|
||||
method public void setLaunchActivity(android.app.PendingIntent);
|
||||
method public void setMediaButtonReceiver(android.app.PendingIntent);
|
||||
method public void setMediaRouter(android.media.routing.MediaRouter);
|
||||
method public void setMetadata(android.media.MediaMetadata);
|
||||
method public void setPlaybackState(android.media.session.PlaybackState);
|
||||
method public void setPlaybackToLocal(android.media.AudioAttributes);
|
||||
|
||||
@@ -305,7 +305,7 @@ public final class Settings {
|
||||
|
||||
/**
|
||||
* Activity Action: Show settings to allow configuration of
|
||||
* {@link android.media.routing.MediaRouteService media route providers}.
|
||||
* cast endpoints.
|
||||
* <p>
|
||||
* In some cases, a matching Activity may not exist, so ensure you
|
||||
* safeguard against this.
|
||||
|
||||
@@ -2210,14 +2210,6 @@
|
||||
android:description="@string/permdesc_modifyParentalControls"
|
||||
android:protectionLevel="signature" />
|
||||
|
||||
<!-- Must be required by a {@link android.media.routing.MediaRouteService}
|
||||
to ensure that only the system can interact with it.
|
||||
@hide -->
|
||||
<permission android:name="android.permission.BIND_ROUTE_PROVIDER"
|
||||
android:label="@string/permlab_bindRouteProvider"
|
||||
android:description="@string/permdesc_bindRouteProvider"
|
||||
android:protectionLevel="signature" />
|
||||
|
||||
<!-- Must be required by device administration receiver, to ensure that only the
|
||||
system can interact with it. -->
|
||||
<permission android:name="android.permission.BIND_DEVICE_ADMIN"
|
||||
@@ -2783,13 +2775,6 @@
|
||||
android:description="@string/permdesc_bindConditionProviderService"
|
||||
android:protectionLevel="signature" />
|
||||
|
||||
<!-- Must be required by a {@link android.media.routing.MediaRouteService},
|
||||
to ensure that only the system can bind to it. -->
|
||||
<permission android:name="android.permission.BIND_MEDIA_ROUTE_SERVICE"
|
||||
android:label="@string/permlab_bindMediaRouteService"
|
||||
android:description="@string/permdesc_bindMediaRouteService"
|
||||
android:protectionLevel="signature" />
|
||||
|
||||
<!-- Must be required by an {@link android.service.dreams.DreamService},
|
||||
to ensure that only the system can bind to it. -->
|
||||
<permission android:name="android.permission.BIND_DREAM_SERVICE"
|
||||
|
||||
@@ -1159,12 +1159,6 @@
|
||||
<string name="permdesc_bindRemoteViews">Allows the holder to bind to the top-level
|
||||
interface of a widget service. Should never be needed for normal apps.</string>
|
||||
|
||||
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||
<string name="permlab_bindRouteProvider">bind to a route provider service</string>
|
||||
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||
<string name="permdesc_bindRouteProvider">Allows the holder to bind to any registered
|
||||
route providers. Should never be needed for normal apps.</string>
|
||||
|
||||
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||
<string name="permlab_bindDeviceAdmin">interact with a device admin</string>
|
||||
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||
@@ -2156,11 +2150,6 @@
|
||||
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||
<string name="permdesc_bindConditionProviderService">Allows the holder to bind to the top-level interface of a condition provider service. Should never be needed for normal apps.</string>
|
||||
|
||||
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||
<string name="permlab_bindMediaRouteService">bind to a media route service</string>
|
||||
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||
<string name="permdesc_bindMediaRouteService">Allows the holder to bind to the top-level interface of a media route service. Should never be needed for normal apps.</string>
|
||||
|
||||
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||
<string name="permlab_bindDreamService">bind to a dream service</string>
|
||||
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.media.routing;
|
||||
|
||||
import android.media.routing.MediaRouteSelector;
|
||||
import android.media.routing.ParcelableConnectionInfo;
|
||||
import android.media.routing.ParcelableDestinationInfo;
|
||||
import android.media.routing.ParcelableRouteInfo;
|
||||
import android.os.IBinder;
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
oneway interface IMediaRouteClientCallback {
|
||||
void onDestinationFound(int seq, in ParcelableDestinationInfo destination,
|
||||
in ParcelableRouteInfo[] routes);
|
||||
|
||||
void onDestinationLost(int seq, String id);
|
||||
|
||||
void onDiscoveryFailed(int seq, int error, in CharSequence message, in Bundle extras);
|
||||
|
||||
void onConnected(int seq, in ParcelableConnectionInfo connection);
|
||||
|
||||
void onDisconnected(int seq);
|
||||
|
||||
void onConnectionFailed(int seq, int error, in CharSequence message, in Bundle extras);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.media.routing;
|
||||
|
||||
import android.media.routing.IMediaRouteClientCallback;
|
||||
import android.media.routing.MediaRouteSelector;
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* Interface to an app's MediaRouteService.
|
||||
* @hide
|
||||
*/
|
||||
oneway interface IMediaRouteService {
|
||||
void registerClient(int clientUid, String clientPackageName,
|
||||
in IMediaRouteClientCallback callback);
|
||||
|
||||
void unregisterClient(in IMediaRouteClientCallback callback);
|
||||
|
||||
void startDiscovery(in IMediaRouteClientCallback callback, int seq,
|
||||
in List<MediaRouteSelector> selectors, int flags);
|
||||
|
||||
void stopDiscovery(in IMediaRouteClientCallback callback);
|
||||
|
||||
void connect(in IMediaRouteClientCallback callback, int seq,
|
||||
String destinationId, String routeId, int flags, in Bundle extras);
|
||||
|
||||
void disconnect(in IMediaRouteClientCallback callback);
|
||||
|
||||
void pauseStream(in IMediaRouteClientCallback callback);
|
||||
|
||||
void resumeStream(in IMediaRouteClientCallback callback);
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.media.routing;
|
||||
|
||||
/** @hide */
|
||||
interface IMediaRouter {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.media.routing;
|
||||
|
||||
/** @hide */
|
||||
interface IMediaRouterDelegate {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.media.routing;
|
||||
|
||||
/** @hide */
|
||||
interface IMediaRouterRoutingCallback {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.media.routing;
|
||||
|
||||
/** @hide */
|
||||
interface IMediaRouterStateCallback {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/* Copyright 2014, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
package android.media.routing;
|
||||
|
||||
parcelable MediaRouteSelector;
|
||||
@@ -1,357 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package android.media.routing;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.media.routing.MediaRouter.RouteFeatures;
|
||||
import android.os.Bundle;
|
||||
import android.os.IInterface;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A media route selector consists of a set of constraints that are used to select
|
||||
* the routes to which an application would like to connect. The constraints consist
|
||||
* of a set of required or optional features and protocols. The constraints may also
|
||||
* require the use of a specific media route service package or additional characteristics
|
||||
* that are described by a bundle of extra parameters.
|
||||
* <p>
|
||||
* The application will typically create several different selectors that express
|
||||
* various combinations of characteristics that it would like to use together when
|
||||
* it connects to a destination media device. For each destination that is discovered,
|
||||
* media route services will publish some number of routes and include information
|
||||
* about which selector each route matches. The application will then choose among
|
||||
* these routes to determine which best satisfies its desired purpose and connect to it.
|
||||
* </p>
|
||||
*/
|
||||
public final class MediaRouteSelector implements Parcelable {
|
||||
private final int mRequiredFeatures;
|
||||
private final int mOptionalFeatures;
|
||||
private final List<String> mRequiredProtocols;
|
||||
private final List<String> mOptionalProtocols;
|
||||
private final String mServicePackageName;
|
||||
private final Bundle mExtras;
|
||||
|
||||
MediaRouteSelector(int requiredFeatures, int optionalFeatures,
|
||||
List<String> requiredProtocols, List<String> optionalProtocols,
|
||||
String servicePackageName, Bundle extras) {
|
||||
mRequiredFeatures = requiredFeatures;
|
||||
mOptionalFeatures = optionalFeatures;
|
||||
mRequiredProtocols = requiredProtocols;
|
||||
mOptionalProtocols = optionalProtocols;
|
||||
mServicePackageName = servicePackageName;
|
||||
mExtras = extras;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the set of required route features.
|
||||
*
|
||||
* @return A set of required route feature flags.
|
||||
*/
|
||||
public @RouteFeatures int getRequiredFeatures() {
|
||||
return mRequiredFeatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the set of optional route features.
|
||||
*
|
||||
* @return A set of optional route feature flags.
|
||||
*/
|
||||
public @RouteFeatures int getOptionalFeatures() {
|
||||
return mOptionalFeatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of route protocols that a route must support in order to be selected.
|
||||
* <p>
|
||||
* Refer to <code>android.support.media.protocols.MediaRouteProtocol</code>
|
||||
* for more information.
|
||||
* </p>
|
||||
*
|
||||
* @return The list of fully qualified route protocol names.
|
||||
*/
|
||||
public @NonNull List<String> getRequiredProtocols() {
|
||||
return mRequiredProtocols;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of optional route protocols that a client may use if they are available.
|
||||
* <p>
|
||||
* Refer to <code>android.support.media.protocols.MediaRouteProtocol</code>
|
||||
* for more information.
|
||||
* </p>
|
||||
*
|
||||
* @return The list of optional fully qualified route protocol names.
|
||||
*/
|
||||
public @NonNull List<String> getOptionalProtocols() {
|
||||
return mOptionalProtocols;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the selector includes a required or optional request for
|
||||
* the specified protocol using its fully qualified class name.
|
||||
* <p>
|
||||
* Refer to <code>android.support.media.protocols.MediaRouteProtocol</code>
|
||||
* for more information.
|
||||
* </p>
|
||||
*
|
||||
* @param clazz The protocol class.
|
||||
* @return True if the protocol was requested.
|
||||
*/
|
||||
public boolean containsProtocol(@NonNull Class<?> clazz) {
|
||||
return containsProtocol(clazz.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the selector includes a required or optional request for
|
||||
* the specified protocol.
|
||||
* <p>
|
||||
* Refer to <code>android.support.media.protocols.MediaRouteProtocol</code>
|
||||
* for more information.
|
||||
* </p>
|
||||
*
|
||||
* @param name The name of the protocol.
|
||||
* @return True if the protocol was requested.
|
||||
*/
|
||||
public boolean containsProtocol(@NonNull String name) {
|
||||
return mRequiredProtocols.contains(name)
|
||||
|| mOptionalProtocols.contains(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the package name of a specific media route service that this route selector
|
||||
* requires.
|
||||
*
|
||||
* @return The required media route service package name, or null if none.
|
||||
*/
|
||||
public @Nullable String getServicePackageName() {
|
||||
return mServicePackageName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets optional extras that may be used to select or configure routes for a
|
||||
* particular purpose. Some extras may be used by media route services to apply
|
||||
* additional constraints or parameters for the routes to be discovered.
|
||||
*
|
||||
* @return The optional extras, or null if none.
|
||||
*/
|
||||
public @Nullable Bundle getExtras() {
|
||||
return mExtras;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MediaRouteSelector{ "
|
||||
+ ", requiredFeatures=0x" + Integer.toHexString(mRequiredFeatures)
|
||||
+ ", optionalFeatures=0x" + Integer.toHexString(mOptionalFeatures)
|
||||
+ ", requiredProtocols=" + mRequiredProtocols
|
||||
+ ", optionalProtocols=" + mOptionalProtocols
|
||||
+ ", servicePackageName=" + mServicePackageName
|
||||
+ ", extras=" + mExtras + " }";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(mRequiredFeatures);
|
||||
dest.writeInt(mOptionalFeatures);
|
||||
dest.writeStringList(mRequiredProtocols);
|
||||
dest.writeStringList(mOptionalProtocols);
|
||||
dest.writeString(mServicePackageName);
|
||||
dest.writeBundle(mExtras);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<MediaRouteSelector> CREATOR =
|
||||
new Parcelable.Creator<MediaRouteSelector>() {
|
||||
@Override
|
||||
public MediaRouteSelector createFromParcel(Parcel source) {
|
||||
int requiredFeatures = source.readInt();
|
||||
int optionalFeatures = source.readInt();
|
||||
ArrayList<String> requiredProtocols = new ArrayList<String>();
|
||||
ArrayList<String> optionalProtocols = new ArrayList<String>();
|
||||
source.readStringList(requiredProtocols);
|
||||
source.readStringList(optionalProtocols);
|
||||
return new MediaRouteSelector(requiredFeatures, optionalFeatures,
|
||||
requiredProtocols, optionalProtocols,
|
||||
source.readString(), source.readBundle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaRouteSelector[] newArray(int size) {
|
||||
return new MediaRouteSelector[size];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Builder for {@link MediaRouteSelector} objects.
|
||||
*/
|
||||
public static final class Builder {
|
||||
private int mRequiredFeatures;
|
||||
private int mOptionalFeatures;
|
||||
private final ArrayList<String> mRequiredProtocols = new ArrayList<String>();
|
||||
private final ArrayList<String> mOptionalProtocols = new ArrayList<String>();
|
||||
private String mServicePackageName;
|
||||
private Bundle mExtras;
|
||||
|
||||
/**
|
||||
* Creates an initially empty selector builder.
|
||||
*/
|
||||
public Builder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the set of required route features.
|
||||
*
|
||||
* @param features A set of required route feature flags.
|
||||
*/
|
||||
public @NonNull Builder setRequiredFeatures(@RouteFeatures int features) {
|
||||
mRequiredFeatures = features;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the set of optional route features.
|
||||
*
|
||||
* @param features A set of optional route feature flags.
|
||||
*/
|
||||
public @NonNull Builder setOptionalFeatures(@RouteFeatures int features) {
|
||||
mOptionalFeatures = features;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route protocol that a route must support in order to be selected
|
||||
* using its fully qualified class name.
|
||||
* <p>
|
||||
* Refer to <code>android.support.media.protocols.MediaRouteProtocol</code>
|
||||
* for more information.
|
||||
* </p>
|
||||
*
|
||||
* @param clazz The protocol class.
|
||||
* @return this
|
||||
*/
|
||||
public @NonNull Builder addRequiredProtocol(@NonNull Class<?> clazz) {
|
||||
if (clazz == null) {
|
||||
throw new IllegalArgumentException("clazz must not be null");
|
||||
}
|
||||
return addRequiredProtocol(clazz.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route protocol that a route must support in order to be selected.
|
||||
* <p>
|
||||
* Refer to <code>android.support.media.protocols.MediaRouteProtocol</code>
|
||||
* for more information.
|
||||
* </p>
|
||||
*
|
||||
* @param name The fully qualified name of the required protocol.
|
||||
* @return this
|
||||
*/
|
||||
public @NonNull Builder addRequiredProtocol(@NonNull String name) {
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
throw new IllegalArgumentException("name must not be null or empty");
|
||||
}
|
||||
mRequiredProtocols.add(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an optional route protocol that a client may use if available
|
||||
* using its fully qualified class name.
|
||||
* <p>
|
||||
* Refer to <code>android.support.media.protocols.MediaRouteProtocol</code>
|
||||
* for more information.
|
||||
* </p>
|
||||
*
|
||||
* @param clazz The protocol class.
|
||||
* @return this
|
||||
*/
|
||||
public @NonNull Builder addOptionalProtocol(@NonNull Class<?> clazz) {
|
||||
if (clazz == null) {
|
||||
throw new IllegalArgumentException("clazz must not be null");
|
||||
}
|
||||
return addOptionalProtocol(clazz.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an optional route protocol that a client may use if available.
|
||||
* <p>
|
||||
* Refer to <code>android.support.media.protocols.MediaRouteProtocol</code>
|
||||
* for more information.
|
||||
* </p>
|
||||
*
|
||||
* @param name The fully qualified name of the optional protocol.
|
||||
* @return this
|
||||
*/
|
||||
public @NonNull Builder addOptionalProtocol(@NonNull String name) {
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
throw new IllegalArgumentException("name must not be null or empty");
|
||||
}
|
||||
mOptionalProtocols.add(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the package name of the media route service to which this selector
|
||||
* appertains.
|
||||
* <p>
|
||||
* If a package name is specified here then this selector will only be
|
||||
* passed to media route services from that package. This has the effect
|
||||
* of restricting the set of matching routes to just those that are offered
|
||||
* by that package.
|
||||
* </p>
|
||||
*
|
||||
* @param packageName The required service package name, or null if none.
|
||||
* @return this
|
||||
*/
|
||||
public @NonNull Builder setServicePackageName(@Nullable String packageName) {
|
||||
mServicePackageName = packageName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets optional extras that may be used to select or configure routes for a
|
||||
* particular purpose. Some extras may be used by route services to specify
|
||||
* additional constraints or parameters for the routes to be discovered.
|
||||
*
|
||||
* @param extras The optional extras, or null if none.
|
||||
* @return this
|
||||
*/
|
||||
public @NonNull Builder setExtras(@Nullable Bundle extras) {
|
||||
mExtras = extras;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the {@link MediaRouteSelector} object.
|
||||
*
|
||||
* @return The new media route selector instance.
|
||||
*/
|
||||
public @NonNull MediaRouteSelector build() {
|
||||
return new MediaRouteSelector(mRequiredFeatures, mOptionalFeatures,
|
||||
mRequiredProtocols, mOptionalProtocols, mServicePackageName, mExtras);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,18 +0,0 @@
|
||||
/* Copyright 2014, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
package android.media.routing;
|
||||
|
||||
parcelable ParcelableConnectionInfo;
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package android.media.routing;
|
||||
|
||||
import android.media.AudioAttributes;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* Internal parcelable representation of a media route connection.
|
||||
*/
|
||||
class ParcelableConnectionInfo implements Parcelable {
|
||||
public AudioAttributes audioAttributes;
|
||||
public int presentationDisplayId = -1;
|
||||
// todo: volume
|
||||
public IBinder[] protocolBinders;
|
||||
public Bundle extras;
|
||||
|
||||
public static final Parcelable.Creator<ParcelableConnectionInfo> CREATOR =
|
||||
new Parcelable.Creator<ParcelableConnectionInfo>() {
|
||||
@Override
|
||||
public ParcelableConnectionInfo createFromParcel(Parcel source) {
|
||||
ParcelableConnectionInfo info = new ParcelableConnectionInfo();
|
||||
if (source.readInt() != 0) {
|
||||
info.audioAttributes = AudioAttributes.CREATOR.createFromParcel(source);
|
||||
}
|
||||
info.presentationDisplayId = source.readInt();
|
||||
info.protocolBinders = source.createBinderArray();
|
||||
info.extras = source.readBundle();
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParcelableConnectionInfo[] newArray(int size) {
|
||||
return new ParcelableConnectionInfo[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
if (audioAttributes != null) {
|
||||
dest.writeInt(1);
|
||||
audioAttributes.writeToParcel(dest, flags);
|
||||
} else {
|
||||
dest.writeInt(0);
|
||||
}
|
||||
dest.writeInt(presentationDisplayId);
|
||||
dest.writeBinderArray(protocolBinders);
|
||||
dest.writeBundle(extras);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/* Copyright 2014, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
package android.media.routing;
|
||||
|
||||
parcelable ParcelableDestinationInfo;
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package android.media.routing;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
/**
|
||||
* Internal parcelable representation of a media destination.
|
||||
*/
|
||||
class ParcelableDestinationInfo implements Parcelable {
|
||||
public String id;
|
||||
public CharSequence name;
|
||||
public CharSequence description;
|
||||
public int iconResourceId;
|
||||
public Bundle extras;
|
||||
|
||||
public static final Parcelable.Creator<ParcelableDestinationInfo> CREATOR =
|
||||
new Parcelable.Creator<ParcelableDestinationInfo>() {
|
||||
@Override
|
||||
public ParcelableDestinationInfo createFromParcel(Parcel source) {
|
||||
ParcelableDestinationInfo info = new ParcelableDestinationInfo();
|
||||
info.id = source.readString();
|
||||
info.name = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
|
||||
info.description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
|
||||
info.iconResourceId = source.readInt();
|
||||
info.extras = source.readBundle();
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParcelableDestinationInfo[] newArray(int size) {
|
||||
return new ParcelableDestinationInfo[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(id);
|
||||
TextUtils.writeToParcel(name, dest, flags);
|
||||
TextUtils.writeToParcel(description, dest, flags);
|
||||
dest.writeInt(iconResourceId);
|
||||
dest.writeBundle(extras);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/* Copyright 2014, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
package android.media.routing;
|
||||
|
||||
parcelable ParcelableRouteInfo;
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package android.media.routing;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* Internal parcelable representation of a media route.
|
||||
*/
|
||||
class ParcelableRouteInfo implements Parcelable {
|
||||
public String id;
|
||||
public int selectorIndex; // index of selector within list used for discovery
|
||||
public int features;
|
||||
public String[] protocols;
|
||||
public Bundle extras;
|
||||
|
||||
public static final Parcelable.Creator<ParcelableRouteInfo> CREATOR =
|
||||
new Parcelable.Creator<ParcelableRouteInfo>() {
|
||||
@Override
|
||||
public ParcelableRouteInfo createFromParcel(Parcel source) {
|
||||
ParcelableRouteInfo info = new ParcelableRouteInfo();
|
||||
info.id = source.readString();
|
||||
info.selectorIndex = source.readInt();
|
||||
info.features = source.readInt();
|
||||
info.protocols = source.createStringArray();
|
||||
info.extras = source.readBundle();
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParcelableRouteInfo[] newArray(int size) {
|
||||
return new ParcelableRouteInfo[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(id);
|
||||
dest.writeInt(selectorIndex);
|
||||
dest.writeInt(features);
|
||||
dest.writeStringArray(protocols);
|
||||
dest.writeBundle(extras);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import android.app.PendingIntent;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.MediaMetadata;
|
||||
import android.media.routing.IMediaRouter;
|
||||
import android.media.session.ISessionController;
|
||||
import android.media.session.PlaybackState;
|
||||
import android.media.session.MediaSession;
|
||||
@@ -35,7 +34,6 @@ interface ISession {
|
||||
ISessionController getController();
|
||||
void setFlags(int flags);
|
||||
void setActive(boolean active);
|
||||
void setMediaRouter(in IMediaRouter router);
|
||||
void setMediaButtonReceiver(in PendingIntent mbr);
|
||||
void setLaunchPendingIntent(in PendingIntent pi);
|
||||
void destroy();
|
||||
|
||||
@@ -20,8 +20,6 @@ import android.content.Intent;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.media.MediaMetadata;
|
||||
import android.media.Rating;
|
||||
import android.media.routing.IMediaRouterDelegate;
|
||||
import android.media.routing.IMediaRouterStateCallback;
|
||||
import android.media.session.ISessionControllerCallback;
|
||||
import android.media.session.ParcelableVolumeInfo;
|
||||
import android.media.session.PlaybackState;
|
||||
@@ -51,8 +49,6 @@ interface ISessionController {
|
||||
void adjustVolume(int direction, int flags, String packageName);
|
||||
void setVolumeTo(int value, int flags, String packageName);
|
||||
|
||||
IMediaRouterDelegate createMediaRouterDelegate(IMediaRouterStateCallback callback);
|
||||
|
||||
// These commands are for the TransportControls
|
||||
void play();
|
||||
void playUri(in Uri uri, in Bundle extras);
|
||||
|
||||
@@ -26,7 +26,6 @@ import android.media.AudioManager;
|
||||
import android.media.MediaMetadata;
|
||||
import android.media.Rating;
|
||||
import android.media.VolumeProvider;
|
||||
import android.media.routing.MediaRouter;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -118,17 +117,6 @@ public final class MediaController {
|
||||
return mTransportControls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a media router delegate through which the destination of the media
|
||||
* router may be observed and controlled.
|
||||
*
|
||||
* @return The media router delegate, or null if the media session does
|
||||
* not support media routing.
|
||||
*/
|
||||
public @Nullable MediaRouter.Delegate createMediaRouterDelegate() {
|
||||
return new MediaRouter.Delegate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the specified media button event to the session. Only media keys can
|
||||
* be sent by this method, other keys will be ignored.
|
||||
|
||||
@@ -28,7 +28,6 @@ import android.media.AudioAttributes;
|
||||
import android.media.MediaMetadata;
|
||||
import android.media.Rating;
|
||||
import android.media.VolumeProvider;
|
||||
import android.media.routing.MediaRouter;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -224,23 +223,6 @@ public final class MediaSession {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Associates a {@link MediaRouter} with this session to control the destination
|
||||
* of media content.
|
||||
* <p>
|
||||
* A media router may only be associated with at most one session at a time.
|
||||
* </p>
|
||||
*
|
||||
* @param router The media router, or null to remove the current association.
|
||||
*/
|
||||
public void setMediaRouter(@Nullable MediaRouter router) {
|
||||
try {
|
||||
mBinder.setMediaRouter(router != null ? router.getBinder() : null);
|
||||
} catch (RemoteException e) {
|
||||
Log.wtf(TAG, "Failure in setMediaButtonReceiver.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a pending intent for your media button receiver to allow restarting
|
||||
* playback after the session has been stopped. If your app is started in
|
||||
|
||||
@@ -26,9 +26,6 @@ import android.media.AudioManagerInternal;
|
||||
import android.media.MediaMetadata;
|
||||
import android.media.Rating;
|
||||
import android.media.VolumeProvider;
|
||||
import android.media.routing.IMediaRouter;
|
||||
import android.media.routing.IMediaRouterDelegate;
|
||||
import android.media.routing.IMediaRouterStateCallback;
|
||||
import android.media.session.ISession;
|
||||
import android.media.session.ISessionCallback;
|
||||
import android.media.session.ISessionController;
|
||||
@@ -96,7 +93,6 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
|
||||
new ArrayList<ISessionControllerCallback>();
|
||||
|
||||
private long mFlags;
|
||||
private IMediaRouter mMediaRouter;
|
||||
private PendingIntent mMediaButtonReceiver;
|
||||
private PendingIntent mLaunchIntent;
|
||||
|
||||
@@ -691,12 +687,6 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
|
||||
mHandler.post(MessageHandler.MSG_UPDATE_SESSION_STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMediaRouter(IMediaRouter router) {
|
||||
mMediaRouter = router;
|
||||
mHandler.post(MessageHandler.MSG_UPDATE_SESSION_STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMediaButtonReceiver(PendingIntent pi) {
|
||||
mMediaButtonReceiver = pi;
|
||||
@@ -1147,13 +1137,6 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
|
||||
public boolean isTransportControlEnabled() {
|
||||
return MediaSessionRecord.this.isTransportControlEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMediaRouterDelegate createMediaRouterDelegate(
|
||||
IMediaRouterStateCallback callback) {
|
||||
// todo
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class MessageHandler extends Handler {
|
||||
|
||||
@@ -9,9 +9,6 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files) \
|
||||
LOCAL_PACKAGE_NAME := OneMedia
|
||||
LOCAL_CERTIFICATE := platform
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
android-support-media-protocols
|
||||
|
||||
LOCAL_PROGUARD_ENABLED := disabled
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
@@ -25,15 +25,6 @@
|
||||
android:name="com.android.onemedia.OnePlayerService"
|
||||
android:exported="true"
|
||||
android:process="com.android.onemedia.service" />
|
||||
<service
|
||||
android:name=".provider.OneMediaRouteProvider"
|
||||
android:permission="android.permission.BIND_MEDIA_ROUTE_SERVICE"
|
||||
android:exported="true"
|
||||
android:process="com.android.onemedia.provider">
|
||||
<intent-filter>
|
||||
<action android:name="android.media.routing.MediaRouteService" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
@@ -19,24 +19,16 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.MediaMetadata;
|
||||
import android.media.routing.MediaRouteSelector;
|
||||
import android.media.routing.MediaRouter;
|
||||
import android.media.routing.MediaRouter.ConnectionRequest;
|
||||
import android.media.routing.MediaRouter.DestinationInfo;
|
||||
import android.media.routing.MediaRouter.RouteInfo;
|
||||
import android.media.session.MediaSession;
|
||||
import android.media.session.MediaSessionManager;
|
||||
import android.media.session.PlaybackState;
|
||||
import android.os.Bundle;
|
||||
import android.support.media.protocols.MediaPlayerProtocol;
|
||||
import android.support.media.protocols.MediaPlayerProtocol.MediaStatus;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import com.android.onemedia.playback.LocalRenderer;
|
||||
import com.android.onemedia.playback.OneMRPRenderer;
|
||||
import com.android.onemedia.playback.Renderer;
|
||||
import com.android.onemedia.playback.RequestUtils;
|
||||
|
||||
@@ -47,7 +39,6 @@ public class PlayerSession {
|
||||
private static final String TAG = "PlayerSession";
|
||||
|
||||
protected MediaSession mSession;
|
||||
protected MediaRouter mRouter;
|
||||
protected Context mContext;
|
||||
protected Renderer mRenderer;
|
||||
protected MediaSession.Callback mCallback;
|
||||
@@ -80,22 +71,11 @@ public class PlayerSession {
|
||||
.getSystemService(Context.MEDIA_SESSION_SERVICE);
|
||||
Log.d(TAG, "Creating session for package " + mContext.getBasePackageName());
|
||||
|
||||
mRouter = new MediaRouter(mContext);
|
||||
mRouter.addSelector(new MediaRouteSelector.Builder()
|
||||
.addRequiredProtocol(MediaPlayerProtocol.class)
|
||||
.build());
|
||||
mRouter.addSelector(new MediaRouteSelector.Builder()
|
||||
.setRequiredFeatures(MediaRouter.ROUTE_FEATURE_LIVE_AUDIO)
|
||||
.setOptionalFeatures(MediaRouter.ROUTE_FEATURE_LIVE_VIDEO)
|
||||
.build());
|
||||
mRouter.setRoutingCallback(new RoutingCallback(), null);
|
||||
|
||||
mSession = new MediaSession(mContext, "OneMedia");
|
||||
mSession.setCallback(mCallback);
|
||||
mSession.setPlaybackState(mPlaybackState);
|
||||
mSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS
|
||||
| MediaSession.FLAG_HANDLES_MEDIA_BUTTONS);
|
||||
mSession.setMediaRouter(mRouter);
|
||||
mSession.setActive(true);
|
||||
updateMetadata();
|
||||
}
|
||||
@@ -113,10 +93,6 @@ public class PlayerSession {
|
||||
mSession.release();
|
||||
mSession = null;
|
||||
}
|
||||
if (mRouter != null) {
|
||||
mRouter.release();
|
||||
mRouter = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener(Listener listener) {
|
||||
@@ -266,63 +242,4 @@ public class PlayerSession {
|
||||
mRenderer.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
private class RoutingCallback extends MediaRouter.RoutingCallback {
|
||||
@Override
|
||||
public void onConnectionStateChanged(int state) {
|
||||
if (state == MediaRouter.CONNECTION_STATE_CONNECTING) {
|
||||
if (mRenderer != null) {
|
||||
mRenderer.onStop();
|
||||
}
|
||||
mRenderer = null;
|
||||
updateState(PlaybackState.STATE_CONNECTING);
|
||||
return;
|
||||
}
|
||||
|
||||
MediaRouter.ConnectionInfo connection = mRouter.getConnection();
|
||||
if (connection != null) {
|
||||
MediaPlayerProtocol protocol =
|
||||
connection.getProtocolObject(MediaPlayerProtocol.class);
|
||||
if (protocol != null) {
|
||||
Log.d(TAG, "Connected to route using media player protocol");
|
||||
|
||||
protocol.setCallback(new PlayerCallback(), null);
|
||||
mRenderer = new OneMRPRenderer(protocol);
|
||||
updateState(PlaybackState.STATE_NONE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Use local route
|
||||
mRenderer = new LocalRenderer(mContext, null);
|
||||
mRenderer.registerListener(mRenderListener);
|
||||
updateState(PlaybackState.STATE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
private class PlayerCallback extends MediaPlayerProtocol.Callback {
|
||||
@Override
|
||||
public void onStatusUpdated(MediaStatus status, Bundle extras) {
|
||||
if (status != null) {
|
||||
Log.d(TAG, "Received status update: " + status.toBundle());
|
||||
switch (status.getPlayerState()) {
|
||||
case MediaStatus.PLAYER_STATE_BUFFERING:
|
||||
updateState(PlaybackState.STATE_BUFFERING);
|
||||
break;
|
||||
case MediaStatus.PLAYER_STATE_IDLE:
|
||||
updateState(PlaybackState.STATE_STOPPED);
|
||||
break;
|
||||
case MediaStatus.PLAYER_STATE_PAUSED:
|
||||
updateState(PlaybackState.STATE_PAUSED);
|
||||
break;
|
||||
case MediaStatus.PLAYER_STATE_PLAYING:
|
||||
updateState(PlaybackState.STATE_PLAYING);
|
||||
break;
|
||||
case MediaStatus.PLAYER_STATE_UNKNOWN:
|
||||
updateState(PlaybackState.STATE_NONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.android.onemedia.playback;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.media.protocols.MediaPlayerProtocol;
|
||||
import android.support.media.protocols.MediaPlayerProtocol.MediaInfo;
|
||||
|
||||
/**
|
||||
* Renderer for communicating with the OneMRP route
|
||||
*/
|
||||
public class OneMRPRenderer extends Renderer {
|
||||
private final MediaPlayerProtocol mProtocol;
|
||||
|
||||
public OneMRPRenderer(MediaPlayerProtocol protocol) {
|
||||
super(null, null);
|
||||
mProtocol = protocol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContent(Bundle request) {
|
||||
MediaInfo mediaInfo = new MediaInfo(request.getString(RequestUtils.EXTRA_KEY_SOURCE),
|
||||
MediaInfo.STREAM_TYPE_BUFFERED, "audio/mp3");
|
||||
mProtocol.load(mediaInfo, true, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onStop() {
|
||||
mProtocol.stop(null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPlay() {
|
||||
mProtocol.play(null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPause() {
|
||||
mProtocol.pause(null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSeekPosition() {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.onemedia.provider;
|
||||
|
||||
import android.media.routing.MediaRouteSelector;
|
||||
import android.media.routing.MediaRouteService;
|
||||
import android.media.routing.MediaRouter.ConnectionInfo;
|
||||
import android.media.routing.MediaRouter.ConnectionRequest;
|
||||
import android.media.routing.MediaRouter.DestinationInfo;
|
||||
import android.media.routing.MediaRouter.DiscoveryRequest;
|
||||
import android.media.routing.MediaRouter.RouteInfo;
|
||||
import android.media.session.PlaybackState;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Process;
|
||||
import android.support.media.protocols.MediaPlayerProtocol;
|
||||
import android.support.media.protocols.MediaPlayerProtocol.MediaInfo;
|
||||
import android.support.media.protocols.MediaPlayerProtocol.MediaStatus;
|
||||
import android.os.Looper;
|
||||
import android.os.ResultReceiver;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.onemedia.playback.LocalRenderer;
|
||||
import com.android.onemedia.playback.Renderer;
|
||||
import com.android.onemedia.playback.RequestUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Test of MediaRouteProvider. Show a dummy provider with a simple interface for
|
||||
* playing music.
|
||||
*/
|
||||
public class OneMediaRouteProvider extends MediaRouteService {
|
||||
private static final String TAG = "OneMRP";
|
||||
private static final boolean DEBUG = true;
|
||||
|
||||
private static final String TEST_DESTINATION_ID = "testDestination";
|
||||
private static final String TEST_ROUTE_ID = "testRoute";
|
||||
|
||||
private Renderer mRenderer;
|
||||
private RenderListener mRenderListener;
|
||||
private PlaybackState mPlaybackState;
|
||||
private Handler mHandler;
|
||||
|
||||
private OneStub mStub;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
mHandler = new Handler();
|
||||
mRenderer = new LocalRenderer(this, null);
|
||||
mRenderListener = new RenderListener();
|
||||
PlaybackState.Builder bob = new PlaybackState.Builder();
|
||||
bob.setActions(PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_PLAY);
|
||||
mPlaybackState = bob.build();
|
||||
|
||||
mRenderer.registerListener(mRenderListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientSession onCreateClientSession(ClientInfo client) {
|
||||
if (client.getUid() != Process.myUid()) {
|
||||
// for testing purposes, only allow connections from this application
|
||||
// since this provider is not fully featured
|
||||
return null;
|
||||
}
|
||||
return new OneSession(client);
|
||||
}
|
||||
|
||||
private final class OneSession extends ClientSession {
|
||||
private final ClientInfo mClient;
|
||||
|
||||
public OneSession(ClientInfo client) {
|
||||
mClient = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onStartDiscovery(DiscoveryRequest req, DiscoveryCallback callback) {
|
||||
for (MediaRouteSelector selector : req.getSelectors()) {
|
||||
if (isMatch(selector)) {
|
||||
DestinationInfo destination = new DestinationInfo.Builder(
|
||||
TEST_DESTINATION_ID, getServiceMetadata(), "OneMedia")
|
||||
.setDescription("Test route from OneMedia app.")
|
||||
.build();
|
||||
ArrayList<RouteInfo> routes = new ArrayList<RouteInfo>();
|
||||
routes.add(new RouteInfo.Builder(
|
||||
TEST_ROUTE_ID, destination, selector).build());
|
||||
callback.onDestinationFound(destination, routes);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopDiscovery() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onConnect(ConnectionRequest req, ConnectionCallback callback) {
|
||||
if (req.getRoute().getId().equals(TEST_ROUTE_ID)) {
|
||||
mStub = new OneStub();
|
||||
ConnectionInfo connection = new ConnectionInfo.Builder(req.getRoute())
|
||||
.setProtocolStub(MediaPlayerProtocol.class, mStub)
|
||||
.build();
|
||||
callback.onConnected(connection);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnect() {
|
||||
mStub = null;
|
||||
}
|
||||
|
||||
private boolean isMatch(MediaRouteSelector selector) {
|
||||
if (!selector.containsProtocol(MediaPlayerProtocol.class)) {
|
||||
return false;
|
||||
}
|
||||
for (String protocol : selector.getRequiredProtocols()) {
|
||||
if (!protocol.equals(MediaPlayerProtocol.class.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private final class OneStub extends MediaPlayerProtocol.Stub {
|
||||
MediaInfo mMediaInfo;
|
||||
|
||||
public OneStub() {
|
||||
super(mHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad(MediaInfo mediaInfo, boolean autoplay, long playPosition,
|
||||
Bundle extras) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Attempting to play " + mediaInfo.getContentId());
|
||||
}
|
||||
// look up the route and send a play command to it
|
||||
mMediaInfo = mediaInfo;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(RequestUtils.EXTRA_KEY_SOURCE, mediaInfo.getContentId());
|
||||
mRenderer.setContent(bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlay(Bundle extras) {
|
||||
mRenderer.onPlay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause(Bundle extras) {
|
||||
mRenderer.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
private class RenderListener implements Renderer.Listener {
|
||||
|
||||
@Override
|
||||
public void onError(int type, int extra, Bundle extras, Throwable error) {
|
||||
Log.d(TAG, "Sending onError with type " + type + " and extra " + extra);
|
||||
sendStatusUpdate(PlaybackState.STATE_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChanged(int newState) {
|
||||
long position = -1;
|
||||
if (mRenderer != null) {
|
||||
position = mRenderer.getSeekPosition();
|
||||
}
|
||||
int pbState;
|
||||
float rate = 0;
|
||||
String errorMsg = null;
|
||||
switch (newState) {
|
||||
case Renderer.STATE_ENDED:
|
||||
case Renderer.STATE_STOPPED:
|
||||
pbState = PlaybackState.STATE_STOPPED;
|
||||
break;
|
||||
case Renderer.STATE_INIT:
|
||||
case Renderer.STATE_PREPARING:
|
||||
pbState = PlaybackState.STATE_BUFFERING;
|
||||
break;
|
||||
case Renderer.STATE_ERROR:
|
||||
pbState = PlaybackState.STATE_ERROR;
|
||||
break;
|
||||
case Renderer.STATE_PAUSED:
|
||||
pbState = PlaybackState.STATE_PAUSED;
|
||||
break;
|
||||
case Renderer.STATE_PLAYING:
|
||||
pbState = PlaybackState.STATE_PLAYING;
|
||||
rate = 1;
|
||||
break;
|
||||
default:
|
||||
pbState = PlaybackState.STATE_ERROR;
|
||||
errorMsg = "unknown state";
|
||||
break;
|
||||
}
|
||||
PlaybackState.Builder bob = new PlaybackState.Builder(mPlaybackState);
|
||||
bob.setState(pbState, position, rate, SystemClock.elapsedRealtime());
|
||||
bob.setErrorMessage(errorMsg);
|
||||
mPlaybackState = bob.build();
|
||||
|
||||
sendStatusUpdate(mPlaybackState.getState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBufferingUpdate(int percent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusLost() {
|
||||
Log.d(TAG, "Focus lost, pausing");
|
||||
// Don't update state here, we'll get a separate call to
|
||||
// onStateChanged when it pauses
|
||||
mRenderer.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNextStarted() {
|
||||
}
|
||||
|
||||
private void sendStatusUpdate(int state) {
|
||||
if (mStub != null) {
|
||||
MediaStatus status = new MediaStatus(1, mStub.mMediaInfo);
|
||||
switch (state) {
|
||||
case PlaybackState.STATE_BUFFERING:
|
||||
case PlaybackState.STATE_FAST_FORWARDING:
|
||||
case PlaybackState.STATE_REWINDING:
|
||||
case PlaybackState.STATE_SKIPPING_TO_NEXT:
|
||||
case PlaybackState.STATE_SKIPPING_TO_PREVIOUS:
|
||||
status.setPlayerState(MediaStatus.PLAYER_STATE_BUFFERING);
|
||||
break;
|
||||
case PlaybackState.STATE_CONNECTING:
|
||||
case PlaybackState.STATE_STOPPED:
|
||||
status.setPlayerState(MediaStatus.PLAYER_STATE_IDLE);
|
||||
break;
|
||||
case PlaybackState.STATE_PAUSED:
|
||||
status.setPlayerState(MediaStatus.PLAYER_STATE_PAUSED);
|
||||
break;
|
||||
case PlaybackState.STATE_PLAYING:
|
||||
status.setPlayerState(MediaStatus.PLAYER_STATE_PLAYING);
|
||||
break;
|
||||
case PlaybackState.STATE_NONE:
|
||||
case PlaybackState.STATE_ERROR:
|
||||
default:
|
||||
status.setPlayerState(MediaStatus.PLAYER_STATE_UNKNOWN);
|
||||
break;
|
||||
}
|
||||
mStub.sendStatusUpdatedEvent(status, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user