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 | #include <media/MediaPlayerInterface.h> |
| 18 | |
| 19 | #include <media/stagefright/foundation/ABase.h> |
| 20 | |
| 21 | namespace android { |
| 22 | |
| 23 | struct ALooper; |
| 24 | struct NuPlayer; |
| 25 | |
| 26 | struct NuPlayerDriver : public MediaPlayerInterface { |
| 27 | NuPlayerDriver(); |
| 28 | |
| 29 | virtual status_t initCheck(); |
| 30 | |
| 31 | virtual status_t setDataSource( |
| 32 | const char *url, const KeyedVector<String8, String8> *headers); |
| 33 | |
| 34 | virtual status_t setDataSource(int fd, int64_t offset, int64_t length); |
| 35 | |
| 36 | virtual status_t setDataSource(const sp<IStreamSource> &source); |
| 37 | |
| 38 | virtual status_t setVideoSurface(const sp<Surface> &surface); |
| 39 | virtual status_t prepare(); |
| 40 | virtual status_t prepareAsync(); |
| 41 | virtual status_t start(); |
| 42 | virtual status_t stop(); |
| 43 | virtual status_t pause(); |
| 44 | virtual bool isPlaying(); |
| 45 | virtual status_t seekTo(int msec); |
| 46 | virtual status_t getCurrentPosition(int *msec); |
| 47 | virtual status_t getDuration(int *msec); |
| 48 | virtual status_t reset(); |
| 49 | virtual status_t setLooping(int loop); |
| 50 | virtual player_type playerType(); |
| 51 | virtual status_t invoke(const Parcel &request, Parcel *reply); |
| 52 | virtual void setAudioSink(const sp<AudioSink> &audioSink); |
| 53 | |
| 54 | virtual status_t getMetadata( |
| 55 | const media::Metadata::Filter& ids, Parcel *records); |
| 56 | |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame^] | 57 | void notifyResetComplete(); |
| 58 | void notifyDuration(int64_t durationUs); |
| 59 | void notifyPosition(int64_t positionUs); |
| 60 | void notifySeekComplete(); |
Andreas Huber | 1aef211 | 2011-01-04 14:01:29 -0800 | [diff] [blame] | 61 | |
Andreas Huber | f933441 | 2010-12-15 15:17:42 -0800 | [diff] [blame] | 62 | protected: |
| 63 | virtual ~NuPlayerDriver(); |
| 64 | |
| 65 | private: |
Andreas Huber | 1aef211 | 2011-01-04 14:01:29 -0800 | [diff] [blame] | 66 | Mutex mLock; |
| 67 | Condition mCondition; |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame^] | 68 | |
| 69 | // The following are protected through "mLock" |
| 70 | // >>> |
Andreas Huber | 1aef211 | 2011-01-04 14:01:29 -0800 | [diff] [blame] | 71 | bool mResetInProgress; |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame^] | 72 | int64_t mDurationUs; |
| 73 | int64_t mPositionUs; |
| 74 | // <<< |
Andreas Huber | 1aef211 | 2011-01-04 14:01:29 -0800 | [diff] [blame] | 75 | |
Andreas Huber | f933441 | 2010-12-15 15:17:42 -0800 | [diff] [blame] | 76 | sp<ALooper> mLooper; |
| 77 | sp<NuPlayer> mPlayer; |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame^] | 78 | |
| 79 | enum State { |
| 80 | UNINITIALIZED, |
| 81 | STOPPED, |
| 82 | PLAYING, |
| 83 | PAUSED |
| 84 | }; |
| 85 | |
| 86 | State mState; |
| 87 | |
| 88 | int64_t mStartupSeekTimeUs; |
Andreas Huber | f933441 | 2010-12-15 15:17:42 -0800 | [diff] [blame] | 89 | |
| 90 | DISALLOW_EVIL_CONSTRUCTORS(NuPlayerDriver); |
| 91 | }; |
| 92 | |
| 93 | } // namespace android |
| 94 | |
| 95 | |