56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
/*
|
|
* Copyright (C) 2025 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 <sys/ioctl.h>
|
|
#include <fcntl.h>
|
|
#include <cerrno>
|
|
#include <unistd.h>
|
|
|
|
#include "VideoPipeAdapter.h"
|
|
#include "DispAdptLog.h"
|
|
|
|
VideoPipeAdapter::VideoPipeAdapter()
|
|
{
|
|
if (mDevFd < 0) {
|
|
mDevFd = open(ADAPTER_NAME, O_RDWR | O_NONBLOCK);
|
|
if (mDevFd < 0)
|
|
DISPLAY_LOGE("can not open %s, error: %d", ADAPTER_NAME, errno);
|
|
}
|
|
}
|
|
|
|
VideoPipeAdapter::~VideoPipeAdapter()
|
|
{
|
|
if (mDevFd >= 0)
|
|
close(mDevFd);
|
|
mDevFd = -1;
|
|
}
|
|
|
|
int VideoPipeAdapter::getVideoDelay(int fps, int outfps)
|
|
{
|
|
if (mDevFd < 0)
|
|
return -1;
|
|
|
|
struct video_delay_arg_t arg = { 0 };
|
|
|
|
arg.input_fps = fps;
|
|
arg.output_fps = outfps;
|
|
int ret = ioctl(mDevFd, VIDEO_PIPE_ADAPTER_GET_VIDEO_DELAY, &arg);
|
|
if (ret)
|
|
DISPLAY_LOGE("can not get video delay, error: %d", errno);
|
|
|
|
return arg.video_delay;
|
|
}
|