160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber/*
260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * Copyright (C) 2012 The Android Open Source Project
360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber *
460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * Licensed under the Apache License, Version 2.0 (the "License");
560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * you may not use this file except in compliance with the License.
660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * You may obtain a copy of the License at
760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber *
860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber *      http://www.apache.org/licenses/LICENSE-2.0
960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber *
1060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * Unless required by applicable law or agreed to in writing, software
1160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * distributed under the License is distributed on an "AS IS" BASIS,
1260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * See the License for the specific language governing permissions and
1460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * limitations under the License.
1560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber */
1660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
1760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huberpackage android.media;
1860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
19b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnarimport android.annotation.IntDef;
20b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar
21b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnarimport java.lang.annotation.Retention;
22b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnarimport java.lang.annotation.RetentionPolicy;
2360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huberimport java.nio.ByteBuffer;
2460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huberimport java.util.HashMap;
2560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huberimport java.util.Map;
2660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
2760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber/**
2860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * Encapsulates the information describing the format of media data,
2960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * be it audio or video.
3060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber *
3160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * The format of the media data is specified as string/value pairs.
3260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber *
33dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar * Keys common to all audio/video formats, <b>all keys not marked optional are mandatory</b>:
3460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber *
3560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <table>
3660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <tr><th>Name</th><th>Value Type</th><th>Description</th></tr>
3760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <tr><td>{@link #KEY_MIME}</td><td>String</td><td>The type of the format.</td></tr>
3860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <tr><td>{@link #KEY_MAX_INPUT_SIZE}</td><td>Integer</td><td>optional, maximum size of a buffer of input data</td></tr>
3960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <tr><td>{@link #KEY_BIT_RATE}</td><td>Integer</td><td><b>encoder-only</b>, desired bitrate in bits/second</td></tr>
4060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * </table>
4160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber *
4260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * Video formats have the following keys:
4360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <table>
4460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <tr><th>Name</th><th>Value Type</th><th>Description</th></tr>
4560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <tr><td>{@link #KEY_WIDTH}</td><td>Integer</td><td></td></tr>
4660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <tr><td>{@link #KEY_HEIGHT}</td><td>Integer</td><td></td></tr>
47158754b1bfc9e0a03a6d9bcd999bdcbd42cedd30Martin Storsjo * <tr><td>{@link #KEY_COLOR_FORMAT}</td><td>Integer</td><td>set by the user
48158754b1bfc9e0a03a6d9bcd999bdcbd42cedd30Martin Storsjo *         for encoders, readable in the output format of decoders</b></td></tr>
497a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar * <tr><td>{@link #KEY_FRAME_RATE}</td><td>Integer or Float</td><td>required for <b>encoders</b>,
507a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar *         optional for <b>decoders</b></td></tr>
5186c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He * <tr><td>{@link #KEY_CAPTURE_RATE}</td><td>Integer</td><td></td></tr>
52be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar * <tr><td>{@link #KEY_I_FRAME_INTERVAL}</td><td>Integer (or Float)</td><td><b>encoder-only</b>,
53be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar *         time-interval between key frames.
54be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar *         Float support added in {@link android.os.Build.VERSION_CODES#N_MR1}</td></tr>
55e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang * <tr><td>{@link #KEY_INTRA_REFRESH_PERIOD}</td><td>Integer</td><td><b>encoder-only</b>, optional</td></tr>
56cd923a219fc105e5d39f70aa00f1d8db7e2dc946Hangyu Kuang * <tr><td>{@link #KEY_LATENCY}</td><td>Integer</td><td><b>encoder-only</b>, optional</td></tr>
579a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar * <tr><td>{@link #KEY_MAX_WIDTH}</td><td>Integer</td><td><b>decoder-only</b>, optional, max-resolution width</td></tr>
589a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar * <tr><td>{@link #KEY_MAX_HEIGHT}</td><td>Integer</td><td><b>decoder-only</b>, optional, max-resolution height</td></tr>
592cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar * <tr><td>{@link #KEY_REPEAT_PREVIOUS_FRAME_AFTER}</td><td>Long</td><td><b>encoder in surface-mode
602cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar *         only</b>, optional</td></tr>
612cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar * <tr><td>{@link #KEY_PUSH_BLANK_BUFFERS_ON_STOP}</td><td>Integer(1)</td><td><b>decoder rendering
622cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar *         to a surface only</b>, optional</td></tr>
632cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar * <tr><td>{@link #KEY_TEMPORAL_LAYERING}</td><td>String</td><td><b>encoder only</b>, optional,
642cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar *         temporal-layering schema</td></tr>
6560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * </table>
669a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar * Specify both {@link #KEY_MAX_WIDTH} and {@link #KEY_MAX_HEIGHT} to enable
679a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar * adaptive playback (seamless resolution change) for a video decoder that
689a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar * supports it ({@link MediaCodecInfo.CodecCapabilities#FEATURE_AdaptivePlayback}).
699a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar * The values are used as hints for the codec: they are the maximum expected
709a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar * resolution to prepare for.  Depending on codec support, preparing for larger
719a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar * maximum resolution may require more memory even if that resolution is never
729a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar * reached.  These fields have no effect for codecs that do not support adaptive
739a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar * playback.<br /><br />
7460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber *
7560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * Audio formats have the following keys:
7660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <table>
7760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <tr><th>Name</th><th>Value Type</th><th>Description</th></tr>
7860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <tr><td>{@link #KEY_CHANNEL_COUNT}</td><td>Integer</td><td></td></tr>
7960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <tr><td>{@link #KEY_SAMPLE_RATE}</td><td>Integer</td><td></td></tr>
80514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar * <tr><td>{@link #KEY_PCM_ENCODING}</td><td>Integer</td><td>optional</td></tr>
8199a86d06333b0ff668f6c0d0294d1f72c7a40d8eAndreas Huber * <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>
8260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * <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>
83a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi * <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>
84a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi * <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>
85a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi * <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>
86a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi * <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>
87a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi * <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>
88a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi * <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>
89a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi * <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>
905cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi * <tr><td>{@link #KEY_AAC_DRC_EFFECT_TYPE}</td><td>Integer</td><td><b>decoder-only</b>, optional, if content is AAC audio, specifies the MPEG-D DRC effect type to use.</td></tr>
9108067d376eae087bfaf8fdb66b5983106f98ac25Andreas Huber * <tr><td>{@link #KEY_CHANNEL_MASK}</td><td>Integer</td><td>optional, a mask of audio channel assignments</td></tr>
9208fb063f078d34e66ff697163de5797a83fb1dedJean-Michel Trivi * <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>
9360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber * </table>
9460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber *
95dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar * Subtitle formats have the following keys:
96dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar * <table>
97dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar * <tr><td>{@link #KEY_MIME}</td><td>String</td><td>The type of the format.</td></tr>
98dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar * <tr><td>{@link #KEY_LANGUAGE}</td><td>String</td><td>The language of the content.</td></tr>
99dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar * </table>
1004342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang *
1014342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang * Image formats have the following keys:
1024342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang * <table>
1034342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang * <tr><td>{@link #KEY_MIME}</td><td>String</td><td>The type of the format.</td></tr>
1044342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang * <tr><td>{@link #KEY_WIDTH}</td><td>Integer</td><td></td></tr>
1054342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang * <tr><td>{@link #KEY_HEIGHT}</td><td>Integer</td><td></td></tr>
1064342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang * <tr><td>{@link #KEY_COLOR_FORMAT}</td><td>Integer</td><td>set by the user
1074342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang *         for encoders, readable in the output format of decoders</b></td></tr>
1086c8512978af64592305e967c838d1b22d348e297Chong Zhang * <tr><td>{@link #KEY_TILE_WIDTH}</td><td>Integer</td><td>required if the image has grid</td></tr>
1096c8512978af64592305e967c838d1b22d348e297Chong Zhang * <tr><td>{@link #KEY_TILE_HEIGHT}</td><td>Integer</td><td>required if the image has grid</td></tr>
1104342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang * <tr><td>{@link #KEY_GRID_ROWS}</td><td>Integer</td><td>required if the image has grid</td></tr>
1116c8512978af64592305e967c838d1b22d348e297Chong Zhang * <tr><td>{@link #KEY_GRID_COLUMNS}</td><td>Integer</td><td>required if the image has grid</td></tr>
1124342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang * </table>
11360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber */
11460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huberpublic final class MediaFormat {
115b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_VIDEO_VP8 = "video/x-vnd.on2.vp8";
116b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_VIDEO_VP9 = "video/x-vnd.on2.vp9";
117b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_VIDEO_AVC = "video/avc";
118b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_VIDEO_HEVC = "video/hevc";
119b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_VIDEO_MPEG4 = "video/mp4v-es";
120b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_VIDEO_H263 = "video/3gpp";
121b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_VIDEO_MPEG2 = "video/mpeg2";
122b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_VIDEO_RAW = "video/raw";
123d5927ae8833780395f8fc5070d0a0a4f8f668292Chong Zhang    public static final String MIMETYPE_VIDEO_DOLBY_VISION = "video/dolby-vision";
124d5927ae8833780395f8fc5070d0a0a4f8f668292Chong Zhang    public static final String MIMETYPE_VIDEO_SCRAMBLED = "video/scrambled";
125b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar
126b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_AUDIO_AMR_NB = "audio/3gpp";
127b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_AUDIO_AMR_WB = "audio/amr-wb";
128b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_AUDIO_MPEG = "audio/mpeg";
129b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_AUDIO_AAC = "audio/mp4a-latm";
130b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_AUDIO_QCELP = "audio/qcelp";
131b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_AUDIO_VORBIS = "audio/vorbis";
132b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_AUDIO_OPUS = "audio/opus";
133b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_AUDIO_G711_ALAW = "audio/g711-alaw";
134b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_AUDIO_G711_MLAW = "audio/g711-mlaw";
135b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_AUDIO_RAW = "audio/raw";
136b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_AUDIO_FLAC = "audio/flac";
137b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_AUDIO_MSGSM = "audio/gsm";
138b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_AUDIO_AC3 = "audio/ac3";
1396564f5be74f7c2cd1db5c5c5693338c613c2074eRachad    public static final String MIMETYPE_AUDIO_EAC3 = "audio/eac3";
140d5927ae8833780395f8fc5070d0a0a4f8f668292Chong Zhang    public static final String MIMETYPE_AUDIO_SCRAMBLED = "audio/scrambled";
141b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar
142b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    /**
1434342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * MIME type for HEIF still image data encoded in HEVC.
1444342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     *
1454342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * To decode such an image, {@link MediaCodec} decoder for
1464342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * {@ #MIMETYPE_VIDEO_HEVC} shall be used. The client needs to form
1474342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * the correct {@link #MediaFormat} based on additional information in
1484342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * the track format, and send it to {@link MediaCodec#configure}.
1494342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     *
1504342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * The track's MediaFormat will come with {@link #KEY_WIDTH} and
1514342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * {@link #KEY_HEIGHT} keys, which describes the width and height
1524342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * of the image. If the image doesn't contain grid (i.e. none of
1536c8512978af64592305e967c838d1b22d348e297Chong Zhang     * {@link #KEY_TILE_WIDTH}, {@link #KEY_TILE_HEIGHT},
1546c8512978af64592305e967c838d1b22d348e297Chong Zhang     * {@link #KEY_GRID_ROWS}, {@link #KEY_GRID_COLUMNS} are present}), the
1554342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * track will contain a single sample of coded data for the entire image,
1564342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * and the image width and height should be used to set up the decoder.
1574342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     *
1584342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * If the image does come with grid, each sample from the track will
1594342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * contain one tile in the grid, of which the size is described by
1606c8512978af64592305e967c838d1b22d348e297Chong Zhang     * {@link #KEY_TILE_WIDTH} and {@link #KEY_TILE_HEIGHT}. This size
1614342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * (instead of {@link #KEY_WIDTH} and {@link #KEY_HEIGHT}) should be
1624342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * used to set up the decoder. The track contains {@link #KEY_GRID_ROWS}
1636c8512978af64592305e967c838d1b22d348e297Chong Zhang     * by {@link #KEY_GRID_COLUMNS} samples in row-major, top-row first,
1644342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * left-to-right order. The output image should be reconstructed by
1654342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * first tiling the decoding results of the tiles in the correct order,
1664342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * then trimming (before rotation is applied) on the bottom and right
1674342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * side, if the tiled area is larger than the image width and height.
1684342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     */
1694342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang    public static final String MIMETYPE_IMAGE_ANDROID_HEIC = "image/vnd.android.heic";
1704342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang
1714342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang    /**
172b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * MIME type for WebVTT subtitle data.
173b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     */
174b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_TEXT_VTT = "text/vtt";
175b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar
176b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    /**
177aabf284cbbf4ee9f3110f8d229810aafc39c2555Jean-Michel Trivi     * MIME type for SubRip (SRT) container.
178aabf284cbbf4ee9f3110f8d229810aafc39c2555Jean-Michel Trivi     */
179aabf284cbbf4ee9f3110f8d229810aafc39c2555Jean-Michel Trivi    public static final String MIMETYPE_TEXT_SUBRIP = "application/x-subrip";
180aabf284cbbf4ee9f3110f8d229810aafc39c2555Jean-Michel Trivi
181aabf284cbbf4ee9f3110f8d229810aafc39c2555Jean-Michel Trivi    /**
182b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * MIME type for CEA-608 closed caption data.
183b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     */
184b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String MIMETYPE_TEXT_CEA_608 = "text/cea-608";
185b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar
186aabf284cbbf4ee9f3110f8d229810aafc39c2555Jean-Michel Trivi    /**
187aabf284cbbf4ee9f3110f8d229810aafc39c2555Jean-Michel Trivi     * MIME type for CEA-708 closed caption data.
188aabf284cbbf4ee9f3110f8d229810aafc39c2555Jean-Michel Trivi     */
189aabf284cbbf4ee9f3110f8d229810aafc39c2555Jean-Michel Trivi    public static final String MIMETYPE_TEXT_CEA_708 = "text/cea-708";
190aabf284cbbf4ee9f3110f8d229810aafc39c2555Jean-Michel Trivi
19160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    private Map<String, Object> mMap;
19260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
19360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
19460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * A key describing the mime type of the MediaFormat.
19560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * The associated value is a string.
19660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
19760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_MIME = "mime";
19860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
19960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
2008a39021dfaf401cabb7f46b83d936ed88bf209d9Lajos Molnar     * A key describing the language of the content, using either ISO 639-1
2018a39021dfaf401cabb7f46b83d936ed88bf209d9Lajos Molnar     * or 639-2/T codes.  The associated value is a string.
202dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar     */
203dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar    public static final String KEY_LANGUAGE = "language";
204dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar
205dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar    /**
20660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * A key describing the sample rate of an audio format.
20760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * The associated value is an integer
20860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
20960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_SAMPLE_RATE = "sample-rate";
21060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
21160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
21260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * A key describing the number of channels in an audio format.
21360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * The associated value is an integer
21460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
21560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_CHANNEL_COUNT = "channel-count";
21660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
21760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
21860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * A key describing the width of the content in a video format.
21960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * The associated value is an integer
22060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
22160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_WIDTH = "width";
22260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
22360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
22460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * A key describing the height of the content in a video format.
22560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * The associated value is an integer
22660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
22760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_HEIGHT = "height";
22860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
2299a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar    /**
2309a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar     * A key describing the maximum expected width of the content in a video
2319a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar     * decoder format, in case there are resolution changes in the video content.
2329a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar     * The associated value is an integer
2339a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar     */
2349a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar    public static final String KEY_MAX_WIDTH = "max-width";
2359a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar
2369a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar    /**
2379a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar     * A key describing the maximum expected height of the content in a video
2389a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar     * decoder format, in case there are resolution changes in the video content.
2399a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar     * The associated value is an integer
2409a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar     */
2419a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar    public static final String KEY_MAX_HEIGHT = "max-height";
2429a4575c31411524f5037f78666cdb648a07a5682Lajos Molnar
24360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /** A key describing the maximum size in bytes of a buffer of data
24460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * described by this MediaFormat.
24560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * The associated value is an integer
24660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
24760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_MAX_INPUT_SIZE = "max-input-size";
24860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
24960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
2500581ee49719fba54fc37071ffa357f4518cf1583Lajos Molnar     * A key describing the average bitrate in bits/sec.
25160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * The associated value is an integer
25260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
25360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_BIT_RATE = "bitrate";
25460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
25560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
2560581ee49719fba54fc37071ffa357f4518cf1583Lajos Molnar     * A key describing the max bitrate in bits/sec.
2570581ee49719fba54fc37071ffa357f4518cf1583Lajos Molnar     * This is usually over a one-second sliding window (e.g. over any window of one second).
2580581ee49719fba54fc37071ffa357f4518cf1583Lajos Molnar     * The associated value is an integer
2590581ee49719fba54fc37071ffa357f4518cf1583Lajos Molnar     * @hide
2600581ee49719fba54fc37071ffa357f4518cf1583Lajos Molnar     */
2610581ee49719fba54fc37071ffa357f4518cf1583Lajos Molnar    public static final String KEY_MAX_BIT_RATE = "max-bitrate";
2620581ee49719fba54fc37071ffa357f4518cf1583Lajos Molnar
2630581ee49719fba54fc37071ffa357f4518cf1583Lajos Molnar    /**
26460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * A key describing the color format of the content in a video format.
26560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Constants are declared in {@link android.media.MediaCodecInfo.CodecCapabilities}.
26660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
26760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_COLOR_FORMAT = "color-format";
26860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
26960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
27060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * A key describing the frame rate of a video format in frames/sec.
2717a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar     * The associated value is normally an integer when the value is used by the platform,
2727a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar     * but video codecs also accept float configuration values.
2737a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar     * Specifically, {@link MediaExtractor#getTrackFormat MediaExtractor} provides an integer
2747a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar     * value corresponding to the frame rate information of the track if specified and non-zero.
2757a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar     * Otherwise, this key is not present. {@link MediaCodec#configure MediaCodec} accepts both
2767a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar     * float and integer values. This represents the desired operating frame rate if the
2777a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar     * {@link #KEY_OPERATING_RATE} is not present and {@link #KEY_PRIORITY} is {@code 0}
2787a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar     * (realtime). For video encoders this value corresponds to the intended frame rate,
2797a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar     * although encoders are expected
2807a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar     * to support variable frame rate based on {@link MediaCodec.BufferInfo#presentationTimeUs
2817a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar     * buffer timestamp}. This key is not used in the {@code MediaCodec}
2827a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar     * {@link MediaCodec#getInputFormat input}/{@link MediaCodec#getOutputFormat output} formats,
2837a5a93b776725a48f57c94c17f972bfcda871118Lajos Molnar     * nor by {@link MediaMuxer#addTrack MediaMuxer}.
28460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
28560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_FRAME_RATE = "frame-rate";
28660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
28760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
2886c8512978af64592305e967c838d1b22d348e297Chong Zhang     * A key describing the width (in pixels) of each tile of the content in a
2896c8512978af64592305e967c838d1b22d348e297Chong Zhang     * {@link #MIMETYPE_IMAGE_ANDROID_HEIC} track. The associated value is an integer.
2904342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     *
2914342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * Refer to {@link #MIMETYPE_IMAGE_ANDROID_HEIC} on decoding instructions of such tracks.
2924342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     *
2936c8512978af64592305e967c838d1b22d348e297Chong Zhang     * @see #KEY_TILE_HEIGHT
2944342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * @see #KEY_GRID_ROWS
2956c8512978af64592305e967c838d1b22d348e297Chong Zhang     * @see #KEY_GRID_COLUMNS
2964342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     */
2976c8512978af64592305e967c838d1b22d348e297Chong Zhang    public static final String KEY_TILE_WIDTH = "tile-width";
2984342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang
2994342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang    /**
3006c8512978af64592305e967c838d1b22d348e297Chong Zhang     * A key describing the height (in pixels) of each tile of the content in a
3016c8512978af64592305e967c838d1b22d348e297Chong Zhang     * {@link #MIMETYPE_IMAGE_ANDROID_HEIC} track. The associated value is an integer.
3024342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     *
3034342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * Refer to {@link #MIMETYPE_IMAGE_ANDROID_HEIC} on decoding instructions of such tracks.
3044342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     *
3056c8512978af64592305e967c838d1b22d348e297Chong Zhang     * @see #KEY_TILE_WIDTH
3064342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * @see #KEY_GRID_ROWS
3076c8512978af64592305e967c838d1b22d348e297Chong Zhang     * @see #KEY_GRID_COLUMNS
3084342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     */
3096c8512978af64592305e967c838d1b22d348e297Chong Zhang    public static final String KEY_TILE_HEIGHT = "tile-height";
3104342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang
3114342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang    /**
3124342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * A key describing the number of grid rows in the content in a
3134342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * {@link #MIMETYPE_IMAGE_ANDROID_HEIC} track. The associated value is an integer.
3144342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     *
3154342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * Refer to {@link #MIMETYPE_IMAGE_ANDROID_HEIC} on decoding instructions of such tracks.
3164342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     *
3176c8512978af64592305e967c838d1b22d348e297Chong Zhang     * @see #KEY_TILE_WIDTH
3186c8512978af64592305e967c838d1b22d348e297Chong Zhang     * @see #KEY_TILE_HEIGHT
3196c8512978af64592305e967c838d1b22d348e297Chong Zhang     * @see #KEY_GRID_COLUMNS
3204342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     */
3214342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang    public static final String KEY_GRID_ROWS = "grid-rows";
3224342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang
3234342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang    /**
3244342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * A key describing the number of grid columns in the content in a
3254342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * {@link #MIMETYPE_IMAGE_ANDROID_HEIC} track. The associated value is an integer.
3264342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     *
3274342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * Refer to {@link #MIMETYPE_IMAGE_ANDROID_HEIC} on decoding instructions of such tracks.
3284342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     *
3296c8512978af64592305e967c838d1b22d348e297Chong Zhang     * @see #KEY_TILE_WIDTH
3306c8512978af64592305e967c838d1b22d348e297Chong Zhang     * @see #KEY_TILE_HEIGHT
3314342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     * @see #KEY_GRID_ROWS
3324342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang     */
3336c8512978af64592305e967c838d1b22d348e297Chong Zhang    public static final String KEY_GRID_COLUMNS = "grid-cols";
3344342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang
3354342f08faba4ce730d080796b13e9f2b9b06c350Chong Zhang    /**
336514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     * A key describing the raw audio sample encoding/format.
337514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     *
338514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     * <p>The associated value is an integer, using one of the
339514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     * {@link AudioFormat}.ENCODING_PCM_ values.</p>
340514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     *
341514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     * <p>This is an optional key for audio decoders and encoders specifying the
342514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     * desired raw audio sample format during {@link MediaCodec#configure
343514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     * MediaCodec.configure(&hellip;)} call. Use {@link MediaCodec#getInputFormat
344514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     * MediaCodec.getInput}/{@link MediaCodec#getOutputFormat OutputFormat(&hellip;)}
345514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     * to confirm the actual format. For the PCM decoder this key specifies both
346514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     * input and output sample encodings.</p>
347514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     *
348514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     * <p>This key is also used by {@link MediaExtractor} to specify the sample
349514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     * format of audio data, if it is specified.</p>
350514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     *
351514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     * <p>If this key is missing, the raw audio sample format is signed 16-bit short.</p>
352514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar     */
353514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar    public static final String KEY_PCM_ENCODING = "pcm-encoding";
354514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar
355514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar    /**
35686c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He     * A key describing the capture rate of a video format in frames/sec.
35786c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He     * <p>
35886c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He     * When capture rate is different than the frame rate, it means that the
35986c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He     * video is acquired at a different rate than the playback, which produces
36086c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He     * slow motion or timelapse effect during playback. Application can use the
36186c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He     * value of this key to tell the relative speed ratio between capture and
36286c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He     * playback rates when the video was recorded.
36386c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He     * </p>
36486c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He     * <p>
36586c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He     * The associated value is an integer or a float.
36686c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He     * </p>
36786c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He     */
36886c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He    public static final String KEY_CAPTURE_RATE = "capture-rate";
36986c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He
37086c545ea8cb276e215a9e76efdde02b0ce98013fZhijun He    /**
371be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * A key describing the frequency of key frames expressed in seconds between key frames.
372be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * <p>
373be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * This key is used by video encoders.
374be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * A negative value means no key frames are requested after the first frame.
375be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * A zero value means a stream containing all key frames is requested.
376be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * <p class=note>
377be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * Most video encoders will convert this value of the number of non-key-frames between
378be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * key-frames, using the {@linkplain #KEY_FRAME_RATE frame rate} information; therefore,
379be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * if the actual frame rate differs (e.g. input frames are dropped or the frame rate
380be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * changes), the <strong>time interval</strong> between key frames will not be the
381be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * configured value.
382be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * <p>
383be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * The associated value is an integer (or float since
384be00432071c0a24b3e4d65a7921291660366f4f1Lajos Molnar     * {@link android.os.Build.VERSION_CODES#N_MR1}).
38560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
38660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_I_FRAME_INTERVAL = "i-frame-interval";
38760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
38860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
389e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang    * An optional key describing the period of intra refresh in frames. This is an
390e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang    * optional parameter that applies only to video encoders. If encoder supports it
391e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang    * ({@link MediaCodecInfo.CodecCapabilities#FEATURE_IntraRefresh}), the whole
392e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang    * frame is completely refreshed after the specified period. Also for each frame,
393e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang    * a fix subset of macroblocks must be intra coded which leads to more constant bitrate
394e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang    * than inserting a key frame. This key is recommended for video streaming applications
395e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang    * as it provides low-delay and good error-resilience. This key is ignored if the
396e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang    * video encoder does not support the intra refresh feature. Use the output format to
397e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang    * verify that this feature was enabled.
398e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang    * The associated value is an integer.
399e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang    */
400e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang    public static final String KEY_INTRA_REFRESH_PERIOD = "intra-refresh-period";
401e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang
402e9618e810a61fee9b0126fe5dd9741743f6fb332Hangyu Kuang   /**
4034b902d72dbe632472b4f56044940367aabf0e41eLajos Molnar     * A key describing the temporal layering schema.  This is an optional parameter
4042cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar     * that applies only to video encoders.  Use {@link MediaCodec#getOutputFormat}
4054b902d72dbe632472b4f56044940367aabf0e41eLajos Molnar     * after {@link MediaCodec#configure configure} to query if the encoder supports
4062cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar     * the desired schema. Supported values are {@code webrtc.vp8.N-layer},
4072cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar     * {@code android.generic.N}, {@code android.generic.N+M} and {@code none}, where
4082cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar     * {@code N} denotes the total number of non-bidirectional layers (which must be at least 1)
4092cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar     * and {@code M} denotes the total number of bidirectional layers (which must be non-negative).
4102cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar     * <p class=note>{@code android.generic.*} schemas have been added in {@link
4112cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar     * android.os.Build.VERSION_CODES#N_MR1}.
4122cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar     * <p>
4132cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar     * The encoder may support fewer temporal layers, in which case the output format
4142cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar     * will contain the configured schema. If the encoder does not support temporal
4152cfca129d600c085e16f93d9a0aca99cb334fcebLajos Molnar     * layering, the output format will not have an entry with this key.
4164b902d72dbe632472b4f56044940367aabf0e41eLajos Molnar     * The associated value is a string.
4174b902d72dbe632472b4f56044940367aabf0e41eLajos Molnar     */
4184b902d72dbe632472b4f56044940367aabf0e41eLajos Molnar    public static final String KEY_TEMPORAL_LAYERING = "ts-schema";
4194b902d72dbe632472b4f56044940367aabf0e41eLajos Molnar
4204b902d72dbe632472b4f56044940367aabf0e41eLajos Molnar    /**
421931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * A key describing the stride of the video bytebuffer layout.
422931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * Stride (or row increment) is the difference between the index of a pixel
423931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * and that of the pixel directly underneath. For YUV 420 formats, the
424931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * stride corresponds to the Y plane; the stride of the U and V planes can
4252c35fd0eba80157675ec7d9c22e33cdbecc9dafeLajos Molnar     * be calculated based on the color format, though it is generally undefined
4262c35fd0eba80157675ec7d9c22e33cdbecc9dafeLajos Molnar     * and depends on the device and release.
427931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * The associated value is an integer, representing number of bytes.
42860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
42960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_STRIDE = "stride";
430931ae62f29983fee1263d256667a6541f5434000Lajos Molnar
43160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
432931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * A key describing the plane height of a multi-planar (YUV) video bytebuffer layout.
4332c35fd0eba80157675ec7d9c22e33cdbecc9dafeLajos Molnar     * Slice height (or plane height/vertical stride) is the number of rows that must be skipped
4342c35fd0eba80157675ec7d9c22e33cdbecc9dafeLajos Molnar     * to get from the top of the Y plane to the top of the U plane in the bytebuffer. In essence
435931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * the offset of the U plane is sliceHeight * stride. The height of the U/V planes
4362c35fd0eba80157675ec7d9c22e33cdbecc9dafeLajos Molnar     * can be calculated based on the color format, though it is generally undefined
4372c35fd0eba80157675ec7d9c22e33cdbecc9dafeLajos Molnar     * and depends on the device and release.
438931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * The associated value is an integer, representing number of rows.
43960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
44060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_SLICE_HEIGHT = "slice-height";
44160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
44260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
4438f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber     * Applies only when configuring a video encoder in "surface-input" mode.
4448f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber     * The associated value is a long and gives the time in microseconds
4458f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber     * after which the frame previously submitted to the encoder will be
4468f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber     * repeated (once) if no new frame became available since.
4478f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber     */
4488f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber    public static final String KEY_REPEAT_PREVIOUS_FRAME_AFTER
4498f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber        = "repeat-previous-frame-after";
4508f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber
4518f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber    /**
4528f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber     * If specified when configuring a video decoder rendering to a surface,
4538f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber     * causes the decoder to output "blank", i.e. black frames to the surface
4548f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber     * when stopped to clear out any previously displayed contents.
4558f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber     * The associated value is an integer of value 1.
4568f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber     */
4578f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber    public static final String KEY_PUSH_BLANK_BUFFERS_ON_STOP
4588f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber        = "push-blank-buffers-on-shutdown";
4598f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber
4608f4d43c3c4c419d5a652f81c5e01554f61d4caf2Andreas Huber    /**
46160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * A key describing the duration (in microseconds) of the content.
46260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * The associated value is a long.
46360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
46460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_DURATION = "durationUs";
46560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
46660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
46760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * A key mapping to a value of 1 if the content is AAC audio and
46860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * audio frames are prefixed with an ADTS header.
46960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * The associated value is an integer (0 or 1).
47099a86d06333b0ff668f6c0d0294d1f72c7a40d8eAndreas Huber     * This key is only supported when _decoding_ content, it cannot
47199a86d06333b0ff668f6c0d0294d1f72c7a40d8eAndreas Huber     * be used to configure an encoder to emit ADTS output.
47260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
47360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_IS_ADTS = "is-adts";
47460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
47560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
47660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * A key describing the channel composition of audio content. This mask
47760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * is composed of bits drawn from channel mask definitions in {@link android.media.AudioFormat}.
47860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * The associated value is an integer.
47960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
48060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_CHANNEL_MASK = "channel-mask";
48160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
48260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
48360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * A key describing the AAC profile to be used (AAC audio formats only).
484816af56eace0c8d4eb57c5bb1b0f6747f3c9be77Martin Storsjo     * Constants are declared in {@link android.media.MediaCodecInfo.CodecProfileLevel}.
48560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
48660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final String KEY_AAC_PROFILE = "aac-profile";
48760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
48808fb063f078d34e66ff697163de5797a83fb1dedJean-Michel Trivi    /**
489a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * A key describing the AAC SBR mode to be used (AAC audio formats only).
490a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * The associated value is an integer and can be set to following values:
491a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <ul>
492a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <li>0 - no SBR should be applied</li>
493a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <li>1 - single rate SBR</li>
494a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <li>2 - double rate SBR</li>
495a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * </ul>
496a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * Note: If this key is not defined the default SRB mode for the desired AAC profile will
497a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * be used.
498a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <p>This key is only used during encoding.
499a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     */
500a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    public static final String KEY_AAC_SBR_MODE = "aac-sbr-mode";
501a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi
502a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    /**
503a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * A key describing the maximum number of channels that can be output by the AAC decoder.
504a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * By default, the decoder will output the same number of channels as present in the encoded
505a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * stream, if supported. Set this value to limit the number of output channels, and use
506a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * the downmix information in the stream, if available.
507a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <p>Values larger than the number of channels in the content to decode are ignored.
508a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <p>This key is only used during decoding.
509a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     */
510a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    public static final String KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT = "aac-max-output-channel_count";
511a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi
512a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    /**
513a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * A key describing a gain to be applied so that the output loudness matches the
514a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * Target Reference Level. This is typically used to normalize loudness across program items.
515a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * The gain is derived as the difference between the Target Reference Level and the
516a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * Program Reference Level. The latter can be given in the bitstream and indicates the actual
517a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * loudness value of the program item.
5185cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * <p>The Target Reference Level controls loudness normalization for both MPEG-4 DRC and
5195cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * MPEG-D DRC.
520a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <p>The value is given as an integer value between
5215cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * 40 and 127, and is calculated as -4 * Target Reference Level in LKFS.
5225cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * Therefore, it represents the range of -10 to -31.75 LKFS.
5235cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * <p>The default value on mobile devices is 64 (-16 LKFS).
524a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <p>This key is only used during decoding.
525a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     */
526a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    public static final String KEY_AAC_DRC_TARGET_REFERENCE_LEVEL = "aac-target-ref-level";
527a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi
528a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    /**
529bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * A key describing for selecting the DRC effect type for MPEG-D DRC.
530bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * The supported values are defined in ISO/IEC 23003-4:2015 and are described as follows:
531bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * <table>
532bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * <tr><th>Value</th><th>Effect</th></tr>
533bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * <tr><th>-1</th><th>Off</th></tr>
534bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * <tr><th>0</th><th>None</th></tr>
535bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * <tr><th>1</th><th>Late night</th></tr>
536bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * <tr><th>2</th><th>Noisy environment</th></tr>
537bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * <tr><th>3</th><th>Limited playback range</th></tr>
538bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * <tr><th>4</th><th>Low playback level</th></tr>
539bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * <tr><th>5</th><th>Dialog enhancement</th></tr>
540bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * <tr><th>6</th><th>General compression</th></tr>
541bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * </table>
542bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * <p>The value -1 (Off) disables DRC processing, while loudness normalization may still be
543bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * active and dependent on KEY_AAC_DRC_TARGET_REFERENCE_LEVEL.<br>
544bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * The value 0 (None) automatically enables DRC processing if necessary to prevent signal
545bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * clipping<br>
546bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * The value 6 (General compression) can be used for enabling MPEG-D DRC without particular
547bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * DRC effect type request.<br>
5485cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * The default DRC effect type is 3 ("Limited playback range") on mobile devices.
549bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     * <p>This key is only used during decoding.
550bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi     */
551bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi    public static final String KEY_AAC_DRC_EFFECT_TYPE = "aac-drc-effect-type";
552bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi
553bba1e9f24db90c77fa3426638cd6103430b3f41dJean-Michel Trivi    /**
554a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * A key describing the target reference level that was assumed at the encoder for
5555cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * calculation of attenuation gains for clipping prevention.
5565cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * <p>If it is known, this information can be provided as an integer value between
5575cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * 0 and 127, which is calculated as -4 * Encoded Target Level in LKFS.
5585cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * If the Encoded Target Level is unknown, the value can be set to -1.
5595cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * <p>The default value is -1 (unknown).
560a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <p>The value is ignored when heavy compression is used (see
561a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * {@link #KEY_AAC_DRC_HEAVY_COMPRESSION}).
562a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <p>This key is only used during decoding.
563a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     */
564a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    public static final String KEY_AAC_ENCODED_TARGET_LEVEL = "aac-encoded-target-level";
565a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi
566a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    /**
567a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * A key describing the boost factor allowing to adapt the dynamics of the output to the
568a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * actual listening requirements. This relies on DRC gain sequences that can be transmitted in
569a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * the encoded bitstream to be able to reduce the dynamics of the output signal upon request.
570a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * This factor enables the user to select how much of the gains are applied.
571a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <p>Positive gains (boost) and negative gains (attenuation, see
572a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * {@link #KEY_AAC_DRC_ATTENUATION_FACTOR}) can be controlled separately for a better match
573a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * to different use-cases.
574a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <p>Typically, attenuation gains are sent for loud signal segments, and boost gains are sent
575a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * for soft signal segments. If the output is listened to in a noisy environment, for example,
576a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * the boost factor is used to enable the positive gains, i.e. to amplify soft signal segments
577a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * beyond the noise floor. But for listening late at night, the attenuation
578a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * factor is used to enable the negative gains, to prevent loud signal from surprising
579a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * the listener. In applications which generally need a low dynamic range, both the boost factor
580a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * and the attenuation factor are used in order to enable all DRC gains.
5815cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * <p>In order to prevent clipping, it is also recommended to apply the attenuation gains
582a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * in case of a downmix and/or loudness normalization to high target reference levels.
583a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <p>Both the boost and the attenuation factor parameters are given as integer values
584a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * between 0 and 127, representing the range of the factor of 0 (i.e. don't apply)
5855cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * to 1 (i.e. fully apply boost/attenuation gains respectively).
5865cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * <p>The default value is 127 (fully apply boost DRC gains).
587a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <p>This key is only used during decoding.
588a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     */
589a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    public static final String KEY_AAC_DRC_BOOST_FACTOR = "aac-drc-boost-level";
590a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi
591a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    /**
592a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * A key describing the attenuation factor allowing to adapt the dynamics of the output to the
593a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * actual listening requirements.
594a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * See {@link #KEY_AAC_DRC_BOOST_FACTOR} for a description of the role of this attenuation
595a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * factor and the value range.
5965cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * <p>The default value is 127 (fully apply attenuation DRC gains).
597a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <p>This key is only used during decoding.
598a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     */
599a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    public static final String KEY_AAC_DRC_ATTENUATION_FACTOR = "aac-drc-cut-level";
600a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi
601a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    /**
602a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * A key describing the selection of the heavy compression profile for DRC.
603a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * Two separate DRC gain sequences can be transmitted in one bitstream: MPEG-4 DRC light
604a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * compression, and DVB-specific heavy compression. When selecting the application of the heavy
605a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * compression, one of the sequences is selected:
606a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <ul>
607a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <li>0 enables light compression,</li>
608a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <li>1 enables heavy compression instead.
609a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * </ul>
610a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * Note that only light compression offers the features of scaling of DRC gains
611a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * (see {@link #KEY_AAC_DRC_BOOST_FACTOR} and {@link #KEY_AAC_DRC_ATTENUATION_FACTOR} for the
612a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * boost and attenuation factors, and frequency-selective (multiband) DRC.
613a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * Light compression usually contains clipping prevention for stereo downmixing while heavy
614a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * compression, if additionally provided in the bitstream, is usually stronger, and contains
615a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * clipping prevention for stereo and mono downmixing.
6165cf2899ccd4ba8c383f4e6bd3e07139c4b63e3d3Jean-Michel Trivi     * <p>The default is 1 (heavy compression).
617a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     * <p>This key is only used during decoding.
618a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi     */
619a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    public static final String KEY_AAC_DRC_HEAVY_COMPRESSION = "aac-drc-heavy-compression";
620a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi
621a8a3f558650c266cc68f0686ced016f90e3632ddJean-Michel Trivi    /**
62208fb063f078d34e66ff697163de5797a83fb1dedJean-Michel Trivi     * A key describing the FLAC compression level to be used (FLAC audio format only).
62308fb063f078d34e66ff697163de5797a83fb1dedJean-Michel Trivi     * The associated value is an integer ranging from 0 (fastest, least compression)
62408fb063f078d34e66ff697163de5797a83fb1dedJean-Michel Trivi     * to 8 (slowest, most compression).
62508fb063f078d34e66ff697163de5797a83fb1dedJean-Michel Trivi     */
62608fb063f078d34e66ff697163de5797a83fb1dedJean-Michel Trivi    public static final String KEY_FLAC_COMPRESSION_LEVEL = "flac-compression-level";
62708fb063f078d34e66ff697163de5797a83fb1dedJean-Michel Trivi
628f8ca13b7a09f6262f13f0301abed0ecde5175c9aChong Zhang    /**
629b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * A key describing the encoding complexity.
630b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * The associated value is an integer.  These values are device and codec specific,
631b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * but lower values generally result in faster and/or less power-hungry encoding.
632b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     *
6331e88cf0796c8b15952b7d6b3160d0d097e857f15Ryan Lothian     * @see MediaCodecInfo.EncoderCapabilities#getComplexityRange()
634b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     */
635b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String KEY_COMPLEXITY = "complexity";
636b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar
637b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    /**
638b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * A key describing the desired encoding quality.
639b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * The associated value is an integer.  This key is only supported for encoders
640b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * that are configured in constant-quality mode.  These values are device and
641b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * codec specific, but lower values generally result in more efficient
642b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * (smaller-sized) encoding.
643b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     *
6441e88cf0796c8b15952b7d6b3160d0d097e857f15Ryan Lothian     * @see MediaCodecInfo.EncoderCapabilities#getQualityRange()
645b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     */
646b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String KEY_QUALITY = "quality";
647b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar
648b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    /**
649c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     * A key describing the desired codec priority.
650c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     * <p>
651c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     * The associated value is an integer. Higher value means lower priority.
652c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     * <p>
653c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     * Currently, only two levels are supported:<br>
654c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     * 0: realtime priority - meaning that the codec shall support the given
655c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     *    performance configuration (e.g. framerate) at realtime. This should
656c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     *    only be used by media playback, capture, and possibly by realtime
657c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     *    communication scenarios if best effort performance is not suitable.<br>
658c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     * 1: non-realtime priority (best effort).
659c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     * <p>
660c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     * This is a hint used at codec configuration and resource planning - to understand
661c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     * the realtime requirements of the application; however, due to the nature of
662c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     * media components, performance is not guaranteed.
663c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     *
664c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu     */
665c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu    public static final String KEY_PRIORITY = "priority";
666c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu
667c33958833fce526ae4d78dcb29cdc85067ab00cbRonghua Wu    /**
6683392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu     * A key describing the desired operating frame rate for video or sample rate for audio
6693392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu     * that the codec will need to operate at.
6703392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu     * <p>
6713392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu     * The associated value is an integer or a float representing frames-per-second or
6723392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu     * samples-per-second
6733392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu     * <p>
6743392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu     * This is used for cases like high-speed/slow-motion video capture, where the video encoder
6753392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu     * format contains the target playback rate (e.g. 30fps), but the component must be able to
6763392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu     * handle the high operating capture rate (e.g. 240fps).
6773392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu     * <p>
6783392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu     * This rate will be used by codec for resource planning and setting the operating points.
6793392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu     *
6803392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu     */
6813392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu    public static final String KEY_OPERATING_RATE = "operating-rate";
6823392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu
6833392ce4a04b117b77c58f41e9ac0e130327e9431Ronghua Wu    /**
684b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * A key describing the desired profile to be used by an encoder.
685931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * The associated value is an integer.
686b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * Constants are declared in {@link MediaCodecInfo.CodecProfileLevel}.
687931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * This key is used as a hint, and is only supported for codecs
6885cbd0b84ac3a6a886628005fb654e77f48c40e9eHangyu Kuang     * that specify a profile. Note: Codecs are free to use all the available
6895cbd0b84ac3a6a886628005fb654e77f48c40e9eHangyu Kuang     * coding tools at the specified profile.
690b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     *
691b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * @see MediaCodecInfo.CodecCapabilities#profileLevels
692b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     */
693b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String KEY_PROFILE = "profile";
694b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar
695b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    /**
696931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * A key describing the desired profile to be used by an encoder.
697931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * The associated value is an integer.
698931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * Constants are declared in {@link MediaCodecInfo.CodecProfileLevel}.
699931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * This key is used as a further hint when specifying a desired profile,
700931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * and is only supported for codecs that specify a level.
701931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * <p>
702931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * This key is ignored if the {@link #KEY_PROFILE profile} is not specified.
703931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     *
704931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * @see MediaCodecInfo.CodecCapabilities#profileLevels
705931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     */
706931ae62f29983fee1263d256667a6541f5434000Lajos Molnar    public static final String KEY_LEVEL = "level";
707931ae62f29983fee1263d256667a6541f5434000Lajos Molnar
708931ae62f29983fee1263d256667a6541f5434000Lajos Molnar    /**
709cd923a219fc105e5d39f70aa00f1d8db7e2dc946Hangyu Kuang    * An optional key describing the desired encoder latency in frames. This is an optional
710cd923a219fc105e5d39f70aa00f1d8db7e2dc946Hangyu Kuang    * parameter that applies only to video encoders. If encoder supports it, it should ouput
711cd923a219fc105e5d39f70aa00f1d8db7e2dc946Hangyu Kuang    * at least one output frame after being queued the specified number of frames. This key
712cd923a219fc105e5d39f70aa00f1d8db7e2dc946Hangyu Kuang    * is ignored if the video encoder does not support the latency feature. Use the output
713cd923a219fc105e5d39f70aa00f1d8db7e2dc946Hangyu Kuang    * format to verify that this feature was enabled and the actual value used by the encoder.
714cd923a219fc105e5d39f70aa00f1d8db7e2dc946Hangyu Kuang    * <p>
715cd923a219fc105e5d39f70aa00f1d8db7e2dc946Hangyu Kuang    * If the key is not specified, the default latency will be implenmentation specific.
716cd923a219fc105e5d39f70aa00f1d8db7e2dc946Hangyu Kuang    * The associated value is an integer.
717cd923a219fc105e5d39f70aa00f1d8db7e2dc946Hangyu Kuang    */
718cd923a219fc105e5d39f70aa00f1d8db7e2dc946Hangyu Kuang    public static final String KEY_LATENCY = "latency";
719cd923a219fc105e5d39f70aa00f1d8db7e2dc946Hangyu Kuang
720cd923a219fc105e5d39f70aa00f1d8db7e2dc946Hangyu Kuang    /**
721786828b623b65fa016b34d0464bf001535f65affHangyu Kuang     * An optional key describing the maximum number of non-display-order coded frames.
722786828b623b65fa016b34d0464bf001535f65affHangyu Kuang     * This is an optional parameter that applies only to video encoders. Application should
723786828b623b65fa016b34d0464bf001535f65affHangyu Kuang     * check the value for this key in the output format to see if codec will produce
724786828b623b65fa016b34d0464bf001535f65affHangyu Kuang     * non-display-order coded frames. If encoder supports it, the output frames' order will be
725786828b623b65fa016b34d0464bf001535f65affHangyu Kuang     * different from the display order and each frame's display order could be retrived from
726786828b623b65fa016b34d0464bf001535f65affHangyu Kuang     * {@link MediaCodec.BufferInfo#presentationTimeUs}. Before API level 27, application may
727786828b623b65fa016b34d0464bf001535f65affHangyu Kuang     * receive non-display-order coded frames even though the application did not request it.
728786828b623b65fa016b34d0464bf001535f65affHangyu Kuang     * Note: Application should not rearrange the frames to display order before feeding them
729786828b623b65fa016b34d0464bf001535f65affHangyu Kuang     * to {@link MediaMuxer#writeSampleData}.
730786828b623b65fa016b34d0464bf001535f65affHangyu Kuang     * <p>
731786828b623b65fa016b34d0464bf001535f65affHangyu Kuang     * The default value is 0.
732786828b623b65fa016b34d0464bf001535f65affHangyu Kuang     */
733786828b623b65fa016b34d0464bf001535f65affHangyu Kuang    public static final String KEY_OUTPUT_REORDER_DEPTH = "output-reorder-depth";
734786828b623b65fa016b34d0464bf001535f65affHangyu Kuang
735786828b623b65fa016b34d0464bf001535f65affHangyu Kuang    /**
736931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * A key describing the desired clockwise rotation on an output surface.
737931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * This key is only used when the codec is configured using an output surface.
7384461356ea87dfaeb8fcd175417bba12e6f63a6b8Lajos Molnar     * The associated value is an integer, representing degrees. Supported values
7394461356ea87dfaeb8fcd175417bba12e6f63a6b8Lajos Molnar     * are 0, 90, 180 or 270. This is an optional field; if not specified, rotation
7404461356ea87dfaeb8fcd175417bba12e6f63a6b8Lajos Molnar     * defaults to 0.
741931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     *
742931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     * @see MediaCodecInfo.CodecCapabilities#profileLevels
743931ae62f29983fee1263d256667a6541f5434000Lajos Molnar     */
744931ae62f29983fee1263d256667a6541f5434000Lajos Molnar    public static final String KEY_ROTATION = "rotation-degrees";
745931ae62f29983fee1263d256667a6541f5434000Lajos Molnar
746931ae62f29983fee1263d256667a6541f5434000Lajos Molnar    /**
747b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * A key describing the desired bitrate mode to be used by an encoder.
748b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * Constants are declared in {@link MediaCodecInfo.CodecCapabilities}.
749b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     *
7501e88cf0796c8b15952b7d6b3160d0d097e857f15Ryan Lothian     * @see MediaCodecInfo.EncoderCapabilities#isBitrateModeSupported(int)
751b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     */
752b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    public static final String KEY_BITRATE_MODE = "bitrate-mode";
753b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar
754b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    /**
75573fc533b2e5700d692fbbf0fb14bc0a32a02fb63Rachad     * A key describing the audio session ID of the AudioTrack associated
75673fc533b2e5700d692fbbf0fb14bc0a32a02fb63Rachad     * to a tunneled video codec.
757b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * The associated value is an integer.
758b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     *
759b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     * @see MediaCodecInfo.CodecCapabilities#FEATURE_TunneledPlayback
760b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar     */
76173fc533b2e5700d692fbbf0fb14bc0a32a02fb63Rachad    public static final String KEY_AUDIO_SESSION_ID = "audio-session-id";
762b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar
763b58dc3132272a5ec1ad4792c3c9d48b4198bd57fLajos Molnar    /**
764d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * A key for boolean AUTOSELECT behavior for the track. Tracks with AUTOSELECT=true
765d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * are considered when automatically selecting a track without specific user
766d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * choice, based on the current locale.
767d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * This is currently only used for subtitle tracks, when the user selected
768d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * 'Default' for the captioning locale.
769d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * The associated value is an integer, where non-0 means TRUE.  This is an optional
770d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * field; if not specified, AUTOSELECT defaults to TRUE.
771f8ca13b7a09f6262f13f0301abed0ecde5175c9aChong Zhang     */
772d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar    public static final String KEY_IS_AUTOSELECT = "is-autoselect";
773f8ca13b7a09f6262f13f0301abed0ecde5175c9aChong Zhang
774f8ca13b7a09f6262f13f0301abed0ecde5175c9aChong Zhang    /**
775d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * A key for boolean DEFAULT behavior for the track. The track with DEFAULT=true is
776d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * selected in the absence of a specific user choice.
777e70785fac6541a38df1fbfd2e5af6338de75d680Chong Zhang     * This is currently used in two scenarios:
778e70785fac6541a38df1fbfd2e5af6338de75d680Chong Zhang     * 1) for subtitle tracks, when the user selected 'Default' for the captioning locale.
779e70785fac6541a38df1fbfd2e5af6338de75d680Chong Zhang     * 2) for a {@link #MIMETYPE_IMAGE_ANDROID_HEIC} track, indicating the image is the
780e70785fac6541a38df1fbfd2e5af6338de75d680Chong Zhang     * primary item in the file.
781e70785fac6541a38df1fbfd2e5af6338de75d680Chong Zhang
782d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * The associated value is an integer, where non-0 means TRUE.  This is an optional
783d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * field; if not specified, DEFAULT is considered to be FALSE.
784f8ca13b7a09f6262f13f0301abed0ecde5175c9aChong Zhang     */
785d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar    public static final String KEY_IS_DEFAULT = "is-default";
786d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar
787f8ca13b7a09f6262f13f0301abed0ecde5175c9aChong Zhang    /**
788d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * A key for the FORCED field for subtitle tracks. True if it is a
789d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * forced subtitle track.  Forced subtitle tracks are essential for the
790d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * content and are shown even when the user turns off Captions.  They
791d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * are used for example to translate foreign/alien dialogs or signs.
792d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * The associated value is an integer, where non-0 means TRUE.  This is an
793d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar     * optional field; if not specified, FORCED defaults to FALSE.
794f8ca13b7a09f6262f13f0301abed0ecde5175c9aChong Zhang     */
795d486f9656a6f9d6c056d84fce39f3db8d1614e1dLajos Molnar    public static final String KEY_IS_FORCED_SUBTITLE = "is-forced-subtitle";
796f8ca13b7a09f6262f13f0301abed0ecde5175c9aChong Zhang
7973cdf7c5b622a8fbb20410736bdab5888d0e1873cRobert Shih    /** @hide */
7983cdf7c5b622a8fbb20410736bdab5888d0e1873cRobert Shih    public static final String KEY_IS_TIMED_TEXT = "is-timed-text";
7993cdf7c5b622a8fbb20410736bdab5888d0e1873cRobert Shih
8006d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    // The following color aspect values must be in sync with the ones in HardwareAPI.h.
801514a3fb7a611a93a7a60f7ff979eed6924f82222Lajos Molnar    /**
8026d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     * An optional key describing the color primaries, white point and
8036d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     * luminance factors for video content.
8046d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     *
8056d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     * The associated value is an integer: 0 if unspecified, or one of the
8066d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     * COLOR_STANDARD_ values.
8076d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     */
8086d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    public static final String KEY_COLOR_STANDARD = "color-standard";
8096d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar
8106d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    /** BT.709 color chromacity coordinates with KR = 0.2126, KB = 0.0722. */
8116d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    public static final int COLOR_STANDARD_BT709 = 1;
8126d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar
8136d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    /** BT.601 625 color chromacity coordinates with KR = 0.299, KB = 0.114. */
8146d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    public static final int COLOR_STANDARD_BT601_PAL = 2;
8156d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar
8166d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    /** BT.601 525 color chromacity coordinates with KR = 0.299, KB = 0.114. */
8176d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    public static final int COLOR_STANDARD_BT601_NTSC = 4;
8186d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar
8196d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    /** BT.2020 color chromacity coordinates with KR = 0.2627, KB = 0.0593. */
8206d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    public static final int COLOR_STANDARD_BT2020 = 6;
8216d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar
822b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    /** @hide */
823b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    @IntDef({
824b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar        COLOR_STANDARD_BT709,
825b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar        COLOR_STANDARD_BT601_PAL,
826b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar        COLOR_STANDARD_BT601_NTSC,
827b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar        COLOR_STANDARD_BT2020,
828b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    })
829b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    @Retention(RetentionPolicy.SOURCE)
830b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    public @interface ColorStandard {}
831b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar
8326d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    /**
8336d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     * An optional key describing the opto-electronic transfer function used
8346d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     * for the video content.
8356d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     *
8366d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     * The associated value is an integer: 0 if unspecified, or one of the
8376d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     * COLOR_TRANSFER_ values.
8386d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     */
8396d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    public static final String KEY_COLOR_TRANSFER = "color-transfer";
8406d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar
8416d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    /** Linear transfer characteristic curve. */
8426d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    public static final int COLOR_TRANSFER_LINEAR = 1;
8436d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar
8446d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    /** SMPTE 170M transfer characteristic curve used by BT.601/BT.709/BT.2020. This is the curve
8456d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     *  used by most non-HDR video content. */
8466d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    public static final int COLOR_TRANSFER_SDR_VIDEO = 3;
8476d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar
8486d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    /** SMPTE ST 2084 transfer function. This is used by some HDR video content. */
8496d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    public static final int COLOR_TRANSFER_ST2084 = 6;
8506d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar
8516d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    /** ARIB STD-B67 hybrid-log-gamma transfer function. This is used by some HDR video content. */
8526d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    public static final int COLOR_TRANSFER_HLG = 7;
8536d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar
854b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    /** @hide */
855b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    @IntDef({
856b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar        COLOR_TRANSFER_LINEAR,
857b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar        COLOR_TRANSFER_SDR_VIDEO,
858b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar        COLOR_TRANSFER_ST2084,
859b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar        COLOR_TRANSFER_HLG,
860b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    })
861b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    @Retention(RetentionPolicy.SOURCE)
862b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    public @interface ColorTransfer {}
863b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar
8646d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    /**
8656d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     * An optional key describing the range of the component values of the video content.
8666d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     *
8676d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     * The associated value is an integer: 0 if unspecified, or one of the
8686d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     * COLOR_RANGE_ values.
8696d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     */
8706d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    public static final String KEY_COLOR_RANGE = "color-range";
8716d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar
8726d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    /** Limited range. Y component values range from 16 to 235 for 8-bit content.
8736d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     *  Cr, Cy values range from 16 to 240 for 8-bit content.
8746d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar     *  This is the default for video content. */
8756d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    public static final int COLOR_RANGE_LIMITED = 2;
8766d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar
8776d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    /** Full range. Y, Cr and Cb component values range from 0 to 255 for 8-bit content. */
8786d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar    public static final int COLOR_RANGE_FULL = 1;
8796d9ef6419aed30bd896bc35c954ff6086de31a1bLajos Molnar
880b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    /** @hide */
881b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    @IntDef({
882b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar        COLOR_RANGE_LIMITED,
883b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar        COLOR_RANGE_FULL,
884b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    })
885b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    @Retention(RetentionPolicy.SOURCE)
886b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar    public @interface ColorRange {}
887b12d49bb1e4498a76ac4d1700d19dc81ff9ae297Lajos Molnar
8886ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar    /**
889ac76fa3581cfbd7bdeb30a070ef78ee2f8f39468Lajos Molnar     * An optional key describing the static metadata of HDR (high-dynamic-range) video content.
890ac76fa3581cfbd7bdeb30a070ef78ee2f8f39468Lajos Molnar     *
891ac76fa3581cfbd7bdeb30a070ef78ee2f8f39468Lajos Molnar     * The associated value is a ByteBuffer. This buffer contains the raw contents of the
892ac76fa3581cfbd7bdeb30a070ef78ee2f8f39468Lajos Molnar     * Static Metadata Descriptor (including the descriptor ID) of an HDMI Dynamic Range and
893ac76fa3581cfbd7bdeb30a070ef78ee2f8f39468Lajos Molnar     * Mastering InfoFrame as defined by CTA-861.3. This key must be provided to video decoders
894ac76fa3581cfbd7bdeb30a070ef78ee2f8f39468Lajos Molnar     * for HDR video content unless this information is contained in the bitstream and the video
895ac76fa3581cfbd7bdeb30a070ef78ee2f8f39468Lajos Molnar     * decoder supports an HDR-capable profile. This key must be provided to video encoders for
896ac76fa3581cfbd7bdeb30a070ef78ee2f8f39468Lajos Molnar     * HDR video content.
897ac76fa3581cfbd7bdeb30a070ef78ee2f8f39468Lajos Molnar     */
898ac76fa3581cfbd7bdeb30a070ef78ee2f8f39468Lajos Molnar    public static final String KEY_HDR_STATIC_INFO = "hdr-static-info";
899ac76fa3581cfbd7bdeb30a070ef78ee2f8f39468Lajos Molnar
900ac76fa3581cfbd7bdeb30a070ef78ee2f8f39468Lajos Molnar    /**
9016ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar     * A key describing a unique ID for the content of a media track.
9026ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar     *
9036ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar     * <p>This key is used by {@link MediaExtractor}. Some extractors provide multiple encodings
9046ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar     * of the same track (e.g. float audio tracks for FLAC and WAV may be expressed as two
9056ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar     * tracks via MediaExtractor: a normal PCM track for backward compatibility, and a float PCM
9066ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar     * track for added fidelity. Similarly, Dolby Vision extractor may provide a baseline SDR
9076ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar     * version of a DV track.) This key can be used to identify which MediaExtractor tracks refer
9086ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar     * to the same underlying content.
9096ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar     * </p>
9106ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar     *
9116ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar     * The associated value is an integer.
9126ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar     */
9136ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar    public static final String KEY_TRACK_ID = "track-id";
9146ef0ac3278be02c2249170b862245692e5afa80dLajos Molnar
915addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang    /**
916addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * A key describing the system id of the conditional access system used to scramble
917addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * a media track.
918addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * <p>
919addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * This key is set by {@link MediaExtractor} if the track is scrambled with a conditional
920addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * access system.
921addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * <p>
922addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * The associated value is an integer.
923addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * @hide
924addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     */
925addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang    public static final String KEY_CA_SYSTEM_ID = "ca-system-id";
926addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang
927addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang    /**
928addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * A key describing the {@link MediaCas.Session} object associated with a media track.
929addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * <p>
930addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * This key is set by {@link MediaExtractor} if the track is scrambled with a conditional
931addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * access system.
932addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * <p>
933addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * The associated value is a ByteBuffer.
934addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     * @hide
935addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang     */
936addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang    public static final String KEY_CA_SESSION_ID = "ca-session-id";
937addc39ec27f3eb9b61ad8565804201a866d16abdChong Zhang
93860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /* package private */ MediaFormat(Map<String, Object> map) {
93960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        mMap = map;
94060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
94160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
94260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
94360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Creates an empty MediaFormat
94460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
94560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public MediaFormat() {
94660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        mMap = new HashMap();
94760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
94860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
94960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /* package private */ Map<String, Object> getMap() {
95060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        return mMap;
95160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
95260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
95360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
95460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Returns true iff a key of the given name exists in the format.
95560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
95660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public final boolean containsKey(String name) {
95760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        return mMap.containsKey(name);
95860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
95960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
96060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
961217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * A key prefix used together with a {@link MediaCodecInfo.CodecCapabilities}
962217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * feature name describing a required or optional feature for a codec capabilities
963217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * query.
964217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * The associated value is an integer, where non-0 value means the feature is
965217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * requested to be present, while 0 value means the feature is requested to be not
966217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * present.
967217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * @see MediaCodecList#findDecoderForFormat
968217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * @see MediaCodecList#findEncoderForFormat
969217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * @see MediaCodecInfo.CodecCapabilities#isFormatSupported
970217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     *
971217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * @hide
972217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     */
973217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar    public static final String KEY_FEATURE_ = "feature-";
974217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar
975217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar    /**
97660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Returns the value of an integer key.
97760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
97860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public final int getInteger(String name) {
97960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        return ((Integer)mMap.get(name)).intValue();
98060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
98160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
98260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
98324390c11b23f83c4737c590c2beaef935469b35dLajos Molnar     * Returns the value of an integer key, or the default value if the
98424390c11b23f83c4737c590c2beaef935469b35dLajos Molnar     * key is missing or is for another type value.
98524390c11b23f83c4737c590c2beaef935469b35dLajos Molnar     * @hide
98624390c11b23f83c4737c590c2beaef935469b35dLajos Molnar     */
98724390c11b23f83c4737c590c2beaef935469b35dLajos Molnar    public final int getInteger(String name, int defaultValue) {
98824390c11b23f83c4737c590c2beaef935469b35dLajos Molnar        try {
98924390c11b23f83c4737c590c2beaef935469b35dLajos Molnar            return getInteger(name);
99024390c11b23f83c4737c590c2beaef935469b35dLajos Molnar        }
99124390c11b23f83c4737c590c2beaef935469b35dLajos Molnar        catch (NullPointerException  e) { /* no such field */ }
99224390c11b23f83c4737c590c2beaef935469b35dLajos Molnar        catch (ClassCastException e) { /* field of different type */ }
99324390c11b23f83c4737c590c2beaef935469b35dLajos Molnar        return defaultValue;
99424390c11b23f83c4737c590c2beaef935469b35dLajos Molnar    }
99524390c11b23f83c4737c590c2beaef935469b35dLajos Molnar
99624390c11b23f83c4737c590c2beaef935469b35dLajos Molnar    /**
99760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Returns the value of a long key.
99860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
99960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public final long getLong(String name) {
100060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        return ((Long)mMap.get(name)).longValue();
100160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
100260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
100360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
100460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Returns the value of a float key.
100560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
100660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public final float getFloat(String name) {
100760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        return ((Float)mMap.get(name)).floatValue();
100860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
100960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
101060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
101160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Returns the value of a string key.
101260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
101360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public final String getString(String name) {
101460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        return (String)mMap.get(name);
101560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
101660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
101760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
101860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Returns the value of a ByteBuffer key.
101960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
102060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public final ByteBuffer getByteBuffer(String name) {
102160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        return (ByteBuffer)mMap.get(name);
102260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
102360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
102460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
1025217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * Returns whether a feature is to be enabled ({@code true}) or disabled
1026217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * ({@code false}).
1027217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     *
1028217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * @param feature the name of a {@link MediaCodecInfo.CodecCapabilities} feature.
1029217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     *
1030217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * @throws IllegalArgumentException if the feature was neither set to be enabled
1031217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     *        nor to be disabled.
1032217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     */
1033217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar    public boolean getFeatureEnabled(String feature) {
1034217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar        Integer enabled = (Integer)mMap.get(KEY_FEATURE_ + feature);
1035217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar        if (enabled == null) {
1036217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar            throw new IllegalArgumentException("feature is not specified");
1037217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar        }
1038217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar        return enabled != 0;
1039217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar    }
1040217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar
1041217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar    /**
104260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Sets the value of an integer key.
104360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
104460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public final void setInteger(String name, int value) {
10455c5978985a3457539d1f3b611f23d26b77484536Andreas Gampe        mMap.put(name, Integer.valueOf(value));
104660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
104760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
104860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
104960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Sets the value of a long key.
105060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
105160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public final void setLong(String name, long value) {
10525c5978985a3457539d1f3b611f23d26b77484536Andreas Gampe        mMap.put(name, Long.valueOf(value));
105360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
105460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
105560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
105660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Sets the value of a float key.
105760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
105860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public final void setFloat(String name, float value) {
105960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        mMap.put(name, new Float(value));
106060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
106160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
106260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
106360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Sets the value of a string key.
106460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
106560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public final void setString(String name, String value) {
106660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        mMap.put(name, value);
106760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
106860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
106960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
107060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Sets the value of a ByteBuffer key.
107160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
107260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public final void setByteBuffer(String name, ByteBuffer bytes) {
107360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        mMap.put(name, bytes);
107460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
107560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
107660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
1077217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * Sets whether a feature is to be enabled ({@code true}) or disabled
1078217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * ({@code false}).
1079217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     *
1080217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * If {@code enabled} is {@code true}, the feature is requested to be present.
1081217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * Otherwise, the feature is requested to be not present.
1082217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     *
1083217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * @param feature the name of a {@link MediaCodecInfo.CodecCapabilities} feature.
1084217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     *
1085217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * @see MediaCodecList#findDecoderForFormat
1086217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * @see MediaCodecList#findEncoderForFormat
1087217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     * @see MediaCodecInfo.CodecCapabilities#isFormatSupported
1088217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar     */
1089217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar    public void setFeatureEnabled(String feature, boolean enabled) {
1090217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar        setInteger(KEY_FEATURE_ + feature, enabled ? 1 : 0);
1091217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar    }
1092217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar
1093217474682ab9c551f331a598cf99d4e8d50f2a8dLajos Molnar    /**
109460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Creates a minimal audio format.
109560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * @param mime The mime type of the content.
109660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * @param sampleRate The sampling rate of the content.
109760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * @param channelCount The number of audio channels in the content.
109860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
109960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final MediaFormat createAudioFormat(
110060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber            String mime,
110160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber            int sampleRate,
110260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber            int channelCount) {
110360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        MediaFormat format = new MediaFormat();
110460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        format.setString(KEY_MIME, mime);
110560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        format.setInteger(KEY_SAMPLE_RATE, sampleRate);
110660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        format.setInteger(KEY_CHANNEL_COUNT, channelCount);
110760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
110860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        return format;
110960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
111060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
111160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    /**
1112dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar     * Creates a minimal subtitle format.
1113dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar     * @param mime The mime type of the content.
11148a39021dfaf401cabb7f46b83d936ed88bf209d9Lajos Molnar     * @param language The language of the content, using either ISO 639-1 or 639-2/T
11158a39021dfaf401cabb7f46b83d936ed88bf209d9Lajos Molnar     *        codes.  Specify null or "und" if language information is only included
11168a39021dfaf401cabb7f46b83d936ed88bf209d9Lajos Molnar     *        in the content.  (This will also work if there are multiple language
11178a39021dfaf401cabb7f46b83d936ed88bf209d9Lajos Molnar     *        tracks in the content.)
1118dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar     */
1119dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar    public static final MediaFormat createSubtitleFormat(
1120dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar            String mime,
1121dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar            String language) {
1122dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar        MediaFormat format = new MediaFormat();
1123dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar        format.setString(KEY_MIME, mime);
1124dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar        format.setString(KEY_LANGUAGE, language);
1125dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar
1126dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar        return format;
1127dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar    }
1128dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar
1129dc775c66bf52d998e6cc37a0ba1ec3b12607fac4Lajos Molnar    /**
113060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * Creates a minimal video format.
113160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * @param mime The mime type of the content.
113260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * @param width The width of the content (in pixels)
113360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     * @param height The height of the content (in pixels)
113460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber     */
113560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public static final MediaFormat createVideoFormat(
113660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber            String mime,
113760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber            int width,
113860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber            int height) {
113960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        MediaFormat format = new MediaFormat();
114060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        format.setString(KEY_MIME, mime);
114160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        format.setInteger(KEY_WIDTH, width);
114260d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        format.setInteger(KEY_HEIGHT, height);
114360d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
114460d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        return format;
114560d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
114660d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber
114760d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    @Override
114860d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    public String toString() {
114960d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber        return mMap.toString();
115060d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber    }
115160d610bf103379277a4b29a7ead4f013f6128e4eAndreas Huber}
1152