From 27287fd9726bc9bc4be8dc3eac91a750f6d6f453 Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 2 May 2005 10:01:58 +0000 Subject: Create and destroy netowrk connections in main function and not in start/stop/freeze... etc --- src/encoder.cc | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/encoder.cc') diff --git a/src/encoder.cc b/src/encoder.cc index cbafb99..2c03b9d 100644 --- a/src/encoder.cc +++ b/src/encoder.cc @@ -25,6 +25,9 @@ */ /* * $Log$ + * 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 + * * Revision 1.21 2005/05/02 09:50:22 deva * Rewrote freeze, shoot and record flags, from encoder to frame. * @@ -112,6 +115,14 @@ void Encoder::encode() if(frame->record || frame->freeze || frame->shoot) { + + // If no connection is present, make a new one + if(!s) { + s = new Socket(port, errobj); + s->sconnect(ip); + n = new Network(s, errobj); + } + n_header h; h.header_type = DATA_HEADER; @@ -125,6 +136,14 @@ void Encoder::encode() // if(shoot_request != shoot_value) shoot_value = shoot_request; 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; + } } if(frame) delete frame; } @@ -139,12 +158,14 @@ void Encoder::setCpr(char *newcpr) void Encoder::freeze() -{ +{ + /* if(!s) { s = new Socket(port, errobj); s->sconnect(ip); n = new Network(s, errobj); } + */ // if(!errobj->hasError()) freeze_request = 1 - freeze_request; } @@ -156,11 +177,13 @@ void Encoder::freeze() */ void Encoder::shoot(unsigned char *rgb) { + /* if(!s) { s = new Socket(port, errobj); s->sconnect(ip); n = new Network(s, errobj); } + */ // if(!errobj->hasError()) shoot_request = 1 - shoot_request; getScreenshot(rgb); } @@ -173,11 +196,13 @@ void Encoder::run() { void Encoder::start() { + /* if(!s) { s = new Socket(port, errobj); s->sconnect(ip); n = new Network(s, errobj); } + */ // if(!errobj->hasError()) record = 1; } @@ -204,12 +229,14 @@ void Encoder::stop(n_savestate save) { queue->unlock(); */ +/* if(s) { if(n) delete n; delete s; s = NULL; n = NULL; } +*/ } -- cgit v1.2.3