Changes to not just die if not connected to monitor. Instead wait around spitting out an error image.
This commit is contained in:
parent
43e1ac2ad4
commit
ea3fcb16a6
|
@ -37,9 +37,17 @@ StreamBase::~StreamBase() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
closeComms();
|
closeComms();
|
||||||
|
if ( monitor ) {
|
||||||
|
delete monitor;
|
||||||
|
monitor = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StreamBase::loadMonitor(int monitor_id) {
|
bool StreamBase::loadMonitor(int p_monitor_id) {
|
||||||
|
monitor_id = p_monitor_id;
|
||||||
|
if ( monitor )
|
||||||
|
delete monitor;
|
||||||
|
|
||||||
if ( !(monitor = Monitor::Load(monitor_id, false, Monitor::QUERY)) ) {
|
if ( !(monitor = Monitor::Load(monitor_id, false, Monitor::QUERY)) ) {
|
||||||
Error("Unable to load monitor id %d for streaming", monitor_id);
|
Error("Unable to load monitor id %d for streaming", monitor_id);
|
||||||
return false;
|
return false;
|
||||||
|
@ -59,7 +67,15 @@ bool StreamBase::loadMonitor(int monitor_id) {
|
||||||
|
|
||||||
bool StreamBase::checkInitialised() {
|
bool StreamBase::checkInitialised() {
|
||||||
if ( !monitor ) {
|
if ( !monitor ) {
|
||||||
Fatal("Cannot stream, not initialised");
|
Error("Cannot stream, not initialised");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( monitor->GetFunction() == Monitor::NONE ) {
|
||||||
|
Error("Monitor %d has function NONE. Will not be able to connect to it.", monitor_id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( !monitor->ShmValid() ) {
|
||||||
|
Error("Monitor shm is not connected");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -257,11 +273,13 @@ bool StreamBase::sendTextFrame(const char *frame_text) {
|
||||||
|
|
||||||
image.EncodeJpeg(buffer, &n_bytes);
|
image.EncodeJpeg(buffer, &n_bytes);
|
||||||
|
|
||||||
fputs("--ZoneMinderFrame\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);
|
||||||
if ( fwrite(buffer, n_bytes, 1, stdout) != 1 ) {
|
if ( fwrite(buffer, n_bytes, 1, stdout) != 1 ) {
|
||||||
Error("Unable to send stream text frame: %s", strerror(errno));
|
Error("Unable to send stream text frame: %s", strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
Debug(1, "Sent %d bytes", n_bytes);
|
||||||
}
|
}
|
||||||
fputs("\r\n\r\n", stdout);
|
fputs("\r\n\r\n", stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
|
@ -61,6 +61,7 @@ protected:
|
||||||
typedef enum { CMD_NONE=0, CMD_PAUSE, CMD_PLAY, CMD_STOP, CMD_FASTFWD, CMD_SLOWFWD, CMD_SLOWREV, CMD_FASTREV, CMD_ZOOMIN, CMD_ZOOMOUT, CMD_PAN, CMD_SCALE, CMD_PREV, CMD_NEXT, CMD_SEEK, CMD_VARPLAY, CMD_GET_IMAGE, CMD_QUIT, CMD_QUERY=99 } MsgCommand;
|
typedef enum { CMD_NONE=0, CMD_PAUSE, CMD_PLAY, CMD_STOP, CMD_FASTFWD, CMD_SLOWFWD, CMD_SLOWREV, CMD_FASTREV, CMD_ZOOMIN, CMD_ZOOMOUT, CMD_PAN, CMD_SCALE, CMD_PREV, CMD_NEXT, CMD_SEEK, CMD_VARPLAY, CMD_GET_IMAGE, CMD_QUIT, CMD_QUERY=99 } MsgCommand;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
int monitor_id;
|
||||||
Monitor *monitor;
|
Monitor *monitor;
|
||||||
|
|
||||||
StreamType type;
|
StreamType type;
|
||||||
|
@ -114,6 +115,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StreamBase():
|
StreamBase():
|
||||||
|
monitor_id(0),
|
||||||
monitor(0),
|
monitor(0),
|
||||||
type(DEFAULT_TYPE),
|
type(DEFAULT_TYPE),
|
||||||
format(""),
|
format(""),
|
||||||
|
|
Loading…
Reference in New Issue