vdr-plugin-streamdev/server/connectionIGMP.c
Frank Schmirler afe255aa0b Added server menu with list of clients. Connections can be terminated
with the "red" key. The former main menu action of suspending live TV
moved to the "blue" key.

Squashed commit of the following:

commit 7175d7de91
Author: Frank Schmirler <vdr@schmirler.de>
Date:   Sun Nov 27 11:51:26 2011 +0100

    Updated README

commit 94aef85adc
Author: Frank Schmirler <vdr@schmirler.de>
Date:   Sun Nov 27 11:32:16 2011 +0100

    Moved "closing connection" log message to overload of cTBSocket::Close() in
    cServerConnection.

commit 9b91301d94
Author: Frank Schmirler <vdr@schmirler.de>
Date:   Fri Nov 25 00:24:37 2011 +0100

    Don't keep a pointer to the connection in components MulticastGroup
    structure as the connection may now be deleted from outside via menu.

commit 7347e24123
Author: Frank Schmirler <vdr@schmirler.de>
Date:   Thu Nov 24 23:45:59 2011 +0100

    Fixed missing Display() call after disconnecting a client.

commit c652e8fa81
Author: Frank Schmirler <vdr@schmirler.de>
Date:   Tue Nov 22 01:15:09 2011 +0100

    Added server menu with list of clients. Connections can be terminated
    with the "red" key. The former main menu action of suspending live TV
    moved to the "blue" key.
2011-11-28 16:23:57 +01:00

79 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_LiveStreamer(NULL),
m_ClientPort(ClientPort),
m_StreamType(StreamType),
m_Channel(NULL)
{
}
cConnectionIGMP::~cConnectionIGMP()
{
delete m_LiveStreamer;
}
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, 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");
}
bool cConnectionIGMP::Close()
{
if (m_LiveStreamer)
m_LiveStreamer->Stop();
return cServerConnection::Close();
}
cString cConnectionIGMP::ToText() const
{
cString str = cServerConnection::ToText();
return m_LiveStreamer ? cString::sprintf("%s\t%s", *str, *m_LiveStreamer->ToText()) : str;
}