Home | History | Annotate | Download | only in aacenc
      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_U32 mAACProfile;
     57 
     58     bool mSentCodecSpecificData;
     59     size_t mInputSize;
     60     int16_t *mInputFrame;
     61     int64_t mInputTimeUs;
     62 
     63     bool mSawInputEOS;
     64 
     65     bool mSignalledError;
     66 
     67     void initPorts();
     68     status_t initEncoder();
     69 
     70     status_t setAudioParams();
     71 
     72     DISALLOW_EVIL_CONSTRUCTORS(SoftAACEncoder2);
     73 };
     74 
     75 }  // namespace android
     76 
     77 #endif  // SOFT_AAC_ENCODER_2_H_
     78