From 6018769717141e28ed5eb84b2cfb3449f3e7334d Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 2 May 2005 10:18:51 +0000 Subject: Preserve network connection when a frozen frame exists, even though no recording is done. --- src/encoder.cc | 37 ++++++++++++++++++++++++------------- src/encoder.h | 5 +++++ 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/encoder.cc b/src/encoder.cc index 2c03b9d..fd7b8a2 100644 --- a/src/encoder.cc +++ b/src/encoder.cc @@ -25,6 +25,9 @@ */ /* * $Log$ + * Revision 1.23 2005/05/02 10:18:51 deva + * Preserve network connection when a frozen frame exists, even though no recording is done. + * * Revision 1.22 2005/05/02 10:01:58 deva * Create and destroy netowrk connections in main function and not in start/stop/freeze... etc * @@ -83,6 +86,8 @@ Encoder::Encoder(Error* err, s = NULL; n = NULL; + frozen = false; + // shoot_request = 0; // shoot_value = 0; // freeze_request = 0; @@ -92,8 +97,6 @@ Encoder::Encoder(Error* err, Encoder::~Encoder() { - if(n) delete n; - if(s) delete s; } @@ -107,11 +110,9 @@ void Encoder::encode() frame = queue->pop(); if(frame) { - /* - if(record || - (freeze_request != freeze_value) || - (shoot_request != shoot_value)) { - */ + if(frame->freeze) frozen = true; + if(frame->shoot) frozen = false; + if(frame->record || frame->freeze || frame->shoot) { @@ -137,12 +138,16 @@ void Encoder::encode() n->sendPackage(&h, frame->data, frame->size); } else { - // No data is to be sent, if we have a connection, destroy it. - if(s) { - if(n) delete n; - delete s; - s = NULL; - n = NULL; + // When frozen we need to preserve the connection in order to + // remember the frozen frame on the server side. + if(!frozen) { + // No data is to be sent, if we have a connection, destroy it. + if(s) { + if(n) delete n; + delete s; + s = NULL; + n = NULL; + } } } if(frame) delete frame; @@ -191,6 +196,12 @@ void Encoder::shoot(unsigned char *rgb) void Encoder::run() { encode(); + if(s) { + if(n) delete n; + delete s; + s = NULL; + n = NULL; + } fprintf(stderr, "Encoder thread stopped.\n"); fflush(stderr); } diff --git a/src/encoder.h b/src/encoder.h index 0d84825..1912261 100644 --- a/src/encoder.h +++ b/src/encoder.h @@ -24,6 +24,9 @@ */ /* * $Log$ + * Revision 1.10 2005/05/02 10:18:51 deva + * Preserve network connection when a frozen frame exists, even though no recording is done. + * * Revision 1.9 2005/05/02 09:50:22 deva * Rewrote freeze, shoot and record flags, from encoder to frame. * @@ -98,6 +101,8 @@ private: char ip[32]; char cpr[32]; + bool frozen; + // volatile int record; // volatile int shoot_request; -- cgit v1.2.3