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