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

Commit 24ed8072 authored by Jae Seo's avatar Jae Seo
Browse files

TIF: Add pixel aspect ratio to TvTrackInfo

Needed to handle scaling properly for some video formats such as 720x576
4:3 and 720x576 16:9 (the most common European SD formats) where pixels
are not square.

Bug: 19500694
Change-Id: I4d245ed40e8b80f7efd6acdb059d20b63b4ef9de
parent 2eabe5b7
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -17805,6 +17805,7 @@ package android.media.tv {
    method public final int getType();
    method public final int getType();
    method public final float getVideoFrameRate();
    method public final float getVideoFrameRate();
    method public final int getVideoHeight();
    method public final int getVideoHeight();
    method public final float getVideoPixelAspectRatio();
    method public final int getVideoWidth();
    method public final int getVideoWidth();
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.media.tv.TvTrackInfo> CREATOR;
    field public static final android.os.Parcelable.Creator<android.media.tv.TvTrackInfo> CREATOR;
@@ -17823,6 +17824,7 @@ package android.media.tv {
    method public final android.media.tv.TvTrackInfo.Builder setLanguage(java.lang.String);
    method public final android.media.tv.TvTrackInfo.Builder setLanguage(java.lang.String);
    method public final android.media.tv.TvTrackInfo.Builder setVideoFrameRate(float);
    method public final android.media.tv.TvTrackInfo.Builder setVideoFrameRate(float);
    method public final android.media.tv.TvTrackInfo.Builder setVideoHeight(int);
    method public final android.media.tv.TvTrackInfo.Builder setVideoHeight(int);
    method public final android.media.tv.TvTrackInfo.Builder setVideoPixelAspectRatio(float);
    method public final android.media.tv.TvTrackInfo.Builder setVideoWidth(int);
    method public final android.media.tv.TvTrackInfo.Builder setVideoWidth(int);
  }
  }
+2 −0
Original line number Original line Diff line number Diff line
@@ -19252,6 +19252,7 @@ package android.media.tv {
    method public final int getType();
    method public final int getType();
    method public final float getVideoFrameRate();
    method public final float getVideoFrameRate();
    method public final int getVideoHeight();
    method public final int getVideoHeight();
    method public final float getVideoPixelAspectRatio();
    method public final int getVideoWidth();
    method public final int getVideoWidth();
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.media.tv.TvTrackInfo> CREATOR;
    field public static final android.os.Parcelable.Creator<android.media.tv.TvTrackInfo> CREATOR;
@@ -19270,6 +19271,7 @@ package android.media.tv {
    method public final android.media.tv.TvTrackInfo.Builder setLanguage(java.lang.String);
    method public final android.media.tv.TvTrackInfo.Builder setLanguage(java.lang.String);
    method public final android.media.tv.TvTrackInfo.Builder setVideoFrameRate(float);
    method public final android.media.tv.TvTrackInfo.Builder setVideoFrameRate(float);
    method public final android.media.tv.TvTrackInfo.Builder setVideoHeight(int);
    method public final android.media.tv.TvTrackInfo.Builder setVideoHeight(int);
    method public final android.media.tv.TvTrackInfo.Builder setVideoPixelAspectRatio(float);
    method public final android.media.tv.TvTrackInfo.Builder setVideoWidth(int);
    method public final android.media.tv.TvTrackInfo.Builder setVideoWidth(int);
  }
  }
