Send audio voice via socket tcp. What signal.
-
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();
-
There's
QAudioInput
in Qt5 andQAudioSource
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. -
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?
-
FWIW, never use TCP to stream "realtime" multimedia data. Use UDP. Look at RTP/RTSP to see how it's done properly.
-
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(); }