Dima Zavin | db5cb14 | 2011-04-19 22:20:55 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 24 | namespace android { |
| 25 | |
| 26 | class AudioParameter { |
| 27 | |
| 28 | public: |
| 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 Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 36 | // keyRouting: to change audio routing, value is an int in audio_devices_t |
Dima Zavin | db5cb14 | 2011-04-19 22:20:55 -0700 | [diff] [blame] | 37 | // keySamplingRate: to change sampling rate routing, value is an int |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 38 | // 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 Zavin | db5cb14 | 2011-04-19 22:20:55 -0700 | [diff] [blame] | 40 | // keyFrameCount: to change audio output frame count, value is an int |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 41 | // keyInputSource: to change audio input source, value is an int in audio_source_t |
Dima Zavin | db5cb14 | 2011-04-19 22:20:55 -0700 | [diff] [blame] | 42 | // (defined in media/mediarecorder.h) |
Glenn Kasten | 28ed2f9 | 2012-06-07 10:17:54 -0700 | [diff] [blame] | 43 | // keyScreenState: either "on" or "off" |
Glenn Kasten | edf47a8 | 2012-04-01 13:49:17 -0700 | [diff] [blame] | 44 | 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 Kasten | 28ed2f9 | 2012-06-07 10:17:54 -0700 | [diff] [blame] | 50 | static const char * const keyScreenState; |
Dima Zavin | db5cb14 | 2011-04-19 22:20:55 -0700 | [diff] [blame] | 51 | |
Mikhail Naganov | 00260b5 | 2016-10-13 12:54:24 -0700 | [diff] [blame] | 52 | // 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 | |
Dean Wheatley | a70eef7 | 2018-01-04 14:23:50 +1100 | [diff] [blame] | 61 | // keys for presentation selection |
| 62 | // keyPresentationId: Audio presentation identifier |
| 63 | // keyProgramId: Audio presentation program identifier |
| 64 | static const char * const keyPresentationId; |
| 65 | static const char * const keyProgramId; |
| 66 | |
Previr Rangroo | 97bf89c | 2017-12-12 10:11:33 +1100 | [diff] [blame] | 67 | // keyAudioLanguagePreferred: Preferred audio language |
| 68 | static const char * const keyAudioLanguagePreferred; |
| 69 | |
Mikhail Naganov | f23fcf6 | 2019-07-08 15:28:43 -0700 | [diff] [blame] | 70 | // keyDeviceConnect / Disconnect: value is an int in audio_devices_t |
| 71 | static const char * const keyDeviceConnect; |
| 72 | static const char * const keyDeviceDisconnect; |
Mikhail Naganov | 2207c05 | 2019-08-05 11:11:38 -0700 | [diff] [blame] | 73 | // Need to be here because vendors still use them. |
| 74 | static const char * const keyStreamConnect; // Deprecated: DO NOT USE. |
| 75 | static const char * const keyStreamDisconnect; // Deprecated: DO NOT USE. |
Mikhail Naganov | 388360c | 2016-10-17 17:09:41 -0700 | [diff] [blame] | 76 | |
| 77 | // For querying stream capabilities. All the returned values are lists. |
| 78 | // keyStreamSupportedFormats: audio_format_t |
| 79 | // keyStreamSupportedChannels: audio_channel_mask_t |
| 80 | // keyStreamSupportedSamplingRates: sampling rate values |
| 81 | static const char * const keyStreamSupportedFormats; |
| 82 | static const char * const keyStreamSupportedChannels; |
| 83 | static const char * const keyStreamSupportedSamplingRates; |
| 84 | |
Mikhail Naganov | 00260b5 | 2016-10-13 12:54:24 -0700 | [diff] [blame] | 85 | static const char * const valueOn; |
| 86 | static const char * const valueOff; |
| 87 | |
Mikhail Naganov | 388360c | 2016-10-17 17:09:41 -0700 | [diff] [blame] | 88 | static const char * const valueListSeparator; |
| 89 | |
Aniket Kumar Lata | 3432e04 | 2018-04-06 14:22:15 -0700 | [diff] [blame] | 90 | // keyReconfigA2dp: Ask HwModule to reconfigure A2DP offloaded codec |
| 91 | // keyReconfigA2dpSupported: Query if HwModule supports A2DP offload codec config |
| 92 | static const char * const keyReconfigA2dp; |
| 93 | static const char * const keyReconfigA2dpSupported; |
| 94 | |
jiabin | 1c4794b | 2020-05-05 10:08:05 -0700 | [diff] [blame^] | 95 | // For querying device supported encapsulation capabilities. All returned values are integer, |
| 96 | // which are bit fields composed from using encapsulation capability values as position bits. |
| 97 | // Encapsulation capability values are defined in audio_encapsulation_mode_t and |
| 98 | // audio_encapsulation_metadata_type_t. For instance, if the supported encapsulation mode is |
| 99 | // AUDIO_ENCAPSULATION_MODE_ELEMENTARY_STREAM, the returned value is |
| 100 | // "supEncapsulationModes=1 << AUDIO_ENCAPSULATION_MODE_HANDLE". |
| 101 | // When querying device supported encapsulation capabilities, the key should use with device |
| 102 | // type and address so that it is able to identify the device. The device will be a key. The |
| 103 | // device type will be the value of key AUDIO_PARAMETER_STREAM_ROUTING. |
| 104 | // static const char * const keyDeviceSupportedEncapsulationModes; |
| 105 | // static const char * const keyDeviceSupportedEncapsulationMetadataTypes; |
| 106 | |
Mikhail Naganov | aad28fc | 2016-11-14 14:56:09 -0800 | [diff] [blame] | 107 | String8 toString() const { return toStringImpl(true); } |
| 108 | String8 keysToString() const { return toStringImpl(false); } |
Dima Zavin | db5cb14 | 2011-04-19 22:20:55 -0700 | [diff] [blame] | 109 | |
| 110 | status_t add(const String8& key, const String8& value); |
| 111 | status_t addInt(const String8& key, const int value); |
Mikhail Naganov | aad28fc | 2016-11-14 14:56:09 -0800 | [diff] [blame] | 112 | status_t addKey(const String8& key); |
Dima Zavin | db5cb14 | 2011-04-19 22:20:55 -0700 | [diff] [blame] | 113 | status_t addFloat(const String8& key, const float value); |
| 114 | |
| 115 | status_t remove(const String8& key); |
| 116 | |
Mikhail Naganov | 913d06c | 2016-11-01 12:49:22 -0700 | [diff] [blame] | 117 | status_t get(const String8& key, String8& value) const; |
| 118 | status_t getInt(const String8& key, int& value) const; |
| 119 | status_t getFloat(const String8& key, float& value) const; |
Mikhail Naganov | f558e02 | 2016-11-14 17:45:17 -0800 | [diff] [blame] | 120 | status_t getAt(size_t index, String8& key) const; |
Mikhail Naganov | 913d06c | 2016-11-01 12:49:22 -0700 | [diff] [blame] | 121 | status_t getAt(size_t index, String8& key, String8& value) const; |
Dima Zavin | db5cb14 | 2011-04-19 22:20:55 -0700 | [diff] [blame] | 122 | |
Mikhail Naganov | 913d06c | 2016-11-01 12:49:22 -0700 | [diff] [blame] | 123 | size_t size() const { return mParameters.size(); } |
Dima Zavin | db5cb14 | 2011-04-19 22:20:55 -0700 | [diff] [blame] | 124 | |
| 125 | private: |
| 126 | String8 mKeyValuePairs; |
| 127 | KeyedVector <String8, String8> mParameters; |
Mikhail Naganov | aad28fc | 2016-11-14 14:56:09 -0800 | [diff] [blame] | 128 | |
| 129 | String8 toStringImpl(bool useValues) const; |
Dima Zavin | db5cb14 | 2011-04-19 22:20:55 -0700 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | }; // namespace android |
| 133 | |
| 134 | #endif /*ANDROID_AUDIOPARAMETER_H_*/ |