blob: 15363375b90b5c10060ce1d4ba49996701f4fe63 [file] [log] [blame]
Glenn Kastenfdf4e4f2013-01-18 15:31:41 -08001/*
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
27namespace android {
28
29enum {
30 REGISTER_WRITER = IBinder::FIRST_CALL_TRANSACTION,
31 UNREGISTER_WRITER,
32};
33
34class BpMediaLogService : public BpInterface<IMediaLogService>
35{
36public:
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());
Marco Nelissen06b46062014-11-14 07:58:25 -080045 data.writeStrongBinder(IInterface::asBinder(shared));
Glenn Kastene03dd222014-01-28 11:04:39 -080046 data.writeInt64((int64_t) size);
Glenn Kastenfdf4e4f2013-01-18 15:31:41 -080047 data.writeCString(name);
Lajos Molnarf1063e22015-04-17 15:19:42 -070048 status_t status __unused = remote()->transact(REGISTER_WRITER, data, &reply);
Glenn Kastenfdf4e4f2013-01-18 15:31:41 -080049 // FIXME ignores status
50 }
51
52 virtual void unregisterWriter(const sp<IMemory>& shared) {
53 Parcel data, reply;
54 data.writeInterfaceToken(IMediaLogService::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -080055 data.writeStrongBinder(IInterface::asBinder(shared));
Lajos Molnarf1063e22015-04-17 15:19:42 -070056 status_t status __unused = remote()->transact(UNREGISTER_WRITER, data, &reply);
Glenn Kastenfdf4e4f2013-01-18 15:31:41 -080057 // FIXME ignores status
58 }
59
60};
61
62IMPLEMENT_META_INTERFACE(MediaLogService, "android.media.IMediaLogService");
63
64// ----------------------------------------------------------------------
65
66status_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());
Glenn Kastene03dd222014-01-28 11:04:39 -080074 size_t size = (size_t) data.readInt64();
Glenn Kastenfdf4e4f2013-01-18 15:31:41 -080075 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
Glenn Kasten40bc9062015-03-20 09:09:33 -070094} // namespace android