blob: 39d58ab586a592d99649cad4718bdc91faecd9d0 [file] [log] [blame]
The Android Open Source Project9066cfe2009-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_IMEDIAPLAYER_H
18#define ANDROID_IMEDIAPLAYER_H
19
20#include <utils/RefBase.h>
Mathias Agopian07952722009-05-19 19:08:10 -070021#include <binder/IInterface.h>
22#include <binder/Parcel.h>
Dave Burkefc301b02011-08-30 14:39:17 +010023#include <utils/KeyedVector.h>
Glenn Kastenbc1d77b2012-01-12 16:38:12 -080024#include <system/audio.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025
John Grossman720aa282012-02-22 15:38:35 -080026// 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
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030namespace android {
31
Nicolas Catania20cb94e2009-05-12 23:25:55 -070032class Parcel;
Andreas Hubere3c01832010-08-16 08:49:37 -070033class Surface;
Dave Burkefc301b02011-08-30 14:39:17 +010034class IStreamSource;
Glenn Kastencc562a32011-02-08 17:26:17 -080035class ISurfaceTexture;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036
37class IMediaPlayer: public IInterface
38{
39public:
40 DECLARE_META_INTERFACE(MediaPlayer);
41
42 virtual void disconnect() = 0;
43
Dave Burkefc301b02011-08-30 14:39:17 +010044 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;
Glenn Kastencc562a32011-02-08 17:26:17 -080048 virtual status_t setVideoSurfaceTexture(
49 const sp<ISurfaceTexture>& surfaceTexture) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050 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;
Glenn Kastenbc1d77b2012-01-12 16:38:12 -080059 virtual status_t setAudioStreamType(audio_stream_type_t type) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080060 virtual status_t setLooping(int loop) = 0;
61 virtual status_t setVolume(float leftVolume, float rightVolume) = 0;
Eric Laurent7070b362010-07-16 07:43:46 -070062 virtual status_t setAuxEffectSendLevel(float level) = 0;
63 virtual status_t attachAuxEffect(int effectId) = 0;
Gloria Wangd01ec6e2011-04-25 17:28:22 -070064 virtual status_t setParameter(int key, const Parcel& request) = 0;
65 virtual status_t getParameter(int key, Parcel* reply) = 0;
John Grossman720aa282012-02-22 15:38:35 -080066 virtual status_t setRetransmitEndpoint(const struct sockaddr_in* endpoint) = 0;
Nicolas Catania20cb94e2009-05-12 23:25:55 -070067
68 // Invoke a generic method on the player by using opaque parcels
69 // for the request and reply.
70 // @param request Parcel that must start with the media player
71 // interface token.
72 // @param[out] reply Parcel to hold the reply data. Cannot be null.
Nicolas Cataniab2c69392009-07-08 08:57:42 -070073 // @return OK if the invocation was made successfully.
Nicolas Catania20cb94e2009-05-12 23:25:55 -070074 virtual status_t invoke(const Parcel& request, Parcel *reply) = 0;
Nicolas Cataniab2c69392009-07-08 08:57:42 -070075
76 // Set a new metadata filter.
77 // @param filter A set of allow and drop rules serialized in a Parcel.
78 // @return OK if the invocation was made successfully.
79 virtual status_t setMetadataFilter(const Parcel& filter) = 0;
Nicolas Catania5d55c712009-07-09 09:21:33 -070080
81 // Retrieve a set of metadata.
82 // @param update_only Include only the metadata that have changed
83 // since the last invocation of getMetadata.
84 // The set is built using the unfiltered
85 // notifications the native player sent to the
86 // MediaPlayerService during that period of
87 // time. If false, all the metadatas are considered.
88 // @param apply_filter If true, once the metadata set has been built based
89 // on the value update_only, the current filter is
90 // applied.
91 // @param[out] metadata On exit contains a set (possibly empty) of metadata.
92 // Valid only if the call returned OK.
93 // @return OK if the invocation was made successfully.
94 virtual status_t getMetadata(bool update_only,
95 bool apply_filter,
96 Parcel *metadata) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097};
98
99// ----------------------------------------------------------------------------
100
101class BnMediaPlayer: public BnInterface<IMediaPlayer>
102{
103public:
104 virtual status_t onTransact( uint32_t code,
105 const Parcel& data,
106 Parcel* reply,
107 uint32_t flags = 0);
108};
109
110}; // namespace android
111
112#endif // ANDROID_IMEDIAPLAYER_H