Files

130 lines
3.6 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 "BinderServer.h"
#include "MesonVideoCompositor.h"
#include "DispAdptLog.h"
#define GET_DISPLAY(display) \
std::shared_ptr<MesonDisplay> mesonDisplay; \
std::map<int, std::shared_ptr<MesonDisplay>>::iterator it = \
mDisplays.find(display); \
if (it != mDisplays.end()) { \
mesonDisplay = it->second; \
} else {\
DISPLAY_LOGE("(%s) met invalid display id (%d)",\
__func__, (int)display); \
return MESON_ERROR_BAD_DISPLAY; \
}
mesonVideoCompositor::mesonVideoCompositor()
{
DispAdptLogInit();
for (uint32_t i = 0; i < 1; i ++) {
/*create meson2display*/
auto disp = std::make_shared<MesonDisplay>(i);
disp->initialize();
mDisplays.emplace(i, disp);
}
}
int mesonVideoCompositor::createLayer(int32_t displayId, int32_t* layerId)
{
int32_t id = 0;
int ret;
GET_DISPLAY(displayId);
ret = mesonDisplay->createLayer(id);
*layerId = id;
return ret;
}
int mesonVideoCompositor::destroyLayer(int32_t displayId, int32_t layerId)
{
GET_DISPLAY(displayId);
return mesonDisplay->destroyLayer(layerId);
}
int mesonVideoCompositor::setTunnelId(int32_t displayId, int32_t layerId, int32_t tunnelId)
{
GET_DISPLAY(displayId);
return mesonDisplay->setTunnelId(layerId, tunnelId);
}
int mesonVideoCompositor::setLayerIndex(int32_t displayId, int32_t layerId, int32_t index)
{
GET_DISPLAY(displayId);
return mesonDisplay->setLayerIndex(layerId, index);
}
int mesonVideoCompositor::setLayerZorder(int32_t displayId, int32_t layerId, int32_t zorder)
{
GET_DISPLAY(displayId);
return mesonDisplay->setLayerZorder(layerId, zorder);
}
int mesonVideoCompositor::setSourceCrop(int32_t displayId, int32_t layerId, struct rect crop)
{
GET_DISPLAY(displayId);
return mesonDisplay->setLayerSourceCrop(layerId, crop);
}
int mesonVideoCompositor::setDisplayFrame(int32_t displayId, int32_t layerId, struct rect frame)
{
drm_rect_t rect = { 0 };
GET_DISPLAY(displayId);
rect.left = frame.x;
rect.top = frame.y;
rect.right = frame.x + frame.w;
rect.bottom = frame.y + frame.h;
return mesonDisplay->setLayerDispFrame(layerId, rect);
}
int mesonVideoCompositor::getDelayLatency(int32_t displayId, int32_t layerId)
{
GET_DISPLAY(displayId);
return mesonDisplay->getVsyncDelayLatency(layerId);
}
int mesonVideoCompositor::setToMainPlane(int32_t displayId)
{
GET_DISPLAY(displayId);
return mesonDisplay->setVideoDisplaytoMainplane();
}
int mesonVideoCompositor::getUiSize(int32_t displayId, int32_t* width, int32_t* height)
{
GET_DISPLAY(displayId);
return mesonDisplay->getUiSize(width, height);
}
int main(int argc, char **argv) {
printf("main run\n");
std::shared_ptr<mesonVideoCompositor> meson = std::make_shared<mesonVideoCompositor>();
std::shared_ptr<BinderServer> binS = std::make_shared<BinderServer>();
binS->setMesonCompositor(meson);
binS->run(binS);
while (true) {
usleep(1000);
}
return 0;
}