整理代码

This commit is contained in:
蒲爽 2026-09-28 21:33:04 +08:00
commit c7b4e178ec
364 changed files with 59691 additions and 0 deletions

View file

@ -0,0 +1,73 @@
/*
*******************************************************************************
* INCLUDE
*******************************************************************************
*/
#include "HDMIFrontend.h"
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <iostream>
namespace Video
{
namespace ITE
{
/*
*******************************************************************************
* CLASS DEFINE
*******************************************************************************
*/
HDMIFrontend::HDMIFrontend(std::string device): Core::Frontend("HDMIFrontend"), _it66021(device), _path(device)
{
_hdmiInfo.have_audio = false;
_hdmiInfo.have_video = false;
_it66021.readInfo(_hdmiInfo);
_pollCancelled = false;
_pollThread.startFunc(
[&]() -> void
{
while (!_pollCancelled)
{
unsigned int revents = 0;
if (_it66021.poll(revents, 1000))
{
if (revents & POLLIN)
{
_it66021.readInfo(_hdmiInfo);
notifyStatusChanged();
}
}
}
});
}
HDMIFrontend::~HDMIFrontend()
{
if (_pollThread.isRunning())
{
_pollCancelled = true;
_pollThread.join();
}
}
void HDMIFrontend::read(MediaInfo& info)
{
info.haveVideo = _hdmiInfo.have_video;
info.haveAudio = _hdmiInfo.have_audio;
info.video.width = _hdmiInfo.hactive;
info.video.height = _hdmiInfo.vactive;
info.video.frameRate = _hdmiInfo.frame_rate;
if (_hdmiInfo.scanmode == 0)
info.video.scanMode = Core::VideoScanMode::PROGRESSIVE;
else
info.video.scanMode = Core::VideoScanMode::INTERLACED;
info.audio.sampleRate = _hdmiInfo.sample_rate;
}
}
}

40
video/ite/HDMIFrontend.h Normal file
View file

@ -0,0 +1,40 @@
#ifndef FEFC9D0D_1536_4204_B19D_636AC379D2CA
#define FEFC9D0D_1536_4204_B19D_636AC379D2CA
/*
*******************************************************************************
* INCLUDE
*******************************************************************************
*/
#include "../core/Frontend.h"
#include "IT66021.h"
#include <Poco/Thread.h>
#include <atomic>
namespace Video
{
namespace ITE
{
/*
*******************************************************************************
* CLASS DECLARE
*******************************************************************************
*/
class HDMIFrontend: public Core::Frontend
{
public:
HDMIFrontend(std::string device);
~HDMIFrontend();
public:
virtual void read(MediaInfo& info) override;
private:
IT66021 _it66021;
std::string _path;
Poco::Thread _pollThread;
std::atomic<bool> _pollCancelled;
IT66021::Info _hdmiInfo;
};
}
}
#endif

29
video/ite/IT66021.cpp Normal file
View file

@ -0,0 +1,29 @@
/*
*******************************************************************************
* INCLUDE
*******************************************************************************
*/
#include "IT66021.h"
namespace Video
{
namespace ITE
{
/*
*******************************************************************************
* CLASS DEFINE
*******************************************************************************
*/
IT66021::IT66021(std::string device): Util::Device(device, Util::Device::Mode::RDWR)
{
open();
}
void IT66021::readInfo(Info& info)
{
read((uint8_t*)&info, sizeof(info));
}
}
}

51
video/ite/IT66021.h Normal file
View file

@ -0,0 +1,51 @@
#ifndef C9FA4497_8D5C_418E_9024_63D07C7F6E95
#define C9FA4497_8D5C_418E_9024_63D07C7F6E95
/*
*******************************************************************************
* INCLUDE
*******************************************************************************
*/
#include "util/Device.h"
namespace Video
{
namespace ITE
{
/*
*******************************************************************************
* CLASS DECLARE
*******************************************************************************
*/
class IT66021: public Util::Device
{
public:
struct Info
{
bool have_video;
uint32_t hactive;
uint32_t vactive;
uint32_t htotal;
uint32_t vtotal;
uint64_t pclk;
uint32_t hfront_porch;
uint32_t hsync_width;
uint32_t hback_porch;
uint32_t vfront_porch;
uint32_t vsync_width;
uint32_t vback_porch;
uint32_t scanmode;
uint32_t vpolarity;
uint32_t hpolarity;
uint32_t frame_rate;
bool have_audio;
uint32_t sample_rate;
};
public:
IT66021(std::string device = "/dev/it66021");
void readInfo(Info& info);
};
}
}
#endif