summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJae Seo <jaeseo@google.com>2014-07-24 15:54:23 -0700
committerDongwon Kang <dwkang@google.com>2014-07-31 16:15:51 +0900
commitd5ce9759524740cfb02638fd1d7b44315957b422 (patch)
tree2bbb5cf248d1773d90dacc9e2ca1868507937de8 /media
parent8d367bcd2281286ec3b8895ade17e839720a8bd9 (diff)
downloadframeworks_base-d5ce9759524740cfb02638fd1d7b44315957b422.zip
frameworks_base-d5ce9759524740cfb02638fd1d7b44315957b422.tar.gz
frameworks_base-d5ce9759524740cfb02638fd1d7b44315957b422.tar.bz2
TIF: Make TvTrackInfo methods more explicit.
This change addresses the following API council feedback: TvTrackInfo: -- Remove all KEY_/VALUE_ constants, and replace with explicit, strongly-typed accessor methods. -- Add additional Bundle getExtras() method (in addition to the explicit types); most of the time this Bundle will be null. Bug: 16542165 Change-Id: Ie48cb170b2bbf07d9460fdc8ed77d7db01799772
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/tv/ITvInputClient.aidl1
-rw-r--r--media/java/android/media/tv/ITvInputSessionCallback.aidl1
-rw-r--r--media/java/android/media/tv/TvInputManager.java53
-rw-r--r--media/java/android/media/tv/TvInputService.java36
-rw-r--r--media/java/android/media/tv/TvTrackInfo.java316
-rw-r--r--media/java/android/media/tv/TvView.java42
6 files changed, 265 insertions, 184 deletions
diff --git a/media/java/android/media/tv/ITvInputClient.aidl b/media/java/android/media/tv/ITvInputClient.aidl
index c48ddf1..2c39afa 100644
--- a/media/java/android/media/tv/ITvInputClient.aidl
+++ b/media/java/android/media/tv/ITvInputClient.aidl
@@ -34,6 +34,7 @@ oneway interface ITvInputClient {
void onSessionEvent(in String name, in Bundle args, int seq);
void onChannelRetuned(in Uri channelUri, int seq);
void onTrackInfoChanged(in List<TvTrackInfo> tracks, int seq);
+ void onTrackSelectionChanged(in List<TvTrackInfo> selectedTracks, int seq);
void onVideoAvailable(int seq);
void onVideoUnavailable(int reason, int seq);
void onContentAllowed(int seq);
diff --git a/media/java/android/media/tv/ITvInputSessionCallback.aidl b/media/java/android/media/tv/ITvInputSessionCallback.aidl
index 4186bb5..3773987 100644
--- a/media/java/android/media/tv/ITvInputSessionCallback.aidl
+++ b/media/java/android/media/tv/ITvInputSessionCallback.aidl
@@ -31,6 +31,7 @@ oneway interface ITvInputSessionCallback {
void onSessionEvent(in String name, in Bundle args);
void onChannelRetuned(in Uri channelUri);
void onTrackInfoChanged(in List<TvTrackInfo> tracks);
+ void onTrackSelectionChanged(in List<TvTrackInfo> selectedTracks);
void onVideoAvailable();
void onVideoUnavailable(int reason);
void onContentAllowed();
diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java
index d97aee0..49b2240 100644
--- a/media/java/android/media/tv/TvInputManager.java
+++ b/media/java/android/media/tv/TvInputManager.java
@@ -164,7 +164,7 @@ public final class TvInputManager {
* This is called when the channel of this session is changed by the underlying TV input
* with out any {@link TvInputManager.Session#tune(Uri)} request.
*
- * @param session A {@link TvInputManager.Session} associated with this callback
+ * @param session A {@link TvInputManager.Session} associated with this callback.
* @param channelUri The URI of a channel.
*/
public void onChannelRetuned(Session session, Uri channelUri) {
@@ -173,16 +173,25 @@ public final class TvInputManager {
/**
* This is called when the track information of the session has been changed.
*
- * @param session A {@link TvInputManager.Session} associated with this callback
+ * @param session A {@link TvInputManager.Session} associated with this callback.
* @param tracks A list which includes track information.
*/
public void onTrackInfoChanged(Session session, List<TvTrackInfo> tracks) {
}
/**
- * This is called when the video is available, so the TV input starts the playback.
+ * This is called when there is a change on the selected tracks in this session.
*
* @param session A {@link TvInputManager.Session} associated with this callback
+ * @param selectedTracks A list of selected tracks.
+ */
+ public void onTrackSelectionChanged(Session session, List<TvTrackInfo> selectedTracks) {
+ }
+
+ /**
+ * This is called when the video is available, so the TV input starts the playback.
+ *
+ * @param session A {@link TvInputManager.Session} associated with this callback.
*/
public void onVideoAvailable(Session session) {
}
@@ -277,12 +286,22 @@ public final class TvInputManager {
mHandler.post(new Runnable() {
@Override
public void run() {
- mSession.setTracks(tracks);
+ mSession.mTracks = tracks;
mSessionCallback.onTrackInfoChanged(mSession, tracks);
}
});
}
+ public void postTrackSelectionChanged(final List<TvTrackInfo> selectedTracks) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mSession.mSelectedTracks = selectedTracks;
+ mSessionCallback.onTrackSelectionChanged(mSession, selectedTracks);
+ }
+ });
+ }
+
public void postVideoAvailable() {
mHandler.post(new Runnable() {
@Override
@@ -469,6 +488,18 @@ public final class TvInputManager {
}
@Override
+ public void onTrackSelectionChanged(List<TvTrackInfo> selectedTracks, int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for seq " + seq);
+ return;
+ }
+ record.postTrackSelectionChanged(selectedTracks);
+ }
+ }
+
+ @Override
public void onVideoAvailable(int seq) {
synchronized (mSessionCallbackRecordMap) {
SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
@@ -868,6 +899,7 @@ public final class TvInputManager {
private TvInputEventSender mSender;
private InputChannel mChannel;
private List<TvTrackInfo> mTracks;
+ private List<TvTrackInfo> mSelectedTracks;
private Session(IBinder token, InputChannel channel, ITvInputManager service, int userId,
int seq, SparseArray<SessionCallbackRecord> sessionCallbackRecordMap) {
@@ -1067,8 +1099,17 @@ public final class TvInputManager {
return new ArrayList<TvTrackInfo>(mTracks);
}
- private void setTracks(List<TvTrackInfo> tracks) {
- mTracks = tracks;
+ /**
+ * Returns a list of selected tracks May return {@code null} if the information is not
+ * available.
+ * @see #selectTrack(TvTrackInfo)
+ * @see #unselectTrack(TvTrackInfo)
+ */
+ public List<TvTrackInfo> getSelectedTracks() {
+ if (mSelectedTracks == null) {
+ return null;
+ }
+ return new ArrayList<TvTrackInfo>(mSelectedTracks);
}
/**
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java
index a321809..29a2230 100644
--- a/media/java/android/media/tv/TvInputService.java
+++ b/media/java/android/media/tv/TvInputService.java
@@ -325,10 +325,6 @@ public abstract class TvInputService extends Service {
* @param tracks A list which includes track information.
*/
public void notifyTrackInfoChanged(final List<TvTrackInfo> tracks) {
- if (!TvTrackInfo.checkSanity(tracks)) {
- throw new IllegalArgumentException(
- "Two or more selected tracks for a track type.");
- }
mHandler.post(new Runnable() {
@Override
public void run() {
@@ -343,6 +339,28 @@ public abstract class TvInputService extends Service {
}
/**
+ * Sends the list of selected tracks. This is expected to be called whenever there is a
+ * change on track selection.
+ *
+ * @param selectedTracks A list of selected tracks.
+ * @see #onSelectTrack(TvTrackInfo)
+ * @see #onUnselectTrack(TvTrackInfo)
+ */
+ public void notifyTrackSelectionChanged(final List<TvTrackInfo> selectedTracks) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ if (DEBUG) Log.d(TAG, "notifyTrackSelectionChanged");
+ mSessionCallback.onTrackSelectionChanged(selectedTracks);
+ } catch (RemoteException e) {
+ Log.w(TAG, "error in notifyTrackSelectionChanged");
+ }
+ }
+ });
+ }
+
+ /**
* Informs the application that video is available and the playback of the TV stream has
* been started.
*/
@@ -572,13 +590,12 @@ public abstract class TvInputService extends Service {
* If it is called multiple times on the same type of track (ie. Video, Audio, Text), the
* track selected previously should be unselected in the implementation of this method.
* Also, if the select operation was successful, the implementation should call
- * {@link #notifyTrackInfoChanged(List)} to report the updated track information.
+ * {@link #notifyTrackSelectionChanged(List)} to report the selected track list.
* </p>
*
* @param track The track to be selected.
* @return {@code true} if the select operation was successful, {@code false} otherwise.
- * @see #notifyTrackInfoChanged
- * @see TvTrackInfo#KEY_IS_SELECTED
+ * @see #notifyTrackSelectionChanged(List)
*/
public boolean onSelectTrack(TvTrackInfo track) {
return false;
@@ -588,13 +605,12 @@ public abstract class TvInputService extends Service {
* Unselects a given track.
* <p>
* If the unselect operation was successful, the implementation should call
- * {@link #notifyTrackInfoChanged(List)} to report the updated track information.
+ * {@link #notifyTrackSelectionChanged(List)} to report the selected track list.
* </p>
*
* @param track The track to be unselected.
* @return {@code true} if the unselect operation was successful, {@code false} otherwise.
- * @see #notifyTrackInfoChanged
- * @see TvTrackInfo#KEY_IS_SELECTED
+ * @see #notifyTrackSelectionChanged(List)
*/
public boolean onUnselectTrack(TvTrackInfo track) {
return false;
diff --git a/media/java/android/media/tv/TvTrackInfo.java b/media/java/android/media/tv/TvTrackInfo.java
index de4f4b7..3b80db4 100644
--- a/media/java/android/media/tv/TvTrackInfo.java
+++ b/media/java/android/media/tv/TvTrackInfo.java
@@ -16,171 +16,121 @@
package android.media.tv;
-import android.media.MediaFormat;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
-import java.util.List;
-
/**
* Encapsulates the format of tracks played in {@link TvInputService}.
*/
public final class TvTrackInfo implements Parcelable {
/**
- * A key describing the type of this track. The associated value is an integer and it should be
- * one of {@link #VALUE_TYPE_AUDIO}, {@link #VALUE_TYPE_VIDEO}, and {@link #VALUE_TYPE_SUBTITLE}.
- * <p>
- * This is a required key.
- * </p>
- */
- public static final String KEY_TYPE = "type";
-
- /**
- * A key describing the language of the track, using either ISO 639-1 or 639-2/T codes.
- * If the language is unknown or could not be determined, the corresponding value will be "und".
- * The associated value is a string.
- * <p>
- * This is a required key.
- * </p>
+ * The type value for audio tracks.
*/
- public static final String KEY_LANGUAGE = MediaFormat.KEY_LANGUAGE;
+ public static final int TYPE_AUDIO = 0;
/**
- * A key describing whether this track is selected for the playback.
- * The associated value is a boolean.
- * <p>
- * This is a required key.
- * </p>
+ * The type value for video tracks.
*/
- public static final String KEY_IS_SELECTED = "is-selected";
+ public static final int TYPE_VIDEO = 1;
/**
- * A key describing the sample rate of an audio track.
- * The associated value is an integer.
+ * The type value for subtitle tracks.
*/
- public static final String KEY_SAMPLE_RATE = MediaFormat.KEY_SAMPLE_RATE;
-
- /**
- * A key describing the number of channels in an audio track.
- * The associated value is an integer.
- */
- public static final String KEY_CHANNEL_COUNT = MediaFormat.KEY_CHANNEL_COUNT;
-
- /**
- * A key describing the width of the content in a video track.
- * The associated value is an integer.
- */
- public static final String KEY_WIDTH = MediaFormat.KEY_WIDTH;
-
- /**
- * A key describing the height of the content in a video track.
- * The associated value is an integer.
- */
- public static final String KEY_HEIGHT = MediaFormat.KEY_HEIGHT;
-
- /**
- * A key describing a tag associated with this track. Expected to be used as an identifier with
- * in a session. The associated value is a string.
- */
- public static final String KEY_TAG = "tag";
+ public static final int TYPE_SUBTITLE = 2;
+
+ private final int mType;
+ private final String mLanguage;
+ private final int mAudioChannelCount;
+ private final int mAudioSampleRate;
+ private final int mVideoWidth;
+ private final int mVideoHeight;
+ private final Bundle mExtra;
+
+ private TvTrackInfo(int type, String language, int audioChannelCount,
+ int audioSampleRate, int videoWidth, int videoHeight, Bundle extra) {
+ mType = type;
+ mLanguage = language;
+ mAudioChannelCount = audioChannelCount;
+ mAudioSampleRate = audioSampleRate;
+ mVideoWidth = videoWidth;
+ mVideoHeight = videoHeight;
+ mExtra = extra;
+ }
- /**
- * The type value for audio track.
- */
- public static final int VALUE_TYPE_AUDIO = 0;
+ private TvTrackInfo(Parcel in) {
+ mType = in.readInt();
+ mLanguage = in.readString();
+ mAudioChannelCount = in.readInt();
+ mAudioSampleRate = in.readInt();
+ mVideoWidth = in.readInt();
+ mVideoHeight = in.readInt();
+ mExtra = in.readBundle();
+ }
/**
- * The type value for video track.
+ * Returns the type of the track. The type should be one of the followings:
+ * {@link #TYPE_AUDIO}, {@link #TYPE_VIDEO} and {@link #TYPE_SUBTITLE}.
*/
- public static final int VALUE_TYPE_VIDEO = 1;
+ public final int getType() {
+ return mType;
+ }
/**
- * The type value for subtitle track.
+ * Returns the language information encoded by either ISO 639-1 or ISO 639-2/T. If the language
+ * is unknown or could not be determined, the corresponding value will be {@code null}.
*/
- public static final int VALUE_TYPE_SUBTITLE = 2;
-
- private final Bundle mBundle;
-
- private TvTrackInfo(Bundle bundle) {
- mBundle = new Bundle(bundle);
- }
-
- private TvTrackInfo(Parcel in) {
- mBundle = in.readBundle();
+ public final String getLanguage() {
+ return mLanguage;
}
/**
- * Checks if there is only one or zero selected track per track type.
- *
- * @param tracks a list including tracks which will be checked.
- * @return true if there is only one or zero selected track per track type, false otherwise
- * @hide
+ * Returns the audio channel count. Valid for {@link #TYPE_AUDIO} tracks only.
*/
- public static boolean checkSanity(List<TvTrackInfo> tracks) {
- int selectedAudioTracks = 0;
- int selectedVideoTracks = 0;
- int selectedSubtitleTracks = 0;
- for (TvTrackInfo track : tracks) {
- if (track.getBoolean(KEY_IS_SELECTED)) {
- int type = track.getInt(KEY_TYPE);
- if (type == VALUE_TYPE_AUDIO) {
- selectedAudioTracks++;
- } else if (type == VALUE_TYPE_VIDEO) {
- selectedVideoTracks++;
- } else if (type == VALUE_TYPE_SUBTITLE) {
- selectedSubtitleTracks++;
- }
- }
- }
- if (selectedAudioTracks > 1 || selectedVideoTracks > 1 || selectedSubtitleTracks > 1) {
- return false;
+ public final int getAudioChannelCount() {
+ if (mType != TYPE_AUDIO) {
+ throw new IllegalStateException("Not an audio track");
}
- return true;
+ return mAudioChannelCount;
}
/**
- * Returns true if the given key is contained in the metadata
- *
- * @param key A String key
- * @return true If the key exists in this metadata, false otherwise
+ * Returns the audio sample rate, in the unit of Hz. Valid for {@link #TYPE_AUDIO} tracks only.
*/
- public boolean containsKey(String key) {
- return mBundle.containsKey(key);
+ public final int getAudioSampleRate() {
+ if (mType != TYPE_AUDIO) {
+ throw new IllegalStateException("Not an audio track");
+ }
+ return mAudioSampleRate;
}
/**
- * Returns the value associated with the given key, or null if no mapping of
- * the desired type exists for the given key or a null value is explicitly
- * associated with the key.
- *
- * @param key The key the value is stored under
- * @return A String value, or null
+ * Returns the width of the video, in the unit of pixels. Valid for {@link #TYPE_VIDEO} tracks
+ * only.
*/
- public String getString(String key) {
- return mBundle.getString(key);
+ public final int getVideoWidth() {
+ if (mType != TYPE_VIDEO) {
+ throw new IllegalStateException("Not a video track");
+ }
+ return mVideoWidth;
}
/**
- * Returns the value associated with the given key, or 0L if no integer exists
- * for the given key.
- *
- * @param key The key the value is stored under
- * @return An integer value
+ * Returns the height of the video, in the unit of pixels. Valid for {@link #TYPE_VIDEO} tracks
+ * only.
*/
- public int getInt(String key) {
- return mBundle.getInt(key, 0);
+ public final int getVideoHeight() {
+ if (mType != TYPE_VIDEO) {
+ throw new IllegalStateException("Not a video track");
+ }
+ return mVideoHeight;
}
/**
- * Returns the value associated with the given key, or false if no integer exists
- * for the given key.
- *
- * @param key The key the value is stored under
- * @return A boolean value
+ * Returns the extra information about the current track.
*/
- public boolean getBoolean(String key) {
- return mBundle.getBoolean(key, false);
+ public final Bundle getExtra() {
+ return mExtra;
}
@Override
@@ -188,13 +138,25 @@ public final class TvTrackInfo implements Parcelable {
return 0;
}
+ /**
+ * Used to package this object into a {@link Parcel}.
+ *
+ * @param dest The {@link Parcel} to be written.
+ * @param flags The flags used for parceling.
+ */
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeBundle(mBundle);
+ dest.writeInt(mType);
+ dest.writeString(mLanguage);
+ dest.writeInt(mAudioChannelCount);
+ dest.writeInt(mAudioSampleRate);
+ dest.writeInt(mVideoWidth);
+ dest.writeInt(mVideoHeight);
+ dest.writeBundle(mExtra);
}
- public static final Parcelable.Creator<TvTrackInfo> CREATOR
- = new Parcelable.Creator<TvTrackInfo>() {
+ public static final Parcelable.Creator<TvTrackInfo> CREATOR =
+ new Parcelable.Creator<TvTrackInfo>() {
@Override
public TvTrackInfo createFromParcel(Parcel in) {
return new TvTrackInfo(in);
@@ -210,73 +172,100 @@ public final class TvTrackInfo implements Parcelable {
* A builder class for creating {@link TvTrackInfo} objects.
*/
public static final class Builder {
- private final Bundle mBundle;
+ private int mType;
+ private String mLanguage;
+ private int mAudioChannelCount;
+ private int mAudioSampleRate;
+ private int mVideoWidth;
+ private int mVideoHeight;
+ private Bundle mExtra;
/**
- * Create a {@link Builder}. Any field that should be included in the
- * {@link TvTrackInfo} must be added.
+ * Create a {@link Builder}. Any field that should be included in the {@link TvTrackInfo}
+ * must be added.
*
* @param type The type of the track.
- * @param language The language of the track, using either ISO 639-1 or 639-2/T codes.
- * "und" if the language is unknown.
- * @param isSelected Whether this track is selected for the playback or not.
*/
- public Builder(int type, String language, boolean isSelected) {
- if (type != VALUE_TYPE_AUDIO
- && type != VALUE_TYPE_VIDEO
- && type != VALUE_TYPE_SUBTITLE) {
+ public Builder(int type) {
+ if (type != TYPE_AUDIO
+ && type != TYPE_VIDEO
+ && type != TYPE_SUBTITLE) {
throw new IllegalArgumentException("Unknown type: " + type);
}
- mBundle = new Bundle();
- putInt(KEY_TYPE, type);
- putString(KEY_LANGUAGE, language);
- putBoolean(KEY_IS_SELECTED, isSelected);
+ mType = type;
}
/**
- * Create a Builder using a {@link TvTrackInfo} instance to set the
- * initial values. All fields in the source metadata will be included in
- * the new metadata. Fields can be overwritten by adding the same key.
+ * Sets the language information of the current track.
*
- * @param source The source {@link TvTrackInfo} instance
+ * @param language The language string encoded by either ISO 639-1 or ISO 639-2/T.
*/
- public Builder(TvTrackInfo source) {
- mBundle = new Bundle(source.mBundle);
+ public final Builder setLanguage(String language) {
+ mLanguage = language;
+ return this;
}
/**
- * Put a String value into the track.
+ * Sets the audio channel count. Valid for {@link #TYPE_AUDIO} tracks only.
*
- * @param key The key for referencing this value
- * @param value The String value to store
- * @return The Builder to allow chaining
+ * @param audioChannelCount The audio channel count.
*/
- public Builder putString(String key, String value) {
- mBundle.putString(key, value);
+ public final Builder setAudioChannelCount(int audioChannelCount) {
+ if (mType != TYPE_AUDIO) {
+ throw new IllegalStateException("Not an audio track");
+ }
+ mAudioChannelCount = audioChannelCount;
return this;
}
/**
- * Put an integer value into the track.
+ * Sets the audio sample rate, in the unit of Hz. Valid for {@link #TYPE_AUDIO} tracks only.
*
- * @param key The key for referencing this value
- * @param value The integer value to store
- * @return The Builder to allow chaining
+ * @param audioSampleRate The audio sample rate.
*/
- public Builder putInt(String key, int value) {
- mBundle.putInt(key, value);
+ public final Builder setAudioSampleRate(int audioSampleRate) {
+ if (mType != TYPE_AUDIO) {
+ throw new IllegalStateException("Not an audio track");
+ }
+ mAudioSampleRate = audioSampleRate;
+ return this;
+ }
+
+ /**
+ * Sets the width of the video, in the unit of pixels. Valid for {@link #TYPE_VIDEO} tracks
+ * only.
+ *
+ * @param videoWidth The width of the video.
+ */
+ public final Builder setVideoWidth(int videoWidth) {
+ if (mType != TYPE_VIDEO) {
+ throw new IllegalStateException("Not a video track");
+ }
+ mVideoWidth = videoWidth;
+ return this;
+ }
+
+ /**
+ * Sets the height of the video, in the unit of pixels. Valid for {@link #TYPE_VIDEO} tracks
+ * only.
+ *
+ * @param videoHeight The height of the video.
+ */
+ public final Builder setVideoHeight(int videoHeight) {
+ if (mType != TYPE_VIDEO) {
+ throw new IllegalStateException("Not a video track");
+ }
+ mVideoHeight = videoHeight;
return this;
}
/**
- * Put a boolean value into the track.
+ * Sets the extra information about the current track.
*
- * @param key The key for referencing this value
- * @param value The boolean value to store
- * @return The Builder to allow chaining
+ * @param extra The extra information.
*/
- public Builder putBoolean(String key, boolean value) {
- mBundle.putBoolean(key, value);
+ public final Builder setExtra(Bundle extra) {
+ mExtra = new Bundle(extra);
return this;
}
@@ -286,7 +275,8 @@ public final class TvTrackInfo implements Parcelable {
* @return The new {@link TvTrackInfo} instance
*/
public TvTrackInfo build() {
- return new TvTrackInfo(mBundle);
+ return new TvTrackInfo(mType, mLanguage, mAudioChannelCount,
+ mAudioSampleRate, mVideoWidth, mVideoHeight, mExtra);
}
}
} \ No newline at end of file
diff --git a/media/java/android/media/tv/TvView.java b/media/java/android/media/tv/TvView.java
index 2f10393..7031f05 100644
--- a/media/java/android/media/tv/TvView.java
+++ b/media/java/android/media/tv/TvView.java
@@ -321,6 +321,17 @@ public class TvView extends ViewGroup {
}
/**
+ * Returns a list of selected tracks. May return {@code null} if the information is not
+ * available.
+ */
+ public List<TvTrackInfo> getSelectedTracks() {
+ if (mSession == null) {
+ return null;
+ }
+ return mSession.getSelectedTracks();
+ }
+
+ /**
* Call {@link TvInputService.Session#appPrivateCommand(String, Bundle)
* TvInputService.Session.appPrivateCommand()} on the current TvView.
*
@@ -569,10 +580,9 @@ public class TvView extends ViewGroup {
private void updateVideoSize(List<TvTrackInfo> tracks) {
for (TvTrackInfo track : tracks) {
- if (track.getBoolean(TvTrackInfo.KEY_IS_SELECTED)
- && track.getInt(TvTrackInfo.KEY_TYPE) == TvTrackInfo.VALUE_TYPE_VIDEO) {
- int width = track.getInt(TvTrackInfo.KEY_WIDTH);
- int height = track.getInt(TvTrackInfo.KEY_HEIGHT);
+ if (track.getType() == TvTrackInfo.TYPE_VIDEO) {
+ int width = track.getVideoWidth();
+ int height = track.getVideoHeight();
if (width != mVideoWidth || height != mVideoHeight) {
mVideoWidth = width;
mVideoHeight = height;
@@ -630,6 +640,15 @@ public class TvView extends ViewGroup {
}
/**
+ * This is called when there is a change on the selected tracks.
+ *
+ * @param inputId The ID of the TV input bound to this view.
+ * @param selectedTracks A list which includes track information.
+ */
+ public void onTrackSelectionChanged(String inputId, List<TvTrackInfo> selectedTracks) {
+ }
+
+ /**
* This is called when the video is available, so the TV input starts the playback.
*
* @param inputId The ID of the TV input bound to this view.
@@ -779,13 +798,26 @@ public class TvView extends ViewGroup {
if (DEBUG) {
Log.d(TAG, "onTrackInfoChanged()");
}
- updateVideoSize(tracks);
if (mListener != null) {
mListener.onTrackInfoChanged(mInputId, tracks);
}
}
@Override
+ public void onTrackSelectionChanged(Session session, List<TvTrackInfo> selectedTracks) {
+ if (this != mSessionCallback) {
+ return;
+ }
+ if (DEBUG) {
+ Log.d(TAG, "onTrackInfoChanged()");
+ }
+ updateVideoSize(selectedTracks);
+ if (mListener != null) {
+ mListener.onTrackSelectionChanged(mInputId, selectedTracks);
+ }
+ }
+
+ @Override
public void onVideoAvailable(Session session) {
if (this != mSessionCallback) {
return;