Index: connectionVTP.c
===================================================================
RCS file: /var/cvsroot/streamdev/server/connectionVTP.c,v
retrieving revision 1.9
diff -u -2 -r1.9 connectionVTP.c
--- connectionVTP.c	16 Apr 2007 11:01:02 -0000	1.9
+++ connectionVTP.c	23 Apr 2007 17:39:10 -0000
@@ -481,4 +483,6 @@
 	delete m_LiveStreamer;
 	delete m_LiveSocket;
+	delete m_FilterStreamer;
+	delete m_FilterSocket;
 	delete m_LSTTHandler;
 	delete m_LSTCHandler;
@@ -499,10 +508,12 @@
 void cConnectionVTP::Detach(void) 
 {
-	if (m_LiveStreamer != NULL) m_LiveStreamer->Detach();
+	if (m_LiveStreamer) m_LiveStreamer->Detach();
+	if (m_FilterStreamer) m_FilterStreamer->Detach();
 }
 
 void cConnectionVTP::Attach(void) 
 {
-	if (m_LiveStreamer != NULL) m_LiveStreamer->Attach();
+	if (m_LiveStreamer) m_LiveStreamer->Attach();
+	if (m_FilterStreamer) m_FilterStreamer->Attach();
 }
 
@@ -572,4 +583,12 @@
 	}
 
+#if VDRVERSNUM >= 10300
+	//
+	// Deliver section filters data in separate, channel-independent data stream
+	//
+	if (strcasecmp(Opts, "FILTERS") == 0)
+		return Respond(220, "Capability \"%s\" accepted", Opts);
+#endif
+
 	return Respond(561, "Capability \"%s\" not known", Opts);
 }
@@ -604,7 +623,12 @@
 	if (ep == Opts || !isspace(*ep))
 		return Respond(500, "Use: PORT Id Destination");
-
-	if (id != 0)
+	
+#if VDRVERSNUM >= 10300
+	if (id != siLive && id != siLiveFilter)
+		return Respond(501, "Wrong connection id %d", id);
+#else
+	if (id != siLive)
 		return Respond(501, "Wrong connection id %d", id);
+#endif
 	
 	Opts = skipspace(ep);
@@ -633,4 +657,31 @@
 	isyslog("Streamdev: Setting data connection to %s:%d", dataip, dataport);
 
+#if VDRVERSNUM >= 10300
+	if (id == siLiveFilter) {
+		if(m_FilterStreamer)
+			m_FilterStreamer->Stop();
+		delete m_FilterSocket;
+
+		m_FilterSocket = new cTBSocket(SOCK_STREAM);
+		if (!m_FilterSocket->Connect(dataip, dataport)) {
+			esyslog("ERROR: Streamdev: Couldn't open data connection to %s:%d: %s",
+				dataip, dataport, strerror(errno));
+			DELETENULL(m_FilterSocket);
+			return Respond(551, "Couldn't open data connection");
+		}
+
+		if(!m_FilterStreamer)
+			m_FilterStreamer = new cStreamdevFilterStreamer;
+		m_FilterStreamer->Start(m_FilterSocket);
+		m_FilterStreamer->Activate(true);
+
+		return Respond(220, "Port command ok, data connection opened");
+	}
+#endif
+
+	if(m_LiveSocket && m_LiveStreamer)
+		m_LiveStreamer->Stop();
+	delete m_LiveSocket;
+
 	m_LiveSocket = new cTBSocket(SOCK_STREAM);
 	if (!m_LiveSocket->Connect(dataip, dataport)) {
@@ -641,8 +692,8 @@
 	}
 
-	if (id == siLive)
+	if(m_LiveStreamer)
 		m_LiveStreamer->Start(m_LiveSocket);
 
-  return Respond(220, "Port command ok, data connection opened");
+	return Respond(220, "Port command ok, data connection opened");
 }
 
@@ -665,5 +721,14 @@
 	m_LiveStreamer->SetChannel(chan, m_NoTSPIDS ? stTS : stTSPIDS);
 	m_LiveStreamer->SetDevice(dev);
+	if(m_LiveSocket)
+		m_LiveStreamer->Start(m_LiveSocket);
 	
+#if VDRVERSNUM >= 10300
+	if(!m_FilterStreamer)
+		m_FilterStreamer = new cStreamdevFilterStreamer;
+	m_FilterStreamer->SetDevice(dev);
+	//m_FilterStreamer->SetChannel(chan);
+#endif
+
 	return Respond(220, "Channel tuned");
 }
@@ -703,6 +768,6 @@
 	char *ep;
 
-	if (m_LiveStreamer == NULL)
-		return Respond(560, "Can't set filters without a stream");
+	if (m_FilterStreamer == NULL)
+		return Respond(560, "Can't set filters without a filter stream");
 	
 	pid = strtol(Opts, &ep, 10);
@@ -718,7 +783,7 @@
 		return Respond(500, "Use: ADDF Pid Tid Mask");
 
-	return m_LiveStreamer->SetFilter(pid, tid, mask, true)
-			? Respond(220, "Filter %d transferring", pid)
-			: Respond(560, "Filter %d not available", pid);
+	return m_FilterStreamer->SetFilter(pid, tid, mask, true)
+	     ? Respond(220, "Filter %d transferring", pid)
+	     : Respond(560, "Filter %d not available", pid);
 #else
 	return Respond(500, "ADDF known but unimplemented with VDR < 1.3.0");
@@ -732,5 +797,5 @@
 	char *ep;
 	
-	if (m_LiveStreamer == NULL)
+	if (m_FilterStreamer == NULL)
 		return Respond(560, "Can't delete filters without a stream");
 	
@@ -747,7 +812,6 @@
 		return Respond(500, "Use: DELF Pid Tid Mask");
 
-	return m_LiveStreamer->SetFilter(pid, tid, mask, false)
-			? Respond(220, "Filter %d stopped", pid)
-			: Respond(560, "Filter %d not transferring", pid);
+	m_FilterStreamer->SetFilter(pid, tid, mask, false);
+	return  Respond(220, "Filter %d stopped", pid);
 #else
 	return Respond(500, "DELF known but unimplemented with VDR < 1.3.0");
@@ -766,6 +830,18 @@
 	switch (id) {
-	case 0: DELETENULL(m_LiveStreamer); break;
+	case siLive: 
+		DELETENULL(m_LiveStreamer); 
+		DELETENULL(m_LiveSocket);
+		break;
+#if VDRVERSNUM >= 10300
+	case siLiveFilter:
+	        DELETENULL(m_FilterStreamer);
+		DELETENULL(m_FilterSocket);
+		break;
+#endif
+	default:
+		return Respond(501, "Wrong connection id %d", id);
+		break;
+
 	}
 
-	DELETENULL(m_LiveSocket);
 	return Respond(220, "Data connection closed");
