blob: 357de9d6b1cf467da032ddff8c8c47902f20a477 [file] [log] [blame]
Jeff Tinkerc0d5f1f2013-04-02 13:08:05 -07001/*
2**
3** Copyright 2013, 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_NDEBUG 0
19#define LOG_TAG "IDrmClient"
20#include <utils/Log.h>
21
22#include <utils/RefBase.h>
23#include <binder/IInterface.h>
24#include <binder/Parcel.h>
25
26#include <media/IMediaPlayerClient.h>
Jeff Tinker7d2c6e82018-02-16 16:14:59 -080027#include <mediadrm/IDrmClient.h>
Jeff Tinkerc0d5f1f2013-04-02 13:08:05 -070028
29namespace android {
30
31enum {
32 NOTIFY = IBinder::FIRST_CALL_TRANSACTION,
33};
34
35class BpDrmClient: public BpInterface<IDrmClient>
36{
37public:
Chih-Hung Hsieh090ef602016-04-27 10:39:54 -070038 explicit BpDrmClient(const sp<IBinder>& impl)
Jeff Tinkerc0d5f1f2013-04-02 13:08:05 -070039 : BpInterface<IDrmClient>(impl)
40 {
41 }
42
43 virtual void notify(DrmPlugin::EventType eventType, int extra, const Parcel *obj)
44 {
45 Parcel data, reply;
46 data.writeInterfaceToken(IDrmClient::getInterfaceDescriptor());
47 data.writeInt32((int)eventType);
48 data.writeInt32(extra);
49 if (obj && obj->dataSize() > 0) {
50 data.appendFrom(const_cast<Parcel *>(obj), 0, obj->dataSize());
51 }
52 remote()->transact(NOTIFY, data, &reply, IBinder::FLAG_ONEWAY);
53 }
54};
55
56IMPLEMENT_META_INTERFACE(DrmClient, "android.media.IDrmClient");
57
58// ----------------------------------------------------------------------
59
60status_t BnDrmClient::onTransact(
61 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
62{
63 switch (code) {
64 case NOTIFY: {
65 CHECK_INTERFACE(IDrmClient, data, reply);
66 int eventType = data.readInt32();
67 int extra = data.readInt32();
68 Parcel obj;
69 if (data.dataAvail() > 0) {
70 obj.appendFrom(const_cast<Parcel *>(&data), data.dataPosition(), data.dataAvail());
71 }
72
73 notify((DrmPlugin::EventType)eventType, extra, &obj);
74 return NO_ERROR;
75 } break;
76 default:
77 return BBinder::onTransact(code, data, reply, flags);
78 }
79}
80
Glenn Kasten40bc9062015-03-20 09:09:33 -070081} // namespace android