NuPlayerDecoderBase.h revision 8db8813d39e3c8b5fbd580dfc3062830744afd63
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 NUPLAYER_DECODER_BASE_H_ 18 19#define NUPLAYER_DECODER_BASE_H_ 20 21#include "NuPlayer.h" 22 23#include <media/stagefright/foundation/AHandler.h> 24 25namespace android { 26 27struct ABuffer; 28struct MediaCodec; 29class MediaBuffer; 30 31struct NuPlayer::DecoderBase : public AHandler { 32 DecoderBase(const sp<AMessage> ¬ify); 33 34 void configure(const sp<AMessage> &format); 35 void init(); 36 void setParameters(const sp<AMessage> ¶ms); 37 38 void setRenderer(const sp<Renderer> &renderer); 39 40 status_t getInputBuffers(Vector<sp<ABuffer> > *dstBuffers) const; 41 void signalFlush(); 42 void signalResume(bool notifyComplete); 43 void initiateShutdown(); 44 45 virtual void getStats( 46 int64_t *mNumFramesTotal, 47 int64_t *mNumFramesDropped) const = 0; 48 49 enum { 50 kWhatInputDiscontinuity = 'inDi', 51 kWhatVideoSizeChanged = 'viSC', 52 kWhatFlushCompleted = 'flsC', 53 kWhatShutdownCompleted = 'shDC', 54 kWhatResumeCompleted = 'resC', 55 kWhatEOS = 'eos ', 56 kWhatError = 'err ', 57 }; 58 59protected: 60 61 virtual ~DecoderBase(); 62 63 virtual void onMessageReceived(const sp<AMessage> &msg); 64 65 virtual void onConfigure(const sp<AMessage> &format) = 0; 66 virtual void onSetParameters(const sp<AMessage> ¶ms) = 0; 67 virtual void onSetRenderer(const sp<Renderer> &renderer) = 0; 68 virtual void onGetInputBuffers(Vector<sp<ABuffer> > *dstBuffers) = 0; 69 virtual void onResume(bool notifyComplete) = 0; 70 virtual void onFlush() = 0; 71 virtual void onShutdown(bool notifyComplete) = 0; 72 73 void onRequestInputBuffers(); 74 virtual bool doRequestBuffers() = 0; 75 virtual void handleError(int32_t err); 76 77 sp<AMessage> mNotify; 78 int32_t mBufferGeneration; 79 80private: 81 enum { 82 kWhatConfigure = 'conf', 83 kWhatSetParameters = 'setP', 84 kWhatSetRenderer = 'setR', 85 kWhatGetInputBuffers = 'gInB', 86 kWhatRequestInputBuffers = 'reqB', 87 kWhatFlush = 'flus', 88 kWhatShutdown = 'shuD', 89 }; 90 91 sp<ALooper> mDecoderLooper; 92 bool mRequestInputBuffersPending; 93 94 DISALLOW_EVIL_CONSTRUCTORS(DecoderBase); 95}; 96 97} // namespace android 98 99#endif // NUPLAYER_DECODER_BASE_H_ 100