c0d421ff5e0a6ef0e7643e83685f16e7826204e3
[platform/core/multimedia/mm-hal-interface.git] / testcase / audio / parser.hh
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Contact: Seungbae Shin <seungbae.shin@samsung.com>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #include <iostream>
20 #include <string>
21 #include <json.h>
22
23 using namespace std;
24
25 class CDeviceMapParser
26 {
27 public:
28         CDeviceMapParser();
29         CDeviceMapParser(const char* map_file);
30         virtual ~CDeviceMapParser();
31
32         void dump_devices();
33
34         void get_playback(string& card, string& device_num, int& rate, int& channels);
35         void get_capture(string& card, string& device_num, int& rate, int& channels);
36
37 private:
38         void open_json(const char* json_file);
39         void close_json();
40         void parse_device_string_object(json_object *device_string_o, string& device_string);
41         void parse_device_role_object(json_object *device_role_o, string& device_params);
42         void parse_device_file_object(json_object *device_file_o, pair<string, string>& device);
43         void parse_device_file_array_object(json_object *device_file_array_o, pair<string, string>& device);
44
45         void parse_playback();
46         void parse_capture();
47         void get_device(string& s, string& card, string& device_num);
48         void get_params(string& s, int& rate, int& channels);
49         void get_single_param(string& s, int& rate, int& channels);
50
51         // FixMe, pair doens't define what is paired clearly....
52         pair<string, string> m_playback; // device_string, device_params
53         pair<string, string> m_capture;  // device_string, device_params
54
55         json_object *m_json_obj;
56         json_object *m_json_device_files_obj;
57 };
58
59