blob: 99f72a68d331faf1e690c124337190915314d9a9 [file] [log] [blame]
Andreas Huberf9334412010-12-15 15:17:42 -08001/*
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
21namespace android {
22
23struct ALooper;
24struct NuPlayer;
25
26struct NuPlayerDriver : public MediaPlayerInterface {
27 NuPlayerDriver();
28
29 virtual status_t initCheck();
30
Andreas Huber9b80c2b2011-06-30 15:47:02 -070031 virtual status_t setUID(uid_t uid);
32
Andreas Huberf9334412010-12-15 15:17:42 -080033 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
Glenn Kasten11731182011-02-08 17:26:17 -080040 virtual status_t setVideoSurfaceTexture(
Andy McFadden8ba01022012-12-18 09:46:54 -080041 const sp<IGraphicBufferProducer> &bufferProducer);
Andreas Huberf9334412010-12-15 15:17:42 -080042 virtual status_t prepare();
43 virtual status_t prepareAsync();
44 virtual status_t start();
45 virtual status_t stop();
46 virtual status_t pause();
47 virtual bool isPlaying();
48 virtual status_t seekTo(int msec);
49 virtual status_t getCurrentPosition(int *msec);
50 virtual status_t getDuration(int *msec);
51 virtual status_t reset();
52 virtual status_t setLooping(int loop);
53 virtual player_type playerType();
54 virtual status_t invoke(const Parcel &request, Parcel *reply);
55 virtual void setAudioSink(const sp<AudioSink> &audioSink);
Gloria Wang4f9e47f2011-04-25 17:28:22 -070056 virtual status_t setParameter(int key, const Parcel &request);
57 virtual status_t getParameter(int key, Parcel *reply);
Andreas Huberf9334412010-12-15 15:17:42 -080058
59 virtual status_t getMetadata(
60 const media::Metadata::Filter& ids, Parcel *records);
61
Andreas Huber3fe62152011-09-16 15:09:22 -070062 virtual status_t dump(int fd, const Vector<String16> &args) const;
63
Andreas Huber9575c962013-02-05 13:59:56 -080064 void notifySetDataSourceCompleted(status_t err);
65 void notifyPrepareCompleted(status_t err);
Andreas Huber43c3e6c2011-01-05 12:17:08 -080066 void notifyResetComplete();
Andreas Huber57a339c2012-12-03 11:18:00 -080067 void notifySetSurfaceComplete();
Andreas Huber43c3e6c2011-01-05 12:17:08 -080068 void notifyDuration(int64_t durationUs);
69 void notifyPosition(int64_t positionUs);
70 void notifySeekComplete();
Andreas Huber3fe62152011-09-16 15:09:22 -070071 void notifyFrameStats(int64_t numFramesTotal, int64_t numFramesDropped);
Chong Zhangdcb89b32013-08-06 09:44:47 -070072 void notifyListener(int msg, int ext1 = 0, int ext2 = 0, const Parcel *in = NULL);
Andreas Huber9575c962013-02-05 13:59:56 -080073 void notifyFlagsChanged(uint32_t flags);
Andreas Huber1aef2112011-01-04 14:01:29 -080074
Andreas Huberf9334412010-12-15 15:17:42 -080075protected:
76 virtual ~NuPlayerDriver();
77
78private:
Andreas Huber9575c962013-02-05 13:59:56 -080079 enum State {
80 STATE_IDLE,
81 STATE_SET_DATASOURCE_PENDING,
82 STATE_UNPREPARED,
83 STATE_PREPARING,
84 STATE_PREPARED,
85 STATE_RUNNING,
86 STATE_PAUSED,
87 STATE_RESET_IN_PROGRESS,
88 };
89
Andreas Huber3fe62152011-09-16 15:09:22 -070090 mutable Mutex mLock;
Andreas Huber1aef2112011-01-04 14:01:29 -080091 Condition mCondition;
Andreas Huber43c3e6c2011-01-05 12:17:08 -080092
Andreas Huber9575c962013-02-05 13:59:56 -080093 State mState;
94
Andreas Huberec0c5972013-02-05 14:47:13 -080095 bool mIsAsyncPrepare;
Andreas Huber9575c962013-02-05 13:59:56 -080096 status_t mAsyncResult;
97
Andreas Huber43c3e6c2011-01-05 12:17:08 -080098 // The following are protected through "mLock"
99 // >>>
Andreas Huber57a339c2012-12-03 11:18:00 -0800100 bool mSetSurfaceInProgress;
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800101 int64_t mDurationUs;
102 int64_t mPositionUs;
Andreas Huber3fe62152011-09-16 15:09:22 -0700103 int64_t mNumFramesTotal;
104 int64_t mNumFramesDropped;
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800105 // <<<
Andreas Huber1aef2112011-01-04 14:01:29 -0800106
Andreas Huberf9334412010-12-15 15:17:42 -0800107 sp<ALooper> mLooper;
108 sp<NuPlayer> mPlayer;
Andreas Huber9575c962013-02-05 13:59:56 -0800109 uint32_t mPlayerFlags;
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800110
Andreas Hubera4af2142011-10-26 15:23:31 -0700111 bool mAtEOS;
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800112
113 int64_t mStartupSeekTimeUs;
Andreas Huberf9334412010-12-15 15:17:42 -0800114
Andreas Huber9575c962013-02-05 13:59:56 -0800115 status_t prepare_l();
116
Andreas Huberf9334412010-12-15 15:17:42 -0800117 DISALLOW_EVIL_CONSTRUCTORS(NuPlayerDriver);
118};
119
120} // namespace android
121
122