IMediaPlayerService.h revision 35213f1420c669f43314cb75eadea450d21a75cb
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
20#include <utils/Errors.h>  // for status_t
21#include <utils/KeyedVector.h>
22#include <utils/RefBase.h>
23#include <utils/String8.h>
24#include <binder/IInterface.h>
25#include <binder/Parcel.h>
26#include <system/audio.h>
27
28#include <media/IMediaPlayerClient.h>
29#include <media/IMediaPlayer.h>
30#include <media/IMediaMetadataRetriever.h>
31
32namespace android {
33
34struct ICrypto;
35class IMediaRecorder;
36class IOMX;
37struct IStreamSource;
38
39class IMediaPlayerService: public IInterface
40{
41public:
42    DECLARE_META_INTERFACE(MediaPlayerService);
43
44    virtual sp<IMediaRecorder> createMediaRecorder(pid_t pid) = 0;
45    virtual sp<IMediaMetadataRetriever> createMetadataRetriever(pid_t pid) = 0;
46    virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client, int audioSessionId = 0) = 0;
47
48    virtual sp<IMemory>         decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0;
49    virtual sp<IMemory>         decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0;
50    virtual sp<IOMX>            getOMX() = 0;
51    virtual sp<ICrypto>         makeCrypto() = 0;
52
53    virtual status_t enableRemoteDisplay(bool enable) = 0;
54
55    // codecs and audio devices usage tracking for the battery app
56    enum BatteryDataBits {
57        // tracking audio codec
58        kBatteryDataTrackAudio          = 0x1,
59        // tracking video codec
60        kBatteryDataTrackVideo          = 0x2,
61        // codec is started, otherwise codec is paused
62        kBatteryDataCodecStarted        = 0x4,
63        // tracking decoder (for media player),
64        // otherwise tracking encoder (for media recorder)
65        kBatteryDataTrackDecoder        = 0x8,
66        // start to play an audio on an audio device
67        kBatteryDataAudioFlingerStart   = 0x10,
68        // stop/pause the audio playback
69        kBatteryDataAudioFlingerStop    = 0x20,
70        // audio is rounted to speaker
71        kBatteryDataSpeakerOn           = 0x40,
72        // audio is rounted to devices other than speaker
73        kBatteryDataOtherAudioDeviceOn  = 0x80,
74    };
75
76    virtual void addBatteryData(uint32_t params) = 0;
77    virtual status_t pullBatteryData(Parcel* reply) = 0;
78};
79
80// ----------------------------------------------------------------------------
81
82class BnMediaPlayerService: public BnInterface<IMediaPlayerService>
83{
84public:
85    virtual status_t    onTransact( uint32_t code,
86                                    const Parcel& data,
87                                    Parcel* reply,
88                                    uint32_t flags = 0);
89};
90
91}; // namespace android
92
93#endif // ANDROID_IMEDIAPLAYERSERVICE_H
94