[cstdstring] demise Format, replacing with StringUtils::Format
[vuplus_xbmc] / xbmc / video / windows / GUIWindowFullScreen.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "threads/SystemClock.h"
22 #include "system.h"
23 #include "GUIWindowFullScreen.h"
24 #include "Application.h"
25 #include "ApplicationMessenger.h"
26 #include "Util.h"
27 #ifdef HAS_VIDEO_PLAYBACK
28 #include "cores/VideoRenderers/RenderManager.h"
29 #endif
30 #include "GUIInfoManager.h"
31 #include "guilib/GUIProgressControl.h"
32 #include "guilib/GUIAudioManager.h"
33 #include "guilib/GUILabelControl.h"
34 #include "video/dialogs/GUIDialogVideoOSD.h"
35 #include "guilib/GUIFontManager.h"
36 #include "guilib/GUITextLayout.h"
37 #include "guilib/GUIWindowManager.h"
38 #include "guilib/Key.h"
39 #include "video/dialogs/GUIDialogFullScreenInfo.h"
40 #include "dialogs/GUIDialogNumeric.h"
41 #include "settings/DisplaySettings.h"
42 #include "settings/MediaSettings.h"
43 #include "settings/Settings.h"
44 #include "guilib/GUISelectButtonControl.h"
45 #include "FileItem.h"
46 #include "video/VideoReferenceClock.h"
47 #include "settings/AdvancedSettings.h"
48 #include "utils/CPUInfo.h"
49 #include "guilib/LocalizeStrings.h"
50 #include "threads/SingleLock.h"
51 #include "utils/log.h"
52 #include "utils/TimeUtils.h"
53 #include "utils/URIUtils.h"
54 #include "utils/StringUtils.h"
55 #include "XBDateTime.h"
56 #include "input/ButtonTranslator.h"
57 #include "pvr/PVRManager.h"
58 #include "pvr/channels/PVRChannelGroupsContainer.h"
59 #include "windowing/WindowingFactory.h"
60 #include "cores/IPlayer.h"
61 #include "filesystem/File.h"
62
63 #include <stdio.h>
64 #include <algorithm>
65 #if defined(TARGET_DARWIN)
66 #include "linux/LinuxResourceCounter.h"
67 #endif
68
69 using namespace PVR;
70
71 #define BLUE_BAR                          0
72 #define LABEL_ROW1                       10
73 #define LABEL_ROW2                       11
74 #define LABEL_ROW3                       12
75 #define CONTROL_GROUP_CHOOSER            503
76
77 //Displays current position, visible after seek or when forced
78 //Alt, use conditional visibility Player.DisplayAfterSeek
79 #define LABEL_CURRENT_TIME               22
80
81 //Displays when video is rebuffering
82 //Alt, use conditional visibility Player.IsCaching
83 #define LABEL_BUFFERING                  24
84
85 //Progressbar used for buffering status and after seeking
86 #define CONTROL_PROGRESS                 23
87
88 #if defined(TARGET_DARWIN)
89 static CLinuxResourceCounter m_resourceCounter;
90 #endif
91
92 CGUIWindowFullScreen::CGUIWindowFullScreen(void)
93     : CGUIWindow(WINDOW_FULLSCREEN_VIDEO, "VideoFullScreen.xml")
94 {
95   m_timeCodeStamp[0] = 0;
96   m_timeCodePosition = 0;
97   m_timeCodeShow = false;
98   m_timeCodeTimeout = 0;
99   m_bShowViewModeInfo = false;
100   m_dwShowViewModeTimeout = 0;
101   m_bShowCurrentTime = false;
102   m_bGroupSelectShow = false;
103   m_loadType = KEEP_IN_MEMORY;
104   // audio
105   //  - language
106   //  - volume
107   //  - stream
108
109   // video
110   //  - Create Bookmark (294)
111   //  - Cycle bookmarks (295)
112   //  - Clear bookmarks (296)
113   //  - jump to specific time
114   //  - slider
115   //  - av delay
116
117   // subtitles
118   //  - delay
119   //  - language
120
121 }
122
123 CGUIWindowFullScreen::~CGUIWindowFullScreen(void)
124 {}
125
126 bool CGUIWindowFullScreen::OnAction(const CAction &action)
127 {
128   if (m_timeCodePosition > 0 && action.GetButtonCode())
129   { // check whether we have a mapping in our virtual videotimeseek "window" and have a select action
130     CKey key(action.GetButtonCode());
131     CAction timeSeek = CButtonTranslator::GetInstance().GetAction(WINDOW_VIDEO_TIME_SEEK, key, false);
132     if (timeSeek.GetID() == ACTION_SELECT_ITEM)
133     {
134       SeekToTimeCodeStamp(SEEK_ABSOLUTE);
135       return true;
136     }
137   }
138
139   switch (action.GetID())
140   {
141   case ACTION_SHOW_OSD:
142     ToggleOSD();
143     return true;
144
145   case ACTION_SHOW_GUI:
146     {
147       // switch back to the menu
148       OutputDebugString("Switching to GUI\n");
149       g_windowManager.PreviousWindow();
150       OutputDebugString("Now in GUI\n");
151       return true;
152     }
153     break;
154
155   case ACTION_PLAYER_PLAY:
156   case ACTION_PAUSE:
157     if (m_timeCodePosition > 0)
158     {
159       SeekToTimeCodeStamp(SEEK_ABSOLUTE);
160       return true;
161     }
162     break;
163
164   case ACTION_STEP_BACK:
165     if (m_timeCodePosition > 0)
166       SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_BACKWARD);
167     else
168       g_application.m_pPlayer->Seek(false, false);
169     return true;
170
171   case ACTION_STEP_FORWARD:
172     if (m_timeCodePosition > 0)
173       SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_FORWARD);
174     else
175       g_application.m_pPlayer->Seek(true, false);
176     return true;
177
178   case ACTION_BIG_STEP_BACK:
179   case ACTION_CHAPTER_OR_BIG_STEP_BACK:
180     if (m_timeCodePosition > 0)
181       SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_BACKWARD);
182     else
183       g_application.m_pPlayer->Seek(false, true, action.GetID() == ACTION_CHAPTER_OR_BIG_STEP_BACK);
184     return true;
185
186   case ACTION_BIG_STEP_FORWARD:
187   case ACTION_CHAPTER_OR_BIG_STEP_FORWARD:
188     if (m_timeCodePosition > 0)
189       SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_FORWARD);
190     else
191       g_application.m_pPlayer->Seek(true, true, action.GetID() == ACTION_CHAPTER_OR_BIG_STEP_FORWARD);
192     return true;
193
194   case ACTION_NEXT_SCENE:
195     if (g_application.m_pPlayer->SeekScene(true))
196       g_infoManager.SetDisplayAfterSeek();
197     return true;
198     break;
199
200   case ACTION_PREV_SCENE:
201     if (g_application.m_pPlayer->SeekScene(false))
202       g_infoManager.SetDisplayAfterSeek();
203     return true;
204     break;
205
206   case ACTION_SHOW_OSD_TIME:
207     m_bShowCurrentTime = !m_bShowCurrentTime;
208     if(!m_bShowCurrentTime)
209       g_infoManager.SetDisplayAfterSeek(0); //Force display off
210     g_infoManager.SetShowTime(m_bShowCurrentTime);
211     return true;
212     break;
213
214   case ACTION_SHOW_INFO:
215     {
216       CGUIDialogFullScreenInfo* pDialog = (CGUIDialogFullScreenInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_FULLSCREEN_INFO);
217       if (pDialog)
218       {
219         CFileItem item(g_application.CurrentFileItem());
220         pDialog->DoModal();
221         return true;
222       }
223       break;
224     }
225
226   case REMOTE_0:
227   case REMOTE_1:
228   case REMOTE_2:
229   case REMOTE_3:
230   case REMOTE_4:
231   case REMOTE_5:
232   case REMOTE_6:
233   case REMOTE_7:
234   case REMOTE_8:
235   case REMOTE_9:
236     {
237       if (g_application.CurrentFileItem().IsLiveTV())
238       {
239           CPVRChannelPtr channel;
240         int iChannelNumber = -1;
241         g_PVRManager.GetCurrentChannel(channel);
242
243         if (action.GetID() == REMOTE_0)
244         {
245           iChannelNumber = g_PVRManager.GetPreviousChannel();
246           if (iChannelNumber > 0)
247             CLog::Log(LOGDEBUG, "switch to channel number %d", iChannelNumber);
248           else
249             CLog::Log(LOGDEBUG, "no previous channel number found");
250         }
251         else
252         {
253           int autoCloseTime = CSettings::Get().GetBool("pvrplayback.confirmchannelswitch") ? 0 : g_advancedSettings.m_iPVRNumericChannelSwitchTimeout;
254           CStdString strChannel = StringUtils::Format("%i", action.GetID() - REMOTE_0);
255           if (CGUIDialogNumeric::ShowAndGetNumber(strChannel, g_localizeStrings.Get(19000), autoCloseTime) || autoCloseTime)
256             iChannelNumber = atoi(strChannel.c_str());
257         }
258
259         if (iChannelNumber > 0 && iChannelNumber != channel->ChannelNumber())
260         {
261           CPVRChannelGroupPtr selectedGroup = g_PVRManager.GetPlayingGroup(channel->IsRadio());
262           CFileItemPtr channel = selectedGroup->GetByChannelNumber(iChannelNumber);
263           if (!channel || !channel->HasPVRChannelInfoTag())
264             return false;
265
266           g_application.OnAction(CAction(ACTION_CHANNEL_SWITCH, (float)iChannelNumber));
267         }
268       }
269       else
270       {
271         ChangetheTimeCode(action.GetID());
272       }
273       return true;
274     }
275     break;
276
277   case ACTION_ASPECT_RATIO:
278     { // toggle the aspect ratio mode (only if the info is onscreen)
279       if (m_bShowViewModeInfo)
280       {
281 #ifdef HAS_VIDEO_PLAYBACK
282         g_renderManager.SetViewMode(++CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode);
283 #endif
284       }
285       m_bShowViewModeInfo = true;
286       m_dwShowViewModeTimeout = XbmcThreads::SystemClockMillis();
287     }
288     return true;
289     break;
290   case ACTION_SMALL_STEP_BACK:
291     if (m_timeCodePosition > 0)
292       SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_BACKWARD);
293     else
294     {
295       int orgpos = (int)g_application.GetTime();
296       int jumpsize = g_advancedSettings.m_videoSmallStepBackSeconds; // secs
297       int setpos = (orgpos > jumpsize) ? orgpos - jumpsize : 0;
298       g_application.SeekTime((double)setpos);
299     }
300     return true;
301     break;
302   case ACTION_SHOW_PLAYLIST:
303     {
304       CFileItem item(g_application.CurrentFileItem());
305       if (item.HasPVRChannelInfoTag())
306         g_windowManager.ActivateWindow(WINDOW_DIALOG_PVR_OSD_CHANNELS);
307       else if (item.HasVideoInfoTag())
308         g_windowManager.ActivateWindow(WINDOW_VIDEO_PLAYLIST);
309       else if (item.HasMusicInfoTag())
310         g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST);
311     }
312     return true;
313     break;
314   case ACTION_PREVIOUS_CHANNELGROUP:
315     {
316       if (g_application.CurrentFileItem().HasPVRChannelInfoTag())
317         ChangetheTVGroup(false);
318       return true;
319     }
320   case ACTION_NEXT_CHANNELGROUP:
321     {
322       if (g_application.CurrentFileItem().HasPVRChannelInfoTag())
323         ChangetheTVGroup(true);
324       return true;
325     }
326   default:
327       break;
328   }
329
330   return CGUIWindow::OnAction(action);
331 }
332
333 void CGUIWindowFullScreen::OnWindowLoaded()
334 {
335   CGUIWindow::OnWindowLoaded();
336   // override the clear colour - we must never clear fullscreen
337   m_clearBackground = 0;
338
339   CGUIProgressControl* pProgress = (CGUIProgressControl*)GetControl(CONTROL_PROGRESS);
340   if(pProgress)
341   {
342     if( pProgress->GetInfo() == 0 || pProgress->GetVisibleCondition() == 0)
343     {
344       pProgress->SetInfo(PLAYER_PROGRESS);
345       pProgress->SetVisibleCondition("player.displayafterseek");
346       pProgress->SetVisible(true);
347     }
348   }
349
350   CGUILabelControl* pLabel = (CGUILabelControl*)GetControl(LABEL_BUFFERING);
351   if(pLabel && pLabel->GetVisibleCondition() == 0)
352   {
353     pLabel->SetVisibleCondition("player.caching");
354     pLabel->SetVisible(true);
355   }
356
357   pLabel = (CGUILabelControl*)GetControl(LABEL_CURRENT_TIME);
358   if(pLabel && pLabel->GetVisibleCondition() == 0)
359   {
360     pLabel->SetVisibleCondition("player.displayafterseek");
361     pLabel->SetVisible(true);
362     pLabel->SetLabel("$INFO(VIDEOPLAYER.TIME) / $INFO(VIDEOPLAYER.DURATION)");
363   }
364
365   m_showCodec.Parse("player.showcodec", GetID());
366
367   FillInTVGroups();
368 }
369
370 bool CGUIWindowFullScreen::OnMessage(CGUIMessage& message)
371 {
372   switch (message.GetMessage())
373   {
374   case GUI_MSG_WINDOW_INIT:
375     {
376       // check whether we've come back here from a window during which time we've actually
377       // stopped playing videos
378       if (message.GetParam1() == WINDOW_INVALID && !g_application.m_pPlayer->IsPlayingVideo())
379       { // why are we here if nothing is playing???
380         g_windowManager.PreviousWindow();
381         return true;
382       }
383       g_infoManager.SetShowInfo(false);
384       g_infoManager.SetShowCodec(false);
385       m_bShowCurrentTime = false;
386       m_bGroupSelectShow = false;
387       g_infoManager.SetDisplayAfterSeek(0); // Make sure display after seek is off.
388
389       // switch resolution
390       g_graphicsContext.SetFullScreenVideo(true);
391
392 #ifdef HAS_VIDEO_PLAYBACK
393       // make sure renderer is uptospeed
394       g_renderManager.Update();
395 #endif
396       // now call the base class to load our windows
397       CGUIWindow::OnMessage(message);
398
399       m_bShowViewModeInfo = false;
400
401       return true;
402     }
403   case GUI_MSG_WINDOW_DEINIT:
404     {
405       CGUIDialog *pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_OSD_TELETEXT);
406       if (pDialog) pDialog->Close(true);
407       pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_SLIDER);
408       if (pDialog) pDialog->Close(true);
409       pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_OSD);
410       if (pDialog) pDialog->Close(true);
411       pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_FULLSCREEN_INFO);
412       if (pDialog) pDialog->Close(true);
413       pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_CHANNELS);
414       if (pDialog) pDialog->Close(true);
415       pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_GUIDE);
416       if (pDialog) pDialog->Close(true);
417       pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_DIRECTOR);
418       if (pDialog) pDialog->Close(true);
419       pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_CUTTER);
420       if (pDialog) pDialog->Close(true);
421
422       CGUIWindow::OnMessage(message);
423
424       CSettings::Get().Save();
425
426       CSingleLock lock (g_graphicsContext);
427       g_graphicsContext.SetFullScreenVideo(false);
428       lock.Leave();
429
430 #ifdef HAS_VIDEO_PLAYBACK
431       // make sure renderer is uptospeed
432       g_renderManager.Update();
433 #endif
434       return true;
435     }
436   case GUI_MSG_CLICKED:
437     {
438       unsigned int iControl = message.GetSenderId();
439       if (iControl == CONTROL_GROUP_CHOOSER && g_PVRManager.IsStarted())
440       {
441         // Get the currently selected label of the Select button
442         CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControl);
443         OnMessage(msg);
444         CStdString strLabel = msg.GetLabel();
445
446         CPVRChannelPtr playingChannel;
447         if (g_PVRManager.GetCurrentChannel(playingChannel))
448         {
449           CPVRChannelGroupPtr selectedGroup = g_PVRChannelGroups->Get(playingChannel->IsRadio())->GetByName(strLabel);
450           if (selectedGroup)
451           {
452             g_PVRManager.SetPlayingGroup(selectedGroup);
453             CLog::Log(LOGDEBUG, "%s - switched to group '%s'", __FUNCTION__, selectedGroup->GroupName().c_str());
454
455             if (!selectedGroup->IsGroupMember(*playingChannel))
456             {
457               CLog::Log(LOGDEBUG, "%s - channel '%s' is not a member of '%s', switching to channel 1 of the new group",
458                   __FUNCTION__, playingChannel->ChannelName().c_str(), selectedGroup->GroupName().c_str());
459               CFileItemPtr switchChannel = selectedGroup->GetByChannelNumber(1);
460
461               if (switchChannel && switchChannel->HasPVRChannelInfoTag())
462                 g_application.OnAction(CAction(ACTION_CHANNEL_SWITCH, (float) switchChannel->GetPVRChannelInfoTag()->ChannelNumber()));
463               else
464               {
465                 CLog::Log(LOGERROR, "%s - cannot find channel '1' in group %s", __FUNCTION__, selectedGroup->GroupName().c_str());
466                 CApplicationMessenger::Get().MediaStop(false);
467               }
468             }
469           }
470           else
471           {
472             CLog::Log(LOGERROR, "%s - could not switch to group '%s'", __FUNCTION__, selectedGroup->GroupName().c_str());
473             CApplicationMessenger::Get().MediaStop(false);
474           }
475         }
476         else
477         {
478           CLog::Log(LOGERROR, "%s - cannot find the current channel", __FUNCTION__);
479           CApplicationMessenger::Get().MediaStop(false);
480         }
481
482         // hide the control and reset focus
483         m_bGroupSelectShow = false;
484         SET_CONTROL_HIDDEN(CONTROL_GROUP_CHOOSER);
485 //      SET_CONTROL_FOCUS(0, 0);
486
487         return true;
488       }
489       break;
490     }
491   case GUI_MSG_SETFOCUS:
492   case GUI_MSG_LOSTFOCUS:
493     if (message.GetSenderId() != WINDOW_FULLSCREEN_VIDEO) return true;
494     break;
495   }
496
497   return CGUIWindow::OnMessage(message);
498 }
499
500 EVENT_RESULT CGUIWindowFullScreen::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
501 {
502   if (event.m_id == ACTION_MOUSE_RIGHT_CLICK)
503   { // no control found to absorb this click - go back to GUI
504     OnAction(CAction(ACTION_SHOW_GUI));
505     return EVENT_RESULT_HANDLED;
506   }
507   if (event.m_id == ACTION_MOUSE_WHEEL_UP)
508   {
509     return g_application.OnAction(CAction(ACTION_ANALOG_SEEK_FORWARD, 0.5f)) ? EVENT_RESULT_HANDLED : EVENT_RESULT_UNHANDLED;
510   }
511   if (event.m_id == ACTION_MOUSE_WHEEL_DOWN)
512   {
513     return g_application.OnAction(CAction(ACTION_ANALOG_SEEK_BACK, 0.5f)) ? EVENT_RESULT_HANDLED : EVENT_RESULT_UNHANDLED;
514   }
515   if (event.m_id == ACTION_GESTURE_NOTIFY)
516     return EVENT_RESULT_UNHANDLED;
517   if (event.m_id != ACTION_MOUSE_MOVE || event.m_offsetX || event.m_offsetY)
518   { // some other mouse action has occurred - bring up the OSD
519     // if it is not already running
520     CGUIDialogVideoOSD *pOSD = (CGUIDialogVideoOSD *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_OSD);
521     if (pOSD && !pOSD->IsDialogRunning())
522     {
523       pOSD->SetAutoClose(3000);
524       pOSD->DoModal();
525     }
526     return EVENT_RESULT_HANDLED;
527   }
528   return EVENT_RESULT_UNHANDLED;
529 }
530
531 void CGUIWindowFullScreen::FrameMove()
532 {
533   if (g_application.m_pPlayer->GetPlaySpeed() != 1)
534     g_infoManager.SetDisplayAfterSeek();
535   if (m_bShowCurrentTime)
536     g_infoManager.SetDisplayAfterSeek();
537
538   if (!g_application.m_pPlayer->HasPlayer()) return;
539
540   if( g_application.m_pPlayer->IsCaching() )
541   {
542     g_infoManager.SetDisplayAfterSeek(0); //Make sure these stuff aren't visible now
543   }
544
545   //------------------------
546   m_showCodec.Update();
547   if (m_showCodec)
548   {
549     // show audio codec info
550     CStdString strAudio, strVideo, strGeneral;
551     g_application.m_pPlayer->GetAudioInfo(strAudio);
552     {
553       CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1);
554       msg.SetLabel(strAudio);
555       OnMessage(msg);
556     }
557     // show video codec info
558     g_application.m_pPlayer->GetVideoInfo(strVideo);
559     {
560       CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW2);
561       msg.SetLabel(strVideo);
562       OnMessage(msg);
563     }
564     // show general info
565     g_application.m_pPlayer->GetGeneralInfo(strGeneral);
566     {
567       CStdString strGeneralFPS;
568 #if defined(TARGET_DARWIN)
569       // We show CPU usage for the entire process, as it's arguably more useful.
570       double dCPU = m_resourceCounter.GetCPUUsage();
571       CStdString strCores;
572       strCores = StringUtils::Format("cpu:%.0f%%", dCPU);
573 #else
574       CStdString strCores = g_cpuInfo.GetCoresUsageString();
575 #endif
576       int    missedvblanks;
577       int    refreshrate;
578       double clockspeed;
579       CStdString strClock;
580
581       if (g_VideoReferenceClock.GetClockInfo(missedvblanks, clockspeed, refreshrate))
582         strClock = StringUtils::Format("S( refresh:%i missed:%i speed:%+.3f%% %s )"
583                                        , refreshrate
584                                        , missedvblanks
585                                        , clockspeed - 100.0
586                                        , g_renderManager.GetVSyncState().c_str());
587
588       strGeneralFPS = StringUtils::Format("%s\nW( fps:%02.2f %s ) %s"
589                                           , strGeneral.c_str()
590                                           , g_infoManager.GetFPS()
591                                           , strCores.c_str(), strClock.c_str() );
592
593       CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW3);
594       msg.SetLabel(strGeneralFPS);
595       OnMessage(msg);
596     }
597   }
598   //----------------------
599   // ViewMode Information
600   //----------------------
601   if (m_bShowViewModeInfo && XbmcThreads::SystemClockMillis() - m_dwShowViewModeTimeout > 2500)
602   {
603     m_bShowViewModeInfo = false;
604   }
605   if (m_bShowViewModeInfo)
606   {
607     RESOLUTION_INFO res = g_graphicsContext.GetResInfo();
608
609     {
610       // get the "View Mode" string
611       CStdString strTitle = g_localizeStrings.Get(629);
612       CStdString strMode = g_localizeStrings.Get(630 + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode);
613       CStdString strInfo = StringUtils::Format("%s : %s", strTitle.c_str(), strMode.c_str());
614       CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1);
615       msg.SetLabel(strInfo);
616       OnMessage(msg);
617     }
618     // show sizing information
619     SPlayerVideoStreamInfo info;
620     g_application.m_pPlayer->GetVideoStreamInfo(info);
621     {
622       // Splitres scaling factor
623       float xscale = (float)res.iScreenWidth  / (float)res.iWidth;
624       float yscale = (float)res.iScreenHeight / (float)res.iHeight;
625
626       CStdString strSizing = StringUtils::Format(g_localizeStrings.Get(245),
627                                                  (int)info.SrcRect.Width(),
628                                                  (int)info.SrcRect.Height(),
629                                                  (int)(info.DestRect.Width() * xscale),
630                                                  (int)(info.DestRect.Height() * yscale),
631                                                  CDisplaySettings::Get().GetZoomAmount(),
632                                                  info.videoAspectRatio*CDisplaySettings::Get().GetPixelRatio(),
633                                                  CDisplaySettings::Get().GetPixelRatio(),
634                                                  CDisplaySettings::Get().GetVerticalShift());
635       CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW2);
636       msg.SetLabel(strSizing);
637       OnMessage(msg);
638     }
639     // show resolution information
640     {
641       CStdString strStatus;
642       if (g_Windowing.IsFullScreen())
643         strStatus = StringUtils::Format("%s %ix%i@%.2fHz - %s",
644                                         g_localizeStrings.Get(13287).c_str(),
645                                         res.iScreenWidth,
646                                         res.iScreenHeight,
647                                         res.fRefreshRate,
648                                         g_localizeStrings.Get(244).c_str());
649       else
650         strStatus = StringUtils::Format("%s %ix%i - %s",
651                                         g_localizeStrings.Get(13287).c_str(),
652                                         res.iScreenWidth,
653                                         res.iScreenHeight,
654                                         g_localizeStrings.Get(242).c_str());
655
656       CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW3);
657       msg.SetLabel(strStatus);
658       OnMessage(msg);
659     }
660   }
661
662   if (m_timeCodeShow && m_timeCodePosition != 0)
663   {
664     if ( (XbmcThreads::SystemClockMillis() - m_timeCodeTimeout) >= 2500)
665     {
666       m_timeCodeShow = false;
667       m_timeCodePosition = 0;
668     }
669     CStdString strDispTime = "00:00:00";
670
671     CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1);
672
673     for (int pos = 7, i = m_timeCodePosition; pos >= 0 && i > 0; pos--)
674     {
675       if (strDispTime[pos] != ':')
676       {
677         i -= 1;
678         strDispTime[pos] = (char)m_timeCodeStamp[i] + '0';
679       }
680     }
681
682     strDispTime += "/" + g_infoManager.GetDuration(TIME_FORMAT_HH_MM_SS) + " [" + g_infoManager.GetCurrentPlayTime(TIME_FORMAT_HH_MM_SS) + "]"; // duration [ time ]
683     msg.SetLabel(strDispTime);
684     OnMessage(msg);
685   }
686
687   if (m_showCodec || m_bShowViewModeInfo)
688   {
689     SET_CONTROL_VISIBLE(LABEL_ROW1);
690     SET_CONTROL_VISIBLE(LABEL_ROW2);
691     SET_CONTROL_VISIBLE(LABEL_ROW3);
692     SET_CONTROL_VISIBLE(BLUE_BAR);
693     SET_CONTROL_HIDDEN(CONTROL_GROUP_CHOOSER);
694   }
695   else if (m_timeCodeShow)
696   {
697     SET_CONTROL_VISIBLE(LABEL_ROW1);
698     SET_CONTROL_HIDDEN(LABEL_ROW2);
699     SET_CONTROL_HIDDEN(LABEL_ROW3);
700     SET_CONTROL_VISIBLE(BLUE_BAR);
701     SET_CONTROL_HIDDEN(CONTROL_GROUP_CHOOSER);
702   }
703   else if (m_bGroupSelectShow)
704   {
705     SET_CONTROL_HIDDEN(LABEL_ROW1);
706     SET_CONTROL_HIDDEN(LABEL_ROW2);
707     SET_CONTROL_HIDDEN(LABEL_ROW3);
708     SET_CONTROL_HIDDEN(BLUE_BAR);
709     SET_CONTROL_VISIBLE(CONTROL_GROUP_CHOOSER);
710   }
711   else
712   {
713     SET_CONTROL_HIDDEN(LABEL_ROW1);
714     SET_CONTROL_HIDDEN(LABEL_ROW2);
715     SET_CONTROL_HIDDEN(LABEL_ROW3);
716     SET_CONTROL_HIDDEN(BLUE_BAR);
717     SET_CONTROL_HIDDEN(CONTROL_GROUP_CHOOSER);
718   }
719 }
720
721 void CGUIWindowFullScreen::Process(unsigned int currentTime, CDirtyRegionList &dirtyregion)
722 {
723   // TODO: This isn't quite optimal - ideally we'd only be dirtying up the actual video render rect
724   //       which is probably the job of the renderer as it can more easily track resizing etc.
725   MarkDirtyRegion();
726   CGUIWindow::Process(currentTime, dirtyregion);
727   m_renderRegion.SetRect(0, 0, (float)g_graphicsContext.GetWidth(), (float)g_graphicsContext.GetHeight());
728 }
729
730 void CGUIWindowFullScreen::Render()
731 {
732   CGUIWindow::Render();
733 }
734
735 void CGUIWindowFullScreen::ChangetheTimeCode(int remote)
736 {
737   if (remote >= REMOTE_0 && remote <= REMOTE_9)
738   {
739     m_timeCodeShow = true;
740     m_timeCodeTimeout = XbmcThreads::SystemClockMillis();
741
742     if (m_timeCodePosition < 6)
743       m_timeCodeStamp[m_timeCodePosition++] = remote - REMOTE_0;
744     else
745     {
746       // rotate around
747       for (int i = 0; i < 5; i++)
748         m_timeCodeStamp[i] = m_timeCodeStamp[i+1];
749       m_timeCodeStamp[5] = remote - REMOTE_0;
750     }
751   }
752 }
753
754 void CGUIWindowFullScreen::SeekToTimeCodeStamp(SEEK_TYPE type, SEEK_DIRECTION direction)
755 {
756   double total = GetTimeCodeStamp();
757   if (type == SEEK_RELATIVE)
758     total = g_application.GetTime() + (((direction == SEEK_FORWARD) ? 1 : -1) * total);
759
760   if (total < g_application.GetTotalTime())
761     g_application.SeekTime(total);
762
763   m_timeCodePosition = 0;
764   m_timeCodeShow = false;
765 }
766
767 double CGUIWindowFullScreen::GetTimeCodeStamp()
768 {
769   // Convert the timestamp into an integer
770   int tot = 0;
771   for (int i = 0; i < m_timeCodePosition; i++)
772     tot = tot * 10 + m_timeCodeStamp[i];
773
774   // Interpret result as HHMMSS
775   int s = tot % 100; tot /= 100;
776   int m = tot % 100; tot /= 100;
777   int h = tot % 100;
778   return h * 3600 + m * 60 + s;
779 }
780
781 void CGUIWindowFullScreen::SeekChapter(int iChapter)
782 {
783   g_application.m_pPlayer->SeekChapter(iChapter);
784
785   // Make sure gui items are visible.
786   g_infoManager.SetDisplayAfterSeek();
787 }
788
789 void CGUIWindowFullScreen::FillInTVGroups()
790 {
791   if (!g_PVRManager.IsStarted())
792     return;
793
794   CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_GROUP_CHOOSER);
795   g_windowManager.SendMessage(msgReset);
796
797   const CPVRChannelGroups *groups = g_PVRChannelGroups->Get(g_PVRManager.IsPlayingRadio());
798   if (groups)
799     groups->FillGroupsGUI(GetID(), CONTROL_GROUP_CHOOSER);
800 }
801
802 void CGUIWindowFullScreen::ChangetheTVGroup(bool next)
803 {
804   if (!g_PVRManager.IsStarted())
805     return;
806
807   CGUISelectButtonControl* pButton = (CGUISelectButtonControl*)GetControl(CONTROL_GROUP_CHOOSER);
808   if (!pButton)
809     return;
810
811   if (!m_bGroupSelectShow)
812   {
813     SET_CONTROL_VISIBLE(CONTROL_GROUP_CHOOSER);
814     SET_CONTROL_FOCUS(CONTROL_GROUP_CHOOSER, 0);
815
816     // fire off an event that we've pressed this button...
817     OnAction(CAction(ACTION_SELECT_ITEM));
818
819     m_bGroupSelectShow = true;
820   }
821   else
822   {
823     if (next)
824       pButton->OnRight();
825     else
826       pButton->OnLeft();
827   }
828 }
829
830 void CGUIWindowFullScreen::ToggleOSD()
831 {
832   CGUIDialogVideoOSD *pOSD = (CGUIDialogVideoOSD *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_OSD);
833   if (pOSD)
834   {
835     if (pOSD->IsDialogRunning())
836       pOSD->Close();
837     else
838       pOSD->DoModal();
839   }
840 }