1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (C) 2020 The Android Open Source Project
3     Licensed under the Apache License, Version 2.0 (the "License");
4     you may not use this file except in compliance with the License.
5     You may obtain a copy of the License at
6          http://www.apache.org/licenses/LICENSE-2.0
7     Unless required by applicable law or agreed to in writing, software
8     distributed under the License is distributed on an "AS IS" BASIS,
9     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10     See the License for the specific language governing permissions and
11     limitations under the License.
12-->
13<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
14           targetNamespace="http://schemas.android.com/audio/audio_effects_conf/v2_0"
15           xmlns:aec="http://schemas.android.com/audio/audio_effects_conf/v2_0"
16           elementFormDefault="qualified">
17  <!-- Simple types -->
18  <xs:simpleType name="versionType">
19    <xs:restriction base="xs:decimal">
20      <xs:enumeration value="2.0"/>
21    </xs:restriction>
22  </xs:simpleType>
23  <xs:simpleType name="uuidType">
24    <xs:restriction base="xs:string">
25      <xs:pattern value="[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}"/>
26    </xs:restriction>
27  </xs:simpleType>
28  <xs:simpleType name="streamInputType">
29    <xs:restriction base="xs:string">
30      <xs:enumeration value="mic"/>
31      <xs:enumeration value="voice_uplink"/>
32      <xs:enumeration value="voice_downlink"/>
33      <xs:enumeration value="voice_call"/>
34      <xs:enumeration value="camcorder"/>
35      <xs:enumeration value="voice_recognition"/>
36      <xs:enumeration value="voice_communication"/>
37      <xs:enumeration value="unprocessed"/>
38      <xs:enumeration value="voice_performance"/>
39      <xs:enumeration value="echo_reference"/>
40      <xs:enumeration value="fm_tuner"/>
41    </xs:restriction>
42  </xs:simpleType>
43  <xs:simpleType name="streamOutputType">
44    <xs:restriction base="xs:string">
45      <xs:enumeration value="voice_call"/>
46      <xs:enumeration value="system"/>
47      <xs:enumeration value="ring"/>
48      <xs:enumeration value="music"/>
49      <xs:enumeration value="alarm"/>
50      <xs:enumeration value="notification"/>
51      <xs:enumeration value="bluetooth_sco"/>
52      <xs:enumeration value="enforced_audible"/>
53      <xs:enumeration value="dtmf"/>
54      <xs:enumeration value="tts"/>
55      <xs:enumeration value="assistant"/>
56    </xs:restriction>
57  </xs:simpleType>
58  <xs:simpleType name="relativePathType">
59    <xs:restriction base="xs:string">
60      <xs:pattern value="[^/].*"/>
61    </xs:restriction>
62  </xs:simpleType>
63  <xs:simpleType name="deviceType">
64    <xs:restriction base="xs:string">
65      <xs:enumeration value="AUDIO_DEVICE_OUT_EARPIECE"/>
66      <xs:enumeration value="AUDIO_DEVICE_OUT_SPEAKER"/>
67      <xs:enumeration value="AUDIO_DEVICE_OUT_WIRED_HEADSET"/>
68      <xs:enumeration value="AUDIO_DEVICE_OUT_WIRED_HEADPHONE"/>
69      <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_SCO"/>
70      <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET"/>
71      <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT"/>
72      <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP"/>
73      <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES"/>
74      <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER"/>
75      <xs:enumeration value="AUDIO_DEVICE_OUT_AUX_DIGITAL"/>
76      <xs:enumeration value="AUDIO_DEVICE_OUT_HDMI"/>
77      <xs:enumeration value="AUDIO_DEVICE_OUT_USB_ACCESSORY"/>
78      <xs:enumeration value="AUDIO_DEVICE_OUT_USB_DEVICE"/>
79      <xs:enumeration value="AUDIO_DEVICE_OUT_REMOTE_SUBMIX"/>
80      <xs:enumeration value="AUDIO_DEVICE_OUT_TELEPHONY_TX"/>
81      <xs:enumeration value="AUDIO_DEVICE_OUT_LINE"/>
82      <xs:enumeration value="AUDIO_DEVICE_OUT_HDMI_ARC"/>
83      <xs:enumeration value="AUDIO_DEVICE_OUT_SPDIF"/>
84      <xs:enumeration value="AUDIO_DEVICE_OUT_FM"/>
85      <xs:enumeration value="AUDIO_DEVICE_OUT_AUX_LINE"/>
86      <xs:enumeration value="AUDIO_DEVICE_OUT_SPEAKER_SAFE"/>
87      <xs:enumeration value="AUDIO_DEVICE_OUT_IP"/>
88      <xs:enumeration value="AUDIO_DEVICE_OUT_BUS"/>
89      <xs:enumeration value="AUDIO_DEVICE_OUT_PROXY"/>
90      <xs:enumeration value="AUDIO_DEVICE_OUT_USB_HEADSET"/>
91      <xs:enumeration value="AUDIO_DEVICE_OUT_HEARING_AID"/>
92      <xs:enumeration value="AUDIO_DEVICE_OUT_ECHO_CANCELLER"/>
93      <!-- Due to the xml format, IN types can not be a separated from OUT types -->
94      <xs:enumeration value="AUDIO_DEVICE_IN_COMMUNICATION"/>
95      <xs:enumeration value="AUDIO_DEVICE_IN_BUILTIN_MIC"/>
96      <xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET"/>
97      <xs:enumeration value="AUDIO_DEVICE_IN_WIRED_HEADSET"/>
98      <xs:enumeration value="AUDIO_DEVICE_IN_AUX_DIGITAL"/>
99      <xs:enumeration value="AUDIO_DEVICE_IN_HDMI"/>
100      <xs:enumeration value="AUDIO_DEVICE_IN_VOICE_CALL"/>
101      <xs:enumeration value="AUDIO_DEVICE_IN_TELEPHONY_RX"/>
102      <xs:enumeration value="AUDIO_DEVICE_IN_BACK_MIC"/>
103      <xs:enumeration value="AUDIO_DEVICE_IN_REMOTE_SUBMIX"/>
104      <xs:enumeration value="AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET"/>
105      <xs:enumeration value="AUDIO_DEVICE_IN_USB_ACCESSORY"/>
106      <xs:enumeration value="AUDIO_DEVICE_IN_USB_DEVICE"/>
107      <xs:enumeration value="AUDIO_DEVICE_IN_FM_TUNER"/>
108      <xs:enumeration value="AUDIO_DEVICE_IN_TV_TUNER"/>
109      <xs:enumeration value="AUDIO_DEVICE_IN_LINE"/>
110      <xs:enumeration value="AUDIO_DEVICE_IN_SPDIF"/>
111      <xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_A2DP"/>
112      <xs:enumeration value="AUDIO_DEVICE_IN_LOOPBACK"/>
113      <xs:enumeration value="AUDIO_DEVICE_IN_IP"/>
114      <xs:enumeration value="AUDIO_DEVICE_IN_BUS"/>
115      <xs:enumeration value="AUDIO_DEVICE_IN_PROXY"/>
116      <xs:enumeration value="AUDIO_DEVICE_IN_USB_HEADSET"/>
117      <xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_BLE"/>
118      <xs:enumeration value="AUDIO_DEVICE_IN_HDMI_ARC"/>
119      <xs:enumeration value="AUDIO_DEVICE_IN_ECHO_REFERENCE"/>
120    </xs:restriction>
121  </xs:simpleType>
122  <!-- Complex types -->
123  <xs:complexType name="librariesType">
124    <xs:annotation>
125      <xs:documentation xml:lang="en">
126        List of effect libraries to load. Each library element must have "name" and
127        "path" attributes. The latter is giving the path of the library .so file
128        relative to the standard effect folders: /(vendor|odm|system)/lib(64)?/soundfx/
129        Example for a library in "/vendor/lib/soundfx/lib.so":
130        <library name="name" path="lib.so"/>
131      </xs:documentation>
132    </xs:annotation>
133    <xs:sequence>
134      <xs:element name="library" minOccurs="0" maxOccurs="unbounded">
135        <xs:complexType>
136          <xs:attribute name="name" type="xs:string" use="required"/>
137          <xs:attribute name="path" type="aec:relativePathType" use="required"/>
138        </xs:complexType>
139      </xs:element>
140    </xs:sequence>
141  </xs:complexType>
142  <xs:complexType name="effectImplType">
143    <xs:attribute name="library" type="xs:string" use="required"/>
144    <xs:attribute name="uuid" type="aec:uuidType" use="required"/>
145  </xs:complexType>
146  <xs:complexType name="effectType">
147    <xs:complexContent>
148      <xs:extension base="aec:effectImplType">
149        <xs:attribute name="name" type="xs:string" use="required"/>
150      </xs:extension>
151    </xs:complexContent>
152  </xs:complexType>
153  <xs:complexType name="effectProxyType">
154    <xs:complexContent>
155      <xs:extension base="aec:effectType">
156        <xs:sequence>
157          <xs:element name="libsw" type="aec:effectImplType"/>
158          <xs:element name="libhw" type="aec:effectImplType"/>
159        </xs:sequence>
160      </xs:extension>
161    </xs:complexContent>
162  </xs:complexType>
163  <xs:complexType name="effectsType">
164    <xs:annotation>
165      <xs:documentation xml:lang="en">
166        List of effects to load. Each effect element must contain "name",
167        "library", and "uuid" attrs. The value of the "library" attr must
168        correspond to the name of a "library" element. The name of the effect
169        element is indicative, only the value of the "uuid" element designates
170        the effect for the audio framework.  The uuid is the implementation
171        specific UUID as specified by the effect vendor. This is not the generic
172        effect type UUID.
173        For effect proxy implementations, SW and HW implementations of the effect
174        can be specified.
175        Example:
176        <effect name="name" library="lib" uuid="uuuu"/>
177        <effectProxy name="proxied" library="proxy" uuid="xxxx">
178            <libsw library="sw_bundle" uuid="yyyy"/>
179            <libhw library="offload_bundle" uuid="zzzz"/>
180        </effectProxy>
181      </xs:documentation>
182    </xs:annotation>
183    <xs:choice maxOccurs="unbounded">
184      <xs:element name="effect" type="aec:effectType" minOccurs="0" maxOccurs="unbounded"/>
185      <xs:element name="effectProxy" type="aec:effectProxyType" minOccurs="0" maxOccurs="unbounded"/>
186    </xs:choice>
187  </xs:complexType>
188  <xs:complexType name="streamProcessingType">
189    <xs:sequence>
190      <xs:element name="apply" minOccurs="0" maxOccurs="unbounded">
191        <xs:complexType>
192          <xs:attribute name="effect" type="xs:string" use="required"/>
193        </xs:complexType>
194      </xs:element>
195    </xs:sequence>
196  </xs:complexType>
197  <xs:complexType name="streamPreprocessType">
198    <xs:annotation>
199      <xs:documentation xml:lang="en">
200        Audio preprocessing configuration. The processing configuration consists
201        of a list of elements each describing processing settings for a given
202        input stream. Valid input stream types are listed in "streamInputType".
203        Each stream element contains a list of "apply" elements. The value of the
204        "effect" attr must correspond to the name of an "effect" element.
205        Example:
206        <stream type="voice_communication">
207            <apply effect="effect1"/>
208            <apply effect="effect2"/>
209        </stream>
210      </xs:documentation>
211    </xs:annotation>
212    <xs:complexContent>
213      <xs:extension base="aec:streamProcessingType">
214        <xs:attribute name="type" type="aec:streamInputType" use="required"/>
215      </xs:extension>
216    </xs:complexContent>
217  </xs:complexType>
218  <xs:complexType name="streamPostprocessType">
219    <xs:annotation>
220      <xs:documentation xml:lang="en">
221        Audio postprocessing configuration. The processing configuration consists
222        of a list of elements each describing processing settings for a given
223        output stream. Valid output stream types are listed in "streamOutputType".
224        Each stream element contains a list of "apply" elements. The value of the
225        "effect" attr must correspond to the name of an "effect" element.
226        Example:
227        <stream type="music">
228            <apply effect="effect1"/>
229        </stream>
230      </xs:documentation>
231    </xs:annotation>
232    <xs:complexContent>
233      <xs:extension base="aec:streamProcessingType">
234        <xs:attribute name="type" type="aec:streamOutputType" use="required"/>
235      </xs:extension>
236    </xs:complexContent>
237  </xs:complexType>
238  <xs:complexType name="deviceProcessType">
239    <xs:annotation>
240      <xs:documentation xml:lang="en">
241        Audio Device Effects configuration. The processing configuration consists
242        of a list of effects to be automatically added on a device Port when involved in an audio
243        patch.
244        Valid device type are listed in "deviceType" and shall be aligned.
245        Each stream element contains a list of "apply" elements. The value of the
246        "effect" attr must correspond to the name of an "effect" element.
247        Note that if the device is involved in a hardware patch, the effect must be hardware
248        accelerated.
249        Example:
250        <devicePort address="BUS00_USAGE_MAIN" type="AUDIO_DEVICE_OUT_BUS">
251            <apply effect="equalizer"/>
252            <apply effect="effect2"/>
253        </devicePort>
254      </xs:documentation>
255    </xs:annotation>
256    <xs:complexContent>
257      <xs:extension base="aec:streamProcessingType">
258         <xs:attribute name="address" type="xs:string" use="required"/>
259         <xs:attribute name="type" type="aec:deviceType" use="required"/>
260      </xs:extension>
261    </xs:complexContent>
262  </xs:complexType>
263  <!-- Root element -->
264  <xs:element name="audio_effects_conf">
265    <xs:complexType>
266      <xs:sequence>
267        <xs:element name="libraries" type="aec:librariesType"/>
268        <xs:element name="effects" type="aec:effectsType"/>
269        <xs:element name="postprocess" minOccurs="0" maxOccurs="1">
270          <xs:complexType>
271            <xs:sequence>
272              <xs:element name="stream" type="aec:streamPostprocessType" minOccurs="0" maxOccurs="unbounded"/>
273            </xs:sequence>
274          </xs:complexType>
275        </xs:element>
276        <xs:element name="preprocess" minOccurs="0" maxOccurs="1">
277          <xs:complexType>
278            <xs:sequence>
279              <xs:element name="stream" type="aec:streamPreprocessType" minOccurs="0" maxOccurs="unbounded"/>
280            </xs:sequence>
281          </xs:complexType>
282        </xs:element>
283        <xs:element name="deviceEffects" minOccurs="0" maxOccurs="1">
284          <xs:complexType>
285            <xs:sequence>
286              <xs:element name="devicePort" type="aec:deviceProcessType" minOccurs="0" maxOccurs="unbounded"/>
287            </xs:sequence>
288          </xs:complexType>
289        </xs:element>
290      </xs:sequence>
291      <xs:attribute name="version" type="aec:versionType" use="required"/>
292    </xs:complexType>
293    <!-- Keys and references -->
294    <xs:key name="libraryName">
295      <xs:selector xpath="aec:libraries/aec:library"/>
296      <xs:field xpath="@name"/>
297    </xs:key>
298    <xs:keyref name="libraryNameRef1" refer="aec:libraryName">
299      <xs:selector xpath="aec:effects/aec:effect"/>
300      <xs:field xpath="@library"/>
301    </xs:keyref>
302    <xs:keyref name="libraryNameRef2" refer="aec:libraryName">
303      <xs:selector xpath="aec:effects/aec:effect/aec:libsw"/>
304      <xs:field xpath="@library"/>
305    </xs:keyref>
306    <xs:keyref name="libraryNameRef3" refer="aec:libraryName">
307      <xs:selector xpath="aec:effects/aec:effect/aec:libhw"/>
308      <xs:field xpath="@library"/>
309    </xs:keyref>
310    <xs:key name="effectName">
311      <xs:selector xpath="aec:effects/aec:effect|aec:effects/aec:effectProxy"/>
312      <xs:field xpath="@name"/>
313    </xs:key>
314    <xs:keyref name="effectNamePreRef" refer="aec:effectName">
315      <xs:selector xpath="aec:preprocess/aec:stream/aec:apply"/>
316      <xs:field xpath="@effect"/>
317    </xs:keyref>
318    <xs:keyref name="effectNamePostRef" refer="aec:effectName">
319      <xs:selector xpath="aec:postprocess/aec:stream/aec:apply"/>
320      <xs:field xpath="@effect"/>
321    </xs:keyref>
322  </xs:element>
323</xs:schema>
324