MythTV master
mmulticastsocketdevice.h
Go to the documentation of this file.
1
2// 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"
36
37#include "msocketdevice.h"
38
41//
42// MMulticastSocketDevice Class Definition/Implementation
43//
46
47class 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
QList< QHostAddress > m_localAddresses
QHostAddress address() const override
qint64 writeBlock(const char *data, quint64 len, const QHostAddress &host, quint16 port) override
quint16 port() const override