1 // Copyright (C) 2024 The Android Open Source Project
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 
6 // http://www.apache.org/licenses/LICENSE-2.0
7 
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 #define LOG_TAG "aics"
15 
16 #include <bluetooth/log.h>
17 
18 #include "aics/api.h"
19 
20 namespace bluetooth::aics {
21 
isValidAudioInputMuteValue(uint8_t data)22 bool isValidAudioInputMuteValue(uint8_t data) {
23   return data >= static_cast<uint8_t>(Mute::NOT_MUTED) &&
24          data <= static_cast<uint8_t>(Mute::DISABLED);
25 }
26 
parseMuteField(uint8_t data)27 Mute parseMuteField(uint8_t data) {
28   log::assert_that(isValidAudioInputMuteValue(data), "Not a valid Mute Value");
29 
30   return static_cast<Mute>(data);
31 }
32 
isValidAudioInputGainModeValue(uint8_t data)33 bool isValidAudioInputGainModeValue(uint8_t data) {
34   return data >= static_cast<uint8_t>(GainMode::MANUAL_ONLY) &&
35          data <= static_cast<uint8_t>(GainMode::AUTOMATIC);
36 }
37 
parseGainModeField(uint8_t data)38 GainMode parseGainModeField(uint8_t data) {
39   log::assert_that(isValidAudioInputGainModeValue(data), "Not a valid GainMode Value");
40 
41   return static_cast<GainMode>(data);
42 }
43 
44 }  // namespace bluetooth::aics
45