MJPEGServer: Output boundary at start of image instead of end.

This avoids hiccups/timeouts causing the next image being seen as a
completely new file rather than a continuation of a multi-part.
This commit is contained in:
Peter Johnson
2016-10-26 23:58:22 -07:00
parent c66a55d81a
commit 43331419f6

View File

@@ -369,7 +369,6 @@ void MJPEGServerImpl::SendStream(wpi::raw_socket_ostream& os) {
SendHeader(oss, 200, "OK", "multipart/x-mixed-replace;boundary=" BOUNDARY,
"Access-Control-Allow-Origin: *");
oss << "--" BOUNDARY "\r\n";
os << oss.str();
DEBUG("HTTP: Headers send, sending stream now");
@@ -397,13 +396,13 @@ void MJPEGServerImpl::SendStream(wpi::raw_socket_ostream& os) {
// with firefox
double timestamp = frame.time() / 10000000.0;
header.clear();
oss << "Content-Type: image/jpeg\r\n"
oss << "\r\n--" BOUNDARY "\r\n"
<< "Content-Type: image/jpeg\r\n"
<< "Content-Length: " << frame.size() << "\r\n"
<< "X-Timestamp: " << timestamp << "\r\n"
<< "\r\n";
os << oss.str();
os << llvm::StringRef(frame.data(), frame.size());
os << "\r\n--" BOUNDARY "\r\n";
// os.flush();
}
Disable();