NuPlayer.h revision 5bc087c573c70c84c6a39946457590b42d392a33
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 24namespace android { 25 26struct ACodec; 27struct MetaData; 28 29struct NuPlayer : public AHandler { 30 NuPlayer(); 31 32 void setListener(const wp<MediaPlayerBase> &listener); 33 34 void setDataSource(const sp<IStreamSource> &source); 35 36 void setDataSource( 37 const char *url, const KeyedVector<String8, String8> *headers); 38 39 void setVideoSurface(const sp<Surface> &surface); 40 void setAudioSink(const sp<MediaPlayerBase::AudioSink> &sink); 41 void start(); 42 43protected: 44 virtual ~NuPlayer(); 45 46 virtual void onMessageReceived(const sp<AMessage> &msg); 47 48private: 49 struct Decoder; 50 struct HTTPLiveSource; 51 struct NuPlayerStreamListener; 52 struct Renderer; 53 struct Source; 54 struct StreamingSource; 55 56 enum { 57 kWhatSetDataSource, 58 kWhatSetVideoSurface, 59 kWhatSetAudioSink, 60 kWhatMoreDataQueued, 61 kWhatStart, 62 kWhatScanSources, 63 kWhatVideoNotify, 64 kWhatAudioNotify, 65 kWhatRendererNotify, 66 }; 67 68 wp<MediaPlayerBase> mListener; 69 sp<Source> mSource; 70 sp<Surface> mSurface; 71 sp<MediaPlayerBase::AudioSink> mAudioSink; 72 sp<Decoder> mVideoDecoder; 73 sp<Decoder> mAudioDecoder; 74 sp<Renderer> mRenderer; 75 76 bool mEOS; 77 bool mAudioEOS; 78 bool mVideoEOS; 79 80 bool mScanSourcesPending; 81 82 enum FlushStatus { 83 NONE, 84 AWAITING_DISCONTINUITY, 85 FLUSHING_DECODER, 86 FLUSHING_DECODER_FORMATCHANGE, 87 SHUTTING_DOWN_DECODER, 88 FLUSHED, 89 SHUT_DOWN, 90 }; 91 92 FlushStatus mFlushingAudio; 93 FlushStatus mFlushingVideo; 94 95 status_t instantiateDecoder(bool audio, sp<Decoder> *decoder); 96 97 status_t feedDecoderInputData(bool audio, const sp<AMessage> &msg); 98 void renderBuffer(bool audio, const sp<AMessage> &msg); 99 100 void notifyListener(int msg, int ext1, int ext2); 101 102 void finishFlushIfPossible(); 103 104 static bool IsFlushingState(FlushStatus state, bool *formatChange = NULL); 105 106 DISALLOW_EVIL_CONSTRUCTORS(NuPlayer); 107}; 108 109} // namespace android 110 111#endif // NU_PLAYER_H_ 112