blob: bedeb6c78b66bada3c65f20e62703dbbe082736d [file] [log] [blame]
Jeff Browne1045962012-09-04 21:38:42 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <stdint.h>
18#include <sys/types.h>
19
20#include <media/IRemoteDisplayClient.h>
Andy McFadden8ba010212012-12-18 09:46:54 -080021#include <gui/IGraphicBufferProducer.h>
Jeff Browne1045962012-09-04 21:38:42 -070022#include <utils/String8.h>
23
24namespace android {
25
26enum {
27 ON_DISPLAY_CONNECTED = IBinder::FIRST_CALL_TRANSACTION,
28 ON_DISPLAY_DISCONNECTED,
29 ON_DISPLAY_ERROR,
30};
31
32class BpRemoteDisplayClient: public BpInterface<IRemoteDisplayClient>
33{
34public:
35 BpRemoteDisplayClient(const sp<IBinder>& impl)
36 : BpInterface<IRemoteDisplayClient>(impl)
37 {
38 }
39
Andy McFadden8ba010212012-12-18 09:46:54 -080040 void onDisplayConnected(const sp<IGraphicBufferProducer>& bufferProducer,
Chong Zhang87ecf192013-06-06 12:42:59 -070041 uint32_t width, uint32_t height, uint32_t flags, uint32_t session)
Jeff Browne1045962012-09-04 21:38:42 -070042 {
43 Parcel data, reply;
44 data.writeInterfaceToken(IRemoteDisplayClient::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -080045 data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jeff Browne1045962012-09-04 21:38:42 -070046 data.writeInt32(width);
47 data.writeInt32(height);
48 data.writeInt32(flags);
Chong Zhang87ecf192013-06-06 12:42:59 -070049 data.writeInt32(session);
Jeff Browne1045962012-09-04 21:38:42 -070050 remote()->transact(ON_DISPLAY_CONNECTED, data, &reply, IBinder::FLAG_ONEWAY);
51 }
52
53 void onDisplayDisconnected()
54 {
55 Parcel data, reply;
56 data.writeInterfaceToken(IRemoteDisplayClient::getInterfaceDescriptor());
57 remote()->transact(ON_DISPLAY_DISCONNECTED, data, &reply, IBinder::FLAG_ONEWAY);
58 }
59
60 void onDisplayError(int32_t error)
61 {
62 Parcel data, reply;
63 data.writeInterfaceToken(IRemoteDisplayClient::getInterfaceDescriptor());
64 data.writeInt32(error);
65 remote()->transact(ON_DISPLAY_ERROR, data, &reply, IBinder::FLAG_ONEWAY);
66 }
67};
68
69IMPLEMENT_META_INTERFACE(RemoteDisplayClient, "android.media.IRemoteDisplayClient");
70
71// ----------------------------------------------------------------------
72
73status_t BnRemoteDisplayClient::onTransact(
74 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
75{
76 switch (code) {
77 case ON_DISPLAY_CONNECTED: {
78 CHECK_INTERFACE(IRemoteDisplayClient, data, reply);
Andy McFadden8ba010212012-12-18 09:46:54 -080079 sp<IGraphicBufferProducer> surfaceTexture(
80 interface_cast<IGraphicBufferProducer>(data.readStrongBinder()));
Jeff Browne1045962012-09-04 21:38:42 -070081 uint32_t width = data.readInt32();
82 uint32_t height = data.readInt32();
83 uint32_t flags = data.readInt32();
Chong Zhang87ecf192013-06-06 12:42:59 -070084 uint32_t session = data.readInt32();
85 onDisplayConnected(surfaceTexture, width, height, flags, session);
Jeff Browne1045962012-09-04 21:38:42 -070086 return NO_ERROR;
87 }
88 case ON_DISPLAY_DISCONNECTED: {
89 CHECK_INTERFACE(IRemoteDisplayClient, data, reply);
90 onDisplayDisconnected();
91 return NO_ERROR;
92 }
93 case ON_DISPLAY_ERROR: {
94 CHECK_INTERFACE(IRemoteDisplayClient, data, reply);
95 int32_t error = data.readInt32();
96 onDisplayError(error);
97 return NO_ERROR;
98 }
99 default:
100 return BBinder::onTransact(code, data, reply, flags);
101 }
102}
103
Glenn Kasten40bc9062015-03-20 09:09:33 -0700104} // namespace android