1 /* 2 ** 3 ** Copyright 2007, 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 #define LOG_TAG "IMediaLogService" 19 //#define LOG_NDEBUG 0 20 21 #include <utils/Log.h> 22 #include <stdint.h> 23 #include <sys/types.h> 24 #include <binder/Parcel.h> 25 #include <media/IMediaLogService.h> 26 27 namespace android { 28 29 enum { 30 REGISTER_WRITER = IBinder::FIRST_CALL_TRANSACTION, 31 UNREGISTER_WRITER, 32 }; 33 34 class BpMediaLogService : public BpInterface<IMediaLogService> 35 { 36 public: 37 BpMediaLogService(const sp<IBinder>& impl) 38 : BpInterface<IMediaLogService>(impl) 39 { 40 } 41 42 virtual void registerWriter(const sp<IMemory>& shared, size_t size, const char *name) { 43 Parcel data, reply; 44 data.writeInterfaceToken(IMediaLogService::getInterfaceDescriptor()); 45 data.writeStrongBinder(IInterface::asBinder(shared)); 46 data.writeInt64((int64_t) size); 47 data.writeCString(name); 48 status_t status __unused = remote()->transact(REGISTER_WRITER, data, &reply); 49 // FIXME ignores status 50 } 51 52 virtual void unregisterWriter(const sp<IMemory>& shared) { 53 Parcel data, reply; 54 data.writeInterfaceToken(IMediaLogService::getInterfaceDescriptor()); 55 data.writeStrongBinder(IInterface::asBinder(shared)); 56 status_t status __unused = remote()->transact(UNREGISTER_WRITER, data, &reply); 57 // FIXME ignores status 58 } 59 60 }; 61 62 IMPLEMENT_META_INTERFACE(MediaLogService, "android.media.IMediaLogService"); 63 64 // ---------------------------------------------------------------------- 65 66 status_t BnMediaLogService::onTransact( 67 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 68 { 69 switch (code) { 70 71 case REGISTER_WRITER: { 72 CHECK_INTERFACE(IMediaLogService, data, reply); 73 sp<IMemory> shared = interface_cast<IMemory>(data.readStrongBinder()); 74 size_t size = (size_t) data.readInt64(); 75 const char *name = data.readCString(); 76 registerWriter(shared, size, name); 77 return NO_ERROR; 78 } 79 80 case UNREGISTER_WRITER: { 81 CHECK_INTERFACE(IMediaLogService, data, reply); 82 sp<IMemory> shared = interface_cast<IMemory>(data.readStrongBinder()); 83 unregisterWriter(shared); 84 return NO_ERROR; 85 } 86 87 default: 88 return BBinder::onTransact(code, data, reply, flags); 89 } 90 } 91 92 // ---------------------------------------------------------------------------- 93 94 } // namespace android 95