• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.bluetooth.a2dp (Bluetooth A2DP Module)
2
3The **a2dp** module provides APIs for using the Bluetooth Advanced Audio Distribution Profile (A2DP), which defines how to stream high quality audio from one device to another over a Bluetooth connection.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9
10
11## Modules to Import
12
13```js
14import a2dp from '@ohos.bluetooth.a2dp';
15```
16
17## a2dp.createA2dpSrcProfile
18
19createA2dpSrcProfile(): A2dpSourceProfile
20
21Creates an **A2dpSrcProfile** instance.
22
23**System capability**: SystemCapability.Communication.Bluetooth.Core
24
25**Return value**
26
27| Type                           | Description        |
28| ----------------------------- | ---------- |
29| A2dpSourceProfile | **A2dpSrcProfile** instance created.|
30
31**Example**
32
33```js
34import { BusinessError } from '@ohos.base';
35try {
36    let a2dpProfile = a2dp.createA2dpSrcProfile();
37    console.info('a2dp success');
38} catch (err) {
39    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
40}
41```
42
43
44## A2dpSourceProfile
45
46Provides APIs for using the A2DP. Before using any API of **A2dpSourceProfile**, you need to create an instance of this class by using **createA2dpSrcProfile()**.
47
48
49### connect
50
51connect(deviceId: string): void
52
53Connects to an A2DP device.
54
55**System API**: This is a system API.
56
57**Required permissions**: ohos.permission.ACCESS_BLUETOOTH
58
59**System capability**: SystemCapability.Communication.Bluetooth.Core
60
61**Parameters**
62
63| Name   | Type    | Mandatory  | Description     |
64| ------ | ------ | ---- | ------- |
65| deviceId | string | Yes   | Address of the device to connect. |
66
67**Error codes**
68
69For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
70
71| ID| Error Message|
72| -------- | ---------------------------- |
73|2900001 | Service stopped.               |
74|2900003 | Bluetooth switch is off.       |
75|2900004 | Profile is not supported.      |
76|2900099 | Operation failed.              |
77
78**Example**
79
80```js
81import { BusinessError } from '@ohos.base';
82try {
83    let a2dpSrc = a2dp.createA2dpSrcProfile();
84    a2dpSrc.connect('XX:XX:XX:XX:XX:XX');
85} catch (err) {
86    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
87}
88```
89
90
91### disconnect
92
93disconnect(deviceId: string): void
94
95Disconnects from an A2DP device.
96
97**System API**: This is a system API.
98
99**Required permissions**: ohos.permission.ACCESS_BLUETOOTH
100
101**System capability**: SystemCapability.Communication.Bluetooth.Core
102
103**Parameters**
104
105| Name   | Type    | Mandatory  | Description     |
106| ------ | ------ | ---- | ------- |
107| deviceId | string | Yes   | Address of the device to disconnect. |
108
109**Error codes**
110
111For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
112
113| ID| Error Message|
114| -------- | ---------------------------- |
115|2900001 | Service stopped.                         |
116|2900003 | Bluetooth switch is off.                 |
117|2900004 | Profile is not supported.                |
118|2900099 | Operation failed.                        |
119
120**Example**
121
122```js
123import { BusinessError } from '@ohos.base';
124try {
125    let a2dpSrc = a2dp.createA2dpSrcProfile();
126    a2dpSrc.disconnect('XX:XX:XX:XX:XX:XX');
127} catch (err) {
128    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
129}
130```
131
132
133### getPlayingState
134
135getPlayingState(deviceId: string): PlayingState
136
137Obtains the playing state of a device.
138
139**Required permissions**: ohos.permission.ACCESS_BLUETOOTH
140
141**System capability**: SystemCapability.Communication.Bluetooth.Core
142
143**Parameters**
144
145| Name   | Type    | Mandatory  | Description     |
146| ------ | ------ | ---- | ------- |
147| device | string | Yes   | Address of the target device. |
148
149**Return value**
150
151| Type                           | Description        |
152| ----------------------------- | ---------- |
153| [PlayingState](#playingstate) | Playing state of the remote device obtained.|
154
155**Error codes**
156
157For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
158
159| ID| Error Message|
160| -------- | ---------------------------- |
161|2900001 | Service stopped.                         |
162|2900003 | Bluetooth switch is off.                 |
163|2900004 | Profile is not supported.                |
164|2900099 | Operation failed.                        |
165
166**Example**
167
168```js
169import { BusinessError } from '@ohos.base';
170try {
171    let a2dpSrc = a2dp.createA2dpSrcProfile();
172    let state = a2dpSrc.getPlayingState('XX:XX:XX:XX:XX:XX');
173} catch (err) {
174    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
175}
176```
177
178### isAbsoluteVolumeSupported<sup>11+</sup>
179
180isAbsoluteVolumeSupported(deviceId: string, callback: AsyncCallback&lt;boolean&gt;): void
181
182Checks whether a device supports the absolute volume capability. This API uses an asynchronous callback to return the result.
183
184**System API**: This is a system API.
185
186**Required permissions**: ohos.permission.ACCESS_BLUETOOTH
187
188**System capability**: SystemCapability.Communication.Bluetooth.Core
189
190**Parameters**
191
192| Name   | Type    | Mandatory  | Description     |
193| ------ | ------ | ---- | ------- |
194| deviceId | string | Yes   | Address of the device to check. |
195| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback invoked to return the result. If the device supports absolute volume, **supported** is returned.|
196
197
198**Error codes**
199
200For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
201
202| ID| Error Message|
203| -------- | ---------------------------- |
204|2900001 | Service stopped.                         |
205|2900003 | Bluetooth switch is off.                 |
206|2900099 | Operation failed.                        |
207
208**Example**
209
210```js
211import { BusinessError } from '@ohos.base';
212try {
213    let a2dpSrc = a2dp.createA2dpSrcProfile();
214    a2dpSrc.isAbsoluteVolumeSupported('XX:XX:XX:XX:XX:XX', (err, supported) => {
215        console.info('device support absolute volume ' + supported);
216    });
217} catch (err) {
218    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
219}
220```
221
222### isAbsoluteVolumeSupported<sup>11+</sup>
223
224isAbsoluteVolumeSupported(deviceId: string): Promise&lt;boolean&gt;
225
226Checks whether a device supports the absolute volume capability. This API uses a promise to return the result.
227
228**System API**: This is a system API.
229
230**Required permissions**: ohos.permission.ACCESS_BLUETOOTH
231
232**System capability**: SystemCapability.Communication.Bluetooth.Core
233
234**Parameters**
235
236| Name   | Type    | Mandatory  | Description     |
237| ------ | ------ | ---- | ------- |
238| deviceId | string | Yes   | Address of the device to check. |
239
240**Return value**
241
242| Type                           | Description        |
243| ----------------------------- | ---------- |
244| Promise&lt;boolean&gt; | Promise used to return the result. If the device supports absolute volume, **supported** is returned.|
245
246**Error codes**
247
248For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
249
250| ID| Error Message|
251| -------- | ---------------------------- |
252|2900001 | Service stopped.                         |
253|2900003 | Bluetooth switch is off.                 |
254|2900099 | Operation failed.                        |
255
256**Example**
257
258```js
259import { BusinessError } from '@ohos.base';
260try {
261    let a2dpSrc = a2dp.createA2dpSrcProfile();
262    a2dpSrc.isAbsoluteVolumeSupported('XX:XX:XX:XX:XX:XX').then((supported) => {
263        console.info('device support absolute volume ' + supported);
264    });
265} catch (err) {
266    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
267}
268```
269
270### isAbsoluteVolumeEnabled<sup>11+</sup>
271
272isAbsoluteVolumeEnabled(deviceId: string, callback: AsyncCallback&lt;boolean&gt;): void
273
274Checks whether the absolute volume capability is enabled for a device. This API uses an asynchronous callback to return the result. Before using this API, use [isAbsoluteVolumeSupported](#isabsolutevolumesupported11) to check whether the device supports the absolute volume capability.
275
276**System API**: This is a system API.
277
278**Required permissions**: ohos.permission.ACCESS_BLUETOOTH
279
280**System capability**: SystemCapability.Communication.Bluetooth.Core
281
282**Parameters**
283
284| Name   | Type    | Mandatory  | Description     |
285| ------ | ------ | ---- | ------- |
286| deviceId | string | Yes   | Address of the device to check. |
287| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback invoked to return the result. If absolute volume is enabled, **enabled** is returned.|
288
289
290**Error codes**
291
292For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
293
294| ID| Error Message|
295| -------- | ---------------------------- |
296|2900001 | Service stopped.                         |
297|2900003 | Bluetooth switch is off.                 |
298|2900099 | Operation failed.                        |
299
300**Example**
301
302```js
303import { BusinessError } from '@ohos.base';
304try {
305    let a2dpSrc = a2dp.createA2dpSrcProfile();
306    a2dpSrc.isAbsoluteVolumeEnabled('XX:XX:XX:XX:XX:XX', (err, enabled) => {
307        console.info('device absolute volume enable ' + enabled);
308    });
309} catch (err) {
310    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
311}
312```
313
314### isAbsoluteVolumeEnabled<sup>11+</sup>
315
316isAbsoluteVolumeEnabled(deviceId: string): Promise&lt;boolean&gt;
317
318Checks whether the absolute volume capability is enabled for a device. This API uses a promise to return the result. Before using this API, use [isAbsoluteVolumeSupported](#isabsolutevolumesupported11) to check whether the device supports the absolute volume capability.
319
320**System API**: This is a system API.
321
322**Required permissions**: ohos.permission.ACCESS_BLUETOOTH
323
324**System capability**: SystemCapability.Communication.Bluetooth.Core
325
326**Parameters**
327
328| Name   | Type    | Mandatory  | Description     |
329| ------ | ------ | ---- | ------- |
330| deviceId | string | Yes   | Address of the device to check. |
331
332**Return value**
333
334| Type                           | Description        |
335| ----------------------------- | ---------- |
336| Promise&lt;boolean&gt; | Promise used to return the result. If absolute volume is enabled, **enabled** is returned.|
337
338**Error codes**
339
340For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
341
342| ID| Error Message|
343| -------- | ---------------------------- |
344|2900001 | Service stopped.                         |
345|2900003 | Bluetooth switch is off.                 |
346|2900099 | Operation failed.                        |
347
348**Example**
349
350```js
351import { BusinessError } from '@ohos.base';
352try {
353    let a2dpSrc = a2dp.createA2dpSrcProfile();
354    a2dpSrc.isAbsoluteVolumeEnabled('XX:XX:XX:XX:XX:XX').then((enabled) => {
355        console.info('device absolute volume enable ' + enabled);
356    });
357} catch (err) {
358    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
359}
360```
361
362### enableAbsoluteVolume<sup>11+</sup>
363
364enableAbsoluteVolume(deviceId: string, callback: AsyncCallback&lt;void&gt;): void
365
366Enables the absolute volume capability for a device. This API uses an asynchronous callback to return the result. Before using this API, use [isAbsoluteVolumeSupported](#isabsolutevolumesupported11) to check whether the device supports the absolute volume capability.
367
368**System API**: This is a system API.
369
370**Required permissions**: ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
371
372**System capability**: SystemCapability.Communication.Bluetooth.Core
373
374**Parameters**
375
376| Name   | Type    | Mandatory  | Description     |
377| ------ | ------ | ---- | ------- |
378| deviceId | string | Yes   | Address of the target device. |
379| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
380
381
382**Error codes**
383
384For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
385
386| ID| Error Message|
387| -------- | ---------------------------- |
388|2900001 | Service stopped.                         |
389|2900003 | Bluetooth switch is off.                 |
390|2900099 | Operation failed.                        |
391
392**Example**
393
394```js
395import { BusinessError } from '@ohos.base';
396try {
397    let a2dpSrc = a2dp.createA2dpSrcProfile();
398    a2dpSrc.enableAbsoluteVolume('XX:XX:XX:XX:XX:XX', (err) => {
399        if (err) {
400            console.error("enableAbsoluteVolume error");
401        }
402    });
403} catch (err) {
404    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
405}
406```
407
408### enableAbsoluteVolume<sup>11+</sup>
409
410enableAbsoluteVolume(deviceId: string): Promise&lt;void&gt;
411
412Enables the absolute volume capability for a device. This API uses a promise to return the result. Before using this API, use [isAbsoluteVolumeSupported](#isabsolutevolumesupported11) to check whether the device supports the absolute volume capability.
413
414**System API**: This is a system API.
415
416**Required permissions**: ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
417
418**System capability**: SystemCapability.Communication.Bluetooth.Core
419
420**Parameters**
421
422| Name   | Type    | Mandatory  | Description     |
423| ------ | ------ | ---- | ------- |
424| deviceId | string | Yes   | Address of the target device. |
425
426**Return value**
427
428| Type                           | Description        |
429| ----------------------------- | ---------- |
430| Promise&lt;void&gt; | Promise used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
431
432**Error codes**
433
434For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
435
436| ID| Error Message|
437| -------- | ---------------------------- |
438|2900001 | Service stopped.                         |
439|2900003 | Bluetooth switch is off.                 |
440|2900099 | Operation failed.                        |
441
442**Example**
443
444```js
445import { BusinessError } from '@ohos.base';
446try {
447    let a2dpSrc = a2dp.createA2dpSrcProfile();
448    a2dpSrc.enableAbsoluteVolume('XX:XX:XX:XX:XX:XX').then(() => {
449            console.info("enableAbsoluteVolume");
450        }
451    );
452} catch (err) {
453    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
454}
455```
456
457### disableAbsoluteVolume<sup>11+</sup>
458
459disableAbsoluteVolume(deviceId: string, callback: AsyncCallback&lt;void&gt;): void
460
461Disables the absolute volume capability for a device. This API uses an asynchronous callback to return the result. Before using this API, use [isAbsoluteVolumeSupported](#isabsolutevolumesupported11) to check whether the device supports the absolute volume capability.
462
463**System API**: This is a system API.
464
465**Required permissions**: ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
466
467**System capability**: SystemCapability.Communication.Bluetooth.Core
468
469**Parameters**
470
471| Name   | Type    | Mandatory  | Description     |
472| ------ | ------ | ---- | ------- |
473| deviceId | string | Yes   | Address of the target device. |
474| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
475
476
477**Error codes**
478
479For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
480
481| ID| Error Message|
482| -------- | ---------------------------- |
483|2900001 | Service stopped.                         |
484|2900003 | Bluetooth switch is off.                 |
485|2900099 | Operation failed.                        |
486
487**Example**
488
489```js
490import { BusinessError } from '@ohos.base';
491try {
492    let a2dpSrc = a2dp.createA2dpSrcProfile();
493    a2dpSrc.disableAbsoluteVolume('XX:XX:XX:XX:XX:XX', (err) => {
494        if (err) {
495            console.error("disableAbsoluteVolume error");
496        }
497    });
498} catch (err) {
499    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
500}
501```
502
503### disableAbsoluteVolume<sup>11+</sup>
504
505disableAbsoluteVolume(deviceId: string): Promise&lt;void&gt;
506
507Disables the absolute volume capability for a device. This API uses a promise to return the result. Before using this API, use [isAbsoluteVolumeSupported](#isabsolutevolumesupported11) to check whether the device supports the absolute volume capability.
508
509**System API**: This is a system API.
510
511**Required permissions**: ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
512
513**System capability**: SystemCapability.Communication.Bluetooth.Core
514
515**Parameters**
516
517| Name   | Type    | Mandatory  | Description     |
518| ------ | ------ | ---- | ------- |
519| deviceId | string | Yes   | Address of the target device. |
520
521**Return value**
522
523| Type                           | Description        |
524| ----------------------------- | ---------- |
525| Promise&lt;void&gt; | Promise used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
526
527**Error codes**
528
529For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
530
531| ID| Error Message|
532| -------- | ---------------------------- |
533|2900001 | Service stopped.                         |
534|2900003 | Bluetooth switch is off.                 |
535|2900099 | Operation failed.                        |
536
537**Example**
538
539```js
540import { BusinessError } from '@ohos.base';
541try {
542    let a2dpSrc = a2dp.createA2dpSrcProfile();
543    a2dpSrc.disableAbsoluteVolume('XX:XX:XX:XX:XX:XX').then(() => {
544        console.info("disableAbsoluteVolume");
545    });
546} catch (err) {
547    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
548}
549```
550
551### getCurrentCodecInfo<sup>11+</sup>
552
553getCurrentCodecInfo(deviceId: string): CodecInfo
554
555Obtains the current codec information.
556
557**System API**: This is a system API.
558
559**Required permissions**: ohos.permission.ACCESS_BLUETOOTH
560
561**System capability**: SystemCapability.Communication.Bluetooth.Core
562
563**Parameters**
564
565| Name   | Type    | Mandatory  | Description     |
566| ------ | ------ | ---- | ------- |
567| deviceId | string | Yes   | Address of the remote device.|
568
569**Return value**
570
571| Type                           | Description        |
572| ----------------------------- | ---------- |
573| [CodecInfo](#codecinfo11)| Codec information obtained.|
574
575**Error codes**
576
577For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
578
579| ID| Error Message|
580| -------- | ---------------------------- |
581|2900001 | Service stopped.                         |
582|2900003 | Bluetooth switch is off.                 |
583|2900099 | Operation failed.                        |
584
585**Example**
586
587```js
588import { BusinessError } from '@ohos.base';
589try {
590    let a2dpSrc = a2dp.createA2dpSrcProfile();
591    let codecInfo : a2dp.CodecInfo = a2dpSrc.getCurrentCodecInfo('XX:XX:XX:XX:XX:XX');
592} catch (err) {
593    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
594}
595```
596
597### setCurrentCodecInfo<sup>11+</sup>
598
599setCurrentCodecInfo(deviceId: string, codecInfo: CodecInfo): void
600
601Sets the current codec information.
602
603**System API**: This is a system API.
604
605**Required permissions**: ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
606
607**System capability**: SystemCapability.Communication.Bluetooth.Core
608
609**Parameters**
610
611| Name   | Type    | Mandatory  | Description     |
612| ------ | ------ | ---- | ------- |
613| deviceId | string | Yes   | Address of the remote device.|
614| codecInfo | [CodecInfo](#codecinfo11) | Yes   | Codec information to set.|
615
616**Error codes**
617
618For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
619
620| ID| Error Message|
621| -------- | ---------------------------- |
622|2900001 | Service stopped.                         |
623|2900003 | Bluetooth switch is off.                 |
624|2900099 | Operation failed.                        |
625
626**Example**
627
628```js
629import { BusinessError } from '@ohos.base';
630try {
631    let a2dpSrc = a2dp.createA2dpSrcProfile();
632    let codecInfo : a2dp.CodecInfo = {
633        codecType: 0,
634        codecBitsPerSample: 1,
635        codecChannelMode: 2,
636        codecSampleRate: 1,
637    }
638    a2dpSrc.setCurrentCodecInfo('XX:XX:XX:XX:XX:XX', codecInfo);
639} catch (err) {
640    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
641}
642```
643
644## PlayingState
645
646Enumerates the A2DP playing states.
647
648**System capability**: SystemCapability.Communication.Bluetooth.Core
649
650| Name               | Value   | Description     |
651| ----------------- | ------ | ------- |
652| STATE_NOT_PLAYING | 0x0000 | Not playing. |
653| STATE_PLAYING     | 0x0001 | Playing.|
654
655
656## CodecInfo<sup>11+</sup>
657
658Defines the codec information.
659
660**System capability**: SystemCapability.Communication.Bluetooth.Core
661
662| Name       | Type                   | Readable  | Writable  | Description                                    |
663| ------------------- | ----------------------- | ---- | ---- | -------------------------------------- |
664| codecType<sup>11+</sup>           | [CodecType](#codectype11)      | Yes   | Yes   | Codec type. The default value is **CODEC_TYPE_SBC**.|
665| codecBitsPerSample<sup>11+</sup>  | [CodecBitsPerSample](#codecbitspersample11)  | Yes   | Yes   | Number of bits of each sample. The default value is **SCAN_MODE_LOW_POWER**.|
666| codecChannelMode<sup>11+</sup>    | [CodecChannelMode](#codecchannelmode11) | Yes   | Yes   | Channel mode of the codec. The default value is **CODEC_CHANNEL_MODE_NONE**.|
667| codecSampleRate<sup>11+</sup>     | [CodecSampleRate](#codecsamplerate11) | Yes   | Yes   | Sampling rate of the codec. The default value is **CODEC_BITS_PER_SAMPLE_NONE**.|
668
669
670## CodecType<sup>11+</sup>
671
672Enumerates the Bluetooth codec types.
673
674**System capability**: SystemCapability.Communication.Bluetooth.Core
675
676| Name               | Value   | Description     |
677| ----------------- | ------ | ------- |
678| CODEC_TYPE_INVALID<sup>11+</sup> | -1 | Unknown type. |
679| CODEC_TYPE_SBC<sup>11+</sup>     | 0 | SBC.|
680| CODEC_TYPE_AAC<sup>11+</sup>     | 1 | AAC.|
681| CODEC_TYPE_L2HC<sup>11+</sup>    | 2 | L2HC.|
682
683
684## CodecChannelMode<sup>11+</sup>
685
686Enumerates the channel modes of the Bluetooth codec.
687
688**System capability**: SystemCapability.Communication.Bluetooth.Core
689
690| Name               | Value   | Description     |
691| ----------------- | ------ | ------- |
692| CODEC_CHANNEL_MODE_NONE<sup>11+</sup>   | 0 | Unknown.|
693| CODEC_CHANNEL_MODE_MONO<sup>11+</sup>   | 1 | Mono. |
694| CODEC_CHANNEL_MODE_STEREO<sup>11+</sup> | 2 | Stereo. |
695
696
697## CodecBitsPerSample<sup>11+</sup>
698
699Enumerates the number of bits per sample for the Bluetooth codec.
700
701**System capability**: SystemCapability.Communication.Bluetooth.Core
702
703| Name               | Value   | Description     |
704| ----------------- | ------ | ------- |
705| CODEC_BITS_PER_SAMPLE_NONE<sup>11+</sup> | 0 | Unknown.|
706| CODEC_BITS_PER_SAMPLE_16<sup>11+</sup>   | 1 | 16 bits per sample.|
707| CODEC_BITS_PER_SAMPLE_24<sup>11+</sup>   | 2 | 24 bits per sample.|
708| CODEC_BITS_PER_SAMPLE_32<sup>11+</sup>   | 3 | 32 bits per sample.|
709
710
711## CodecSampleRate<sup>11+</sup>
712
713Enumerates the sampling rates of the Bluetooth codec.
714
715**System capability**: SystemCapability.Communication.Bluetooth.Core
716
717| Name               | Value   | Description     |
718| ----------------- | ------ | ------- |
719| CODEC_SAMPLE_RATE_NONE<sup>11+</sup>    | 0 | Unknown.|
720| CODEC_SAMPLE_RATE_44100<sup>11+</sup>   | 1 | 44.1 kHz.|
721| CODEC_SAMPLE_RATE_48000<sup>11+</sup>   | 2 | 48 kHz.|
722| CODEC_SAMPLE_RATE_88200<sup>11+</sup>   | 3 | 88.2 kHz.|
723| CODEC_SAMPLE_RATE_96000<sup>11+</sup>   | 4 | 96 kHz.|
724| CODEC_SAMPLE_RATE_176400<sup>11+</sup>  | 5 | 176.4 kHz.|
725| CODEC_SAMPLE_RATE_192000<sup>11+</sup>  | 6 | 192 kHz.|
726