1 /* 2 * Copyright (C) 2010 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 AAC_ENCODER_H 18 #define AAC_ENCODER_H 19 20 #include <media/stagefright/MediaSource.h> 21 #include <media/stagefright/MetaData.h> 22 23 struct VO_AUDIO_CODECAPI; 24 struct VO_MEM_OPERATOR; 25 26 namespace android { 27 28 struct MediaBufferGroup; 29 30 class AACEncoder: public MediaSource { 31 public: 32 AACEncoder(const sp<MediaSource> &source, const sp<MetaData> &meta); 33 34 virtual status_t start(MetaData *params); 35 virtual status_t stop(); 36 virtual sp<MetaData> getFormat(); 37 virtual status_t read( 38 MediaBuffer **buffer, const ReadOptions *options); 39 40 41 protected: 42 virtual ~AACEncoder(); 43 44 private: 45 sp<MediaSource> mSource; 46 sp<MetaData> mMeta; 47 bool mStarted; 48 MediaBufferGroup *mBufferGroup; 49 MediaBuffer *mInputBuffer; 50 status_t mInitCheck; 51 int32_t mSampleRate; 52 int32_t mChannels; 53 int32_t mBitRate; 54 int32_t mFrameCount; 55 56 int64_t mAnchorTimeUs; 57 int64_t mNumInputSamples; 58 59 enum { 60 kNumSamplesPerFrame = 1024, 61 }; 62 63 int16_t *mInputFrame; 64 65 uint8_t mAudioSpecificConfigData[2]; // auido specific data 66 void *mEncoderHandle; 67 VO_AUDIO_CODECAPI *mApiHandle; 68 VO_MEM_OPERATOR *mMemOperator; 69 70 status_t setAudioSpecificConfigData(); 71 status_t initCheck(); 72 73 AACEncoder& operator=(const AACEncoder &rhs); 74 AACEncoder(const AACEncoder& copy); 75 76 }; 77 78 } 79 80 #endif //#ifndef AAC_ENCODER_H 81 82