+39 −2
Original line number Original line Diff line number Diff line
@@ -48,11 +48,12 @@ public final class TvTrackInfo implements Parcelable {
    private final int mVideoWidth;
    private final int mVideoWidth;
    private final int mVideoHeight;
    private final int mVideoHeight;
    private final float mVideoFrameRate;
    private final float mVideoFrameRate;
    private final float mVideoPixelAspectRatio;
    private final Bundle mExtra;
    private final Bundle mExtra;


    private TvTrackInfo(int type, String id, String language, String description,
    private TvTrackInfo(int type, String id, String language, String description,
            int audioChannelCount, int audioSampleRate, int videoWidth, int videoHeight,
            int audioChannelCount, int audioSampleRate, int videoWidth, int videoHeight,
            float videoFrameRate, Bundle extra) {
            float videoFrameRate, float videoPixelAspectRatio, Bundle extra) {
        mType = type;
        mType = type;
        mId = id;
        mId = id;
        mLanguage = language;
        mLanguage = language;
@@ -62,6 +63,7 @@ public final class TvTrackInfo implements Parcelable {
        mVideoWidth = videoWidth;
        mVideoWidth = videoWidth;
        mVideoHeight = videoHeight;
        mVideoHeight = videoHeight;
        mVideoFrameRate = videoFrameRate;
        mVideoFrameRate = videoFrameRate;
        mVideoPixelAspectRatio = videoPixelAspectRatio;
        mExtra = extra;
        mExtra = extra;
    }
    }


@@ -75,6 +77,7 @@ public final class TvTrackInfo implements Parcelable {
        mVideoWidth = in.readInt();
        mVideoWidth = in.readInt();
        mVideoHeight = in.readInt();
        mVideoHeight = in.readInt();
        mVideoFrameRate = in.readFloat();
        mVideoFrameRate = in.readFloat();
        mVideoPixelAspectRatio = in.readFloat();
        mExtra = in.readBundle();
        mExtra = in.readBundle();
    }
    }


@@ -161,6 +164,17 @@ public final class TvTrackInfo implements Parcelable {
        return mVideoFrameRate;
        return mVideoFrameRate;
    }
    }


    /**
     * Returns the pixel aspect ratio (the ratio of a pixel's width to its height) of the video.
     * Valid only for {@link #TYPE_VIDEO} tracks.
     */
    public final float getVideoPixelAspectRatio() {
        if (mType != TYPE_VIDEO) {
            throw new IllegalStateException("Not a video track");
        }
        return mVideoPixelAspectRatio;
    }

    /**
    /**
     * Returns the extra information about the current track.
     * Returns the extra information about the current track.
     */
     */
@@ -190,6 +204,7 @@ public final class TvTrackInfo implements Parcelable {
        dest.writeInt(mVideoWidth);
        dest.writeInt(mVideoWidth);
        dest.writeInt(mVideoHeight);
        dest.writeInt(mVideoHeight);
        dest.writeFloat(mVideoFrameRate);
        dest.writeFloat(mVideoFrameRate);
        dest.writeFloat(mVideoPixelAspectRatio);
        dest.writeBundle(mExtra);
        dest.writeBundle(mExtra);
    }
    }


@@ -219,6 +234,7 @@ public final class TvTrackInfo implements Parcelable {
        private int mVideoWidth;
        private int mVideoWidth;
        private int mVideoHeight;
        private int mVideoHeight;
        private float mVideoFrameRate;
        private float mVideoFrameRate;
        private float mVideoPixelAspectRatio = 1.0f;
        private Bundle mExtra;
        private Bundle mExtra;


        /**
        /**
@@ -331,6 +347,26 @@ public final class TvTrackInfo implements Parcelable {
            return this;
            return this;
        }
        }


        /**
         * Sets the pixel aspect ratio (the ratio of a pixel's width to its height) of the video.
         * Valid only for {@link #TYPE_VIDEO} tracks.
         * <p>
         * This is needed for applications to be able to scale the video properly for some video
         * formats such as 720x576 4:3 and 720x576 16:9 where pixels are not square. By default,
         * applications assume the value of 1.0 (square pixels), so it is not necessary to set the
         * pixel aspect ratio for most video formats.
         * </p>
         *
         * @param videoPixelAspectRatio The pixel aspect ratio of the video.
         */
        public final Builder setVideoPixelAspectRatio(float videoPixelAspectRatio) {
            if (mType != TYPE_VIDEO) {
                throw new IllegalStateException("Not a video track");
            }
            mVideoPixelAspectRatio = videoPixelAspectRatio;
            return this;
        }

        /**
        /**
         * Sets the extra information about the current track.
         * Sets the extra information about the current track.
         *
         *
@@ -348,7 +384,8 @@ public final class TvTrackInfo implements Parcelable {
         */
         */
        public TvTrackInfo build() {
        public TvTrackInfo build() {
            return new TvTrackInfo(mType, mId, mLanguage, mDescription, mAudioChannelCount,
            return new TvTrackInfo(mType, mId, mLanguage, mDescription, mAudioChannelCount,
                    mAudioSampleRate, mVideoWidth, mVideoHeight, mVideoFrameRate, mExtra);
                    mAudioSampleRate, mVideoWidth, mVideoHeight, mVideoFrameRate,
                    mVideoPixelAspectRatio, mExtra);
        }
        }
    }
    }
}
}