Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SSDP NOTIFY
Forum Updated to NodeBB v4.3 + New Features

SSDP NOTIFY

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 186 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • sonichyS Offline
    sonichyS Offline
    sonichy
    wrote on last edited by sonichy
    #1

    Macast (https://xfangfang.github.io/Macast/) is python DLNA Media Renderer, I want to change it to Qt.
    But on_pushButton_notify_clicked() has no respond!
    Source: https://github.com/sonichy/HTYDLNA

    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        groupAddress = QHostAddress("239.255.255.250");
        socket = new QUdpSocket(this);
        auto ok = socket->bind(QHostAddress::AnyIPv4, 8000, QUdpSocket::ShareAddress);
        connect(socket, SIGNAL(readyRead()), this, SLOT(readMsg()));    
        if (!ok) {
            return;
        }
    
        ok = socket->joinMulticastGroup(groupAddress);    
        if (!ok) {
            return;
        }
    
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::readMsg()
    {    
        while (socket->hasPendingDatagrams()) {
            QByteArray reply;
            reply.resize(socket->pendingDatagramSize());
            socket->readDatagram(reply.data(), reply.size());
            qDebug() << c;
            qDebug() << reply.data();
        }
        c++;
    }
    
    
    void MainWindow::on_pushButton_discover_clicked()
    {
        c = 0;
        QByteArray message("M-SEARCH * HTTP/1.1\r\n"
                           "Host:239.255.255.250:1900\r\n"
                           //"ST: ssdp:all\r\n"
                           "ST: upnp:rootdevice\r\n"
                           "Man: \"ssdp:discover\"\r\n"
                           "MX: 3\r\n"
                           "\r\n");    
    
        auto writeOk = socket->writeDatagram(message.data(), groupAddress, 1900);
        if (writeOk == -1) {
            qDebug() << "Writing Datagram failed";
        }
    }
    
    void MainWindow::on_pushButton_notify_clicked()
    {
        c = 0;
        QByteArray message("NOTIFY * HTTP/1.1\r\n"
                           "HOST: 239.255.255.250:1900\r\n"
                          "ST: upnp:rootdevice\r\n"                      
                           "NTS: ssdp:alive\r\n"
                           "LOCATION: http://192.168.2.100:8000/description.xml\r\n"
                           "USN: uuid:1234567890-abcdefg-hijklmn-opqrst-uvwxyz::upnp:rootdevice\r\n"
                           "CACHE-CONTROL: max-age=300\r\n"
                           "SERVER: 3.4.72-rt89 DLNADOC/1.50 UPnP/1.0 SakaueDLNA/1.1.0"
                           "\r\n");
    
        auto writeOk = socket->writeDatagram(message.data(), groupAddress, 1900);
        if (writeOk == -1) {
            qDebug() << "Writing Datagram failed";
        }
    }
    

    https://github.com/sonichy

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      When testing for an error, it's usually a good idea to at least print that something went wrong and not just exit early like you do in your constructor.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved