X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=mardrone%2Fdronelib%2Fvideo.cpp;h=a4ec15593a10c53f65b95787b1ee49e18023118e;hb=323e8e1692d15a3435f1813f038e757cd2614938;hp=7ba76adf3bcd08f4939a3e356894ac210216b173;hpb=5338a11daffd03a49ef70b077b37ddc1414063a5;p=mardrone diff --git a/mardrone/dronelib/video.cpp b/mardrone/dronelib/video.cpp index 7ba76ad..a4ec155 100644 --- a/mardrone/dronelib/video.cpp +++ b/mardrone/dronelib/video.cpp @@ -18,7 +18,15 @@ ! ! *===================================================================*/ +#include +#include +#include +#include +#include #include "video.h" +#include +#include +#include #include #include #include @@ -99,12 +107,39 @@ QRectF DroneVideo::boundingRect() const VideoThread::VideoThread(DroneVideo *parentp,QHostAddress host,QImage *_image) { + struct ip_mreq imreq; + QString my_ip; + my_ip="192.168.1.2"; image=_image; qDebug() << "videoThread::videoThread"; stopped=false; parent=parentp; videoSock=new QUdpSocket(); - videoSock->bind(QHostAddress::Any,5555); + if(!videoSock->bind(QHostAddress::Any,5555)) qDebug() << "VideoThread::VideoThread ** Cant Bind to port 5555 ***" << videoSock->errorString(); + QList netconfs=QNetworkConfigurationManager().allConfigurations(); + foreach (QNetworkConfiguration np,netconfs) { + qDebug() << "network Confifuration name " << np.name() << np.bearerName() << np.bearerTypeName(); + QNetworkSession ns(np); + if(ns.interface().addressEntries().empty()) + qDebug() << "network session " << ns.interface().humanReadableName() << "**NotConfig**"; + else { + qDebug() << "network session " << ns.interface().humanReadableName() << ns.interface().addressEntries().first().ip(); + // Ubuntu may give wlan0 as "Ethernet" + if((np.bearerName()==QString("WLAN")) || (ns.interface().humanReadableName()==QString("wlan0")) ) { + my_ip=ns.interface().addressEntries().first().ip().toString(); + qDebug() << "My IP is " << my_ip; + } + } + } + // Qt 4.7.x + imreq.imr_multiaddr.s_addr=inet_addr("224.1.1.1"); + imreq.imr_interface.s_addr=inet_addr(my_ip.toAscii()); + setsockopt(videoSock->socketDescriptor(),IPPROTO_IP,IP_ADD_MEMBERSHIP,&imreq,sizeof(imreq)); +//#else + // Qt 4.8 + if(!videoSock->joinMulticastGroup(QHostAddress("224.1.1.1"))) + qDebug() << "VideoThread::VideoThread can't join multicast Group 224.1.1.1" << videoSock->errorString(); +//#endif droneHost=host; videoRec=FALSE; videoFile=NULL;