The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2008, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include <utils/RefBase.h> |
Mathias Agopian | 0795272 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 19 | #include <binder/IInterface.h> |
| 20 | #include <binder/Parcel.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | |
| 22 | #include <media/IMediaPlayerClient.h> |
| 23 | |
| 24 | namespace android { |
| 25 | |
| 26 | enum { |
| 27 | NOTIFY = IBinder::FIRST_CALL_TRANSACTION, |
| 28 | }; |
| 29 | |
| 30 | class BpMediaPlayerClient: public BpInterface<IMediaPlayerClient> |
| 31 | { |
| 32 | public: |
| 33 | BpMediaPlayerClient(const sp<IBinder>& impl) |
| 34 | : BpInterface<IMediaPlayerClient>(impl) |
| 35 | { |
| 36 | } |
| 37 | |
Gloria Wang | 162ee49 | 2011-04-11 17:23:27 -0700 | [diff] [blame] | 38 | virtual void notify(int msg, int ext1, int ext2, const Parcel *obj) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | { |
| 40 | Parcel data, reply; |
| 41 | data.writeInterfaceToken(IMediaPlayerClient::getInterfaceDescriptor()); |
| 42 | data.writeInt32(msg); |
| 43 | data.writeInt32(ext1); |
| 44 | data.writeInt32(ext2); |
Gloria Wang | 162ee49 | 2011-04-11 17:23:27 -0700 | [diff] [blame] | 45 | if (obj && obj->dataSize() > 0) { |
| 46 | data.appendFrom(const_cast<Parcel *>(obj), 0, obj->dataSize()); |
| 47 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | remote()->transact(NOTIFY, data, &reply, IBinder::FLAG_ONEWAY); |
| 49 | } |
| 50 | }; |
| 51 | |
niko | dcd810d | 2009-06-22 08:49:52 -0700 | [diff] [blame] | 52 | IMPLEMENT_META_INTERFACE(MediaPlayerClient, "android.media.IMediaPlayerClient"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | |
| 54 | // ---------------------------------------------------------------------- |
| 55 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | status_t BnMediaPlayerClient::onTransact( |
| 57 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 58 | { |
| 59 | switch(code) { |
| 60 | case NOTIFY: { |
| 61 | CHECK_INTERFACE(IMediaPlayerClient, data, reply); |
| 62 | int msg = data.readInt32(); |
| 63 | int ext1 = data.readInt32(); |
| 64 | int ext2 = data.readInt32(); |
Gloria Wang | 162ee49 | 2011-04-11 17:23:27 -0700 | [diff] [blame] | 65 | Parcel obj; |
| 66 | if (data.dataAvail() > 0) { |
| 67 | obj.appendFrom(const_cast<Parcel *>(&data), data.dataPosition(), data.dataAvail()); |
| 68 | } |
| 69 | |
| 70 | notify(msg, ext1, ext2, &obj); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | return NO_ERROR; |
| 72 | } break; |
| 73 | default: |
| 74 | return BBinder::onTransact(code, data, reply, flags); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | }; // namespace android |