Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8bbcf8aa authored by Kyeongkab.Nam's avatar Kyeongkab.Nam
Browse files

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
parent e716ff86
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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);
+52 −5
Original line number Diff line number Diff line
@@ -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();
@@ -191,6 +194,23 @@ public final class TvTrackInfo implements Parcelable {
        return mAudioDescription;
    }

    /**
     * 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;
@@ -473,6 +499,27 @@ public final class TvTrackInfo implements Parcelable {
            return this;
        }

        /**
         * 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);
        }
    }