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

Commit b744e479 authored by Jae Seo's avatar Jae Seo Committed by Android (Google) Code Review
Browse files

Merge "TIF: Add pixel aspect ratio to TvTrackInfo"

parents 52743f3b 24ed8072
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -17810,6 +17810,7 @@ package android.media.tv {
    method public final int getType();
    method public final float getVideoFrameRate();
    method public final int getVideoHeight();
    method public final float getVideoPixelAspectRatio();
    method public final int getVideoWidth();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.media.tv.TvTrackInfo> CREATOR;
@@ -17828,6 +17829,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 setVideoFrameRate(float);
    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);
  }
+2 −0
Original line number Diff line number Diff line
@@ -19261,6 +19261,7 @@ package android.media.tv {
    method public final int getType();
    method public final float getVideoFrameRate();
    method public final int getVideoHeight();
    method public final float getVideoPixelAspectRatio();
    method public final int getVideoWidth();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.media.tv.TvTrackInfo> CREATOR;
@@ -19279,6 +19280,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 setVideoFrameRate(float);
    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);
  }
+39 −2
Original line number Diff line number Diff line
@@ -48,11 +48,12 @@ public final class TvTrackInfo implements Parcelable {
    private final int mVideoWidth;
    private final int mVideoHeight;
    private final float mVideoFrameRate;
    private final float mVideoPixelAspectRatio;
    private final Bundle mExtra;

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

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

@@ -161,6 +164,17 @@ public final class TvTrackInfo implements Parcelable {
        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.
     */
@@ -190,6 +204,7 @@ public final class TvTrackInfo implements Parcelable {
        dest.writeInt(mVideoWidth);
        dest.writeInt(mVideoHeight);
        dest.writeFloat(mVideoFrameRate);
        dest.writeFloat(mVideoPixelAspectRatio);
        dest.writeBundle(mExtra);
    }

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

        /**
@@ -331,6 +347,26 @@ public final class TvTrackInfo implements Parcelable {
            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.
         *
@@ -348,7 +384,8 @@ public final class TvTrackInfo implements Parcelable {
         */
        public TvTrackInfo build() {
            return new TvTrackInfo(mType, mId, mLanguage, mDescription, mAudioChannelCount,
                    mAudioSampleRate, mVideoWidth, mVideoHeight, mVideoFrameRate, mExtra);
                    mAudioSampleRate, mVideoWidth, mVideoHeight, mVideoFrameRate,
                    mVideoPixelAspectRatio, mExtra);
        }
    }
}