Fix zms giving 500 code instead of displaying error image due to not having sent the headers yet.
This commit is contained in:
parent
4596f61250
commit
848a537a0f
|
@ -465,10 +465,12 @@ bool MonitorStream::sendFrame(Image *image, SystemTimePoint timestamp) {
|
||||||
void MonitorStream::runStream() {
|
void MonitorStream::runStream() {
|
||||||
if (type == STREAM_SINGLE) {
|
if (type == STREAM_SINGLE) {
|
||||||
// Not yet migrated over to stream class
|
// Not yet migrated over to stream class
|
||||||
if (checkInitialised())
|
if (checkInitialised()) {
|
||||||
SingleImage(scale);
|
SingleImage(scale);
|
||||||
else
|
} else {
|
||||||
|
fputs("Content-Type: multipart/x-mixed-replace; boundary=" BOUNDARY "\r\n\r\n", stdout);
|
||||||
sendTextFrame("Unable to send image");
|
sendTextFrame("Unable to send image");
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,8 +267,8 @@ bool StreamBase::sendTextFrame(const char *frame_text) {
|
||||||
subpixelorder = monitor->SubpixelOrder();
|
subpixelorder = monitor->SubpixelOrder();
|
||||||
labelsize = monitor->LabelSize();
|
labelsize = monitor->LabelSize();
|
||||||
}
|
}
|
||||||
Debug(2, "Sending %dx%d * %d text frame '%s'",
|
Debug(2, "Sending %dx%dx%dx%d * %d scale text frame '%s'",
|
||||||
width, height, scale, frame_text);
|
width, height, colours, subpixelorder, scale, frame_text);
|
||||||
|
|
||||||
Image image(width, height, colours, subpixelorder);
|
Image image(width, height, colours, subpixelorder);
|
||||||
image.Clear();
|
image.Clear();
|
||||||
|
@ -276,9 +276,10 @@ bool StreamBase::sendTextFrame(const char *frame_text) {
|
||||||
|
|
||||||
if (scale != 100) {
|
if (scale != 100) {
|
||||||
image.Scale(scale);
|
image.Scale(scale);
|
||||||
|
Debug(2, "Scaled to %dx%d", image.Width(), image.Height());
|
||||||
}
|
}
|
||||||
if ( type == STREAM_MPEG ) {
|
if (type == STREAM_MPEG) {
|
||||||
if ( !vid_stream ) {
|
if (!vid_stream) {
|
||||||
vid_stream = new VideoStream("pipe:", format, bitrate, effective_fps, image.Colours(), image.SubpixelOrder(), image.Width(), image.Height());
|
vid_stream = new VideoStream("pipe:", format, bitrate, effective_fps, image.Colours(), image.SubpixelOrder(), image.Width(), image.Height());
|
||||||
fprintf(stdout, "Content-type: %s\r\n\r\n", vid_stream->MimeType());
|
fprintf(stdout, "Content-type: %s\r\n\r\n", vid_stream->MimeType());
|
||||||
vid_stream->OpenStream();
|
vid_stream->OpenStream();
|
||||||
|
@ -289,6 +290,7 @@ bool StreamBase::sendTextFrame(const char *frame_text) {
|
||||||
int n_bytes = 0;
|
int n_bytes = 0;
|
||||||
|
|
||||||
image.EncodeJpeg(buffer, &n_bytes);
|
image.EncodeJpeg(buffer, &n_bytes);
|
||||||
|
Debug(4, "Encoded to %d bytes", n_bytes);
|
||||||
|
|
||||||
fputs("--" BOUNDARY "\r\nContent-Type: image/jpeg\r\n", stdout);
|
fputs("--" BOUNDARY "\r\nContent-Type: image/jpeg\r\n", stdout);
|
||||||
fprintf(stdout, "Content-Length: %d\r\n\r\n", n_bytes);
|
fprintf(stdout, "Content-Length: %d\r\n\r\n", n_bytes);
|
||||||
|
|
|
@ -265,7 +265,7 @@ int main(int argc, const char *argv[], char **envp) {
|
||||||
stream.setStreamQueue(connkey);
|
stream.setStreamQueue(connkey);
|
||||||
stream.setStreamBuffer(playback_buffer);
|
stream.setStreamBuffer(playback_buffer);
|
||||||
if ( !stream.setStreamStart(monitor_id) ) {
|
if ( !stream.setStreamStart(monitor_id) ) {
|
||||||
Error("Unable set start stream for monitor %d", monitor_id);
|
fputs("Content-Type: multipart/x-mixed-replace; boundary=" BOUNDARY "\r\n\r\n", stdout);
|
||||||
stream.sendTextFrame("Unable to connect to monitor");
|
stream.sendTextFrame("Unable to connect to monitor");
|
||||||
logTerm();
|
logTerm();
|
||||||
zmDbClose();
|
zmDbClose();
|
||||||
|
|
Loading…
Reference in New Issue