Wei Jia | bc2fb72 | 2014-07-08 16:37:57 -0700 | [diff] [blame] | 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 | |
Chong Zhang | 7137ec7 | 2014-11-12 16:41:05 -0800 | [diff] [blame] | 23 | #include "NuPlayerDecoderBase.h" |
Wei Jia | bc2fb72 | 2014-07-08 16:37:57 -0700 | [diff] [blame] | 24 | |
| 25 | namespace android { |
| 26 | |
Chong Zhang | 7137ec7 | 2014-11-12 16:41:05 -0800 | [diff] [blame] | 27 | struct NuPlayer::DecoderPassThrough : public DecoderBase { |
Wei Jia | c6cfd70 | 2014-11-11 16:33:20 -0800 | [diff] [blame] | 28 | DecoderPassThrough(const sp<AMessage> ¬ify, |
| 29 | const sp<Source> &source, |
| 30 | const sp<Renderer> &renderer); |
Wei Jia | bc2fb72 | 2014-07-08 16:37:57 -0700 | [diff] [blame] | 31 | |
Chong Zhang | 7137ec7 | 2014-11-12 16:41:05 -0800 | [diff] [blame] | 32 | virtual void getStats( |
| 33 | int64_t *mNumFramesTotal, |
| 34 | int64_t *mNumFramesDropped) const; |
Wei Jia | bc2fb72 | 2014-07-08 16:37:57 -0700 | [diff] [blame] | 35 | |
| 36 | protected: |
| 37 | |
| 38 | virtual ~DecoderPassThrough(); |
| 39 | |
| 40 | virtual void onMessageReceived(const sp<AMessage> &msg); |
| 41 | |
Chong Zhang | 7137ec7 | 2014-11-12 16:41:05 -0800 | [diff] [blame] | 42 | virtual void onConfigure(const sp<AMessage> &format); |
| 43 | virtual void onSetRenderer(const sp<Renderer> &renderer); |
| 44 | virtual void onGetInputBuffers(Vector<sp<ABuffer> > *dstBuffers); |
Chong Zhang | f8d7177 | 2014-11-26 15:08:34 -0800 | [diff] [blame] | 45 | virtual void onResume(bool notifyComplete); |
Chong Zhang | 66704af | 2015-03-03 19:32:35 -0800 | [diff] [blame^] | 46 | virtual void onFlush(); |
Chong Zhang | 7137ec7 | 2014-11-12 16:41:05 -0800 | [diff] [blame] | 47 | virtual void onShutdown(bool notifyComplete); |
| 48 | virtual void doRequestBuffers(); |
| 49 | |
Wei Jia | bc2fb72 | 2014-07-08 16:37:57 -0700 | [diff] [blame] | 50 | private: |
| 51 | enum { |
Wei Jia | bc2fb72 | 2014-07-08 16:37:57 -0700 | [diff] [blame] | 52 | kWhatBufferConsumed = 'bufC', |
Wei Jia | bc2fb72 | 2014-07-08 16:37:57 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
Wei Jia | c6cfd70 | 2014-11-11 16:33:20 -0800 | [diff] [blame] | 55 | sp<Source> mSource; |
| 56 | sp<Renderer> mRenderer; |
Wei Jia | c6cfd70 | 2014-11-11 16:33:20 -0800 | [diff] [blame] | 57 | int64_t mSkipRenderingUntilMediaTimeUs; |
Ronghua Wu | f182891 | 2014-12-01 15:33:36 -0800 | [diff] [blame] | 58 | bool mPaused; |
Wei Jia | c6cfd70 | 2014-11-11 16:33:20 -0800 | [diff] [blame] | 59 | |
Phil Burk | c5cc2e2 | 2014-09-09 20:08:39 -0700 | [diff] [blame] | 60 | bool mReachedEOS; |
Chong Zhang | 7137ec7 | 2014-11-12 16:41:05 -0800 | [diff] [blame] | 61 | |
| 62 | // Used by feedDecoderInputData to aggregate small buffers into |
| 63 | // one large buffer. |
| 64 | sp<ABuffer> mPendingAudioAccessUnit; |
| 65 | status_t mPendingAudioErr; |
| 66 | sp<ABuffer> mAggregateBuffer; |
| 67 | |
| 68 | // mPendingBuffersToDrain are only for debugging. It can be removed |
| 69 | // when the power investigation is done. |
Phil Burk | c5cc2e2 | 2014-09-09 20:08:39 -0700 | [diff] [blame] | 70 | size_t mPendingBuffersToDrain; |
| 71 | size_t mCachedBytes; |
Wei Jia | bc2fb72 | 2014-07-08 16:37:57 -0700 | [diff] [blame] | 72 | AString mComponentName; |
| 73 | |
Chong Zhang | 7137ec7 | 2014-11-12 16:41:05 -0800 | [diff] [blame] | 74 | bool isStaleReply(const sp<AMessage> &msg); |
Ronghua Wu | f182891 | 2014-12-01 15:33:36 -0800 | [diff] [blame] | 75 | bool isDoneFetching() const; |
Chong Zhang | 7137ec7 | 2014-11-12 16:41:05 -0800 | [diff] [blame] | 76 | |
| 77 | status_t dequeueAccessUnit(sp<ABuffer> *accessUnit); |
| 78 | sp<ABuffer> aggregateBuffer(const sp<ABuffer> &accessUnit); |
| 79 | status_t fetchInputData(sp<AMessage> &reply); |
Chong Zhang | 66704af | 2015-03-03 19:32:35 -0800 | [diff] [blame^] | 80 | void doFlush(bool notifyComplete); |
Chong Zhang | 7137ec7 | 2014-11-12 16:41:05 -0800 | [diff] [blame] | 81 | |
| 82 | void onInputBufferFetched(const sp<AMessage> &msg); |
| 83 | void onBufferConsumed(int32_t size); |
| 84 | |
Wei Jia | bc2fb72 | 2014-07-08 16:37:57 -0700 | [diff] [blame] | 85 | DISALLOW_EVIL_CONSTRUCTORS(DecoderPassThrough); |
| 86 | }; |
| 87 | |
| 88 | } // namespace android |
| 89 | |
| 90 | #endif // NUPLAYER_DECODER_PASS_THROUGH_H_ |