blob: 6d98852eb4052878ba8c210d4fb6908ef5c6299b [file] [log] [blame]
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 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#ifndef ANDROID_PVPLAYER_H
18#define ANDROID_PVPLAYER_H
19
20#include <utils/Errors.h>
21#include <media/MediaPlayerInterface.h>
22
23#define MAX_OPENCORE_INSTANCES 25
24
25#ifdef MAX_OPENCORE_INSTANCES
26#include <cutils/atomic.h>
27#endif
28
29class PlayerDriver;
30
31namespace android {
32
33class PVPlayer : public MediaPlayerInterface
34{
35public:
36 PVPlayer();
37 virtual ~PVPlayer();
38
39 virtual status_t initCheck();
40 virtual status_t setDataSource(const char *url);
41 virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
42 virtual status_t setVideoSurface(const sp<ISurface>& surface);
43 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() { return PV_PLAYER; }
55
56 // make available to PlayerDriver
57 void sendEvent(int msg, int ext1=0, int ext2=0) { MediaPlayerBase::sendEvent(msg, ext1, ext2); }
58
59private:
60 static void do_nothing(status_t s, void *cookie, bool cancelled) { }
61 static void run_init(status_t s, void *cookie, bool cancelled);
62 static void run_set_video_surface(status_t s, void *cookie, bool cancelled);
63 static void run_set_audio_output(status_t s, void *cookie, bool cancelled);
64 static void run_prepare(status_t s, void *cookie, bool cancelled);
65
66 PlayerDriver* mPlayerDriver;
67 char * mDataSourcePath;
68 bool mIsDataSourceSet;
69 sp<ISurface> mSurface;
70 int mSharedFd;
71 status_t mInit;
72 int mDuration;
73
74#ifdef MAX_OPENCORE_INSTANCES
75 static volatile int32_t sNumInstances;
76#endif
77};
78
79}; // namespace android
80
81#endif // ANDROID_PVPLAYER_H