Home | History | Annotate | Download | only in nuplayer
      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     bool mPaused;
     56 
     57     bool    mReachedEOS;
     58 
     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.
     67     size_t  mPendingBuffersToDrain;
     68     size_t  mCachedBytes;
     69     AString mComponentName;
     70 
     71     bool isStaleReply(const sp<AMessage> &msg);
     72     bool isDoneFetching() const;
     73 
     74     status_t dequeueAccessUnit(sp<ABuffer> *accessUnit);
     75     sp<ABuffer> aggregateBuffer(const sp<ABuffer> &accessUnit);
     76     status_t fetchInputData(sp<AMessage> &reply);
     77     void doFlush(bool notifyComplete);
     78 
     79     void onInputBufferFetched(const sp<AMessage> &msg);
     80     void onBufferConsumed(int32_t size);
     81 
     82     DISALLOW_EVIL_CONSTRUCTORS(DecoderPassThrough);
     83 };
     84 
     85 }  // namespace android
     86 
     87 #endif  // NUPLAYER_DECODER_PASS_THROUGH_H_
     88