IMediaPlayerService.h revision 81e68448f3361eaf8618930471fdc3c21bdf5cbc
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;
35struct IDrm;
36struct IHDCP;
37struct IMediaHTTPService;
38class IMediaRecorder;
39class IOMX;
40class IRemoteDisplay;
41class IRemoteDisplayClient;
42struct IStreamSource;
43
44class IMediaPlayerService: public IInterface
45{
46public:
47    DECLARE_META_INTERFACE(MediaPlayerService);
48
49    virtual sp<IMediaRecorder> createMediaRecorder() = 0;
50    virtual sp<IMediaMetadataRetriever> createMetadataRetriever() = 0;
51    virtual sp<IMediaPlayer> create(const sp<IMediaPlayerClient>& client, int audioSessionId = 0) = 0;
52
53    virtual status_t         decode(
54            const sp<IMediaHTTPService> &httpService,
55            const char* url,
56            uint32_t *pSampleRate,
57            int* pNumChannels,
58            audio_format_t* pFormat,
59            const sp<IMemoryHeap>& heap, size_t *pSize) = 0;
60
61    virtual status_t         decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate,
62                                    int* pNumChannels, audio_format_t* pFormat,
63                                    const sp<IMemoryHeap>& heap, size_t *pSize) = 0;
64    virtual sp<IOMX>            getOMX() = 0;
65    virtual sp<ICrypto>         makeCrypto() = 0;
66    virtual sp<IDrm>            makeDrm() = 0;
67    virtual sp<IHDCP>           makeHDCP(bool createEncryptionModule) = 0;
68
69    // Connects to a remote display.
70    // 'iface' specifies the address of the local interface on which to listen for
71    // a connection from the remote display as an ip address and port number
72    // of the form "x.x.x.x:y".  The media server should call back into the provided remote
73    // display client when display connection, disconnection or errors occur.
74    // The assumption is that at most one remote display will be connected to the
75    // provided interface at a time.
76    virtual sp<IRemoteDisplay> listenForRemoteDisplay(const sp<IRemoteDisplayClient>& client,
77            const String8& iface) = 0;
78
79    // codecs and audio devices usage tracking for the battery app
80    enum BatteryDataBits {
81        // tracking audio codec
82        kBatteryDataTrackAudio          = 0x1,
83        // tracking video codec
84        kBatteryDataTrackVideo          = 0x2,
85        // codec is started, otherwise codec is paused
86        kBatteryDataCodecStarted        = 0x4,
87        // tracking decoder (for media player),
88        // otherwise tracking encoder (for media recorder)
89        kBatteryDataTrackDecoder        = 0x8,
90        // start to play an audio on an audio device
91        kBatteryDataAudioFlingerStart   = 0x10,
92        // stop/pause the audio playback
93        kBatteryDataAudioFlingerStop    = 0x20,
94        // audio is rounted to speaker
95        kBatteryDataSpeakerOn           = 0x40,
96        // audio is rounted to devices other than speaker
97        kBatteryDataOtherAudioDeviceOn  = 0x80,
98    };
99
100    virtual void addBatteryData(uint32_t params) = 0;
101    virtual status_t pullBatteryData(Parcel* reply) = 0;
102};
103
104// ----------------------------------------------------------------------------
105
106class BnMediaPlayerService: public BnInterface<IMediaPlayerService>
107{
108public:
109    virtual status_t    onTransact( uint32_t code,
110                                    const Parcel& data,
111                                    Parcel* reply,
112                                    uint32_t flags = 0);
113};
114
115}; // namespace android
116
117#endif // ANDROID_IMEDIAPLAYERSERVICE_H
118