
Untitled
By: a guest on
May 1st, 2012 | syntax:
None | size: 0.93 KB | hits: 59 | expires: Never
streaming MJPEG via CGI on nginx / lighty
// As soon as someone connects
fprintf (stdout, "Connection: close"
"rn"
"Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0"
"rn"
"Pragma: no-cache"
"rn"
"Content-Type: multipart/x-mixed-replace;boundary=" BOUNDARY
"rn"
"rn"
"--" BOUNDARY "rn");
[...]
while (1) {
//Magically take the frame from the shared memory
fprintf(stdout, "Content-Type: image/jpegrn"
"Content-Length: %drn"
"rn", frame_length);
DBG("sending framen");
if ((fwrite(frame_data, frame_length, sizeof (char) , stdout)) == 0 ) {
ERR ("Error sending frame");
break;
}
DBG("sending boundaryn");
fprintf(stdout, "rn--" BOUNDARY "rn");
}