blob: 8c54e157d0a3e0176f77c8ba9a0df71f5615b0f7 [file] [log] [blame]
Dharmaray Kundargi643290d2011-01-16 16:02:42 -08001/*
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
24namespace android{
25
26#define WINDOW_SIZE 10
27
28enum veAudioFormat {MONO_16_BIT, STEREO_16_BIT};
29
30
31typedef 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
38typedef 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
53class VideoEditorBGAudioProcessing {
54public:
55 VideoEditorBGAudioProcessing();
56 void veSetAudioProcessingParams(veAudMixSettings mixParams);
57 M4OSA_Int32 veProcessAudioMixNDuck(void* , void *, void *);
58
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080059 ~VideoEditorBGAudioProcessing();
60
61private:
62 M4OSA_Int32 mInSampleRate;
63 M4OSA_Int32 mOutSampleRate;
64 veAudioFormat mBTFormat;
65
66 M4OSA_Bool mIsSSRCneeded;
67 M4OSA_Int32 mBTChannelCount;
68 M4OSA_Int32 mPTChannelCount;
69 M4OSA_UInt8 mChannelConversion;
70
71 M4OSA_UInt32 mDucking_threshold;
72 M4OSA_Float mDucking_lowVolume;
73 M4OSA_Float mDuckingFactor ;
74 M4OSA_Bool mDucking_enable;
75 M4OSA_Int32 mAudioVolumeArray[WINDOW_SIZE];
76 M4OSA_Int32 mAudVolArrIndex;
77 M4OSA_Bool mDoDucking;
78 M4OSA_Float mPTVolLevel;
79 M4OSA_Float mBTVolLevel;
80
81 M4AM_Buffer mPTBuffer;
82 M4AM_Buffer mBTBuffer;
83 M4AM_Buffer mOutMixBuffer;
84 M4OSA_Int16 *mTempBuffer;
85 M4OSA_Int32 mTempFrameCount;
86
87 M4OSA_Int32 getDecibelSound(M4OSA_UInt32 value);
88 M4OSA_Bool isThresholdBreached(M4OSA_Int32* averageValue,
89 M4OSA_Int32 storeCount, M4OSA_Int32 thresholdValue);
90
91 // This returns the size of buffer which needs to allocated
92 // before resampling is called
93 M4OSA_Int32 calculateOutResampleBufSize();
94};
95} // namespace android