I am trying to read an mjpgstream with QNetworkReply.
First the server sends a boundary string terminated with \r\n
I have tried to parse it with a slot connected to the QNeworkReply's readyRead() signal:
void GetImage::mjpgReadyRead()
{
qWarning() << mjpgReply->bytesAvailable();
if (mjpgReply->canReadLine()) {
qWarning() << "can";
mjpgBoundary = mjpgReply->readLine();
mjpgState = MjpgHeader;
qWarning() << mjpgBoundary << mjpgBoundary.length();
}
And it never finds lines.
I have figured out that if I call a getChar before the canReadLine it works ok.
void GetImage::mjpgReadyRead()
{
qWarning() << mjpgReply->bytesAvailable();
char c;
mjpgReply->getChar(&c);
if (mjpgReply->canReadLine()) {
qWarning() << "can";
mjpgBoundary = mjpgReply->readLine();
mjpgState = MjpgHeader;
qWarning() << mjpgBoundary << mjpgBoundary.length();
}