AVCDecoder.h revision b5ae1c8712ee74ae30a115b80ecde9990bdb9a9f
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 62 void addCodecSpecificData(const uint8_t *data, size_t size); 63 64 static int32_t ActivateSPSWrapper( 65 void *userData, unsigned int sizeInMbs, unsigned int numBuffers); 66 67 static int32_t BindFrameWrapper( 68 void *userData, int32_t index, uint8_t **yuv); 69 70 static void UnbindFrame(void *userData, int32_t index); 71 72 int32_t activateSPS( 73 unsigned int sizeInMbs, unsigned int numBuffers); 74 75 int32_t bindFrame(int32_t index, uint8_t **yuv); 76 77 void releaseFrames(); 78 79 AVCDecoder(const AVCDecoder &); 80 AVCDecoder &operator=(const AVCDecoder &); 81}; 82 83} // namespace android 84 85#endif // AVC_DECODER_H_ 86