blob: fb20257c7ec19cd1f53cdece9fd808554e5be34e [file] [log] [blame]
Wei Jiabc2fb722014-07-08 16:37:57 -07001/*
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
25namespace android {
26
27struct NuPlayer::DecoderPassThrough : public Decoder {
28 DecoderPassThrough(const sp<AMessage> &notify);
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
39protected:
40
41 virtual ~DecoderPassThrough();
42
43 virtual void onMessageReceived(const sp<AMessage> &msg);
44
45private:
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
Phil Burkc5cc2e22014-09-09 20:08:39 -070058 /** Returns true if a buffer was requested.
59 * Returns false if at EOS or cache already full.
60 */
61 bool requestABuffer();
Wei Jiabc2fb722014-07-08 16:37:57 -070062 bool isStaleReply(const sp<AMessage> &msg);
63
64 void onConfigure(const sp<AMessage> &format);
65 void onFlush();
66 void onInputBufferFilled(const sp<AMessage> &msg);
Chong Zhangde01afb2014-08-13 13:48:10 -070067 void onBufferConsumed(int32_t size);
Phil Burkc5cc2e22014-09-09 20:08:39 -070068 void requestMaxBuffers();
Wei Jiabc2fb722014-07-08 16:37:57 -070069 void onShutdown();
70
71 int32_t mBufferGeneration;
Phil Burkc5cc2e22014-09-09 20:08:39 -070072 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;
Wei Jiabc2fb722014-07-08 16:37:57 -070078 AString mComponentName;
79
80 DISALLOW_EVIL_CONSTRUCTORS(DecoderPassThrough);
81};
82
83} // namespace android
84
85#endif // NUPLAYER_DECODER_PASS_THROUGH_H_