]> git.vomp.tv Git - vompclient.git/commitdiff
User setting for TCP window size
authorChris Tallon <chris@vomp.tv>
Sun, 26 Feb 2006 16:08:10 +0000 (16:08 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 26 Feb 2006 16:08:10 +0000 (16:08 +0000)
command.cc
tcp.cc
tcp.h
vdr.cc
vdr.h
voptions.cc
voptionsmenu.cc
voptionsmenu.h

index 7ece424d9f4add8dfe03fdef2e8552d8ae2b56d7..ecaf4e1824723d6a053063d4f12e8e1a16de52f4 100644 (file)
@@ -544,6 +544,22 @@ void Command::doJustConnected(VConnect* vconnect)
     video->setMode(Video::NORMAL);
   }
 
+  config = vdr->configLoad("Advanced", "TCP receive window");
+  if (config)
+  {
+    size_t newTCPsize = atoi(config);
+    delete[] config;
+
+    logger->log("Command", Log::INFO, "Setting TCP window size %i", newTCPsize);
+    vdr->setReceiveWindow(newTCPsize);
+  }
+  else
+  {
+    logger->log("Command", Log::INFO, "TCP window size not found, setting 2048");
+    vdr->setReceiveWindow(2048); // Default
+  }
+
+
   // config done
 
   // Save power state = on
diff --git a/tcp.cc b/tcp.cc
index fd5444fbda38b92d013b9e015c79dcc4c1f2d12c..61a079ac15e930225925b450730d97b06b62f71f 100644 (file)
--- a/tcp.cc
+++ b/tcp.cc
@@ -72,9 +72,7 @@ int TCP::connectTo(char* host, unsigned short port)
   oldflags |= O_NONBLOCK;
   fcntl(sock, F_SETFL, oldflags);
 
-  // Set receive window
-  size_t rxBufferSize = 2048;
-  setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &rxBufferSize, sizeof(size_t));
+//  setReceiveWindow(2048);
 
   // ok, how to open a connection in non blocking mode (and therefore have a self set timeout!!)
 
@@ -146,6 +144,13 @@ The full documentation:
 */
 }
 
+void TCP::setReceiveWindow(size_t rxBufferSize)
+{
+  // Set receive window
+  int r = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &rxBufferSize, sizeof(size_t));
+  Log::getInstance()->log("TCP", Log::DEBUG, "Set receive window to %i, success(=0): %i", rxBufferSize, r);
+}
+
 void TCP::assignSocket(int tsocket)
 {
   sock = tsocket;
diff --git a/tcp.h b/tcp.h
index 4a024c71065dba0cf877044e275a32c4d339b45a..19ad1c0a57798d095b13b02a5ef9901e2bb2f1b3 100644 (file)
--- a/tcp.h
+++ b/tcp.h
@@ -60,6 +60,7 @@ class TCP
     static void dump(unsigned char* data, ULONG size);
 
     void getMAC(char* dest); // copies 6 MAC bytes to dest
+    void setReceiveWindow(size_t rxBufferSize);
 
   private:
     int sock;
diff --git a/vdr.cc b/vdr.cc
index 3f8c7e72010e9a048547cff42c92960e7e6d89c6..79481b8ff1b93370fd07f45769752492ef4342a8 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -152,6 +152,11 @@ void VDR::disconnect()
   Log::getInstance()->log("VDR", Log::DEBUG, "Disconnect");
 }
 
+void VDR::setReceiveWindow(size_t size)
+{
+  tcp->setReceiveWindow(size);
+}
+
 ///////////////////////////////////////////////////////
 
 int VDR::getPacket()
diff --git a/vdr.h b/vdr.h
index 5622fd0a1a6283c9c2efac99bde2c92aa12511f6..780905484dc055ed07b579f38fb89df6b8f80646 100644 (file)
--- a/vdr.h
+++ b/vdr.h
@@ -108,6 +108,8 @@ class VDR
     void disconnect();
     ULLONG getResumePoint(char* fileName);  // uses configLoad
 
