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 LICENSE 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 "libmythbase/compat.h"
37 
38 #include "msocketdevice.h"
39 
42 //
43 // MMulticastSocketDevice Class Definition/Implementation
44 //
47 
48 class MMulticastSocketDevice : public MSocketDevice
49 {
50  public:
52  MSocketDevice(MSocketDevice::Datagram),
53  m_localAddresses(QNetworkInterface::allAddresses()) {}
54  MMulticastSocketDevice(const QString& sAddress, quint16 nPort, u_char ttl = 0);
55 
56  ~MMulticastSocketDevice() override;
57 
58  qint64 writeBlock(
59  const char *data, quint64 len,
60  const QHostAddress & host, quint16 port) override; // MSocketDevice
61 
62  QHostAddress address() const override // MSocketDevice
63  { return m_address; }
64  quint16 port() const override // MSocketDevice
65  { return m_port; }
66 
67  private:
68  QList<QHostAddress> m_localAddresses;
69  QHostAddress m_address;
70  quint16 m_port {0};
71  struct ip_mreq m_imr {};
72 };
73 
74 #endif // MULTICAST_SOCKET_DEVICE_H
MMulticastSocketDevice::writeBlock
qint64 writeBlock(const char *data, quint64 len, const QHostAddress &host, quint16 port) override
Definition: mmulticastsocketdevice.cpp:91
MMulticastSocketDevice
Definition: mmulticastsocketdevice.h:48
MMulticastSocketDevice::port
quint16 port() const override
Definition: mmulticastsocketdevice.h:64
MMulticastSocketDevice::address
QHostAddress address() const override
Definition: mmulticastsocketdevice.h:62
MMulticastSocketDevice::~MMulticastSocketDevice
~MMulticastSocketDevice() override
Definition: mmulticastsocketdevice.cpp:78
MMulticastSocketDevice::m_imr
Definition: mmulticastsocketdevice.h:71
mythlogging.h
compat.h
MMulticastSocketDevice::m_port
quint16 m_port
Definition: mmulticastsocketdevice.h:70
MMulticastSocketDevice::m_localAddresses
QList< QHostAddress > m_localAddresses
Definition: mmulticastsocketdevice.h:68
MMulticastSocketDevice::m_address
QHostAddress m_address
Definition: mmulticastsocketdevice.h:69
MMulticastSocketDevice::MMulticastSocketDevice
MMulticastSocketDevice()
Definition: mmulticastsocketdevice.h:51