• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
25 namespace android {
26 
27 struct NuPlayer::DecoderPassThrough : public DecoderBase {
28     DecoderPassThrough(const sp<AMessage> &notify,
29                        const sp<Source> &source,
30                        const sp<Renderer> &renderer);
31 
32 protected:
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 onGetInputBuffers(Vector<sp<ABuffer> > *dstBuffers);
42     virtual void onResume(bool notifyComplete);
43     virtual void onFlush();
44     virtual void onShutdown(bool notifyComplete);
45     virtual bool doRequestBuffers();
46 
47 private:
48     enum {
49         kWhatBufferConsumed     = 'bufC',
50     };
51 
52     sp<Source> mSource;
53     sp<Renderer> mRenderer;
54     int64_t mSkipRenderingUntilMediaTimeUs;
55 
56     bool    mReachedEOS;
57 
58     // Used by feedDecoderInputData to aggregate small buffers into
59     // one large buffer.
60     sp<ABuffer> mPendingAudioAccessUnit;
61     status_t    mPendingAudioErr;
62     sp<ABuffer> mAggregateBuffer;
63 
64     // mPendingBuffersToDrain are only for debugging. It can be removed
65     // when the power investigation is done.
66     size_t  mPendingBuffersToDrain;
67     size_t  mCachedBytes;
68     AString mComponentName;
69 
70     bool isStaleReply(const sp<AMessage> &msg);
71     bool isDoneFetching() const;
72 
73     status_t dequeueAccessUnit(sp<ABuffer> *accessUnit);
74     sp<ABuffer> aggregateBuffer(const sp<ABuffer> &accessUnit);
75     status_t fetchInputData(sp<AMessage> &reply);
76     void doFlush(bool notifyComplete);
77 
78     void onInputBufferFetched(const sp<AMessage> &msg);
79     void onBufferConsumed(int32_t size);
80 
81     DISALLOW_EVIL_CONSTRUCTORS(DecoderPassThrough);
82 };
83 
84 }  // namespace android
85 
86 #endif  // NUPLAYER_DECODER_PASS_THROUGH_H_
87