Andreas Huber | a158746 | 2010-12-15 15:17:42 -0800 | [diff] [blame] | 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 DECODER_WRAPPER_H_ |
| 18 | |
| 19 | #define DECODER_WRAPPER_H_ |
| 20 | |
| 21 | #include <media/stagefright/foundation/AHandler.h> |
| 22 | |
| 23 | namespace android { |
| 24 | |
| 25 | struct MediaSource; |
| 26 | |
| 27 | struct DecoderWrapper : public AHandler { |
| 28 | DecoderWrapper(); |
| 29 | |
| 30 | void setNotificationMessage(const sp<AMessage> &msg); |
| 31 | void initiateSetup(const sp<AMessage> &msg); |
| 32 | void initiateShutdown(); |
| 33 | void signalFlush(); |
| 34 | void signalResume(); |
| 35 | |
| 36 | protected: |
| 37 | virtual ~DecoderWrapper(); |
| 38 | |
| 39 | virtual void onMessageReceived(const sp<AMessage> &msg); |
| 40 | |
| 41 | private: |
| 42 | struct WrapperSource; |
| 43 | struct WrapperReader; |
| 44 | |
| 45 | enum { |
| 46 | kWhatSetup, |
| 47 | kWhatInputBufferFilled, |
| 48 | kWhatOutputBufferDrained, |
| 49 | kWhatShutdown, |
| 50 | kWhatFillBufferDone, |
| 51 | kWhatInputDataRequested, |
| 52 | kWhatFlush, |
| 53 | kWhatResume, |
| 54 | }; |
| 55 | |
| 56 | sp<AMessage> mNotify; |
| 57 | |
| 58 | sp<WrapperSource> mSource; |
| 59 | |
| 60 | sp<ALooper> mReaderLooper; |
| 61 | sp<WrapperReader> mReader; |
| 62 | |
| 63 | int32_t mNumOutstandingInputBuffers; |
| 64 | int32_t mNumOutstandingOutputBuffers; |
| 65 | int32_t mNumPendingDecodes; |
| 66 | bool mFlushing; |
| 67 | |
| 68 | void onSetup(const sp<AMessage> &msg); |
Andreas Huber | 41c3f74 | 2010-12-21 10:22:33 -0800 | [diff] [blame] | 69 | void onShutdown(); |
Andreas Huber | a158746 | 2010-12-15 15:17:42 -0800 | [diff] [blame] | 70 | void onFlush(); |
| 71 | void onResume(); |
| 72 | |
| 73 | void postFillBuffer(); |
| 74 | void completeFlushIfPossible(); |
| 75 | |
| 76 | DISALLOW_EVIL_CONSTRUCTORS(DecoderWrapper); |
| 77 | }; |
| 78 | |
| 79 | } // namespace android |
| 80 | |
| 81 | #endif // DECODER_WRAPPER_H_ |
| 82 | |