summaryrefslogtreecommitdiff
path: root/src/encoder.cc
diff options
context:
space:
mode:
authordeva <deva>2005-05-02 10:18:51 +0000
committerdeva <deva>2005-05-02 10:18:51 +0000
commit6018769717141e28ed5eb84b2cfb3449f3e7334d (patch)
treeb6824d1de5da6a1a4fdbb54184ad2f27314ea8c2 /src/encoder.cc
parent27287fd9726bc9bc4be8dc3eac91a750f6d6f453 (diff)
Preserve network connection when a frozen frame exists, even though no recording is done.
Diffstat (limited to 'src/encoder.cc')
-rw-r--r--src/encoder.cc37
1 files changed, 24 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);
}