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 REQUEST_MERGE_WAKEUP, 33 }; 34 35 class BpMediaLogService : public BpInterface<IMediaLogService> 36 { 37 public: 38 explicit BpMediaLogService(const sp<IBinder>& impl) 39 : BpInterface<IMediaLogService>(impl) 40 { 41 } 42 43 virtual void registerWriter(const sp<IMemory>& shared, size_t size, const char *name) { 44 Parcel data, reply; 45 data.writeInterfaceToken(IMediaLogService::getInterfaceDescriptor()); 46 data.writeStrongBinder(IInterface::asBinder(shared)); 47 data.writeInt64((int64_t) size); 48 data.writeCString(name); 49 status_t status __unused = remote()->transact(REGISTER_WRITER, data, &reply); 50 // FIXME ignores status 51 } 52 53 virtual void unregisterWriter(const sp<IMemory>& shared) { 54 Parcel data, reply; 55 data.writeInterfaceToken(IMediaLogService::getInterfaceDescriptor()); 56 data.writeStrongBinder(IInterface::asBinder(shared)); 57 status_t status __unused = remote()->transact(UNREGISTER_WRITER, data, &reply); 58 // FIXME ignores status 59 } 60 61 virtual void requestMergeWakeup() { 62 Parcel data, reply; 63 data.writeInterfaceToken(IMediaLogService::getInterfaceDescriptor()); 64 status_t status __unused = remote()->transact(REQUEST_MERGE_WAKEUP, data, &reply); 65 // FIXME ignores status 66 } 67 68 }; 69 70 IMPLEMENT_META_INTERFACE(MediaLogService, "android.media.IMediaLogService"); 71 72 // ---------------------------------------------------------------------- 73 74 status_t BnMediaLogService::onTransact( 75 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 76 { 77 switch (code) { 78 79 case REGISTER_WRITER: { 80 CHECK_INTERFACE(IMediaLogService, data, reply); 81 sp<IMemory> shared = interface_cast<IMemory>(data.readStrongBinder()); 82 size_t size = (size_t) data.readInt64(); 83 const char *name = data.readCString(); 84 registerWriter(shared, size, name); 85 return NO_ERROR; 86 } 87 88 case UNREGISTER_WRITER: { 89 CHECK_INTERFACE(IMediaLogService, data, reply); 90 sp<IMemory> shared = interface_cast<IMemory>(data.readStrongBinder()); 91 unregisterWriter(shared); 92 return NO_ERROR; 93 } 94 95 case REQUEST_MERGE_WAKEUP: { 96 CHECK_INTERFACE(IMediaLogService, data, reply); 97 requestMergeWakeup(); 98 return NO_ERROR; 99 } 100 101 default: 102 return BBinder::onTransact(code, data, reply, flags); 103 } 104 } 105 106 // ---------------------------------------------------------------------------- 107 108 } // namespace android 109