Home | History | Annotate | Download | only in aacdec
      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_2_H_
     18 #define SOFT_AAC_2_H_
     19 
     20 #include "SimpleSoftOMXComponent.h"
     21 
     22 #include "aacdecoder_lib.h"
     23 
     24 namespace android {
     25 
     26 struct SoftAAC2 : public SimpleSoftOMXComponent {
     27     SoftAAC2(const char *name,
     28             const OMX_CALLBACKTYPE *callbacks,
     29             OMX_PTR appData,
     30             OMX_COMPONENTTYPE **component);
     31 
     32 protected:
     33     virtual ~SoftAAC2();
     34 
     35     virtual OMX_ERRORTYPE internalGetParameter(
     36             OMX_INDEXTYPE index, OMX_PTR params);
     37 
     38     virtual OMX_ERRORTYPE internalSetParameter(
     39             OMX_INDEXTYPE index, const OMX_PTR params);
     40 
     41     virtual void onQueueFilled(OMX_U32 portIndex);
     42     virtual void onPortFlushCompleted(OMX_U32 portIndex);
     43     virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled);
     44 
     45 private:
     46     enum {
     47         kNumInputBuffers        = 4,
     48         kNumOutputBuffers       = 4,
     49     };
     50 
     51     HANDLE_AACDECODER mAACDecoder;
     52     CStreamInfo *mStreamInfo;
     53     bool mIsADTS;
     54     bool mIsFirst;
     55     size_t mInputBufferCount;
     56     bool mSignalledError;
     57     int64_t mAnchorTimeUs;
     58     int64_t mNumSamplesOutput;
     59 
     60     enum {
     61         NONE,
     62         AWAITING_DISABLED,
     63         AWAITING_ENABLED
     64     } mOutputPortSettingsChange;
     65 
     66     void initPorts();
     67     status_t initDecoder();
     68     bool isConfigured() const;
     69     void maybeConfigureDownmix() const;
     70 
     71     DISALLOW_EVIL_CONSTRUCTORS(SoftAAC2);
     72 };
     73 
     74 }  // namespace android
     75 
     76 #endif  // SOFT_AAC_2_H_
     77