1 /* 2 * Copyright (C) 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_PASS_THROUGH_H_ 18 19 #define NUPLAYER_DECODER_PASS_THROUGH_H_ 20 21 #include "NuPlayer.h" 22 23 #include "NuPlayerDecoder.h" 24 25 namespace android { 26 27 struct NuPlayer::DecoderPassThrough : public Decoder { 28 DecoderPassThrough(const sp<AMessage> ¬ify); 29 30 virtual void configure(const sp<AMessage> &format); 31 virtual void init(); 32 33 virtual void signalFlush(); 34 virtual void signalResume(); 35 virtual void initiateShutdown(); 36 37 bool supportsSeamlessFormatChange(const sp<AMessage> &to) const; 38 39 protected: 40 41 virtual ~DecoderPassThrough(); 42 43 virtual void onMessageReceived(const sp<AMessage> &msg); 44 45 private: 46 enum { 47 kWhatRequestABuffer = 'reqB', 48 kWhatConfigure = 'conf', 49 kWhatInputBufferFilled = 'inpF', 50 kWhatBufferConsumed = 'bufC', 51 kWhatFlush = 'flus', 52 kWhatShutdown = 'shuD', 53 }; 54 55 sp<AMessage> mNotify; 56 sp<ALooper> mDecoderLooper; 57 58 /** Returns true if a buffer was requested. 59 * Returns false if at EOS or cache already full. 60 */ 61 bool requestABuffer(); 62 bool isStaleReply(const sp<AMessage> &msg); 63 64 void onConfigure(const sp<AMessage> &format); 65 void onFlush(); 66 void onInputBufferFilled(const sp<AMessage> &msg); 67 void onBufferConsumed(int32_t size); 68 void requestMaxBuffers(); 69 void onShutdown(); 70 71 int32_t mBufferGeneration; 72 bool mReachedEOS; 73 // TODO mPendingBuffersToFill and mPendingBuffersToDrain are only for 74 // debugging. They can be removed when the power investigation is done. 75 size_t mPendingBuffersToFill; 76 size_t mPendingBuffersToDrain; 77 size_t mCachedBytes; 78 AString mComponentName; 79 80 DISALLOW_EVIL_CONSTRUCTORS(DecoderPassThrough); 81 }; 82 83 } // namespace android 84 85 #endif // NUPLAYER_DECODER_PASS_THROUGH_H_ 86