blob: 1bb7ca23f850db3d43fb876b9a3452a97e5d69bb [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
40 virtual status_t setVideoSurface(const sp<Surface> &surface);
Glenn Kasten11731182011-02-08 17:26:17 -080041 virtual status_t setVideoSurfaceTexture(
42 const sp<ISurfaceTexture> &surfaceTexture);
Andreas Huberf9334412010-12-15 15:17:42 -080043 virtual status_t prepare();
44 virtual status_t prepareAsync();
45 virtual status_t start();
46 virtual status_t stop();
47 virtual status_t pause();
48 virtual bool isPlaying();
49 virtual status_t seekTo(int msec);
50 virtual status_t getCurrentPosition(int *msec);
51 virtual status_t getDuration(int *msec);
52 virtual status_t reset();
53 virtual status_t setLooping(int loop);
54 virtual player_type playerType();
55 virtual status_t invoke(const Parcel &request, Parcel *reply);
56 virtual void setAudioSink(const sp<AudioSink> &audioSink);
Gloria Wang4f9e47f2011-04-25 17:28:22 -070057 virtual status_t setParameter(int key, const Parcel &request);
58 virtual status_t getParameter(int key, Parcel *reply);
Andreas Huberf9334412010-12-15 15:17:42 -080059
60 virtual status_t getMetadata(
61 const media::Metadata::Filter& ids, Parcel *records);
62
Andreas Huber43c3e6c2011-01-05 12:17:08 -080063 void notifyResetComplete();
64 void notifyDuration(int64_t durationUs);
65 void notifyPosition(int64_t positionUs);
66 void notifySeekComplete();
Andreas Huber1aef2112011-01-04 14:01:29 -080067
Andreas Huberf9334412010-12-15 15:17:42 -080068protected:
69 virtual ~NuPlayerDriver();
70
71private:
Andreas Huber1aef2112011-01-04 14:01:29 -080072 Mutex mLock;
73 Condition mCondition;
Andreas Huber43c3e6c2011-01-05 12:17:08 -080074
75 // The following are protected through "mLock"
76 // >>>
Andreas Huber1aef2112011-01-04 14:01:29 -080077 bool mResetInProgress;
Andreas Huber43c3e6c2011-01-05 12:17:08 -080078 int64_t mDurationUs;
79 int64_t mPositionUs;
80 // <<<
Andreas Huber1aef2112011-01-04 14:01:29 -080081
Andreas Huberf9334412010-12-15 15:17:42 -080082 sp<ALooper> mLooper;
83 sp<NuPlayer> mPlayer;
Andreas Huber43c3e6c2011-01-05 12:17:08 -080084
85 enum State {
86 UNINITIALIZED,
87 STOPPED,
88 PLAYING,
89 PAUSED
90 };
91
92 State mState;
93
94 int64_t mStartupSeekTimeUs;
Andreas Huberf9334412010-12-15 15:17:42 -080095
96 DISALLOW_EVIL_CONSTRUCTORS(NuPlayerDriver);
97};
98
99} // namespace android
100
101