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. Send audio voice via socket tcp. What signal.

Send audio voice via socket tcp. What signal.

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 814 Views 2 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.
  • Z Offline
    Z Offline
    zabitqt
    wrote on last edited by zabitqt
    #1

    Hey, I capture audio this time, but for the same reason of QAbstractVideoSurface.
    I have successfull capture video end SEND PACKETS BYTES FRAME TO SOCKET TCP!!!
    If someone want to know how I have done it send me a message DM.

    Now this snippet capture audio but I want send data voice to socket channel tcp.
    Iis there a signal for this purpose?

        QAudioRecorder* audioRecorder = new QAudioRecorder;
    
        QAudioEncoderSettings audioSettings;
        audioSettings.setCodec("audio/amr");
        audioSettings.setQuality(QMultimedia::HighQuality);
    
        audioRecorder->setEncodingSettings(audioSettings);
    
        //audioRecorder->setOutputLocation(QUrl(QCoreApplication::applicationDirPath() + "/" + "test_audio"));
    
        audioRecorder->record();
    
    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by Bonnie
      #2

      There's QAudioInput in Qt5 and QAudioSource in Qt6, with a example for both:
      https://doc.qt.io/qt-5/qtmultimedia-multimedia-audioinput-example.html
      https://doc.qt.io/qt-6/qtmultimedia-audiosource-example.html
      Again what you captured from them are uncompressed raw audio.

      Z 1 Reply Last reply
      0
      • B Bonnie

        There's QAudioInput in Qt5 and QAudioSource in Qt6, with a example for both:
        https://doc.qt.io/qt-5/qtmultimedia-multimedia-audioinput-example.html
        https://doc.qt.io/qt-6/qtmultimedia-audiosource-example.html
        Again what you captured from them are uncompressed raw audio.

        Z Offline
        Z Offline
        zabitqt
        wrote on last edited by
        #3

        @Bonnie

        QAudioRecorder* recorder = new QAudioRecorder();
            QAudioProbe* probe = new QAudioProbe;
        
            connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)), this, SLOT(processBuffer(QAudioBuffer)));
            
        
            QAudioEncoderSettings audioSettings;
            audioSettings.setCodec("audio/amr");
            audioSettings.setQuality(QMultimedia::HighQuality);
        
            recorder->setEncodingSettings(audioSettings);
        
            
            qDebug() << "probe ritorna " << probe->setSource(recorder); // Returns true, hopefully.
        
        
            recorder->record(); // Now we can do things like calculating levels or performing an FFT
            qDebug() << "scritto " << recorder->setOutputLocation(QCoreApplication::applicationDirPath() + "/" + "test_audio");
            myAudioServer = new MyAudioServer();
            myAudioServer->startServer();
        
            //qDebug() << o;
            qDebug() << recorder->supportedAudioCodecs();
            qDebug() << recorder->state();
            qDebug() << recorder->error();
            qDebug() << recorder->outputLocation();
        

        SetOutLocation return false! Why?

        1 Reply Last reply
        0
        • Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by
          #4

          FWIW, never use TCP to stream "realtime" multimedia data. Use UDP. Look at RTP/RTSP to see how it's done properly.

          If you meet the AI on the road, kill it.

          1 Reply Last reply
          1
          • Z Offline
            Z Offline
            zabitqt
            wrote on last edited by
            #5

            Ok It return false because I don't set QUrl string.
            How can play WAV file? I have tried QSound::play but It crash in Thread.

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zabitqt
              wrote on last edited by
              #6

              Qt5Cored.pdb contains the debug information required to find the source for the module Qt5Cored.dll

              void MyThreadAudioTcpSocket::run()
              {
                  qDebug() << "Audio Thread started";
                  socket = new QTcpSocket();
                  connect(socket, SIGNAL(readyRead()), this, SLOT(readyRead()), Qt::DirectConnection);
                  connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
                  socket->connectToHost("192.168.0.10", 12346);
                  // we need to wait...
                  if (!socket->waitForConnected(5000))
                  {
                      qDebug() << "Error: " << socket->errorString();
                  }
              
              
                  QSound bells("C:\\Users\\Administrator\\Documents\\test.wav");
                  bells.play();
              
                  exec();
              
              }
              
              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