From 1ae4725a55198b868680740cb4ca83ca76b137c9 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 1 Nov 2014 17:56:55 +0100 Subject: [PATCH] First Windows porting changes after adding scraper support --- boxstack.cc | 2 +- colour.cc | 56 ++++++++--------- defines.h | 5 +- dvbsubtitles.cc | 28 ++------- event.h | 6 +- main.cc | 6 ++ message.h | 2 +- mutex.cc | 3 +- osdvector.cc | 3 +- osdwin.cc | 55 +++++++++++++---- osdwin.h | 3 + surface.cc | 1 + surfacewin.cc | 155 ++++++++++++++++++------------------------------ timers.cc | 13 +--- vdr.h | 2 +- vepg.cc | 5 +- vepgsettimer.cc | 3 +- vepgsummary.cc | 29 ++++++++- video.cc | 7 ++- videowin.cc | 21 ++----- videowin.h | 11 ++-- vrecording.cc | 19 ++++++ vtimeredit.cc | 6 +- vtimerlist.cc | 4 +- vvideolivetv.cc | 10 ++-- winmain.cc | 25 ++++++++ wselectlist.cc | 1 + wtabbar.cc | 8 +++ wtabbar.h | 1 + wtextbox.cc | 22 +++++++ wtextbox.h | 1 + 31 files changed, 292 insertions(+), 221 deletions(-) diff --git a/boxstack.cc b/boxstack.cc index b8cfee5..55ffa00 100644 --- a/boxstack.cc +++ b/boxstack.cc @@ -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; diff --git a/colour.cc b/colour.cc index 78dbe1e..5ee9baa 100644 --- 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 diff --git a/defines.h b/defines.h index 960a5e9..b09dc65 100644 --- 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 diff --git a/dvbsubtitles.cc b/dvbsubtitles.cc index 75508c6..2d9e7b7 100644 --- a/dvbsubtitles.cc +++ b/dvbsubtitles.cc @@ -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 7b7822a..4473d7a 100644 --- 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 b8d193a..d412558 100644 --- 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; diff --git a/message.h b/message.h index c115772..b153b7b 100644 --- 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; }; diff --git a/mutex.cc b/mutex.cc index a9a32d4..6748626 100644 --- a/mutex.cc +++ b/mutex.cc @@ -19,9 +19,10 @@ */ #include "mutex.h" - +#ifndef WIN32 #include #include +#endif Mutex::Mutex() { #ifndef WIN32 diff --git a/osdvector.cc b/osdvector.cc index a05a709..9d25beb 100644 --- a/osdvector.cc +++ b/osdvector.cc @@ -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; diff --git a/osdwin.cc b/osdwin.cc index 4c70e09..0a99ec3 100644 --- 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}; diff --git a/osdwin.h b/osdwin.h index d904853..5800f99 100644 --- a/osdwin.h +++ b/osdwin.h @@ -30,6 +30,7 @@ #include #include #include +#include struct OSDVERTEX { @@ -115,6 +116,8 @@ private: EVR_state evrstate; bool evrsupported; HWND window; + ULONG_PTR gdiptoken; + Gdiplus::GdiplusStartupInput gdipstartup; UINT dxvatoken; IDirect3DDeviceManager9 *d3ddevman; diff --git a/surface.cc b/surface.cc index d28b178..d3397b3 100644 --- a/surface.cc +++ b/surface.cc @@ -21,6 +21,7 @@ #include "surface.h" #include +#include #include "osd.h" #include "log.h" #include "video.h" diff --git a/surfacewin.cc b/surfacewin.cc index 9c7c81c..ba9face 100644 --- a/surfacewin.cc +++ b/surfacewin.cc @@ -22,7 +22,7 @@ #include "osdwin.h" #include "bitmap.h" #include "log.h" -#include +#include 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; +} + -}*/ diff --git a/timers.cc b/timers.cc index b9bb844..115cacb 100644 --- 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, ¤tTime); -#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(¤tTime); long int requestedTime; long int requestedTimeNSEC; diff --git a/vdr.h b/vdr.h index 502d7cb..18aa348 100644 --- 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 32cd413..9779265 100644 --- 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 diff --git a/vepgsettimer.cc b/vepgsettimer.cc index 0a2d714..b48fe5e 100644 --- a/vepgsettimer.cc +++ b/vepgsettimer.cc @@ -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 diff --git a/vepgsummary.cc b/vepgsummary.cc index 9784513..8a76def 100644 --- a/vepgsummary.cc +++ b/vepgsummary.cc @@ -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; + } } } diff --git a/video.cc b/video.cc index ae406e9..8403b10 100644 --- a/video.cc +++ b/video.cc @@ -52,7 +52,7 @@ Video* Video::getInstance() { return instance; } - +#include // 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 diff --git a/videowin.cc b/videowin.cc index 2b1de80..cf97375 100644 --- a/videowin.cc +++ b/videowin.cc @@ -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(); diff --git a/videowin.h b/videowin.h index 7919973..c379049 100644 --- a/videowin.h +++ b/videowin.h @@ -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; diff --git a/vrecording.cc b/vrecording.cc index f9e2eca..47ac22e 100644 --- a/vrecording.cc +++ b/vrecording.cc @@ -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 diff --git a/vtimeredit.cc b/vtimeredit.cc index 1c17cbe..1e03d2e 100644 --- a/vtimeredit.cc +++ b/vtimeredit.cc @@ -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; diff --git a/vtimerlist.cc b/vtimerlist.cc index b9f3897..fa20d32 100644 --- a/vtimerlist.cc +++ b/vtimerlist.cc @@ -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); diff --git a/vvideolivetv.cc b/vvideolivetv.cc index e009f38..e788024 100644 --- a/vvideolivetv.cc +++ b/vvideolivetv.cc @@ -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(player))->tellSubtitlesOSDVisible(true); + PlayerLiveTV* playerlivetv = dynamic_cast(player); + if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(true); osd.setVisible(true); if (newNowNextData) { @@ -835,7 +835,8 @@ void VVideoLiveTV::clearScreen() draw(); boxstack->update(this); - (static_cast(player))->tellSubtitlesOSDVisible(false); + PlayerLiveTV* playerlivetv = dynamic_cast(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(player))->tellSubtitlesOSDVisible(false); + PlayerLiveTV* playerlivetv = dynamic_cast(player); + if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false); Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey end."); } } diff --git a/winmain.cc b/winmain.cc index d120f8a..f66d054 100644 --- a/winmain.cc +++ b/winmain.cc @@ -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); } diff --git a/wselectlist.cc b/wselectlist.cc index 35dce91..94bfc63 100644 --- a/wselectlist.cc +++ b/wselectlist.cc @@ -24,6 +24,7 @@ #include "log.h" #include +#include WSelectList::WSelectList(): backgroundColour(DrawStyle::VIEWBACKGROUND) diff --git a/wtabbar.cc b/wtabbar.cc index e5df6e4..7cb7a46 100644 --- a/wtabbar.cc +++ b/wtabbar.cc @@ -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= 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; + +} diff --git a/wtextbox.h b/wtextbox.h index 5003157..1f82c97 100644 --- a/wtextbox.h +++ b/wtextbox.h @@ -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: -- 2.39.5