• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
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  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef LOG_TAG
17 #define LOG_TAG "OHAudioCommon"
18 #endif
19 
20 #include "OHAudioCommon.h"
21 
22 namespace OHOS {
23 namespace AudioStandard {
ConvertLayoutToChannel(OH_AudioChannelLayout layout)24 AudioChannel OHAudioCommon::ConvertLayoutToChannel(OH_AudioChannelLayout layout)
25 {
26     AudioChannel channel = AudioChannel::CHANNEL_UNKNOW;
27     switch (layout) {
28         case OH_AudioChannelLayout::CH_LAYOUT_MONO:
29             channel = AudioChannel::MONO;
30             break;
31         case OH_AudioChannelLayout::CH_LAYOUT_STEREO:
32             channel = AudioChannel::STEREO;
33             break;
34         case OH_AudioChannelLayout::CH_LAYOUT_2POINT1:
35         case OH_AudioChannelLayout::CH_LAYOUT_3POINT0:
36             channel = AudioChannel::CHANNEL_3;
37             break;
38         case OH_AudioChannelLayout::CH_LAYOUT_3POINT1:
39         case OH_AudioChannelLayout::CH_LAYOUT_4POINT0:
40         case OH_AudioChannelLayout::CH_LAYOUT_QUAD:
41             channel = AudioChannel::CHANNEL_4;
42             break;
43         case OH_AudioChannelLayout::CH_LAYOUT_5POINT0:
44         case OH_AudioChannelLayout::CH_LAYOUT_2POINT1POINT2:
45             channel = AudioChannel::CHANNEL_5;
46             break;
47         case OH_AudioChannelLayout::CH_LAYOUT_5POINT1:
48         case OH_AudioChannelLayout::CH_LAYOUT_HEXAGONAL:
49         case OH_AudioChannelLayout::CH_LAYOUT_3POINT1POINT2:
50             channel = AudioChannel::CHANNEL_6;
51             break;
52         case OH_AudioChannelLayout::CH_LAYOUT_7POINT0:
53             channel = AudioChannel::CHANNEL_7;
54             break;
55         case OH_AudioChannelLayout::CH_LAYOUT_7POINT1:
56             channel = AudioChannel::CHANNEL_8;
57             break;
58         case OH_AudioChannelLayout::CH_LAYOUT_7POINT1POINT2:
59             channel = AudioChannel::CHANNEL_10;
60             break;
61         case OH_AudioChannelLayout::CH_LAYOUT_7POINT1POINT4:
62             channel = AudioChannel::CHANNEL_12;
63             break;
64         default:
65             channel = AudioChannel::CHANNEL_UNKNOW;
66             break;
67     }
68     return channel;
69 }
70 
71 } // namespace AudioStandard
72 } // namespace OHOS
73