123 lines
4.2 KiB
C++
123 lines
4.2 KiB
C++
#ifndef CF63EDDC_B464_4F43_9D68_4B200F07DD82
|
|
#define CF63EDDC_B464_4F43_9D68_4B200F07DD82
|
|
/*
|
|
*******************************************************************************
|
|
* INCLUDE
|
|
*******************************************************************************
|
|
*/
|
|
#include "MPPChannel.h"
|
|
#include "VideoFrame.h"
|
|
#include "../../core/VideoDecoder.h"
|
|
#include "../../core/CodecCapabilityManager.h"
|
|
#include "../../core/FrameSynchronizer.h"
|
|
#include <functional>
|
|
#include "util/Broadcast.h"
|
|
|
|
namespace Video
|
|
{
|
|
namespace MPP5
|
|
{
|
|
/*
|
|
*******************************************************************************
|
|
* CLASS DECLARE
|
|
*******************************************************************************
|
|
*/
|
|
class VideoDecoder: public MPPChannel,
|
|
public Core::VideoDecoder
|
|
{
|
|
private:
|
|
class Pipe: public MPPChannel
|
|
{
|
|
public:
|
|
Pipe(const std::string& name, uint32_t id);
|
|
~Pipe();
|
|
|
|
public:
|
|
void start(uint32_t width, uint32_t height);
|
|
void stop();
|
|
void write(VideoFrame& frame, uint64_t pts, uint32_t timeref, bool isFrozen, hi_video_frame_info& frameX);
|
|
|
|
uint32_t groupID() const;
|
|
const std::string& name() const;
|
|
|
|
const uint32_t width();
|
|
const uint32_t height();
|
|
|
|
private:
|
|
const std::string _name;
|
|
uint32_t _width;
|
|
uint32_t _height;
|
|
};
|
|
|
|
enum class PostTaskControl
|
|
{
|
|
RUNNING,
|
|
EXIT,
|
|
INSTANT_EXIT,
|
|
};
|
|
|
|
public:
|
|
VideoDecoder(const std::string& name);
|
|
~VideoDecoder();
|
|
void reset() override;
|
|
|
|
protected:
|
|
void start() override;
|
|
void stop() override;
|
|
void initialize() override;
|
|
void deinitialize() override;
|
|
void onConfigChanged(ParameterNames& names) override;
|
|
|
|
Core::Frame::Ptr decode() override;
|
|
|
|
void bind(const MPPChannel& next) override;
|
|
void unbind(const MPPChannel& next) override;
|
|
|
|
void sendUserFrame(VideoFrame::Ptr pFrame, uint64_t duration, uint32_t& timeref);
|
|
void runSendUserFrame(VideoFrame::Ptr pFrame, std::function<bool(void)> condition);
|
|
void runSignalLost(std::atomic<bool>& isCancelled);
|
|
void runFault(std::atomic<bool>& isCancelled);
|
|
Core::Packet::Ptr runExceptionProcedure(std::atomic<bool>& isCancelled);
|
|
bool handleSerialCode(const Core::SerialCode& code);
|
|
void handlePreviousChanged();
|
|
void decodePacket(Core::Packet::Ptr pPacket, std::atomic<bool>& isCancelled);
|
|
void createDecoder(uint32_t width, uint32_t height, uint32_t frameRate, Core::CodecID codecID);
|
|
void releaseDecoder(bool instant = false);
|
|
Core::Packet::Ptr tryReadPacket(uint32_t timeout, bool shuldLog);
|
|
void releaseCapabilityHandle();
|
|
void frameCopy(hi_video_frame_info& from, hi_video_frame_info& to);
|
|
void frameRelease(hi_video_frame_info& frame);
|
|
bool saveSingleFrame(hi_video_frame_info& frame, const std::string& dir_path);
|
|
bool loadVideoFrame(const std::string& dir_path, hi_video_frame_info& frame);
|
|
|
|
private:
|
|
Core::CodecCapabilityManager::Handle _handle;
|
|
Pipe _pipe;
|
|
::Util::Task _postTask;
|
|
std::atomic<PostTaskControl> _postTaskControl;
|
|
uint32_t _frameTimeRef = 2;
|
|
Core::FrameSynchronizer _synchronizer;
|
|
const uint32_t _channelId;
|
|
hi_video_frame_info _frameX;
|
|
bool _frozenPlay;
|
|
bool _firstPic;
|
|
bool _buttonPressed;
|
|
bool _lastStatus;
|
|
|
|
bool _catchUpEnabled;
|
|
bool _isCatchingUp;
|
|
void updateCatchUpState();
|
|
|
|
PROPERTY_DECLARE(UsingCapability, Core::CodecID, Core::CodecID::NB, private, private)
|
|
|
|
public:
|
|
static void initModule();
|
|
static void deinitModule();
|
|
|
|
private:
|
|
static Core::CodecCapabilityManager _vdhCapabilityManager;
|
|
static Core::CodecCapabilityManager _jpgdCapabilityManager;
|
|
};
|
|
}
|
|
}
|
|
#endif
|