IMediaPlayer.h revision fff6d715a8db0daf08a50634f242c40268de3d49
1/*
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_IMEDIAPLAYER_H
18#define ANDROID_IMEDIAPLAYER_H
19
20#include <utils/RefBase.h>
21#include <binder/IInterface.h>
22#include <binder/Parcel.h>
23#include <utils/KeyedVector.h>
24#include <system/audio.h>
25
26namespace android {
27
28class Parcel;
29class Surface;
30class IStreamSource;
31class ISurfaceTexture;
32
33class IMediaPlayer: public IInterface
34{
35public:
36    DECLARE_META_INTERFACE(MediaPlayer);
37
38    virtual void            disconnect() = 0;
39
40    virtual status_t        setDataSource(const char *url,
41                                    const KeyedVector<String8, String8>* headers) = 0;
42    virtual status_t        setDataSource(int fd, int64_t offset, int64_t length) = 0;
43    virtual status_t        setDataSource(const sp<IStreamSource>& source) = 0;
44    virtual status_t        setVideoSurfaceTexture(
45                                    const sp<ISurfaceTexture>& surfaceTexture) = 0;
46    virtual status_t        prepareAsync() = 0;
47    virtual status_t        start() = 0;
48    virtual status_t        stop() = 0;
49    virtual status_t        pause() = 0;
50    virtual status_t        isPlaying(bool* state) = 0;
51    virtual status_t        seekTo(int msec) = 0;
52    virtual status_t        getCurrentPosition(int* msec) = 0;
53    virtual status_t        getDuration(int* msec) = 0;
54    virtual status_t        reset() = 0;
55    virtual status_t        setAudioStreamType(audio_stream_type_t type) = 0;
56    virtual status_t        setLooping(int loop) = 0;
57    virtual status_t        setVolume(float leftVolume, float rightVolume) = 0;
58    virtual status_t        setAuxEffectSendLevel(float level) = 0;
59    virtual status_t        attachAuxEffect(int effectId) = 0;
60    virtual status_t        setParameter(int key, const Parcel& request) = 0;
61    virtual status_t        getParameter(int key, Parcel* reply) = 0;
62
63    // Invoke a generic method on the player by using opaque parcels
64    // for the request and reply.
65    // @param request Parcel that must start with the media player
66    // interface token.
67    // @param[out] reply Parcel to hold the reply data. Cannot be null.
68    // @return OK if the invocation was made successfully.
69    virtual status_t        invoke(const Parcel& request, Parcel *reply) = 0;
70
71    // Set a new metadata filter.
72    // @param filter A set of allow and drop rules serialized in a Parcel.
73    // @return OK if the invocation was made successfully.
74    virtual status_t        setMetadataFilter(const Parcel& filter) = 0;
75
76    // Retrieve a set of metadata.
77    // @param update_only Include only the metadata that have changed
78    //                    since the last invocation of getMetadata.
79    //                    The set is built using the unfiltered
80    //                    notifications the native player sent to the
81    //                    MediaPlayerService during that period of
82    //                    time. If false, all the metadatas are considered.
83    // @param apply_filter If true, once the metadata set has been built based
84    //                     on the value update_only, the current filter is
85    //                     applied.
86    // @param[out] metadata On exit contains a set (possibly empty) of metadata.
87    //                      Valid only if the call returned OK.
88    // @return OK if the invocation was made successfully.
89    virtual status_t        getMetadata(bool update_only,
90                                        bool apply_filter,
91                                        Parcel *metadata) = 0;
92};
93
94// ----------------------------------------------------------------------------
95
96class BnMediaPlayer: public BnInterface<IMediaPlayer>
97{
98public:
99    virtual status_t    onTransact( uint32_t code,
100                                    const Parcel& data,
101                                    Parcel* reply,
102                                    uint32_t flags = 0);
103};
104
105}; // namespace android
106
107#endif // ANDROID_IMEDIAPLAYER_H
108