Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 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 | |
James Dong | 3bd4559 | 2012-01-20 19:28:01 -0800 | [diff] [blame^] | 17 | #ifndef VE_BACKGROUND_AUDIO_PROC_H |
| 18 | #define VE_BACKGROUND_AUDIO_PROC_H |
| 19 | |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 20 | #include "M4OSA_Error.h" |
| 21 | #include "M4OSA_Types.h" |
| 22 | #include "M4OSA_Memory.h" |
| 23 | #include "M4OSA_Export.h" |
| 24 | #include "M4OSA_CoreID.h" |
| 25 | |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 26 | |
James Dong | 3bd4559 | 2012-01-20 19:28:01 -0800 | [diff] [blame^] | 27 | namespace android { |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 28 | |
| 29 | typedef struct { |
| 30 | M4OSA_UInt16* m_dataAddress; // Android SRC needs a Int16 pointer |
| 31 | M4OSA_UInt32 m_bufferSize; |
| 32 | } M4AM_Buffer16; // Structure contains Int16_t pointer |
| 33 | |
James Dong | 3bd4559 | 2012-01-20 19:28:01 -0800 | [diff] [blame^] | 34 | enum AudioFormat { |
| 35 | MONO_16_BIT, |
| 36 | STEREO_16_BIT |
| 37 | }; |
| 38 | |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 39 | // Following struct will be used by app to supply the PT and BT properties |
| 40 | // along with ducking values |
| 41 | typedef struct { |
| 42 | M4OSA_Int32 lvInSampleRate; // Sampling audio freq (8000,16000 or more ) |
| 43 | M4OSA_Int32 lvOutSampleRate; //Sampling audio freq (8000,16000 or more ) |
James Dong | 3bd4559 | 2012-01-20 19:28:01 -0800 | [diff] [blame^] | 44 | AudioFormat lvBTFormat; |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 45 | |
| 46 | M4OSA_Int32 lvInDucking_threshold; |
| 47 | M4OSA_Float lvInDucking_lowVolume; |
| 48 | M4OSA_Bool lvInDucking_enable; |
| 49 | M4OSA_Float lvPTVolLevel; |
| 50 | M4OSA_Float lvBTVolLevel; |
| 51 | M4OSA_Int32 lvBTChannelCount; |
| 52 | M4OSA_Int32 lvPTChannelCount; |
James Dong | 3bd4559 | 2012-01-20 19:28:01 -0800 | [diff] [blame^] | 53 | } AudioMixSettings; |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 54 | |
| 55 | // This class is defined to get SF SRC access |
| 56 | class VideoEditorBGAudioProcessing { |
| 57 | public: |
| 58 | VideoEditorBGAudioProcessing(); |
James Dong | 3bd4559 | 2012-01-20 19:28:01 -0800 | [diff] [blame^] | 59 | ~VideoEditorBGAudioProcessing() {} |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 60 | |
James Dong | 3bd4559 | 2012-01-20 19:28:01 -0800 | [diff] [blame^] | 61 | void setMixParams(const AudioMixSettings& params); |
| 62 | |
| 63 | M4OSA_Int32 mixAndDuck( |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 64 | void* primaryTrackBuffer, |
| 65 | void* backgroundTrackBuffer, |
| 66 | void* mixedOutputBuffer); |
| 67 | |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 68 | private: |
James Dong | 3bd4559 | 2012-01-20 19:28:01 -0800 | [diff] [blame^] | 69 | enum { |
| 70 | kProcessingWindowSize = 10, |
| 71 | }; |
| 72 | |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 73 | M4OSA_Int32 mInSampleRate; |
| 74 | M4OSA_Int32 mOutSampleRate; |
James Dong | 3bd4559 | 2012-01-20 19:28:01 -0800 | [diff] [blame^] | 75 | AudioFormat mBTFormat; |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 76 | |
| 77 | M4OSA_Bool mIsSSRCneeded; |
| 78 | M4OSA_Int32 mBTChannelCount; |
| 79 | M4OSA_Int32 mPTChannelCount; |
| 80 | M4OSA_UInt8 mChannelConversion; |
| 81 | |
| 82 | M4OSA_UInt32 mDucking_threshold; |
| 83 | M4OSA_Float mDucking_lowVolume; |
| 84 | M4OSA_Float mDuckingFactor ; |
| 85 | M4OSA_Bool mDucking_enable; |
James Dong | 3bd4559 | 2012-01-20 19:28:01 -0800 | [diff] [blame^] | 86 | M4OSA_Int32 mAudioVolumeArray[kProcessingWindowSize]; |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 87 | M4OSA_Int32 mAudVolArrIndex; |
| 88 | M4OSA_Bool mDoDucking; |
| 89 | M4OSA_Float mPTVolLevel; |
| 90 | M4OSA_Float mBTVolLevel; |
| 91 | |
| 92 | M4AM_Buffer16 mBTBuffer; |
| 93 | |
| 94 | M4OSA_Int32 getDecibelSound(M4OSA_UInt32 value); |
| 95 | M4OSA_Bool isThresholdBreached(M4OSA_Int32* averageValue, |
| 96 | M4OSA_Int32 storeCount, M4OSA_Int32 thresholdValue); |
| 97 | |
| 98 | // This returns the size of buffer which needs to allocated |
| 99 | // before resampling is called |
| 100 | M4OSA_Int32 calculateOutResampleBufSize(); |
James Dong | ed6269f | 2012-01-19 18:40:59 -0800 | [diff] [blame] | 101 | |
| 102 | // Don't call me. |
| 103 | VideoEditorBGAudioProcessing(const VideoEditorBGAudioProcessing&); |
| 104 | VideoEditorBGAudioProcessing& operator=( |
| 105 | const VideoEditorBGAudioProcessing&); |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 106 | }; |
James Dong | 3bd4559 | 2012-01-20 19:28:01 -0800 | [diff] [blame^] | 107 | |
| 108 | } // namespace android |
| 109 | |
| 110 | #endif // VE_BACKGROUND_AUDIO_PROC_H |