xref: /aosp_15_r20/frameworks/av/media/libstagefright/codecs/aacenc/SoftAACEncoder2.h (revision ec779b8e0859a360c3d303172224686826e6e0e1)
1 /*
2  * Copyright (C) 2012 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 SOFT_AAC_ENCODER_2_H_
18 
19 #define SOFT_AAC_ENCODER_2_H_
20 
21 #include <media/stagefright/omx/SimpleSoftOMXComponent.h>
22 
23 #include "aacenc_lib.h"
24 
25 namespace android {
26 
27 struct SoftAACEncoder2 : public SimpleSoftOMXComponent {
28     SoftAACEncoder2(
29             const char *name,
30             const OMX_CALLBACKTYPE *callbacks,
31             OMX_PTR appData,
32             OMX_COMPONENTTYPE **component);
33 
34 protected:
35     virtual ~SoftAACEncoder2();
36 
37     virtual OMX_ERRORTYPE internalGetParameter(
38             OMX_INDEXTYPE index, OMX_PTR params);
39 
40     virtual OMX_ERRORTYPE internalSetParameter(
41             OMX_INDEXTYPE index, const OMX_PTR params);
42 
43     virtual void onQueueFilled(OMX_U32 portIndex);
44 
45     virtual void onReset();
46 
47 private:
48     enum {
49         kNumBuffers             = 4,
50         kNumSamplesPerFrame     = 1024
51     };
52 
53     HANDLE_AACENCODER mAACEncoder;
54 
55     OMX_U32 mNumChannels;
56     OMX_U32 mSampleRate;
57     OMX_U32 mBitRate;
58     OMX_S32 mSBRMode;
59     OMX_S32 mSBRRatio;
60     OMX_U32 mAACProfile;
61 
62     bool mSentCodecSpecificData;
63     size_t mInputSize;
64     int16_t *mInputFrame;
65     size_t mAllocatedFrameSize;
66     int64_t mInputTimeUs;
67 
68     bool mSawInputEOS;
69 
70     bool mSignalledError;
71 
72     void initPorts();
73     status_t initEncoder();
74 
75     status_t setAudioParams();
76 
77     DISALLOW_EVIL_CONSTRUCTORS(SoftAACEncoder2);
78 };
79 
80 }  // namespace android
81 
82 #endif  // SOFT_AAC_ENCODER_2_H_
83