The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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> |
Mathias Agopian | 7562408 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 21 | #include <binder/IInterface.h> |
| 22 | #include <binder/Parcel.h> |
Dave Burke | d681bbb | 2011-08-30 14:39:17 +0100 | [diff] [blame] | 23 | #include <utils/KeyedVector.h> |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 24 | #include <system/audio.h> |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | |
John Grossman | c795b64 | 2012-02-22 15:38:35 -0800 | [diff] [blame] | 26 | // Fwd decl to make sure everyone agrees that the scope of struct sockaddr_in is |
| 27 | // global, and not in android:: |
| 28 | struct sockaddr_in; |
| 29 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | namespace android { |
| 31 | |
Nicolas Catania | 1d187f1 | 2009-05-12 23:25:55 -0700 | [diff] [blame] | 32 | class Parcel; |
Andreas Huber | 5daeb12 | 2010-08-16 08:49:37 -0700 | [diff] [blame] | 33 | class Surface; |
Dave Burke | d681bbb | 2011-08-30 14:39:17 +0100 | [diff] [blame] | 34 | class IStreamSource; |
Andy McFadden | 8ba0102 | 2012-12-18 09:46:54 -0800 | [diff] [blame] | 35 | class IGraphicBufferProducer; |
Andreas Huber | 1b86fe0 | 2014-01-29 11:13:26 -0800 | [diff] [blame] | 36 | struct IMediaHTTPService; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | |
| 38 | class IMediaPlayer: public IInterface |
| 39 | { |
| 40 | public: |
| 41 | DECLARE_META_INTERFACE(MediaPlayer); |
| 42 | |
| 43 | virtual void disconnect() = 0; |
| 44 | |
Andreas Huber | 1b86fe0 | 2014-01-29 11:13:26 -0800 | [diff] [blame] | 45 | virtual status_t setDataSource( |
| 46 | const sp<IMediaHTTPService> &httpService, |
| 47 | const char *url, |
| 48 | const KeyedVector<String8, String8>* headers) = 0; |
| 49 | |
Dave Burke | d681bbb | 2011-08-30 14:39:17 +0100 | [diff] [blame] | 50 | virtual status_t setDataSource(int fd, int64_t offset, int64_t length) = 0; |
| 51 | virtual status_t setDataSource(const sp<IStreamSource>& source) = 0; |
Glenn Kasten | 1173118 | 2011-02-08 17:26:17 -0800 | [diff] [blame] | 52 | virtual status_t setVideoSurfaceTexture( |
Andy McFadden | 8ba0102 | 2012-12-18 09:46:54 -0800 | [diff] [blame] | 53 | const sp<IGraphicBufferProducer>& bufferProducer) = 0; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | virtual status_t prepareAsync() = 0; |
| 55 | virtual status_t start() = 0; |
| 56 | virtual status_t stop() = 0; |
| 57 | virtual status_t pause() = 0; |
| 58 | virtual status_t isPlaying(bool* state) = 0; |
Wei Jia | 9816016 | 2015-02-04 17:01:11 -0800 | [diff] [blame] | 59 | virtual status_t setPlaybackRate(float rate) = 0; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | virtual status_t seekTo(int msec) = 0; |
| 61 | virtual status_t getCurrentPosition(int* msec) = 0; |
| 62 | virtual status_t getDuration(int* msec) = 0; |
| 63 | virtual status_t reset() = 0; |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 64 | virtual status_t setAudioStreamType(audio_stream_type_t type) = 0; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | virtual status_t setLooping(int loop) = 0; |
| 66 | virtual status_t setVolume(float leftVolume, float rightVolume) = 0; |
Eric Laurent | 2beeb50 | 2010-07-16 07:43:46 -0700 | [diff] [blame] | 67 | virtual status_t setAuxEffectSendLevel(float level) = 0; |
| 68 | virtual status_t attachAuxEffect(int effectId) = 0; |
Gloria Wang | 4f9e47f | 2011-04-25 17:28:22 -0700 | [diff] [blame] | 69 | virtual status_t setParameter(int key, const Parcel& request) = 0; |
| 70 | virtual status_t getParameter(int key, Parcel* reply) = 0; |
John Grossman | c795b64 | 2012-02-22 15:38:35 -0800 | [diff] [blame] | 71 | virtual status_t setRetransmitEndpoint(const struct sockaddr_in* endpoint) = 0; |
John Grossman | 44a7e42 | 2012-06-21 17:29:24 -0700 | [diff] [blame] | 72 | virtual status_t getRetransmitEndpoint(struct sockaddr_in* endpoint) = 0; |
Marco Nelissen | 6b74d67 | 2012-02-28 16:07:44 -0800 | [diff] [blame] | 73 | virtual status_t setNextPlayer(const sp<IMediaPlayer>& next) = 0; |
Nicolas Catania | 1d187f1 | 2009-05-12 23:25:55 -0700 | [diff] [blame] | 74 | |
| 75 | // Invoke a generic method on the player by using opaque parcels |
| 76 | // for the request and reply. |
| 77 | // @param request Parcel that must start with the media player |
| 78 | // interface token. |
| 79 | // @param[out] reply Parcel to hold the reply data. Cannot be null. |
Nicolas Catania | a7e0e8b | 2009-07-08 08:57:42 -0700 | [diff] [blame] | 80 | // @return OK if the invocation was made successfully. |
Nicolas Catania | 1d187f1 | 2009-05-12 23:25:55 -0700 | [diff] [blame] | 81 | virtual status_t invoke(const Parcel& request, Parcel *reply) = 0; |
Nicolas Catania | a7e0e8b | 2009-07-08 08:57:42 -0700 | [diff] [blame] | 82 | |
| 83 | // Set a new metadata filter. |
| 84 | // @param filter A set of allow and drop rules serialized in a Parcel. |
| 85 | // @return OK if the invocation was made successfully. |
| 86 | virtual status_t setMetadataFilter(const Parcel& filter) = 0; |
Nicolas Catania | 8e1b6cc | 2009-07-09 09:21:33 -0700 | [diff] [blame] | 87 | |
| 88 | // Retrieve a set of metadata. |
| 89 | // @param update_only Include only the metadata that have changed |
| 90 | // since the last invocation of getMetadata. |
| 91 | // The set is built using the unfiltered |
| 92 | // notifications the native player sent to the |
| 93 | // MediaPlayerService during that period of |
| 94 | // time. If false, all the metadatas are considered. |
| 95 | // @param apply_filter If true, once the metadata set has been built based |
| 96 | // on the value update_only, the current filter is |
| 97 | // applied. |
| 98 | // @param[out] metadata On exit contains a set (possibly empty) of metadata. |
| 99 | // Valid only if the call returned OK. |
| 100 | // @return OK if the invocation was made successfully. |
| 101 | virtual status_t getMetadata(bool update_only, |
| 102 | bool apply_filter, |
| 103 | Parcel *metadata) = 0; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | // ---------------------------------------------------------------------------- |
| 107 | |
| 108 | class BnMediaPlayer: public BnInterface<IMediaPlayer> |
| 109 | { |
| 110 | public: |
| 111 | virtual status_t onTransact( uint32_t code, |
| 112 | const Parcel& data, |
| 113 | Parcel* reply, |
| 114 | uint32_t flags = 0); |
| 115 | }; |
| 116 | |
| 117 | }; // namespace android |
| 118 | |
| 119 | #endif // ANDROID_IMEDIAPLAYER_H |