MythTV  master
mmulticastsocketdevice.h
Go to the documentation of this file.
1 // Program Name: mmulticastsocketdevice.h
3 // Created : Oct. 1, 2005
4 //
5 // Purpose : Multicast QSocketDevice Implmenetation
6 //
7 // Copyright (c) 2005 David Blain <dblain@mythtv.org>
8 //
9 // Licensed under the GPL v2 or later, see COPYING for details
10 //
12 
13 #ifndef MULTICAST_SOCKET_DEVICE_H
14 #define MULTICAST_SOCKET_DEVICE_H
15 
16 #ifdef __FreeBSD__
17 # include <sys/types.h>
18 #endif
19 
20 #ifdef _WIN32
21 # include <ws2tcpip.h>
22 #else
23 # include <sys/socket.h>
24 # include <netinet/in.h>
25 # include <netinet/ip.h>
26 #endif
27 
28 // Qt headers
29 #include <QNetworkInterface>
30 #include <QHostAddress>
31 #include <QByteArray>
32 #include <QString>
33 
34 // MythTV headers
35 #include "msocketdevice.h"
36 #include "mythlogging.h"
37 #include "compat.h"
38 
41 //
42 // MMulticastSocketDevice Class Definition/Implementation
43 //
46 
47 class MMulticastSocketDevice : public MSocketDevice
48 {
49  public:
51  MSocketDevice(MSocketDevice::Datagram),
52  m_localAddresses(QNetworkInterface::allAddresses()) {}
53  MMulticastSocketDevice(const QString& sAddress, quint16 nPort, u_char ttl = 0);
54 
55  ~MMulticastSocketDevice() override;
56 
57  qint64 writeBlock(
58  const char *data, quint64 len,
59  const QHostAddress & host, quint16 port) override; // MSocketDevice
60 
61  QHostAddress address() const override // MSocketDevice
62  { return m_address; }
63  quint16 port() const override // MSocketDevice
64  { return m_port; }
65 
66  private:
67  QList<QHostAddress> m_localAddresses;
68  QHostAddress m_address;
69  quint16 m_port {0};
70  struct ip_mreq m_imr {};
71 };
72 
73 #endif // MULTICAST_SOCKET_DEVICE_H
MMulticastSocketDevice::writeBlock
qint64 writeBlock(const char *data, quint64 len, const QHostAddress &host, quint16 port) override
Definition: mmulticastsocketdevice.cpp:90
MMulticastSocketDevice
Definition: mmulticastsocketdevice.h:47
MMulticastSocketDevice::port
quint16 port() const override
Definition: mmulticastsocketdevice.h:63
MMulticastSocketDevice::address
QHostAddress address() const override
Definition: mmulticastsocketdevice.h:61
MMulticastSocketDevice::~MMulticastSocketDevice
~MMulticastSocketDevice() override
Definition: mmulticastsocketdevice.cpp:77
MMulticastSocketDevice::m_imr
Definition: mmulticastsocketdevice.h:70
mythlogging.h
compat.h
MMulticastSocketDevice::m_port
quint16 m_port
Definition: mmulticastsocketdevice.h:69
MMulticastSocketDevice::m_localAddresses
QList< QHostAddress > m_localAddresses
Definition: mmulticastsocketdevice.h:67
MMulticastSocketDevice::m_address
QHostAddress m_address
Definition: mmulticastsocketdevice.h:68
MMulticastSocketDevice::MMulticastSocketDevice
MMulticastSocketDevice()
Definition: mmulticastsocketdevice.h:50