| Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame^] | 1 | /* | 
|  | 2 | * Copyright (C) 2011 NXP Software | 
|  | 3 | * Copyright (C) 2011 The Android Open Source Project | 
|  | 4 | * | 
|  | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 6 | * you may not use this file except in compliance with the License. | 
|  | 7 | * You may obtain a copy of the License at | 
|  | 8 | * | 
|  | 9 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 10 | * | 
|  | 11 | * Unless required by applicable law or agreed to in writing, software | 
|  | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 14 | * See the License for the specific language governing permissions and | 
|  | 15 | * limitations under the License. | 
|  | 16 | */ | 
|  | 17 |  | 
|  | 18 | #include "M4OSA_Error.h" | 
|  | 19 | #include "M4OSA_Types.h" | 
|  | 20 | #include "M4OSA_Memory.h" | 
|  | 21 | #include "M4OSA_Export.h" | 
|  | 22 | #include "M4OSA_CoreID.h" | 
|  | 23 |  | 
|  | 24 | namespace android{ | 
|  | 25 |  | 
|  | 26 | #define WINDOW_SIZE 10 | 
|  | 27 |  | 
|  | 28 | enum veAudioFormat {MONO_16_BIT, STEREO_16_BIT}; | 
|  | 29 |  | 
|  | 30 |  | 
|  | 31 | typedef struct { | 
|  | 32 | M4OSA_UInt16*   m_dataAddress; // Android SRC needs a Int16 pointer | 
|  | 33 | M4OSA_UInt32    m_bufferSize; | 
|  | 34 | } M4AM_Buffer; | 
|  | 35 |  | 
|  | 36 | // Following struct will be used by app to supply the PT and BT properties | 
|  | 37 | // along with ducking values | 
|  | 38 | typedef struct { | 
|  | 39 | M4OSA_Int32 lvInSampleRate; // Sampling audio freq (8000,16000 or more ) | 
|  | 40 | M4OSA_Int32 lvOutSampleRate; //Sampling audio freq (8000,16000 or more ) | 
|  | 41 | veAudioFormat lvBTFormat; | 
|  | 42 |  | 
|  | 43 | M4OSA_Int32 lvInDucking_threshold; | 
|  | 44 | M4OSA_Float lvInDucking_lowVolume; | 
|  | 45 | M4OSA_Bool lvInDucking_enable; | 
|  | 46 | M4OSA_Float lvPTVolLevel; | 
|  | 47 | M4OSA_Float lvBTVolLevel; | 
|  | 48 | M4OSA_Int32 lvBTChannelCount; | 
|  | 49 | M4OSA_Int32 lvPTChannelCount; | 
|  | 50 | } veAudMixSettings; | 
|  | 51 |  | 
|  | 52 | // This class is defined to get SF SRC access | 
|  | 53 | class VideoEditorBGAudioProcessing { | 
|  | 54 | public: | 
|  | 55 | VideoEditorBGAudioProcessing(); | 
|  | 56 | void veSetAudioProcessingParams(veAudMixSettings mixParams); | 
|  | 57 | M4OSA_Int32 veProcessAudioMixNDuck(void* , void *, void *); | 
|  | 58 |  | 
|  | 59 | protected: | 
|  | 60 | ~VideoEditorBGAudioProcessing(); | 
|  | 61 |  | 
|  | 62 | private: | 
|  | 63 | M4OSA_Int32 mInSampleRate; | 
|  | 64 | M4OSA_Int32 mOutSampleRate; | 
|  | 65 | veAudioFormat mBTFormat; | 
|  | 66 |  | 
|  | 67 | M4OSA_Bool mIsSSRCneeded; | 
|  | 68 | M4OSA_Int32 mBTChannelCount; | 
|  | 69 | M4OSA_Int32 mPTChannelCount; | 
|  | 70 | M4OSA_UInt8 mChannelConversion; | 
|  | 71 |  | 
|  | 72 | M4OSA_UInt32 mDucking_threshold; | 
|  | 73 | M4OSA_Float mDucking_lowVolume; | 
|  | 74 | M4OSA_Float mDuckingFactor ; | 
|  | 75 | M4OSA_Bool mDucking_enable; | 
|  | 76 | M4OSA_Int32 mAudioVolumeArray[WINDOW_SIZE]; | 
|  | 77 | M4OSA_Int32 mAudVolArrIndex; | 
|  | 78 | M4OSA_Bool mDoDucking; | 
|  | 79 | M4OSA_Float mPTVolLevel; | 
|  | 80 | M4OSA_Float mBTVolLevel; | 
|  | 81 |  | 
|  | 82 | M4AM_Buffer mPTBuffer; | 
|  | 83 | M4AM_Buffer mBTBuffer; | 
|  | 84 | M4AM_Buffer mOutMixBuffer; | 
|  | 85 | M4OSA_Int16 *mTempBuffer; | 
|  | 86 | M4OSA_Int32 mTempFrameCount; | 
|  | 87 |  | 
|  | 88 | M4OSA_Int32 getDecibelSound(M4OSA_UInt32 value); | 
|  | 89 | M4OSA_Bool  isThresholdBreached(M4OSA_Int32* averageValue, | 
|  | 90 | M4OSA_Int32 storeCount, M4OSA_Int32 thresholdValue); | 
|  | 91 |  | 
|  | 92 | // This returns the size of buffer which needs to allocated | 
|  | 93 | // before resampling is called | 
|  | 94 | M4OSA_Int32 calculateOutResampleBufSize(); | 
|  | 95 | }; | 
|  | 96 | } // namespace android |