mirror of
https://projects.vdr-developer.org/git/vdr-plugin-streamdev.git
synced 2023-10-10 17:16:51 +00:00
- transfer
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: component.c,v 1.1 2004/12/30 22:44:18 lordjaxom Exp $
|
||||
* $Id: component.c,v 1.2 2005/02/08 17:22:35 lordjaxom Exp $
|
||||
*/
|
||||
|
||||
#include "server/component.h"
|
||||
@@ -38,7 +38,7 @@ cServerConnection *cServerComponent::CanAct(const cTBSelect &Select) {
|
||||
cServerConnection *client = NewConnection();
|
||||
if (client->Accept(m_Listen)) {
|
||||
isyslog("Streamdev: Accepted new client (%s) %s:%d", m_Protocol,
|
||||
(const char*)client->RemoteIp(), client->RemotePort());
|
||||
client->RemoteIp().c_str(), client->RemotePort());
|
||||
return client;
|
||||
} else {
|
||||
esyslog("Streamdev: Couldn't accept (%s): %s", m_Protocol,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: connection.c,v 1.1 2004/12/30 22:44:19 lordjaxom Exp $
|
||||
* $Id: connection.c,v 1.2 2005/02/08 17:22:35 lordjaxom Exp $
|
||||
*/
|
||||
|
||||
#include "server/connection.h"
|
||||
@@ -27,13 +27,13 @@ bool cServerConnection::CanAct(const cTBSelect &Select) {
|
||||
int b;
|
||||
if ((b = Read(m_RdBuf + m_RdBytes, sizeof(m_RdBuf) - m_RdBytes - 1)) < 0) {
|
||||
esyslog("Streamdev: Read from client (%s) %s:%d failed: %s", m_Protocol,
|
||||
(const char*)RemoteIp(), RemotePort(), strerror(errno));
|
||||
RemoteIp().c_str(), RemotePort(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (b == 0) {
|
||||
isyslog("Streamdev: Client (%s) %s:%d closed connection", m_Protocol,
|
||||
(const char*)RemoteIp(), RemotePort());
|
||||
RemoteIp().c_str(), RemotePort());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ bool cServerConnection::CanAct(const cTBSelect &Select) {
|
||||
int b;
|
||||
if ((b = Write(m_WrBuf + m_WrOffs, m_WrBytes - m_WrOffs)) < 0) {
|
||||
esyslog("Streamdev: Write to client (%s) %s:%d failed: %s", m_Protocol,
|
||||
(const char*)RemoteIp(), RemotePort(), strerror(errno));
|
||||
RemoteIp().c_str(), RemotePort(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -85,18 +85,18 @@ bool cServerConnection::ParseBuffer(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cServerConnection::Respond(const char *Message) {
|
||||
uint len = strlen(Message);
|
||||
if (m_WrBytes + len + 2 > sizeof(m_WrBuf)) {
|
||||
bool cServerConnection::Respond(const std::string &Message) {
|
||||
if (m_WrBytes + Message.size() + 2 > sizeof(m_WrBuf)) {
|
||||
esyslog("Streamdev: Output buffer overflow (%s) for %s:%d", m_Protocol,
|
||||
(const char*)RemoteIp(), RemotePort());
|
||||
RemoteIp().c_str(), RemotePort());
|
||||
return false;
|
||||
}
|
||||
Dprintf("OUT: |%s|\n", Message);
|
||||
memcpy(m_WrBuf + m_WrBytes, Message, len);
|
||||
m_WrBuf[m_WrBytes + len] = '\015';
|
||||
m_WrBuf[m_WrBytes + len + 1] = '\012';
|
||||
m_WrBytes += len + 2;
|
||||
Dprintf("OUT: |%s|\n", Message.c_str());
|
||||
memcpy(m_WrBuf + m_WrBytes, Message.c_str(), Message.size());
|
||||
|
||||
m_WrBytes += Message.size();
|
||||
m_WrBuf[m_WrBytes++] = '\015';
|
||||
m_WrBuf[m_WrBytes++] = '\012';
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: connection.h,v 1.1 2004/12/30 22:44:19 lordjaxom Exp $
|
||||
* $Id: connection.h,v 1.2 2005/02/08 17:22:35 lordjaxom Exp $
|
||||
*/
|
||||
|
||||
#ifndef VDR_STREAMDEV_SERVER_CONNECTION_H
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
|
||||
/* Will put Message into the response queue, which will be sent in the next
|
||||
server cycle. Note that Message will be line-terminated by Respond */
|
||||
bool Respond(const char *Message);
|
||||
bool Respond(const std::string &Message);
|
||||
|
||||
/* Will make the socket close after sending all queued output data */
|
||||
void DeferClose(void) { m_DeferClose = true; }
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: connectionHTTP.c,v 1.3 2005/02/08 15:34:38 lordjaxom Exp $
|
||||
* $Id: connectionHTTP.c,v 1.4 2005/02/08 17:22:35 lordjaxom Exp $
|
||||
*/
|
||||
|
||||
#include "server/connectionHTTP.h"
|
||||
@@ -63,7 +63,7 @@ bool cConnectionHTTP::Command(char *Cmd) {
|
||||
|| m_Channel->Vpid() == 1 || m_Channel->Vpid() == 0x1FFF)) {
|
||||
return Respond("HTTP/1.0 200 OK")
|
||||
&& Respond("Content-Type: audio/mpeg")
|
||||
&& Respond((cTBString)"icy-name: " + m_Channel->Name())
|
||||
&& Respond((std::string)"icy-name: " + m_Channel->Name())
|
||||
&& Respond("");
|
||||
} else {
|
||||
return Respond("HTTP/1.0 200 OK")
|
||||
@@ -86,20 +86,20 @@ bool cConnectionHTTP::Command(char *Cmd) {
|
||||
|
||||
void cConnectionHTTP::Flushed(void) {
|
||||
if (m_Status == hsListing) {
|
||||
cTBString line;
|
||||
|
||||
if (m_ListChannel == NULL) {
|
||||
Respond("</ul></body></html>");
|
||||
DeferClose();
|
||||
return;
|
||||
}
|
||||
|
||||
std::string line;
|
||||
if (m_ListChannel->GroupSep())
|
||||
line.Format("<li>--- %s ---</li>", m_ListChannel->Name());
|
||||
line = (std::string)"<li>--- " + m_ListChannel->Name() + "---</li>";
|
||||
else
|
||||
line.Format("<li><a href=\"http://%s:%d/%s\">%s</a></li>",
|
||||
(const char*)LocalIp(), StreamdevServerSetup.HTTPServerPort,
|
||||
(const char*)m_ListChannel->GetChannelID().ToString(), m_ListChannel->Name());
|
||||
line = (std::string)"<li><a href=\"http://" + LocalIp() + ":"
|
||||
+ (const char*)itoa(StreamdevServerSetup.HTTPServerPort) + "/"
|
||||
+ (const char*)m_ListChannel->GetChannelID().ToString() + "\">"
|
||||
+ m_ListChannel->Name() + "</a></li>";
|
||||
if (!Respond(line))
|
||||
DeferClose();
|
||||
m_ListChannel = Channels.Next(m_ListChannel);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: connectionVTP.c,v 1.3 2005/02/08 15:34:38 lordjaxom Exp $
|
||||
* $Id: connectionVTP.c,v 1.4 2005/02/08 17:22:35 lordjaxom Exp $
|
||||
*/
|
||||
|
||||
#include "server/connectionVTP.h"
|
||||
@@ -82,13 +82,13 @@ bool cConnectionVTP::Command(char *Cmd) {
|
||||
else if (strcasecmp(Cmd, "NEWT") == 0) return CmdNEWT(ep);
|
||||
else if (strcasecmp(Cmd, "DELT") == 0) return CmdDELT(ep);
|
||||
else
|
||||
return Respond(500, (cTBString)"Unknown Command '" + Cmd + "'");
|
||||
return Respond(500, (std::string)"Unknown Command '" + Cmd + "'");
|
||||
}
|
||||
|
||||
bool cConnectionVTP::CmdCAPS(char *Opts) {
|
||||
if (strcasecmp(Opts, "TSPIDS") == 0)
|
||||
return Respond(220, (cTBString)"Capability \"" + Opts + "\" accepted");
|
||||
return Respond(561, (cTBString)"Capability \"" + Opts + "\" not known");
|
||||
return Respond(220, (std::string)"Capability \"" + Opts + "\" accepted");
|
||||
return Respond(561, (std::string)"Capability \"" + Opts + "\" not known");
|
||||
}
|
||||
|
||||
bool cConnectionVTP::CmdPROV(char *Opts) {
|
||||
@@ -102,7 +102,7 @@ bool cConnectionVTP::CmdPROV(char *Opts) {
|
||||
|
||||
Opts = skipspace(ep);
|
||||
if ((chan = ChannelFromString(Opts)) == NULL)
|
||||
return Respond(550, (cTBString)"Undefined channel \"" + Opts + "\"");
|
||||
return Respond(550, (std::string)"Undefined channel \"" + Opts + "\"");
|
||||
|
||||
return GetDevice(chan, prio) != NULL
|
||||
? Respond(220, "Channel available")
|
||||
@@ -120,7 +120,7 @@ bool cConnectionVTP::CmdPORT(char *Opts) {
|
||||
return Respond(500, "Use: PORT Id Destination");
|
||||
|
||||
if (id >= si_Count)
|
||||
return Respond(501, "Wrong connection id " + cTBString::Number(id));
|
||||
return Respond(501, (std::string)"Wrong connection id " + (const char*)itoa(id));
|
||||
|
||||
Opts = skipspace(ep);
|
||||
n = 0;
|
||||
@@ -166,7 +166,7 @@ bool cConnectionVTP::CmdTUNE(char *Opts) {
|
||||
cDevice *dev;
|
||||
|
||||
if ((chan = ChannelFromString(Opts)) == NULL)
|
||||
return Respond(550, (cTBString)"Undefined channel \"" + Opts + "\"");
|
||||
return Respond(550, (std::string)"Undefined channel \"" + Opts + "\"");
|
||||
|
||||
if ((dev = GetDevice(chan, 0)) == NULL)
|
||||
return Respond(560, "Channel not available");
|
||||
@@ -191,8 +191,8 @@ bool cConnectionVTP::CmdADDP(char *Opts) {
|
||||
return Respond(500, "Use: ADDP Pid");
|
||||
|
||||
return m_LiveStreamer && m_LiveStreamer->SetPid(pid, true)
|
||||
? Respond(220, "Pid " + cTBString::Number(pid) + " available")
|
||||
: Respond(560, "Pid " + cTBString::Number(pid) + " not available");
|
||||
? Respond(220, (std::string)"Pid " + (const char*)itoa(pid) + " available")
|
||||
: Respond(560, (std::string)"Pid " + (const char*)itoa(pid) + " not available");
|
||||
}
|
||||
|
||||
bool cConnectionVTP::CmdDELP(char *Opts) {
|
||||
@@ -204,8 +204,8 @@ bool cConnectionVTP::CmdDELP(char *Opts) {
|
||||
return Respond(500, "Use: DELP Pid");
|
||||
|
||||
return m_LiveStreamer && m_LiveStreamer->SetPid(pid, false)
|
||||
? Respond(220, "Pid " + cTBString::Number(pid) + " stopped")
|
||||
: Respond(560, "Pid " + cTBString::Number(pid) + " not transferring");
|
||||
? Respond(220, (std::string)"Pid " + (const char*)itoa(pid) + " stopped")
|
||||
: Respond(560, (std::string)"Pid " + (const char*)itoa(pid) + " not transferring");
|
||||
}
|
||||
|
||||
bool cConnectionVTP::CmdADDF(char *Opts) {
|
||||
@@ -229,8 +229,8 @@ bool cConnectionVTP::CmdADDF(char *Opts) {
|
||||
return Respond(500, "Use: ADDF Pid Tid Mask");
|
||||
|
||||
return m_LiveStreamer->SetFilter(pid, tid, mask, true)
|
||||
? Respond(220, "Filter " + cTBString::Number(pid) + " transferring")
|
||||
: Respond(560, "Filter " + cTBString::Number(pid) + " not available");
|
||||
? Respond(220, (std::string)"Filter " + (const char*)itoa(pid) + " transferring")
|
||||
: Respond(560, (std::string)"Filter " + (const char*)itoa(pid) + " not available");
|
||||
#else
|
||||
return Respond(500, "ADDF known but unimplemented with VDR < 1.3.0");
|
||||
#endif
|
||||
@@ -257,8 +257,8 @@ bool cConnectionVTP::CmdDELF(char *Opts) {
|
||||
return Respond(500, "Use: DELF Pid Tid Mask");
|
||||
|
||||
return m_LiveStreamer->SetFilter(pid, tid, mask, false)
|
||||
? Respond(220, "Filter " + cTBString::Number(pid) + " stopped")
|
||||
: Respond(560, "Filter " + cTBString::Number(pid) + " not transferring");
|
||||
? Respond(220, (std::string)"Filter " + (const char*)itoa(pid) + " stopped")
|
||||
: Respond(560, (std::string)"Filter " + (const char*)itoa(pid) + " not transferring");
|
||||
#else
|
||||
return Respond(500, "DELF known but unimplemented with VDR < 1.3.0");
|
||||
#endif
|
||||
@@ -530,12 +530,12 @@ bool cConnectionVTP::CmdDELT(char *Option) {
|
||||
EXIT_WRAPPER();
|
||||
}
|
||||
|
||||
bool cConnectionVTP::Respond(int Code, const char *Message) {
|
||||
cTBString pkt;
|
||||
if (Code < 0)
|
||||
pkt.Format("%03d-%s", -Code, Message);
|
||||
else
|
||||
pkt.Format("%03d %s", Code, Message);
|
||||
return cServerConnection::Respond((const char*)pkt);
|
||||
bool cConnectionVTP::Respond(int Code, const std::string &Message) {
|
||||
char *buffer;
|
||||
bool result;
|
||||
asprintf(&buffer, "%03d%c%s", Code < 0 ? -Code : Code, Code < 0 ? '-' : ' ', Message.c_str());
|
||||
result = cServerConnection::Respond(buffer);
|
||||
free(buffer);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
bool CmdNEWT(char *Opts);
|
||||
bool CmdDELT(char *Opts);
|
||||
|
||||
bool Respond(int Code, const char *Message);
|
||||
bool Respond(int Code, const std::string &Message);
|
||||
};
|
||||
|
||||
#endif // VDR_STREAMDEV_SERVERS_CONNECTIONVTP_H
|
||||
|
@@ -155,8 +155,7 @@ bool cStreamdevLiveStreamer::SetFilter(u_short Pid, u_char Tid, u_char Mask,
|
||||
#endif
|
||||
}
|
||||
|
||||
uchar *cStreamdevLiveStreamer::Process(const uchar *Data, int &Count,
|
||||
int &Result) {
|
||||
uchar *cStreamdevLiveStreamer::Process(const uchar *Data, int &Count, int &Result) {
|
||||
uchar *remuxed = m_Remux != NULL ? m_Remux->Process(Data, Count, Result)
|
||||
: cStreamdevStreamer::Process(Data, Count, Result);
|
||||
if (remuxed) {
|
||||
@@ -186,18 +185,18 @@ uchar *cStreamdevLiveStreamer::Process(const uchar *Data, int &Count,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cTBString cStreamdevLiveStreamer::Report(void) {
|
||||
cTBString result;
|
||||
std::string cStreamdevLiveStreamer::Report(void) {
|
||||
std::string result;
|
||||
|
||||
if (m_Device != NULL)
|
||||
result += "+- Device is " + cTBString::Number(m_Device->CardIndex()) + "\n";
|
||||
result += (std::string)"+- Device is " + (const char*)itoa(m_Device->CardIndex()) + "\n";
|
||||
if (m_Receiver != NULL)
|
||||
result += "+- Receiver is allocated\n";
|
||||
|
||||
result += "+- Pids are ";
|
||||
for (int i = 0; i < MAXRECEIVEPIDS; ++i)
|
||||
if (m_Pids[i] != 0)
|
||||
result += cTBString::Number(m_Pids[i]) + ", ";
|
||||
result += (std::string)(const char*)itoa(m_Pids[i]) + ", ";
|
||||
result += "\n";
|
||||
return result;
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ public:
|
||||
virtual void Start(cTBSocket *Socket);
|
||||
|
||||
// Statistical purposes:
|
||||
virtual cTBString Report(void);
|
||||
virtual std::string Report(void);
|
||||
};
|
||||
|
||||
#endif // VDR_STREAMDEV_LIVESTREAMER_H
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: server.c,v 1.1 2004/12/30 22:44:20 lordjaxom Exp $
|
||||
* $Id: server.c,v 1.2 2005/02/08 17:22:35 lordjaxom Exp $
|
||||
*/
|
||||
|
||||
#include "server/server.h"
|
||||
@@ -106,11 +106,11 @@ void cStreamdevServer::Action(void) {
|
||||
|
||||
if (m_Clients.Count() > StreamdevServerSetup.MaxClients) {
|
||||
esyslog("Streamdev: Too many clients, rejecting %s:%d",
|
||||
(const char*)client->RemoteIp(), client->RemotePort());
|
||||
client->RemoteIp().c_str(), client->RemotePort());
|
||||
client->Reject();
|
||||
} else if (!StreamdevHosts.Acceptable(client->RemoteIpAddr())) {
|
||||
esyslog("Streamdev: Client from %s:%d not allowed to connect",
|
||||
(const char*)client->RemoteIp(), client->RemotePort());
|
||||
client->RemoteIp().c_str(), client->RemotePort());
|
||||
client->Reject();
|
||||
} else
|
||||
client->Welcome();
|
||||
@@ -122,7 +122,7 @@ void cStreamdevServer::Action(void) {
|
||||
cServerConnection *next = m_Clients.Next(s);
|
||||
if (!s->CanAct(select)) {
|
||||
isyslog("Streamdev: Closing connection to %s:%d",
|
||||
(const char*)s->RemoteIp(), s->RemotePort());
|
||||
s->RemoteIp().c_str(), s->RemotePort());
|
||||
s->Close();
|
||||
m_Clients.Del(s);
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: streamer.c,v 1.2 2005/02/08 13:59:16 lordjaxom Exp $
|
||||
* $Id: streamer.c,v 1.3 2005/02/08 17:22:35 lordjaxom Exp $
|
||||
*/
|
||||
|
||||
#include <vdr/ringbuffer.h>
|
||||
@@ -16,10 +16,8 @@
|
||||
#define VIDEOBUFSIZE MEGABYTE(4)
|
||||
#define MAXBLOCKSIZE TS_SIZE*10
|
||||
|
||||
cStreamdevStreamer::cStreamdevStreamer(const char *Name)
|
||||
#if VDRVERSNUM >= 10300
|
||||
:cThread("Streamdev: " + (cTBString)Name)
|
||||
#endif
|
||||
cStreamdevStreamer::cStreamdevStreamer(const char *Name):
|
||||
cThread(((std::string)"Streamdev: " + Name).c_str())
|
||||
{
|
||||
m_Active = false;
|
||||
m_Receivers = 0;
|
||||
|
Reference in New Issue
Block a user