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_IMEDIAPLAYERSERVICE_H |
| 18 | #define ANDROID_IMEDIAPLAYERSERVICE_H |
| 19 | |
Nicolas Catania | 20cb94e | 2009-05-12 23:25:55 -0700 | [diff] [blame] | 20 | #include <utils/Errors.h> // for status_t |
Andreas Huber | 2564300 | 2010-01-28 11:19:57 -0800 | [diff] [blame] | 21 | #include <utils/KeyedVector.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | #include <utils/RefBase.h> |
Andreas Huber | 2564300 | 2010-01-28 11:19:57 -0800 | [diff] [blame] | 23 | #include <utils/String8.h> |
Mathias Agopian | 0795272 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 24 | #include <binder/IInterface.h> |
| 25 | #include <binder/Parcel.h> |
Glenn Kasten | 1c5a89d | 2012-01-04 09:36:37 -0800 | [diff] [blame^] | 26 | #include <system/audio.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | |
| 28 | #include <media/IMediaPlayerClient.h> |
| 29 | #include <media/IMediaPlayer.h> |
| 30 | #include <media/IMediaMetadataRetriever.h> |
| 31 | |
| 32 | namespace android { |
| 33 | |
| 34 | class IMediaRecorder; |
Andreas Huber | e46b7be | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 35 | class IOMX; |
Andreas Huber | 52b52cd | 2010-11-23 11:41:34 -0800 | [diff] [blame] | 36 | struct IStreamSource; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | |
| 38 | class IMediaPlayerService: public IInterface |
| 39 | { |
| 40 | public: |
| 41 | DECLARE_META_INTERFACE(MediaPlayerService); |
| 42 | |
Dave Burke | fc301b0 | 2011-08-30 14:39:17 +0100 | [diff] [blame] | 43 | virtual sp<IMediaRecorder> createMediaRecorder(pid_t pid) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | virtual sp<IMediaMetadataRetriever> createMetadataRetriever(pid_t pid) = 0; |
Dave Burke | fc301b0 | 2011-08-30 14:39:17 +0100 | [diff] [blame] | 45 | virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client, int audioSessionId = 0) = 0; |
Andreas Huber | 52b52cd | 2010-11-23 11:41:34 -0800 | [diff] [blame] | 46 | |
Glenn Kasten | 1c5a89d | 2012-01-04 09:36:37 -0800 | [diff] [blame^] | 47 | virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0; |
| 48 | virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0; |
Andreas Huber | 784202e | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 49 | virtual sp<IOMX> getOMX() = 0; |
Gloria Wang | d211f41 | 2011-02-19 18:37:57 -0800 | [diff] [blame] | 50 | |
Gloria Wang | 9b3f152 | 2011-02-24 14:51:45 -0800 | [diff] [blame] | 51 | // codecs and audio devices usage tracking for the battery app |
Gloria Wang | d211f41 | 2011-02-19 18:37:57 -0800 | [diff] [blame] | 52 | enum BatteryDataBits { |
| 53 | // tracking audio codec |
Gloria Wang | 9b3f152 | 2011-02-24 14:51:45 -0800 | [diff] [blame] | 54 | kBatteryDataTrackAudio = 0x1, |
Gloria Wang | d211f41 | 2011-02-19 18:37:57 -0800 | [diff] [blame] | 55 | // tracking video codec |
Gloria Wang | 9b3f152 | 2011-02-24 14:51:45 -0800 | [diff] [blame] | 56 | kBatteryDataTrackVideo = 0x2, |
Gloria Wang | d211f41 | 2011-02-19 18:37:57 -0800 | [diff] [blame] | 57 | // codec is started, otherwise codec is paused |
Gloria Wang | 9b3f152 | 2011-02-24 14:51:45 -0800 | [diff] [blame] | 58 | kBatteryDataCodecStarted = 0x4, |
Gloria Wang | d211f41 | 2011-02-19 18:37:57 -0800 | [diff] [blame] | 59 | // tracking decoder (for media player), |
| 60 | // otherwise tracking encoder (for media recorder) |
Gloria Wang | 9b3f152 | 2011-02-24 14:51:45 -0800 | [diff] [blame] | 61 | kBatteryDataTrackDecoder = 0x8, |
| 62 | // start to play an audio on an audio device |
| 63 | kBatteryDataAudioFlingerStart = 0x10, |
| 64 | // stop/pause the audio playback |
| 65 | kBatteryDataAudioFlingerStop = 0x20, |
| 66 | // audio is rounted to speaker |
| 67 | kBatteryDataSpeakerOn = 0x40, |
| 68 | // audio is rounted to devices other than speaker |
| 69 | kBatteryDataOtherAudioDeviceOn = 0x80, |
Gloria Wang | d211f41 | 2011-02-19 18:37:57 -0800 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | virtual void addBatteryData(uint32_t params) = 0; |
| 73 | virtual status_t pullBatteryData(Parcel* reply) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | // ---------------------------------------------------------------------------- |
| 77 | |
| 78 | class BnMediaPlayerService: public BnInterface<IMediaPlayerService> |
| 79 | { |
| 80 | public: |
| 81 | virtual status_t onTransact( uint32_t code, |
| 82 | const Parcel& data, |
| 83 | Parcel* reply, |
| 84 | uint32_t flags = 0); |
| 85 | }; |
| 86 | |
| 87 | }; // namespace android |
| 88 | |
| 89 | #endif // ANDROID_IMEDIAPLAYERSERVICE_H |