blob: 838c60a43a151036e4203c4b7130de592710f33a [file] [log] [blame]
Wei Jia53692fa2017-12-11 10:33:46 -08001/*
2 * Copyright 2017 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 NUPLAYER2_DECODER_PASS_THROUGH_H_
18
19#define NUPLAYER2_DECODER_PASS_THROUGH_H_
20
21#include "NuPlayer2.h"
22
23#include "NuPlayer2DecoderBase.h"
24
25namespace android {
26
27struct NuPlayer2::DecoderPassThrough : public DecoderBase {
28 DecoderPassThrough(const sp<AMessage> &notify,
29 const sp<Source> &source,
30 const sp<Renderer> &renderer);
31
32protected:
33
34 virtual ~DecoderPassThrough();
35
36 virtual void onMessageReceived(const sp<AMessage> &msg);
37
38 virtual void onConfigure(const sp<AMessage> &format);
39 virtual void onSetParameters(const sp<AMessage> &params);
40 virtual void onSetRenderer(const sp<Renderer> &renderer);
41 virtual void onResume(bool notifyComplete);
42 virtual void onFlush();
43 virtual void onShutdown(bool notifyComplete);
44 virtual bool doRequestBuffers();
45
46private:
47 enum {
48 kWhatBufferConsumed = 'bufC',
49 };
50
51 sp<Source> mSource;
52 sp<Renderer> mRenderer;
53 int64_t mSkipRenderingUntilMediaTimeUs;
54
55 bool mReachedEOS;
56
57 // Used by feedDecoderInputData to aggregate small buffers into
58 // one large buffer.
59 sp<ABuffer> mPendingAudioAccessUnit;
60 status_t mPendingAudioErr;
61 sp<ABuffer> mAggregateBuffer;
62
63 // mPendingBuffersToDrain are only for debugging. It can be removed
64 // when the power investigation is done.
65 size_t mPendingBuffersToDrain;
66 size_t mCachedBytes;
67 AString mComponentName;
68
69 bool isStaleReply(const sp<AMessage> &msg);
70 bool isDoneFetching() const;
71
72 status_t dequeueAccessUnit(sp<ABuffer> *accessUnit);
73 sp<ABuffer> aggregateBuffer(const sp<ABuffer> &accessUnit);
74 status_t fetchInputData(sp<AMessage> &reply);
75 void doFlush(bool notifyComplete);
76
77 void onInputBufferFetched(const sp<AMessage> &msg);
78 void onBufferConsumed(int32_t size);
79
80 DISALLOW_EVIL_CONSTRUCTORS(DecoderPassThrough);
81};
82
83} // namespace android
84
85#endif // NUPLAYER2_DECODER_PASS_THROUGH_H_