]> git.vomp.tv Git - vompclient.git/commitdiff
Windows port
authorChris Tallon <chris@vomp.tv>
Fri, 19 May 2006 20:32:07 +0000 (20:32 +0000)
committerChris Tallon <chris@vomp.tv>
Fri, 19 May 2006 20:32:07 +0000 (20:32 +0000)
osdwin.cc
recman.h
recording.cc
remotewin.cc
videowin.cc
videowin.h
vompreswin.h
vompwin.rc
winmain.cc

index 962017c51858b1932729ed6f6b960894cee0444e..2df6fe1f90ec8d871108c06e6448c316aef0bde2 100644 (file)
--- a/osdwin.cc
+++ b/osdwin.cc
@@ -21,7 +21,7 @@
 \r
 #include "osdwin.h"\r
 #include "mtd.h"\r
-#include "video.h"\r
+#include "videowin.h"\r
 #include "surfacewin.h"\r
 \r
 #include "dsallocator.h"\r
@@ -75,7 +75,7 @@ int OsdWin::init(void* device)
   d3dparas.Windowed=TRUE;\r
   d3dparas.SwapEffect=D3DSWAPEFFECT_COPY;\r
   if (d3d->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,*((HWND*) device),\r
-         D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dparas,&d3ddevice)!=D3D_OK) {\r
+         D3DCREATE_SOFTWARE_VERTEXPROCESSING |D3DCREATE_MULTITHREADED,&d3dparas,&d3ddevice)!=D3D_OK) {\r
           Log::getInstance()->log("OSD", Log::WARN, "Could not create Direct3D9 device!");\r
        return 0;\r
   }\r