+    void setReceiveWindow(size_t size);
+
     // protocol functions
 
     int doLogin();
index 0d03d2add5b47aeafd7336d2ec288648fd59bbfa..a2d224665374e8195b79d1de7c9e05603a855842 100644 (file)
@@ -28,7 +28,11 @@ VOptions::VOptions(View* tparent, const char* title, const OPTIONDATA* toptionDa
   optionData = toptionData;
   numOptions = tnumOptions;
 
-  create(530, 85 + (numOptions * 30));
+  UINT newHeight = 85;
+  if (numOptions < 4) newHeight += (4 * 30);
+  else newHeight += (numOptions * 30);
+
+  create(530, newHeight);
 
   setBackgroundColour(Colour::VIEWBACKGROUND);
   setTitleBarOn(1);
@@ -130,7 +134,7 @@ void VOptions::draw()
   WSymbol wsy;
   Colour cl;
 
-  drawText(tr("Press back to exit, <, > or [ok] to change"), 10, 55+numOptions*30, Colour::LIGHTTEXT);
+  drawText(tr("Press back to exit, <, > or [ok] to change"), 10, area.h - 30, Colour::LIGHTTEXT);
 
   wsy.setSurface(surface);
 
index f0ef93b1619c7587422a3f561eda422db8c368cf..06c5a65b81ff8cd62a0e48ea825d2dc54b333f28 100644 (file)
@@ -24,7 +24,7 @@ VOptionsMenu::VOptionsMenu()
 {
   viewman = ViewMan::getInstance();
 
-  create(460, 190);
+  create(460, 200);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(140, 170);
@@ -47,7 +47,7 @@ VOptionsMenu::VOptionsMenu()
   wb = new WButton();
   wb->setText("General");
   wb->setSurface(surface);
-  wb->setSurfaceOffset(160, 70);
+  wb->setSurfaceOffset(160, 60);
   wb->setDimensions(140, fontHeight);
   wb->setTag(1);
   buttons.push_back(wb);
@@ -55,11 +55,20 @@ VOptionsMenu::VOptionsMenu()
   wb = new WButton();
   wb->setText("Timers");
   wb->setSurface(surface);
-  wb->setSurfaceOffset(160, 110);
+  wb->setSurfaceOffset(160, 100);
   wb->setDimensions(140, fontHeight);
   wb->setTag(2);
   buttons.push_back(wb);
 
+  wb = new WButton();
+  wb->setText("Advanced");
+  wb->setSurface(surface);
+  wb->setSurfaceOffset(160, 140);
+  wb->setDimensions(140, fontHeight);
+  wb->setTag(3);
+  buttons.push_back(wb);
+
+
   selectedButton = buttons.begin();
   (*selectedButton)->setActive(1);
 }
@@ -120,6 +129,7 @@ int VOptionsMenu::handleCommand(int command)
       {
         case 1: doGeneral();   break;
         case 2: doTimers();    break;
+        case 3: doAdvanced();  break;
       }
       return 2;
     }
@@ -210,6 +220,22 @@ void VOptionsMenu::doApplyChanges(map<int,int>* changedOptions)
         }
         break;
       }
+      case 13:
+      {
+        size_t newTCPsize = 2048;
+
+        if (i->second == 0) newTCPsize = 1024;
+        else if (i->second == 1) newTCPsize = 2048;
+        else if (i->second == 2) newTCPsize = 4096;
+        else if (i->second == 3) newTCPsize = 8192;
+        else if (i->second == 4) newTCPsize = 16384;
+        else if (i->second == 5) newTCPsize = 32768;
+        else if (i->second == 6) newTCPsize = 65536;
+
+        Log::getInstance()->log("Options", Log::DEBUG, "Setting TCP window size %i", newTCPsize);
+        vdr->setReceiveWindow(newTCPsize);
+        break;
+      }
     }
   }
 
