blob: a4cc15210d289f3ae5ffa40d723546893ce38f65 [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
Wei Jiac5de0912016-11-18 10:22:14 -080026#include <media/IMediaSource.h>
Hassan Shojania071437a2017-01-23 09:19:40 -080027#include <media/drm/DrmAPI.h> // for DrmPlugin::* enum
Andy Hung9fc8b5c2017-01-24 13:36:48 -080028#include <media/VolumeShaper.h>
Wei Jiac5de0912016-11-18 10:22:14 -080029
John Grossmanc795b642012-02-22 15:38:35 -080030// Fwd decl to make sure everyone agrees that the scope of struct sockaddr_in is
31// global, and not in android::
32struct sockaddr_in;
33
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080034namespace android {
35
Nicolas Catania1d187f12009-05-12 23:25:55 -070036class Parcel;
Andreas Huber5daeb122010-08-16 08:49:37 -070037class Surface;
Chris Watkins99f31602015-03-20 13:06:33 -070038class IDataSource;
Lajos Molnaree4e1b12015-04-17 13:46:19 -070039struct IStreamSource;
Andy McFadden8ba01022012-12-18 09:46:54 -080040class IGraphicBufferProducer;
Andreas Huber1b86fe02014-01-29 11:13:26 -080041struct IMediaHTTPService;
Lajos Molnar3a474aa2015-04-24 17:10:07 -070042struct AudioPlaybackRate;
43struct AVSyncSettings;
Wei Jiad399e7e2016-10-26 15:49:11 -070044struct BufferingSettings;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080045
Wei Jiac5de0912016-11-18 10:22:14 -080046typedef IMediaSource::ReadOptions::SeekMode MediaPlayerSeekMode;
47
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080048class IMediaPlayer: public IInterface
49{
50public:
51 DECLARE_META_INTERFACE(MediaPlayer);
52
53 virtual void disconnect() = 0;
54
Andreas Huber1b86fe02014-01-29 11:13:26 -080055 virtual status_t setDataSource(
56 const sp<IMediaHTTPService> &httpService,
57 const char *url,
58 const KeyedVector<String8, String8>* headers) = 0;
59
Dave Burked681bbb2011-08-30 14:39:17 +010060 virtual status_t setDataSource(int fd, int64_t offset, int64_t length) = 0;
61 virtual status_t setDataSource(const sp<IStreamSource>& source) = 0;
Chris Watkins99f31602015-03-20 13:06:33 -070062 virtual status_t setDataSource(const sp<IDataSource>& source) = 0;
Glenn Kasten11731182011-02-08 17:26:17 -080063 virtual status_t setVideoSurfaceTexture(
Andy McFadden8ba01022012-12-18 09:46:54 -080064 const sp<IGraphicBufferProducer>& bufferProducer) = 0;
Wei Jiad399e7e2016-10-26 15:49:11 -070065 virtual status_t getDefaultBufferingSettings(
66 BufferingSettings* buffering /* nonnull */) = 0;
67 virtual status_t setBufferingSettings(const BufferingSettings& buffering) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080068 virtual status_t prepareAsync() = 0;
69 virtual status_t start() = 0;
70 virtual status_t stop() = 0;
71 virtual status_t pause() = 0;
72 virtual status_t isPlaying(bool* state) = 0;
Lajos Molnar3a474aa2015-04-24 17:10:07 -070073 virtual status_t setPlaybackSettings(const AudioPlaybackRate& rate) = 0;
74 virtual status_t getPlaybackSettings(AudioPlaybackRate* rate /* nonnull */) = 0;
75 virtual status_t setSyncSettings(const AVSyncSettings& sync, float videoFpsHint) = 0;
76 virtual status_t getSyncSettings(AVSyncSettings* sync /* nonnull */,
77 float* videoFps /* nonnull */) = 0;
Wei Jiac5de0912016-11-18 10:22:14 -080078 virtual status_t seekTo(
79 int msec,
80 MediaPlayerSeekMode mode = MediaPlayerSeekMode::SEEK_PREVIOUS_SYNC) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080081 virtual status_t getCurrentPosition(int* msec) = 0;
82 virtual status_t getDuration(int* msec) = 0;
83 virtual status_t reset() = 0;
Glenn Kastenfff6d712012-01-12 16:38:12 -080084 virtual status_t setAudioStreamType(audio_stream_type_t type) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080085 virtual status_t setLooping(int loop) = 0;
86 virtual status_t setVolume(float leftVolume, float rightVolume) = 0;
Eric Laurent2beeb502010-07-16 07:43:46 -070087 virtual status_t setAuxEffectSendLevel(float level) = 0;
88 virtual status_t attachAuxEffect(int effectId) = 0;
Gloria Wang4f9e47f2011-04-25 17:28:22 -070089 virtual status_t setParameter(int key, const Parcel& request) = 0;
90 virtual status_t getParameter(int key, Parcel* reply) = 0;
John Grossmanc795b642012-02-22 15:38:35 -080091 virtual status_t setRetransmitEndpoint(const struct sockaddr_in* endpoint) = 0;
John Grossman44a7e422012-06-21 17:29:24 -070092 virtual status_t getRetransmitEndpoint(struct sockaddr_in* endpoint) = 0;
Marco Nelissen6b74d672012-02-28 16:07:44 -080093 virtual status_t setNextPlayer(const sp<IMediaPlayer>& next) = 0;
Andy Hung9fc8b5c2017-01-24 13:36:48 -080094
95 virtual VolumeShaper::Status applyVolumeShaper(
96 const sp<VolumeShaper::Configuration>& configuration,
97 const sp<VolumeShaper::Operation>& operation) = 0;
98 virtual sp<VolumeShaper::State> getVolumeShaperState(int id) = 0;
99
Hassan Shojania071437a2017-01-23 09:19:40 -0800100 // ModDrm
101 virtual status_t prepareDrm(const uint8_t uuid[16], const int mode) = 0;
102 virtual status_t releaseDrm() = 0;
103 virtual status_t getKeyRequest(Vector<uint8_t> const& scope,
104 String8 const &mimeType,
105 DrmPlugin::KeyType keyType,
106 KeyedVector<String8, String8>& optionalParameters,
107 Vector<uint8_t>& request,
108 String8& defaultUrl,
109 DrmPlugin::KeyRequestType& keyRequestType) = 0;
110 virtual status_t provideKeyResponse(Vector<uint8_t>& releaseKeySetId,
111 Vector<uint8_t>& response,
112 Vector<uint8_t>& keySetId) = 0;
113 virtual status_t restoreKeys(Vector<uint8_t> const& keySetId) = 0;
114 virtual status_t getDrmPropertyString(String8 const& name, String8& value) = 0;
115 virtual status_t setDrmPropertyString(String8 const& name, String8 const& value) = 0;
Nicolas Catania1d187f12009-05-12 23:25:55 -0700116
117 // Invoke a generic method on the player by using opaque parcels
118 // for the request and reply.
119 // @param request Parcel that must start with the media player
120 // interface token.
121 // @param[out] reply Parcel to hold the reply data. Cannot be null.
Nicolas Cataniaa7e0e8b2009-07-08 08:57:42 -0700122 // @return OK if the invocation was made successfully.
Nicolas Catania1d187f12009-05-12 23:25:55 -0700123 virtual status_t invoke(const Parcel& request, Parcel *reply) = 0;
Nicolas Cataniaa7e0e8b2009-07-08 08:57:42 -0700124
125 // Set a new metadata filter.
126 // @param filter A set of allow and drop rules serialized in a Parcel.
127 // @return OK if the invocation was made successfully.
128 virtual status_t setMetadataFilter(const Parcel& filter) = 0;
Nicolas Catania8e1b6cc2009-07-09 09:21:33 -0700129
130 // Retrieve a set of metadata.
131 // @param update_only Include only the metadata that have changed
132 // since the last invocation of getMetadata.
133 // The set is built using the unfiltered
134 // notifications the native player sent to the
135 // MediaPlayerService during that period of
136 // time. If false, all the metadatas are considered.
137 // @param apply_filter If true, once the metadata set has been built based
138 // on the value update_only, the current filter is
139 // applied.
140 // @param[out] metadata On exit contains a set (possibly empty) of metadata.
141 // Valid only if the call returned OK.
142 // @return OK if the invocation was made successfully.
143 virtual status_t getMetadata(bool update_only,
144 bool apply_filter,
145 Parcel *metadata) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800146};
147
148// ----------------------------------------------------------------------------
149
150class BnMediaPlayer: public BnInterface<IMediaPlayer>
151{
152public:
153 virtual status_t onTransact( uint32_t code,
154 const Parcel& data,
155 Parcel* reply,
156 uint32_t flags = 0);
157};
158
159}; // namespace android
160
161#endif // ANDROID_IMEDIAPLAYER_H