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