From a029466c2f9ee07889923105939081bb8c8d77ad Mon Sep 17 00:00:00 2001
From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期一, 17 四月 2017 14:01:28 +0800
Subject: [PATCH]
---
RtspFace/PL_Fork.cpp | 151 +++++++++++++++++++++++++++++++++++++-------------
1 files changed, 112 insertions(+), 39 deletions(-)
diff --git a/RtspFace/PL_Fork.cpp b/RtspFace/PL_Fork.cpp
index 9bf79c3..91af5a9 100644
--- a/RtspFace/PL_Fork.cpp
+++ b/RtspFace/PL_Fork.cpp
@@ -1,49 +1,122 @@
-#ifndef _PL_FORK_H_
-#define _PL_FORK_H_
+#include "PL_Fork.h"
+#include "MaterialBuffer.h"
+#include "logger.h"
-#include "PipeLine.h"
-
-struct PL_Fork_Config
+struct PL_Fork_Internal
{
+ //uint8_t buffer[1920*1080*4];
+ //size_t buffSize;
+ //size_t buffSizeMax;
+ PipeMaterial lastPm;
+
+ MB_Frame lastFrame;
+
+ PL_Fork_Config config;
+
+ bool payError;
+
+ PL_Fork_Internal() :
+ //buffSize(0), buffSizeMax(sizeof(buffer)),
+ lastPm(), lastFrame(), config(), payError(true)
+ {
+ }
+
+ ~PL_Fork_Internal()
+ {
+ }
+
+ void reset()
+ {
+ //buffSize = 0;
+ payError = true;
+
+ PipeMaterial _lastPm;
+ lastPm = _lastPm;
+
+ MB_Frame _lastFrame;
+ lastFrame = _lastFrame;
+
+ PL_Fork_Config _config;
+ config = _config;
+ }
};
-class PL_Fork : public PipeLineElem
+PipeLineElem* create_PL_Fork()
{
-public:
- enum ForkBy
+ return new PL_Fork;
+}
+
+PL_Fork::PL_Fork() : internal(new PL_Fork_Internal), pl(nullptr)
+{
+}
+
+PL_Fork::~PL_Fork()
+{
+ delete (PL_Fork_Internal*)internal;
+ internal= nullptr;
+}
+
+bool PL_Fork::init(void* args)
+{
+ PL_Fork_Internal* in = (PL_Fork_Internal*)internal;
+ in->reset();
+
+ if (args == nullptr)
{
- FB_NONE,
- FB_TURNS,
- FB_RANDOM,
- FB_PM_TYPE,
- FB_MB_TYPE,
- FB_BREAK_LIST
- };
+ LOG_ERROR << "Config should give" << std::endl;
+ return false;
+ }
+
+ PL_Fork_Config* config = (PL_Fork_Config*)args;
+ in->config = *config;
+
+ return true;
+}
+
+void PL_Fork::finit()
+{
+ PL_Fork_Internal* in = (PL_Fork_Internal*)internal;
+
+}
+
+bool PL_Fork::pay(const PipeMaterial& pm)
+{
+ PL_Fork_Internal* in = (PL_Fork_Internal*)internal;
+ PL_Fork_Config& config(in->config);
+
+ in->lastPm = pm;
- enum ForkSync
+ return false;
+}
+
+bool PL_Fork::gain(PipeMaterial& pm)
+{
+ PL_Fork_Internal* in = (PL_Fork_Internal*)internal;
+
+ return false;
+}
+
+void PL_Fork::attach_pipe_line(PipeLine* pl)
+{
+ PL_Fork_Internal* in = (PL_Fork_Internal*)internal;
+
+ if (this->pl != nullptr)
{
- FS_NONE,
- FS_SEQUENCE,
- FS_PARALLEL,
- FS_MAIN_PL_FIRST,
- FS_MAIN_PL_LAST,
- };
-
-public:
- PL_Fork();
- virtual ~PL_Fork();
-
- virtual bool init(void* args);
- virtual void finit();
-
- virtual bool pay(const PipeMaterial& pm);
- virtual bool gain(PipeMaterial& pm);
+ LOG_ERROR << "Has areadly attached pipe line" << std::endl;
+ return;
+ }
-private:
- void* internal;
-};
-
-PipeLineElem* create_PL_Paint();
-
-#endif
+ if (pl == nullptr)
+ {
+ LOG_NOTICE << "Detach pipe line" << std::endl;
+ this->pl->remove_elem(this);
+ this->pl = nullptr;
+ return;
+ }
+
+ this->pl = pl;
+ PipeLine* mainPipeLineManager = this->manager;
+ pl->push_front_elem(this);
+ this->manager = mainPipeLineManager;
+}
--
Gitblit v1.8.0