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_H_ 18 19 #define SOFT_AAC_ENCODER_H_ 20 21 #include <media/stagefright/omx/SimpleSoftOMXComponent.h> 22 23 struct VO_AUDIO_CODECAPI; 24 struct VO_MEM_OPERATOR; 25 26 namespace android { 27 28 struct SoftAACEncoder : public SimpleSoftOMXComponent { 29 SoftAACEncoder( 30 const char *name, 31 const OMX_CALLBACKTYPE *callbacks, 32 OMX_PTR appData, 33 OMX_COMPONENTTYPE **component); 34 35 protected: 36 virtual ~SoftAACEncoder(); 37 38 virtual OMX_ERRORTYPE internalGetParameter( 39 OMX_INDEXTYPE index, OMX_PTR params); 40 41 virtual OMX_ERRORTYPE internalSetParameter( 42 OMX_INDEXTYPE index, const OMX_PTR params); 43 44 virtual void onQueueFilled(OMX_U32 portIndex); 45 46 virtual void onReset(); 47 48 private: 49 enum { 50 kNumBuffers = 4, 51 kNumSamplesPerFrame = 1024, 52 }; 53 54 void *mEncoderHandle; 55 VO_AUDIO_CODECAPI *mApiHandle; 56 VO_MEM_OPERATOR *mMemOperator; 57 58 OMX_U32 mNumChannels; 59 OMX_U32 mSampleRate; 60 OMX_U32 mBitRate; 61 62 bool mSentCodecSpecificData; 63 size_t mInputSize; 64 int16_t *mInputFrame; 65 int64_t mInputTimeUs; 66 67 bool mSawInputEOS; 68 69 uint8_t mAudioSpecificConfigData[2]; 70 71 bool mSignalledError; 72 73 void initPorts(); 74 status_t initEncoder(); 75 76 status_t setAudioSpecificConfigData(); 77 status_t setAudioParams(); 78 79 DISALLOW_EVIL_CONSTRUCTORS(SoftAACEncoder); 80 }; 81 82 } // namespace android 83 84 #endif // SOFT_AAC_ENCODER_H_ 85