1 /* 2 * Copyright (C) 2017 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_FLAC_DECODER_H 18 #define SOFT_FLAC_DECODER_H 19 20 #include "FLACDecoder.h" 21 #include <media/stagefright/omx/SimpleSoftOMXComponent.h> 22 23 namespace android { 24 25 struct SoftFlacDecoder : public SimpleSoftOMXComponent { 26 SoftFlacDecoder(const char *name, 27 const OMX_CALLBACKTYPE *callbacks, 28 OMX_PTR appData, 29 OMX_COMPONENTTYPE **component); 30 31 virtual OMX_ERRORTYPE initCheck() const override; 32 33 protected: 34 virtual ~SoftFlacDecoder(); 35 36 virtual OMX_ERRORTYPE internalGetParameter( 37 OMX_INDEXTYPE index, OMX_PTR params) override; 38 39 virtual OMX_ERRORTYPE internalSetParameter( 40 OMX_INDEXTYPE index, const OMX_PTR params) override; 41 42 virtual void onQueueFilled(OMX_U32 portIndex); 43 virtual void onPortFlushCompleted(OMX_U32 portIndex) override; 44 virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled) override; 45 virtual void onReset() override; 46 47 private: 48 static constexpr unsigned int kNumSamplesPerFrame = 2048; // adjusted based on stream. 49 50 enum { 51 kNumInputBuffers = 4, 52 kNumOutputBuffers = 4, 53 }; 54 OMX_NUMERICALDATATYPE mNumericalData = OMX_NumericalDataSigned; 55 OMX_U32 mBitsPerSample = 16; 56 57 FLACDecoder *mFLACDecoder; 58 FLAC__StreamMetadata_StreamInfo mStreamInfo; 59 size_t mInputBufferCount; 60 bool mHasStreamInfo; 61 bool mSignalledError; 62 bool mSawInputEOS; 63 bool mFinishedDecoder; 64 65 enum { 66 NONE, 67 AWAITING_DISABLED, 68 AWAITING_ENABLED 69 } mOutputPortSettingsChange; 70 71 void initPorts(); 72 void initDecoder(); 73 bool isConfigured() const; 74 void drainDecoder(); 75 76 DISALLOW_EVIL_CONSTRUCTORS(SoftFlacDecoder); 77 }; 78 79 } // namespace android 80 81 #endif // SOFT_FLAC_DECODER_H 82