New MediaFormat keys for AAC

Decoder:
    KEY_AAC_DRC_ATTENUATION_FACTOR
    KEY_AAC_DRC_BOOST_FACTOR
    KEY_AAC_DRC_HEAVY_COMPRESSION
    KEY_AAC_DRC_TARGET_REFERENCE_LEVEL
    KEY_AAC_ENCODED_TARGET_LEVEL
    KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT
Encoder:
    KEY_AAC_SBR_MODE

Change-Id: I69abe01add135875446914134d93a58815992e07
diff --git a/api/current.txt b/api/current.txt
index 001d9b9..5de5c8b 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -14972,7 +14972,14 @@
     method public final void setInteger(java.lang.String, int);
     method public final void setLong(java.lang.String, long);
     method public final void setString(java.lang.String, java.lang.String);
+    field public static final java.lang.String KEY_AAC_DRC_ATTENUATION_FACTOR = "aac-drc-cut-level";
+    field public static final java.lang.String KEY_AAC_DRC_BOOST_FACTOR = "aac-drc-boost-level";
+    field public static final java.lang.String KEY_AAC_DRC_HEAVY_COMPRESSION = "aac-drc-heavy-compression";
+    field public static final java.lang.String KEY_AAC_DRC_TARGET_REFERENCE_LEVEL = "aac-target-ref-level";
+    field public static final java.lang.String KEY_AAC_ENCODED_TARGET_LEVEL = "aac-encoded-target-level";
+    field public static final java.lang.String KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT = "aac-max-output-channel_count";
     field public static final java.lang.String KEY_AAC_PROFILE = "aac-profile";
+    field public static final java.lang.String KEY_AAC_SBR_MODE = "aac-sbr-mode";
     field public static final java.lang.String KEY_BITRATE_MODE = "bitrate-mode";
     field public static final java.lang.String KEY_BIT_RATE = "bitrate";
     field public static final java.lang.String KEY_CHANNEL_COUNT = "channel-count";