@@ -188,8 +188,34 @@ void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){
        if (external_driving) {\r
                //Copy video to Backbuffer\r
                if (present!=NULL) {\r
-                       d3ddevice->StretchRect(present,NULL,d3drtsurf  ,NULL,D3DTEXF_LINEAR);\r
-\r
+                       VideoWin* video =(VideoWin*) Video::getInstance();\r
+                       /*calculating destination rect */\r
+                       RECT destrect={0,0,video->getScreenWidth(),video->getScreenHeight()};\r
+                       UCHAR mode=video->getMode();\r
+                       switch (mode) {\r
+                       case Video::EIGHTH:\r
+                       destrect.right=destrect.right/2;\r
+                       destrect.bottom=destrect.bottom/2;\r
+                       case Video::QUARTER:\r
+                       destrect.right=destrect.right/2+video->getPosx()*2;\r
+                       destrect.bottom=destrect.bottom/2+video->getPosy()*2;\r
+                       destrect.left=video->getPosx()*2;\r
+                       destrect.top=video->getPosy()*2;\r
+                       d3ddevice->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0);\r
+                       break;\r
+                       };\r
+                       D3DSURFACE_DESC surf_desc;\r
+                       present->GetDesc(&surf_desc);//for chop sides\r
+                       RECT sourcerect= {0,0,surf_desc.Width,surf_desc.Height};\r
+                       if (video->getPseudoTVsize()==Video::ASPECT4X3 \r
+                               && video->getMode()==Video::NORMAL \r
+                               && video->getAspectRatio()==Video::ASPECT16X9) {\r
+                                       unsigned int correction=((double) (surf_desc.Width))*4.*9./3./16.;\r
+                                       sourcerect.left=(surf_desc.Width-correction)/2;\r
+                                       sourcerect.right=sourcerect.left+correction;\r
+                       }\r
+\r
+                       d3ddevice->StretchRect(present,&sourcerect,d3drtsurf  ,&destrect,D3DTEXF_LINEAR);\r
                }\r
        } else {\r
                //Clear Background\r
index 81a01d702b4f121af0c0b5ea56ac67e3fd6cae68..68b8691a7969a942ffc6899328a8e5546262f4b6 100644 (file)
--- a/recman.h
+++ b/recman.h
 
 #include <stack>
 
+#ifdef WIN32
+#include <winsock2.h>
+#include <windows.h>
+#define PATH_MAX FILENAME_MAX
+#endif
+
 #include "directory.h"
 #include "recording.h"
 
index 365b5322f2fa71d8efd7ef247080f2a1e78a641b..8272fd747070dc8bd760d7f4b3d565d1ab3e2adb 100644 (file)
@@ -30,8 +30,8 @@ Recording::Recording()
 
 Recording::~Recording()
 {
-  if (progName) { free(progName); progName = NULL; }
-  if (fileName) { free(fileName); fileName = NULL; }
+  if (progName) { delete[] progName; progName = NULL; }
+  if (fileName) { delete[] fileName; fileName = NULL; }
   index = -1; // just in case
 }
 
@@ -57,22 +57,16 @@ void Recording::setStartTime(ULONG tstartTime)
 
 void Recording::setProgName(char* tProgName)
 {
-  if (progName) free(progName);
+  if (progName) delete[] progName;
 
-  if (asprintf(&progName, tProgName) == -1)
-  {
-    free(progName);
-    progName = NULL;
-  }
+  progName = new char[strlen(tProgName) + 1];
+  if (progName) strcpy(progName, tProgName);
 }
 
 void Recording::setFileName(char* tFileName)
 {
-  if (fileName) free(fileName);
+  if (fileName) delete[] fileName;
 
-  if (asprintf(&fileName, tFileName) == -1)
-  {
-    free(fileName);
-    fileName = NULL;
-  }
+  fileName = new char[strlen(tFileName) + 1];
+  if (fileName) strcpy(fileName, tFileName);
 }
index 37e1facefe6abbe5dda4bd6d45fd65b382f52e5f..1d6fbc3354ad4e82dfb152d986c957557aadeac9 100644 (file)
-/*
-    Copyright 2004-2005 Chris Tallon
-
-    This file is part of VOMP.
-
-    VOMP is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    VOMP is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-#include "remotewin.h"
-
-
-RemoteWin::RemoteWin()
-{
-  initted = 0;
-  curevent=NA_NONE;
-  signal=false;
-}
-
-RemoteWin::~RemoteWin()
-{
-}
-
-int RemoteWin::init(char* devName)
-{
-  if (initted) return 0;
-  initted = 1;
-  event = CreateEvent(NULL,/*FALSE*/TRUE,FALSE,NULL);
-
-
-  return 1;
-}
-
-int RemoteWin::shutdown()
-{
-  if (!initted) return 0;
-  CloseHandle(event);
-  initted = 0;
-  return 1;
-}
-
-UCHAR RemoteWin::getButtonPress(int waitType)
-{
-  /* how = 0 - block
-     how = 1 - start new wait
-     how = 2 - continue wait
-     how = 3 - no wait
-  */
-  DWORD wait;
-
-  if (curevent!=NA_NONE) {
-    UCHAR temp=curevent;
-    curevent=NA_NONE;
-    return temp;
-  }
-  if (waitType==3) {
-    return NA_NONE;
-  }
-  if (waitType==0) {
-    wait=INFINITE;
-  } else { //We do not distingish between 2 and 3
-    wait=1000;
-
-  }
-  WaitForSingleObject(event,wait);
-  ResetEvent(event);
-  if (curevent==NA_NONE) {
-    if (signal) {
-      signal=false;
-    return NA_SIGNAL; //Since we have no signals on windows, we simulate this
-    } else {
-      return NA_NONE;
-    }
-  }
-  UCHAR temp2=curevent;
-  curevent=NA_NONE;
-  return temp2;
-
-}
-
-void RemoteWin::clearBuffer()
-{
-}
-
-int RemoteWin::ReceiveButtonVK(UINT button) {
-  UCHAR pb=NA_NONE;
-  //should we use a translation table ? No APPCOMMAND iS DWORD!
-  switch (button) { //Processing VK_Messages
-  case VK_DOWN:
-    pb=DOWN; break;
-  case VK_RETURN:
-  case VK_SPACE:
-    pb=OK;break;
-  case VK_LEFT:
-    pb=LEFT;break;
-  case '9':
-  case VK_NUMPAD9:
-    pb=NINE;break;
-  case '8':
-  case VK_NUMPAD8:
-    pb=EIGHT;break;
-  case '7':
-  case VK_NUMPAD7:
-    pb=SEVEN;break;
-  case '6':
-  case VK_NUMPAD6:
-    pb=SIX;break;
-  case '5':
-  case VK_NUMPAD5:
-    pb=FIVE;break;
-  case '4':
-  case VK_NUMPAD4:
-    pb=FOUR;break;
-  case '3':
-  case VK_NUMPAD3:
-    pb=THREE;break;
-  case '2':
-  case VK_NUMPAD2:
-    pb=TWO;break;
-  case '1':
-  case VK_NUMPAD1:
-    pb=ONE;break;
-  case '0':
-  case VK_NUMPAD0:
-    pb=ZERO;break;
-  case VK_RIGHT:
-    pb=RIGHT;break;
-  case VK_UP:
-    pb=UP;break;
-  case VK_MULTIPLY:
-    pb=STAR;break;
-  case 'J'://j for JUMP TO instead of go to
-    pb=GO;break;
-  case VK_ESCAPE:
-    pb=POWER;break;
-  case VK_BACK:
-    pb=BACK;break;
-  case 'M':
-    pb=MENU;break;
-  case 'R':
-    pb=RED;break;
-  case 'G':
-    pb=GREEN;break;
-  case 'Y':
-    pb=YELLOW;break;
-  case 'B':
-    pb=BLUE; break;
-
-
-  }; //All other commands are process via APPCOMMAND_MESSAGES
-  if (pb==NA_NONE) return 0;
-  curevent=pb;
-  //PulseEvent(event);
-  SetEvent(event);
-  return 1;
-}
-
-int RemoteWin::ReceiveButtonAP(UINT button) {
-  UCHAR pb=NA_NONE;
-  //should we use a translation table ? No APPCOMMAND iS DWORD!
-  switch (button) { //Processing VK_Messages
-  case APPCOMMAND_MEDIA_CHANNEL_DOWN:
-    pb=CHANNELDOWN;break;
-  case APPCOMMAND_MEDIA_CHANNEL_UP:
-    pb=CHANNELUP;break;
-  case APPCOMMAND_MEDIA_FAST_FORWARD:
-    pb=FORWARD;break;
-  case APPCOMMAND_VOLUME_MUTE:
-    pb=MUTE;break;
-  case APPCOMMAND_MEDIA_PAUSE:
-    pb=PAUSE;break;
-  case APPCOMMAND_MEDIA_PLAY:
-    pb=PLAY;break;
-  case APPCOMMAND_MEDIA_RECORD:
-    pb=RECORD;break;
-  case APPCOMMAND_MEDIA_PREVIOUSTRACK:
-    pb=SKIPBACK;break;
-  case APPCOMMAND_MEDIA_REWIND:
-    pb=REVERSE;break;
-  case APPCOMMAND_MEDIA_NEXTTRACK:
-    pb=SKIPFORWARD;break;
-  case APPCOMMAND_MEDIA_STOP:
-    pb=STOP;break;
-  case APPCOMMAND_VOLUME_DOWN:
-    pb=VOLUMEDOWN;break;
-  case APPCOMMAND_VOLUME_UP:
-    pb=VOLUMEUP;break;
-  };
-  if (pb==NA_NONE) return 0;
-  curevent=pb;
-  //PulseEvent(event);
-  SetEvent(event);
-  return 1;
-}
-
-void RemoteWin::Signal() {
-  signal=true;
-  //PulseEvent(event);
-  SetEvent(event);
-}
+/*\r
+    Copyright 2004-2005 Chris Tallon\r
+\r
+    This file is part of VOMP.\r
+\r
+    VOMP is free software; you can redistribute it and/or modify\r
+    it under the terms of the GNU General Public License as published by\r
+    the Free Software Foundation; either version 2 of the License, or\r
+    (at your option) any later version.\r
+\r
+    VOMP is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+    GNU General Public License for more details.\r
+\r
+    You should have received a copy of the GNU General Public License\r
+    along with VOMP; if not, write to the Free Software\r
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+*/\r
+\r
+#include "remotewin.h"\r
+#include "vompreswin.h"\r
+\r
+\r
+RemoteWin::RemoteWin()\r
+{\r
+  initted = 0;\r
+  curevent=NA_NONE;\r
+  signal=false;\r
+}\r
+\r
+RemoteWin::~RemoteWin()\r
+{\r
+}\r
+\r
+int RemoteWin::init(char* devName)\r
+{\r
+  if (initted) return 0;\r
+  initted = 1;\r
+  event = CreateEvent(NULL,/*FALSE*/TRUE,FALSE,NULL);\r
+\r
+\r
+  return 1;\r
+}\r
+\r
+int RemoteWin::shutdown()\r
+{\r
+  if (!initted) return 0;\r
+  CloseHandle(event);\r
+  initted = 0;\r
+  return 1;\r
+}\r
+\r
+UCHAR RemoteWin::getButtonPress(int waitType)\r
+{\r
+  /* how = 0 - block\r
+     how = 1 - start new wait\r
+     how = 2 - continue wait\r
+     how = 3 - no wait\r
+  */\r
+  DWORD wait;\r
+\r
+  if (curevent!=NA_NONE) {\r
+         UCHAR temp=curevent;\r
+         curevent=NA_NONE;\r
+         return temp;\r
+  }\r
+  if (waitType==3) {\r
+         return NA_NONE;\r
+  }\r
+  if (waitType==0) {\r
+         wait=INFINITE;\r
+  } else { //We do not distingish between 2 and 3\r
+         wait=1000;\r
+\r
+  }\r
+  WaitForSingleObject(event,wait);\r
+  ResetEvent(event);\r
+  if (curevent==NA_NONE) {\r
+         if (signal) {\r
+                 signal=false;\r
+               return NA_SIGNAL; //Since we have no signals on windows, we simulate this\r
+         } else {\r
+                 return NA_NONE;\r
+         }\r
+  }\r
+  UCHAR temp2=curevent;\r
+  curevent=NA_NONE;\r
+  return temp2;\r
+  \r
+}\r
+\r
+void RemoteWin::clearBuffer()\r
+{\r
+}\r
+\r
+int RemoteWin::ReceiveButtonVK(UINT button) {\r
+       UCHAR pb=NA_NONE;\r
+       //should we use a translation table ? No APPCOMMAND iS DWORD!\r
+       switch (button) { //Processing VK_Messages\r
+       case VK_DOWN:\r
+               pb=DOWN; break;\r
+       case VK_RETURN:\r
+       case VK_SPACE:\r
+               pb=OK;break;\r
+       case VK_LEFT:\r
+               pb=LEFT;break;\r
+       case '9':\r
+       case VK_NUMPAD9:\r
+               pb=NINE;break;\r
+       case '8':\r
+       case VK_NUMPAD8:\r
+               pb=EIGHT;break;\r
+       case '7':\r
+       case VK_NUMPAD7:\r
+               pb=SEVEN;break;\r
+       case '6':\r
+       case VK_NUMPAD6:\r
+               pb=SIX;break;\r
+       case '5':\r
+       case VK_NUMPAD5:\r
+               pb=FIVE;break;\r
+       case '4':\r
+       case VK_NUMPAD4:\r
+               pb=FOUR;break;\r
+       case '3':\r
+       case VK_NUMPAD3:\r
+               pb=THREE;break;\r
+       case '2':\r
+       case VK_NUMPAD2:\r
+               pb=TWO;break;\r
+       case '1':\r
+       case VK_NUMPAD1:\r
+               pb=ONE;break;\r
+       case '0':\r
+       case VK_NUMPAD0:\r
+               pb=ZERO;break;\r
+       case VK_RIGHT:\r
+               pb=RIGHT;break;\r
+       case VK_UP:\r
+               pb=UP;break;\r
+       case VK_MULTIPLY:\r
+               pb=STAR;break;\r
+       case 'J'://j for JUMP TO instead of go to\r
+               pb=GO;break;\r
+       case VK_ESCAPE:\r
+               pb=POWER;break;\r
+       case VK_BACK:\r
+               pb=BACK;break;\r
+       case 'M':\r
+               pb=MENU;break;\r
+       case 'R':\r
+               pb=RED;break;\r
+       case 'G':\r
+               pb=GREEN;break;\r
+       case 'Y':\r
+               pb=YELLOW;break;\r
+       case 'B':\r
+               pb=BLUE; break;\r
+\r
+\r
+       }; //All other commands are process via APPCOMMAND_MESSAGES\r
+       if (pb==NA_NONE) return 0;\r
+       curevent=pb;\r
+       //PulseEvent(event);\r
+       SetEvent(event);\r
+       return 1;\r
+}\r
+\r
+int RemoteWin::ReceiveButtonAP(UINT button) {\r
+       UCHAR pb=NA_NONE;\r
+       //should we use a translation table ? No APPCOMMAND iS DWORD!\r
+       switch (button) { //Processing VK_Messages\r
+       case APPCOMMAND_MEDIA_CHANNEL_DOWN:\r
+               pb=CHANNELDOWN;break;\r
+       case APPCOMMAND_MEDIA_CHANNEL_UP:\r
+               pb=CHANNELUP;break;\r
+       case APPCOMMAND_MEDIA_FAST_FORWARD:\r
+               pb=FORWARD;break;\r
+       case APPCOMMAND_VOLUME_MUTE:\r
+               pb=MUTE;break;\r
+       case APPCOMMAND_MEDIA_PAUSE:\r
+               pb=PAUSE;break;\r
+       case APPCOMMAND_MEDIA_PLAY:\r
+               pb=PLAY;break;\r
+       case APPCOMMAND_MEDIA_RECORD:\r
+               pb=RECORD;break;\r
+       case APPCOMMAND_MEDIA_PREVIOUSTRACK:\r
+               pb=SKIPBACK;break;\r
+       case APPCOMMAND_MEDIA_REWIND:\r
+               pb=REVERSE;break;\r
+       case APPCOMMAND_MEDIA_NEXTTRACK:\r
+               pb=SKIPFORWARD;break;\r
+       case APPCOMMAND_MEDIA_STOP:\r
+               pb=STOP;break;\r
+       case APPCOMMAND_VOLUME_DOWN:\r
+               pb=VOLUMEDOWN;break;\r
+       case APPCOMMAND_VOLUME_UP:\r
+               pb=VOLUMEUP;break;\r
+       };\r
+       if (pb==NA_NONE) return 0;\r
+       curevent=pb;\r
+       //PulseEvent(event);\r
+       SetEvent(event);\r
+       return 1;\r
+}\r
+\r
+void RemoteWin::Signal() {\r
+       signal=true;\r
+       //PulseEvent(event);\r
+       SetEvent(event);\r
+}\r
+\r
index 8c1962d20e14498f74336c099a1253c032e1e462..c1e3356319ca4a236d2d3c07a535a90bf9f05e39 100644 (file)
@@ -45,12 +45,16 @@ VideoWin::VideoWin()
   startoffset=0;
   lastrefaudiotime=0;
   lastrefvideotime=0;
