server_connectionVTP-add-filter-stream.patch by Petri Hintukainen

- Add new stream for section filters data
This commit is contained in:
schmirl 2007-04-24 11:40:35 +00:00
parent 9994ecfd08
commit d012504c3a

View File

@ -1,5 +1,5 @@
/* /*
* $Id: connectionVTP.c,v 1.11 2007/04/24 11:03:41 schmirl Exp $ * $Id: connectionVTP.c,v 1.12 2007/04/24 11:40:35 schmirl Exp $
*/ */
#include "server/connectionVTP.h" #include "server/connectionVTP.h"
@ -482,6 +482,8 @@ cConnectionVTP::~cConnectionVTP()
free(m_LastCommand); free(m_LastCommand);
delete m_LiveStreamer; delete m_LiveStreamer;
delete m_LiveSocket; delete m_LiveSocket;
delete m_FilterStreamer;
delete m_FilterSocket;
delete m_LSTTHandler; delete m_LSTTHandler;
delete m_LSTCHandler; delete m_LSTCHandler;
delete m_LSTEHandler; delete m_LSTEHandler;
@ -505,12 +507,14 @@ void cConnectionVTP::Reject(void)
void cConnectionVTP::Detach(void) 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) void cConnectionVTP::Attach(void)
{ {
if (m_LiveStreamer != NULL) m_LiveStreamer->Attach(); if (m_LiveStreamer) m_LiveStreamer->Attach();
if (m_FilterStreamer) m_FilterStreamer->Attach();
} }
bool cConnectionVTP::Command(char *Cmd) bool cConnectionVTP::Command(char *Cmd)
@ -578,6 +582,14 @@ bool cConnectionVTP::CmdCAPS(char *Opts)
return Respond(220, "Capability \"%s\" accepted", Opts); return Respond(220, "Capability \"%s\" accepted", Opts);
} }
#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); return Respond(561, "Capability \"%s\" not known", Opts);
} }
@ -610,9 +622,14 @@ bool cConnectionVTP::CmdPORT(char *Opts)
id = strtoul(Opts, &ep, 10); id = strtoul(Opts, &ep, 10);
if (ep == Opts || !isspace(*ep)) if (ep == Opts || !isspace(*ep))
return Respond(500, "Use: PORT Id Destination"); 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); return Respond(501, "Wrong connection id %d", id);
#else
if (id != siLive)
return Respond(501, "Wrong connection id %d", id);
#endif
Opts = skipspace(ep); Opts = skipspace(ep);
n = 0; n = 0;
@ -639,6 +656,33 @@ bool cConnectionVTP::CmdPORT(char *Opts)
isyslog("Streamdev: Setting data connection to %s:%d", dataip, dataport); 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;
if(m_LiveSocket && m_LiveStreamer) if(m_LiveSocket && m_LiveStreamer)
m_LiveStreamer->Stop(); m_LiveStreamer->Stop();
delete m_LiveSocket; delete m_LiveSocket;
@ -677,7 +721,16 @@ bool cConnectionVTP::CmdTUNE(char *Opts)
m_LiveStreamer->SetDevice(dev); m_LiveStreamer->SetDevice(dev);
if(m_LiveSocket) if(m_LiveSocket)
m_LiveStreamer->Start(m_LiveSocket); m_LiveStreamer->Start(m_LiveSocket);
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"); return Respond(220, "Channel tuned");
} }
@ -715,8 +768,8 @@ bool cConnectionVTP::CmdADDF(char *Opts)
int pid, tid, mask; int pid, tid, mask;
char *ep; char *ep;
if (m_LiveStreamer == NULL) if (m_FilterStreamer == NULL)
return Respond(560, "Can't set filters without a stream"); return Respond(560, "Can't set filters without a filter stream");
pid = strtol(Opts, &ep, 10); pid = strtol(Opts, &ep, 10);
if (ep == Opts || (*ep != ' ')) if (ep == Opts || (*ep != ' '))
@ -730,7 +783,7 @@ bool cConnectionVTP::CmdADDF(char *Opts)
if (ep == Opts || (*ep != '\0' && *ep != ' ')) if (ep == Opts || (*ep != '\0' && *ep != ' '))
return Respond(500, "Use: ADDF Pid Tid Mask"); return Respond(500, "Use: ADDF Pid Tid Mask");
return m_LiveStreamer->SetFilter(pid, tid, mask, true) return m_FilterStreamer->SetFilter(pid, tid, mask, true)
? Respond(220, "Filter %d transferring", pid) ? Respond(220, "Filter %d transferring", pid)
: Respond(560, "Filter %d not available", pid); : Respond(560, "Filter %d not available", pid);
#else #else
@ -744,7 +797,7 @@ bool cConnectionVTP::CmdDELF(char *Opts)
int pid, tid, mask; int pid, tid, mask;
char *ep; char *ep;
if (m_LiveStreamer == NULL) if (m_FilterStreamer == NULL)
return Respond(560, "Can't delete filters without a stream"); return Respond(560, "Can't delete filters without a stream");
pid = strtol(Opts, &ep, 10); pid = strtol(Opts, &ep, 10);
@ -759,9 +812,8 @@ bool cConnectionVTP::CmdDELF(char *Opts)
if (ep == Opts || (*ep != '\0' && *ep != ' ')) if (ep == Opts || (*ep != '\0' && *ep != ' '))
return Respond(500, "Use: DELF Pid Tid Mask"); return Respond(500, "Use: DELF Pid Tid Mask");
return m_LiveStreamer->SetFilter(pid, tid, mask, false) m_FilterStreamer->SetFilter(pid, tid, mask, false);
? Respond(220, "Filter %d stopped", pid) return Respond(220, "Filter %d stopped", pid);
: Respond(560, "Filter %d not transferring", pid);
#else #else
return Respond(500, "DELF known but unimplemented with VDR < 1.3.0"); return Respond(500, "DELF known but unimplemented with VDR < 1.3.0");
#endif #endif
@ -777,10 +829,22 @@ bool cConnectionVTP::CmdABRT(char *Opts)
return Respond(500, "Use: ABRT Id"); return Respond(500, "Use: ABRT Id");
switch (id) { 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"); return Respond(220, "Data connection closed");
} }