mirror of
https://projects.vdr-developer.org/git/vdr-plugin-streamdev.git
synced 2023-10-10 19:16:51 +02:00
77 lines
1.8 KiB
C
77 lines
1.8 KiB
C
/*
|
|
* $Id: connectionIGMP.c,v 1.3 2010/08/03 10:46:41 schmirl Exp $
|
|
*/
|
|
|
|
#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),
|
|
m_StreamType(StreamType),
|
|
m_Channel(NULL)
|
|
{
|
|
}
|
|
|
|
cConnectionIGMP::~cConnectionIGMP()
|
|
{
|
|
}
|
|
|
|
bool cConnectionIGMP::SetChannel(cChannel *Channel, in_addr_t Dst)
|
|
{
|
|
if (Channel) {
|
|
m_Channel = Channel;
|
|
struct in_addr ip;
|
|
ip.s_addr = Dst;
|
|
if (Connect(inet_ntoa(ip), m_ClientPort))
|
|
return true;
|
|
else
|
|
esyslog("streamdev-server IGMP: Connect failed: %m");
|
|
return false;
|
|
}
|
|
else
|
|
esyslog("streamdev-server IGMP: Channel not found");
|
|
return false;
|
|
}
|
|
|
|
void cConnectionIGMP::Welcome()
|
|
{
|
|
cDevice *device = NULL;
|
|
if (ProvidesChannel(m_Channel, StreamdevServerSetup.IGMPPriority))
|
|
device = SwitchDevice(m_Channel, StreamdevServerSetup.IGMPPriority);
|
|
if (device != NULL) {
|
|
cStreamdevLiveStreamer * liveStreamer = new cStreamdevLiveStreamer(StreamdevServerSetup.IGMPPriority, this);
|
|
SetStreamer(liveStreamer);
|
|
if (liveStreamer->SetChannel(m_Channel, m_StreamType)) {
|
|
liveStreamer->SetDevice(device);
|
|
if (!SetDSCP())
|
|
LOG_ERROR_STR("unable to set DSCP sockopt");
|
|
Dprintf("streamer start\n");
|
|
liveStreamer->Start(this);
|
|
}
|
|
else {
|
|
esyslog("streamdev-server IGMP: SetChannel failed");
|
|
SetStreamer(NULL);
|
|
}
|
|
}
|
|
else
|
|
esyslog("streamdev-server IGMP: SwitchDevice failed");
|
|
}
|
|
|
|
bool cConnectionIGMP::Close()
|
|
{
|
|
if (Streamer())
|
|
Streamer()->Stop();
|
|
return cServerConnection::Close();
|
|
}
|
|
|
|
cString cConnectionIGMP::ToText() const
|
|
{
|
|
cString str = cServerConnection::ToText();
|
|
return Streamer() ? cString::sprintf("%s\t%s", *str, *Streamer()->ToText()) : str;
|
|
}
|