First Windows porting changes after adding scraper support
authorMarten Richter <marten.richter@freenet.de>
Sat, 1 Nov 2014 16:56:55 +0000 (17:56 +0100)
committerMarten Richter <marten.richter@freenet.de>
Sat, 1 Nov 2014 18:08:44 +0000 (19:08 +0100)
31 files changed:
boxstack.cc
colour.cc
defines.h
dvbsubtitles.cc
event.h
main.cc
message.h
mutex.cc
osdvector.cc
osdwin.cc
osdwin.h
surface.cc
surfacewin.cc
timers.cc
vdr.h
vepg.cc
vepgsettimer.cc
vepgsummary.cc
video.cc
videowin.cc
videowin.h
vrecording.cc
vtimeredit.cc
vtimerlist.cc
vvideolivetv.cc
winmain.cc
wselectlist.cc
wtabbar.cc
wtabbar.h
wtextbox.cc
wtextbox.h

index b8cfee5a9c10038231c5baf6ecd34e98526ac9fd..55ffa00fefe1c272710049d44119dd2d89bcc7a4 100644 (file)
@@ -571,7 +571,7 @@ void BoxStack::processMessage(Message* m)
   /* Handle mouse events*/
   // They come in with m->to = NULL? and just need to be delivered to top box?
   if ((numBoxes > 1) && ((m->message == Message::MOUSE_MOVE) || (m->message == Message::MOUSE_LBDOWN)
-                 || (m->message == Message::MOUSE_ANDROID_SCROLL)))
+                 || (m->message == Message::MOUSE_SCROLL)))
   {
     boxes[numBoxes-1]->processMessage(m);
     return;
index 78dbe1e3dc31b057a44cbda699cfbb8860630e1f..5ee9baa3fd0711af4a4c406fcd37b3ed068de326 100644 (file)
--- a/colour.cc
+++ b/colour.cc
@@ -359,42 +359,42 @@ Real colours
        DrawStyle::SELECTHIGHLIGHT.grad_col[0]=DrawStyle(0xFFa4fd15);
        DrawStyle::SELECTHIGHLIGHT.grad_col[1]=DrawStyle(0xFFa4fd15);
        DrawStyle::SELECTHIGHLIGHT.grad_col[2]=DrawStyle(0x7D000000);
-       DrawStyle::SELECTHIGHLIGHT.grad_pos[0]=0.3;
-       DrawStyle::SELECTHIGHLIGHT.grad_pos[1]=0.9;
+       DrawStyle::SELECTHIGHLIGHT.grad_pos[0]=0.3f;
+       DrawStyle::SELECTHIGHLIGHT.grad_pos[1]=0.9f;
        DrawStyle::SELECTHIGHLIGHT.num_colors=3;
        DrawStyle::SELECTHIGHLIGHT.ft=DrawStyle::GradientLinear;
-       DrawStyle::SELECTHIGHLIGHT.x1=0.0;
-       DrawStyle::SELECTHIGHLIGHT.y1=0.2;
-       DrawStyle::SELECTHIGHLIGHT.x2=1.1;
-       DrawStyle::SELECTHIGHLIGHT.y2=0.8;
+       DrawStyle::SELECTHIGHLIGHT.x1=0.0f;
+       DrawStyle::SELECTHIGHLIGHT.y1=0.2f;
+       DrawStyle::SELECTHIGHLIGHT.x2=1.1f;
+       DrawStyle::SELECTHIGHLIGHT.y2=0.8f;
 
 
        DrawStyle::SELECTDARKHIGHLIGHT=DrawStyle(0xFD999999);
        DrawStyle::SELECTDARKHIGHLIGHT.grad_col[0]=DrawStyle(0xFF7bbd0f);
        DrawStyle::SELECTDARKHIGHLIGHT.grad_col[1]=DrawStyle(0xFF7bbd0f);
        DrawStyle::SELECTDARKHIGHLIGHT.grad_col[2]=DrawStyle(0x7D000000);
-       DrawStyle::SELECTDARKHIGHLIGHT.grad_pos[0]=0.3;
-       DrawStyle::SELECTDARKHIGHLIGHT.grad_pos[1]=0.9;
+       DrawStyle::SELECTDARKHIGHLIGHT.grad_pos[0]=0.3f;
+       DrawStyle::SELECTDARKHIGHLIGHT.grad_pos[1]=0.9f;
        DrawStyle::SELECTDARKHIGHLIGHT.num_colors=3;
        DrawStyle::SELECTDARKHIGHLIGHT.ft=DrawStyle::GradientLinear;
-       DrawStyle::SELECTDARKHIGHLIGHT.x1=0.0;
-       DrawStyle::SELECTDARKHIGHLIGHT.y1=0.2;
-       DrawStyle::SELECTDARKHIGHLIGHT.x2=1.1;
-       DrawStyle::SELECTDARKHIGHLIGHT.y2=0.8;
+       DrawStyle::SELECTDARKHIGHLIGHT.x1=0.0f;
+       DrawStyle::SELECTDARKHIGHLIGHT.y1=0.2f;
+       DrawStyle::SELECTDARKHIGHLIGHT.x2=1.1f;
+       DrawStyle::SELECTDARKHIGHLIGHT.y2=0.8f;
 
 
        DrawStyle::SELECTBACKGROUND=DrawStyle(0xFE999999);
        DrawStyle::SELECTBACKGROUND.grad_col[0]=DrawStyle(0xFF353b50);
        DrawStyle::SELECTBACKGROUND.grad_col[1]=DrawStyle(0xFF353b50);
        DrawStyle::SELECTBACKGROUND.grad_col[2]=DrawStyle(0x7D000000);
-       DrawStyle::SELECTBACKGROUND.grad_pos[0]=0.3;
-       DrawStyle::SELECTBACKGROUND.grad_pos[1]=0.9;
+       DrawStyle::SELECTBACKGROUND.grad_pos[0]=0.3f;
+       DrawStyle::SELECTBACKGROUND.grad_pos[1]=0.9f;
        DrawStyle::SELECTBACKGROUND.num_colors=3;
        DrawStyle::SELECTBACKGROUND.ft=DrawStyle::GradientLinear;
-       DrawStyle::SELECTBACKGROUND.x1=0.0;
-       DrawStyle::SELECTBACKGROUND.y1=0.2;
-       DrawStyle::SELECTBACKGROUND.x2=1.1;
-       DrawStyle::SELECTBACKGROUND.y2=0.8;
+       DrawStyle::SELECTBACKGROUND.x1=0.0f;
+       DrawStyle::SELECTBACKGROUND.y1=0.2f;
+       DrawStyle::SELECTBACKGROUND.x2=1.1f;
+       DrawStyle::SELECTBACKGROUND.y2=0.8f;
 
        DrawStyle::TITLEBARBACKGROUND=DrawStyle::SELECTBACKGROUND;
 
@@ -411,14 +411,14 @@ Real colours
        DrawStyle::PROGRAMMEA.grad_col[0]=DrawStyle(0xFF353b50);
        DrawStyle::PROGRAMMEA.grad_col[1]=DrawStyle(0xFF353b50);
        DrawStyle::PROGRAMMEA.grad_col[2]=DrawStyle(0xFE999999);
-       DrawStyle::PROGRAMMEA.grad_pos[0]=0.3;
-       DrawStyle::PROGRAMMEA.grad_pos[1]=0.9;
+       DrawStyle::PROGRAMMEA.grad_pos[0]=0.3f;
+       DrawStyle::PROGRAMMEA.grad_pos[1]=0.9f;
        DrawStyle::PROGRAMMEA.num_colors=3;
        DrawStyle::PROGRAMMEA.ft=DrawStyle::GradientLinear;
-       DrawStyle::PROGRAMMEA.x1=0.0;
-       DrawStyle::PROGRAMMEA.y1=0.2;
-       DrawStyle::PROGRAMMEA.x2=1.0;
-       DrawStyle::PROGRAMMEA.y2=0.8;
+       DrawStyle::PROGRAMMEA.x1=0.0f;
+       DrawStyle::PROGRAMMEA.y1=0.2f;
+       DrawStyle::PROGRAMMEA.x2=1.0f;
+       DrawStyle::PROGRAMMEA.y2=0.8f;
 
 
        DrawStyle::NOPROGRAMME=DrawStyle(0xFF353b50); // no programme details colour
@@ -427,10 +427,10 @@ Real colours
        DrawStyle::WALLPAPER.grad_col[0]=DrawStyle(0x0012273f);
        DrawStyle::WALLPAPER.num_colors=1;
        DrawStyle::WALLPAPER.ft=DrawStyle::GradientLinear;
-       DrawStyle::WALLPAPER.x1=0.0;
-       DrawStyle::WALLPAPER.y1=0.0;
-       DrawStyle::WALLPAPER.x2=0.0;
-       DrawStyle::WALLPAPER.y2=1.0;
+       DrawStyle::WALLPAPER.x1=0.0f;
+       DrawStyle::WALLPAPER.y1=0.0f;
+       DrawStyle::WALLPAPER.x2=0.0f;
+       DrawStyle::WALLPAPER.y2=1.0f;
 
        /*
 Silly colours
index 960a5e9a383232e0edfb4ed19a5fe818d9ffb53e..b09dc657a3532072a88dcc38151479c5a8f5ba0c 100644 (file)
--- a/defines.h
+++ b/defines.h
@@ -37,6 +37,9 @@ typedef unsigned long long ULLONG;
 void MILLISLEEP(ULONG a);
 long long getTimeMS();
 
+int getClockRealTime(struct timespec *tp);
+
+
 #ifdef WIN32
 
   #define Surface_TYPE SurfaceWin
@@ -51,7 +54,7 @@ long long getTimeMS();
   #define STRCASESTR StrStrI
 /*  #define STRTOULL _strtoui64 */
   #define STRTOUL strtoul
-  #define STRTOKR strtok_l
+  #define STRTOKR strtok_s
 
   #define CLOSESOCKET closesocket
   #define DEFAULT_TCP_WINDOWSIZE 2048
index 75508c63d1f2853ecc5331d2944b5fb62481768c..2d9e7b7f3d434880d5a620dd1f819f9c91e25129 100644 (file)
@@ -47,22 +47,12 @@ cTimeMs::cTimeMs(int Ms)
 uint64_t cTimeMs::Now(void)
 {
   struct timespec tp;
-#ifndef WIN32
-  if (clock_gettime(CLOCK_REALTIME, &tp) == 0)
+
+  if (getClockRealTime(&tp) == 0)
     return (uint64_t(tp.tv_sec)) * 1000 + tp.tv_nsec / 1000000;
   else
     Log::getInstance()->log("SUBTITLES", Log::DEBUG, "cTimeMs: clock_gettime(CLOCK_REALTIME) failed");
 
-#else
-  SYSTEMTIME systime;
-   __int64  filetime;
-   __int64  test;
-  GetSystemTime(&systime);
-  SystemTimeToFileTime(&systime,(FILETIME*)&filetime);
-  tp.tv_sec=(filetime-WINDOWS_TIME_BASE_OFFSET)/(10*1000*1000);
-  tp.tv_nsec=((filetime-WINDOWS_TIME_BASE_OFFSET)%(10*1000*1000))*100;
-  return (uint64_t(tp.tv_sec)) * 1000 + tp.tv_nsec / 1000000;
-#endif
 }
 
 void cTimeMs::Set(int Ms)
@@ -982,17 +972,9 @@ void DVBSubtitles::threadMethod()
       {
         Log::getInstance()->log("SUBTITLES", Log::DEBUG, "Sleeping for %d and %d", sleeptime.tv_sec, sleeptime.tv_nsec);
         struct timespec targetTime;
-#ifndef WIN32
-        clock_gettime(CLOCK_REALTIME, &targetTime);
-#else
-        SYSTEMTIME systime;
-        __int64  filetime;
-        __int64  test;
-        GetSystemTime(&systime);
-        SystemTimeToFileTime(&systime,(FILETIME*)&filetime);
-        targetTime.tv_sec=(filetime-WINDOWS_TIME_BASE_OFFSET)/(10*1000*1000);
-        targetTime.tv_nsec=((filetime-WINDOWS_TIME_BASE_OFFSET)%(10*1000*1000))*100;
-#endif
+
+               getClockRealTime(&targetTime);
+
         targetTime.tv_nsec += sleeptime.tv_nsec;
         if (targetTime.tv_nsec > 999999999)
         {
diff --git a/event.h b/event.h
index 7b7822a204ee4050d977304ee1e08dc2533a4069..4473d7a5859e2faa60a8553366badf11ab6eba70 100644 (file)
--- a/event.h
+++ b/event.h
@@ -43,13 +43,9 @@ class Event
     void loadinfos(UINT channelid);
 
     ULONG id;
-    #ifdef WIN32
-    time_t time;
-    time_t duration;
-    #else
+
     ULONG time;
     ULONG duration;
-    #endif // FIXME sort this out, causes signedness problems under linux
 
     char* title;
     char* subtitle;
diff --git a/main.cc b/main.cc
index b8d193a2321c99f5642c9e3f92aded403ecfdd39..d41255828b685248f4f685564c0e15d98e7008cc 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -602,6 +602,12 @@ long long getTimeMS() {
        return ts.tv_sec*1000+ts.tv_nsec/1000000LL;
 }
 
+int getClockRealTime(struct timespec *tp)
+{
+       return clock_gettime(CLOCK_REALTIME, tp);
+}
+
+
 int min(UINT a, int b)
 {
   if (a > b) return b;
index c115772a1d0d723f748b95e6226dabcddca590b7..b153b7b8cfd75d735140a000c7e1593bd54364de 100644 (file)
--- a/message.h
+++ b/message.h
@@ -76,7 +76,7 @@ class Message
     const static ULONG TELETEXTUPDATE = 32;
     const static ULONG TELETEXTUPDATEFIRSTLINE = 33;
     const static ULONG SUBTITLE_CHANGE_CHANNEL = 34;
-    const static ULONG MOUSE_ANDROID_SCROLL = 35;
+    const static ULONG MOUSE_SCROLL = 35;
     const static ULONG NEW_PICTURE = 36;
     const static ULONG NEW_PICTURE_STATIC = 37;
 };
index a9a32d4139dc5b6704e844eea0b1768cd0a91d9a..674862662b900ceffa3ac8b9bc8bf56eebe9ee02 100644 (file)
--- a/mutex.cc
+++ b/mutex.cc
 */
 #include "mutex.h"
 
-
+#ifndef WIN32
 #include <unistd.h>
 #include <sys/syscall.h>
+#endif
 
 Mutex::Mutex() {
 #ifndef WIN32
index a05a70924c82b26cf1d376b2703e877211955657..9d25beb4c3b1c21ba8cf207452ee461f8a0d758d 100644 (file)
@@ -830,7 +830,8 @@ void OsdVector::PictureReader::threadMethod()
                //Log::getInstance()->log("OsdVector", Log::DEBUG, "TVMedia Sleep Picture Reader");
 
                struct timespec target_time;
-               clock_gettime(CLOCK_REALTIME,&target_time);
+               getClockRealTime(&target_time);
+
                target_time.tv_nsec+=1000000LL*10;
                if (target_time.tv_nsec>999999999) {
                        target_time.tv_nsec-=1000000000L;
index 4c70e09fc41def65623c842fb23cf8f8680bc568..0a99ec3e8a9fc818e2cf68914608738e3bcc5075 100644 (file)
--- a/osdwin.cc
+++ b/osdwin.cc
@@ -178,7 +178,7 @@ int OsdWin::init(void* device)
           }
    }
 
-
+   GdiplusStartup(&gdiptoken, &gdipstartup, NULL);
 
 
   //Now we will create the Screen
@@ -285,6 +285,7 @@ int OsdWin::shutdown()
   d3d->Release();
   if (swapsurf) swapsurf->Release();
   if (swappy) swappy->Release();
+  Gdiplus::GdiplusShutdown(gdiptoken);
 
   return 1;
 }
@@ -406,19 +407,49 @@ void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){
                        /*calculating destination rect */
                        RECT destrect={0,0,/*video->getScreenWidth()*/ targetdesc.Width,
                                /*video->getScreenHeight()*/targetdesc.Height};
-                       UCHAR mode=video->getMode();
-                       switch (mode) {
-                       case Video::EIGHTH:
-                       destrect.right=destrect.right/2;
-                       destrect.bottom=destrect.bottom/2;
-                       case Video::QUARTER:
-                       destrect.right=destrect.right/2+video->getPosx()*2;
-                       destrect.bottom=destrect.bottom/2+video->getPosy()*2;
-                       destrect.left=video->getPosx()*2;
-                       destrect.top=video->getPosy()*2;
-                       d3ddevice->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0);
+                       const VideoDisplay &vd=video->getVideoDisplay();
+                       int addx, addy;
+                       addx = addy = 0;
+
+                       switch (vd.mode) {
+                       case Eighth:
+                               destrect.right=destrect.right/2;
+                               destrect.bottom=destrect.bottom/2;
+                       case Quarter:
+                               destrect.right=destrect.right/2;
+                               destrect.bottom=destrect.bottom/2;
+                       break;
+                       case Window:
+                               float imageaspect = 720.f / 576.f;
+                               float boxaspect = ((float)vd.width) / ((float)vd.height) ;
+                               float videoaspect = ((float)targetdesc.Width) / ((float)targetdesc.Height);
+                               if (imageaspect > boxaspect) {
+                                       destrect.right = (int)(((float)destrect.right) * ((float)vd.width) / 720.f);
+                                       destrect.bottom = (int)(((float)destrect.right)/videoaspect);
+                                       addy += (((float)vd.height) - ((float)vd.width) / imageaspect)*0.5f / 576.f 
+                                               *((float)targetdesc.Height);
+                               }
+                               else {
+                                       destrect.bottom = (int)(((float)destrect.bottom) * ((float)vd.height) / 576.f);
+                                       destrect.right = (int)(((float)destrect.bottom)*videoaspect);
+                                       addx += (((float)vd.width) - ((float)vd.height) * imageaspect)*0.5f / 720.f
+                                               *((float)targetdesc.Width);
+                               }
+                               
+                               
                        break;
                        };
+                       switch (vd.mode) {
+                       case Quarter:
+                       case Eighth:
+                       case Window:
+                               destrect.left = (int)(((float)vd.x*targetdesc.Width) / 720.f)+addx;
+                               destrect.top = (int)(((float)vd.y*targetdesc.Height) / 576.f)+addy;
+                               destrect.right += destrect.left;
+                               destrect.bottom += destrect.top;
+                       break;
+                       }
+                       d3ddevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
                        D3DSURFACE_DESC surf_desc;
                        present->GetDesc(&surf_desc);//for chop sides
                        RECT sourcerect= {0,0,surf_desc.Width,surf_desc.Height};
index d9048534e78ea3f61797a430d528b092cad2170a..5800f99aab85a9b3e64f678f441cdae8d3e9cecb 100644 (file)
--- a/osdwin.h
+++ b/osdwin.h
@@ -30,6 +30,7 @@
 #include <winsock2.h>
 #include <d3d9.h>
 #include <Dxva2api.h>
+#include <gdiplus.h>
 
 struct OSDVERTEX
 {
@@ -115,6 +116,8 @@ private:
        EVR_state evrstate;
        bool evrsupported;
        HWND window;
+       ULONG_PTR gdiptoken;
+       Gdiplus::GdiplusStartupInput gdipstartup;
 
        UINT dxvatoken;
        IDirect3DDeviceManager9 *d3ddevman;
index d28b178c30d9ac34ed2e3c7821462b7efbaed665..d3397b32338edb369e9c5e6e80325024b7d3adbf 100644 (file)
@@ -21,6 +21,7 @@
 #include "surface.h"
 
 #include <math.h>
+#include <algorithm>
 #include "osd.h"
 #include "log.h"
 #include "video.h"
index 9c7c81cb0b38ebe941ec64dc32e667d2c04bd11d..ba9face3f4bfed592b1f92b6dd3a1517ca3e435e 100644 (file)
@@ -22,7 +22,7 @@
 #include "osdwin.h"
 #include "bitmap.h"
 #include "log.h"
-#include <D3dx9tex.h>
+#include <gdiplus.h>
 
 SurfaceWin::SurfaceWin(int id)
 : Surface(id)
@@ -297,109 +297,70 @@ void SurfaceWin::ReleaseSurface()
   if (temp_text) temp_text->Release();
 }
 
-void SurfaceWin::drawJpeg(const char *fileName,int x, int y,int *width, int *height){
-  WaitForSingleObject(event,INFINITE); //since this might be called before surface
-  //allocation we will wait in this case, hopefully without deadlocks
-  if (!d3dsurface) {
-    return ; //why does this happen
-  }
-  OsdWin* osd=((OsdWin*)(Osd::getInstance()));
+void SurfaceWin::drawJpeg(const char *fileName, int x, int y, int *width, int *height){
+       WaitForSingleObject(event, INFINITE); //since this might be called before surface
+       //allocation we will wait in this case, hopefully without deadlocks
+       if (!d3dsurface) {
+               return; //why does this happen
+       }
+       OsdWin* osd = ((OsdWin*)(Osd::getInstance()));
+       osd->BeginPainting();
+
+       HDC dc;
+       HRESULT hres = d3dsurface->GetDC(&dc);
+       if (hres != D3D_OK) return; 
+
+       HRSRC hrc = FindResource(GetModuleHandle(NULL), fileName, RT_RCDATA);
+       DWORD size = SizeofResource(GetModuleHandle(NULL), hrc);
+       void *pointer = LockResource(LoadResource(GetModuleHandle(NULL),hrc));
+       HGLOBAL memhandle=GlobalAlloc(GMEM_MOVEABLE, size);
+       if (!memhandle)
+       {
+               d3dsurface->ReleaseDC(dc);
+               UnlockResource(hrc);
+               return;
+       }
+       void *mempointer = GlobalLock(memhandle);
+       if (!mempointer) {
+               d3dsurface->ReleaseDC(dc);
+               GlobalUnlock(mempointer);
+               GlobalFree(memhandle);
+               UnlockResource(hrc);
+               return;
+       }
+       
+       memcpy(mempointer, pointer, size);
+       UnlockResource(hrc);
 
 
-  D3DXIMAGE_INFO image_inf;
-  osd->BeginPainting();
-//  D3DXGetImageInfoFromFile(fileName,&image_inf);
-  D3DXGetImageInfoFromResource(NULL,fileName,&image_inf);
-  RECT dest_rec={x,y,x+image_inf.Width,
-    y+image_inf.Height};
-/*  if (D3DXLoadSurfaceFromFile(
-    d3dsurface,
-    NULL,
-    &dest_rec,
-    fileName,
-    NULL,
-    D3DX_FILTER_NONE,
-    0,
-    &image_inf)!=D3D_OK) {
-      Log::getInstance()->log("Surface", Log::DEBUG, "Could not open jpeg!");
-
-  }*/
-  if (D3DXLoadSurfaceFromResource(
-    d3dsurface,
-    NULL,
-    &dest_rec,
-    NULL,
-    fileName,
-    NULL,
-    D3DX_FILTER_NONE,
-    0,
-    &image_inf)!=D3D_OK) {
-      Log::getInstance()->log("Surface", Log::DEBUG, "Could not open jpeg!");
+       IStream *memstream = NULL;
+       if (CreateStreamOnHGlobal(memhandle, FALSE, &memstream) != S_OK)
+       {
+               GlobalUnlock(mempointer);
+               GlobalFree(memhandle);
+               d3dsurface->ReleaseDC(dc);
+               
+               return;
+       } 
 
-  }
-  osd->EndPainting();
-  *width=image_inf.Width;
-  *height=image_inf.Height;
 
-}
+       Gdiplus::Graphics graphics(dc);
+       Gdiplus::Image image(memstream);
+       
+       *width = image.GetWidth();
+       *height = image.GetHeight();
 
-/*
-void SurfaceWin::drawJpeg(char *buffer,ULONG buflength,DWORD x, DWORD y,DWORD *width, DWORD *height){
-  WaitForSingleObject(event,INFINITE); //since this might be called before surface
-  //allocation we will wait in this case, hopefully without deadlocks
-  if (!d3dsurface) {
-    return ; //why does this happen
-  }
-  OsdWin* osd=((OsdWin*)(Osd::getInstance()));
+       graphics.DrawImage(&image, x, y, *width, *height);
 
+       memstream->Release();
+       GlobalUnlock(mempointer);
+       GlobalFree(memhandle);
+       
+       d3dsurface->ReleaseDC(dc);
+       osd->EndPainting();
 
-  D3DXIMAGE_INFO image_inf;
-  osd->BeginPainting();
-//  D3DXGetImageInfoFromFile(fileName,&image_inf);
-  D3DXGetImageInfoFromFileInMemory((void*)buffer,buflength,&image_inf);
-  RECT dest_rec={x,y,x+image_inf.Width,
-    y+image_inf.Height};
-/*  if (D3DXLoadSurfaceFromFile(
-    d3dsurface,
-    NULL,
-    &dest_rec,
-    fileName,
-    NULL,
-    D3DX_FILTER_NONE,
-    0,
-    &image_inf)!=D3D_OK) {
-      Log::getInstance()->log("Surface", Log::DEBUG, "Could not open jpeg!");
-
-  }*/
-/*  if (D3DXLoadSurfaceFromResource(
-    d3dsurface,
-    NULL,
-    &dest_rec,
-    NULL,
-    fileName,
-    NULL,
-    D3DX_FILTER_NONE,
-    0,
-    &image_inf)!=D3D_OK) {
-      Log::getInstance()->log("Surface", Log::DEBUG, "Could not open jpeg!");
-
-  }*
-  if (D3DXLoadSurfaceFromFileInMemory(
-    d3dsurface,
-    NULL,
-    &dest_rec,
-    (void*)buffer,
-    buflength,
-    NULL,
-    D3DX_FILTER_NONE,
-    0,
-    &image_inf)!=D3D_OK) {
-      Log::getInstance()->log("Surface", Log::DEBUG, "Could not open jpeg!");
 
-  }
-  osd->EndPainting();
-  *width=image_inf.Width;
-  *height=image_inf.Height;
+}
+
 
-}*/
 
index b9bb844833c81616d64847e2b748aa8ecb3b925a..115cacb5027905dd1bf3c496c9b68cb8fe6752ea 100644 (file)
--- a/timers.cc
+++ b/timers.cc
@@ -154,18 +154,7 @@ bool Timers::setTimerD(TimerReceiver* client, int clientReference, long int requ
 {
   struct timespec currentTime;
 
-#ifndef WIN32
-  clock_gettime(CLOCK_REALTIME, &currentTime);
-#else
-  SYSTEMTIME systime;
-  __int64  filetime;
-  __int64  test;
-  GetSystemTime(&systime);
-  SystemTimeToFileTime(&systime,(FILETIME*)&filetime);
-   currentTime.tv_sec=(filetime-WINDOWS_TIME_BASE_OFFSET)/(10*1000*1000);
-   //#error "Hier gibt was zu tun!"
-   currentTime.tv_nsec=((filetime-WINDOWS_TIME_BASE_OFFSET)%(10*1000*1000))*100;
-#endif
+  getClockRealTime(&currentTime);
 
   long int requestedTime;
   long int requestedTimeNSEC;
diff --git a/vdr.h b/vdr.h
index 502d7cb6a7caf77da01af315fb355e1516c678e9..18aa3485f6be7240d7fd31e3212306b29499df27 100644 (file)
--- a/vdr.h
+++ b/vdr.h
@@ -56,7 +56,7 @@ class SerializeBuffer;
 #endif
 class MovieInfo;
 class SeriesInfo;
-struct TVMediaInfo;
+class TVMediaInfo;
 
 
 using namespace std;
diff --git a/vepg.cc b/vepg.cc
index 32cd413bb2b3f0dd1d7318726c1cb7b08e899367..97792657af7e270eafe6cfa4751bc38c2b41cb9c 100644 (file)
--- a/vepg.cc
+++ b/vepg.cc
@@ -89,7 +89,7 @@ VEpg::VEpg(void* tparent, UINT tcurrentChannelIndex, ChannelList* tchanList)
   int screenheighthalf=Video::getInstance()->getScreenHeight()/2;
  // summaryLines = ((float)screenheighthalf)/((float)fontHeight))-1;
  // summaryLowerPadding = screenheighthalf-summaryLines*(fontHeight);
-  gridRows = (screenheighthalf-fontHeight*2-40)/fontHeight;
+  gridRows = (screenheighthalf-fontHeight*3-40)/fontHeight;
 
 
   // initialise variables and pointers
@@ -217,7 +217,8 @@ void VEpg::setInfo(Event* event)
   char timeString[9]; // to hold programme start and end time
   int length = strlen(event->title); // calculate length of programme title string
   char* title = new char[length + 15]; // create string to hold start time, end time and programme title
-  btime = localtime((time_t*)&event->time); //get programme start time
+  time_t eventtime = event->time;
+  btime = localtime((time_t*)&eventtime); //get programme start time
 #ifndef _MSC_VER
   strftime(timeString, 9, "%0H:%0M - ", btime); // and format it as hh:mm -
 #else
index 0a2d714712340f6095d3dcfbc78f206c08b82903..b48fe5efce2699f777331e9dbc03e830239c97c9 100644 (file)
@@ -180,7 +180,8 @@ void VEpgSetTimer::draw()
   time_t t;
   struct tm* btime;
   char timeString[10];
-  btime = localtime((time_t*)&event->time);
+  time_t eventtime = event->time;
+  btime = localtime(&eventtime);
 #ifndef _MSC_VER
   strftime(timeString, 9, "%0H:%0M - ", btime); // and format it as hh:mm -
 #else
index 978451329bfe5f0cb3e655cdbfada1ba971128e8..8a76deff13a902bfeb9acd76544b34dd005bc736 100644 (file)
@@ -173,6 +173,7 @@ int VEpgSummary::handleCommand(int command)
        if (command==Remote::RED)
     {
       if (!channel) return 2;
+         MessageBox(0, "test", "test", 0);
       Log::getInstance()->log("VEpgSummary", Log::DEBUG, "ID %lu TIME %lu DURATION %lu TITLE %s", event->id, event->time, event->duration, event->title);
       VEpgSetTimer* vs = new VEpgSetTimer(event, channel);
       vs->draw();
@@ -207,11 +208,29 @@ void VEpgSummary::processMessage(Message* m)
 {
   if (m->message == Message::MOUSE_MOVE)
   {
-    // todo
+         if (tabbar.mouseMove((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY()))
+         {
+                 BoxStack::getInstance()->update(this);
+         }
   }
   else if (m->message == Message::MOUSE_LBDOWN)
   {
     int cancel = true;
+       int x = (m->parameter >> 16) - getScreenX();
+       int y = (m->parameter & 0xFFFF) - getScreenY();
+
+       if ((boxRed.getX() <= x) && (boxRed.getX() + (int)boxRed.getWidth() >= x) &&
+               (boxRed.getY() <= y) && (boxRed.getY() + (int)boxRed.getHeight() >= y)) {
+               BoxStack::getInstance()->handleCommand(Remote::RED);
+               cancel = false;
+       }
+
+
+       if (cancel && tabbar.mouseLBDOWN((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY()))
+       {
+               BoxStack::getInstance()->update(this);
+               cancel = false;
+       }
     if (cancel)
     {
       //check if press is outside this view! then simulate cancel
@@ -222,6 +241,14 @@ void VEpgSummary::processMessage(Message* m)
         BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
       }
     }
+  } else if (m->message == Message::MOUSE_SCROLL)
+  {
+         if (tabbar.mouseAndroidScroll((m->tag >> 16) - getScreenX(), (m->tag & 0xFFFF) - getScreenY(),
+                 (short)(m->parameter >> 16), (short)(m->parameter & 0xFFFF)))
+         {
+                 BoxStack::getInstance()->update(this);
+                 return;
+         }
   }
 }
 
index ae406e974accd535aabf8d7e6580fe6507aa2031..8403b1002638ffc56893b7c68990ac13611b3906 100644 (file)
--- a/video.cc
+++ b/video.cc
@@ -52,7 +52,7 @@ Video* Video::getInstance()
 {
   return instance;
 }
-
+#include <Windows.h>
 // For legacy implementations
 bool Video::setVideoDisplay(VideoDisplay display)
 {
@@ -61,17 +61,18 @@ bool Video::setVideoDisplay(VideoDisplay display)
                if (display.fallbackMode == None || display.fallbackMode == Window) return false; // No Effect
                applyMode=display.fallbackMode;
        }
+       MessageBox(0, "videodisplay", "videodisplay", 0);
        switch (applyMode) {
        case Fullscreen: {
                setMode(mode);
        } break;
        case Quarter: {
                setMode(QUARTER);
-               setPosition(display.x/2, display.y/2);
+               setPosition(display.x / 2, display.y / 2);
        }break;
        case Eighth: {
                setMode(EIGHTH);
-               setPosition(display.x/2, display.y/2);
+               setPosition(display.x / 2, display.y / 2);      
        } break;
        case Window:
        case None: return false; break; //Stupid
index 2b1de80ef15d94639b7a60de5be8ef13601fd62a..cf97375c2a7c22d3f1cb3e16a67fe0a56e682537 100644 (file)
@@ -72,8 +72,6 @@ VideoWin::VideoWin()
   audioon=true;
   audiovolume=0;
   pseudotvsize=0;
-  videoposx=0;
-  videoposy=0;
   aud_type=Audio::MPEG2_PES;
   iframemode=false;//We are not in Iframe mode at begining
   vmrdeinterlacing=2;//Best
@@ -91,6 +89,8 @@ VideoWin::VideoWin()
   videoH264dtsfix=false;
   videompeg2dtsfix=false;
 
+  vd.mode = Fullscreen;
+
 
 
 
@@ -127,8 +127,8 @@ int VideoWin::init(UCHAR tformat)
 
   initted = 1;
   tvsize=Video::ASPECT16X9; //Internally Vomp should think we are a 16:9 TV
-  videoposx=0;
-  videoposy=0;
+
+  vd.mode = Fullscreen;
   initFilterDatabase();
   initH264FilterDatabase();
 
@@ -204,8 +204,6 @@ int VideoWin::setMode(UCHAR tmode)
   if ((tmode != NORMAL) && (tmode != LETTERBOX) && (tmode != UNKNOWN2) && (tmode != QUARTER) && (tmode != EIGHTH)
       && (tmode != ZOOM) && (tmode != UNKNOWN6)) return 0;
   if (tmode==NORMAL || tmode == LETTERBOX) mode = tmode;
-  videoposx=0;
-  videoposy=0;
   AdjustWindow();
 
   return 1;
@@ -228,15 +226,6 @@ int VideoWin::setSource()
   return 1;
 }
 
-int VideoWin::setPosition(int x, int y)
-{
-  if (!initted) return 0;
-  if (mode==QUARTER || mode==EIGHTH) {
-  videoposx=x;
-  videoposy=y;
-  }
-  return 1;
-}
 
 int VideoWin::sync()
 {
@@ -1477,8 +1466,6 @@ int VideoWin::reset()
 int VideoWin::dsreset()
 {
   if (!initted) return 0;
-  videoposx=0;
-  videoposy=0;
   iframemode=false;//exit iframe mode
   CleanupDS();
 
index 7919973f4d278066e6d7ee2a1a18ff372c607496..c379049513c7ca795b67bcab416f445cc41e009f 100644 (file)
@@ -142,8 +142,7 @@ public:
 
        virtual bool displayIFrame(const UCHAR* buffer, UINT length);
 
-       unsigned int getPosx() {return videoposx;};
-       unsigned int getPosy() {return videoposy;};
+       const VideoDisplay & getVideoDisplay() { return vd; };
        bool isVideoOn() {return videoon;};
        bool isdsinited() {return dsinited;};
        int lastAType() {return lastaudiomode;};
@@ -163,8 +162,10 @@ public:
        int test2();
 #endif
 protected:
-       int setPosition(int x, int y); // legacy api remove
-#error Port the new api
+       bool setVideoDisplay(VideoDisplay display) { vd = display; return true; };
+
+       VideoDisplay vd;
+
 
 private:
        int EnterIframePlayback();
@@ -213,8 +214,6 @@ private:
        UCHAR pseudotvsize;
        REFERENCE_TIME lastreftimeRT;
        ULLONG lastreftimePTS;
-       unsigned int videoposx;
-       unsigned int videoposy;
        int lastaudiomode;
        int audiovolume;
        UCHAR aud_type;
index f9e2eca5bb8c64f1981e53fb0831e29f029de7d9..47ac22ed2835b44ed3854b07beef24b82fe2be7f 100644 (file)
@@ -338,6 +338,20 @@ void VRecording::processMessage(Message* m)
         break;
       }
     }
+       if (tabbar.mouseMove((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY()))
+       {
+               BoxStack::getInstance()->update(this);
+               return;
+       }
+  }
+  else if (m->message == Message::MOUSE_SCROLL)
+  {
+         if (tabbar.mouseAndroidScroll((m->tag >> 16) - getScreenX(), (m->tag & 0xFFFF) - getScreenY(),
+                 (short)(m->parameter >> 16), (short) (m->parameter & 0xFFFF)))
+         {
+                 BoxStack::getInstance()->update(this);
+                 return;
+         }
   }
   else if (m->message == Message::MOUSE_LBDOWN)
   {
@@ -351,6 +365,11 @@ void VRecording::processMessage(Message* m)
         break;
       }
     }
+       if (cancel && tabbar.mouseLBDOWN((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY()))
+       {
+               BoxStack::getInstance()->update(this);
+               cancel = false;
+       }
     if (cancel)
     {
       //check if press is outside this view! then simulate cancel
index 1c17cbea0f8ac53e54df85606f8c72cd98bc4259..1e03d2e9636ac6633d0222c240432fa490a72f2f 100644 (file)
@@ -119,12 +119,14 @@ void VTimerEdit::draw()
                                                            ypos += fontheight;
 
   // Start
-  tms = localtime((time_t*)&recTimer->startTime);
+  time_t rectime = recTimer->startTime;
+  tms = localtime((time_t*)&rectime);
   strftime(buffer, 999, "%d/%m %H:%M", tms);
   drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT);         ypos += fontheight;
 
   // Stop
-  tms = localtime((time_t*)&recTimer->stopTime);
+  rectime = recTimer->startTime;
+  tms = localtime((time_t*)&rectime);
   strftime(buffer, 999, "%d/%m %H:%M", tms);
   drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT);         ypos += fontheight;
 
index b9f3897acef7568f49d76758a40da3ed90ab5f30..fa20d32ca315c72e30b502c6a9d38a76e7c0fbba 100644 (file)
@@ -150,8 +150,8 @@ bool VTimerList::load()
   for (UINT i = 0; i < recTimerList->size(); i++)
   {
     recTimer = (*recTimerList)[i];
-
-    btime = localtime((time_t*)&recTimer->startTime);
+       time_t rectime = recTimer->startTime;
+    btime = localtime((time_t*)&rectime);
     strftime(strA, 299, "%d/%m %H:%M ", btime);
     SNPRINTF(strB, 299, "%s\t%s", strA, recTimer->getName());
     sl.addOption(strB, (ULONG)recTimer, first);
index e009f388d3bdc6f262a8124fb69ae01240ed2dce..e788024504cee4e75d56f6c03495b4c6f8a7f82e 100644 (file)
@@ -773,7 +773,6 @@ void VVideoLiveTV::setNowNextData()
     {
       event = (*eventList)[i];
 
-      //btime = localtime((time_t*)&event->time);
       time_t etime = event->time;
       btime = localtime(&etime);
 #ifndef _MSC_VER
@@ -792,7 +791,8 @@ void VVideoLiveTV::setNowNextData()
 
 void VVideoLiveTV::displayOSD(bool newNowNextData)
 {
-  (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(true);
+  PlayerLiveTV* playerlivetv = dynamic_cast<PlayerLiveTV*>(player);
+  if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(true);
   osd.setVisible(true);
   if (newNowNextData)
   {
@@ -835,7 +835,8 @@ void VVideoLiveTV::clearScreen()
   draw();
   boxstack->update(this);
 
-  (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(false);
+  PlayerLiveTV* playerlivetv = dynamic_cast<PlayerLiveTV*>(player);
+  if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false);
 }
 
 void VVideoLiveTV::showUnavailable()
@@ -906,7 +907,8 @@ void VVideoLiveTV::timercall(int ref)
       else  boxstack->update(this, osd.getRegion());
 
       Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 3."); 
-      (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(false);
+         PlayerLiveTV* playerlivetv = dynamic_cast<PlayerLiveTV*>(player);
+         if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false);
       Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey end."); 
     }
   }
index d120f8a6b7d3f2323daa3394ec1649cb1cd63223..f66d0545798c760ce1e419b24c4819304875f07e 100644 (file)
@@ -90,6 +90,17 @@ void MILLISLEEP(ULONG a)
 
 }
 
+int getClockRealTime(struct timespec *tp){
+       SYSTEMTIME systime;
+       __int64  filetime;
+       __int64  test;
+       GetSystemTime(&systime);
+       SystemTimeToFileTime(&systime, (FILETIME*)&filetime);
+       tp->tv_sec = (filetime - WINDOWS_TIME_BASE_OFFSET) / (10 * 1000 * 1000);
+       tp->tv_nsec = ((filetime - WINDOWS_TIME_BASE_OFFSET) % (10 * 1000 * 1000)) * 100;
+       return 0;
+}
+
 DWORD WINAPI commandthreadStart(void *arg)
 {
    command->run();
@@ -721,6 +732,20 @@ LONG FAR PASCAL WindowProc(HWND wind, UINT msg, WPARAM wparam, LPARAM lparam)
       command->postMessageFromOuterSpace(mousemes);
     }
             }break;
+  case WM_MOUSEWHEEL:{
+       POINT mpos = { GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam) };
+       ClientToScreen(wind, &mpos);
+       if (TranslateMousePosition(&mpos)) {
+               Message *mousemes = new Message();
+               mousemes->message = Message::MOUSE_SCROLL;
+               mousemes->from = NULL;
+               mousemes->to = BoxStack::getInstance();
+               mousemes->parameter = (0 & 0xFFFF) << 16 | (GET_WHEEL_DELTA_WPARAM(wparam)  &0xFFFF);
+               mousemes->tag = (mpos.x & 0xFFFF) << 16 | (mpos.y & 0xFFFF);
+               command->postMessageFromOuterSpace(mousemes);
+       }
+
+  } break;
     default:
         return DefWindowProc(wind, msg, wparam, lparam);
     }
index 35dce918f356be17cfe7d6c59ccab12fc62c1c4d..94bfc63fe1383b5f268d3b4f6aa8a0b95c1838ae 100644 (file)
@@ -24,6 +24,7 @@
 #include "log.h"
 
 #include <math.h>
+#include <string.h>
 
 WSelectList::WSelectList():
 backgroundColour(DrawStyle::VIEWBACKGROUND)
index e5df6e494db3baf8b5b49b3a9e4e2ae28ebb7933..7cb7a46d0518d6b4405a7a48d2a70d88bbcfac3b 100644 (file)
@@ -277,6 +277,14 @@ bool WTabBar::mouseMove(int x, int y) {
     return false;
 }
 
+bool WTabBar::mouseAndroidScroll(int x, int y, int sx, int sy) {
+       if (tabs[visiblePane].pane->mouseAndroidScroll(x, y,sx,sy)) {
+               draw();
+               return true;
+       }
+       return false;
+}
+
 bool WTabBar::mouseLBDOWN(int x, int y) {
     UINT i;
     for (i=0;i<tabs.size();i++) {
index bfd8d70239905b87bfaf91554a4c0c3243ca6303..b3846a4e16ed6056cde3b7871004178368502711 100644 (file)
--- a/wtabbar.h
+++ b/wtabbar.h
@@ -45,6 +45,7 @@ class WTabBar : public Boxx
     int handleCommand(int command);
     bool mouseMove(int x, int y) ;
     bool mouseLBDOWN(int x, int y);
+       bool mouseAndroidScroll(int x, int y, int sx, int sy);
     void activateFocus(bool active);
 
   private:
index 7cb6045fd6d813540e1815d1bec767d0b90406fd..a57bfdb0772116611fbebca2e07a4eaa54439c74 100644 (file)
@@ -124,3 +124,25 @@ int WTextbox::handleCommand(int command)
 
   return 0;
 }
+
+bool WTextbox::mouseAndroidScroll(int x, int y, int sx, int sy)
+{
+       if ((x - getRootBoxOffsetX()) >= 0 && (y - getRootBoxOffsetY()) >= 0
+               && (x - getRootBoxOffsetX()) <= (int)area.w && (y - getRootBoxOffsetY()) <= (int)area.h )
+       {
+               int change = -sy /120;
+               if (change < 0) {
+                       int rel_change = min(cur_scroll_line, -change);
+                       cur_scroll_line-=rel_change;
+                       rem_scroll_line+=rel_change;
+               }
+               else if (change > 0) {
+                       int rel_change = min(rem_scroll_line, change);
+                       cur_scroll_line += rel_change;
+                       rem_scroll_line -= rel_change;
+               }
+               return true;
+       }
+       return false;
+
+}
index 5003157f3dd645d7db2929f0bf6a730e9bf6a7dd..1f82c97f75117bc2846329fa02e81fa18a697aeb 100644 (file)
@@ -42,6 +42,7 @@ class WTextbox : public Boxx
 
     // if added as a pane
     int handleCommand(int command);
+       bool mouseAndroidScroll(int x, int y, int sx, int sy);
 
   private: