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