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