media: Add interface to query and set intra refresh for encoder.
Bug:26587630
Change-Id: I913a56b4888e2c46ad30ba0e9c3130da7101f7a4
diff --git a/api/current.txt b/api/current.txt
index ee4a572..72ded69 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -19991,6 +19991,7 @@
field public static final deprecated int COLOR_QCOM_FormatYUV420SemiPlanar = 2141391872; // 0x7fa30c00
field public static final deprecated int COLOR_TI_FormatYUV420PackedSemiPlanar = 2130706688; // 0x7f000100
field public static final java.lang.String FEATURE_AdaptivePlayback = "adaptive-playback";
+ field public static final java.lang.String FEATURE_IntraRefresh = "intra-refresh";
field public static final java.lang.String FEATURE_SecurePlayback = "secure-playback";
field public static final java.lang.String FEATURE_TunneledPlayback = "tunneled-playback";
field public int[] colorFormats;
@@ -20364,6 +20365,7 @@
field public static final java.lang.String KEY_FLAC_COMPRESSION_LEVEL = "flac-compression-level";
field public static final java.lang.String KEY_FRAME_RATE = "frame-rate";
field public static final java.lang.String KEY_HEIGHT = "height";
+ field public static final java.lang.String KEY_INTRA_REFRESH_PERIOD = "intra-refresh-period";
field public static final java.lang.String KEY_IS_ADTS = "is-adts";
field public static final java.lang.String KEY_IS_AUTOSELECT = "is-autoselect";
field public static final java.lang.String KEY_IS_DEFAULT = "is-default";
diff --git a/api/system-current.txt b/api/system-current.txt
index 187fa6b..7e4f00b 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -21299,6 +21299,7 @@
field public static final deprecated int COLOR_QCOM_FormatYUV420SemiPlanar = 2141391872; // 0x7fa30c00
field public static final deprecated int COLOR_TI_FormatYUV420PackedSemiPlanar = 2130706688; // 0x7f000100
field public static final java.lang.String FEATURE_AdaptivePlayback = "adaptive-playback";
+ field public static final java.lang.String FEATURE_IntraRefresh = "intra-refresh";
field public static final java.lang.String FEATURE_SecurePlayback = "secure-playback";
field public static final java.lang.String FEATURE_TunneledPlayback = "tunneled-playback";
field public int[] colorFormats;
@@ -21672,6 +21673,7 @@
field public static final java.lang.String KEY_FLAC_COMPRESSION_LEVEL = "flac-compression-level";
field public static final java.lang.String KEY_FRAME_RATE = "frame-rate";
field public static final java.lang.String KEY_HEIGHT = "height";
+ field public static final java.lang.String KEY_INTRA_REFRESH_PERIOD = "intra-refresh-period";
field public static final java.lang.String KEY_IS_ADTS = "is-adts";
field public static final java.lang.String KEY_IS_AUTOSELECT = "is-autoselect";
field public static final java.lang.String KEY_IS_DEFAULT = "is-default";
diff --git a/api/test-current.txt b/api/test-current.txt
index 915fbee..63cc8b5 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -19999,6 +19999,7 @@
field public static final deprecated int COLOR_QCOM_FormatYUV420SemiPlanar = 2141391872; // 0x7fa30c00
field public static final deprecated int COLOR_TI_FormatYUV420PackedSemiPlanar = 2130706688; // 0x7f000100
field public static final java.lang.String FEATURE_AdaptivePlayback = "adaptive-playback";
+ field public static final java.lang.String FEATURE_IntraRefresh = "intra-refresh";
field public static final java.lang.String FEATURE_SecurePlayback = "secure-playback";
field public static final java.lang.String FEATURE_TunneledPlayback = "tunneled-playback";
field public int[] colorFormats;
@@ -20372,6 +20373,7 @@
field public static final java.lang.String KEY_FLAC_COMPRESSION_LEVEL = "flac-compression-level";
field public static final java.lang.String KEY_FRAME_RATE = "frame-rate";
field public static final java.lang.String KEY_HEIGHT = "height";
+ field public static final java.lang.String KEY_INTRA_REFRESH_PERIOD = "intra-refresh-period";
field public static final java.lang.String KEY_IS_ADTS = "is-adts";
field public static final java.lang.String KEY_IS_AUTOSELECT = "is-autoselect";
field public static final java.lang.String KEY_IS_DEFAULT = "is-default";
diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java
index 0fba992..1c9c69e 100644
--- a/media/java/android/media/MediaCodecInfo.java
+++ b/media/java/android/media/MediaCodecInfo.java
@@ -460,6 +460,11 @@
public static final String FEATURE_TunneledPlayback = "tunneled-playback";
/**
+ * <b>video encoder only</b>: codec supports intra refresh.
+ */
+ public static final String FEATURE_IntraRefresh = "intra-refresh";
+
+ /**
* Query codec feature capabilities.
* <p>
* These features are supported to be used by the codec. These
@@ -486,6 +491,10 @@
new Feature(FEATURE_TunneledPlayback, (1 << 2), false),
};
+ private static final Feature[] encoderFeatures = {
+ new Feature(FEATURE_IntraRefresh, (1 << 0), false),
+ };
+
/** @hide */
public String[] validFeatures() {
Feature[] features = getValidFeatures();
@@ -500,7 +509,7 @@
if (!isEncoder()) {
return decoderFeatures;
}
- return new Feature[] {};
+ return encoderFeatures;
}
private boolean checkFeature(String name, int flags) {
diff --git a/media/java/android/media/MediaFormat.java b/media/java/android/media/MediaFormat.java
index b2fa0ac..69dd03d 100644
--- a/media/java/android/media/MediaFormat.java
+++ b/media/java/android/media/MediaFormat.java
@@ -44,7 +44,8 @@
* for encoders, readable in the output format of decoders</b></td></tr>
* <tr><td>{@link #KEY_FRAME_RATE}</td><td>Integer or Float</td><td><b>encoder-only</b></td></tr>
* <tr><td>{@link #KEY_CAPTURE_RATE}</td><td>Integer</td><td></td></tr>
-* <tr><td>{@link #KEY_I_FRAME_INTERVAL}</td><td>Integer</td><td><b>encoder-only</b></td></tr>
+ * <tr><td>{@link #KEY_I_FRAME_INTERVAL}</td><td>Integer</td><td><b>encoder-only</b></td></tr>
+ * <tr><td>{@link #KEY_INTRA_REFRESH_PERIOD}</td><td>Integer</td><td><b>encoder-only</b>, optional</td></tr>
* <tr><td>{@link #KEY_MAX_WIDTH}</td><td>Integer</td><td><b>decoder-only</b>, optional, max-resolution width</td></tr>
* <tr><td>{@link #KEY_MAX_HEIGHT}</td><td>Integer</td><td><b>decoder-only</b>, optional, max-resolution height</td></tr>
* <tr><td>{@link #KEY_REPEAT_PREVIOUS_FRAME_AFTER}</td><td>Long</td><td><b>video encoder in surface-mode only</b></td></tr>
@@ -217,6 +218,20 @@
public static final String KEY_I_FRAME_INTERVAL = "i-frame-interval";
/**
+ * An optional key describing the period of intra refresh in frames. This is an
+ * optional parameter that applies only to video encoders. If encoder supports it
+ * ({@link MediaCodecInfo.CodecCapabilities#FEATURE_IntraRefresh}), the whole
+ * frame is completely refreshed after the specified period. Also for each frame,
+ * a fix subset of macroblocks must be intra coded which leads to more constant bitrate
+ * than inserting a key frame. This key is recommended for video streaming applications
+ * as it provides low-delay and good error-resilience. This key is ignored if the
+ * video encoder does not support the intra refresh feature. Use the output format to
+ * verify that this feature was enabled.
+ * The associated value is an integer.
+ */
+ public static final String KEY_INTRA_REFRESH_PERIOD = "intra-refresh-period";
+
+ /**
* A key describing the temporal layering schema. This is an optional parameter
* that applies only to video encoders. Use {@link MediaCodec#getInputFormat}
* after {@link MediaCodec#configure configure} to query if the encoder supports