AudioParameter.h revision db5cb14318bb24cd6ea14ff7ceea0d5e1f83d903
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 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. 36 // keyRouting: to change audio routing, value is an int in AudioSystem::audio_devices 37 // keySamplingRate: to change sampling rate routing, value is an int 38 // keyFormat: to change audio format, value is an int in AudioSystem::audio_format 39 // keyChannels: to change audio channel configuration, value is an int in AudioSystem::audio_channels 40 // keyFrameCount: to change audio output frame count, value is an int 41 // keyInputSource: to change audio input source, value is an int in audio_source 42 // (defined in media/mediarecorder.h) 43 static const char *keyRouting; 44 static const char *keySamplingRate; 45 static const char *keyFormat; 46 static const char *keyChannels; 47 static const char *keyFrameCount; 48 static const char *keyInputSource; 49 50 String8 toString(); 51 52 status_t add(const String8& key, const String8& value); 53 status_t addInt(const String8& key, const int value); 54 status_t addFloat(const String8& key, const float value); 55 56 status_t remove(const String8& key); 57 58 status_t get(const String8& key, String8& value); 59 status_t getInt(const String8& key, int& value); 60 status_t getFloat(const String8& key, float& value); 61 status_t getAt(size_t index, String8& key, String8& value); 62 63 size_t size() { return mParameters.size(); } 64 65private: 66 String8 mKeyValuePairs; 67 KeyedVector <String8, String8> mParameters; 68}; 69 70}; // namespace android 71 72#endif /*ANDROID_AUDIOPARAMETER_H_*/ 73