1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.media;
18 
19 import android.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.compat.annotation.UnsupportedAppUsage;
23 
24 import java.lang.annotation.Retention;
25 import java.lang.annotation.RetentionPolicy;
26 import java.nio.ByteBuffer;
27 import java.util.AbstractSet;
28 import java.util.HashMap;
29 import java.util.Iterator;
30 import java.util.Map;
31 import java.util.Set;
32 import java.util.stream.Collectors;
33 
34 /**
35  * Encapsulates the information describing the format of media data, be it audio or video, as
36  * well as optional feature metadata.
37  * <p>
38  * The format of the media data is specified as key/value pairs. Keys are strings. Values can
39  * be integer, long, float, String or ByteBuffer.
40  * <p>
41  * The feature metadata is specificed as string/boolean pairs.
42  * <p>
43  * Keys common to all audio/video formats, <b>all keys not marked optional are mandatory</b>:
44  *
45  * <table>
46  * <tr><th>Name</th><th>Value Type</th><th>Description</th></tr>
47  * <tr><td>{@link #KEY_MIME}</td><td>String</td><td>The type of the format.</td></tr>
48  * <tr><td>{@link #KEY_MAX_INPUT_SIZE}</td><td>Integer</td><td>optional, maximum size of a buffer of input data</td></tr>
49  * <tr><td>{@link #KEY_BIT_RATE}</td><td>Integer</td><td><b>encoder-only</b>, desired bitrate in bits/second</td></tr>
50  * </table>
51  *
52  * Video formats have the following keys:
53  * <table>
54  * <tr><th>Name</th><th>Value Type</th><th>Description</th></tr>
55  * <tr><td>{@link #KEY_WIDTH}</td><td>Integer</td><td></td></tr>
56  * <tr><td>{@link #KEY_HEIGHT}</td><td>Integer</td><td></td></tr>
57  * <tr><td>{@link #KEY_COLOR_FORMAT}</td><td>Integer</td><td>set by the user
58  *         for encoders, readable in the output format of decoders</b></td></tr>
59  * <tr><td>{@link #KEY_FRAME_RATE}</td><td>Integer or Float</td><td>required for <b>encoders</b>,
60  *         optional for <b>decoders</b></td></tr>
61  * <tr><td>{@link #KEY_CAPTURE_RATE}</td><td>Integer</td><td></td></tr>
62  * <tr><td>{@link #KEY_I_FRAME_INTERVAL}</td><td>Integer (or Float)</td><td><b>encoder-only</b>,
63  *         time-interval between key frames.
64  *         Float support added in {@link android.os.Build.VERSION_CODES#N_MR1}</td></tr>
65  * <tr><td>{@link #KEY_INTRA_REFRESH_PERIOD}</td><td>Integer</td><td><b>encoder-only</b>, optional</td></tr>
66  * <tr><td>{@link #KEY_LATENCY}</td><td>Integer</td><td><b>encoder-only</b>, optional</td></tr>
67  * <tr><td>{@link #KEY_MAX_WIDTH}</td><td>Integer</td><td><b>decoder-only</b>, optional, max-resolution width</td></tr>
68  * <tr><td>{@link #KEY_MAX_HEIGHT}</td><td>Integer</td><td><b>decoder-only</b>, optional, max-resolution height</td></tr>
69  * <tr><td>{@link #KEY_REPEAT_PREVIOUS_FRAME_AFTER}</td><td>Long</td><td><b>encoder in surface-mode
70  *         only</b>, optional</td></tr>
71  * <tr><td>{@link #KEY_PUSH_BLANK_BUFFERS_ON_STOP}</td><td>Integer(1)</td><td><b>decoder rendering
72  *         to a surface only</b>, optional</td></tr>
73  * <tr><td>{@link #KEY_TEMPORAL_LAYERING}</td><td>String</td><td><b>encoder only</b>, optional,
74  *         temporal-layering schema</td></tr>
75  * </table>
76  * Specify both {@link #KEY_MAX_WIDTH} and {@link #KEY_MAX_HEIGHT} to enable
77  * adaptive playback (seamless resolution change) for a video decoder that
78  * supports it ({@link MediaCodecInfo.CodecCapabilities#FEATURE_AdaptivePlayback}).
79  * The values are used as hints for the codec: they are the maximum expected
80  * resolution to prepare for.  Depending on codec support, preparing for larger
81  * maximum resolution may require more memory even if that resolution is never
82  * reached.  These fields have no effect for codecs that do not support adaptive
83  * playback.<br /><br />
84  *
85  * Audio formats have the following keys:
86  * <table>
87  * <tr><th>Name</th><th>Value Type</th><th>Description</th></tr>
88  * <tr><td>{@link #KEY_CHANNEL_COUNT}</td><td>Integer</td><td></td></tr>
89  * <tr><td>{@link #KEY_SAMPLE_RATE}</td><td>Integer</td><td></td></tr>
90  * <tr><td>{@link #KEY_PCM_ENCODING}</td><td>Integer</td><td>optional</td></tr>
91  * <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>
92  * <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>
93  * <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>
94  * <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>
95  * <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>
96  * <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>
97  * <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>
98  * <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>
99  * <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>
100  * <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>
101  * <tr><td>{@link #KEY_CHANNEL_MASK}</td><td>Integer</td><td>optional, a mask of audio channel assignments</td></tr>
102  * <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>
103  * </table>
104  *
105  * Subtitle formats have the following keys:
106  * <table>
107  * <tr><td>{@link #KEY_MIME}</td><td>String</td><td>The type of the format.</td></tr>
108  * <tr><td>{@link #KEY_LANGUAGE}</td><td>String</td><td>The language of the content.</td></tr>
109  * </table>
110  *
111  * Image formats have the following keys:
112  * <table>
113  * <tr><td>{@link #KEY_MIME}</td><td>String</td><td>The type of the format.</td></tr>
114  * <tr><td>{@link #KEY_WIDTH}</td><td>Integer</td><td></td></tr>
115  * <tr><td>{@link #KEY_HEIGHT}</td><td>Integer</td><td></td></tr>
116  * <tr><td>{@link #KEY_COLOR_FORMAT}</td><td>Integer</td><td>set by the user
117  *         for encoders, readable in the output format of decoders</b></td></tr>
118  * <tr><td>{@link #KEY_TILE_WIDTH}</td><td>Integer</td><td>required if the image has grid</td></tr>
119  * <tr><td>{@link #KEY_TILE_HEIGHT}</td><td>Integer</td><td>required if the image has grid</td></tr>
120  * <tr><td>{@link #KEY_GRID_ROWS}</td><td>Integer</td><td>required if the image has grid</td></tr>
121  * <tr><td>{@link #KEY_GRID_COLUMNS}</td><td>Integer</td><td>required if the image has grid</td></tr>
122  * </table>
123  */
124 public final class MediaFormat {
125     public static final String MIMETYPE_VIDEO_VP8 = "video/x-vnd.on2.vp8";
126     public static final String MIMETYPE_VIDEO_VP9 = "video/x-vnd.on2.vp9";
127     public static final String MIMETYPE_VIDEO_AV1 = "video/av01";
128     public static final String MIMETYPE_VIDEO_AVC = "video/avc";
129     public static final String MIMETYPE_VIDEO_HEVC = "video/hevc";
130     public static final String MIMETYPE_VIDEO_MPEG4 = "video/mp4v-es";
131     public static final String MIMETYPE_VIDEO_H263 = "video/3gpp";
132     public static final String MIMETYPE_VIDEO_MPEG2 = "video/mpeg2";
133     public static final String MIMETYPE_VIDEO_RAW = "video/raw";
134     public static final String MIMETYPE_VIDEO_DOLBY_VISION = "video/dolby-vision";
135     public static final String MIMETYPE_VIDEO_SCRAMBLED = "video/scrambled";
136 
137     public static final String MIMETYPE_AUDIO_AMR_NB = "audio/3gpp";
138     public static final String MIMETYPE_AUDIO_AMR_WB = "audio/amr-wb";
139     public static final String MIMETYPE_AUDIO_MPEG = "audio/mpeg";
140     public static final String MIMETYPE_AUDIO_AAC = "audio/mp4a-latm";
141     public static final String MIMETYPE_AUDIO_QCELP = "audio/qcelp";
142     public static final String MIMETYPE_AUDIO_VORBIS = "audio/vorbis";
143     public static final String MIMETYPE_AUDIO_OPUS = "audio/opus";
144     public static final String MIMETYPE_AUDIO_G711_ALAW = "audio/g711-alaw";
145     public static final String MIMETYPE_AUDIO_G711_MLAW = "audio/g711-mlaw";
146     public static final String MIMETYPE_AUDIO_RAW = "audio/raw";
147     public static final String MIMETYPE_AUDIO_FLAC = "audio/flac";
148     public static final String MIMETYPE_AUDIO_MSGSM = "audio/gsm";
149     public static final String MIMETYPE_AUDIO_AC3 = "audio/ac3";
150     public static final String MIMETYPE_AUDIO_EAC3 = "audio/eac3";
151     public static final String MIMETYPE_AUDIO_EAC3_JOC = "audio/eac3-joc";
152     public static final String MIMETYPE_AUDIO_AC4 = "audio/ac4";
153     public static final String MIMETYPE_AUDIO_SCRAMBLED = "audio/scrambled";
154 
155     /**
156      * MIME type for HEIF still image data encoded in HEVC.
157      *
158      * To decode such an image, {@link MediaCodec} decoder for
159      * {@link #MIMETYPE_VIDEO_HEVC} shall be used. The client needs to form
160      * the correct {@link #MediaFormat} based on additional information in
161      * the track format, and send it to {@link MediaCodec#configure}.
162      *
163      * The track's MediaFormat will come with {@link #KEY_WIDTH} and
164      * {@link #KEY_HEIGHT} keys, which describes the width and height
165      * of the image. If the image doesn't contain grid (i.e. none of
166      * {@link #KEY_TILE_WIDTH}, {@link #KEY_TILE_HEIGHT},
167      * {@link #KEY_GRID_ROWS}, {@link #KEY_GRID_COLUMNS} are present}), the
168      * track will contain a single sample of coded data for the entire image,
169      * and the image width and height should be used to set up the decoder.
170      *
171      * If the image does come with grid, each sample from the track will
172      * contain one tile in the grid, of which the size is described by
173      * {@link #KEY_TILE_WIDTH} and {@link #KEY_TILE_HEIGHT}. This size
174      * (instead of {@link #KEY_WIDTH} and {@link #KEY_HEIGHT}) should be
175      * used to set up the decoder. The track contains {@link #KEY_GRID_ROWS}
176      * by {@link #KEY_GRID_COLUMNS} samples in row-major, top-row first,
177      * left-to-right order. The output image should be reconstructed by
178      * first tiling the decoding results of the tiles in the correct order,
179      * then trimming (before rotation is applied) on the bottom and right
180      * side, if the tiled area is larger than the image width and height.
181      */
182     public static final String MIMETYPE_IMAGE_ANDROID_HEIC = "image/vnd.android.heic";
183 
184     /**
185      * MIME type for WebVTT subtitle data.
186      */
187     public static final String MIMETYPE_TEXT_VTT = "text/vtt";
188 
189     /**
190      * MIME type for SubRip (SRT) container.
191      */
192     public static final String MIMETYPE_TEXT_SUBRIP = "application/x-subrip";
193 
194     /**
195      * MIME type for CEA-608 closed caption data.
196      */
197     public static final String MIMETYPE_TEXT_CEA_608 = "text/cea-608";
198 
199     /**
200      * MIME type for CEA-708 closed caption data.
201      */
202     public static final String MIMETYPE_TEXT_CEA_708 = "text/cea-708";
203 
204     @UnsupportedAppUsage
205     private Map<String, Object> mMap;
206 
207     /**
208      * A key describing the mime type of the MediaFormat.
209      * The associated value is a string.
210      */
211     public static final String KEY_MIME = "mime";
212 
213     /**
214      * A key describing the language of the content, using either ISO 639-1
215      * or 639-2/T codes.  The associated value is a string.
216      */
217     public static final String KEY_LANGUAGE = "language";
218 
219     /**
220      * A key describing the sample rate of an audio format.
221      * The associated value is an integer
222      */
223     public static final String KEY_SAMPLE_RATE = "sample-rate";
224 
225     /**
226      * A key describing the number of channels in an audio format.
227      * The associated value is an integer
228      */
229     public static final String KEY_CHANNEL_COUNT = "channel-count";
230 
231     /**
232      * A key describing the width of the content in a video format.
233      * The associated value is an integer
234      */
235     public static final String KEY_WIDTH = "width";
236 
237     /**
238      * A key describing the height of the content in a video format.
239      * The associated value is an integer
240      */
241     public static final String KEY_HEIGHT = "height";
242 
243     /**
244      * A key describing the maximum expected width of the content in a video
245      * decoder format, in case there are resolution changes in the video content.
246      * The associated value is an integer
247      */
248     public static final String KEY_MAX_WIDTH = "max-width";
249 
250     /**
251      * A key describing the maximum expected height of the content in a video
252      * decoder format, in case there are resolution changes in the video content.
253      * The associated value is an integer
254      */
255     public static final String KEY_MAX_HEIGHT = "max-height";
256 
257     /** A key describing the maximum size in bytes of a buffer of data
258      * described by this MediaFormat.
259      * The associated value is an integer
260      */
261     public static final String KEY_MAX_INPUT_SIZE = "max-input-size";
262 
263     /**
264      * A key describing the average bitrate in bits/sec.
265      * The associated value is an integer
266      */
267     public static final String KEY_BIT_RATE = "bitrate";
268 
269     /**
270      * A key describing the max bitrate in bits/sec.
271      * This is usually over a one-second sliding window (e.g. over any window of one second).
272      * The associated value is an integer
273      * @hide
274      */
275     public static final String KEY_MAX_BIT_RATE = "max-bitrate";
276 
277     /**
278      * A key describing the color format of the content in a video format.
279      * Constants are declared in {@link android.media.MediaCodecInfo.CodecCapabilities}.
280      */
281     public static final String KEY_COLOR_FORMAT = "color-format";
282 
283     /**
284      * A key describing the frame rate of a video format in frames/sec.
285      * The associated value is normally an integer when the value is used by the platform,
286      * but video codecs also accept float configuration values.
287      * Specifically, {@link MediaExtractor#getTrackFormat MediaExtractor} provides an integer
288      * value corresponding to the frame rate information of the track if specified and non-zero.
289      * Otherwise, this key is not present. {@link MediaCodec#configure MediaCodec} accepts both
290      * float and integer values. This represents the desired operating frame rate if the
291      * {@link #KEY_OPERATING_RATE} is not present and {@link #KEY_PRIORITY} is {@code 0}
292      * (realtime). For video encoders this value corresponds to the intended frame rate,
293      * although encoders are expected
294      * to support variable frame rate based on {@link MediaCodec.BufferInfo#presentationTimeUs
295      * buffer timestamp}. This key is not used in the {@code MediaCodec}
296      * {@link MediaCodec#getInputFormat input}/{@link MediaCodec#getOutputFormat output} formats,
297      * nor by {@link MediaMuxer#addTrack MediaMuxer}.
298      */
299     public static final String KEY_FRAME_RATE = "frame-rate";
300 
301     /**
302      * A key describing the width (in pixels) of each tile of the content in a
303      * {@link #MIMETYPE_IMAGE_ANDROID_HEIC} track. The associated value is an integer.
304      *
305      * Refer to {@link #MIMETYPE_IMAGE_ANDROID_HEIC} on decoding instructions of such tracks.
306      *
307      * @see #KEY_TILE_HEIGHT
308      * @see #KEY_GRID_ROWS
309      * @see #KEY_GRID_COLUMNS
310      */
311     public static final String KEY_TILE_WIDTH = "tile-width";
312 
313     /**
314      * A key describing the height (in pixels) of each tile of the content in a
315      * {@link #MIMETYPE_IMAGE_ANDROID_HEIC} track. The associated value is an integer.
316      *
317      * Refer to {@link #MIMETYPE_IMAGE_ANDROID_HEIC} on decoding instructions of such tracks.
318      *
319      * @see #KEY_TILE_WIDTH
320      * @see #KEY_GRID_ROWS
321      * @see #KEY_GRID_COLUMNS
322      */
323     public static final String KEY_TILE_HEIGHT = "tile-height";
324 
325     /**
326      * A key describing the number of grid rows in the content in a
327      * {@link #MIMETYPE_IMAGE_ANDROID_HEIC} track. The associated value is an integer.
328      *
329      * Refer to {@link #MIMETYPE_IMAGE_ANDROID_HEIC} on decoding instructions of such tracks.
330      *
331      * @see #KEY_TILE_WIDTH
332      * @see #KEY_TILE_HEIGHT
333      * @see #KEY_GRID_COLUMNS
334      */
335     public static final String KEY_GRID_ROWS = "grid-rows";
336 
337     /**
338      * A key describing the number of grid columns in the content in a
339      * {@link #MIMETYPE_IMAGE_ANDROID_HEIC} track. The associated value is an integer.
340      *
341      * Refer to {@link #MIMETYPE_IMAGE_ANDROID_HEIC} on decoding instructions of such tracks.
342      *
343      * @see #KEY_TILE_WIDTH
344      * @see #KEY_TILE_HEIGHT
345      * @see #KEY_GRID_ROWS
346      */
347     public static final String KEY_GRID_COLUMNS = "grid-cols";
348 
349     /**
350      * A key describing the raw audio sample encoding/format.
351      *
352      * <p>The associated value is an integer, using one of the
353      * {@link AudioFormat}.ENCODING_PCM_ values.</p>
354      *
355      * <p>This is an optional key for audio decoders and encoders specifying the
356      * desired raw audio sample format during {@link MediaCodec#configure
357      * MediaCodec.configure(&hellip;)} call. Use {@link MediaCodec#getInputFormat
358      * MediaCodec.getInput}/{@link MediaCodec#getOutputFormat OutputFormat(&hellip;)}
359      * to confirm the actual format. For the PCM decoder this key specifies both
360      * input and output sample encodings.</p>
361      *
362      * <p>This key is also used by {@link MediaExtractor} to specify the sample
363      * format of audio data, if it is specified.</p>
364      *
365      * <p>If this key is missing, the raw audio sample format is signed 16-bit short.</p>
366      */
367     public static final String KEY_PCM_ENCODING = "pcm-encoding";
368 
369     /**
370      * A key describing the capture rate of a video format in frames/sec.
371      * <p>
372      * When capture rate is different than the frame rate, it means that the
373      * video is acquired at a different rate than the playback, which produces
374      * slow motion or timelapse effect during playback. Application can use the
375      * value of this key to tell the relative speed ratio between capture and
376      * playback rates when the video was recorded.
377      * </p>
378      * <p>
379      * The associated value is an integer or a float.
380      * </p>
381      */
382     public static final String KEY_CAPTURE_RATE = "capture-rate";
383 
384     /**
385      * A key describing the frequency of key frames expressed in seconds between key frames.
386      * <p>
387      * This key is used by video encoders.
388      * A negative value means no key frames are requested after the first frame.
389      * A zero value means a stream containing all key frames is requested.
390      * <p class=note>
391      * Most video encoders will convert this value of the number of non-key-frames between
392      * key-frames, using the {@linkplain #KEY_FRAME_RATE frame rate} information; therefore,
393      * if the actual frame rate differs (e.g. input frames are dropped or the frame rate
394      * changes), the <strong>time interval</strong> between key frames will not be the
395      * configured value.
396      * <p>
397      * The associated value is an integer (or float since
398      * {@link android.os.Build.VERSION_CODES#N_MR1}).
399      */
400     public static final String KEY_I_FRAME_INTERVAL = "i-frame-interval";
401 
402     /**
403     * An optional key describing the period of intra refresh in frames. This is an
404     * optional parameter that applies only to video encoders. If encoder supports it
405     * ({@link MediaCodecInfo.CodecCapabilities#FEATURE_IntraRefresh}), the whole
406     * frame is completely refreshed after the specified period. Also for each frame,
407     * a fix subset of macroblocks must be intra coded which leads to more constant bitrate
408     * than inserting a key frame. This key is recommended for video streaming applications
409     * as it provides low-delay and good error-resilience. This key is ignored if the
410     * video encoder does not support the intra refresh feature. Use the output format to
411     * verify that this feature was enabled.
412     * The associated value is an integer.
413     */
414     public static final String KEY_INTRA_REFRESH_PERIOD = "intra-refresh-period";
415 
416     /**
417      * An optional key describing whether encoders prepend headers to sync frames (e.g.
418      * SPS and PPS to IDR frames for H.264). This is an optional parameter that applies only
419      * to video encoders. A video encoder may not support this feature; the component will fail
420      * to configure in that case. For other components, this key is ignored.
421      *
422      * The value is an integer, with 1 indicating to prepend headers to every sync frames,
423      * or 0 otherwise. The default value is 0.
424      */
425     public static final String KEY_PREPEND_HEADER_TO_SYNC_FRAMES = "prepend-sps-pps-to-idr-frames";
426 
427     /**
428      * A key describing the temporal layering schema.  This is an optional parameter
429      * that applies only to video encoders.  Use {@link MediaCodec#getOutputFormat}
430      * after {@link MediaCodec#configure configure} to query if the encoder supports
431      * the desired schema. Supported values are {@code webrtc.vp8.N-layer},
432      * {@code android.generic.N}, {@code android.generic.N+M} and {@code none}, where
433      * {@code N} denotes the total number of non-bidirectional layers (which must be at least 1)
434      * and {@code M} denotes the total number of bidirectional layers (which must be non-negative).
435      * <p class=note>{@code android.generic.*} schemas have been added in {@link
436      * android.os.Build.VERSION_CODES#N_MR1}.
437      * <p>
438      * The encoder may support fewer temporal layers, in which case the output format
439      * will contain the configured schema. If the encoder does not support temporal
440      * layering, the output format will not have an entry with this key.
441      * The associated value is a string.
442      */
443     public static final String KEY_TEMPORAL_LAYERING = "ts-schema";
444 
445     /**
446      * A key describing the stride of the video bytebuffer layout.
447      * Stride (or row increment) is the difference between the index of a pixel
448      * and that of the pixel directly underneath. For YUV 420 formats, the
449      * stride corresponds to the Y plane; the stride of the U and V planes can
450      * be calculated based on the color format, though it is generally undefined
451      * and depends on the device and release.
452      * The associated value is an integer, representing number of bytes.
453      */
454     public static final String KEY_STRIDE = "stride";
455 
456     /**
457      * A key describing the plane height of a multi-planar (YUV) video bytebuffer layout.
458      * Slice height (or plane height/vertical stride) is the number of rows that must be skipped
459      * to get from the top of the Y plane to the top of the U plane in the bytebuffer. In essence
460      * the offset of the U plane is sliceHeight * stride. The height of the U/V planes
461      * can be calculated based on the color format, though it is generally undefined
462      * and depends on the device and release.
463      * The associated value is an integer, representing number of rows.
464      */
465     public static final String KEY_SLICE_HEIGHT = "slice-height";
466 
467     /**
468      * Applies only when configuring a video encoder in "surface-input" mode.
469      * The associated value is a long and gives the time in microseconds
470      * after which the frame previously submitted to the encoder will be
471      * repeated (once) if no new frame became available since.
472      */
473     public static final String KEY_REPEAT_PREVIOUS_FRAME_AFTER
474         = "repeat-previous-frame-after";
475 
476     /**
477      * Instruct the video encoder in "surface-input" mode to drop excessive
478      * frames from the source, so that the input frame rate to the encoder
479      * does not exceed the specified fps.
480      *
481      * The associated value is a float, representing the max frame rate to
482      * feed the encoder at.
483      *
484      */
485     public static final String KEY_MAX_FPS_TO_ENCODER
486         = "max-fps-to-encoder";
487 
488     /**
489      * Instruct the video encoder in "surface-input" mode to limit the gap of
490      * timestamp between any two adjacent frames fed to the encoder to the
491      * specified amount (in micro-second).
492      *
493      * The associated value is a long int. When positive, it represents the max
494      * timestamp gap between two adjacent frames fed to the encoder. When negative,
495      * the absolute value represents a fixed timestamp gap between any two adjacent
496      * frames fed to the encoder. Note that this will also apply even when the
497      * original timestamp goes backward in time. Under normal conditions, such frames
498      * would be dropped and not sent to the encoder.
499      *
500      * The output timestamp will be restored to the original timestamp and will
501      * not be affected.
502      *
503      * This is used in some special scenarios where input frames arrive sparingly
504      * but it's undesirable to allocate more bits to any single frame, or when it's
505      * important to ensure all frames are captured (rather than captured in the
506      * correct order).
507      *
508      */
509     public static final String KEY_MAX_PTS_GAP_TO_ENCODER
510         = "max-pts-gap-to-encoder";
511 
512     /**
513      * If specified when configuring a video encoder that's in "surface-input"
514      * mode, it will instruct the encoder to put the surface source in suspended
515      * state when it's connected. No video frames will be accepted until a resume
516      * operation (see {@link MediaCodec#PARAMETER_KEY_SUSPEND}), optionally with
517      * timestamp specified via {@link MediaCodec#PARAMETER_KEY_SUSPEND_TIME}, is
518      * received.
519      *
520      * The value is an integer, with 1 indicating to create with the surface
521      * source suspended, or 0 otherwise. The default value is 0.
522      *
523      * If this key is not set or set to 0, the surface source will accept buffers
524      * as soon as it's connected to the encoder (although they may not be encoded
525      * immediately). This key can be used when the client wants to prepare the
526      * encoder session in advance, but do not want to accept buffers immediately.
527      */
528     public static final String KEY_CREATE_INPUT_SURFACE_SUSPENDED
529         = "create-input-buffers-suspended";
530 
531     /**
532      * If specified when configuring a video decoder rendering to a surface,
533      * causes the decoder to output "blank", i.e. black frames to the surface
534      * when stopped to clear out any previously displayed contents.
535      * The associated value is an integer of value 1.
536      */
537     public static final String KEY_PUSH_BLANK_BUFFERS_ON_STOP
538         = "push-blank-buffers-on-shutdown";
539 
540     /**
541      * A key describing the duration (in microseconds) of the content.
542      * The associated value is a long.
543      */
544     public static final String KEY_DURATION = "durationUs";
545 
546     /**
547      * A key mapping to a value of 1 if the content is AAC audio and
548      * audio frames are prefixed with an ADTS header.
549      * The associated value is an integer (0 or 1).
550      * This key is only supported when _decoding_ content, it cannot
551      * be used to configure an encoder to emit ADTS output.
552      */
553     public static final String KEY_IS_ADTS = "is-adts";
554 
555     /**
556      * A key describing the channel composition of audio content. This mask
557      * is composed of bits drawn from channel mask definitions in {@link android.media.AudioFormat}.
558      * The associated value is an integer.
559      */
560     public static final String KEY_CHANNEL_MASK = "channel-mask";
561 
562     /**
563      * A key describing the AAC profile to be used (AAC audio formats only).
564      * Constants are declared in {@link android.media.MediaCodecInfo.CodecProfileLevel}.
565      */
566     public static final String KEY_AAC_PROFILE = "aac-profile";
567 
568     /**
569      * A key describing the AAC SBR mode to be used (AAC audio formats only).
570      * The associated value is an integer and can be set to following values:
571      * <ul>
572      * <li>0 - no SBR should be applied</li>
573      * <li>1 - single rate SBR</li>
574      * <li>2 - double rate SBR</li>
575      * </ul>
576      * Note: If this key is not defined the default SRB mode for the desired AAC profile will
577      * be used.
578      * <p>This key is only used during encoding.
579      */
580     public static final String KEY_AAC_SBR_MODE = "aac-sbr-mode";
581 
582     /**
583      * A key describing the maximum number of channels that can be output by the AAC decoder.
584      * By default, the decoder will output the same number of channels as present in the encoded
585      * stream, if supported. Set this value to limit the number of output channels, and use
586      * the downmix information in the stream, if available.
587      * <p>Values larger than the number of channels in the content to decode are ignored.
588      * <p>This key is only used during decoding.
589      */
590     public static final String KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT = "aac-max-output-channel_count";
591 
592     /**
593      * A key describing a gain to be applied so that the output loudness matches the
594      * Target Reference Level. This is typically used to normalize loudness across program items.
595      * The gain is derived as the difference between the Target Reference Level and the
596      * Program Reference Level. The latter can be given in the bitstream and indicates the actual
597      * loudness value of the program item.
598      * <p>The Target Reference Level controls loudness normalization for both MPEG-4 DRC and
599      * MPEG-D DRC.
600      * <p>The value is given as an integer value between
601      * 40 and 127, and is calculated as -4 * Target Reference Level in LKFS.
602      * Therefore, it represents the range of -10 to -31.75 LKFS.
603      * <p>The default value on mobile devices is 64 (-16 LKFS).
604      * <p>This key is only used during decoding.
605      */
606     public static final String KEY_AAC_DRC_TARGET_REFERENCE_LEVEL = "aac-target-ref-level";
607 
608     /**
609      * A key describing for selecting the DRC effect type for MPEG-D DRC.
610      * The supported values are defined in ISO/IEC 23003-4:2015 and are described as follows:
611      * <table>
612      * <tr><th>Value</th><th>Effect</th></tr>
613      * <tr><th>-1</th><th>Off</th></tr>
614      * <tr><th>0</th><th>None</th></tr>
615      * <tr><th>1</th><th>Late night</th></tr>
616      * <tr><th>2</th><th>Noisy environment</th></tr>
617      * <tr><th>3</th><th>Limited playback range</th></tr>
618      * <tr><th>4</th><th>Low playback level</th></tr>
619      * <tr><th>5</th><th>Dialog enhancement</th></tr>
620      * <tr><th>6</th><th>General compression</th></tr>
621      * </table>
622      * <p>The value -1 (Off) disables DRC processing, while loudness normalization may still be
623      * active and dependent on KEY_AAC_DRC_TARGET_REFERENCE_LEVEL.<br>
624      * The value 0 (None) automatically enables DRC processing if necessary to prevent signal
625      * clipping<br>
626      * The value 6 (General compression) can be used for enabling MPEG-D DRC without particular
627      * DRC effect type request.<br>
628      * The default DRC effect type is 3 ("Limited playback range") on mobile devices.
629      * <p>This key is only used during decoding.
630      */
631     public static final String KEY_AAC_DRC_EFFECT_TYPE = "aac-drc-effect-type";
632 
633     /**
634      * A key describing the target reference level that was assumed at the encoder for
635      * calculation of attenuation gains for clipping prevention.
636      * <p>If it is known, this information can be provided as an integer value between
637      * 0 and 127, which is calculated as -4 * Encoded Target Level in LKFS.
638      * If the Encoded Target Level is unknown, the value can be set to -1.
639      * <p>The default value is -1 (unknown).
640      * <p>The value is ignored when heavy compression is used (see
641      * {@link #KEY_AAC_DRC_HEAVY_COMPRESSION}).
642      * <p>This key is only used during decoding.
643      */
644     public static final String KEY_AAC_ENCODED_TARGET_LEVEL = "aac-encoded-target-level";
645 
646     /**
647      * A key describing the boost factor allowing to adapt the dynamics of the output to the
648      * actual listening requirements. This relies on DRC gain sequences that can be transmitted in
649      * the encoded bitstream to be able to reduce the dynamics of the output signal upon request.
650      * This factor enables the user to select how much of the gains are applied.
651      * <p>Positive gains (boost) and negative gains (attenuation, see
652      * {@link #KEY_AAC_DRC_ATTENUATION_FACTOR}) can be controlled separately for a better match
653      * to different use-cases.
654      * <p>Typically, attenuation gains are sent for loud signal segments, and boost gains are sent
655      * for soft signal segments. If the output is listened to in a noisy environment, for example,
656      * the boost factor is used to enable the positive gains, i.e. to amplify soft signal segments
657      * beyond the noise floor. But for listening late at night, the attenuation
658      * factor is used to enable the negative gains, to prevent loud signal from surprising
659      * the listener. In applications which generally need a low dynamic range, both the boost factor
660      * and the attenuation factor are used in order to enable all DRC gains.
661      * <p>In order to prevent clipping, it is also recommended to apply the attenuation gains
662      * in case of a downmix and/or loudness normalization to high target reference levels.
663      * <p>Both the boost and the attenuation factor parameters are given as integer values
664      * between 0 and 127, representing the range of the factor of 0 (i.e. don't apply)
665      * to 1 (i.e. fully apply boost/attenuation gains respectively).
666      * <p>The default value is 127 (fully apply boost DRC gains).
667      * <p>This key is only used during decoding.
668      */
669     public static final String KEY_AAC_DRC_BOOST_FACTOR = "aac-drc-boost-level";
670 
671     /**
672      * A key describing the attenuation factor allowing to adapt the dynamics of the output to the
673      * actual listening requirements.
674      * See {@link #KEY_AAC_DRC_BOOST_FACTOR} for a description of the role of this attenuation
675      * factor and the value range.
676      * <p>The default value is 127 (fully apply attenuation DRC gains).
677      * <p>This key is only used during decoding.
678      */
679     public static final String KEY_AAC_DRC_ATTENUATION_FACTOR = "aac-drc-cut-level";
680 
681     /**
682      * A key describing the selection of the heavy compression profile for DRC.
683      * Two separate DRC gain sequences can be transmitted in one bitstream: MPEG-4 DRC light
684      * compression, and DVB-specific heavy compression. When selecting the application of the heavy
685      * compression, one of the sequences is selected:
686      * <ul>
687      * <li>0 enables light compression,</li>
688      * <li>1 enables heavy compression instead.
689      * </ul>
690      * Note that only light compression offers the features of scaling of DRC gains
691      * (see {@link #KEY_AAC_DRC_BOOST_FACTOR} and {@link #KEY_AAC_DRC_ATTENUATION_FACTOR} for the
692      * boost and attenuation factors, and frequency-selective (multiband) DRC.
693      * Light compression usually contains clipping prevention for stereo downmixing while heavy
694      * compression, if additionally provided in the bitstream, is usually stronger, and contains
695      * clipping prevention for stereo and mono downmixing.
696      * <p>The default is 1 (heavy compression).
697      * <p>This key is only used during decoding.
698      */
699     public static final String KEY_AAC_DRC_HEAVY_COMPRESSION = "aac-drc-heavy-compression";
700 
701     /**
702      * A key describing the FLAC compression level to be used (FLAC audio format only).
703      * The associated value is an integer ranging from 0 (fastest, least compression)
704      * to 8 (slowest, most compression).
705      */
706     public static final String KEY_FLAC_COMPRESSION_LEVEL = "flac-compression-level";
707 
708     /**
709      * A key describing the encoding complexity.
710      * The associated value is an integer.  These values are device and codec specific,
711      * but lower values generally result in faster and/or less power-hungry encoding.
712      *
713      * @see MediaCodecInfo.EncoderCapabilities#getComplexityRange()
714      */
715     public static final String KEY_COMPLEXITY = "complexity";
716 
717     /**
718      * A key describing the desired encoding quality.
719      * The associated value is an integer.  This key is only supported for encoders
720      * that are configured in constant-quality mode.  These values are device and
721      * codec specific, but lower values generally result in more efficient
722      * (smaller-sized) encoding.
723      *
724      * @see MediaCodecInfo.EncoderCapabilities#getQualityRange()
725      */
726     public static final String KEY_QUALITY = "quality";
727 
728     /**
729      * A key describing the desired codec priority.
730      * <p>
731      * The associated value is an integer. Higher value means lower priority.
732      * <p>
733      * Currently, only two levels are supported:<br>
734      * 0: realtime priority - meaning that the codec shall support the given
735      *    performance configuration (e.g. framerate) at realtime. This should
736      *    only be used by media playback, capture, and possibly by realtime
737      *    communication scenarios if best effort performance is not suitable.<br>
738      * 1: non-realtime priority (best effort).
739      * <p>
740      * This is a hint used at codec configuration and resource planning - to understand
741      * the realtime requirements of the application; however, due to the nature of
742      * media components, performance is not guaranteed.
743      *
744      */
745     public static final String KEY_PRIORITY = "priority";
746 
747     /**
748      * A key describing the desired operating frame rate for video or sample rate for audio
749      * that the codec will need to operate at.
750      * <p>
751      * The associated value is an integer or a float representing frames-per-second or
752      * samples-per-second
753      * <p>
754      * This is used for cases like high-speed/slow-motion video capture, where the video encoder
755      * format contains the target playback rate (e.g. 30fps), but the component must be able to
756      * handle the high operating capture rate (e.g. 240fps).
757      * <p>
758      * This rate will be used by codec for resource planning and setting the operating points.
759      *
760      */
761     public static final String KEY_OPERATING_RATE = "operating-rate";
762 
763     /**
764      * A key describing the desired profile to be used by an encoder.
765      * The associated value is an integer.
766      * Constants are declared in {@link MediaCodecInfo.CodecProfileLevel}.
767      * This key is used as a hint, and is only supported for codecs
768      * that specify a profile. Note: Codecs are free to use all the available
769      * coding tools at the specified profile.
770      *
771      * @see MediaCodecInfo.CodecCapabilities#profileLevels
772      */
773     public static final String KEY_PROFILE = "profile";
774 
775     /**
776      * A key describing the desired profile to be used by an encoder.
777      * The associated value is an integer.
778      * Constants are declared in {@link MediaCodecInfo.CodecProfileLevel}.
779      * This key is used as a further hint when specifying a desired profile,
780      * and is only supported for codecs that specify a level.
781      * <p>
782      * This key is ignored if the {@link #KEY_PROFILE profile} is not specified.
783      *
784      * @see MediaCodecInfo.CodecCapabilities#profileLevels
785      */
786     public static final String KEY_LEVEL = "level";
787 
788     /**
789     * An optional key describing the desired encoder latency in frames. This is an optional
790     * parameter that applies only to video encoders. If encoder supports it, it should ouput
791     * at least one output frame after being queued the specified number of frames. This key
792     * is ignored if the video encoder does not support the latency feature. Use the output
793     * format to verify that this feature was enabled and the actual value used by the encoder.
794     * <p>
795     * If the key is not specified, the default latency will be implenmentation specific.
796     * The associated value is an integer.
797     */
798     public static final String KEY_LATENCY = "latency";
799 
800     /**
801      * An optional key describing the maximum number of non-display-order coded frames.
802      * This is an optional parameter that applies only to video encoders. Application should
803      * check the value for this key in the output format to see if codec will produce
804      * non-display-order coded frames. If encoder supports it, the output frames' order will be
805      * different from the display order and each frame's display order could be retrived from
806      * {@link MediaCodec.BufferInfo#presentationTimeUs}. Before API level 27, application may
807      * receive non-display-order coded frames even though the application did not request it.
808      * Note: Application should not rearrange the frames to display order before feeding them
809      * to {@link MediaMuxer#writeSampleData}.
810      * <p>
811      * The default value is 0.
812      */
813     public static final String KEY_OUTPUT_REORDER_DEPTH = "output-reorder-depth";
814 
815     /**
816      * A key describing the desired clockwise rotation on an output surface.
817      * This key is only used when the codec is configured using an output surface.
818      * The associated value is an integer, representing degrees. Supported values
819      * are 0, 90, 180 or 270. This is an optional field; if not specified, rotation
820      * defaults to 0.
821      *
822      * @see MediaCodecInfo.CodecCapabilities#profileLevels
823      */
824     public static final String KEY_ROTATION = "rotation-degrees";
825 
826     /**
827      * A key describing the desired bitrate mode to be used by an encoder.
828      * Constants are declared in {@link MediaCodecInfo.CodecCapabilities}.
829      *
830      * @see MediaCodecInfo.EncoderCapabilities#isBitrateModeSupported(int)
831      */
832     public static final String KEY_BITRATE_MODE = "bitrate-mode";
833 
834     /**
835      * A key describing the audio session ID of the AudioTrack associated
836      * to a tunneled video codec.
837      * The associated value is an integer.
838      *
839      * @see MediaCodecInfo.CodecCapabilities#FEATURE_TunneledPlayback
840      */
841     public static final String KEY_AUDIO_SESSION_ID = "audio-session-id";
842 
843     /**
844      * A key for boolean AUTOSELECT behavior for the track. Tracks with AUTOSELECT=true
845      * are considered when automatically selecting a track without specific user
846      * choice, based on the current locale.
847      * This is currently only used for subtitle tracks, when the user selected
848      * 'Default' for the captioning locale.
849      * The associated value is an integer, where non-0 means TRUE.  This is an optional
850      * field; if not specified, AUTOSELECT defaults to TRUE.
851      */
852     public static final String KEY_IS_AUTOSELECT = "is-autoselect";
853 
854     /**
855      * A key for boolean DEFAULT behavior for the track. The track with DEFAULT=true is
856      * selected in the absence of a specific user choice.
857      * This is currently used in two scenarios:
858      * 1) for subtitle tracks, when the user selected 'Default' for the captioning locale.
859      * 2) for a {@link #MIMETYPE_IMAGE_ANDROID_HEIC} track, indicating the image is the
860      * primary item in the file.
861 
862      * The associated value is an integer, where non-0 means TRUE.  This is an optional
863      * field; if not specified, DEFAULT is considered to be FALSE.
864      */
865     public static final String KEY_IS_DEFAULT = "is-default";
866 
867     /**
868      * A key for the FORCED field for subtitle tracks. True if it is a
869      * forced subtitle track.  Forced subtitle tracks are essential for the
870      * content and are shown even when the user turns off Captions.  They
871      * are used for example to translate foreign/alien dialogs or signs.
872      * The associated value is an integer, where non-0 means TRUE.  This is an
873      * optional field; if not specified, FORCED defaults to FALSE.
874      */
875     public static final String KEY_IS_FORCED_SUBTITLE = "is-forced-subtitle";
876 
877     /**
878      * A key describing the number of haptic channels in an audio format.
879      * The associated value is an integer.
880      */
881     public static final String KEY_HAPTIC_CHANNEL_COUNT = "haptic-channel-count";
882 
883     /** @hide */
884     public static final String KEY_IS_TIMED_TEXT = "is-timed-text";
885 
886     // The following color aspect values must be in sync with the ones in HardwareAPI.h.
887     /**
888      * An optional key describing the color primaries, white point and
889      * luminance factors for video content.
890      *
891      * The associated value is an integer: 0 if unspecified, or one of the
892      * COLOR_STANDARD_ values.
893      */
894     public static final String KEY_COLOR_STANDARD = "color-standard";
895 
896     /** BT.709 color chromacity coordinates with KR = 0.2126, KB = 0.0722. */
897     public static final int COLOR_STANDARD_BT709 = 1;
898 
899     /** BT.601 625 color chromacity coordinates with KR = 0.299, KB = 0.114. */
900     public static final int COLOR_STANDARD_BT601_PAL = 2;
901 
902     /** BT.601 525 color chromacity coordinates with KR = 0.299, KB = 0.114. */
903     public static final int COLOR_STANDARD_BT601_NTSC = 4;
904 
905     /** BT.2020 color chromacity coordinates with KR = 0.2627, KB = 0.0593. */
906     public static final int COLOR_STANDARD_BT2020 = 6;
907 
908     /** @hide */
909     @IntDef({
910         COLOR_STANDARD_BT709,
911         COLOR_STANDARD_BT601_PAL,
912         COLOR_STANDARD_BT601_NTSC,
913         COLOR_STANDARD_BT2020,
914     })
915     @Retention(RetentionPolicy.SOURCE)
916     public @interface ColorStandard {}
917 
918     /**
919      * An optional key describing the opto-electronic transfer function used
920      * for the video content.
921      *
922      * The associated value is an integer: 0 if unspecified, or one of the
923      * COLOR_TRANSFER_ values.
924      */
925     public static final String KEY_COLOR_TRANSFER = "color-transfer";
926 
927     /** Linear transfer characteristic curve. */
928     public static final int COLOR_TRANSFER_LINEAR = 1;
929 
930     /** SMPTE 170M transfer characteristic curve used by BT.601/BT.709/BT.2020. This is the curve
931      *  used by most non-HDR video content. */
932     public static final int COLOR_TRANSFER_SDR_VIDEO = 3;
933 
934     /** SMPTE ST 2084 transfer function. This is used by some HDR video content. */
935     public static final int COLOR_TRANSFER_ST2084 = 6;
936 
937     /** ARIB STD-B67 hybrid-log-gamma transfer function. This is used by some HDR video content. */
938     public static final int COLOR_TRANSFER_HLG = 7;
939 
940     /** @hide */
941     @IntDef({
942         COLOR_TRANSFER_LINEAR,
943         COLOR_TRANSFER_SDR_VIDEO,
944         COLOR_TRANSFER_ST2084,
945         COLOR_TRANSFER_HLG,
946     })
947     @Retention(RetentionPolicy.SOURCE)
948     public @interface ColorTransfer {}
949 
950     /**
951      * An optional key describing the range of the component values of the video content.
952      *
953      * The associated value is an integer: 0 if unspecified, or one of the
954      * COLOR_RANGE_ values.
955      */
956     public static final String KEY_COLOR_RANGE = "color-range";
957 
958     /** Limited range. Y component values range from 16 to 235 for 8-bit content.
959      *  Cr, Cy values range from 16 to 240 for 8-bit content.
960      *  This is the default for video content. */
961     public static final int COLOR_RANGE_LIMITED = 2;
962 
963     /** Full range. Y, Cr and Cb component values range from 0 to 255 for 8-bit content. */
964     public static final int COLOR_RANGE_FULL = 1;
965 
966     /** @hide */
967     @IntDef({
968         COLOR_RANGE_LIMITED,
969         COLOR_RANGE_FULL,
970     })
971     @Retention(RetentionPolicy.SOURCE)
972     public @interface ColorRange {}
973 
974     /**
975      * An optional key describing the static metadata of HDR (high-dynamic-range) video content.
976      *
977      * The associated value is a ByteBuffer. This buffer contains the raw contents of the
978      * Static Metadata Descriptor (including the descriptor ID) of an HDMI Dynamic Range and
979      * Mastering InfoFrame as defined by CTA-861.3. This key must be provided to video decoders
980      * for HDR video content unless this information is contained in the bitstream and the video
981      * decoder supports an HDR-capable profile. This key must be provided to video encoders for
982      * HDR video content.
983      */
984     public static final String KEY_HDR_STATIC_INFO = "hdr-static-info";
985 
986     /**
987      * An optional key describing the HDR10+ metadata of the video content.
988      *
989      * The associated value is a ByteBuffer containing HDR10+ metadata conforming to the
990      * user_data_registered_itu_t_t35() syntax of SEI message for ST 2094-40. This key will
991      * be present on:
992      *<p>
993      * - The formats of output buffers of a decoder configured for HDR10+ profiles (such as
994      *   {@link MediaCodecInfo.CodecProfileLevel#VP9Profile2HDR10Plus}, {@link
995      *   MediaCodecInfo.CodecProfileLevel#VP9Profile3HDR10Plus} or {@link
996      *   MediaCodecInfo.CodecProfileLevel#HEVCProfileMain10HDR10Plus}), or
997      *<p>
998      * - The formats of output buffers of an encoder configured for an HDR10+ profiles that
999      *   uses out-of-band metadata (such as {@link
1000      *   MediaCodecInfo.CodecProfileLevel#VP9Profile2HDR10Plus} or {@link
1001      *   MediaCodecInfo.CodecProfileLevel#VP9Profile3HDR10Plus}).
1002      *
1003      * @see MediaCodec#PARAMETER_KEY_HDR10_PLUS_INFO
1004      */
1005     public static final String KEY_HDR10_PLUS_INFO = "hdr10-plus-info";
1006 
1007     /**
1008      * A key describing a unique ID for the content of a media track.
1009      *
1010      * <p>This key is used by {@link MediaExtractor}. Some extractors provide multiple encodings
1011      * of the same track (e.g. float audio tracks for FLAC and WAV may be expressed as two
1012      * tracks via MediaExtractor: a normal PCM track for backward compatibility, and a float PCM
1013      * track for added fidelity. Similarly, Dolby Vision extractor may provide a baseline SDR
1014      * version of a DV track.) This key can be used to identify which MediaExtractor tracks refer
1015      * to the same underlying content.
1016      * </p>
1017      *
1018      * The associated value is an integer.
1019      */
1020     public static final String KEY_TRACK_ID = "track-id";
1021 
1022     /**
1023      * A key describing the system id of the conditional access system used to scramble
1024      * a media track.
1025      * <p>
1026      * This key is set by {@link MediaExtractor} if the track is scrambled with a conditional
1027      * access system, regardless of the presence of a valid {@link MediaCas} object.
1028      * <p>
1029      * The associated value is an integer.
1030      * @hide
1031      */
1032     public static final String KEY_CA_SYSTEM_ID = "ca-system-id";
1033 
1034     /**
1035      * A key describing the {@link MediaCas.Session} object associated with a media track.
1036      * <p>
1037      * This key is set by {@link MediaExtractor} if the track is scrambled with a conditional
1038      * access system, after it receives a valid {@link MediaCas} object.
1039      * <p>
1040      * The associated value is a ByteBuffer.
1041      * @hide
1042      */
1043     public static final String KEY_CA_SESSION_ID = "ca-session-id";
1044 
1045     /**
1046      * A key describing the private data in the CA_descriptor associated with a media track.
1047      * <p>
1048      * This key is set by {@link MediaExtractor} if the track is scrambled with a conditional
1049      * access system, before it receives a valid {@link MediaCas} object.
1050      * <p>
1051      * The associated value is a ByteBuffer.
1052      * @hide
1053      */
1054     public static final String KEY_CA_PRIVATE_DATA = "ca-private-data";
1055 
1056     /**
1057      * A key describing the maximum number of B frames between I or P frames,
1058      * to be used by a video encoder.
1059      * The associated value is an integer. The default value is 0, which means
1060      * that no B frames are allowed. Note that non-zero value does not guarantee
1061      * B frames; it's up to the encoder to decide.
1062      */
1063     public static final String KEY_MAX_B_FRAMES = "max-bframes";
1064 
MediaFormat(@onNull Map<String, Object> map)1065     /* package private */ MediaFormat(@NonNull Map<String, Object> map) {
1066         mMap = map;
1067     }
1068 
1069     /**
1070      * Creates an empty MediaFormat
1071      */
MediaFormat()1072     public MediaFormat() {
1073         mMap = new HashMap();
1074     }
1075 
1076     @UnsupportedAppUsage
getMap()1077     /* package private */ Map<String, Object> getMap() {
1078         return mMap;
1079     }
1080 
1081     /**
1082      * Returns true iff a key of the given name exists in the format.
1083      */
containsKey(@onNull String name)1084     public final boolean containsKey(@NonNull String name) {
1085         return mMap.containsKey(name);
1086     }
1087 
1088     /**
1089      * Returns true iff a feature of the given name exists in the format.
1090      */
containsFeature(@onNull String name)1091     public final boolean containsFeature(@NonNull String name) {
1092         return mMap.containsKey(KEY_FEATURE_ + name);
1093     }
1094 
1095     public static final int TYPE_NULL = 0;
1096     public static final int TYPE_INTEGER = 1;
1097     public static final int TYPE_LONG = 2;
1098     public static final int TYPE_FLOAT = 3;
1099     public static final int TYPE_STRING = 4;
1100     public static final int TYPE_BYTE_BUFFER = 5;
1101 
1102     /** @hide */
1103     @IntDef({
1104         TYPE_NULL,
1105         TYPE_INTEGER,
1106         TYPE_LONG,
1107         TYPE_FLOAT,
1108         TYPE_STRING,
1109         TYPE_BYTE_BUFFER
1110     })
1111     @Retention(RetentionPolicy.SOURCE)
1112     public @interface Type {}
1113 
1114     /**
1115      * Returns the value type for a key. If the key does not exist, it returns TYPE_NULL.
1116      */
getValueTypeForKey(@onNull String name)1117     public final @Type int getValueTypeForKey(@NonNull String name) {
1118         Object value = mMap.get(name);
1119         if (value == null) {
1120             return TYPE_NULL;
1121         } else if (value instanceof Integer) {
1122             return TYPE_INTEGER;
1123         } else if (value instanceof Long) {
1124             return TYPE_LONG;
1125         } else if (value instanceof Float) {
1126             return TYPE_FLOAT;
1127         } else if (value instanceof String) {
1128             return TYPE_STRING;
1129         } else if (value instanceof ByteBuffer) {
1130             return TYPE_BYTE_BUFFER;
1131         }
1132         throw new RuntimeException("invalid value for key");
1133     }
1134 
1135     /**
1136      * A key prefix used together with a {@link MediaCodecInfo.CodecCapabilities}
1137      * feature name describing a required or optional feature for a codec capabilities
1138      * query.
1139      * The associated value is an integer, where non-0 value means the feature is
1140      * requested to be present, while 0 value means the feature is requested to be not
1141      * present.
1142      * @see MediaCodecList#findDecoderForFormat
1143      * @see MediaCodecList#findEncoderForFormat
1144      * @see MediaCodecInfo.CodecCapabilities#isFormatSupported
1145      *
1146      * @hide
1147      */
1148     public static final String KEY_FEATURE_ = "feature-";
1149 
1150     /**
1151      * Returns the value of a numeric key. This is provided as a convenience method for keys
1152      * that may take multiple numeric types, such as {@link #KEY_FRAME_RATE}, or {@link
1153      * #KEY_I_FRAME_INTERVAL}.
1154      *
1155      * @return null if the key does not exist or the stored value for the key is null
1156      * @throws ClassCastException if the stored value for the key is ByteBuffer or String
1157      */
getNumber(@onNull String name)1158     public final @Nullable Number getNumber(@NonNull String name) {
1159         return ((Number)mMap.get(name));
1160     }
1161 
1162     /**
1163      * Returns the value of a numeric key, or the default value if the key is missing.
1164      *
1165      * @return defaultValue if the key does not exist or the stored value for the key is null
1166      * @throws ClassCastException if the stored value for the key is ByteBuffer or String
1167      */
getNumber(@onNull String name, @NonNull Number defaultValue)1168     public final @NonNull Number getNumber(@NonNull String name, @NonNull Number defaultValue) {
1169         Number ret = getNumber(name);
1170         return ret == null ? defaultValue : ret;
1171     }
1172 
1173     /**
1174      * Returns the value of an integer key.
1175      *
1176      * @throws NullPointerException if the key does not exist or the stored value for the key is
1177      *         null
1178      * @throws ClassCastException if the stored value for the key is long, float, ByteBuffer or
1179      *         String
1180      */
getInteger(@onNull String name)1181     public final int getInteger(@NonNull String name) {
1182         return ((Integer)mMap.get(name)).intValue();
1183     }
1184 
1185     /**
1186      * Returns the value of an integer key, or the default value if the key is missing.
1187      *
1188      * @return defaultValue if the key does not exist or the stored value for the key is null
1189      * @throws ClassCastException if the stored value for the key is long, float, ByteBuffer or
1190      *         String
1191      */
getInteger(@onNull String name, int defaultValue)1192     public final int getInteger(@NonNull String name, int defaultValue) {
1193         try {
1194             return getInteger(name);
1195         } catch (NullPointerException  e) {
1196             /* no such field or field is null */
1197             return defaultValue;
1198         }
1199     }
1200 
1201     /**
1202      * Returns the value of a long key.
1203      *
1204      * @throws NullPointerException if the key does not exist or the stored value for the key is
1205      *         null
1206      * @throws ClassCastException if the stored value for the key is int, float, ByteBuffer or
1207      *         String
1208      */
getLong(@onNull String name)1209     public final long getLong(@NonNull String name) {
1210         return ((Long)mMap.get(name)).longValue();
1211     }
1212 
1213     /**
1214      * Returns the value of an long key, or the default value if the key is missing.
1215      *
1216      * @return defaultValue if the key does not exist or the stored value for the key is null
1217      * @throws ClassCastException if the stored value for the key is int, float, ByteBuffer or
1218      *         String
1219      */
getLong(@onNull String name, long defaultValue)1220     public final long getLong(@NonNull String name, long defaultValue) {
1221         try {
1222             return getLong(name);
1223         } catch (NullPointerException  e) {
1224             /* no such field or field is null */
1225             return defaultValue;
1226         }
1227     }
1228 
1229     /**
1230      * Returns the value of a float key.
1231      *
1232      * @throws NullPointerException if the key does not exist or the stored value for the key is
1233      *         null
1234      * @throws ClassCastException if the stored value for the key is int, long, ByteBuffer or
1235      *         String
1236      */
getFloat(@onNull String name)1237     public final float getFloat(@NonNull String name) {
1238         return ((Float)mMap.get(name)).floatValue();
1239     }
1240 
1241     /**
1242      * Returns the value of an float key, or the default value if the key is missing.
1243      *
1244      * @return defaultValue if the key does not exist or the stored value for the key is null
1245      * @throws ClassCastException if the stored value for the key is int, long, ByteBuffer or
1246      *         String
1247      */
getFloat(@onNull String name, float defaultValue)1248     public final float getFloat(@NonNull String name, float defaultValue) {
1249         try {
1250             return getFloat(name);
1251         } catch (NullPointerException  e) {
1252             /* no such field or field is null */
1253             return defaultValue;
1254         }
1255     }
1256 
1257     /**
1258      * Returns the value of a string key.
1259      *
1260      * @return null if the key does not exist or the stored value for the key is null
1261      * @throws ClassCastException if the stored value for the key is int, long, float or ByteBuffer
1262      */
getString(@onNull String name)1263     public final @Nullable String getString(@NonNull String name) {
1264         return (String)mMap.get(name);
1265     }
1266 
1267     /**
1268      * Returns the value of an string key, or the default value if the key is missing.
1269      *
1270      * @return defaultValue if the key does not exist or the stored value for the key is null
1271      * @throws ClassCastException if the stored value for the key is int, long, float or ByteBuffer
1272      */
getString(@onNull String name, @NonNull String defaultValue)1273     public final @NonNull String getString(@NonNull String name, @NonNull String defaultValue) {
1274         String ret = getString(name);
1275         return ret == null ? defaultValue : ret;
1276     }
1277 
1278     /**
1279      * Returns the value of a ByteBuffer key.
1280      *
1281      * @return null if the key does not exist or the stored value for the key is null
1282      * @throws ClassCastException if the stored value for the key is int, long, float or String
1283      */
getByteBuffer(@onNull String name)1284     public final @Nullable ByteBuffer getByteBuffer(@NonNull String name) {
1285         return (ByteBuffer)mMap.get(name);
1286     }
1287 
1288     /**
1289      * Returns the value of a ByteBuffer key, or the default value if the key is missing.
1290      *
1291      * @return defaultValue if the key does not exist or the stored value for the key is null
1292      * @throws ClassCastException if the stored value for the key is int, long, float or String
1293      */
getByteBuffer( @onNull String name, @NonNull ByteBuffer defaultValue)1294     public final @NonNull ByteBuffer getByteBuffer(
1295             @NonNull String name, @NonNull ByteBuffer defaultValue) {
1296         ByteBuffer ret = getByteBuffer(name);
1297         return ret == null ? defaultValue : ret;
1298     }
1299 
1300     /**
1301      * Returns whether a feature is to be enabled ({@code true}) or disabled
1302      * ({@code false}).
1303      *
1304      * @param feature the name of a {@link MediaCodecInfo.CodecCapabilities} feature.
1305      *
1306      * @throws IllegalArgumentException if the feature was neither set to be enabled
1307      *         nor to be disabled.
1308      */
getFeatureEnabled(@onNull String feature)1309     public boolean getFeatureEnabled(@NonNull String feature) {
1310         Integer enabled = (Integer)mMap.get(KEY_FEATURE_ + feature);
1311         if (enabled == null) {
1312             throw new IllegalArgumentException("feature is not specified");
1313         }
1314         return enabled != 0;
1315     }
1316 
1317     /**
1318      * Sets the value of an integer key.
1319      */
setInteger(@onNull String name, int value)1320     public final void setInteger(@NonNull String name, int value) {
1321         mMap.put(name, Integer.valueOf(value));
1322     }
1323 
1324     /**
1325      * Sets the value of a long key.
1326      */
setLong(@onNull String name, long value)1327     public final void setLong(@NonNull String name, long value) {
1328         mMap.put(name, Long.valueOf(value));
1329     }
1330 
1331     /**
1332      * Sets the value of a float key.
1333      */
setFloat(@onNull String name, float value)1334     public final void setFloat(@NonNull String name, float value) {
1335         mMap.put(name, new Float(value));
1336     }
1337 
1338     /**
1339      * Sets the value of a string key.
1340      * <p>
1341      * If value is {@code null}, it sets a null value that behaves similarly to a missing key.
1342      * This could be used prior to API level {@link android os.Build.VERSION_CODES#Q} to effectively
1343      * remove a key.
1344      */
setString(@onNull String name, @Nullable String value)1345     public final void setString(@NonNull String name, @Nullable String value) {
1346         mMap.put(name, value);
1347     }
1348 
1349     /**
1350      * Sets the value of a ByteBuffer key.
1351      * <p>
1352      * If value is {@code null}, it sets a null value that behaves similarly to a missing key.
1353      * This could be used prior to API level {@link android os.Build.VERSION_CODES#Q} to effectively
1354      * remove a key.
1355      */
setByteBuffer(@onNull String name, @Nullable ByteBuffer bytes)1356     public final void setByteBuffer(@NonNull String name, @Nullable ByteBuffer bytes) {
1357         mMap.put(name, bytes);
1358     }
1359 
1360     /**
1361      * Removes a value of a given key if present. Has no effect if the key is not present.
1362      */
removeKey(@onNull String name)1363     public final void removeKey(@NonNull String name) {
1364         // exclude feature mappings
1365         if (!name.startsWith(KEY_FEATURE_)) {
1366             mMap.remove(name);
1367         }
1368     }
1369 
1370     /**
1371      * Removes a given feature setting if present. Has no effect if the feature setting is not
1372      * present.
1373      */
removeFeature(@onNull String name)1374     public final void removeFeature(@NonNull String name) {
1375         mMap.remove(KEY_FEATURE_ + name);
1376     }
1377 
1378     /**
1379      * A Partial set view for a portion of the keys in a MediaFormat object.
1380      *
1381      * This class is needed as we want to return a portion of the actual format keys in getKeys()
1382      * and another portion of the keys in getFeatures(), and still allow the view properties.
1383      */
1384     private abstract class FilteredMappedKeySet extends AbstractSet<String> {
1385         private Set<String> mKeys;
1386 
1387         // Returns true if this set should include this key
keepKey(String key)1388         abstract protected boolean keepKey(String key);
1389 
1390         // Maps a key from the underlying key set into its new value in this key set
mapKeyToItem(String key)1391         abstract protected String mapKeyToItem(String key);
1392 
1393         // Maps a key from this key set into its original value in the underlying key set
mapItemToKey(String item)1394         abstract protected String mapItemToKey(String item);
1395 
FilteredMappedKeySet()1396         public FilteredMappedKeySet() {
1397             mKeys = mMap.keySet();
1398         }
1399 
1400         // speed up contains and remove from abstract implementation (that would iterate
1401         // over each element)
1402         @Override
contains(Object o)1403         public boolean contains(Object o) {
1404             if (o instanceof String) {
1405                 String key = mapItemToKey((String)o);
1406                 return keepKey(key) && mKeys.contains(key);
1407             }
1408             return false;
1409         }
1410 
1411         @Override
remove(Object o)1412         public boolean remove(Object o) {
1413             if (o instanceof String) {
1414                 String key = mapItemToKey((String)o);
1415                 if (keepKey(key) && mKeys.remove(key)) {
1416                     mMap.remove(key);
1417                     return true;
1418                 }
1419             }
1420             return false;
1421         }
1422 
1423         private class KeyIterator implements Iterator<String> {
1424             Iterator<String> mIterator;
1425             String mLast;
1426 
KeyIterator()1427             public KeyIterator() {
1428                 // We must create a copy of the filtered stream, as remove operation has to modify
1429                 // the underlying data structure (mMap), so the iterator's operation is undefined.
1430                 // Use a list as it is likely less memory consuming than the other alternative: set.
1431                 mIterator =
1432                     mKeys.stream().filter(k -> keepKey(k)).collect(Collectors.toList()).iterator();
1433             }
1434 
1435             @Override
hasNext()1436             public boolean hasNext() {
1437                 return mIterator.hasNext();
1438             }
1439 
1440             @Override
next()1441             public String next() {
1442                 mLast = mIterator.next();
1443                 return mapKeyToItem(mLast);
1444             }
1445 
1446             @Override
remove()1447             public void remove() {
1448                 mIterator.remove();
1449                 mMap.remove(mLast);
1450             }
1451         }
1452 
1453         @Override
iterator()1454         public Iterator<String> iterator() {
1455             return new KeyIterator();
1456         }
1457 
1458         @Override
size()1459         public int size() {
1460             return (int)mKeys.stream().filter(k -> keepKey(k)).count();
1461         }
1462     }
1463 
1464     /**
1465      * A Partial set view for a portion of the keys in a MediaFormat object for keys that
1466      * don't start with a prefix, such as "feature-"
1467      */
1468     private class UnprefixedKeySet extends FilteredMappedKeySet {
1469         private String mPrefix;
1470 
UnprefixedKeySet(String prefix)1471         public UnprefixedKeySet(String prefix) {
1472             super();
1473             mPrefix = prefix;
1474         }
1475 
keepKey(String key)1476         protected boolean keepKey(String key) {
1477             return !key.startsWith(mPrefix);
1478         }
1479 
mapKeyToItem(String key)1480         protected String mapKeyToItem(String key) {
1481             return key;
1482         }
1483 
mapItemToKey(String item)1484         protected String mapItemToKey(String item) {
1485             return item;
1486         }
1487     }
1488 
1489     /**
1490      * A Partial set view for a portion of the keys in a MediaFormat object for keys that
1491      * start with a prefix, such as "feature-", with the prefix removed
1492      */
1493     private class PrefixedKeySetWithPrefixRemoved extends FilteredMappedKeySet {
1494         private String mPrefix;
1495         private int mPrefixLength;
1496 
PrefixedKeySetWithPrefixRemoved(String prefix)1497         public PrefixedKeySetWithPrefixRemoved(String prefix) {
1498             super();
1499             mPrefix = prefix;
1500             mPrefixLength = prefix.length();
1501         }
1502 
keepKey(String key)1503         protected boolean keepKey(String key) {
1504             return key.startsWith(mPrefix);
1505         }
1506 
mapKeyToItem(String key)1507         protected String mapKeyToItem(String key) {
1508             return key.substring(mPrefixLength);
1509         }
1510 
mapItemToKey(String item)1511         protected String mapItemToKey(String item) {
1512             return mPrefix + item;
1513         }
1514     }
1515 
1516 
1517    /**
1518      * Returns a {@link java.util.Set Set} view of the keys contained in this MediaFormat.
1519      *
1520      * The set is backed by the MediaFormat object, so changes to the format are reflected in the
1521      * set, and vice-versa. If the format is modified while an iteration over the set is in progress
1522      * (except through the iterator's own remove operation), the results of the iteration are
1523      * undefined. The set supports element removal, which removes the corresponding mapping from the
1524      * format, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations.
1525      * It does not support the add or addAll operations.
1526      */
getKeys()1527     public final @NonNull java.util.Set<String> getKeys() {
1528         return new UnprefixedKeySet(KEY_FEATURE_);
1529     }
1530 
1531    /**
1532      * Returns a {@link java.util.Set Set} view of the features contained in this MediaFormat.
1533      *
1534      * The set is backed by the MediaFormat object, so changes to the format are reflected in the
1535      * set, and vice-versa. If the format is modified while an iteration over the set is in progress
1536      * (except through the iterator's own remove operation), the results of the iteration are
1537      * undefined. The set supports element removal, which removes the corresponding mapping from the
1538      * format, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations.
1539      * It does not support the add or addAll operations.
1540      */
getFeatures()1541     public final @NonNull java.util.Set<String> getFeatures() {
1542         return new PrefixedKeySetWithPrefixRemoved(KEY_FEATURE_);
1543     }
1544 
1545     /**
1546      * Create a copy of a media format object.
1547      */
MediaFormat(@onNull MediaFormat other)1548     public MediaFormat(@NonNull MediaFormat other) {
1549         this();
1550         mMap.putAll(other.mMap);
1551     }
1552 
1553     /**
1554      * Sets whether a feature is to be enabled ({@code true}) or disabled
1555      * ({@code false}).
1556      *
1557      * If {@code enabled} is {@code true}, the feature is requested to be present.
1558      * Otherwise, the feature is requested to be not present.
1559      *
1560      * @param feature the name of a {@link MediaCodecInfo.CodecCapabilities} feature.
1561      *
1562      * @see MediaCodecList#findDecoderForFormat
1563      * @see MediaCodecList#findEncoderForFormat
1564      * @see MediaCodecInfo.CodecCapabilities#isFormatSupported
1565      */
setFeatureEnabled(@onNull String feature, boolean enabled)1566     public void setFeatureEnabled(@NonNull String feature, boolean enabled) {
1567         setInteger(KEY_FEATURE_ + feature, enabled ? 1 : 0);
1568     }
1569 
1570     /**
1571      * Creates a minimal audio format.
1572      * @param mime The mime type of the content.
1573      * @param sampleRate The sampling rate of the content.
1574      * @param channelCount The number of audio channels in the content.
1575      */
createAudioFormat( @onNull String mime, int sampleRate, int channelCount)1576     public static final @NonNull MediaFormat createAudioFormat(
1577             @NonNull String mime,
1578             int sampleRate,
1579             int channelCount) {
1580         MediaFormat format = new MediaFormat();
1581         format.setString(KEY_MIME, mime);
1582         format.setInteger(KEY_SAMPLE_RATE, sampleRate);
1583         format.setInteger(KEY_CHANNEL_COUNT, channelCount);
1584 
1585         return format;
1586     }
1587 
1588     /**
1589      * Creates a minimal subtitle format.
1590      * @param mime The mime type of the content.
1591      * @param language The language of the content, using either ISO 639-1 or 639-2/T
1592      *        codes.  Specify null or "und" if language information is only included
1593      *        in the content.  (This will also work if there are multiple language
1594      *        tracks in the content.)
1595      */
createSubtitleFormat( @onNull String mime, String language)1596     public static final @NonNull MediaFormat createSubtitleFormat(
1597             @NonNull String mime,
1598             String language) {
1599         MediaFormat format = new MediaFormat();
1600         format.setString(KEY_MIME, mime);
1601         format.setString(KEY_LANGUAGE, language);
1602 
1603         return format;
1604     }
1605 
1606     /**
1607      * Creates a minimal video format.
1608      * @param mime The mime type of the content.
1609      * @param width The width of the content (in pixels)
1610      * @param height The height of the content (in pixels)
1611      */
createVideoFormat( @onNull String mime, int width, int height)1612     public static final @NonNull MediaFormat createVideoFormat(
1613             @NonNull String mime,
1614             int width,
1615             int height) {
1616         MediaFormat format = new MediaFormat();
1617         format.setString(KEY_MIME, mime);
1618         format.setInteger(KEY_WIDTH, width);
1619         format.setInteger(KEY_HEIGHT, height);
1620 
1621         return format;
1622     }
1623 
1624     @Override
toString()1625     public @NonNull String toString() {
1626         return mMap.toString();
1627     }
1628 }
1629