I want to create a Http Server to send an MJPEG Stream. I\'m Already able to send an Image but no Live-Stream.
What I did: Created an TCP-Server. When a client Conn
I solved it myself.... I just had to adjust some Protocol releated things....
m_TcpHttpClient->readAll(); // Discard "Get Request String"
QByteArray ContentType = ("HTTP/1.0 200 OK\r\n" \
"Server: en.code-bude.net example server\r\n" \
"Cache-Control: no-cache\r\n" \
"Cache-Control: private\r\n" \
"Content-Type: multipart/x-mixed-replace;boundary=--boundary\r\n\r\n");
m_TcpHttpClient->write(ContentType);
while(1){
// Image to Byte Array via OPENCV Method
std::vector<uchar> buff;
imencode(".jpg",m_VisualEngine->GetActualFrame(),buff);
std::string content(buff.begin(), buff.end());
QByteArray CurrentImg(QByteArray::fromStdString(content));
QByteArray BoundaryString = ("--boundary\r\n" \
"Content-Type: image/jpeg\r\n" \
"Content-Length: ");
BoundaryString.append(QString::number(CurrentImg.length()));
BoundaryString.append("\r\n\r\n");
m_TcpHttpClient->write(BoundaryString);
m_TcpHttpClient->write(CurrentImg); // Write The Encoded Image
m_TcpHttpClient->flush();
}