NuPlayerDecoder.h revision 66704af4d82c2b6303609b29402641f861fdcb19
1/* 2 * Copyright 2014 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#define NUPLAYER_DECODER_H_ 19 20#include "NuPlayer.h" 21 22#include "NuPlayerDecoderBase.h" 23 24namespace android { 25 26struct NuPlayer::Decoder : public DecoderBase { 27 Decoder(const sp<AMessage> ¬ify, 28 const sp<Source> &source, 29 const sp<Renderer> &renderer = NULL, 30 const sp<NativeWindowWrapper> &nativeWindow = NULL, 31 const sp<CCDecoder> &ccDecoder = NULL); 32 33 virtual void getStats( 34 int64_t *mNumFramesTotal, 35 int64_t *mNumFramesDropped) const; 36 37protected: 38 virtual ~Decoder(); 39 40 virtual void onMessageReceived(const sp<AMessage> &msg); 41 42 virtual void onConfigure(const sp<AMessage> &format); 43 virtual void onSetRenderer(const sp<Renderer> &renderer); 44 virtual void onGetInputBuffers(Vector<sp<ABuffer> > *dstBuffers); 45 virtual void onResume(bool notifyComplete); 46 virtual void onFlush(); 47 virtual void onShutdown(bool notifyComplete); 48 virtual void doRequestBuffers(); 49 50private: 51 enum { 52 kWhatCodecNotify = 'cdcN', 53 kWhatRenderBuffer = 'rndr', 54 }; 55 56 sp<NativeWindowWrapper> mNativeWindow; 57 58 sp<Source> mSource; 59 sp<Renderer> mRenderer; 60 sp<CCDecoder> mCCDecoder; 61 62 sp<AMessage> mInputFormat; 63 sp<AMessage> mOutputFormat; 64 sp<MediaCodec> mCodec; 65 sp<ALooper> mCodecLooper; 66 67 List<sp<AMessage> > mPendingInputMessages; 68 69 Vector<sp<ABuffer> > mInputBuffers; 70 Vector<sp<ABuffer> > mOutputBuffers; 71 Vector<sp<ABuffer> > mCSDsForCurrentFormat; 72 Vector<sp<ABuffer> > mCSDsToSubmit; 73 Vector<bool> mInputBufferIsDequeued; 74 Vector<MediaBuffer *> mMediaBuffers; 75 Vector<size_t> mDequeuedInputBuffers; 76 77 int64_t mSkipRenderingUntilMediaTimeUs; 78 int64_t mNumFramesTotal; 79 int64_t mNumFramesDropped; 80 bool mIsAudio; 81 bool mIsVideoAVC; 82 bool mIsSecure; 83 bool mFormatChangePending; 84 bool mTimeChangePending; 85 86 bool mPaused; 87 bool mResumePending; 88 AString mComponentName; 89 90 bool handleAnInputBuffer(); 91 bool handleAnOutputBuffer(); 92 93 void releaseAndResetMediaBuffers(); 94 void requestCodecNotification(); 95 bool isStaleReply(const sp<AMessage> &msg); 96 97 void doFlush(bool notifyComplete); 98 status_t fetchInputData(sp<AMessage> &reply); 99 bool onInputBufferFetched(const sp<AMessage> &msg); 100 void onRenderBuffer(const sp<AMessage> &msg); 101 102 bool supportsSeamlessFormatChange(const sp<AMessage> &to) const; 103 bool supportsSeamlessAudioFormatChange(const sp<AMessage> &targetFormat) const; 104 void rememberCodecSpecificData(const sp<AMessage> &format); 105 bool isDiscontinuityPending() const; 106 void finishHandleDiscontinuity(bool flushOnTimeChange); 107 108 void notifyResumeCompleteIfNecessary(); 109 110 DISALLOW_EVIL_CONSTRUCTORS(Decoder); 111}; 112 113} // namespace android 114 115#endif // NUPLAYER_DECODER_H_ 116