/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef NUPLAYER_DECODER_BASE_H_ #define NUPLAYER_DECODER_BASE_H_ #include "NuPlayer.h" #include namespace android { struct ABuffer; struct MediaCodec; class MediaBuffer; class Surface; struct NuPlayer::DecoderBase : public AHandler { DecoderBase(const sp ¬ify); void configure(const sp &format); void init(); void setParameters(const sp ¶ms); // Synchronous call to ensure decoder will not request or send out data. void pause(); void setRenderer(const sp &renderer); virtual status_t setVideoSurface(const sp &) { return INVALID_OPERATION; } status_t getInputBuffers(Vector > *dstBuffers) const; void signalFlush(); void signalResume(bool notifyComplete); void initiateShutdown(); virtual sp getStats() const { return mStats; } enum { kWhatInputDiscontinuity = 'inDi', kWhatVideoSizeChanged = 'viSC', kWhatFlushCompleted = 'flsC', kWhatShutdownCompleted = 'shDC', kWhatResumeCompleted = 'resC', kWhatEOS = 'eos ', kWhatError = 'err ', }; protected: virtual ~DecoderBase(); virtual void onMessageReceived(const sp &msg); virtual void onConfigure(const sp &format) = 0; virtual void onSetParameters(const sp ¶ms) = 0; virtual void onSetRenderer(const sp &renderer) = 0; virtual void onGetInputBuffers(Vector > *dstBuffers) = 0; virtual void onResume(bool notifyComplete) = 0; virtual void onFlush() = 0; virtual void onShutdown(bool notifyComplete) = 0; void onRequestInputBuffers(); virtual bool doRequestBuffers() = 0; virtual void handleError(int32_t err); sp mNotify; int32_t mBufferGeneration; bool mPaused; sp mStats; private: enum { kWhatConfigure = 'conf', kWhatSetParameters = 'setP', kWhatSetRenderer = 'setR', kWhatPause = 'paus', kWhatGetInputBuffers = 'gInB', kWhatRequestInputBuffers = 'reqB', kWhatFlush = 'flus', kWhatShutdown = 'shuD', }; sp mDecoderLooper; bool mRequestInputBuffersPending; DISALLOW_EVIL_CONSTRUCTORS(DecoderBase); }; } // namespace android #endif // NUPLAYER_DECODER_BASE_H_