整理代码

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

118
video/core/VideoMixer.h Normal file
View file

@ -0,0 +1,118 @@
#ifndef D84CC9FA_711B_4439_A0F8_424C43E082CB
#define D84CC9FA_711B_4439_A0F8_424C43E082CB
/*
*******************************************************************************
* INCLUDE
*******************************************************************************
*/
#include "VideoComponent.h"
#include "util/FactoryManager.h"
#include <unordered_map>
namespace Video
{
namespace Core
{
/*
*******************************************************************************
* CLASS DECLARE
*******************************************************************************
*/
class VideoMixerSelector
{
public:
static int select(const std::string&)
{
return 0;
}
};
class VideoMixer: public VideoComponent,
public ::Util::FactoryManager<VideoMixer, int, VideoMixerSelector, const std::string&>
{
public:
using Ptr = Poco::AutoPtr<VideoMixer>;
class Channel: public VideoComponent
{
public:
using Ptr = Poco::AutoPtr<Channel>;
struct Region
{
double x;
double y;
double width;
double height;
bool operator==(const Region& other) const
{
return std::abs(x - other.x) < 1e-9 && std::abs(y - other.y) < 1e-9 &&
std::abs(width - other.width) < 1e-9 && std::abs(height - other.height) < 1e-9;
}
bool operator!=(const Region& other) const
{
return !(this->operator==(other));
}
};
protected:
Channel(const std::string& name, VideoMixer::Ptr, uint32_t id);
public:
~Channel();
CONFIGURABLE_DECLARE_PARAMETER(Region, Region)
CONFIGURABLE_DECLARE_PARAMETER(ZOrder, int)
CONFIGURABLE_DECLARE_PARAMETER(Attach, bool)
CONFIGURABLE_DECLARE_PARAMETER(Input, VideoComponent::Ptr)
uint32_t id() const;
protected:
void onConfigChanged(ParameterNames& names) override;
VideoMixer::Ptr mixer();
private:
VideoMixer::Ptr _pMixer;
uint32_t _id;
friend VideoMixer;
};
public:
VideoMixer(const std::string& name);
~VideoMixer();
Channel::Ptr getChannel(uint32_t id);
protected:
void start() override;
void stop() override;
virtual Channel::Ptr createChannel(uint32_t id) = 0;
template <class T, typename F> void foreachChannel(F&&);
private:
std::unordered_map<uint32_t, Channel::Ptr> _channels;
};
inline uint32_t VideoMixer::Channel::id() const
{
return _id;
}
inline VideoMixer::Ptr VideoMixer::Channel::mixer()
{
return _pMixer;
}
template <class T, typename F> inline void VideoMixer::foreachChannel(F&& exec)
{
for (auto m : _channels)
exec(m.second.cast<T>());
}
}
}
#endif