@@ -219,7 +245,7 @@ void VOptionsMenu::doApplyChanges(map<int,int>* changedOptions)
 
 void VOptionsMenu::doGeneral()
 {
-  static const int numOptions = 8;
+  static const int numOptions = 7;
 
   static const char* options1[] = {"Old", "New"};
   static const char* options3[] = {"RGB+composite", "S-Video"};
@@ -237,13 +263,12 @@ void VOptionsMenu::doGeneral()
     {5, "16:9 on 4:3 display mode", "TV",      "Widemode",         OPTIONTYPE_TEXT, 2, 0, 0, options5 },
     {6, "Power state after bootup", "General", "Power After Boot", OPTIONTYPE_TEXT, 3, 0, 0, options6 },
     {7, "Display channels",         "General", "Channels",         OPTIONTYPE_TEXT, 2, 0, 0, options7 },
-    {8, "VDR-Pri 0=OK !See forums!","General", "Live priority",    OPTIONTYPE_INT,  100, 0, 0, NULL }
   };
 
   // As all the above data is const static, it can be sent to the new View, this stack frame can
   // quit and the pointers will all still be valid. I think. (Hope).
 
-  VOptions* v = new VOptions(this, "General Options", optionData, numOptions);
+  VOptions* v = new VOptions(this, tr("General Options"), optionData, numOptions);
   v->draw();
   viewman->add(v);
   viewman->updateView(v);
@@ -259,13 +284,34 @@ void VOptionsMenu::doTimers()
     {9, "Default start margin (minutes)", "Timers", "Start margin",  OPTIONTYPE_INT, 20, 5, 0, NULL },
     {10, "Default end margin (minutes)",   "Timers", "End margin",    OPTIONTYPE_INT, 20, 5, 0, NULL },
     {11, "Default priority",               "Timers", "Priority",      OPTIONTYPE_INT, 100, 99, 0, NULL },
-    {12, "Default lifetime",               "Timers", "Lifetime",      OPTIONTYPE_INT, 100, 99, 0, NULL }
+    {12, "Default lifetime",               "Timers", "Lifetime",      OPTIONTYPE_INT, 100, 99, 0, NULL },
+  };
+
+  // As all the above data is const static, it can be sent to the new View, this stack frame can
+  // quit and the pointers will all still be valid. I think. (Hope).
+
+  VOptions* v = new VOptions(this, tr("Timer Options"), optionData, numOptions);
+  v->draw();
+  viewman->add(v);
+  viewman->updateView(v);
+}
+
+void VOptionsMenu::doAdvanced()
+{
+  static const int numOptions = 2;
+
+  static const char* options13[] = {"1024", "2048", "4096", "8192", "16384", "32768", "65536"};
+
+  const static OPTIONDATA optionData[numOptions] =
+  {
+    {8, "VDR-Pri 0=OK !See forums!",  "General",  "Live priority",      OPTIONTYPE_INT,  100, 0, 0, NULL },
+    {13, "TCP receive window size",   "Advanced", "TCP receive window", OPTIONTYPE_TEXT, 7, 1, 0, options13 }
   };
 
   // As all the above data is const static, it can be sent to the new View, this stack frame can
   // quit and the pointers will all still be valid. I think. (Hope).
 
-  VOptions* v = new VOptions(this, "Timer Options", optionData, numOptions);
+  VOptions* v = new VOptions(this, tr("Advanced Options"), optionData, numOptions);
   v->draw();
   viewman->add(v);
   viewman->updateView(v);
index fb1cf08e68fab5d92fdc08699fb24bb0bbf8b7c3..f8cf20e0561edaa35b669a3e4d0b90494c19e828 100644 (file)
@@ -47,6 +47,7 @@ class VOptionsMenu : public View
   private:
     void doGeneral();
     void doTimers();
+    void doAdvanced();
     void doApplyChanges(map<int,int>* changedOptions);
 
     VDR* vdr;