1 /*
2  * Copyright (C) 2019 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 #ifndef CONFIG_MANAGER_UTIL_H
17 #define CONFIG_MANAGER_UTIL_H
18 
19 #include <android/hardware/automotive/evs/1.1/types.h>
20 #include <system/camera_metadata.h>
21 
22 #include <string>
23 #include <utility>
24 
25 using ::android::hardware::automotive::evs::V1_1::CameraParam;
26 
27 class ConfigManagerUtil {
28 public:
29     /**
30      * Convert a given std::string into V4L2_CID_*
31      */
32     static bool convertToEvsCameraParam(const std::string& id, CameraParam& camParam);
33     /**
34      * Convert a given std::string into android.hardware.graphics.common.PixelFormat
35      */
36     static bool convertToPixelFormat(const std::string& format, int32_t& pixelFormat);
37     /**
38      * Convert a given std::string into corresponding camera metadata data tag defined in
39      * system/media/camera/include/system/camera_metadta_tags.h
40      */
41     static bool convertToMetadataTag(const char* name, camera_metadata_tag& aTag);
42     /**
43      * Convert a given std::string into a floating value array
44      */
45     static float* convertFloatArray(const char* sz, const char* vals, size_t& count,
46                                     const char delimiter = ',');
47     /**
48      * Trim a std::string
49      */
50     static std::string trimString(const std::string& src, const std::string& ws = " \n\r\t\f\v");
51 
52     /**
53      * Convert a given std::string to corresponding camera capabilities
54      */
55     static bool convertToCameraCapability(
56             const char* name, camera_metadata_enum_android_request_available_capabilities_t& cap);
57 };
58 
59 #endif  // CONFIG_MANAGER_UTIL_H
60