1
+ /*
2
+ * Copyright (C) 2021 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.audio.common ;
18
+
19
+ import android.media.audio.common.AudioFormatType ;
20
+ import android.media.audio.common.PcmType ;
21
+
22
+ /**
23
+ * An extensible type for specifying audio formats. All formats are largely
24
+ * divided into two classes: PCM and non-PCM (bitstreams). Bitstreams can
25
+ * be encapsulated into PCM streams.
26
+ *
27
+ * The type defined in a way to make each format uniquely identifiable, so
28
+ * that if the framework and the HAL construct a value for the same type
29
+ * (e.g. PCM 16 bit), they will produce identical parcelables which will have
30
+ * identical hashes. This makes possible deduplicating type descriptions
31
+ * by the framework when they are received from different HAL modules without
32
+ * relying on having some centralized registry of enumeration values.
33
+ *
34
+ * {@hide}
35
+ */
36
+ @JavaDerive(equals = true , toString = true )
37
+ // @VintfStability
38
+ parcelable AudioFormatDescription {
39
+ /**
40
+ * The type of the audio format. See the 'AudioFormatType' for the
41
+ * list of supported values.
42
+ */
43
+ AudioFormatType type = AudioFormatType . DEFAULT ;
44
+ /**
45
+ * The type of the PCM stream or the transport stream for PCM
46
+ * encapsulations. See 'PcmType' for the list of supported values.
47
+ */
48
+ PcmType pcm = PcmType . DEFAULT ;
49
+ /**
50
+ * Optional encoding specification. Must be left empty when:
51
+ *
52
+ * - 'type == DEFAULT && pcm == DEFAULT' -- that means "default" type;
53
+ * - 'type == PCM' -- that means a regular PCM stream (not an encapsulation
54
+ * of an encoded bitstream).
55
+ *
56
+ * For PCM encapsulations of encoded bitstreams (e.g. an encapsulation
57
+ * according to IEC-61937 standard), the value of the 'pcm' field must
58
+ * be set accordingly, as an example, PCM_INT_16_BIT must be used for
59
+ * IEC-61937. Note that 'type == NON_PCM' in this case.
60
+ *
61
+ * Encoding names mostly follow IANA standards for media types (MIME), and
62
+ * frameworks/av/media/module/foundation/MediaDefs.cpp with the latter
63
+ * having priority. Since there are still many audio types not found in any
64
+ * of these lists, the following rules are applied:
65
+ *
66
+ * - If there is a direct MIME type for the encoding, the MIME type name
67
+ * is used as is, e.g. "audio/eac3" for the EAC-3 format.
68
+ * - If the encoding is a "subformat" of a MIME-registered format,
69
+ * the latter is augmented with a suffix, e.g. "audio/eac3-joc" for the
70
+ * JOC extension of EAC-3.
71
+ * - If it's a proprietary format, a "vnd." prefix is added, similar to
72
+ * IANA rules, e.g. "audio/vnd.dolby.truehd".
73
+ * - Otherwise, "x-" prefix is added, e.g. "audio/x-iec61937".
74
+ * - All MIME types not found in the IANA formats list have an associated
75
+ * comment.
76
+ */
77
+ @utf8InCpp String encoding ;
78
+ }
0 commit comments