1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "GUIWindowFullScreen.h"
#include "FileItem.h"
#include "GUIInfoManager.h"
#include "GUIWindowFullScreenDefines.h"
#include "ServiceBroker.h"
#include "application/Application.h"
#include "application/ApplicationComponents.h"
#include "application/ApplicationPlayer.h"
#include "cores/IPlayer.h"
#include "guilib/GUIComponent.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/LocalizeStrings.h"
#include "input/Key.h"
#include "settings/DisplaySettings.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "utils/StringUtils.h"
#include "video/ViewModeSettings.h"
#include "video/dialogs/GUIDialogFullScreenInfo.h"
#include "video/dialogs/GUIDialogSubtitleSettings.h"
#include "windowing/WinSystem.h"
#include <algorithm>
#include <stdio.h>
#if defined(TARGET_DARWIN)
#include "platform/posix/PosixResourceCounter.h"
#endif
using namespace KODI::GUILIB;
using namespace KODI::MESSAGING;
#if defined(TARGET_DARWIN)
static CPosixResourceCounter m_resourceCounter;
#endif
CGUIWindowFullScreen::CGUIWindowFullScreen()
: CGUIWindow(WINDOW_FULLSCREEN_VIDEO, "VideoFullScreen.xml")
{
m_viewModeChanged = true;
m_dwShowViewModeTimeout = {};
m_bShowCurrentTime = false;
m_loadType = KEEP_IN_MEMORY;
// audio
// - language
// - volume
// - stream
// video
// - Create Bookmark (294)
// - Cycle bookmarks (295)
// - Clear bookmarks (296)
// - jump to specific time
// - slider
// - av delay
// subtitles
// - delay
// - language
m_controlStats = new GUICONTROLSTATS;
}
CGUIWindowFullScreen::~CGUIWindowFullScreen(void)
{
delete m_controlStats;
}
bool CGUIWindowFullScreen::OnAction(const CAction &action)
{
auto& components = CServiceBroker::GetAppComponents();
const auto appPlayer = components.GetComponent<CApplicationPlayer>();
switch (action.GetID())
{
case ACTION_SHOW_OSD:
ToggleOSD();
return true;
case ACTION_TRIGGER_OSD:
TriggerOSD();
return true;
case ACTION_MOUSE_MOVE:
if (action.GetAmount(2) || action.GetAmount(3))
{
if (!appPlayer->IsInMenu())
{
TriggerOSD();
return true;
}
}
break;
case ACTION_MOUSE_LEFT_CLICK:
if (!appPlayer->IsInMenu())
{
TriggerOSD();
return true;
}
break;
case ACTION_SHOW_GUI:
{
// switch back to the menu
CServiceBroker::GetGUI()->GetWindowManager().PreviousWindow();
return true;
}
break;
case ACTION_SHOW_OSD_TIME:
m_bShowCurrentTime = !m_bShowCurrentTime;
CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPlayerInfoProvider().SetShowTime(m_bShowCurrentTime);
return true;
break;
case ACTION_SHOW_INFO:
{
CGUIDialogFullScreenInfo* pDialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogFullScreenInfo>(WINDOW_DIALOG_FULLSCREEN_INFO);
if (pDialog)
{
CFileItem item(g_application.CurrentFileItem());
pDialog->Open();
return true;
}
break;
}
case ACTION_ASPECT_RATIO:
{ // toggle the aspect ratio mode (only if the info is onscreen)
if (m_dwShowViewModeTimeout.time_since_epoch().count() != 0)
{
CVideoSettings vs = appPlayer->GetVideoSettings();
vs.m_ViewMode = CViewModeSettings::GetNextQuickCycleViewMode(vs.m_ViewMode);
appPlayer->SetRenderViewMode(vs.m_ViewMode, vs.m_CustomZoomAmount, vs.m_CustomPixelRatio,
vs.m_CustomVerticalShift, vs.m_CustomNonLinStretch);
}
else
m_viewModeChanged = true;
m_dwShowViewModeTimeout = std::chrono::steady_clock::now();
}
return true;
break;
case ACTION_SHOW_PLAYLIST:
{
CFileItem item(g_application.CurrentFileItem());
if (item.HasPVRChannelInfoTag())
CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_DIALOG_PVR_OSD_CHANNELS);
else if (item.HasVideoInfoTag())
CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_VIDEO_PLAYLIST);
else if (item.HasMusicInfoTag())
CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_MUSIC_PLAYLIST);
}
return true;
break;
case ACTION_BROWSE_SUBTITLE:
{
std::string path = CGUIDialogSubtitleSettings::BrowseForSubtitle();
if (!path.empty())
appPlayer->AddSubtitle(path);
return true;
}
default:
break;
}
return CGUIWindow::OnAction(action);
}
void CGUIWindowFullScreen::ClearBackground()
{
const auto& components = CServiceBroker::GetAppComponents();
const auto appPlayer = components.GetComponent<CApplicationPlayer>();
if (appPlayer->IsRenderingVideoLayer())
CServiceBroker::GetWinSystem()->GetGfxContext().Clear(0);
}
void CGUIWindowFullScreen::OnWindowLoaded()
{
CGUIWindow::OnWindowLoaded();
// override the clear colour - we must never clear fullscreen
m_clearBackground = 0;
}
bool CGUIWindowFullScreen::OnMessage(CGUIMessage& message)
{
switch (message.GetMessage())
{
case GUI_MSG_WINDOW_INIT:
{
// check whether we've come back here from a window during which time we've actually
// stopped playing videos
const auto& components = CServiceBroker::GetAppComponents();
const auto appPlayer = components.GetComponent<CApplicationPlayer>();
if (message.GetParam1() == WINDOW_INVALID && !appPlayer->IsPlayingVideo())
{ // why are we here if nothing is playing???
CServiceBroker::GetGUI()->GetWindowManager().PreviousWindow();
return true;
}
GUIINFO::CPlayerGUIInfo& guiInfo = CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPlayerInfoProvider();
guiInfo.SetShowInfo(false);
m_bShowCurrentTime = false;
// switch resolution
CServiceBroker::GetWinSystem()->GetGfxContext().SetFullScreenVideo(true);
// now call the base class to load our windows
CGUIWindow::OnMessage(message);
m_dwShowViewModeTimeout = {};
m_viewModeChanged = true;
return true;
}
case GUI_MSG_WINDOW_DEINIT:
{
// close all active modal dialogs
CServiceBroker::GetGUI()->GetWindowManager().CloseInternalModalDialogs(true);
CGUIWindow::OnMessage(message);
CServiceBroker::GetSettingsComponent()->GetSettings()->Save();
CServiceBroker::GetWinSystem()->GetGfxContext().SetFullScreenVideo(false);
return true;
}
case GUI_MSG_SETFOCUS:
case GUI_MSG_LOSTFOCUS:
if (message.GetSenderId() != WINDOW_FULLSCREEN_VIDEO) return true;
break;
}
return CGUIWindow::OnMessage(message);
}
EVENT_RESULT CGUIWindowFullScreen::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
{
if (event.m_id == ACTION_MOUSE_RIGHT_CLICK)
{ // no control found to absorb this click - go back to GUI
OnAction(CAction(ACTION_SHOW_GUI));
return EVENT_RESULT_HANDLED;
}
if (event.m_id == ACTION_MOUSE_WHEEL_UP)
{
return g_application.OnAction(CAction(ACTION_ANALOG_SEEK_FORWARD, 0.5f)) ? EVENT_RESULT_HANDLED : EVENT_RESULT_UNHANDLED;
}
if (event.m_id == ACTION_MOUSE_WHEEL_DOWN)
{
return g_application.OnAction(CAction(ACTION_ANALOG_SEEK_BACK, 0.5f)) ? EVENT_RESULT_HANDLED : EVENT_RESULT_UNHANDLED;
}
if (event.m_id >= ACTION_GESTURE_NOTIFY && event.m_id <= ACTION_GESTURE_END) // gestures
return EVENT_RESULT_UNHANDLED;
return EVENT_RESULT_UNHANDLED;
}
void CGUIWindowFullScreen::FrameMove()
{
const auto& components = CServiceBroker::GetAppComponents();
const auto appPlayer = components.GetComponent<CApplicationPlayer>();
if (!appPlayer->HasPlayer())
return;
//----------------------
// ViewMode Information
//----------------------
auto now = std::chrono::steady_clock::now();
auto duration =
std::chrono::duration_cast<std::chrono::milliseconds>(now - m_dwShowViewModeTimeout);
if (m_dwShowViewModeTimeout.time_since_epoch().count() != 0 && duration.count() > 2500)
{
m_dwShowViewModeTimeout = {};
m_viewModeChanged = true;
}
if (m_dwShowViewModeTimeout.time_since_epoch().count() != 0)
{
RESOLUTION_INFO res = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo();
{
// get the "View Mode" string
const std::string& strTitle = g_localizeStrings.Get(629);
const auto& vs = appPlayer->GetVideoSettings();
int sId = CViewModeSettings::GetViewModeStringIndex(vs.m_ViewMode);
const std::string& strMode = g_localizeStrings.Get(sId);
std::string strInfo = StringUtils::Format("{} : {}", strTitle, strMode);
CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1);
msg.SetLabel(strInfo);
OnMessage(msg);
}
// show sizing information
VideoStreamInfo info;
appPlayer->GetVideoStreamInfo(CURRENT_STREAM, info);
{
// Splitres scaling factor
float xscale = (float)res.iScreenWidth / (float)res.iWidth;
float yscale = (float)res.iScreenHeight / (float)res.iHeight;
std::string strSizing = StringUtils::Format(
g_localizeStrings.Get(245), (int)info.SrcRect.Width(), (int)info.SrcRect.Height(),
(int)(info.DestRect.Width() * xscale), (int)(info.DestRect.Height() * yscale),
CDisplaySettings::GetInstance().GetZoomAmount(),
info.videoAspectRatio * CDisplaySettings::GetInstance().GetPixelRatio(),
CDisplaySettings::GetInstance().GetPixelRatio(),
CDisplaySettings::GetInstance().GetVerticalShift());
CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW2);
msg.SetLabel(strSizing);
OnMessage(msg);
}
// show resolution information
{
std::string strStatus;
if (CServiceBroker::GetWinSystem()->IsFullScreen())
strStatus = StringUtils::Format("{} {}x{}@{:.2f}Hz - {}", g_localizeStrings.Get(13287),
res.iScreenWidth, res.iScreenHeight, res.fRefreshRate,
g_localizeStrings.Get(244));
else
strStatus =
StringUtils::Format("{} {}x{} - {}", g_localizeStrings.Get(13287), res.iScreenWidth,
res.iScreenHeight, g_localizeStrings.Get(242));
CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW3);
msg.SetLabel(strStatus);
OnMessage(msg);
}
}
if (m_viewModeChanged)
{
if (m_dwShowViewModeTimeout.time_since_epoch().count() != 0)
{
SET_CONTROL_VISIBLE(LABEL_ROW1);
SET_CONTROL_VISIBLE(LABEL_ROW2);
SET_CONTROL_VISIBLE(LABEL_ROW3);
SET_CONTROL_VISIBLE(BLUE_BAR);
}
else
{
SET_CONTROL_HIDDEN(LABEL_ROW1);
SET_CONTROL_HIDDEN(LABEL_ROW2);
SET_CONTROL_HIDDEN(LABEL_ROW3);
SET_CONTROL_HIDDEN(BLUE_BAR);
}
m_viewModeChanged = false;
}
}
void CGUIWindowFullScreen::Process(unsigned int currentTime, CDirtyRegionList &dirtyregion)
{
const auto& components = CServiceBroker::GetAppComponents();
const auto appPlayer = components.GetComponent<CApplicationPlayer>();
if (appPlayer->IsRenderingGuiLayer())
MarkDirtyRegion();
m_controlStats->Reset();
CGUIWindow::Process(currentTime, dirtyregion);
//! @todo This isn't quite optimal - ideally we'd only be dirtying up the actual video render rect
//! which is probably the job of the renderer as it can more easily track resizing etc.
m_renderRegion.SetRect(0, 0, (float)CServiceBroker::GetWinSystem()->GetGfxContext().GetWidth(), (float)CServiceBroker::GetWinSystem()->GetGfxContext().GetHeight());
}
void CGUIWindowFullScreen::Render()
{
CServiceBroker::GetWinSystem()->GetGfxContext().SetRenderingResolution(CServiceBroker::GetWinSystem()->GetGfxContext().GetVideoResolution(), false);
auto& components = CServiceBroker::GetAppComponents();
const auto appPlayer = components.GetComponent<CApplicationPlayer>();
appPlayer->Render(true, 255);
CServiceBroker::GetWinSystem()->GetGfxContext().SetRenderingResolution(m_coordsRes, m_needsScaling);
CGUIWindow::Render();
}
void CGUIWindowFullScreen::RenderEx()
{
CGUIWindow::RenderEx();
CServiceBroker::GetWinSystem()->GetGfxContext().SetRenderingResolution(CServiceBroker::GetWinSystem()->GetGfxContext().GetVideoResolution(), false);
auto& components = CServiceBroker::GetAppComponents();
const auto appPlayer = components.GetComponent<CApplicationPlayer>();
appPlayer->Render(false, 255, false);
CServiceBroker::GetWinSystem()->GetGfxContext().SetRenderingResolution(m_coordsRes, m_needsScaling);
}
void CGUIWindowFullScreen::SeekChapter(int iChapter)
{
auto& components = CServiceBroker::GetAppComponents();
const auto appPlayer = components.GetComponent<CApplicationPlayer>();
appPlayer->SeekChapter(iChapter);
}
void CGUIWindowFullScreen::ToggleOSD()
{
CGUIDialog *pOSD = GetOSD();
if (pOSD)
{
if (pOSD->IsDialogRunning())
pOSD->Close();
else
pOSD->Open();
}
MarkDirtyRegion();
}
void CGUIWindowFullScreen::TriggerOSD()
{
CGUIDialog *pOSD = GetOSD();
if (pOSD && !pOSD->IsDialogRunning())
{
const auto& components = CServiceBroker::GetAppComponents();
const auto appPlayer = components.GetComponent<CApplicationPlayer>();
if (!appPlayer->IsPlayingGame())
pOSD->SetAutoClose(3000);
pOSD->Open();
}
}
bool CGUIWindowFullScreen::HasVisibleControls()
{
return m_controlStats->nCountVisible > 0;
}
CGUIDialog* CGUIWindowFullScreen::GetOSD()
{
return CServiceBroker::GetGUI()->GetWindowManager().GetDialog(WINDOW_DIALOG_VIDEO_OSD);
}
|