Andreas Huber | f933441 | 2010-12-15 15:17:42 -0800 | [diff] [blame^] | 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 | |
| 27 | namespace android { |
| 28 | |
| 29 | struct ACodec; |
| 30 | struct MetaData; |
| 31 | |
| 32 | struct 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 | |
| 42 | protected: |
| 43 | virtual ~NuPlayer(); |
| 44 | |
| 45 | virtual void onMessageReceived(const sp<AMessage> &msg); |
| 46 | |
| 47 | private: |
| 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 | FLUSHED |
| 83 | }; |
| 84 | |
| 85 | FlushStatus mFlushingAudio; |
| 86 | FlushStatus mFlushingVideo; |
| 87 | |
| 88 | status_t instantiateDecoder( |
| 89 | bool audio, sp<Decoder> *decoder); |
| 90 | |
| 91 | status_t feedDecoderInputData(bool audio, const sp<AMessage> &msg); |
| 92 | void renderBuffer(bool audio, const sp<AMessage> &msg); |
| 93 | |
| 94 | status_t dequeueNextAccessUnit( |
| 95 | ATSParser::SourceType *type, sp<ABuffer> *accessUnit); |
| 96 | |
| 97 | status_t dequeueAccessUnit( |
| 98 | ATSParser::SourceType type, sp<ABuffer> *accessUnit); |
| 99 | |
| 100 | void feedMoreTSData(); |
| 101 | void notifyListener(int msg, int ext1, int ext2); |
| 102 | |
| 103 | DISALLOW_EVIL_CONSTRUCTORS(NuPlayer); |
| 104 | }; |
| 105 | |
| 106 | } // namespace android |
| 107 | |
| 108 | #endif // NU_PLAYER_H_ |