From 7f63f973141f973faff7896087697f5150332864 Mon Sep 17 00:00:00 2001
From: pans <pans@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期五, 30 十二月 2016 12:32:02 +0800
Subject: [PATCH] 

---
 RtspFace/PipeLine.h |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/RtspFace/PipeLine.h b/RtspFace/PipeLine.h
index 898e1f6..79e1984 100644
--- a/RtspFace/PipeLine.h
+++ b/RtspFace/PipeLine.h
@@ -12,13 +12,33 @@
 class PipeLineElem;
 class PipeLine;
 
+struct PipeMaterial;
+typedef void (* pm_deleter_func)(PipeMaterial* pm);
+
+// PipeMaterial instance should be unref when pay() finished
 struct PipeMaterial
 {
-	uint8_t* buffer;
+	enum PipeMaterialBufferType
+	{
+		PMT__FIRST,
+		PMT_NONE,     // buffer = nullptr, buffSize = 0
+		PMT_BYTES,    // buffer = uint8_t[N], buffSize = N
+		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;
+	void* buffer;
 	size_t buffSize;
 	PipeLineElem* former;
+	pm_deleter_func deleter;
+	void* args;
 	
 	PipeMaterial();
+	
+	void exec_deleter();
 };
 
 class PipeLineElem
@@ -41,11 +61,14 @@
 typedef PipeLineElem* (*elem_create_func_t)();
 
 // 0 (there is no elem). do nothing
-// 1 (there is one elem). gain
-// 2 (there is two elems). gain --> pay
-// 3 (there is more than two elems). gain --> pay gain --> pay gain --> ... --> pay
+// 1 (there is one elem). gain --> pm.deleter
+// 2 (there is two elems). gain --> pay --> pm.deleter
+// 3 (there is more than two elems). 
+//    gain --> [pay --> pm.deleter --> gain -->] [pay --> pm.deleter --> gain -->] ... --> pay --> pm.deleter
 class PipeLine
 {
+	friend class PipeDebugger;
+
 public:
 	PipeLine();
 	
@@ -57,6 +80,7 @@
 	PipeLineElem* push_elem(const std::string& type);
 	
 	// 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

--
Gitblit v1.8.0