3030namespace android {
3131
3232enum {
33- CREATE_URL = IBinder::FIRST_CALL_TRANSACTION,
34- CREATE_FD,
35- CREATE_STREAM,
33+ CREATE = IBinder::FIRST_CALL_TRANSACTION,
3634 DECODE_URL,
3735 DECODE_FD,
3836 CREATE_MEDIA_RECORDER,
@@ -60,28 +58,14 @@ class BpMediaPlayerService: public BpInterface<IMediaPlayerService>
6058 }
6159
6260 virtual sp<IMediaPlayer> create (
63- pid_t pid, const sp<IMediaPlayerClient>& client,
64- const char * url, const KeyedVector<String8, String8> *headers, int audioSessionId) {
61+ pid_t pid, const sp<IMediaPlayerClient>& client, int audioSessionId) {
6562 Parcel data, reply;
6663 data.writeInterfaceToken (IMediaPlayerService::getInterfaceDescriptor ());
6764 data.writeInt32 (pid);
6865 data.writeStrongBinder (client->asBinder ());
69- data.writeCString (url);
70-
71- if (headers == NULL ) {
72- data.writeInt32 (0 );
73- } else {
74- // serialize the headers
75- data.writeInt32 (headers->size ());
76- for (size_t i = 0 ; i < headers->size (); ++i) {
77- data.writeString8 (headers->keyAt (i));
78- data.writeString8 (headers->valueAt (i));
79- }
80- }
8166 data.writeInt32 (audioSessionId);
8267
83- remote ()->transact (CREATE_URL, data, &reply);
84-
68+ remote ()->transact (CREATE, data, &reply);
8569 return interface_cast<IMediaPlayer>(reply.readStrongBinder ());
8670 }
8771
@@ -94,38 +78,6 @@ class BpMediaPlayerService: public BpInterface<IMediaPlayerService>
9478 return interface_cast<IMediaRecorder>(reply.readStrongBinder ());
9579 }
9680
97- virtual sp<IMediaPlayer> create (pid_t pid, const sp<IMediaPlayerClient>& client, int fd,
98- int64_t offset, int64_t length, int audioSessionId)
99- {
100- Parcel data, reply;
101- data.writeInterfaceToken (IMediaPlayerService::getInterfaceDescriptor ());
102- data.writeInt32 (pid);
103- data.writeStrongBinder (client->asBinder ());
104- data.writeFileDescriptor (fd);
105- data.writeInt64 (offset);
106- data.writeInt64 (length);
107- data.writeInt32 (audioSessionId);
108-
109- remote ()->transact (CREATE_FD, data, &reply);
110-
111- return interface_cast<IMediaPlayer>(reply.readStrongBinder ());;
112- }
113-
114- virtual sp<IMediaPlayer> create (
115- pid_t pid, const sp<IMediaPlayerClient> &client,
116- const sp<IStreamSource> &source, int audioSessionId) {
117- Parcel data, reply;
118- data.writeInterfaceToken (IMediaPlayerService::getInterfaceDescriptor ());
119- data.writeInt32 (static_cast <int32_t >(pid));
120- data.writeStrongBinder (client->asBinder ());
121- data.writeStrongBinder (source->asBinder ());
122- data.writeInt32 (static_cast <int32_t >(audioSessionId));
123-
124- remote ()->transact (CREATE_STREAM, data, &reply);
125-
126- return interface_cast<IMediaPlayer>(reply.readStrongBinder ());;
127- }
128-
12981 virtual sp<IMemory> decode (const char * url, uint32_t *pSampleRate, int * pNumChannels, int * pFormat)
13082 {
13183 Parcel data, reply;
@@ -181,62 +133,16 @@ status_t BnMediaPlayerService::onTransact(
181133 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
182134{
183135 switch (code) {
184- case CREATE_URL : {
136+ case CREATE : {
185137 CHECK_INTERFACE (IMediaPlayerService, data, reply);
186138 pid_t pid = data.readInt32 ();
187139 sp<IMediaPlayerClient> client =
188140 interface_cast<IMediaPlayerClient>(data.readStrongBinder ());
189- const char * url = data.readCString ();
190-
191- KeyedVector<String8, String8> headers;
192- int32_t numHeaders = data.readInt32 ();
193- for (int i = 0 ; i < numHeaders; ++i) {
194- String8 key = data.readString8 ();
195- String8 value = data.readString8 ();
196- headers.add (key, value);
197- }
198- int audioSessionId = data.readInt32 ();
199-
200- sp<IMediaPlayer> player = create (
201- pid, client, url, numHeaders > 0 ? &headers : NULL , audioSessionId);
202-
203- reply->writeStrongBinder (player->asBinder ());
204- return NO_ERROR;
205- } break ;
206- case CREATE_FD: {
207- CHECK_INTERFACE (IMediaPlayerService, data, reply);
208- pid_t pid = data.readInt32 ();
209- sp<IMediaPlayerClient> client = interface_cast<IMediaPlayerClient>(data.readStrongBinder ());
210- int fd = dup (data.readFileDescriptor ());
211- int64_t offset = data.readInt64 ();
212- int64_t length = data.readInt64 ();
213141 int audioSessionId = data.readInt32 ();
214-
215- sp<IMediaPlayer> player = create (pid, client, fd, offset, length, audioSessionId);
142+ sp<IMediaPlayer> player = create (pid, client, audioSessionId);
216143 reply->writeStrongBinder (player->asBinder ());
217144 return NO_ERROR;
218145 } break ;
219- case CREATE_STREAM:
220- {
221- CHECK_INTERFACE (IMediaPlayerService, data, reply);
222-
223- pid_t pid = static_cast <pid_t >(data.readInt32 ());
224-
225- sp<IMediaPlayerClient> client =
226- interface_cast<IMediaPlayerClient>(data.readStrongBinder ());
227-
228- sp<IStreamSource> source =
229- interface_cast<IStreamSource>(data.readStrongBinder ());
230-
231- int audioSessionId = static_cast <int >(data.readInt32 ());
232-
233- sp<IMediaPlayer> player =
234- create (pid, client, source, audioSessionId);
235-
236- reply->writeStrongBinder (player->asBinder ());
237- return OK;
238- break ;
239- }
240146 case DECODE_URL: {
241147 CHECK_INTERFACE (IMediaPlayerService, data, reply);
242148 const char * url = data.readCString ();
0 commit comments