blob: 7742d30da8f8af04baa50b38c0d938b92cef688c [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 {
Wei Jiac6cfd702014-11-11 16:33:20 -080028 DecoderPassThrough(const sp<AMessage> &notify,
29 const sp<Source> &source,
30 const sp<Renderer> &renderer);
Wei Jiabc2fb722014-07-08 16:37:57 -070031
32 virtual void configure(const sp<AMessage> &format);
33 virtual void init();
34
35 virtual void signalFlush();
36 virtual void signalResume();
37 virtual void initiateShutdown();
38
39 bool supportsSeamlessFormatChange(const sp<AMessage> &to) const;
40
41protected:
42
43 virtual ~DecoderPassThrough();
44
45 virtual void onMessageReceived(const sp<AMessage> &msg);
46
47private:
48 enum {
49 kWhatRequestABuffer = 'reqB',
Wei Jiabc2fb722014-07-08 16:37:57 -070050 kWhatBufferConsumed = 'bufC',
Wei Jiabc2fb722014-07-08 16:37:57 -070051 };
52
53 sp<AMessage> mNotify;
54 sp<ALooper> mDecoderLooper;
55
Wei Jiac6cfd702014-11-11 16:33:20 -080056 sp<Source> mSource;
57 sp<Renderer> mRenderer;
58
Phil Burkc5cc2e22014-09-09 20:08:39 -070059 /** Returns true if a buffer was requested.
60 * Returns false if at EOS or cache already full.
61 */
62 bool requestABuffer();
Wei Jiabc2fb722014-07-08 16:37:57 -070063 bool isStaleReply(const sp<AMessage> &msg);
64
65 void onConfigure(const sp<AMessage> &format);
66 void onFlush();
67 void onInputBufferFilled(const sp<AMessage> &msg);
Chong Zhangde01afb2014-08-13 13:48:10 -070068 void onBufferConsumed(int32_t size);
Phil Burkc5cc2e22014-09-09 20:08:39 -070069 void requestMaxBuffers();
Wei Jiabc2fb722014-07-08 16:37:57 -070070 void onShutdown();
71
Wei Jiac6cfd702014-11-11 16:33:20 -080072 int64_t mSkipRenderingUntilMediaTimeUs;
73
Wei Jiabc2fb722014-07-08 16:37:57 -070074 int32_t mBufferGeneration;
Phil Burkc5cc2e22014-09-09 20:08:39 -070075 bool mReachedEOS;
76 // TODO mPendingBuffersToFill and mPendingBuffersToDrain are only for
77 // debugging. They can be removed when the power investigation is done.
78 size_t mPendingBuffersToFill;
79 size_t mPendingBuffersToDrain;
80 size_t mCachedBytes;
Wei Jiabc2fb722014-07-08 16:37:57 -070081 AString mComponentName;
82
83 DISALLOW_EVIL_CONSTRUCTORS(DecoderPassThrough);
84};
85
86} // namespace android
87
88#endif // NUPLAYER_DECODER_PASS_THROUGH_H_