TIF: Add the video frame rate information to TvTrackInfo

Bug: 16187997
Change-Id: I25d5489e42502fa8f2537aadc205bb4203980fb2
diff --git a/api/current.txt b/api/current.txt
index 93f30d6..de84e3f2 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -17071,6 +17071,7 @@
     method public final java.lang.String getId();
     method public final java.lang.String getLanguage();
     method public final int getType();
+    method public final float getVideoFrameRate();
     method public final int getVideoHeight();
     method public final int getVideoWidth();
     method public void writeToParcel(android.os.Parcel, int);
@@ -17087,6 +17088,7 @@
     method public final android.media.tv.TvTrackInfo.Builder setAudioSampleRate(int);
     method public final android.media.tv.TvTrackInfo.Builder setExtra(android.os.Bundle);
     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 setVideoWidth(int);
   }
diff --git a/media/java/android/media/tv/TvTrackInfo.java b/media/java/android/media/tv/TvTrackInfo.java
index 6ddb2a2..e0aacd6 100644
--- a/media/java/android/media/tv/TvTrackInfo.java
+++ b/media/java/android/media/tv/TvTrackInfo.java
@@ -46,10 +46,12 @@
     private final int mAudioSampleRate;
     private final int mVideoWidth;
     private final int mVideoHeight;
+    private final float mVideoFrameRate;
     private final Bundle mExtra;
 
     private TvTrackInfo(int type, String id, String language, int audioChannelCount,
-            int audioSampleRate, int videoWidth, int videoHeight, Bundle extra) {
+            int audioSampleRate, int videoWidth, int videoHeight, float videoFrameRate,
+            Bundle extra) {
         mType = type;
         mId = id;
         mLanguage = language;
@@ -57,6 +59,7 @@
         mAudioSampleRate = audioSampleRate;
         mVideoWidth = videoWidth;
         mVideoHeight = videoHeight;
+        mVideoFrameRate = videoFrameRate;
         mExtra = extra;
     }
 
@@ -68,6 +71,7 @@
         mAudioSampleRate = in.readInt();
         mVideoWidth = in.readInt();
         mVideoHeight = in.readInt();
+        mVideoFrameRate = in.readFloat();
         mExtra = in.readBundle();
     }
 
@@ -137,6 +141,17 @@
     }
 
     /**
+     * Returns the frame rate of the video, in the unit of fps (frames per second). Valid only for
+     * {@link #TYPE_VIDEO} tracks.
+     */
+    public final float getVideoFrameRate() {
+        if (mType != TYPE_VIDEO) {
+            throw new IllegalStateException("Not a video track");
+        }
+        return mVideoFrameRate;
+    }
+
+    /**
      * Returns the extra information about the current track.
      */
     public final Bundle getExtra() {
@@ -163,6 +178,7 @@
         dest.writeInt(mAudioSampleRate);
         dest.writeInt(mVideoWidth);
         dest.writeInt(mVideoHeight);
+        dest.writeFloat(mVideoFrameRate);
         dest.writeBundle(mExtra);
     }
 
@@ -190,6 +206,7 @@
         private int mAudioSampleRate;
         private int mVideoWidth;
         private int mVideoHeight;
+        private float mVideoFrameRate;
         private Bundle mExtra;
 
         /**
@@ -279,6 +296,20 @@
         }
 
         /**
+         * Sets the frame rate of the video, in the unit fps (frames per rate). Valid only for
+         * {@link #TYPE_VIDEO} tracks.
+         *
+         * @param videoFrameRate The frame rate of the video.
+         */
+        public final Builder setVideoFrameRate(float videoFrameRate) {
+            if (mType != TYPE_VIDEO) {
+                throw new IllegalStateException("Not a video track");
+            }
+            mVideoFrameRate = videoFrameRate;
+            return this;
+        }
+
+        /**
          * Sets the extra information about the current track.
          *
          * @param extra The extra information.
@@ -295,7 +326,7 @@
          */
         public TvTrackInfo build() {
             return new TvTrackInfo(mType, mId, mLanguage, mAudioChannelCount, mAudioSampleRate,
-                    mVideoWidth, mVideoHeight, mExtra);
+                    mVideoWidth, mVideoHeight, mVideoFrameRate, mExtra);
         }
     }
 }
\ No newline at end of file