blob: ea03a90bcb51f10f03014e4abc586dc7f60e4cf5 [file] [log] [blame]
Dima Zavindb5cb142011-04-19 22:20:55 -07001/*
2 * Copyright (C) 2008-2011 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#ifndef ANDROID_AUDIOPARAMETER_H_
18#define ANDROID_AUDIOPARAMETER_H_
19
20#include <utils/Errors.h>
21#include <utils/KeyedVector.h>
22#include <utils/String8.h>
23
24namespace android {
25
26class AudioParameter {
27
28public:
29 AudioParameter() {}
30 AudioParameter(const String8& keyValuePairs);
31 virtual ~AudioParameter();
32
33 // reserved parameter keys for changing standard parameters with setParameters() function.
34 // Using these keys is mandatory for AudioFlinger to properly monitor audio output/input
35 // configuration changes and act accordingly.
Dima Zavinfce7a472011-04-19 22:30:36 -070036 // keyRouting: to change audio routing, value is an int in audio_devices_t
Dima Zavindb5cb142011-04-19 22:20:55 -070037 // keySamplingRate: to change sampling rate routing, value is an int
Dima Zavinfce7a472011-04-19 22:30:36 -070038 // keyFormat: to change audio format, value is an int in audio_format_t
39 // keyChannels: to change audio channel configuration, value is an int in audio_channels_t
Dima Zavindb5cb142011-04-19 22:20:55 -070040 // keyFrameCount: to change audio output frame count, value is an int
Dima Zavinfce7a472011-04-19 22:30:36 -070041 // keyInputSource: to change audio input source, value is an int in audio_source_t
Dima Zavindb5cb142011-04-19 22:20:55 -070042 // (defined in media/mediarecorder.h)
Glenn Kasten28ed2f92012-06-07 10:17:54 -070043 // keyScreenState: either "on" or "off"
Glenn Kastenedf47a82012-04-01 13:49:17 -070044 static const char * const keyRouting;
45 static const char * const keySamplingRate;
46 static const char * const keyFormat;
47 static const char * const keyChannels;
48 static const char * const keyFrameCount;
49 static const char * const keyInputSource;
Glenn Kasten28ed2f92012-06-07 10:17:54 -070050 static const char * const keyScreenState;
Dima Zavindb5cb142011-04-19 22:20:55 -070051
Mikhail Naganov00260b52016-10-13 12:54:24 -070052 // keyBtNrec: BT SCO Noise Reduction + Echo Cancellation parameters
53 // keyHwAvSync: get HW synchronization source identifier from a device
54 // keyMonoOutput: Enable mono audio playback
55 // keyStreamHwAvSync: set HW synchronization source identifier on a stream
56 static const char * const keyBtNrec;
57 static const char * const keyHwAvSync;
58 static const char * const keyMonoOutput;
59 static const char * const keyStreamHwAvSync;
60
Mikhail Naganov388360c2016-10-17 17:09:41 -070061 // keyStreamConnect / Disconnect: value is an int in audio_devices_t
62 static const char * const keyStreamConnect;
63 static const char * const keyStreamDisconnect;
64
65 // For querying stream capabilities. All the returned values are lists.
66 // keyStreamSupportedFormats: audio_format_t
67 // keyStreamSupportedChannels: audio_channel_mask_t
68 // keyStreamSupportedSamplingRates: sampling rate values
69 static const char * const keyStreamSupportedFormats;
70 static const char * const keyStreamSupportedChannels;
71 static const char * const keyStreamSupportedSamplingRates;
72
Mikhail Naganov00260b52016-10-13 12:54:24 -070073 static const char * const valueOn;
74 static const char * const valueOff;
75
Mikhail Naganov388360c2016-10-17 17:09:41 -070076 static const char * const valueListSeparator;
77
Dima Zavindb5cb142011-04-19 22:20:55 -070078 String8 toString();
79
80 status_t add(const String8& key, const String8& value);
81 status_t addInt(const String8& key, const int value);
82 status_t addFloat(const String8& key, const float value);
83
84 status_t remove(const String8& key);
85
86 status_t get(const String8& key, String8& value);
87 status_t getInt(const String8& key, int& value);
88 status_t getFloat(const String8& key, float& value);
89 status_t getAt(size_t index, String8& key, String8& value);
90
91 size_t size() { return mParameters.size(); }
92
93private:
94 String8 mKeyValuePairs;
95 KeyedVector <String8, String8> mParameters;
96};
97
98}; // namespace android
99
100#endif /*ANDROID_AUDIOPARAMETER_H_*/