1 // Copyright (C) 2021 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <stdint.h>
18 
19 #include <map>
20 #include <optional>
21 #include <string>
22 
23 namespace audio_proxy::service {
24 
25 struct StreamConfig {
26   // Buffer size in milliseconds, as defined by IStream::getBufferSize.
27   uint32_t bufferSizeMs;
28 
29   // Latency in milliseconds, as defined by IStreamOut::getLatency.
30   uint32_t latencyMs;
31 };
32 
33 // Global configurations for the audio HAL service and AudioProxy service.
34 struct ServiceConfig {
35   // Name of the service. It will be used to identify the audio HAL service and
36   // AudioProxy service.
37   std::string name;
38 
39   // Supported stream configs. Key is the address of the stream. Value is the
40   // config.
41   std::map<std::string, StreamConfig> streams;
42 };
43 
44 std::optional<ServiceConfig> parseServiceConfigFromCommandLine(int argc,
45                                                                char** argv);
46 
47 }  // namespace audio_proxy::service