NuPlayerDecoderPassThrough.h revision f1828910d48bbd22e1392e6ab0ce31298d1f115c
1/*
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 "NuPlayerDecoderBase.h"
24
25namespace android {
26
27struct NuPlayer::DecoderPassThrough : public DecoderBase {
28    DecoderPassThrough(const sp<AMessage> &notify,
29                       const sp<Source> &source,
30                       const sp<Renderer> &renderer);
31
32    virtual void getStats(
33            int64_t *mNumFramesTotal,
34            int64_t *mNumFramesDropped) const;
35
36protected:
37
38    virtual ~DecoderPassThrough();
39
40    virtual void onMessageReceived(const sp<AMessage> &msg);
41
42    virtual void onConfigure(const sp<AMessage> &format);
43    virtual void onSetRenderer(const sp<Renderer> &renderer);
44    virtual void onGetInputBuffers(Vector<sp<ABuffer> > *dstBuffers);
45    virtual void onResume(bool notifyComplete);
46    virtual void onFlush(bool notifyComplete);
47    virtual void onShutdown(bool notifyComplete);
48    virtual void doRequestBuffers();
49
50private:
51    enum {
52        kWhatBufferConsumed     = 'bufC',
53    };
54
55    sp<AMessage> mNotify;
56    sp<Source> mSource;
57    sp<Renderer> mRenderer;
58    int64_t mSkipRenderingUntilMediaTimeUs;
59    bool mPaused;
60
61    int32_t mBufferGeneration;
62    bool    mReachedEOS;
63
64    // Used by feedDecoderInputData to aggregate small buffers into
65    // one large buffer.
66    sp<ABuffer> mPendingAudioAccessUnit;
67    status_t    mPendingAudioErr;
68    sp<ABuffer> mAggregateBuffer;
69
70    // mPendingBuffersToDrain are only for debugging. It can be removed
71    // when the power investigation is done.
72    size_t  mPendingBuffersToDrain;
73    size_t  mCachedBytes;
74    AString mComponentName;
75
76    bool isStaleReply(const sp<AMessage> &msg);
77    bool isDoneFetching() const;
78
79    status_t dequeueAccessUnit(sp<ABuffer> *accessUnit);
80    sp<ABuffer> aggregateBuffer(const sp<ABuffer> &accessUnit);
81    status_t fetchInputData(sp<AMessage> &reply);
82
83    void onInputBufferFetched(const sp<AMessage> &msg);
84    void onBufferConsumed(int32_t size);
85
86    DISALLOW_EVIL_CONSTRUCTORS(DecoderPassThrough);
87};
88
89}  // namespace android
90
91#endif  // NUPLAYER_DECODER_PASS_THROUGH_H_
92