Add hearingImpaired information to TvTrackInfo
Add TIF API for getting hearing impaired attribute for audio and
subtitle tracks in order for TV App to use it.
Test: build
Bug: 112835103
Change-Id: I4046b5d49fcec2b944972bc532e844f0bdab9476
diff --git a/api/current.txt b/api/current.txt
index dc64678..bd8cc2e 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -28329,6 +28329,7 @@
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 @@
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 ab7bbca..c17beba 100644
--- a/media/java/android/media/tv/TvTrackInfo.java
+++ b/media/java/android/media/tv/TvTrackInfo.java
@@ -62,6 +62,7 @@
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 @@
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 @@
mAudioChannelCount = audioChannelCount;
mAudioSampleRate = audioSampleRate;
mAudioDescription = audioDescription;
+ mHardOfHearing = hardOfHearing;
mVideoWidth = videoWidth;
mVideoHeight = videoHeight;
mVideoFrameRate = videoFrameRate;
@@ -99,6 +101,7 @@
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 @@
}
/**
+ * 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 @@
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 @@
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 @@
&& mVideoFrameRate == obj.mVideoFrameRate
&& mVideoPixelAspectRatio == obj.mVideoPixelAspectRatio
&& mVideoActiveFormatDescription == obj.mVideoActiveFormatDescription;
+
+ case TYPE_SUBTITLE:
+ return mHardOfHearing == obj.mHardOfHearing;
}
return true;
@@ -361,6 +386,7 @@
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 @@
}
/**
+ * 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 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);
}
}