diff --git a/media/java/android/media/MediaFormat.java b/media/java/android/media/MediaFormat.java
index 16a2235..e2825bb 100644
--- a/media/java/android/media/MediaFormat.java
+++ b/media/java/android/media/MediaFormat.java
@@ -65,6 +65,14 @@
  * <tr><td>{@link #KEY_SAMPLE_RATE}</td><td>Integer</td><td></td></tr>
  * <tr><td>{@link #KEY_IS_ADTS}</td><td>Integer</td><td>optional, if <em>decoding</em> AAC audio content, setting this key to 1 indicates that each audio frame is prefixed by the ADTS header.</td></tr>
  * <tr><td>{@link #KEY_AAC_PROFILE}</td><td>Integer</td><td><b>encoder-only</b>, optional, if content is AAC audio, specifies the desired profile.</td></tr>
+ * <tr><td>{@link #KEY_AAC_SBR_MODE}</td><td>Integer</td><td><b>encoder-only</b>, optional, if content is AAC audio, specifies the desired SBR mode.</td></tr>
+ * <tr><td>{@link #KEY_AAC_DRC_TARGET_REFERENCE_LEVEL}</td><td>Integer</td><td><b>decoder-only</b>, optional, if content is AAC audio, specifies the target reference level.</td></tr>
+ * <tr><td>{@link #KEY_AAC_ENCODED_TARGET_LEVEL}</td><td>Integer</td><td><b>decoder-only</b>, optional, if content is AAC audio, specifies the target reference level used at encoder.</td></tr>
+ * <tr><td>{@link #KEY_AAC_DRC_BOOST_FACTOR}</td><td>Integer</td><td><b>decoder-only</b>, optional, if content is AAC audio, specifies the DRC boost factor.</td></tr>
+ * <tr><td>{@link #KEY_AAC_DRC_ATTENUATION_FACTOR}</td><td>Integer</td><td><b>decoder-only</b>, optional, if content is AAC audio, specifies the DRC attenuation factor.</td></tr>
+ * <tr><td>{@link #KEY_AAC_DRC_HEAVY_COMPRESSION}</td><td>Integer</td><td><b>decoder-only</b>, optional, if content is AAC audio, specifies whether to use heavy compression.</td></tr>
+ * <tr><td>{@link #KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT}</td><td>Integer</td><td><b>decoder-only</b>, optional, if content is AAC audio, specifies the maximum number of channels the decoder outputs.</td></tr>
+ * <tr><td>{@link #}</td><td>Integer</td><td><b>decoder-only</b>, optional, if content is AAC audio, specifies .</td></tr>
  * <tr><td>{@link #KEY_CHANNEL_MASK}</td><td>Integer</td><td>optional, a mask of audio channel assignments</td></tr>
  * <tr><td>{@link #KEY_FLAC_COMPRESSION_LEVEL}</td><td>Integer</td><td><b>encoder-only</b>, optional, if content is FLAC audio, specifies the desired compression level.</td></tr>
  * </table>
@@ -261,6 +269,110 @@
     public static final String KEY_AAC_PROFILE = "aac-profile";
 
     /**
+     * A key describing the AAC SBR mode to be used (AAC audio formats only).
+     * The associated value is an integer and can be set to following values:
+     * <ul>
+     * <li>0 - no SBR should be applied</li>
+     * <li>1 - single rate SBR</li>
+     * <li>2 - double rate SBR</li>
+     * </ul>
+     * Note: If this key is not defined the default SRB mode for the desired AAC profile will
+     * be used.
+     * <p>This key is only used during encoding.
+     */
+    public static final String KEY_AAC_SBR_MODE = "aac-sbr-mode";
+
+    /**
+     * A key describing the maximum number of channels that can be output by the AAC decoder.
+     * By default, the decoder will output the same number of channels as present in the encoded
+     * stream, if supported. Set this value to limit the number of output channels, and use
+     * the downmix information in the stream, if available.
+     * <p>Values larger than the number of channels in the content to decode are ignored.
+     * <p>This key is only used during decoding.
+     */
+    public static final String KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT = "aac-max-output-channel_count";
+
+    /**
+     * A key describing a gain to be applied so that the output loudness matches the
+     * Target Reference Level. This is typically used to normalize loudness across program items.
+     * The gain is derived as the difference between the Target Reference Level and the
+     * Program Reference Level. The latter can be given in the bitstream and indicates the actual
+     * loudness value of the program item.
+     * <p>The value is given as an integer value between
+     * 0 and 127, and is calculated as -0.25 * Target Reference Level in dBFS.
+     * Therefore, it represents the range of Full Scale (0 dBFS) to -31.75 dBFS.
+     * <p>This key is only used during decoding.
+     */
+    public static final String KEY_AAC_DRC_TARGET_REFERENCE_LEVEL = "aac-target-ref-level";
+
+    /**
+     * A key describing the target reference level that was assumed at the encoder for
+     * calculation of attenuation gains for clipping prevention. This information can be provided
+     * if it is known, otherwise a worst-case assumption is used.
+     * <p>The value is given as an integer value between
+     * 0 and 127, and is calculated as -0.25 * Target Reference Level in dBFS.
+     * Therefore, it represents the range of Full Scale (0 dBFS) to -31.75 dBFS.
+     * The default value is the worst-case assumption of 127.
+     * <p>The value is ignored when heavy compression is used (see
+     * {@link #KEY_AAC_DRC_HEAVY_COMPRESSION}).
+     * <p>This key is only used during decoding.
+     */
+    public static final String KEY_AAC_ENCODED_TARGET_LEVEL = "aac-encoded-target-level";
+
+    /**
+     * A key describing the boost factor allowing to adapt the dynamics of the output to the
+     * actual listening requirements. This relies on DRC gain sequences that can be transmitted in
+     * the encoded bitstream to be able to reduce the dynamics of the output signal upon request.
+     * This factor enables the user to select how much of the gains are applied.
+     * <p>Positive gains (boost) and negative gains (attenuation, see
+     * {@link #KEY_AAC_DRC_ATTENUATION_FACTOR}) can be controlled separately for a better match
+     * to different use-cases.
+     * <p>Typically, attenuation gains are sent for loud signal segments, and boost gains are sent
+     * for soft signal segments. If the output is listened to in a noisy environment, for example,
+     * the boost factor is used to enable the positive gains, i.e. to amplify soft signal segments
+     * beyond the noise floor. But for listening late at night, the attenuation
+     * factor is used to enable the negative gains, to prevent loud signal from surprising
+     * the listener. In applications which generally need a low dynamic range, both the boost factor
+     * and the attenuation factor are used in order to enable all DRC gains.
+     * <p>In order to prevent clipping, it is also recommended to apply the attenuation factors
+     * in case of a downmix and/or loudness normalization to high target reference levels.
+     * <p>Both the boost and the attenuation factor parameters are given as integer values
+     * between 0 and 127, representing the range of the factor of 0 (i.e. don't apply)
+     * to 1 (i.e. fully apply boost/attenuation factors respectively).
+     * <p>This key is only used during decoding.
+     */
+    public static final String KEY_AAC_DRC_BOOST_FACTOR = "aac-drc-boost-level";
+
+    /**
+     * A key describing the attenuation factor allowing to adapt the dynamics of the output to the
+     * actual listening requirements.
+     * See {@link #KEY_AAC_DRC_BOOST_FACTOR} for a description of the role of this attenuation
+     * factor and the value range.
+     * <p>This key is only used during decoding.
+     */
+    public static final String KEY_AAC_DRC_ATTENUATION_FACTOR = "aac-drc-cut-level";
+
+    /**
+     * A key describing the selection of the heavy compression profile for DRC.
+     * Two separate DRC gain sequences can be transmitted in one bitstream: MPEG-4 DRC light
+     * compression, and DVB-specific heavy compression. When selecting the application of the heavy
+     * compression, one of the sequences is selected:
+     * <ul>
+     * <li>0 enables light compression,</li>
+     * <li>1 enables heavy compression instead.
+     * </ul>
+     * Note that only light compression offers the features of scaling of DRC gains
+     * (see {@link #KEY_AAC_DRC_BOOST_FACTOR} and {@link #KEY_AAC_DRC_ATTENUATION_FACTOR} for the
+     * boost and attenuation factors, and frequency-selective (multiband) DRC.
+     * Light compression usually contains clipping prevention for stereo downmixing while heavy
+     * compression, if additionally provided in the bitstream, is usually stronger, and contains
+     * clipping prevention for stereo and mono downmixing.
+     * <p>The default is light compression.
+     * <p>This key is only used during decoding.
+     */
+    public static final String KEY_AAC_DRC_HEAVY_COMPRESSION = "aac-drc-heavy-compression";
+
+    /**
      * A key describing the FLAC compression level to be used (FLAC audio format only).
      * The associated value is an integer ranging from 0 (fastest, least compression)
      * to 8 (slowest, most compression).