00001 00002 // Program Name: mmulticastsocketdevice.h 00003 // Created : Oct. 1, 2005 00004 // 00005 // Purpose : Multicast QSocketDevice Implmenetation 00006 // 00007 // Copyright (c) 2005 David Blain <dblain@mythtv.org> 00008 // 00009 // Licensed under the GPL v2 or later, see COPYING for details 00010 // 00012 00013 #ifndef _MULTICAST_SOCKET_DEVICE_H_ 00014 #define _MULTICAST_SOCKET_DEVICE_H_ 00015 00016 #ifdef _WIN32 00017 # ifndef _MSC_VER 00018 # include <ws2tcpip.h> 00019 # endif 00020 #else 00021 # include <sys/socket.h> 00022 # include <netinet/in.h> 00023 # include <netinet/ip.h> 00024 #endif 00025 00026 // Qt headers 00027 #include <QNetworkInterface> 00028 #include <QHostAddress> 00029 #include <QByteArray> 00030 #include <QString> 00031 00032 // MythTV headers 00033 #include "msocketdevice.h" 00034 #include "mythlogging.h" 00035 #include "compat.h" 00036 00039 // 00040 // MMulticastSocketDevice Class Definition/Implementation 00041 // 00044 00045 class MMulticastSocketDevice : public MSocketDevice 00046 { 00047 public: 00048 MMulticastSocketDevice() : 00049 MSocketDevice(MSocketDevice::Datagram), 00050 m_local_addresses(QNetworkInterface::allAddresses()), 00051 m_port(0) 00052 { 00053 memset(&m_imr, 0, sizeof(struct ip_mreq)); 00054 } 00055 00056 MMulticastSocketDevice(QString sAddress, quint16 nPort, u_char ttl = 0); 00057 00058 virtual ~MMulticastSocketDevice(); 00059 00060 virtual qint64 writeBlock( 00061 const char *data, quint64 len, 00062 const QHostAddress & host, quint16 port); 00063 00064 virtual QHostAddress address() const { return m_address; } 00065 virtual quint16 port() const { return m_port; } 00066 00067 private: 00068 QList<QHostAddress> m_local_addresses; 00069 QHostAddress m_address; 00070 quint16 m_port; 00071 struct ip_mreq m_imr; 00072 }; 00073 00074 #endif // _MULTICAST_SOCKET_DEVICE_H_
1.6.3