The Android Open Source Project | 9066cfe | 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 | 0795272 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 21 | #include <binder/IInterface.h> |
| 22 | #include <binder/Parcel.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | |
Nicolas Catania | 20cb94e | 2009-05-12 23:25:55 -0700 | [diff] [blame] | 26 | class Parcel; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | class ISurface; |
Andreas Huber | e3c0183 | 2010-08-16 08:49:37 -0700 | [diff] [blame] | 28 | class Surface; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | |
| 30 | class IMediaPlayer: public IInterface |
| 31 | { |
| 32 | public: |
| 33 | DECLARE_META_INTERFACE(MediaPlayer); |
| 34 | |
| 35 | virtual void disconnect() = 0; |
| 36 | |
Andreas Huber | e3c0183 | 2010-08-16 08:49:37 -0700 | [diff] [blame] | 37 | virtual status_t setVideoSurface(const sp<Surface>& surface) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | virtual status_t prepareAsync() = 0; |
| 39 | virtual status_t start() = 0; |
| 40 | virtual status_t stop() = 0; |
| 41 | virtual status_t pause() = 0; |
| 42 | virtual status_t isPlaying(bool* state) = 0; |
| 43 | virtual status_t seekTo(int msec) = 0; |
| 44 | virtual status_t getCurrentPosition(int* msec) = 0; |
| 45 | virtual status_t getDuration(int* msec) = 0; |
| 46 | virtual status_t reset() = 0; |
| 47 | virtual status_t setAudioStreamType(int type) = 0; |
| 48 | virtual status_t setLooping(int loop) = 0; |
| 49 | virtual status_t setVolume(float leftVolume, float rightVolume) = 0; |
Eric Laurent | 7070b36 | 2010-07-16 07:43:46 -0700 | [diff] [blame] | 50 | virtual status_t setAuxEffectSendLevel(float level) = 0; |
| 51 | virtual status_t attachAuxEffect(int effectId) = 0; |
Nicolas Catania | 20cb94e | 2009-05-12 23:25:55 -0700 | [diff] [blame] | 52 | |
| 53 | // Invoke a generic method on the player by using opaque parcels |
| 54 | // for the request and reply. |
| 55 | // @param request Parcel that must start with the media player |
| 56 | // interface token. |
| 57 | // @param[out] reply Parcel to hold the reply data. Cannot be null. |
Nicolas Catania | b2c6939 | 2009-07-08 08:57:42 -0700 | [diff] [blame] | 58 | // @return OK if the invocation was made successfully. |
Nicolas Catania | 20cb94e | 2009-05-12 23:25:55 -0700 | [diff] [blame] | 59 | virtual status_t invoke(const Parcel& request, Parcel *reply) = 0; |
Nicolas Catania | b2c6939 | 2009-07-08 08:57:42 -0700 | [diff] [blame] | 60 | |
| 61 | // Set a new metadata filter. |
| 62 | // @param filter A set of allow and drop rules serialized in a Parcel. |
| 63 | // @return OK if the invocation was made successfully. |
| 64 | virtual status_t setMetadataFilter(const Parcel& filter) = 0; |
Nicolas Catania | 5d55c71 | 2009-07-09 09:21:33 -0700 | [diff] [blame] | 65 | |
| 66 | // Retrieve a set of metadata. |
| 67 | // @param update_only Include only the metadata that have changed |
| 68 | // since the last invocation of getMetadata. |
| 69 | // The set is built using the unfiltered |
| 70 | // notifications the native player sent to the |
| 71 | // MediaPlayerService during that period of |
| 72 | // time. If false, all the metadatas are considered. |
| 73 | // @param apply_filter If true, once the metadata set has been built based |
| 74 | // on the value update_only, the current filter is |
| 75 | // applied. |
| 76 | // @param[out] metadata On exit contains a set (possibly empty) of metadata. |
| 77 | // Valid only if the call returned OK. |
| 78 | // @return OK if the invocation was made successfully. |
| 79 | virtual status_t getMetadata(bool update_only, |
| 80 | bool apply_filter, |
| 81 | Parcel *metadata) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | // ---------------------------------------------------------------------------- |
| 85 | |
| 86 | class BnMediaPlayer: public BnInterface<IMediaPlayer> |
| 87 | { |
| 88 | public: |
| 89 | virtual status_t onTransact( uint32_t code, |
| 90 | const Parcel& data, |
| 91 | Parcel* reply, |
| 92 | uint32_t flags = 0); |
| 93 | }; |
| 94 | |
| 95 | }; // namespace android |
| 96 | |
| 97 | #endif // ANDROID_IMEDIAPLAYER_H |