1 /* 2 * Copyright (C) 2018 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 ANDROID_C2_SOFT_MP3_DEC_H_ 18 #define ANDROID_C2_SOFT_MP3_DEC_H_ 19 20 #include <SimpleC2Component.h> 21 22 23 struct tPVMP3DecoderExternal; 24 25 bool parseMp3Header(uint32_t header, size_t *frame_size, 26 uint32_t *out_sampling_rate = nullptr, 27 uint32_t *out_channels = nullptr, 28 uint32_t *out_bitrate = nullptr, 29 uint32_t *out_num_samples = nullptr); 30 31 namespace android { 32 33 struct C2SoftMP3 : public SimpleC2Component { 34 class IntfImpl; 35 36 C2SoftMP3(const char *name, c2_node_id_t id, 37 const std::shared_ptr<IntfImpl> &intfImpl); 38 virtual ~C2SoftMP3(); 39 40 // From SimpleC2Component 41 c2_status_t onInit() override; 42 c2_status_t onStop() override; 43 void onReset() override; 44 void onRelease() override; 45 c2_status_t onFlush_sm() override; 46 void process( 47 const std::unique_ptr<C2Work> &work, 48 const std::shared_ptr<C2BlockPool> &pool) override; 49 c2_status_t drain( 50 uint32_t drainMode, 51 const std::shared_ptr<C2BlockPool> &pool) override; 52 53 private: 54 enum { 55 kPVMP3DecoderDelay = 529 // samples 56 }; 57 58 std::shared_ptr<IntfImpl> mIntf; 59 tPVMP3DecoderExternal *mConfig; 60 void *mDecoderBuf; 61 62 bool mIsFirst; 63 bool mSignalledError; 64 bool mSignalledOutputEos; 65 bool mGaplessBytes; 66 uint64_t mAnchorTimeStamp; 67 uint64_t mProcessedSamples; 68 69 status_t initDecoder(); 70 71 C2_DO_NOT_COPY(C2SoftMP3); 72 }; 73 74 } // namespace android 75 76 #endif // ANDROID_C2_SOFT_MP3_DEC_H_ 77