From 5cf652629fb40796cd2e0ab17c3617ed52365473 Mon Sep 17 00:00:00 2001
From: pans <pans@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期五, 18 八月 2017 10:32:05 +0800
Subject: [PATCH] capnp client fix bug
---
RtspFace/PipeLine.h | 89 +++++++++++++++++++++++++++++++++-----------
1 files changed, 66 insertions(+), 23 deletions(-)
diff --git a/RtspFace/PipeLine.h b/RtspFace/PipeLine.h
index 2a59df7..4bf3c43 100644
--- a/RtspFace/PipeLine.h
+++ b/RtspFace/PipeLine.h
@@ -8,28 +8,40 @@
#define PLGP_RTSP_SDP "RTSP_SDP"
#define PLGP_RTSP_FMTP "RTSP_FMTP"
+#define PLGP_RTSP_WIDTH "RTSP_WIDTH"
+#define PLGP_RTSP_HEIGHT "RTSP_HEIGHT"
+#define PLGP_RTSP_FPS "RTSP_FPS"
+#define PLGP_DEC_SPS_B64 "DEC_SPS_B64"
+#define PLGP_DEC_PPS_B64 "DEC_PPS_B64"
+#define PLGP_ENC_SPS_B64 "ENC_SPS_B64"
+#define PLGP_ENC_PPS_B64 "ENC_PPS_B64"
+
+#define ENABLE_PIPELINE_ELEM_TIMING_DEBUGGER
class PipeLineElem;
class PipeLine;
-enum PipeMaterialBufferType
-{
- PMT__FIRST,
- PMT_BYTES,
- PMT_TEXT,
- PMT_IMAGE,
- PMT_PM_LIST,
- PMT_PTR_AVFRAME,
- PMT__LAST
-};
-
struct PipeMaterial;
-typedef void (* pm_deleter_func)(PipeMaterial* pm);
+typedef void (* pm_deleter_func)(PipeMaterial* pm, bool lastRet);
+typedef bool (* pm_breaker_func)(const PipeMaterial* pm, void* args); // return true if continue breaking up
+// PipeMaterial instance should be unref when pay() finished
struct PipeMaterial
{
+ enum PipeMaterialBufferType
+ {
+ PMT__FIRST,
+ PMT_NONE, // buffer = nullptr, buffSize = 0
+ PMT_BYTES, // buffer = uint8_t[N], buffSize = N
+ PMT_PTR, // buffer = void*, buffSize = 0
+ PMT_FRAME, // buffer = MB_Frame*, buffSize = 0
+ PMT_PM_LIST, // buffer = PipeMaterial*[N], buffSize = N
+ PMT_FRAME_LIST, // buffer = MB_Frame*[N], buffSize = N
+ PMT__LAST
+ };
+
PipeMaterialBufferType type;
- uint8_t* buffer;
+ void* buffer;
size_t buffSize;
PipeLineElem* former;
pm_deleter_func deleter;
@@ -37,7 +49,19 @@
PipeMaterial();
- void exec_deleter();
+ void exec_deleter(bool lastRet);
+
+ void reset()
+ {
+ PipeMaterial _temp;
+ *this = _temp;
+ }
+
+ int breake(PipeMaterialBufferType selectPmType, int _selectMbfType, pm_breaker_func breaker, void* args = nullptr) const;
+ int breake(int _selectMbfUsage, pm_breaker_func breaker, void* args = nullptr) const;
+
+ //#todo assemble pm/mbf into this pm
+ void assemble();
};
class PipeLineElem
@@ -58,6 +82,7 @@
};
typedef PipeLineElem* (*elem_create_func_t)();
+typedef void (*elem_destory_func_t)(PipeLineElem* elem);
// 0 (there is no elem). do nothing
// 1 (there is one elem). gain --> pm.deleter
@@ -66,6 +91,8 @@
// gain --> [pay --> pm.deleter --> gain -->] [pay --> pm.deleter --> gain -->] ... --> pay --> pm.deleter
class PipeLine
{
+ friend class PipeDebugger;
+
public:
PipeLine();
@@ -73,29 +100,45 @@
~PipeLine();
bool register_elem_creator(const std::string& type, elem_create_func_t func);
+ static bool register_global_elem_creator(const std::string& type, elem_create_func_t func);
+
void push_elem(PipeLineElem* elem);
PipeLineElem* push_elem(const std::string& type);
+ void push_front_elem(PipeLineElem* elem);
+ bool remove_elem(PipeLineElem* elem);
+ PipeLineElem* at(int idx);
+
+ void finit(elem_destory_func_t elem_destory_func);
+
+ bool check_pipe_complete(PipeLineElem* lastRetElem) const;
// do pipe sync. returns the element who returns false, or the last one.
+ // if false return, the element should deal with pm, clean up.
PipeLineElem* pipe(PipeMaterial* pm = nullptr);
- // do pipe async
- void pipe_start();
- void pipe_notify(PipeLineElem*);
- void pipe_stop();
-
- void set_global_param(const std::string& name, const std::string& value);
- std::string get_global_param(const std::string& name) const;
+ void set_param(const std::string& name, const std::string& value);
+ std::string get_param(const std::string& name) const;
private:
typedef std::map<const std::string, elem_create_func_t> elem_create_func_map_t;
elem_create_func_map_t elem_create_func_map;
+ static elem_create_func_map_t global_elem_create_func_map;
typedef std::vector<PipeLineElem*> elem_vec_t;
elem_vec_t elems;
- typedef std::map<const std::string, std::string> global_params_map_t;
- global_params_map_t global_params_map;
+ typedef std::map<const std::string, std::string> params_map_t;
+ params_map_t params_map;
+};
+
+class PipeLineElemTimingDebugger
+{
+public:
+ PipeLineElemTimingDebugger(const PipeLineElem* _elem = nullptr);
+ ~PipeLineElemTimingDebugger();
+
+ const PipeLineElem* elem;
+ uint64_t beginTime;
};
#endif
--
Gitblit v1.8.0