AVCDecoder.h revision 6624c9fd0bc5e3858a22a04c05b5059445c1c367
1/* 2 * Copyright (C) 2009 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 AVC_DECODER_H_ 18 19#define AVC_DECODER_H_ 20 21#include <media/stagefright/MediaBuffer.h> 22#include <media/stagefright/MediaSource.h> 23#include <utils/Vector.h> 24 25struct tagAVCHandle; 26 27namespace android { 28 29struct AVCDecoder : public MediaSource, 30 public MediaBufferObserver { 31 AVCDecoder(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 41 virtual void signalBufferReturned(MediaBuffer *buffer); 42 43protected: 44 virtual ~AVCDecoder(); 45 46private: 47 sp<MediaSource> mSource; 48 bool mStarted; 49 50 sp<MetaData> mFormat; 51 52 Vector<MediaBuffer *> mCodecSpecificData; 53 54 tagAVCHandle *mHandle; 55 Vector<MediaBuffer *> mFrames; 56 MediaBuffer *mInputBuffer; 57 58 int64_t mAnchorTimeUs; 59 int64_t mNumSamplesOutput; 60 int64_t mPendingSeekTimeUs; 61 MediaSource::ReadOptions::SeekMode mPendingSeekMode; 62 63 int64_t mTargetTimeUs; 64 65 void addCodecSpecificData(const uint8_t *data, size_t size); 66 67 static int32_t ActivateSPSWrapper( 68 void *userData, unsigned int sizeInMbs, unsigned int numBuffers); 69 70 static int32_t BindFrameWrapper( 71 void *userData, int32_t index, uint8_t **yuv); 72 73 static void UnbindFrame(void *userData, int32_t index); 74 75 int32_t activateSPS( 76 unsigned int sizeInMbs, unsigned int numBuffers); 77 78 int32_t bindFrame(int32_t index, uint8_t **yuv); 79 80 void releaseFrames(); 81 82 AVCDecoder(const AVCDecoder &); 83 AVCDecoder &operator=(const AVCDecoder &); 84}; 85 86} // namespace android 87 88#endif // AVC_DECODER_H_ 89