Files
frameworks_base/media/java/android/media/MediaRouterClientState.java
Jeff Brown 69b07161be Add media router service and integrate with remote displays.
This change adds a new media router service whose purpose is to track
global state information associated with media routes.  This service
publishes routes to the media router instance in application processes
and handles requested state changes such as selecting or unselecting
global routes.  The service also binds to remote display provider
services which can offer new remote display routes to the system.

Includes a test application for manually verifying certain aspects
of the operation of the media router service.

The remote display provider interface is essentially a stripped down
media route provider interface as defined in the support library
media router implementation.  For now, it is designed to be used only
by first parties to publish remote display routes to the system so
it is not exposed as public API in the SDK.  In the future, the remote
display provider interface will most likely be deprecated and replaced
with a more featureful media route provider interface for third
party integration, similar to what is in the support library today.

Further patch sets integrate these new capabilities into the System UI
and Settings for connecting remote displays.

Bug: 11257292
Change-Id: I31109f23f17b474d17534d0f5f4503e388b081c2
2013-11-07 03:25:37 -08:00

184 lines
6.0 KiB
Java

/*
* Copyright (C) 2013 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;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
/**
* Information available from MediaRouterService about the state perceived by
* a particular client and the routes that are available to it.
*
* Clients must not modify the contents of this object.
* @hide
*/
public final class MediaRouterClientState implements Parcelable {
/**
* A list of all known routes.
*/
public final ArrayList<RouteInfo> routes;
/**
* The id of the current globally selected route, or null if none.
* Globally selected routes override any other route selections that applications
* may have made. Used for remote displays.
*/
public String globallySelectedRouteId;
public MediaRouterClientState() {
routes = new ArrayList<RouteInfo>();
}
MediaRouterClientState(Parcel src) {
routes = src.createTypedArrayList(RouteInfo.CREATOR);
globallySelectedRouteId = src.readString();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeTypedList(routes);
dest.writeString(globallySelectedRouteId);
}
public static final Parcelable.Creator<MediaRouterClientState> CREATOR =
new Parcelable.Creator<MediaRouterClientState>() {
@Override
public MediaRouterClientState createFromParcel(Parcel in) {
return new MediaRouterClientState(in);
}
@Override
public MediaRouterClientState[] newArray(int size) {
return new MediaRouterClientState[size];
}
};
public static final class RouteInfo implements Parcelable {
public String id;
public String name;
public String description;
public int supportedTypes;
public boolean enabled;
public int statusCode;
public int playbackType;
public int playbackStream;
public int volume;
public int volumeMax;
public int volumeHandling;
public int presentationDisplayId;
public RouteInfo(String id) {
this.id = id;
enabled = true;
statusCode = MediaRouter.RouteInfo.STATUS_NONE;
playbackType = MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE;
playbackStream = -1;
volumeHandling = MediaRouter.RouteInfo.PLAYBACK_VOLUME_FIXED;
presentationDisplayId = -1;
}
public RouteInfo(RouteInfo other) {
id = other.id;
name = other.name;
description = other.description;
supportedTypes = other.supportedTypes;
enabled = other.enabled;
statusCode = other.statusCode;
playbackType = other.playbackType;
playbackStream = other.playbackStream;
volume = other.volume;
volumeMax = other.volumeMax;
volumeHandling = other.volumeHandling;
presentationDisplayId = other.presentationDisplayId;
}
RouteInfo(Parcel in) {
id = in.readString();
name = in.readString();
description = in.readString();
supportedTypes = in.readInt();
enabled = in.readInt() != 0;
statusCode = in.readInt();
playbackType = in.readInt();
playbackStream = in.readInt();
volume = in.readInt();
volumeMax = in.readInt();
volumeHandling = in.readInt();
presentationDisplayId = in.readInt();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(id);
dest.writeString(name);
dest.writeString(description);
dest.writeInt(supportedTypes);
dest.writeInt(enabled ? 1 : 0);
dest.writeInt(statusCode);
dest.writeInt(playbackType);
dest.writeInt(playbackStream);
dest.writeInt(volume);
dest.writeInt(volumeMax);
dest.writeInt(volumeHandling);
dest.writeInt(presentationDisplayId);
}
@Override
public String toString() {
return "RouteInfo{ id=" + id
+ ", name=" + name
+ ", description=" + description
+ ", supportedTypes=0x" + Integer.toHexString(supportedTypes)
+ ", enabled=" + enabled
+ ", statusCode=" + statusCode
+ ", playbackType=" + playbackType
+ ", playbackStream=" + playbackStream
+ ", volume=" + volume
+ ", volumeMax=" + volumeMax
+ ", volumeHandling=" + volumeHandling
+ ", presentationDisplayId=" + presentationDisplayId
+ " }";
}
@SuppressWarnings("hiding")
public static final Parcelable.Creator<RouteInfo> CREATOR =
new Parcelable.Creator<RouteInfo>() {
@Override
public RouteInfo createFromParcel(Parcel in) {
return new RouteInfo(in);
}
@Override
public RouteInfo[] newArray(int size) {
return new RouteInfo[size];
}
};
}
}