• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 #ifndef ANDROID_HARDWARE_AUDIO_PARAMETERS_UTIL_H_
18 #define ANDROID_HARDWARE_AUDIO_PARAMETERS_UTIL_H_
19 
20 // clang-format off
21 #include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h)
22 #include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h)
23 // clang-format on
24 
25 #include <functional>
26 #include <memory>
27 
28 #include <hidl/HidlSupport.h>
29 #include <media/AudioParameter.h>
30 
31 namespace android {
32 namespace hardware {
33 namespace audio {
34 namespace CORE_TYPES_CPP_VERSION {
35 namespace implementation {
36 
37 using ::android::hardware::hidl_string;
38 using ::android::hardware::hidl_vec;
39 using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION;
40 using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION;
41 
42 class ParametersUtil {
43    public:
44     Result setParam(const char* name, const char* value);
45     Result getParam(const char* name, bool* value);
46     Result getParam(const char* name, int* value);
47     Result getParam(const char* name, String8* value, AudioParameter context = {});
48     void getParametersImpl(
49         const hidl_vec<ParameterValue>& context, const hidl_vec<hidl_string>& keys,
50         std::function<void(Result retval, const hidl_vec<ParameterValue>& parameters)> cb);
51     std::unique_ptr<AudioParameter> getParams(const AudioParameter& keys);
52     Result setParam(const char* name, bool value);
53     Result setParam(const char* name, int value);
54     Result setParam(const char* name, float value);
55     Result setParametersImpl(const hidl_vec<ParameterValue>& context,
56                              const hidl_vec<ParameterValue>& parameters);
57     Result setParams(const AudioParameter& param);
58     Result setParam(const char* name, const DeviceAddress& address);
59 
60    protected:
~ParametersUtil()61     virtual ~ParametersUtil() {}
62 
63     virtual char* halGetParameters(const char* keys) = 0;
64     virtual int halSetParameters(const char* keysAndValues) = 0;
65 };
66 
67 }  // namespace implementation
68 }  // namespace CORE_TYPES_CPP_VERSION
69 }  // namespace audio
70 }  // namespace hardware
71 }  // namespace android
72 
73 #endif  // ANDROID_HARDWARE_AUDIO_PARAMETERS_UTIL_H_
74