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 "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 private: 46 enum { 47 kNumBuffers = 4, 48 kNumSamplesPerFrame = 1024 49 }; 50 51 HANDLE_AACENCODER mAACEncoder; 52 53 OMX_U32 mNumChannels; 54 OMX_U32 mSampleRate; 55 OMX_U32 mBitRate; 56 OMX_S32 mSBRMode; 57 OMX_S32 mSBRRatio; 58 OMX_U32 mAACProfile; 59 60 bool mSentCodecSpecificData; 61 size_t mInputSize; 62 int16_t *mInputFrame; 63 int64_t mInputTimeUs; 64 65 bool mSawInputEOS; 66 67 bool mSignalledError; 68 69 void initPorts(); 70 status_t initEncoder(); 71 72 status_t setAudioParams(); 73 74 DISALLOW_EVIL_CONSTRUCTORS(SoftAACEncoder2); 75 }; 76 77 } // namespace android 78 79 #endif // SOFT_AAC_ENCODER_2_H_ 80