blob: 17ef489ac730262b94801e5456409cb750d15321 [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_IMEDIAPLAYER_H
18#define ANDROID_IMEDIAPLAYER_H
19
20#include <utils/RefBase.h>
Mathias Agopian75624082009-05-19 19:08:10 -070021#include <binder/IInterface.h>
22#include <binder/Parcel.h>
Dave Burked681bbb2011-08-30 14:39:17 +010023#include <utils/KeyedVector.h>
Glenn Kastenfff6d712012-01-12 16:38:12 -080024#include <system/audio.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080025
John Grossmanc795b642012-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 Project89fa4ad2009-03-03 19:31:44 -080030namespace android {
31
Nicolas Catania1d187f12009-05-12 23:25:55 -070032class Parcel;
Andreas Huber5daeb122010-08-16 08:49:37 -070033class Surface;
Chris Watkins99f31602015-03-20 13:06:33 -070034class IDataSource;
Dave Burked681bbb2011-08-30 14:39:17 +010035class IStreamSource;
Andy McFadden8ba01022012-12-18 09:46:54 -080036class IGraphicBufferProducer;
Andreas Huber1b86fe02014-01-29 11:13:26 -080037struct IMediaHTTPService;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080038
39class IMediaPlayer: public IInterface
40{
41public:
42 DECLARE_META_INTERFACE(MediaPlayer);
43
44 virtual void disconnect() = 0;
45
Andreas Huber1b86fe02014-01-29 11:13:26 -080046 virtual status_t setDataSource(
47 const sp<IMediaHTTPService> &httpService,
48 const char *url,
49 const KeyedVector<String8, String8>* headers) = 0;
50
Dave Burked681bbb2011-08-30 14:39:17 +010051 virtual status_t setDataSource(int fd, int64_t offset, int64_t length) = 0;
52 virtual status_t setDataSource(const sp<IStreamSource>& source) = 0;
Chris Watkins99f31602015-03-20 13:06:33 -070053 virtual status_t setDataSource(const sp<IDataSource>& source) = 0;
Glenn Kasten11731182011-02-08 17:26:17 -080054 virtual status_t setVideoSurfaceTexture(
Andy McFadden8ba01022012-12-18 09:46:54 -080055 const sp<IGraphicBufferProducer>& bufferProducer) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080056 virtual status_t prepareAsync() = 0;
57 virtual status_t start() = 0;
58 virtual status_t stop() = 0;
59 virtual status_t pause() = 0;
60 virtual status_t isPlaying(bool* state) = 0;
Wei Jia98160162015-02-04 17:01:11 -080061 virtual status_t setPlaybackRate(float rate) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080062 virtual status_t seekTo(int msec) = 0;
63 virtual status_t getCurrentPosition(int* msec) = 0;
64 virtual status_t getDuration(int* msec) = 0;
65 virtual status_t reset() = 0;
Glenn Kastenfff6d712012-01-12 16:38:12 -080066 virtual status_t setAudioStreamType(audio_stream_type_t type) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080067 virtual status_t setLooping(int loop) = 0;
68 virtual status_t setVolume(float leftVolume, float rightVolume) = 0;
Eric Laurent2beeb502010-07-16 07:43:46 -070069 virtual status_t setAuxEffectSendLevel(float level) = 0;
70 virtual status_t attachAuxEffect(int effectId) = 0;
Gloria Wang4f9e47f2011-04-25 17:28:22 -070071 virtual status_t setParameter(int key, const Parcel& request) = 0;
72 virtual status_t getParameter(int key, Parcel* reply) = 0;
John Grossmanc795b642012-02-22 15:38:35 -080073 virtual status_t setRetransmitEndpoint(const struct sockaddr_in* endpoint) = 0;
John Grossman44a7e422012-06-21 17:29:24 -070074 virtual status_t getRetransmitEndpoint(struct sockaddr_in* endpoint) = 0;
Marco Nelissen6b74d672012-02-28 16:07:44 -080075 virtual status_t setNextPlayer(const sp<IMediaPlayer>& next) = 0;
Nicolas Catania1d187f12009-05-12 23:25:55 -070076
77 // Invoke a generic method on the player by using opaque parcels
78 // for the request and reply.
79 // @param request Parcel that must start with the media player
80 // interface token.
81 // @param[out] reply Parcel to hold the reply data. Cannot be null.
Nicolas Cataniaa7e0e8b2009-07-08 08:57:42 -070082 // @return OK if the invocation was made successfully.
Nicolas Catania1d187f12009-05-12 23:25:55 -070083 virtual status_t invoke(const Parcel& request, Parcel *reply) = 0;
Nicolas Cataniaa7e0e8b2009-07-08 08:57:42 -070084
85 // Set a new metadata filter.
86 // @param filter A set of allow and drop rules serialized in a Parcel.
87 // @return OK if the invocation was made successfully.
88 virtual status_t setMetadataFilter(const Parcel& filter) = 0;
Nicolas Catania8e1b6cc2009-07-09 09:21:33 -070089
90 // Retrieve a set of metadata.
91 // @param update_only Include only the metadata that have changed
92 // since the last invocation of getMetadata.
93 // The set is built using the unfiltered
94 // notifications the native player sent to the
95 // MediaPlayerService during that period of
96 // time. If false, all the metadatas are considered.
97 // @param apply_filter If true, once the metadata set has been built based
98 // on the value update_only, the current filter is
99 // applied.
100 // @param[out] metadata On exit contains a set (possibly empty) of metadata.
101 // Valid only if the call returned OK.
102 // @return OK if the invocation was made successfully.
103 virtual status_t getMetadata(bool update_only,
104 bool apply_filter,
105 Parcel *metadata) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800106};
107
108// ----------------------------------------------------------------------------
109
110class BnMediaPlayer: public BnInterface<IMediaPlayer>
111{
112public:
113 virtual status_t onTransact( uint32_t code,
114 const Parcel& data,
115 Parcel* reply,
116 uint32_t flags = 0);
117};
118
119}; // namespace android
120
121#endif // ANDROID_IMEDIAPLAYER_H