blob: 53be275c5484b14e31685de3333a3c2b5f566f53 [file] [log] [blame]
François Gaffie20f06f92015-03-24 09:01:14 +01001/*
2 * Copyright (C) 2015 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#pragma once
18
François Gaffief1e95082018-11-02 13:53:31 +010019#include <policy.h>
François Gaffie20f06f92015-03-24 09:01:14 +010020#include <RoutingStrategy.h>
21#include <EngineDefinition.h>
22#include <Volume.h>
23#include <system/audio.h>
François Gaffief1e95082018-11-02 13:53:31 +010024#include <media/AudioCommonTypes.h>
François Gaffie20f06f92015-03-24 09:01:14 +010025#include <utils/Errors.h>
26#include <string>
27#include <vector>
28
29namespace android {
30
31/**
32 * This interface allows the parameter plugin to:
33 * - instantiate all the members of the policy engine (strategies, input sources, usages, profiles)
34 * - keep up to date the attributes of these policy members ( i.e. devices to be used for a
35 * strategy, strategy to be followed by a usage or a stream, ...)
36 */
37class AudioPolicyPluginInterface
38{
39public:
40 /**
41 * Add a strategy to the engine
42 *
43 * @param[in] name of the strategy to add
44 * @param[in] identifier: the numerical value associated to this member. It MUST match either
45 * system/audio.h or system/audio_policy.h enumration value in order to link the
46 * parameter controled by the PFW and the policy manager component.
47 *
48 * @return NO_ERROR if the strategy has been added successfully, error code otherwise.
49 *
50 */
51 virtual android::status_t addStrategy(const std::string &name, routing_strategy id) = 0;
52
53 /**
54 * Add a streams to the engine.
55 *
56 * @param[in] name of the stream to add
57 * @param[in] identifier: the numerical value associated to this member. It MUST match either
58 * system/audio.h or system/audio_policy.h enumration value in order to link the
59 * parameter controled by the PFW and the policy manager component.
60 *
61 * @return NO_ERROR if the stream has been added successfully, error code otherwise.
62 *
63 */
64 virtual android::status_t addStream(const std::string &name, audio_stream_type_t id) = 0;
65
66 /**
67 * Add a usage to the engine
68 *
69 * @param[in] name of the usage to add
70 * @param[in] identifier: the numerical value associated to this member. It MUST match either
71 * system/audio.h or system/audio_policy.h enumration value in order to link the
72 * parameter controled by the PFW and the policy manager component.
73 *
74 * @return NO_ERROR if the usage has been added successfully, error code otherwise.
75 *
76 */
77 virtual android::status_t addUsage(const std::string &name, audio_usage_t id) = 0;
78
79 /**
80 * Add an input source to the engine
81 *
82 * @param[in] name of the input source to add
83 * @param[in] identifier: the numerical value associated to this member. It MUST match either
84 * system/audio.h or system/audio_policy.h enumration value in order to link the
85 * parameter controled by the PFW and the policy manager component.
86 *
87 * @return NO_ERROR if the input source has been added successfully, error code otherwise.
88 *
89 */
90 virtual android::status_t addInputSource(const std::string &name, audio_source_t id) = 0;
91
92 /**
93 * Set the device to be used by a strategy.
94 *
95 * @param[in] strategy: name of the strategy for which the device to use has to be set
96 * @param[in] devices; mask of devices to be used for the given strategy.
97 *
98 * @return true if the devices were set correclty for this strategy, false otherwise.
99 */
100 virtual bool setDeviceForStrategy(const routing_strategy &strategy, audio_devices_t devices) = 0;
101
102 /**
103 * Set the strategy to be followed by a stream.
104 *
105 * @param[in] stream: name of the stream for which the strategy to use has to be set
106 * @param[in] strategy to follow for the given stream.
107 *
108 * @return true if the strategy were set correclty for this stream, false otherwise.
109 */
110 virtual bool setStrategyForStream(const audio_stream_type_t &stream, routing_strategy strategy) = 0;
111
112 /**
113 * Set the strategy to be followed by a stream.
114 *
115 * @param[in] stream: name of the stream for which the strategy to use has to be set
François Gaffied1ab2bd2015-12-02 18:20:06 +0100116 * @param[in] volumeProfile to follow for the given stream.
François Gaffie20f06f92015-03-24 09:01:14 +0100117 *
François Gaffied1ab2bd2015-12-02 18:20:06 +0100118 * @return true if the profile was set correclty for this stream, false otherwise.
François Gaffie20f06f92015-03-24 09:01:14 +0100119 */
120 virtual bool setVolumeProfileForStream(const audio_stream_type_t &stream,
François Gaffied1ab2bd2015-12-02 18:20:06 +0100121 const audio_stream_type_t &volumeProfile) = 0;
François Gaffie20f06f92015-03-24 09:01:14 +0100122
123 /**
124 * Set the strategy to be followed by a usage.
125 *
126 * @param[in] usage: name of the usage for which the strategy to use has to be set
127 * @param[in] strategy to follow for the given usage.
128 *
129 * @return true if the strategy were set correclty for this usage, false otherwise.
130 */
131 virtual bool setStrategyForUsage(const audio_usage_t &usage, routing_strategy strategy) = 0;
132
133 /**
134 * Set the input device to be used by an input source.
135 *
136 * @param[in] inputSource: name of the input source for which the device to use has to be set
137 * @param[in] devices; mask of devices to be used for the given input source.
138 *
139 * @return true if the devices were set correclty for this input source, false otherwise.
140 */
141 virtual bool setDeviceForInputSource(const audio_source_t &inputSource,
142 audio_devices_t device) = 0;
143
François Gaffief1e95082018-11-02 13:53:31 +0100144 virtual void setDeviceAddressForProductStrategy(product_strategy_t strategy,
145 const std::string &address) = 0;
146
147 /**
148 * Set the device to be used by a product strategy.
149 *
150 * @param[in] strategy: name of the product strategy for which the device to use has to be set
151 * @param[in] devices; mask of devices to be used for the given strategy.
152 *
153 * @return true if the devices were set correclty for this strategy, false otherwise.
154 */
155 virtual bool setDeviceTypesForProductStrategy(product_strategy_t strategy,
156 audio_devices_t devices) = 0;
157
158 virtual product_strategy_t getProductStrategyByName(const std::string &address) = 0;
159
François Gaffie20f06f92015-03-24 09:01:14 +0100160protected:
161 virtual ~AudioPolicyPluginInterface() {}
162};
163
Mikhail Naganov1b2a7942017-12-08 10:18:09 -0800164} // namespace android