1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 
17 
18 #ifndef CTSAUDIO_BUILTINPROCESSING_H
19 #define CTSAUDIO_BUILTINPROCESSING_H
20 
21 #include "task/TaskGeneric.h"
22 
23 class BuiltinProcessing {
24 public:
25     BuiltinProcessing();
26 
27     typedef TaskGeneric::ExecutionResult \
28             (BuiltinProcessing::*BuiltinProcessingMemberFn)(void**, void**);
29     struct BuiltinInfo {
30         const char* mName;
31         BuiltinProcessingMemberFn mFunction;
32         size_t mNInput;
33         const bool* mInputTypes; // true: android::sp<Buffer>*, false: Value*
34         size_t mNOutput;
35         const bool* mOutputTypes;
36     };
37 
38     static const int N_BUILTIN_FNS = 1;
39     static BuiltinInfo BUINTIN_FN_TABLE[N_BUILTIN_FNS];
40     /**
41      * calculate RMS of given data. The rms is passed to moving average filter
42      * And the averaged RMS should be within passMin to passMax to pass the test.
43      * Otherwise, it will just return EResultOK.
44      * Input: android::sp<Buffer> data, int64_t passMin, int64_t passMax
45      * Output:int64_t rms
46      */
47     TaskGeneric::ExecutionResult rms_mva(void** inputs, void** outputs);
48 private:
49     static const int RMS_CONTINUOUS_PASSES = 5;
50     int mRMSPasses;
51 };
52 
53 
54 #endif // CTSAUDIO_BUILTINPROCESSING_H
55