NuPlayerDriver.h revision 08e10cb404c0f1620ca9db7494ccbb8adcca5ee5
1a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber/*
2a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber * Copyright (C) 2010 The Android Open Source Project
3a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber *
4a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber * Licensed under the Apache License, Version 2.0 (the "License");
5a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber * you may not use this file except in compliance with the License.
6a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber * You may obtain a copy of the License at
7a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber *
8a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber *      http://www.apache.org/licenses/LICENSE-2.0
9a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber *
10a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber * Unless required by applicable law or agreed to in writing, software
11a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber * distributed under the License is distributed on an "AS IS" BASIS,
12a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber * See the License for the specific language governing permissions and
14a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber * limitations under the License.
15a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber */
16a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
17a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber#include <media/MediaPlayerInterface.h>
18a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
19a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber#include <media/stagefright/foundation/ABase.h>
20a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
21a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Hubernamespace android {
22a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
23a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huberstruct ALooper;
24a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huberstruct NuPlayer;
25a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
26a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huberstruct NuPlayerDriver : public MediaPlayerInterface {
27a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    NuPlayerDriver();
28a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
29a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t initCheck();
30a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
31a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t setDataSource(
32a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber            const char *url, const KeyedVector<String8, String8> *headers);
33a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
34a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
35a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
36a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t setDataSource(const sp<IStreamSource> &source);
37a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
38a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t setVideoSurface(const sp<Surface> &surface);
39a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t prepare();
40a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t prepareAsync();
41a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t start();
42a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t stop();
43a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t pause();
44a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual bool isPlaying();
45a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t seekTo(int msec);
46a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t getCurrentPosition(int *msec);
47a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t getDuration(int *msec);
48a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t reset();
49a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t setLooping(int loop);
50a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual player_type playerType();
51a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t invoke(const Parcel &request, Parcel *reply);
52a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual void setAudioSink(const sp<AudioSink> &audioSink);
53a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
54a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual status_t getMetadata(
55a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber            const media::Metadata::Filter& ids, Parcel *records);
56a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
5708e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber    void notifyResetComplete();
5808e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber    void notifyDuration(int64_t durationUs);
5908e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber    void notifyPosition(int64_t positionUs);
6008e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber    void notifySeekComplete();
61cbeaca7a819cc11724f6f34457dabf5bd55a84a1Andreas Huber
62a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huberprotected:
63a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    virtual ~NuPlayerDriver();
64a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
65a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huberprivate:
66cbeaca7a819cc11724f6f34457dabf5bd55a84a1Andreas Huber    Mutex mLock;
67cbeaca7a819cc11724f6f34457dabf5bd55a84a1Andreas Huber    Condition mCondition;
6808e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber
6908e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber    // The following are protected through "mLock"
7008e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber    // >>>
71cbeaca7a819cc11724f6f34457dabf5bd55a84a1Andreas Huber    bool mResetInProgress;
7208e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber    int64_t mDurationUs;
7308e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber    int64_t mPositionUs;
7408e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber    // <<<
75cbeaca7a819cc11724f6f34457dabf5bd55a84a1Andreas Huber
76a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    sp<ALooper> mLooper;
77a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    sp<NuPlayer> mPlayer;
7808e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber
7908e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber    enum State {
8008e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber        UNINITIALIZED,
8108e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber        STOPPED,
8208e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber        PLAYING,
8308e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber        PAUSED
8408e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber    };
8508e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber
8608e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber    State mState;
8708e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber
8808e10cb404c0f1620ca9db7494ccbb8adcca5ee5Andreas Huber    int64_t mStartupSeekTimeUs;
89a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
90a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber    DISALLOW_EVIL_CONSTRUCTORS(NuPlayerDriver);
91a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber};
92a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
93a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber}  // namespace android
94a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
95a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber
96