blob: 145fd80b2ddacf03fdddb88c68c5ed4d0d47821e [file] [log] [blame]
Andreas Hubera1587462010-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
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);
Glenn Kastencc562a32011-02-08 17:26:17 -080039 virtual status_t setVideoSurfaceTexture(
40 const sp<ISurfaceTexture> &surfaceTexture);
Andreas Hubera1587462010-12-15 15:17:42 -080041 virtual status_t prepare();
42 virtual status_t prepareAsync();
43 virtual status_t start();
44 virtual status_t stop();
45 virtual status_t pause();
46 virtual bool isPlaying();
47 virtual status_t seekTo(int msec);
48 virtual status_t getCurrentPosition(int *msec);
49 virtual status_t getDuration(int *msec);
50 virtual status_t reset();
51 virtual status_t setLooping(int loop);
52 virtual player_type playerType();
53 virtual status_t invoke(const Parcel &request, Parcel *reply);
54 virtual void setAudioSink(const sp<AudioSink> &audioSink);
Gloria Wangd01ec6e2011-04-25 17:28:22 -070055 virtual status_t setParameter(int key, const Parcel &request);
56 virtual status_t getParameter(int key, Parcel *reply);
Andreas Hubera1587462010-12-15 15:17:42 -080057
58 virtual status_t getMetadata(
59 const media::Metadata::Filter& ids, Parcel *records);
60
Andreas Huber08e10cb2011-01-05 12:17:08 -080061 void notifyResetComplete();
62 void notifyDuration(int64_t durationUs);
63 void notifyPosition(int64_t positionUs);
64 void notifySeekComplete();
Andreas Hubercbeaca72011-01-04 14:01:29 -080065
Andreas Hubera1587462010-12-15 15:17:42 -080066protected:
67 virtual ~NuPlayerDriver();
68
69private:
Andreas Hubercbeaca72011-01-04 14:01:29 -080070 Mutex mLock;
71 Condition mCondition;
Andreas Huber08e10cb2011-01-05 12:17:08 -080072
73 // The following are protected through "mLock"
74 // >>>
Andreas Hubercbeaca72011-01-04 14:01:29 -080075 bool mResetInProgress;
Andreas Huber08e10cb2011-01-05 12:17:08 -080076 int64_t mDurationUs;
77 int64_t mPositionUs;
78 // <<<
Andreas Hubercbeaca72011-01-04 14:01:29 -080079
Andreas Hubera1587462010-12-15 15:17:42 -080080 sp<ALooper> mLooper;
81 sp<NuPlayer> mPlayer;
Andreas Huber08e10cb2011-01-05 12:17:08 -080082
83 enum State {
84 UNINITIALIZED,
85 STOPPED,
86 PLAYING,
87 PAUSED
88 };
89
90 State mState;
91
92 int64_t mStartupSeekTimeUs;
Andreas Hubera1587462010-12-15 15:17:42 -080093
94 DISALLOW_EVIL_CONSTRUCTORS(NuPlayerDriver);
95};
96
97} // namespace android
98
99