summaryrefslogtreecommitdiff
path: root/src/encoder.cc
diff options
context:
space:
mode:
authordeva <deva>2005-05-02 10:01:58 +0000
committerdeva <deva>2005-05-02 10:01:58 +0000
commit27287fd9726bc9bc4be8dc3eac91a750f6d6f453 (patch)
treeab04a7f5b91d689f1001a2c934c8073367f6dde3 /src/encoder.cc
parent6928574175200fdaee9c04fafe388dd87b336095 (diff)
Create and destroy netowrk connections in main function and not in start/stop/freeze... etc
Diffstat (limited to 'src/encoder.cc')
-rw-r--r--src/encoder.cc29
1 files changed, 28 insertions, 1 deletions
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;
}
+*/
}