diff options
author | Chong Zhang <chz@google.com> | 2013-09-11 23:51:44 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-09-11 23:51:45 +0000 |
commit | bcb97996eb6e5ef257c6f4418ce49ff410002471 (patch) | |
tree | c68855a5847bcc814f79f5ed03307f696f2fade0 /media | |
parent | af2d8bbdbd9fdbcf109949ec18dc2bb2312b5744 (diff) | |
parent | f8ca13b7a09f6262f13f0301abed0ecde5175c9a (diff) | |
download | frameworks_base-bcb97996eb6e5ef257c6f4418ce49ff410002471.zip frameworks_base-bcb97996eb6e5ef257c6f4418ce49ff410002471.tar.gz frameworks_base-bcb97996eb6e5ef257c6f4418ce49ff410002471.tar.bz2 |
Merge "Pass subtitle track properties to SubtitleController" into klp-dev
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/MediaFormat.java | 22 | ||||
-rw-r--r-- | media/java/android/media/MediaPlayer.java | 26 |
2 files changed, 44 insertions, 4 deletions
diff --git a/media/java/android/media/MediaFormat.java b/media/java/android/media/MediaFormat.java index 949a42c..71af9cc 100644 --- a/media/java/android/media/MediaFormat.java +++ b/media/java/android/media/MediaFormat.java @@ -197,6 +197,28 @@ public final class MediaFormat { */ public static final String KEY_FLAC_COMPRESSION_LEVEL = "flac-compression-level"; + /** + * A key for boolean AUTOSELECT field. Tracks with AUTOSELECT=true are + * considered when automatically selecting a track without specific user + * choice (as defined by HLS). + * @hide + */ + public static final String KEY_AUTOSELECT = "autoselect"; + + /** + * A key for boolean DEFAULT field. The track with DEFAULT=true is selected + * in the absence of a specific user choice (as defined by HLS). + * @hide + */ + public static final String KEY_DEFAULT = "default"; + + /** + * A key for boolean FORCED field for subtitle tracks. True if it is a + * forced subtitle track. + * @hide + */ + public static final String KEY_FORCED = "forced"; + /* package private */ MediaFormat(Map<String, Object> map) { mMap = map; } diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index ce1896a..bcdc1c8 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -1578,7 +1578,8 @@ public class MediaPlayer implements SubtitleController.Listener * unknown or could not be determined, null is returned. */ public MediaFormat getFormat() { - if (mTrackType == MEDIA_TRACK_TYPE_TIMEDTEXT) { + if (mTrackType == MEDIA_TRACK_TYPE_TIMEDTEXT + || mTrackType == MEDIA_TRACK_TYPE_SUBTITLE) { return mFormat; } return null; @@ -1602,6 +1603,12 @@ public class MediaPlayer implements SubtitleController.Listener if (mTrackType == MEDIA_TRACK_TYPE_TIMEDTEXT) { mFormat = MediaFormat.createSubtitleFormat( MEDIA_MIMETYPE_TEXT_SUBRIP, language); + } else if (mTrackType == MEDIA_TRACK_TYPE_SUBTITLE) { + mFormat = MediaFormat.createSubtitleFormat( + MEDIA_MIMETYPE_TEXT_VTT, language); + mFormat.setInteger(MediaFormat.KEY_AUTOSELECT, in.readInt()); + mFormat.setInteger(MediaFormat.KEY_DEFAULT, in.readInt()); + mFormat.setInteger(MediaFormat.KEY_FORCED, in.readInt()); } else { mFormat = new MediaFormat(); mFormat.setString(MediaFormat.KEY_LANGUAGE, language); @@ -1629,6 +1636,12 @@ public class MediaPlayer implements SubtitleController.Listener public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mTrackType); dest.writeString(getLanguage()); + + if (mTrackType == MEDIA_TRACK_TYPE_SUBTITLE) { + dest.writeInt(mFormat.getInteger(MediaFormat.KEY_AUTOSELECT)); + dest.writeInt(mFormat.getInteger(MediaFormat.KEY_DEFAULT)); + dest.writeInt(mFormat.getInteger(MediaFormat.KEY_FORCED)); + } } /** @@ -1693,6 +1706,12 @@ public class MediaPlayer implements SubtitleController.Listener */ public static final String MEDIA_MIMETYPE_TEXT_SUBRIP = "application/x-subrip"; + /** + * MIME type for WebVTT subtitle data. + * @hide + */ + public static final String MEDIA_MIMETYPE_TEXT_VTT = "text/vtt"; + /* * A helper function to check if the mime type is supported by media framework. */ @@ -1829,9 +1848,8 @@ public class MediaPlayer implements SubtitleController.Listener if (i < mInbandSubtitleTracks.length) { inbandTracks[i] = mInbandSubtitleTracks[i]; } else { - MediaFormat format = MediaFormat.createSubtitleFormat( - "text/vtt", tracks[i].getLanguage()); - SubtitleTrack track = mSubtitleController.addTrack(format); + SubtitleTrack track = mSubtitleController.addTrack( + tracks[i].getFormat()); inbandTracks[i] = track; } } |