2009-02-13 11:39:20 +01:00
|
|
|
/*
|
2010-12-02 09:57:17 +01:00
|
|
|
* $Id: connectionIGMP.c,v 1.3 2010/08/03 10:46:41 schmirl Exp $
|
2009-02-13 11:39:20 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include "server/connectionIGMP.h"
|
|
|
|
#include "server/server.h"
|
|
|
|
#include "server/setup.h"
|
|
|
|
#include <vdr/channels.h>
|
|
|
|
|
|
|
|
cConnectionIGMP::cConnectionIGMP(const char* Name, int ClientPort, eStreamType StreamType) :
|
|
|
|
cServerConnection(Name, SOCK_DGRAM),
|
|
|
|
m_ClientPort(ClientPort),
|
2011-10-18 08:50:54 +02:00
|
|
|
m_StreamType(StreamType),
|
|
|
|
m_Channel(NULL)
|
2009-02-13 11:39:20 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
cConnectionIGMP::~cConnectionIGMP()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-10-18 08:50:54 +02:00
|
|
|
bool cConnectionIGMP::SetChannel(cChannel *Channel, in_addr_t Dst)
|
2009-02-13 11:39:20 +01:00
|
|
|
{
|
2011-10-18 08:50:54 +02:00
|
|
|
if (Channel) {
|
|
|
|
m_Channel = Channel;
|
|
|
|
struct in_addr ip;
|
|
|
|
ip.s_addr = Dst;
|
|
|
|
if (Connect(inet_ntoa(ip), m_ClientPort))
|
|
|
|
return true;
|
2009-02-13 11:39:20 +01:00
|
|
|
else
|
2011-10-18 08:50:54 +02:00
|
|
|
esyslog("streamdev-server IGMP: Connect failed: %m");
|
|
|
|
return false;
|
2009-02-13 11:39:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
esyslog("streamdev-server IGMP: Channel not found");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-10-18 08:50:54 +02:00
|
|
|
void cConnectionIGMP::Welcome()
|
|
|
|
{
|
2014-06-07 00:24:27 +02:00
|
|
|
if (cStreamdevLiveStreamer::ProvidesChannel(m_Channel, StreamdevServerSetup.IGMPPriority)) {
|
|
|
|
cStreamdevLiveStreamer * liveStreamer = new cStreamdevLiveStreamer(this, m_Channel, StreamdevServerSetup.IGMPPriority, m_StreamType);
|
|
|
|
if (liveStreamer->GetDevice()) {
|
|
|
|
SetStreamer(liveStreamer);
|
2011-10-18 08:50:54 +02:00
|
|
|
if (!SetDSCP())
|
|
|
|
LOG_ERROR_STR("unable to set DSCP sockopt");
|
|
|
|
Dprintf("streamer start\n");
|
2014-05-18 18:16:51 +02:00
|
|
|
liveStreamer->Start(this);
|
2011-10-18 08:50:54 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-05-18 18:16:51 +02:00
|
|
|
SetStreamer(NULL);
|
2014-06-07 00:24:27 +02:00
|
|
|
delete liveStreamer;
|
|
|
|
esyslog("streamdev-server IGMP: SetChannel failed");
|
2011-10-18 08:50:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2013-11-01 15:33:19 +01:00
|
|
|
esyslog("streamdev-server IGMP: SwitchDevice failed");
|
2011-10-18 08:50:54 +02:00
|
|
|
}
|
|
|
|
|
2011-11-28 16:23:57 +01:00
|
|
|
bool cConnectionIGMP::Close()
|
2009-02-13 11:39:20 +01:00
|
|
|
{
|
2014-05-18 18:16:51 +02:00
|
|
|
if (Streamer())
|
|
|
|
Streamer()->Stop();
|
2011-11-28 16:23:57 +01:00
|
|
|
return cServerConnection::Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
cString cConnectionIGMP::ToText() const
|
|
|
|
{
|
|
|
|
cString str = cServerConnection::ToText();
|
2014-05-18 18:16:51 +02:00
|
|
|
return Streamer() ? cString::sprintf("%s\t%s", *str, *Streamer()->ToText()) : str;
|
2009-02-13 11:39:20 +01:00
|
|
|
}
|