Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -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 DASHPLAYER_DECODER_H_ |
| 18 | |
| 19 | #define DASHPLAYER_DECODER_H_ |
| 20 | |
| 21 | #include "DashPlayerRenderer.h" |
| 22 | #include "DashPlayer.h" |
Mahesh Lanka | 4d0ff4e | 2014-07-21 22:35:33 +0530 | [diff] [blame] | 23 | #include <media/stagefright/foundation/AHandler.h> |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | struct ABuffer; |
Mahesh Lanka | 4d0ff4e | 2014-07-21 22:35:33 +0530 | [diff] [blame] | 28 | struct MediaCodec; |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 29 | |
| 30 | struct DashPlayer::Decoder : public AHandler { |
| 31 | Decoder(const sp<AMessage> ¬ify, |
Manikanta Sivapala | 672cd8f | 2015-08-05 19:12:15 +0530 | [diff] [blame] | 32 | const sp<Surface> &nativeWindow = NULL); |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 33 | |
| 34 | void configure(const sp<MetaData> &meta); |
Mahesh Lanka | 4d0ff4e | 2014-07-21 22:35:33 +0530 | [diff] [blame] | 35 | void init(); |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 36 | |
| 37 | void signalFlush(); |
| 38 | void signalResume(); |
| 39 | void initiateShutdown(); |
Mahesh Lanka | 4d0ff4e | 2014-07-21 22:35:33 +0530 | [diff] [blame] | 40 | |
Mahesh Lanka | 4d0ff4e | 2014-07-21 22:35:33 +0530 | [diff] [blame] | 41 | |
| 42 | enum { |
| 43 | kWhatFillThisBuffer = 'flTB', |
| 44 | kWhatDrainThisBuffer = 'drTB', |
| 45 | kWhatOutputFormatChanged = 'fmtC', |
| 46 | kWhatFlushCompleted = 'flsC', |
| 47 | kWhatShutdownCompleted = 'shDC', |
| 48 | kWhatEOS = 'eos ', |
| 49 | kWhatError = 'err ', |
| 50 | }; |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 51 | |
| 52 | protected: |
| 53 | virtual ~Decoder(); |
| 54 | |
| 55 | virtual void onMessageReceived(const sp<AMessage> &msg); |
| 56 | |
| 57 | private: |
| 58 | enum { |
| 59 | kWhatCodecNotify = 'cdcN', |
Mahesh Lanka | 4d0ff4e | 2014-07-21 22:35:33 +0530 | [diff] [blame] | 60 | kWhatConfigure = 'conf', |
| 61 | kWhatInputBufferFilled = 'inpF', |
| 62 | kWhatRenderBuffer = 'rndr', |
| 63 | kWhatFlush = 'flus', |
| 64 | kWhatShutdown = 'shuD', |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | sp<AMessage> mNotify; |
Manikanta Sivapala | 672cd8f | 2015-08-05 19:12:15 +0530 | [diff] [blame] | 68 | sp<Surface> mNativeWindow; |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 69 | |
Mahesh Lanka | 4d0ff4e | 2014-07-21 22:35:33 +0530 | [diff] [blame] | 70 | sp<AMessage> mInputFormat; |
| 71 | sp<AMessage> mOutputFormat; |
| 72 | sp<MediaCodec> mCodec; |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 73 | sp<ALooper> mCodecLooper; |
Mahesh Lanka | 4d0ff4e | 2014-07-21 22:35:33 +0530 | [diff] [blame] | 74 | sp<ALooper> mDecoderLooper; |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 75 | |
Mahesh Lanka | 4d0ff4e | 2014-07-21 22:35:33 +0530 | [diff] [blame] | 76 | Vector<sp<ABuffer> > mInputBuffers; |
| 77 | Vector<sp<ABuffer> > mOutputBuffers; |
| 78 | |
| 79 | void handleError(int32_t err); |
| 80 | bool handleAnInputBuffer(); |
| 81 | bool handleAnOutputBuffer(); |
| 82 | |
| 83 | void requestCodecNotification(); |
| 84 | bool isStaleReply(const sp<AMessage> &msg); |
| 85 | |
Manikanta Sivapala | 29760d6 | 2015-08-05 14:37:03 +0530 | [diff] [blame] | 86 | int mLogLevel; |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 87 | |
| 88 | sp<AMessage> makeFormat(const sp<MetaData> &meta); |
| 89 | |
Mahesh Lanka | 4d0ff4e | 2014-07-21 22:35:33 +0530 | [diff] [blame] | 90 | void onConfigure(const sp<AMessage> &format); |
| 91 | void onFlush(); |
| 92 | void onInputBufferFilled(const sp<AMessage> &msg); |
| 93 | void onRenderBuffer(const sp<AMessage> &msg); |
| 94 | void onShutdown(); |
| 95 | |
| 96 | int32_t mBufferGeneration; |
| 97 | AString mComponentName; |
| 98 | |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 99 | |
| 100 | DISALLOW_EVIL_CONSTRUCTORS(Decoder); |
| 101 | }; |
| 102 | |
| 103 | } // namespace android |
| 104 | |
| 105 | #endif // DASHPLAYER_DECODER_H_ |