PDA

View Full Version : qnetworkaccessmanager problem!



novamaster
6th July 2009, 19:59
hi to all. this is my first post in qtcentre, and basically my first question ever related to QT!
i'am trying to send audio data captured from mic to an ip camera (it has a build-in speaker).
the http api of my camera expects A POST HTTP request of the form:

POST /axis-cgi/audio/transmit.cgi HTTP/1.0\r\n
Content-Type: audio/basic\r\n
Content-Length: 9999999\r\n
Connection: Keep-Alive\r\n
Cache-Control: no-cache\r\n
\r\n
<Audio data>
<Audio data>
<Audio data>
...
<Audio data>


where <Audio data> are 240 bytes of audio data.


the problem iam facing is that at the time of the request the audio data are not avaliable. they become avaliable with time as you speak.

is there a way to handle this situation? how can i post the newly avaliable audio data when they will be avaliable; i guess that for every 240 new bytes of data i could write something like:


QNetworkRequest request(url);
request.setRawHeader("httptype","singlepart");
request.setRawHeader("Content-Type","audio/basic");
request.setRawHeader("Connection","keep-alive");

//data is a QByteArray of 240 bytes
//and manager is a QNetworkAccessManager object
manager->post(request,&data);


but what i would like to do is to make the request once and then keep sending the new data when they would be avaliable.
Does anybody knows how to achieve this with QT;
any suggestions?

wysota
6th July 2009, 23:05
I'd do it manually using QTcpSocket. Your usecase is very simple so you don't have to implement the full http protocol, just mimic it in the parts you need.

novamaster
7th July 2009, 14:56
the problem is solved. i use my own tcp socket and handle authentication issues myself. But i really wondering why QNetworkAccessManager or QHttp does not allowed access to their internal tcpSocket...Thanks wysota.

wysota
7th July 2009, 15:14
QHttp has a QHttp::setSocket() method you can use to access the socket. But I really don't see how it would help in your situation...

novamaster
7th July 2009, 20:21
well QHttp::setSocket() was the first thing i tried without positive results...

wysota
7th July 2009, 20:38
But what would you want to do with the socket?

dabbler
7th August 2010, 11:46
I am looking for access to the socket to see if it is still connected or not.

When I use QNetworkAccessManager and disconnect from the network in the midst of an FTP upload, then QNetworkAccessManager never recovers and never informs me of a problem and subsequent put() requests are ignored.