198 lines
5.3 KiB
C++
198 lines
5.3 KiB
C++
/*
|
|
* Copyright (C) 2024 Amlogic Corporation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
*
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
#include <binder/IPCThreadState.h>
|
|
#include <binder/ProcessState.h>
|
|
#include <binder/IServiceManager.h>
|
|
|
|
#include "binderInfo.h"
|
|
#include "BinderClient.h"
|
|
|
|
BinderClient::BinderClient()
|
|
{
|
|
sp<ProcessState> proc(ProcessState::self());
|
|
proc->startThreadPool();
|
|
Parcel send, reply;
|
|
|
|
sp<IServiceManager> serviceManager = defaultServiceManager();
|
|
do {
|
|
mServicebinder = serviceManager->getService(String16("compositor-service"));
|
|
printf("%s mServicebinder is %p\n", __FUNCTION__, mServicebinder.get());
|
|
if (mServicebinder != 0) break;
|
|
printf("BinderClient: Waiting mesonvideo-service published.\n");
|
|
usleep(500000);
|
|
} while (true);
|
|
|
|
send.writeStrongBinder(sp<BinderClient>(this));
|
|
int ret = mServicebinder->transact(CMD_SEND_CLIENT, send, &reply);
|
|
if (ret < 0)
|
|
printf("transact binder fail\n");
|
|
}
|
|
|
|
int BinderClient::createLayer(int32_t displayId, int32_t *layerId)
|
|
{
|
|
Parcel send, reply;
|
|
int ret = -1;
|
|
|
|
if (mServicebinder != NULL) {
|
|
send.writeInt32(displayId);
|
|
ret = mServicebinder->transact(CMD_CREATE_LAYER, send, &reply);
|
|
if (!ret)
|
|
*layerId = reply.readInt32();
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int BinderClient::destroyLayer(int32_t displayId, int32_t layerId)
|
|
{
|
|
Parcel send, reply;
|
|
int ret = -1;
|
|
|
|
if (mServicebinder != NULL) {
|
|
send.writeInt32(displayId);
|
|
send.writeInt32(layerId);
|
|
ret = mServicebinder->transact(CMD_DESTROY_LAYER, send, &reply);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int BinderClient::setTunnelId(int32_t displayId, int32_t layerId, int32_t tunnelId)
|
|
{
|
|
Parcel send, reply;
|
|
int ret = -1;
|
|
|
|
if (mServicebinder != NULL) {
|
|
send.writeInt32(displayId);
|
|
send.writeInt32(layerId);
|
|
send.writeInt32(tunnelId);
|
|
ret = mServicebinder->transact(CMD_SET_TUNNEL_ID, send, &reply);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int BinderClient::setLayerIndex(int32_t displayId, int32_t layerId, int32_t index)
|
|
{
|
|
Parcel send, reply;
|
|
int ret = -1;
|
|
|
|
if (mServicebinder != NULL) {
|
|
send.writeInt32(displayId);
|
|
send.writeInt32(layerId);
|
|
send.writeInt32(index);
|
|
ret = mServicebinder->transact(CMD_SET_LAYER_INDEX, send, &reply);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int BinderClient::setLayerZorder(int32_t displayId, int32_t layerId, int32_t zorder)
|
|
{
|
|
Parcel send, reply;
|
|
int ret = -1;
|
|
|
|
if (mServicebinder != NULL) {
|
|
send.writeInt32(displayId);
|
|
send.writeInt32(layerId);
|
|
send.writeInt32(zorder);
|
|
ret = mServicebinder->transact(CMD_SET_LAYER_ZORDER, send, &reply);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int BinderClient::setSourceCrop(int32_t displayId, int32_t layerId, struct rect crop)
|
|
{
|
|
Parcel send, reply;
|
|
int ret = -1;
|
|
|
|
if (mServicebinder != NULL) {
|
|
send.writeInt32(displayId);
|
|
send.writeInt32(layerId);
|
|
send.writeInt32(crop.x);
|
|
send.writeInt32(crop.y);
|
|
send.writeInt32(crop.w);
|
|
send.writeInt32(crop.h);
|
|
ret = mServicebinder->transact(CMD_SET_SOURCE_CROP, send, &reply);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int BinderClient::setDisplayFrame(int32_t displayId, int32_t layerId, struct rect frame)
|
|
{
|
|
Parcel send, reply;
|
|
int ret = -1;
|
|
|
|
if (mServicebinder != NULL) {
|
|
send.writeInt32(displayId);
|
|
send.writeInt32(layerId);
|
|
send.writeInt32(frame.x);
|
|
send.writeInt32(frame.y);
|
|
send.writeInt32(frame.w);
|
|
send.writeInt32(frame.h);
|
|
ret = mServicebinder->transact(CMD_SET_DISPLAY_FRAME, send, &reply);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int BinderClient::getDelayLatency(int32_t displayId, int32_t layerId)
|
|
{
|
|
Parcel send, reply;
|
|
int ret = -1;
|
|
|
|
if (mServicebinder != NULL) {
|
|
send.writeInt32(displayId);
|
|
send.writeInt32(layerId);
|
|
ret = mServicebinder->transact(CMD_GET_DELAY_LATENCY, send, &reply);
|
|
if (!ret)
|
|
ret = reply.readInt32();
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int BinderClient::setToMainPlane(int32_t displayId)
|
|
{
|
|
Parcel send, reply;
|
|
int ret = -1;
|
|
|
|
if (mServicebinder != NULL) {
|
|
send.writeInt32(displayId);
|
|
ret = mServicebinder->transact(CMD_SET_MAIN_PLANE, send, &reply);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
status_t BinderClient::onTransact(uint32_t code,
|
|
const Parcel& data, Parcel* reply,
|
|
uint32_t flags) {
|
|
return BBinder::onTransact(code, data, reply, flags);
|
|
}
|
|
|
|
int BinderClient::getUiSize(int32_t displayId, int32_t &width, int32_t &height)
|
|
{
|
|
Parcel send, reply;
|
|
int ret = -1;
|
|
|
|
if (mServicebinder != NULL) {
|
|
send.writeInt32(displayId);
|
|
|
|
ret = mServicebinder->transact(CMD_GET_UI_SIZE, send, &reply);
|
|
if (ret == 0) {
|
|
width = reply.readInt32();
|
|
height = reply.readInt32();
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|