Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -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 DashPlayer; |
| 25 | |
| 26 | struct DashPlayerDriver : public MediaPlayerInterface { |
| 27 | DashPlayerDriver(); |
| 28 | |
| 29 | virtual status_t initCheck(); |
| 30 | |
| 31 | virtual status_t setUID(uid_t uid); |
| 32 | |
| 33 | virtual status_t setDataSource( |
| 34 | const char *url, const KeyedVector<String8, String8> *headers); |
| 35 | |
| 36 | virtual status_t setDataSource(int fd, int64_t offset, int64_t length); |
| 37 | |
| 38 | virtual status_t setDataSource(const sp<IStreamSource> &source); |
| 39 | |
Sudhir Sharma | 3cfecd6 | 2013-07-17 15:01:24 -0700 | [diff] [blame] | 40 | #ifdef ANDROID_JB_MR2 |
| 41 | virtual status_t setVideoSurfaceTexture( |
| 42 | const sp<IGraphicBufferProducer> &bufferProducer); |
| 43 | #else |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 44 | virtual status_t setVideoSurfaceTexture( |
| 45 | const sp<ISurfaceTexture> &surfaceTexture); |
Sudhir Sharma | 3cfecd6 | 2013-07-17 15:01:24 -0700 | [diff] [blame] | 46 | #endif |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 47 | virtual status_t prepare(); |
| 48 | virtual status_t prepareAsync(); |
| 49 | virtual status_t start(); |
| 50 | virtual status_t stop(); |
| 51 | virtual status_t pause(); |
| 52 | virtual bool isPlaying(); |
| 53 | virtual status_t seekTo(int msec); |
| 54 | virtual status_t getCurrentPosition(int *msec); |
| 55 | virtual status_t getDuration(int *msec); |
| 56 | virtual status_t reset(); |
| 57 | virtual status_t setLooping(int loop); |
| 58 | virtual player_type playerType(); |
| 59 | virtual status_t invoke(const Parcel &request, Parcel *reply); |
| 60 | virtual void setAudioSink(const sp<AudioSink> &audioSink); |
| 61 | virtual status_t setParameter(int key, const Parcel &request); |
| 62 | virtual status_t getParameter(int key, Parcel *reply); |
| 63 | |
| 64 | virtual status_t getMetadata( |
| 65 | const media::Metadata::Filter& ids, Parcel *records); |
| 66 | |
| 67 | virtual status_t dump(int fd, const Vector<String16> &args) const; |
| 68 | |
| 69 | void notifyResetComplete(); |
| 70 | void notifyDuration(int64_t durationUs); |
| 71 | void notifyPosition(int64_t positionUs); |
| 72 | void notifySeekComplete(); |
| 73 | void notifyFrameStats(int64_t numFramesTotal, int64_t numFramesDropped); |
| 74 | void notifyListener(int msg, int ext1 = 0, int ext2 = 0, const Parcel *obj=NULL); |
| 75 | |
| 76 | protected: |
| 77 | virtual ~DashPlayerDriver(); |
| 78 | |
| 79 | private: |
| 80 | mutable Mutex mLock; |
| 81 | Condition mCondition; |
| 82 | |
| 83 | // The following are protected through "mLock" |
| 84 | // >>> |
| 85 | bool mResetInProgress; |
| 86 | int64_t mDurationUs; |
| 87 | int64_t mPositionUs; |
| 88 | int64_t mNumFramesTotal; |
| 89 | int64_t mNumFramesDropped; |
| 90 | // <<< |
| 91 | |
| 92 | sp<ALooper> mLooper; |
| 93 | sp<DashPlayer> mPlayer; |
| 94 | |
| 95 | enum State { |
| 96 | UNINITIALIZED, |
| 97 | STOPPED, |
| 98 | PLAYING, |
| 99 | PAUSED |
| 100 | }; |
| 101 | |
| 102 | State mState; |
| 103 | bool mAtEOS; |
| 104 | |
| 105 | int64_t mStartupSeekTimeUs; |
| 106 | |
| 107 | DISALLOW_EVIL_CONSTRUCTORS(DashPlayerDriver); |
| 108 | }; |
| 109 | |
| 110 | } // namespace android |
| 111 | |
| 112 | |