diff options
| -rw-r--r-- | api/current.txt | 2 | ||||
| -rw-r--r-- | media/java/android/media/tv/TvTrackInfo.java | 57 |
2 files changed, 54 insertions, 5 deletions
diff --git a/api/current.txt b/api/current.txt index dc646787beb8..bd8cc2eb5f4d 100644 --- a/api/current.txt +++ b/api/current.txt @@ -28329,6 +28329,7 @@ package android.media.tv { method public int getVideoWidth(); method public boolean isAudioDescription(); method public boolean isEncrypted(); + method public boolean isHardOfHearing(); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.media.tv.TvTrackInfo> CREATOR; field public static final int TYPE_AUDIO = 0; // 0x0 @@ -28345,6 +28346,7 @@ package android.media.tv { method public android.media.tv.TvTrackInfo.Builder setDescription(CharSequence); method @NonNull public android.media.tv.TvTrackInfo.Builder setEncrypted(boolean); method public android.media.tv.TvTrackInfo.Builder setExtra(android.os.Bundle); + method @NonNull public android.media.tv.TvTrackInfo.Builder setHardOfHearing(boolean); method public android.media.tv.TvTrackInfo.Builder setLanguage(String); method public android.media.tv.TvTrackInfo.Builder setVideoActiveFormatDescription(byte); method public android.media.tv.TvTrackInfo.Builder setVideoFrameRate(float); diff --git a/media/java/android/media/tv/TvTrackInfo.java b/media/java/android/media/tv/TvTrackInfo.java index ab7bbca1d01c..c17beba2b9d1 100644 --- a/media/java/android/media/tv/TvTrackInfo.java +++ b/media/java/android/media/tv/TvTrackInfo.java @@ -62,6 +62,7 @@ public final class TvTrackInfo implements Parcelable { private final int mAudioChannelCount; private final int mAudioSampleRate; private final boolean mAudioDescription; + private final boolean mHardOfHearing; private final int mVideoWidth; private final int mVideoHeight; private final float mVideoFrameRate; @@ -72,8 +73,8 @@ public final class TvTrackInfo implements Parcelable { private TvTrackInfo(int type, String id, String language, CharSequence description, boolean encrypted, int audioChannelCount, int audioSampleRate, boolean audioDescription, - int videoWidth, int videoHeight, float videoFrameRate, float videoPixelAspectRatio, - byte videoActiveFormatDescription, Bundle extra) { + boolean hardOfHearing, int videoWidth, int videoHeight, float videoFrameRate, + float videoPixelAspectRatio, byte videoActiveFormatDescription, Bundle extra) { mType = type; mId = id; mLanguage = language; @@ -82,6 +83,7 @@ public final class TvTrackInfo implements Parcelable { mAudioChannelCount = audioChannelCount; mAudioSampleRate = audioSampleRate; mAudioDescription = audioDescription; + mHardOfHearing = hardOfHearing; mVideoWidth = videoWidth; mVideoHeight = videoHeight; mVideoFrameRate = videoFrameRate; @@ -99,6 +101,7 @@ public final class TvTrackInfo implements Parcelable { mAudioChannelCount = in.readInt(); mAudioSampleRate = in.readInt(); mAudioDescription = in.readInt() != 0; + mHardOfHearing = in.readInt() != 0; mVideoWidth = in.readInt(); mVideoHeight = in.readInt(); mVideoFrameRate = in.readFloat(); @@ -192,6 +195,23 @@ public final class TvTrackInfo implements Parcelable { } /** + * Returns {@code true} if the track is intended for people with hearing impairment, {@code + * false} otherwise. Valid only for {@link #TYPE_AUDIO} and {@link #TYPE_SUBTITLE} tracks. + * + * <p>For example of broadcast, hard of hearing information may be referred to broadcast + * standard (e.g. ISO 639 Language Descriptor of ISO/IEC 13818-1, Supplementary Audio Language + * Descriptor, AC-3 Descriptor, Enhanced AC-3 Descriptor, AAC Descriptor of ETSI EN 300 468). + * + * @throws IllegalStateException if not called on an audio track or a subtitle track + */ + public boolean isHardOfHearing() { + if (mType != TYPE_AUDIO && mType != TYPE_SUBTITLE) { + throw new IllegalStateException("Not an audio or a subtitle track"); + } + return mHardOfHearing; + } + + /** * Returns the width of the video, in the unit of pixels. Valid only for {@link #TYPE_VIDEO} * tracks. * @@ -287,6 +307,7 @@ public final class TvTrackInfo implements Parcelable { dest.writeInt(mAudioChannelCount); dest.writeInt(mAudioSampleRate); dest.writeInt(mAudioDescription ? 1 : 0); + dest.writeInt(mHardOfHearing ? 1 : 0); dest.writeInt(mVideoWidth); dest.writeInt(mVideoHeight); dest.writeFloat(mVideoFrameRate); @@ -318,7 +339,8 @@ public final class TvTrackInfo implements Parcelable { case TYPE_AUDIO: return mAudioChannelCount == obj.mAudioChannelCount && mAudioSampleRate == obj.mAudioSampleRate - && mAudioDescription == obj.mAudioDescription; + && mAudioDescription == obj.mAudioDescription + && mHardOfHearing == obj.mHardOfHearing; case TYPE_VIDEO: return mVideoWidth == obj.mVideoWidth @@ -326,6 +348,9 @@ public final class TvTrackInfo implements Parcelable { && mVideoFrameRate == obj.mVideoFrameRate && mVideoPixelAspectRatio == obj.mVideoPixelAspectRatio && mVideoActiveFormatDescription == obj.mVideoActiveFormatDescription; + + case TYPE_SUBTITLE: + return mHardOfHearing == obj.mHardOfHearing; } return true; @@ -361,6 +386,7 @@ public final class TvTrackInfo implements Parcelable { private int mAudioChannelCount; private int mAudioSampleRate; private boolean mAudioDescription; + private boolean mHardOfHearing; private int mVideoWidth; private int mVideoHeight; private float mVideoFrameRate; @@ -474,6 +500,27 @@ public final class TvTrackInfo implements Parcelable { } /** + * Sets the hard of hearing attribute of the track. Valid only for {@link #TYPE_AUDIO} and + * {@link #TYPE_SUBTITLE} tracks. + * + * <p>For example of broadcast, hard of hearing information may be referred to broadcast + * standard (e.g. ISO 639 Language Descriptor of ISO/IEC 13818-1, Supplementary Audio + * Language Descriptor, AC-3 Descriptor, Enhanced AC-3 Descriptor, AAC Descriptor of ETSI EN + * 300 468). + * + * @param hardOfHearing The hard of hearing attribute of the track. + * @throws IllegalStateException if not called on an audio track or a subtitle track + */ + @NonNull + public Builder setHardOfHearing(boolean hardOfHearing) { + if (mType != TYPE_AUDIO && mType != TYPE_SUBTITLE) { + throw new IllegalStateException("Not an audio track or a subtitle track"); + } + mHardOfHearing = hardOfHearing; + return this; + } + + /** * Sets the width of the video, in the unit of pixels. Valid only for {@link #TYPE_VIDEO} * tracks. * @@ -575,8 +622,8 @@ public final class TvTrackInfo implements Parcelable { */ public TvTrackInfo build() { return new TvTrackInfo(mType, mId, mLanguage, mDescription, mEncrypted, - mAudioChannelCount, mAudioSampleRate, mAudioDescription, mVideoWidth, - mVideoHeight, mVideoFrameRate, mVideoPixelAspectRatio, + mAudioChannelCount, mAudioSampleRate, mAudioDescription, mHardOfHearing, + mVideoWidth, mVideoHeight, mVideoFrameRate, mVideoPixelAspectRatio, mVideoActiveFormatDescription, mExtra); } } |