+  lastreftimeBYTE=0;
+  lastreftimeRT=0;
   firstsynched=false;
   cur_audio_media_sample=NULL;
   cur_video_media_sample=NULL;
   videoon=true;
   audioon=true;
   pseudotvsize=0;
+  videoposx=0;
+  videoposy=0;
  
 
 
@@ -72,7 +76,9 @@ int VideoWin::init(UCHAR tformat)
 
   initted = 1;
   tvsize=Video::ASPECT16X9; //Internally Vomp should think we are a 16:9 TV
-  
+  videoposx=0;
+  videoposy=0;
+
   if (!setFormat(tformat)){ shutdown(); return 0; }
   return 1;
 }
@@ -141,6 +147,8 @@ int VideoWin::setMode(UCHAR tmode)
   if ((tmode != NORMAL) && (tmode != LETTERBOX) && (tmode != UNKNOWN2) && (tmode != QUARTER) && (tmode != EIGHTH)
       && (tmode != ZOOM) && (tmode != UNKNOWN6)) return 0;
   mode = tmode;
+  videoposx=0;
+  videoposy=0;
   AdjustWindow();
 
   return 1;
@@ -166,7 +174,10 @@ int VideoWin::setSource()
 int VideoWin::setPosition(int x, int y)
 {
   if (!initted) return 0;
-
+  if (mode==QUARTER || mode==EIGHTH) {
+       videoposx=x;
+       videoposy=y;
+  }
   return 1;
 }
 
@@ -301,7 +312,8 @@ int VideoWin::stop()
 int VideoWin::reset()
 {
   if (!initted) return 0;
-
+  videoposx=0;
+  videoposy=0;
 
   return 1;
 }
@@ -665,6 +677,10 @@ void VideoWin::ResetTimeOffsets() {
   startoffset=0;
   lastrefaudiotime=0;
   lastrefvideotime=0;
+  lastreftimeBYTE=0;
+  lastreftimeRT=0;
+
+  
 }
 
 
index 36e8052e6f82837aa7638f20d7e1ee4a0feb53bb..9897112910c994463ad4c797606689411c642435 100644 (file)
@@ -91,6 +91,9 @@ class VideoWin : public Video
     void turnVideoOn(){videoon=true;};
     void turnVideoOff(){videoon=false;};
 
+       unsigned int getPosx() {return videoposx;};
+       unsigned int getPosy() {return videoposy;};
+
 #ifdef DEV
     int test();
     int test2();
@@ -122,6 +125,8 @@ private:
   UCHAR pseudotvsize;
   REFERENCE_TIME lastreftimeRT;
   ULLONG lastreftimeBYTE;
+  unsigned int videoposx;
+  unsigned int videoposy;
 #ifdef DS_DEBUG
   DWORD graphidentifier;
 #endif
