1 /* 2 * Copyright (C) 2011 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_AMR_H_ 18 19 #define SOFT_AMR_H_ 20 21 #include "SimpleSoftOMXComponent.h" 22 23 namespace android { 24 25 struct SoftAMR : public SimpleSoftOMXComponent { 26 SoftAMR(const char *name, 27 const OMX_CALLBACKTYPE *callbacks, 28 OMX_PTR appData, 29 OMX_COMPONENTTYPE **component); 30 31 protected: 32 virtual ~SoftAMR(); 33 34 virtual OMX_ERRORTYPE internalGetParameter( 35 OMX_INDEXTYPE index, OMX_PTR params); 36 37 virtual OMX_ERRORTYPE internalSetParameter( 38 OMX_INDEXTYPE index, const OMX_PTR params); 39 40 virtual void onQueueFilled(OMX_U32 portIndex); 41 virtual void onPortFlushCompleted(OMX_U32 portIndex); 42 virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled); 43 44 private: 45 enum { 46 kNumBuffers = 4, 47 kSampleRateNB = 8000, 48 kSampleRateWB = 16000, 49 kNumSamplesPerFrameNB = 160, 50 kNumSamplesPerFrameWB = 320, 51 }; 52 53 enum { 54 MODE_NARROW, 55 MODE_WIDE 56 57 } mMode; 58 59 void *mState; 60 void *mDecoderBuf; 61 int16_t *mDecoderCookie; 62 63 size_t mInputBufferCount; 64 int64_t mAnchorTimeUs; 65 int64_t mNumSamplesOutput; 66 67 bool mSignalledError; 68 69 enum { 70 NONE, 71 AWAITING_DISABLED, 72 AWAITING_ENABLED 73 } mOutputPortSettingsChange; 74 75 int16_t mInputSampleBuffer[477]; 76 77 void initPorts(); 78 status_t initDecoder(); 79 bool isConfigured() const; 80 81 DISALLOW_EVIL_CONSTRUCTORS(SoftAMR); 82 }; 83 84 } // namespace android 85 86 #endif // SOFT_AMR_H_ 87 88