NuPlayerDecoder.h revision 1cd139824b2e6832f239cd27d8962d3239053c02
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_H_ 18 19#define NUPLAYER_DECODER_H_ 20 21#include "NuPlayer.h" 22 23#include <media/stagefright/foundation/AHandler.h> 24 25namespace android { 26 27struct ABuffer; 28struct MediaCodec; 29 30struct NuPlayer::Decoder : public AHandler { 31 Decoder(const sp<AMessage> ¬ify, 32 const sp<NativeWindowWrapper> &nativeWindow = NULL); 33 34 void configure(const sp<AMessage> &format); 35 void init(); 36 37 void signalFlush(); 38 void signalResume(); 39 void initiateShutdown(); 40 41 bool supportsSeamlessFormatChange(const sp<AMessage> &to) const; 42 43 enum { 44 kWhatFillThisBuffer = 'flTB', 45 kWhatDrainThisBuffer = 'drTB', 46 kWhatOutputFormatChanged = 'fmtC', 47 kWhatFlushCompleted = 'flsC', 48 kWhatShutdownCompleted = 'shDC', 49 kWhatEOS = 'eos ', 50 kWhatError = 'err ', 51 }; 52 53protected: 54 55 virtual ~Decoder(); 56 57 virtual void onMessageReceived(const sp<AMessage> &msg); 58 59private: 60 enum { 61 kWhatCodecNotify = 'cdcN', 62 kWhatConfigure = 'conf', 63 kWhatInputBufferFilled = 'inpF', 64 kWhatRenderBuffer = 'rndr', 65 kWhatFlush = 'flus', 66 kWhatShutdown = 'shuD', 67 }; 68 69 sp<AMessage> mNotify; 70 sp<NativeWindowWrapper> mNativeWindow; 71 72 sp<AMessage> mInputFormat; 73 sp<AMessage> mOutputFormat; 74 sp<MediaCodec> mCodec; 75 sp<ALooper> mCodecLooper; 76 sp<ALooper> mDecoderLooper; 77 78 Vector<sp<ABuffer> > mInputBuffers; 79 Vector<sp<ABuffer> > mOutputBuffers; 80 81 void handleError(int32_t err); 82 bool handleAnInputBuffer(); 83 bool handleAnOutputBuffer(); 84 85 void requestCodecNotification(); 86 bool isStaleReply(const sp<AMessage> &msg); 87 88 void onConfigure(const sp<AMessage> &format); 89 void onFlush(); 90 void onInputBufferFilled(const sp<AMessage> &msg); 91 void onRenderBuffer(const sp<AMessage> &msg); 92 void onShutdown(); 93 94 int32_t mBufferGeneration; 95 AString mComponentName; 96 97 bool supportsSeamlessAudioFormatChange(const sp<AMessage> &targetFormat) const; 98 99 DISALLOW_EVIL_CONSTRUCTORS(Decoder); 100}; 101 102} // namespace android 103 104#endif // NUPLAYER_DECODER_H_ 105