blob: db33e87ad85d496479e5ae8c01cf5c7145ab4798 [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
Chong Zhang7137ec72014-11-12 16:41:05 -080023#include "NuPlayerDecoderBase.h"
Wei Jiabc2fb722014-07-08 16:37:57 -070024
25namespace android {
26
Chong Zhang7137ec72014-11-12 16:41:05 -080027struct NuPlayer::DecoderPassThrough : public DecoderBase {
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
Wei Jiabc2fb722014-07-08 16:37:57 -070032protected:
33
34 virtual ~DecoderPassThrough();
35
36 virtual void onMessageReceived(const sp<AMessage> &msg);
37
Chong Zhang7137ec72014-11-12 16:41:05 -080038 virtual void onConfigure(const sp<AMessage> &format);
Ronghua Wu8db88132015-04-22 13:51:35 -070039 virtual void onSetParameters(const sp<AMessage> &params);
Chong Zhang7137ec72014-11-12 16:41:05 -080040 virtual void onSetRenderer(const sp<Renderer> &renderer);
41 virtual void onGetInputBuffers(Vector<sp<ABuffer> > *dstBuffers);
Chong Zhangf8d71772014-11-26 15:08:34 -080042 virtual void onResume(bool notifyComplete);
Chong Zhang66704af2015-03-03 19:32:35 -080043 virtual void onFlush();
Chong Zhang7137ec72014-11-12 16:41:05 -080044 virtual void onShutdown(bool notifyComplete);
Chong Zhang3b032b32015-04-17 15:49:06 -070045 virtual bool doRequestBuffers();
Chong Zhang7137ec72014-11-12 16:41:05 -080046
Wei Jiabc2fb722014-07-08 16:37:57 -070047private:
48 enum {
Wei Jiabc2fb722014-07-08 16:37:57 -070049 kWhatBufferConsumed = 'bufC',
Wei Jiabc2fb722014-07-08 16:37:57 -070050 };
51
Wei Jiac6cfd702014-11-11 16:33:20 -080052 sp<Source> mSource;
53 sp<Renderer> mRenderer;
Wei Jiac6cfd702014-11-11 16:33:20 -080054 int64_t mSkipRenderingUntilMediaTimeUs;
Ronghua Wuf1828912014-12-01 15:33:36 -080055 bool mPaused;
Wei Jiac6cfd702014-11-11 16:33:20 -080056
Phil Burkc5cc2e22014-09-09 20:08:39 -070057 bool mReachedEOS;
Chong Zhang7137ec72014-11-12 16:41:05 -080058
59 // Used by feedDecoderInputData to aggregate small buffers into
60 // one large buffer.
61 sp<ABuffer> mPendingAudioAccessUnit;
62 status_t mPendingAudioErr;
63 sp<ABuffer> mAggregateBuffer;
64
65 // mPendingBuffersToDrain are only for debugging. It can be removed
66 // when the power investigation is done.
Phil Burkc5cc2e22014-09-09 20:08:39 -070067 size_t mPendingBuffersToDrain;
68 size_t mCachedBytes;
Wei Jiabc2fb722014-07-08 16:37:57 -070069 AString mComponentName;
70
Chong Zhang7137ec72014-11-12 16:41:05 -080071 bool isStaleReply(const sp<AMessage> &msg);
Ronghua Wuf1828912014-12-01 15:33:36 -080072 bool isDoneFetching() const;
Chong Zhang7137ec72014-11-12 16:41:05 -080073
74 status_t dequeueAccessUnit(sp<ABuffer> *accessUnit);
75 sp<ABuffer> aggregateBuffer(const sp<ABuffer> &accessUnit);
76 status_t fetchInputData(sp<AMessage> &reply);
Chong Zhang66704af2015-03-03 19:32:35 -080077 void doFlush(bool notifyComplete);
Chong Zhang7137ec72014-11-12 16:41:05 -080078
79 void onInputBufferFetched(const sp<AMessage> &msg);
80 void onBufferConsumed(int32_t size);
81
Wei Jiabc2fb722014-07-08 16:37:57 -070082 DISALLOW_EVIL_CONSTRUCTORS(DecoderPassThrough);
83};
84
85} // namespace android
86
87#endif // NUPLAYER_DECODER_PASS_THROUGH_H_