NuPlayer.h revision 3831a066bcf1019864a94d2bc7b4c9241efc5c22
1/* 2 * Copyright (C) 2010 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 NU_PLAYER_H_ 18 19#define NU_PLAYER_H_ 20 21#include <media/MediaPlayerInterface.h> 22#include <media/stagefright/foundation/AHandler.h> 23 24#include "ATSParser.h" 25#include "AnotherPacketSource.h" 26 27namespace android { 28 29struct ACodec; 30struct MetaData; 31 32struct NuPlayer : public AHandler { 33 NuPlayer(); 34 35 void setListener(const wp<MediaPlayerBase> &listener); 36 37 void setDataSource(const sp<IStreamSource> &source); 38 void setVideoSurface(const sp<Surface> &surface); 39 void setAudioSink(const sp<MediaPlayerBase::AudioSink> &sink); 40 void start(); 41 42protected: 43 virtual ~NuPlayer(); 44 45 virtual void onMessageReceived(const sp<AMessage> &msg); 46 47private: 48 struct Renderer; 49 struct Decoder; 50 struct NuPlayerStreamListener; 51 52 enum { 53 kWhatSetDataSource, 54 kWhatSetVideoSurface, 55 kWhatSetAudioSink, 56 kWhatMoreDataQueued, 57 kWhatStart, 58 kWhatScanSources, 59 kWhatVideoNotify, 60 kWhatAudioNotify, 61 kWhatRendererNotify, 62 }; 63 64 wp<MediaPlayerBase> mListener; 65 sp<IStreamSource> mSource; 66 sp<Surface> mSurface; 67 sp<MediaPlayerBase::AudioSink> mAudioSink; 68 sp<NuPlayerStreamListener> mStreamListener; 69 sp<ATSParser> mTSParser; 70 sp<Decoder> mVideoDecoder; 71 sp<Decoder> mAudioDecoder; 72 sp<Renderer> mRenderer; 73 74 bool mEOS; 75 bool mAudioEOS; 76 bool mVideoEOS; 77 78 enum FlushStatus { 79 NONE, 80 AWAITING_DISCONTINUITY, 81 FLUSHING_DECODER, 82 SHUTTING_DOWN_DECODER, 83 FLUSHED, 84 SHUT_DOWN, 85 }; 86 87 FlushStatus mFlushingAudio; 88 FlushStatus mFlushingVideo; 89 90 status_t instantiateDecoder( 91 bool audio, sp<Decoder> *decoder, bool ignoreCodecSpecificData); 92 93 status_t feedDecoderInputData(bool audio, const sp<AMessage> &msg); 94 void renderBuffer(bool audio, const sp<AMessage> &msg); 95 96 status_t dequeueNextAccessUnit( 97 ATSParser::SourceType *type, sp<ABuffer> *accessUnit); 98 99 status_t dequeueAccessUnit( 100 ATSParser::SourceType type, sp<ABuffer> *accessUnit); 101 102 void feedMoreTSData(); 103 void notifyListener(int msg, int ext1, int ext2); 104 105 void finishFlushIfPossible(); 106 107 DISALLOW_EVIL_CONSTRUCTORS(NuPlayer); 108}; 109 110} // namespace android 111 112#endif // NU_PLAYER_H_ 113