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_LiveStreamer(NULL),
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
delete m_LiveStreamer;
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
cDevice *device = NULL;
|
|
|
|
if (ProvidesChannel(m_Channel, 0))
|
|
|
|
device = GetDevice(m_Channel, 0);
|
|
|
|
if (device != NULL) {
|
|
|
|
device->SwitchChannel(m_Channel, false);
|
|
|
|
m_LiveStreamer = new cStreamdevLiveStreamer(0, this);
|
|
|
|
if (m_LiveStreamer->SetChannel(m_Channel, m_StreamType)) {
|
|
|
|
m_LiveStreamer->SetDevice(device);
|
|
|
|
if (!SetDSCP())
|
|
|
|
LOG_ERROR_STR("unable to set DSCP sockopt");
|
|
|
|
Dprintf("streamer start\n");
|
|
|
|
m_LiveStreamer->Start(this);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
esyslog("streamdev-server IGMP: SetChannel failed");
|
|
|
|
DELETENULL(m_LiveStreamer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
esyslog("streamdev-server IGMP: GetDevice failed");
|
|
|
|
}
|
|
|
|
|
2009-02-13 11:39:20 +01:00
|
|
|
void cConnectionIGMP::Stop()
|
|
|
|
{
|
|
|
|
if (m_LiveStreamer) {
|
|
|
|
m_LiveStreamer->Stop();
|
|
|
|
DELETENULL(m_LiveStreamer);
|
|
|
|
}
|
|
|
|
}
|
2011-11-22 01:15:09 +01:00
|
|
|
|
|
|
|
cString cConnectionIGMP::ToText() const
|
|
|
|
{
|
|
|
|
cString str = cServerConnection::ToText();
|
|
|
|
return m_LiveStreamer ? cString::sprintf("%s\t%s", *str, *m_LiveStreamer->ToText()) : str;
|
|
|
|
}
|