整理代码

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

115
video/core/VideoDecoder.h Normal file
View file

@ -0,0 +1,115 @@
#ifndef ACE5DB6F_B3E6_42E2_8DAE_6D520F93DC50
#define ACE5DB6F_B3E6_42E2_8DAE_6D520F93DC50
/*
*******************************************************************************
* INCLUDE
*******************************************************************************
*/
#include "VideoComponent.h"
#include "AudioDecoder.h"
#include "CodecID.h"
#include "util/FactoryManager.h"
#include "util/Task.h"
#include <Poco/SharedPtr.h>
#include <functional>
namespace Video
{
namespace Core
{
/*
*******************************************************************************
* CLASS DECLARE
*******************************************************************************
*/
class VideoDecodeHandlerSelector
{
public:
static CodecID select(CodecID codec, VideoComponent::Ptr)
{
return codec;
}
};
class VideoDecodeHandler: public ::Util::FactoryManager<VideoDecodeHandler, CodecID, VideoDecodeHandlerSelector,
CodecID, VideoComponent::Ptr>
{
public:
using Ptr = Poco::SharedPtr<VideoDecodeHandler>;
public:
VideoDecodeHandler(const std::string& name, CodecID codecID, VideoComponent::Ptr pPrevious);
virtual ~VideoDecodeHandler();
public:
const std::string& name() const;
VideoComponent::Ptr previous() const;
virtual void write(Packet::Ptr pPacket) = 0;
virtual Frame::Ptr read() = 0;
private:
const std::string _name;
VideoComponent::Ptr _pPrevious;
};
inline const std::string& VideoDecodeHandler::name() const
{
return _name;
}
inline VideoComponent::Ptr VideoDecodeHandler::previous() const
{
return _pPrevious;
}
/*
*******************************************************************************
* CLASS DECLARE
*******************************************************************************
*/
class VideoDecoderSelector
{
public:
static int select(const std::string&)
{
return 0;
}
};
class VideoDecoder: public VideoComponent,
public ::Util::FactoryManager<VideoDecoder, int, VideoDecoderSelector, const std::string&>
{
public:
using Ptr = Poco::AutoPtr<VideoDecoder>;
public:
VideoDecoder(const std::string& name);
virtual ~VideoDecoder();
virtual void reset() {};
protected:
void start() override;
void stop() override;
virtual Frame::Ptr decode() = 0;
Packet::Ptr readPacket(uint32_t timeout = 4000);
void onLink(Core::Component::Ptr pPrevious) override;
void onUnlink(Core::Component::Ptr pPrevious) override;
Util::Task& task();
PROPERTY_DECLARE(AssociatedAudio, AudioDecoder::Ptr, nullptr, public, public)
private:
Util::Task _task;
};
inline Util::Task& VideoDecoder::task()
{
return _task;
}
}
}
#endif