VorbisDecoder.h revision 388379f8b4cabe7bccf280d450a6db2c3149796b
1/* 2 * Copyright (C) 2010 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 VORBIS_DECODER_H_ 18 19#define VORBIS_DECODER_H_ 20 21#include <media/stagefright/MediaSource.h> 22 23struct vorbis_dsp_state; 24struct vorbis_info; 25 26namespace android { 27 28struct MediaBufferGroup; 29 30struct VorbisDecoder : public MediaSource { 31 VorbisDecoder(const sp<MediaSource> &source); 32 33 virtual status_t start(MetaData *params); 34 virtual status_t stop(); 35 36 virtual sp<MetaData> getFormat(); 37 38 virtual status_t read( 39 MediaBuffer **buffer, const ReadOptions *options); 40 41protected: 42 virtual ~VorbisDecoder(); 43 44private: 45 enum { 46 kMaxNumSamplesPerBuffer = 8192 * 2 47 }; 48 49 sp<MediaSource> mSource; 50 bool mStarted; 51 52 MediaBufferGroup *mBufferGroup; 53 54 int32_t mNumChannels; 55 int32_t mSampleRate; 56 int64_t mAnchorTimeUs; 57 int64_t mNumFramesOutput; 58 59 vorbis_dsp_state *mState; 60 vorbis_info *mVi; 61 62 int decodePacket(MediaBuffer *packet, MediaBuffer *out); 63 64 VorbisDecoder(const VorbisDecoder &); 65 VorbisDecoder &operator=(const VorbisDecoder &); 66}; 67 68} // namespace android 69 70#endif // VORBIS_DECODER_H_ 71 72