index 28facbe57a6c4dbf1010f0ca450e640f78e6059e..11787604cf4cd289c3372a616349483b28a2f7fe 100644 (file)
@@ -1,30 +1,32 @@
-
-/*
-    Copyright 2004-2005 Chris Tallon
-
-    This file is part of VOMP.
-
-    VOMP is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    VOMP is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-#ifndef VOMPRESWIN_H
-#define _WIN32_WINNT 0x501
-
-#include <winsock2.h>
-#include <winuser.h>
-#define VOMPACCELERATOR 1
-
-#define VOMPRESWIN_H
-#endif
+\r
+/*\r
+    Copyright 2004-2005 Chris Tallon\r
+\r
+    This file is part of VOMP.\r
+\r
+    VOMP is free software; you can redistribute it and/or modify\r
+    it under the terms of the GNU General Public License as published by\r
+    the Free Software Foundation; either version 2 of the License, or\r
+    (at your option) any later version.\r
+\r
+    VOMP is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+    GNU General Public License for more details.\r
+\r
+    You should have received a copy of the GNU General Public License\r
+    along with VOMP; if not, write to the Free Software\r
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+*/\r
+\r
+#ifndef VOMPRESWIN_H\r
+#define _WIN32_WINNT 0x501\r
+\r
+#include <winsock2.h>\r
+#include <winuser.h>\r
+#define VOMPACCELERATOR 1\r
+#define VOMP_FULL_SCREEN 101\r
+\r
+#define VOMPRESWIN_H\r
+#endif\r
+\r
index 103371a7b57924054b4b288b3d773d5f3bea4589..7d0fbf595151498b41d7965ea2f65674795b09ac 100644 (file)
@@ -1,43 +1,45 @@
-
-
-#include "vompreswin.h"
-
-
-
-//1 TEXTINCLUDE
-//BEGIN
-//    "#include ""winsock2.h""\r\n"
-//    "#include ""vompreswin.h""\r\n"
-//    "\0"
-//END
-
-
-
-
-
-VOMPACCELERATOR ACCELERATORS
-BEGIN
-    VK_INSERT,      APPCOMMAND_MEDIA_CHANNEL_DOWN, VIRTKEY, CONTROL,
-                                                    NOINVERT
-    VK_INSERT,      APPCOMMAND_MEDIA_CHANNEL_DOWN, VIRTKEY, NOINVERT
-    VK_PRIOR,       APPCOMMAND_MEDIA_CHANNEL_DOWN, VIRTKEY, NOINVERT
-    VK_OEM_PLUS,    APPCOMMAND_MEDIA_CHANNEL_UP, VIRTKEY, CONTROL, NOINVERT
-    VK_OEM_PLUS,    APPCOMMAND_MEDIA_CHANNEL_UP, VIRTKEY, NOINVERT
-    VK_NEXT,        APPCOMMAND_MEDIA_CHANNEL_UP, VIRTKEY, NOINVERT
-    "F",            APPCOMMAND_MEDIA_FAST_FORWARD, VIRTKEY, SHIFT, CONTROL,
-                                                    NOINVERT
-    VK_F8,          APPCOMMAND_VOLUME_MUTE, VIRTKEY, NOINVERT
-    "P",            APPCOMMAND_MEDIA_PAUSE, VIRTKEY, CONTROL, NOINVERT
-    "P",            APPCOMMAND_MEDIA_PLAY,  VIRTKEY, SHIFT, CONTROL,
-                                                    NOINVERT
-    "R",            APPCOMMAND_MEDIA_RECORD, VIRTKEY, CONTROL, NOINVERT
-    "B",            APPCOMMAND_MEDIA_PREVIOUSTRACK, VIRTKEY, CONTROL,
-                                                    NOINVERT
-    "F",            APPCOMMAND_MEDIA_NEXTTRACK, VIRTKEY, CONTROL, NOINVERT
-    "S",            APPCOMMAND_MEDIA_STOP,  VIRTKEY, CONTROL, NOINVERT
-    VK_F9,          APPCOMMAND_VOLUME_DOWN, VIRTKEY, NOINVERT
-    VK_F10,         APPCOMMAND_VOLUME_UP,   VIRTKEY, NOINVERT
-END
-
-
-
+\r
+\r
+#include "vompreswin.h"\r
+\r
+\r
+\r
+//1 TEXTINCLUDE \r
+//BEGIN\r
+//    "#include ""winsock2.h""\r\n"\r
+//    "#include ""vompreswin.h""\r\n"\r
+//    "\0"\r
+//END\r
+\r
+\r
+\r
+\r
+\r
+VOMPACCELERATOR ACCELERATORS \r
+BEGIN\r
+    VK_INSERT,      APPCOMMAND_MEDIA_CHANNEL_DOWN, VIRTKEY, CONTROL, \r
+                                                    NOINVERT\r
+    VK_INSERT,      APPCOMMAND_MEDIA_CHANNEL_DOWN, VIRTKEY, NOINVERT\r
+    VK_PRIOR,       APPCOMMAND_MEDIA_CHANNEL_DOWN, VIRTKEY, NOINVERT\r
+    VK_OEM_PLUS,    APPCOMMAND_MEDIA_CHANNEL_UP, VIRTKEY, CONTROL, NOINVERT\r
+    VK_OEM_PLUS,    APPCOMMAND_MEDIA_CHANNEL_UP, VIRTKEY, NOINVERT\r
+    VK_NEXT,        APPCOMMAND_MEDIA_CHANNEL_UP, VIRTKEY, NOINVERT\r
+    "F",            APPCOMMAND_MEDIA_FAST_FORWARD, VIRTKEY, SHIFT, CONTROL, \r
+                                                    NOINVERT\r
+    VK_F8,          APPCOMMAND_VOLUME_MUTE, VIRTKEY, NOINVERT\r
+    "P",            APPCOMMAND_MEDIA_PAUSE, VIRTKEY, CONTROL, NOINVERT\r
+    "P",            APPCOMMAND_MEDIA_PLAY,  VIRTKEY, SHIFT, CONTROL, \r
+                                                    NOINVERT\r
+    "R",            APPCOMMAND_MEDIA_RECORD, VIRTKEY, CONTROL, NOINVERT\r
+    "B",            APPCOMMAND_MEDIA_PREVIOUSTRACK, VIRTKEY, CONTROL, \r
+                                                    NOINVERT\r
+    "F",            APPCOMMAND_MEDIA_NEXTTRACK, VIRTKEY, CONTROL, NOINVERT\r
+    "S",            APPCOMMAND_MEDIA_STOP,  VIRTKEY, CONTROL, NOINVERT\r
+    VK_F9,          APPCOMMAND_VOLUME_DOWN, VIRTKEY, NOINVERT\r
+    VK_F10,         APPCOMMAND_VOLUME_UP,   VIRTKEY, NOINVERT\r
+       VK_RETURN,      VOMP_FULL_SCREEN,       VIRTKEY, ALT, NOINVERT\r
+END\r
+\r
+\r
+\r
+\r
index f6053face0becb10c9f274cd963ad6c76ddc3ad8..e6e945926f36cd40f9b6152bdb30442581272834 100644 (file)
-/*
-    Copyright 2004-2005 Chris Tallon
-
-    This file is part of VOMP.
-
-    VOMP is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    VOMP is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-#ifdef WIN32
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-
-#define _WIN32_WINNT 0x501
-#include <winsock2.h>
-#include <windows.h>
-
-#include "vompreswin.h"
-
-#include "defines.h"
-#include "log.h"
-#include "remotewin.h"
-#include "ledwin.h"
-#include "mtdwin.h"
-#include "timers.h"
-#include "videowin.h"
-#include "audiowin.h"
-#include "vdr.h"
-#include "osdwin.h"
-#include "viewman.h"
-#include "command.h"
-
-void sighandler(int signalReceived);
-void shutdown(int code);
-
-// Global variables --------------------------------------------------------------------------------------------------
-int debugEnabled = 0;
-Log* logger;
-Remote* remote;
-Mtd* mtd;
-Led* led;
-Osd* osd;
-Timers* timers;
-ViewMan* viewman;
-Command* command;
-VDR* vdr;
-Video* video;
-Audio* audio;
-
-
+/*\r
+    Copyright 2004-2005 Chris Tallon\r
+\r
+    This file is part of VOMP.\r
+\r
+    VOMP is free software; you can redistribute it and/or modify\r
+    it under the terms of the GNU General Public License as published by\r
+    the Free Software Foundation; either version 2 of the License, or\r
+    (at your option) any later version.\r
+\r
+    VOMP is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+    GNU General Public License for more details.\r
+\r
+    You should have received a copy of the GNU General Public License\r
+    along with VOMP; if not, write to the Free Software\r
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+*/\r
+#ifdef WIN32\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <signal.h>\r
+\r
+#define _WIN32_WINNT 0x501\r
+#include <winsock2.h>\r
+#include <windows.h>\r
+\r
+#include "vompreswin.h"\r
+\r
+#include "defines.h"\r
+#include "log.h"\r
+#include "remotewin.h"\r
+#include "ledwin.h"\r
+#include "mtdwin.h"\r
+#include "timers.h"\r
+#include "videowin.h"\r
+#include "audiowin.h"\r
+#include "vdr.h"\r
+#include "osdwin.h"\r
+#include "viewman.h"\r
+#include "command.h"\r
+\r
+void sighandler(int signalReceived);\r
+void shutdown(int code);\r
+\r
+// Global variables --------------------------------------------------------------------------------------------------\r
+int debugEnabled = 0;\r
+Log* logger;\r
+Remote* remote;\r
+Mtd* mtd;\r
+Led* led;\r
+Osd* osd;\r
+Timers* timers;\r
+ViewMan* viewman;\r
+Command* command;\r
+VDR* vdr;\r
+Video* video;\r
+Audio* audio;\r
+bool wnd_fullscreen=false;\r
+RECT wnd_fs_rect={20,20,768+20,576+20};\r
+RECT wnd_fs_rect_client={0,0,768,576};\r
+\r
+\r
 void MILLISLEEP(ULONG a)
 {
 
   Sleep(a);
 
-}
-
-DWORD WINAPI commandthreadStart(void *arg)
-{
-        command->run();
-        return 0;
-}
-
-bool InitApp(HINSTANCE hinst,int cmdshow);
-
-HWND win;//global window handle
-HACCEL acc;
-
-#define ERROR_MSG(str) MessageBox(win,str,"Error!",MB_OK|MB_ICONWARNING)
-INT WINAPI WinMain( HINSTANCE hinst , HINSTANCE previnst, LPSTR cmdline, int cmdshow)
-{
-  //On Windows we have to init a window, we use DXUT
-       if (!InitApp(hinst,cmdshow)) return false;
-  //Starting Network support
-  WSADATA wsadat; 
-  int result = WSAStartup(MAKEWORD(2,2),&wsadat);
-  if (result!=NO_ERROR) {
-        ERROR_MSG("Initialising WinSocked: Error at WSAStartup()\n");
-               return 0;
-  }
-  result= CoInitializeEx(NULL,COINIT_MULTITHREADED );//Initialize COM for DirectShow
-  if (result!=S_OK) {
-         ERROR_MSG("Initialising COM: Error at Coinitialize()\n");
-         return 0;
-  }
-
-
-
-
-  // Init global vars ------------------------------------------------------------------------------------------------
-
-  logger     = new Log();
-  remote     = new RemoteWin();
-  mtd        = new MtdWin();
-  led        = new LedWin();
-  timers     = new Timers();
-  osd        = new OsdWin();
-  vdr        = new VDR();
-  video      = new VideoWin();
-  audio      = new AudioWin();
-  viewman    = new ViewMan();
-  command    = new Command();
-
-  if (!logger || !remote || !mtd || !led || !osd || !video || !audio || !viewman || !command)
-  {
-    ERROR_MSG("Could not create objects. Memory problems?\n");
-    shutdown(1);
-       WSACleanup();
-       return 0;
-  }
-
-  // Get logging module started --------------------------------------------------------------------------------------
-
-  if (!logger->init(Log::DEBUG, "vompwin.log", true))
-  {
-    ERROR_MSG("Could not initialise log object. Aborting.\n");
-    shutdown(1);
-       WSACleanup();
-       return 0;
-  }
-
-  logger->log("Core", Log::INFO, "Starting up...");
-  
-
-
-  // Init modules ----------------------------------------------------------------------------------------------------
-  int success;
-
-  success = remote->init("/dev/rawir");
-  if (success)
-  {
-    logger->log("Core", Log::INFO, "Remote module initialised");
-  }
-  else
-  {
-    logger->log("Core", Log::EMERG, "Remote module failed to initialise");
-    shutdown(1);
-       WSACleanup();
-       return 0;
-  }
-
-  success = led->init(0);
-  if (success)
-  {
-    logger->log("Core", Log::INFO, "LED module initialised");
-  }
-  else
-  {
-    logger->log("Core", Log::EMERG, "LED module failed to initialise");
-    shutdown(1);
-       WSACleanup();
-       return 0;
-  }
-
-  success = mtd->init("/dev/mtd1");
-  if (success)
-  {
-    logger->log("Core", Log::INFO, "Mtd module initialised");
-  }
-  else
-  {
-    logger->log("Core", Log::EMERG, "Mtd module failed to initialise");
-    shutdown(1);
-       WSACleanup();
-       return 0;
-  }
-
-  success = timers->init();
-  if (success)
-  {
-    logger->log("Core", Log::INFO, "Timers module initialised");
-  }
-  else
-  {
-    logger->log("Core", Log::EMERG, "Timers module failed to initialise");
-    shutdown(1);
-       WSACleanup();
-       return 0;
-  }
-
-  UCHAR videoFormat = (UCHAR)mtd->getPALorNTSC();
-  if      (videoFormat == Video::PAL)  logger->log("Core", Log::INFO, "Read from MTD: PAL 720x576");
-  else if (videoFormat == Video::NTSC) logger->log("Core", Log::INFO, "Read from MTD: NTSC 720x480");
-  else                                 logger->log("Core", Log::INFO, "No help from MTD. Assuming NTSC 720x480");
-
-  success = video->init(videoFormat);
-  if (success)
-  {
-    logger->log("Core", Log::INFO, "Video module initialised");
-  }
-  else
-  {
-    logger->log("Core", Log::EMERG, "Video module failed to initialise");
-    shutdown(1);
-       WSACleanup();
-       return 0;
-  }
-
-  success = osd->init((void*)&win);
-  if (success)
-  {
-    logger->log("Core", Log::INFO, "OSD module initialised");
-  }
-  else
-  {
-    logger->log("Core", Log::EMERG, "OSD module failed to initialise");
-    shutdown(1);
-       WSACleanup();
-       return 0;
-  }
-
-  success = audio->init(Audio::MPEG2_PES);
-  if (success)
-  {
-    logger->log("Core", Log::INFO, "Audio module initialised");
-  }
-  else
-  {
-    logger->log("Core", Log::EMERG, "Audio module failed to initialise");
-    shutdown(1);
-       WSACleanup();
-       return 0;
-  }
-
-  success = vdr->init(3024);
-  if (success)
-  {
-    logger->log("Core", Log::INFO, "VDR module initialised");
-  }
-  else
-  {
-    logger->log("Core", Log::EMERG, "VDR module failed to initialise");
-    shutdown(1);
-       WSACleanup();
-       return 0;
-  }
-
-  success = viewman->init();
-  if (success)
-  {
-    logger->log("Core", Log::INFO, "ViewMan module initialised");
-  }
-  else
-  {
-    logger->log("Core", Log::EMERG, "ViewMan module failed to initialise");
-    shutdown(1);
-       WSACleanup();
-       return 0;
-  }
-
-  success = command->init();
-  if (success)
-  {
-    logger->log("Core", Log::INFO, "Command module initialised");
-  }
-  else
-  {
-    logger->log("Core", Log::EMERG, "Command module failed to initialise");
-    shutdown(1);
-       WSACleanup();
-       return 0;
-  }
-
-  // Other init ------------------------------------------------------------------------------------------------------
-
-  logger->log("Core", Log::NOTICE, "Startup successful");
-
-  // Run main loop ---------------------------------------------------------------------------------------------------
-
-  // Ok, all major device components and other bits are loaded and ready
-  
-  HANDLE commandthread;
- commandthread= CreateThread(NULL, 0, commandthreadStart, NULL,0, 
-         NULL);
-  MSG message;
-  message.message=WM_NULL;
-  bool run=true;
-  while(run && WaitForSingleObject(commandthread,0)==WAIT_TIMEOUT) {
-         if (PeekMessage(&message, NULL, 0,0,PM_REMOVE)!=0) {
-                 if (TranslateAccelerator(win,acc,&message)==NULL) {
-                         TranslateMessage(&message);
-                         DispatchMessage(&message);
-                         switch (message.message) {
-                         case WM_QUIT:
-                                 run=false; //TODO post exit to command Messages
-                         };
-                 }
-         } else {
-                 //Render
-                 ((OsdWin*)osd)->Render();
-         }
-  }
-  // When that returns quit ------------------------------------------------------------------------------------------
-  WaitForSingleObject(commandthread,INFINITE);
-  shutdown(0);
-  WSACleanup();
-  return 0;
-
-}
-
-
-
-void CalculateWindowSize(RECT * size,ULONG size_mode) {
-       DWORD width, height;
-       DWORD adjheight,adjwidth;
-       DWORD flags =WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU 
-                 |WS_MINIMIZEBOX | WS_SIZEBOX |WS_MAXIMIZEBOX;
-       RECT wnted={50,50,150,150};
-       AdjustWindowRect(&wnted,flags ,false);
-       adjwidth=-wnted.left+wnted.right-100;
-       adjheight=-wnted.top+wnted.bottom-100;
-       width=size->right-size->left-adjwidth;
-       height=size->bottom-size->top-adjheight;
-       UCHAR mode=video->getMode();
-       UCHAR aspect=((VideoWin*)video)->getAspectRatio();
-       UCHAR tvsize=((VideoWin*)video)->getPseudoTVsize();
-       double aspectrt=4./3.;
-       if (tvsize==Video::ASPECT16X9) {
-               if (aspect==Video::ASPECT16X9) {
-                       aspectrt=4./3.; //looks strange, but it is a 16:9 tv
-               } else if (aspect==Video::ASPECT4X3) {
-                       aspectrt=4./3./(16./9.)*(4./3.); //I hope this is correct
-               }
-       } else if (tvsize==Video::ASPECT4X3) {
-               if (aspect==Video::ASPECT16X9) {
-                       if (mode==Video::LETTERBOX) {
-                               aspectrt=16./9.;
-                       } else {
-                               aspectrt=4./3.;
-                       }
-               } if (aspect==Video::ASPECT4X3) {
-                       aspectrt=4./3.;
-               }
-       }
-       switch (size_mode) {
-       case WMSZ_BOTTOM:
-       case WMSZ_BOTTOMRIGHT:
-       case WMSZ_TOP:
-       case WMSZ_TOPRIGHT:
-       width=(ULONG)(((double)height)*aspectrt);
-       size->right=size->left+width+adjwidth;
-       break;
-       case WMSZ_BOTTOMLEFT:
-       case WMSZ_TOPLEFT:
-       width=(ULONG)(((double)height)*aspectrt);
-       size->left=size->right-width-adjwidth;
-       break;
-       case WMSZ_LEFT:
-       case WMSZ_RIGHT:
-       height=(ULONG)(((double)width)/aspectrt);
-       size->bottom=size->top+height+adjheight;
-       break;
-       }
-}
-
-void AdjustWindow() {
-       RECT winrect;
-       GetWindowRect(win,&winrect);
-       CalculateWindowSize(&winrect,WMSZ_BOTTOM);
-       MoveWindow(win,winrect.left,
-               winrect.top,winrect.right-winrect.left,winrect.bottom-winrect.top,true);
-
-}
-
-LONG FAR PASCAL WindowProc(HWND win, UINT msg, WPARAM wparam, LPARAM lparam)
-{
-   switch (msg) {
-   case WM_DESTROY: {
-          //TODO: call command
-          logger->log("Core", Log::NOTICE, "Window closed, shutting down...");
-       command->stop(); // FIXME this is probably not safe - use the messaging system / is that even safe?
-          ((RemoteWin*)Remote::getInstance())->Signal();
-          PostQuitMessage(0);
-       }break;
-   case WM_SIZING: {
-          CalculateWindowSize((RECT*) lparam,wparam);
-          return TRUE;
-                                  }break;
-       case WM_SIZE: {
-        int width = LOWORD(lparam);
-        int height = HIWORD(lparam);
-         //Call device
-        }
-        break;
-        case WM_PAINT:
-        RECT r;
-        PAINTSTRUCT ps;
-        if (GetUpdateRect(win, &r, FALSE)) {
-            BeginPaint(win, &ps);
-            //Call Painting Mechanism
-            EndPaint(win, &ps);
-        }
-        break;
-        case WM_KEYDOWN:
-                if (((RemoteWin*)remote)->ReceiveButtonVK(wparam)) {
-                        return 0L; //We process that Key
-                } else {
-                        return DefWindowProc(win, msg, wparam, lparam);
-                }
-
-                break;
-       case WM_APPCOMMAND:
-               if (((RemoteWin*)remote)->ReceiveButtonAP(GET_APPCOMMAND_LPARAM(lparam))){
-                       return TRUE; //yes we process that message
-               } else {
-                       return DefWindowProc(win, msg, wparam, lparam);
-               }
-
-               break;
-       case WM_COMMAND:
-               if (((RemoteWin*)remote)->ReceiveButtonAP(LOWORD(wparam))){
-                       return 0; //yes we process that message
-               } else {
-                       return DefWindowProc(win, msg, wparam, lparam);
-               }
-
-               break;
-    default:
-        return DefWindowProc(win, msg, wparam, lparam);
-    }
-    return 0L;
-}
-
-
-bool InitApp(HINSTANCE hinst,int cmdshow) {
-       WNDCLASS wcs;
-       DWORD flags;
-       wcs.style = CS_HREDRAW | CS_VREDRAW;
-    wcs.lpfnWndProc = WindowProc;
-    wcs.cbClsExtra = 0;
-    wcs.cbWndExtra = sizeof(DWORD);
-    wcs.hInstance = hinst;
-    wcs.hIcon = NULL;
-    wcs.hCursor = NULL;
-    wcs.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
-    wcs.lpszMenuName = NULL;
-    wcs.lpszClassName = "vomp";
-       acc=LoadAccelerators(hinst,MAKEINTRESOURCE(VOMPACCELERATOR));
-       if (!RegisterClass(&wcs))
-        return false;
-       flags =WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU 
-                 |WS_MINIMIZEBOX | WS_SIZEBOX |WS_MAXIMIZEBOX;
-       RECT wnted={50,50,768+50,576+50};
-       AdjustWindowRect(&wnted,flags ,false);
-       win=CreateWindow("vomp","vomp",flags, CW_USEDEFAULT,CW_USEDEFAULT,
-               wnted.right-wnted.left,wnted.bottom-wnted.top,NULL,NULL,hinst,NULL);
-       if (!win)
-        return FALSE;
-       ShowWindow(win,SW_SHOWNORMAL);
-    UpdateWindow(win);
-       return TRUE;
-}
-
-
-
-
-
-// -------------------------------------------------------------------------------------------------------------------
-
-void shutdown(int code)
-{
-  if (viewman)
-  {
-    viewman->shutdown();
-    delete viewman;
-    logger->log("Core", Log::NOTICE, "ViewMan module shut down");
-  }
-
-  if (command) // shut down command here in case views have posted messages
-  {
-    command->shutdown();
-    delete command;
-    logger->log("Core", Log::NOTICE, "Command module shut down");
-  }
-
-  if (vdr)
-  {
-    vdr->shutdown();
-    delete vdr;
-    logger->log("Core", Log::NOTICE, "VDR module shut down");
-  }
-
-  if (osd)
-  {
-    osd->shutdown();
-    delete osd;
-    logger->log("Core", Log::NOTICE, "OSD module shut down");
-  }
-
-  if (audio)
-  {
-    audio->shutdown();
-    delete audio;
-    logger->log("Core", Log::NOTICE, "Audio module shut down");
-  }
-
-  if (video)
-  {
-    video->shutdown();
-    delete video;
-    logger->log("Core", Log::NOTICE, "Video module shut down");
-  }
-
-  if (timers)
-  {
-    timers->shutdown();
-    delete timers;
-    logger->log("Core", Log::NOTICE, "Timers module shut down");
-  }
-
-  if (mtd)
-  {
-    mtd->shutdown();
-    delete mtd;
-    logger->log("Core", Log::NOTICE, "MTD module shut down");
-  }
-
-  if (led)
-  {
-    led->shutdown();
-    delete led;
-    logger->log("Core", Log::NOTICE, "LED module shut down");
-  }
-
-  if (remote)
-  {
-    remote->shutdown();
-    delete remote;
-    logger->log("Core", Log::NOTICE, "Remote module shut down");
-  }
-
-  if (logger)
-  {
-    logger->log("Core", Log::NOTICE, "Log module shutting down... bye!\n\n");
-    logger->shutdown();
-    delete logger;
-  }
-  ExitProcess(0);
-
-}
-
-// -------------------------------------------------------------------------------------------------------------------
-
-ULLONG ntohll(ULLONG a)
-{
-  return htonll(a);
-}
-
-ULLONG htonll(ULLONG a)
-{
-       return (((ULLONG)htonl((ULONG)((a<<32)>> 32))<<32) 
-               |(ULONG)htonl(((ULONG) (a >> 32))));
-}
-#endif
+}\r
+\r
+DWORD WINAPI commandthreadStart(void *arg)\r
+{\r
+        command->run();\r
+        return 0;\r
+}\r
+\r
+bool InitApp(HINSTANCE hinst,int cmdshow);\r
+\r
+HWND win_main;//global window handle\r
+HWND win;//global child window handle\r
+HACCEL acc;\r
+\r
+#define ERROR_MSG(str) MessageBox(win_main,str,"Error!",MB_OK|MB_ICONWARNING)\r
+INT WINAPI WinMain( HINSTANCE hinst , HINSTANCE previnst, LPSTR cmdline, int cmdshow)\r
+{\r
+  //On Windows we have to init a window, we use DXUT\r
+       if (!InitApp(hinst,cmdshow)) return false;\r
+  //Starting Network support\r
+  WSADATA wsadat; \r
+  int result = WSAStartup(MAKEWORD(2,2),&wsadat);\r
+  if (result!=NO_ERROR) {\r
+        ERROR_MSG("Initialising WinSocked: Error at WSAStartup()\n");\r
+               return 0;\r
+  }\r
+  result= CoInitializeEx(NULL,COINIT_MULTITHREADED );//Initialize COM for DirectShow\r
+  if (result!=S_OK) {\r
+         ERROR_MSG("Initialising COM: Error at Coinitialize()\n");\r
+         return 0;\r
+  }\r
+\r
+\r
+\r
+\r
+  // Init global vars ------------------------------------------------------------------------------------------------\r
+\r
+  logger     = new Log();\r
+  remote     = new RemoteWin();\r
+  mtd        = new MtdWin();\r
+  led        = new LedWin();\r
+  timers     = new Timers();\r
+  osd        = new OsdWin();\r
+  vdr        = new VDR();\r
+  video      = new VideoWin();\r
+  audio      = new AudioWin();\r
+  viewman    = new ViewMan();\r
+  command    = new Command();\r
+\r
+  if (!logger || !remote || !mtd || !led || !osd || !video || !audio || !viewman || !command)\r
+  {\r
+    ERROR_MSG("Could not create objects. Memory problems?\n");\r
+    shutdown(1);\r
+       WSACleanup();\r
+       return 0;\r
+  }\r
+\r
+  // Get logging module started --------------------------------------------------------------------------------------\r
+\r
+  if (!logger->init(Log::DEBUG, "vompwin.log", true))\r
+  {\r
+    ERROR_MSG("Could not initialise log object. Aborting.\n");\r
+    shutdown(1);\r
+       WSACleanup();\r
+       return 0;\r
+  }\r
+\r
+  logger->log("Core", Log::INFO, "Starting up...");\r
+  \r
+\r
+\r
+  // Init modules ----------------------------------------------------------------------------------------------------\r
+  int success;\r
+\r
+  success = remote->init("/dev/rawir");\r
+  if (success)\r
+  {\r
+    logger->log("Core", Log::INFO, "Remote module initialised");\r
+  }\r
+  else\r
+  {\r
+    logger->log("Core", Log::EMERG, "Remote module failed to initialise");\r
+    shutdown(1);\r
+       WSACleanup();\r
+       return 0;\r
+  }\r
+\r
+  success = led->init(0);\r
+  if (success)\r
+  {\r
+    logger->log("Core", Log::INFO, "LED module initialised");\r
+  }\r
+  else\r
+  {\r
+    logger->log("Core", Log::EMERG, "LED module failed to initialise");\r
+    shutdown(1);\r
+       WSACleanup();\r
+       return 0;\r
+  }\r
+\r
+  success = mtd->init("/dev/mtd1");\r
+  if (success)\r
+  {\r
+    logger->log("Core", Log::INFO, "Mtd module initialised");\r
+  }\r
+  else\r
+  {\r
+    logger->log("Core", Log::EMERG, "Mtd module failed to initialise");\r
+    shutdown(1);\r
+       WSACleanup();\r
+       return 0;\r
+  }\r
+\r
+  success = timers->init();\r
+  if (success)\r
+  {\r
+    logger->log("Core", Log::INFO, "Timers module initialised");\r
+  }\r
+  else\r
+  {\r
+    logger->log("Core", Log::EMERG, "Timers module failed to initialise");\r
+    shutdown(1);\r
+       WSACleanup();\r
+       return 0;\r
+  }\r
+\r
+  UCHAR videoFormat = (UCHAR)mtd->getPALorNTSC();\r
+  if      (videoFormat == Video::PAL)  logger->log("Core", Log::INFO, "Read from MTD: PAL 720x576");\r
+  else if (videoFormat == Video::NTSC) logger->log("Core", Log::INFO, "Read from MTD: NTSC 720x480");\r
+  else                                 logger->log("Core", Log::INFO, "No help from MTD. Assuming NTSC 720x480");\r
+\r
+  success = video->init(videoFormat);\r
+  if (success)\r
+  {\r
+    logger->log("Core", Log::INFO, "Video module initialised");\r
+  }\r
+  else\r
+  {\r
+    logger->log("Core", Log::EMERG, "Video module failed to initialise");\r
+    shutdown(1);\r
+       WSACleanup();\r
+       return 0;\r
+  }\r
+\r
+  success = osd->init((void*)&win);\r
+  if (success)\r
+  {\r
+    logger->log("Core", Log::INFO, "OSD module initialised");\r
+  }\r
+  else\r
+  {\r
+    logger->log("Core", Log::EMERG, "OSD module failed to initialise");\r
+    shutdown(1);\r
+       WSACleanup();\r
+       return 0;\r
+  }\r
+\r
+  success = audio->init(Audio::MPEG2_PES);\r
+  if (success)\r
+  {\r
+    logger->log("Core", Log::INFO, "Audio module initialised");\r
+  }\r
+  else\r
+  {\r
+    logger->log("Core", Log::EMERG, "Audio module failed to initialise");\r
+    shutdown(1);\r
+       WSACleanup();\r
+       return 0;\r
+  }\r
+\r
+  success = vdr->init(3024);\r
+  if (success)\r
+  {\r
+    logger->log("Core", Log::INFO, "VDR module initialised");\r
+  }\r
+  else\r
+  {\r
+    logger->log("Core", Log::EMERG, "VDR module failed to initialise");\r
+    shutdown(1);\r
+       WSACleanup();\r
+       return 0;\r
+  }\r
+\r
+  success = viewman->init();\r
+  if (success)\r
+  {\r
+    logger->log("Core", Log::INFO, "ViewMan module initialised");\r
+  }\r
+  else\r
+  {\r
+    logger->log("Core", Log::EMERG, "ViewMan module failed to initialise");\r
+    shutdown(1);\r
+       WSACleanup();\r
+       return 0;\r
+  }\r
+\r
+  success = command->init();\r
+  if (success)\r
+  {\r
+    logger->log("Core", Log::INFO, "Command module initialised");\r
+  }\r
+  else\r
+  {\r
+    logger->log("Core", Log::EMERG, "Command module failed to initialise");\r
+    shutdown(1);\r
+       WSACleanup();\r
+       return 0;\r
+  }\r
+\r
+  // Other init ------------------------------------------------------------------------------------------------------\r
+\r
+  logger->log("Core", Log::NOTICE, "Startup successful");\r
+\r
+  // Run main loop ---------------------------------------------------------------------------------------------------\r
+\r
+  // Ok, all major device components and other bits are loaded and ready\r
+  \r
+  HANDLE commandthread;\r
+ commandthread= CreateThread(NULL, 0, commandthreadStart, NULL,0, \r
+         NULL);\r
+  MSG message;\r
+  message.message=WM_NULL;\r
+  bool run=true;\r
+  while(run && WaitForSingleObject(commandthread,0)==WAIT_TIMEOUT) {\r
+         if (PeekMessage(&message, NULL, 0,0,PM_REMOVE)!=0) {\r
+                 if (TranslateAccelerator(win_main,acc,&message)==NULL) {\r
+                         TranslateMessage(&message);\r
+                         DispatchMessage(&message);\r
+                         switch (message.message) {\r
+                         case WM_QUIT:\r
+                                 run=false; //TODO post exit to command Messages\r
+                         };\r
+                 }\r
+         } else {\r
+                 //Render\r
+                 ((OsdWin*)osd)->Render();\r
+         }\r
+  }\r
+  // When that returns quit ------------------------------------------------------------------------------------------\r
+  WaitForSingleObject(commandthread,INFINITE);\r
+  shutdown(0);\r
+  WSACleanup();\r
+  return 0;\r
+\r
+}\r
+\r
+\r
+\r
+void CalculateWindowSize(RECT * size,ULONG size_mode) {\r
+       \r
+       DWORD width, height;\r
+       DWORD adjheight,adjwidth;\r
+       if (!wnd_fullscreen) {\r
+               DWORD flags =WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU \r
+                                |WS_MINIMIZEBOX | WS_SIZEBOX |WS_MAXIMIZEBOX;\r
+               RECT wnted={50,50,150,150};\r
+               AdjustWindowRect(&wnted,flags ,false);\r
+               adjwidth=-wnted.left+wnted.right-100;\r
+               adjheight=-wnted.top+wnted.bottom-100;\r
+       } else {\r
+               adjwidth=adjheight=0;\r
+       }\r
+       width=size->right-size->left-adjwidth;\r
+       height=size->bottom-size->top-adjheight;\r
+       UCHAR mode=video->getMode();\r
+       UCHAR aspect=((VideoWin*)video)->getAspectRatio();\r
+       UCHAR tvsize=((VideoWin*)video)->getPseudoTVsize();\r
+       double aspectrt=4./3.;\r
+       if (tvsize==Video::ASPECT16X9) {\r
+               if (aspect==Video::ASPECT16X9) {\r
+                       aspectrt=4./3.; //looks strange, but it is a 16:9 tv\r
+               } else if (aspect==Video::ASPECT4X3) {\r
+                       aspectrt=4./3./(16./9.)*(4./3.); //I hope this is correct\r
+               }\r
+       } else if (tvsize==Video::ASPECT4X3) {\r
+               if (aspect==Video::ASPECT16X9) {\r
+                       if (mode!=Video::NORMAL) {\r
+                               aspectrt=16./9.;\r
+                       } else {\r
+                               aspectrt=4./3.;\r
+                       }\r
+               } else if (aspect==Video::ASPECT4X3) {\r
+                       aspectrt=4./3.;\r
+               }\r
+       }\r
+       if (!wnd_fullscreen) {\r
+               switch (size_mode) {\r
+               case WMSZ_BOTTOM:\r
+               case WMSZ_BOTTOMRIGHT:\r
+               case WMSZ_TOP:\r
+               case WMSZ_TOPRIGHT:\r
+               width=(ULONG)(((double)height)*aspectrt);\r
+               size->right=size->left+width+adjwidth;\r
+               break;\r
+               case WMSZ_BOTTOMLEFT:\r
+               case WMSZ_TOPLEFT:\r
+               width=(ULONG)(((double)height)*aspectrt);\r
+               size->left=size->right-width-adjwidth;\r
+               break;\r
+               case WMSZ_LEFT:\r
+               case WMSZ_RIGHT:\r
+               height=(ULONG)(((double)width)/aspectrt);\r
+               size->bottom=size->top+height+adjheight;\r
+               break;\r
+               }\r
+               MoveWindow(win,0,0,width,height,TRUE);\r
+       } else {\r
+               RECT newrect={0,0,width,height};\r
+               DWORD newlength;\r
+               if ((ULONG)(((double)height)*aspectrt)>width) {\r
+                       newlength=(ULONG)(((double)width)/aspectrt);\r
+                       newrect.top+=(height-newlength)/2;\r
+                       newrect.bottom-=(height-newlength);\r
+               } else {\r
+                       newlength=(ULONG)(((double)height)*aspectrt);\r
+                       newrect.left+=(width-newlength)/2;\r
+                       newrect.right-=(width-newlength);\r
+               }\r
+               MoveWindow(win,newrect.left,newrect.top,newrect.right,newrect.bottom,TRUE);\r
+       }\r
+       \r
+}\r
+\r
+void AdjustWindow() {\r
+       if (!wnd_fullscreen) {\r
+               RECT winrect;\r
+               GetWindowRect(win_main,&winrect);\r
+               CalculateWindowSize(&winrect,WMSZ_BOTTOM);\r
+               MoveWindow(win_main,winrect.left,\r
+                       winrect.top,winrect.right-winrect.left,winrect.bottom-winrect.top,true);\r
+       } else {\r
+               RECT winrect;\r
+               GetWindowRect(win_main,&winrect);\r
+               CalculateWindowSize(&winrect,WMSZ_BOTTOM);\r
+\r
+       }\r
+}\r
+\r
+void ToggleFullscreen() {\r
+       if (wnd_fullscreen) {\r
+               wnd_fullscreen=false;\r
+               SetWindowLong(win_main,GWL_STYLE,WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU \r
+                 |WS_MINIMIZEBOX | WS_SIZEBOX |WS_MAXIMIZEBOX);\r
+               SetWindowPos(win_main,NULL,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);\r
+\r
+               SetWindowPos(win_main,HWND_TOP,wnd_fs_rect.left,wnd_fs_rect.top,\r
+                                                       wnd_fs_rect.right-wnd_fs_rect.left,\r
+                                                       wnd_fs_rect.bottom-wnd_fs_rect.top,\r
+                                                       SWP_DRAWFRAME | SWP_FRAMECHANGED);\r
+               MoveWindow(win,wnd_fs_rect_client.left,wnd_fs_rect_client.top,\r
+                                                       wnd_fs_rect_client.right-wnd_fs_rect_client.left,\r
+                                                       wnd_fs_rect_client.bottom-wnd_fs_rect_client.top,TRUE);\r
+               AdjustWindow();\r
+       } else {\r
+               GetWindowRect(win_main,&wnd_fs_rect);\r
+               GetWindowRect(win,&wnd_fs_rect_client);\r
+               SetWindowLong(win_main,GWL_STYLE,WS_VISIBLE | WS_POPUP );\r
+               SetWindowPos(win_main,NULL,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);\r
+               HMONITOR monitor=MonitorFromWindow(win_main,MONITOR_DEFAULTTONEAREST);  \r
+               MONITORINFO moninfo;\r
+               moninfo.cbSize=sizeof(moninfo);\r
+               wnd_fullscreen=true;\r
+               if (!GetMonitorInfo(monitor,&moninfo)) return ;\r
+               SetWindowPos(win_main,HWND_TOP,moninfo.rcMonitor.left,moninfo.rcMonitor.top,\r
+                       moninfo.rcMonitor.right,moninfo.rcMonitor.bottom,SWP_FRAMECHANGED);\r
+               \r
+               AdjustWindow();\r
+               \r
+       }\r
+\r
+\r
+}\r
+\r
+LONG FAR PASCAL WindowProc(HWND wind, UINT msg, WPARAM wparam, LPARAM lparam)\r
+{\r
+   switch (msg) {\r
+   case WM_DESTROY: {\r
+          //TODO: call command\r
+          logger->log("Core", Log::NOTICE, "Window closed, shutting down...");\r
+       command->stop(); // FIXME this is probably not safe - use the messaging system / is that even safe?\r
+          ((RemoteWin*)Remote::getInstance())->Signal();\r
+          PostQuitMessage(0);\r
+       }break;\r
+   case WM_SIZING: {\r
+          CalculateWindowSize((RECT*) lparam,wparam);\r
+          return TRUE;\r
+                                  }break;\r
+       case WM_SIZE: {\r
+        int width = LOWORD(lparam);\r
+        int height = HIWORD(lparam);\r
+         //Call device\r
+        }\r
+        break;\r
+        case WM_PAINT:\r
+        RECT r;\r
+        PAINTSTRUCT ps;\r
+        if (GetUpdateRect(wind, &r, FALSE)) {\r
+            BeginPaint(wind, &ps);\r
+            //Call Painting Mechanism\r
+            EndPaint(wind, &ps);\r
+        }\r
+        break;\r
+        case WM_KEYDOWN:\r
+                if (((RemoteWin*)remote)->ReceiveButtonVK(wparam)) {\r
+                        return 0L; //We process that Key\r
+                } else {\r
+                        return DefWindowProc(wind, msg, wparam, lparam);\r
+                }\r
+\r
+                break;\r
+       case WM_APPCOMMAND:\r
+               if (((RemoteWin*)remote)->ReceiveButtonAP(GET_APPCOMMAND_LPARAM(lparam))){\r
+                       return TRUE; //yes we process that message\r
+               } else {\r
+                       return DefWindowProc(wind, msg, wparam, lparam);\r
+               }\r
+\r
+               break;\r
+       case WM_COMMAND:\r
+               if (LOWORD(wparam)==VOMP_FULL_SCREEN) {\r
+                       ToggleFullscreen();\r
+                       return 0;\r
+               }\r
+               if (((RemoteWin*)remote)->ReceiveButtonAP(LOWORD(wparam))){\r
+                       return 0; //yes we process that message\r
+               } else {\r
+                       return DefWindowProc(wind, msg, wparam, lparam);\r
+               }\r
+\r
+               break;\r
+       case WM_SETCURSOR:\r
+               if (((HANDLE)wparam)==win) {\r
+                       SetCursor(NULL);\r
+                       return 1;\r
+               } else {\r
+                       return DefWindowProc(wind, msg, wparam, lparam);\r
+               }\r
+               break;\r
+    default:\r
+        return DefWindowProc(wind, msg, wparam, lparam);\r
+    }\r
+    return 0L;\r
+}\r
+\r
+\r
+bool InitApp(HINSTANCE hinst,int cmdshow) {\r
+       /* main window */\r
+       WNDCLASS wcs;\r
+       DWORD flags;\r
+       wcs.style = CS_HREDRAW | CS_VREDRAW;\r
+    wcs.lpfnWndProc = WindowProc;\r
+    wcs.cbClsExtra = 0;\r
+    wcs.cbWndExtra = sizeof(DWORD);\r
+    wcs.hInstance = hinst;\r
+    wcs.hIcon = NULL;\r
+    wcs.hCursor = NULL;\r
+    wcs.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);\r
+    wcs.lpszMenuName = NULL;\r
+    wcs.lpszClassName = "vomp";\r
+       acc=LoadAccelerators(hinst,MAKEINTRESOURCE(VOMPACCELERATOR));\r
+       if (!RegisterClass(&wcs))\r
+        return false;\r
+       flags =WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU \r
+                 |WS_MINIMIZEBOX | WS_SIZEBOX |WS_MAXIMIZEBOX;\r
+       RECT wnted={50,50,768+50,576+50};\r
+       AdjustWindowRect(&wnted,flags ,false);\r
+       win_main=CreateWindow("vomp","VOMP on Windows",flags, CW_USEDEFAULT,CW_USEDEFAULT,\r
+               wnted.right-wnted.left,wnted.bottom-wnted.top,NULL,NULL,hinst,NULL);\r
+       if (!win_main)\r
+        return FALSE;\r
+       ShowWindow(win_main,SW_SHOWNORMAL);\r
+    UpdateWindow(win_main);\r
+       /* in order to handle letterboxing we use a child window */\r
+       WNDCLASS child_wcs;\r
+       child_wcs.style = CS_HREDRAW | CS_VREDRAW;\r
+    child_wcs.lpfnWndProc = DefWindowProc;\r
+    child_wcs.cbClsExtra = 0;\r
+    child_wcs.cbWndExtra = sizeof(DWORD);\r
+    child_wcs.hInstance = hinst;\r
+    child_wcs.hIcon = NULL;\r
+    child_wcs.hCursor = NULL;\r
+    child_wcs.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);\r
+    child_wcs.lpszMenuName = NULL;\r
+    child_wcs.lpszClassName = "vomp_playback";\r
+       if (!RegisterClass(&child_wcs))\r
+        return false;\r
+\r
+       win=CreateWindow("vomp_playback","Vomp Playback Window",WS_VISIBLE | WS_CHILD |WS_CLIPCHILDREN,\r
+               0,0,768,576,win_main,NULL,hinst,NULL);\r
+       if (!win)\r
+               return FALSE;\r
+       ShowWindow(win,SW_SHOWNORMAL);\r
+       UpdateWindow(win);\r
+       return TRUE;\r
+}\r
+\r
+\r
+\r
+\r
+\r
+// -------------------------------------------------------------------------------------------------------------------\r
+\r
+void shutdown(int code)\r
+{\r
+  if (viewman)\r
+  {\r
+    viewman->shutdown();\r
+    delete viewman;\r
+    logger->log("Core", Log::NOTICE, "ViewMan module shut down");\r
+  }\r
+\r
+  if (command) // shut down command here in case views have posted messages\r
+  {\r
+    command->shutdown();\r
+    delete command;\r
+    logger->log("Core", Log::NOTICE, "Command module shut down");\r
+  }\r
+\r
+  if (vdr)\r
+  {\r
+    vdr->shutdown();\r
+    delete vdr;\r
+    logger->log("Core", Log::NOTICE, "VDR module shut down");\r
+  }\r
+\r
+  if (osd)\r
+  {\r
+    osd->shutdown();\r
+    delete osd;\r
+    logger->log("Core", Log::NOTICE, "OSD module shut down");\r
+  }\r
+\r
+  if (audio)\r
+  {\r
+    audio->shutdown();\r
+    delete audio;\r
+    logger->log("Core", Log::NOTICE, "Audio module shut down");\r
+  }\r
+\r
+  if (video)\r
+  {\r
+    video->shutdown();\r
+    delete video;\r
+    logger->log("Core", Log::NOTICE, "Video module shut down");\r
+  }\r
+\r
+  if (timers)\r
+  {\r
+    timers->shutdown();\r
+    delete timers;\r
+    logger->log("Core", Log::NOTICE, "Timers module shut down");\r
+  }\r
+\r
+  if (mtd)\r
+  {\r
+    mtd->shutdown();\r
+    delete mtd;\r
+    logger->log("Core", Log::NOTICE, "MTD module shut down");\r
+  }\r
+\r
+  if (led)\r
+  {\r
+    led->shutdown();\r
+    delete led;\r
+    logger->log("Core", Log::NOTICE, "LED module shut down");\r
+  }\r
+\r
+  if (remote)\r
+  {\r
+    remote->shutdown();\r
+    delete remote;\r
+    logger->log("Core", Log::NOTICE, "Remote module shut down");\r
+  }\r
+\r
+  if (logger)\r
+  {\r
+    logger->log("Core", Log::NOTICE, "Log module shutting down... bye!\n\n");\r
+    logger->shutdown();\r
+    delete logger;\r
+  }\r
+  ExitProcess(0);\r
+\r
+}\r
+\r
+// -------------------------------------------------------------------------------------------------------------------\r
+\r
+ULLONG ntohll(ULLONG a)\r
+{\r
+  return htonll(a);\r
+}\r
+\r
+ULLONG htonll(ULLONG a)\r
+{\r
+       return (((ULLONG)htonl((ULONG)((a<<32)>> 32))<<32) \r
+               |(ULONG)htonl(((ULONG) (a >> 32))));\r
+}\r
+#endif\r