2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "GUIDialogVideoSettings.h"
11 #include "GUIPassword.h"
12 #include "ServiceBroker.h"
13 #include "addons/Skin.h"
14 #include "application/ApplicationComponents.h"
15 #include "application/ApplicationPlayer.h"
16 #include "dialogs/GUIDialogYesNo.h"
17 #include "guilib/GUIComponent.h"
18 #include "guilib/GUIWindowManager.h"
19 #include "guilib/LocalizeStrings.h"
20 #include "profiles/ProfileManager.h"
21 #include "settings/MediaSettings.h"
22 #include "settings/Settings.h"
23 #include "settings/SettingsComponent.h"
24 #include "settings/lib/Setting.h"
25 #include "settings/lib/SettingDefinitions.h"
26 #include "settings/lib/SettingsManager.h"
27 #include "utils/LangCodeExpander.h"
28 #include "utils/StringUtils.h"
29 #include "utils/Variant.h"
30 #include "utils/log.h"
31 #include "video/VideoDatabase.h"
32 #include "video/ViewModeSettings.h"
36 #define SETTING_VIDEO_VIEW_MODE "video.viewmode"
37 #define SETTING_VIDEO_ZOOM "video.zoom"
38 #define SETTING_VIDEO_PIXEL_RATIO "video.pixelratio"
39 #define SETTING_VIDEO_BRIGHTNESS "video.brightness"
40 #define SETTING_VIDEO_CONTRAST "video.contrast"
41 #define SETTING_VIDEO_GAMMA "video.gamma"
42 #define SETTING_VIDEO_NONLIN_STRETCH "video.nonlinearstretch"
43 #define SETTING_VIDEO_POSTPROCESS "video.postprocess"
44 #define SETTING_VIDEO_VERTICAL_SHIFT "video.verticalshift"
45 #define SETTING_VIDEO_TONEMAP_METHOD "video.tonemapmethod"
46 #define SETTING_VIDEO_TONEMAP_PARAM "video.tonemapparam"
47 #define SETTING_VIDEO_ORIENTATION "video.orientation"
49 #define SETTING_VIDEO_VDPAU_NOISE "vdpau.noise"
50 #define SETTING_VIDEO_VDPAU_SHARPNESS "vdpau.sharpness"
52 #define SETTING_VIDEO_INTERLACEMETHOD "video.interlacemethod"
53 #define SETTING_VIDEO_SCALINGMETHOD "video.scalingmethod"
55 #define SETTING_VIDEO_STEREOSCOPICMODE "video.stereoscopicmode"
56 #define SETTING_VIDEO_STEREOSCOPICINVERT "video.stereoscopicinvert"
58 #define SETTING_VIDEO_MAKE_DEFAULT "video.save"
59 #define SETTING_VIDEO_CALIBRATION "video.calibration"
60 #define SETTING_VIDEO_STREAM "video.stream"
62 CGUIDialogVideoSettings::CGUIDialogVideoSettings()
63 : CGUIDialogSettingsManualBase(WINDOW_DIALOG_VIDEO_OSD_SETTINGS
, "DialogSettings.xml")
66 CGUIDialogVideoSettings::~CGUIDialogVideoSettings() = default;
68 void CGUIDialogVideoSettings::OnSettingChanged(const std::shared_ptr
<const CSetting
>& setting
)
73 CGUIDialogSettingsManualBase::OnSettingChanged(setting
);
75 auto& components
= CServiceBroker::GetAppComponents();
76 const auto appPlayer
= components
.GetComponent
<CApplicationPlayer
>();
78 const std::string
&settingId
= setting
->GetId();
79 if (settingId
== SETTING_VIDEO_INTERLACEMETHOD
)
81 CVideoSettings vs
= appPlayer
->GetVideoSettings();
82 vs
.m_InterlaceMethod
= static_cast<EINTERLACEMETHOD
>(std::static_pointer_cast
<const CSettingInt
>(setting
)->GetValue());
83 appPlayer
->SetVideoSettings(vs
);
85 else if (settingId
== SETTING_VIDEO_SCALINGMETHOD
)
87 CVideoSettings vs
= appPlayer
->GetVideoSettings();
88 vs
.m_ScalingMethod
= static_cast<ESCALINGMETHOD
>(std::static_pointer_cast
<const CSettingInt
>(setting
)->GetValue());
89 appPlayer
->SetVideoSettings(vs
);
91 else if (settingId
== SETTING_VIDEO_STREAM
)
93 m_videoStream
= std::static_pointer_cast
<const CSettingInt
>(setting
)->GetValue();
94 // only change the video stream if a different one has been asked for
95 if (appPlayer
->GetVideoStream() != m_videoStream
)
97 appPlayer
->SetVideoStream(m_videoStream
); // Set the video stream to the one selected
100 else if (settingId
== SETTING_VIDEO_VIEW_MODE
)
102 int value
= std::static_pointer_cast
<const CSettingInt
>(setting
)->GetValue();
103 const CVideoSettings vs
= appPlayer
->GetVideoSettings();
105 appPlayer
->SetRenderViewMode(value
, vs
.m_CustomZoomAmount
, vs
.m_CustomPixelRatio
,
106 vs
.m_CustomVerticalShift
, vs
.m_CustomNonLinStretch
);
108 m_viewModeChanged
= true;
109 GetSettingsManager()->SetNumber(SETTING_VIDEO_ZOOM
, static_cast<double>(vs
.m_CustomZoomAmount
));
110 GetSettingsManager()->SetNumber(SETTING_VIDEO_PIXEL_RATIO
,
111 static_cast<double>(vs
.m_CustomPixelRatio
));
112 GetSettingsManager()->SetNumber(SETTING_VIDEO_VERTICAL_SHIFT
,
113 static_cast<double>(vs
.m_CustomVerticalShift
));
114 GetSettingsManager()->SetBool(SETTING_VIDEO_NONLIN_STRETCH
, vs
.m_CustomNonLinStretch
);
115 m_viewModeChanged
= false;
117 else if (settingId
== SETTING_VIDEO_ZOOM
||
118 settingId
== SETTING_VIDEO_VERTICAL_SHIFT
||
119 settingId
== SETTING_VIDEO_PIXEL_RATIO
||
120 settingId
== SETTING_VIDEO_NONLIN_STRETCH
)
122 CVideoSettings vs
= appPlayer
->GetVideoSettings();
123 if (settingId
== SETTING_VIDEO_ZOOM
)
124 vs
.m_CustomZoomAmount
= static_cast<float>(std::static_pointer_cast
<const CSettingNumber
>(setting
)->GetValue());
125 else if (settingId
== SETTING_VIDEO_VERTICAL_SHIFT
)
126 vs
.m_CustomVerticalShift
= static_cast<float>(std::static_pointer_cast
<const CSettingNumber
>(setting
)->GetValue());
127 else if (settingId
== SETTING_VIDEO_PIXEL_RATIO
)
128 vs
.m_CustomPixelRatio
= static_cast<float>(std::static_pointer_cast
<const CSettingNumber
>(setting
)->GetValue());
129 else if (settingId
== SETTING_VIDEO_NONLIN_STRETCH
)
130 vs
.m_CustomNonLinStretch
= std::static_pointer_cast
<const CSettingBool
>(setting
)->GetValue();
132 // try changing the view mode to custom. If it already is set to custom
133 // manually call the render manager
134 if (GetSettingsManager()->GetInt(SETTING_VIDEO_VIEW_MODE
) != ViewModeCustom
)
135 GetSettingsManager()->SetInt(SETTING_VIDEO_VIEW_MODE
, ViewModeCustom
);
137 appPlayer
->SetRenderViewMode(vs
.m_ViewMode
, vs
.m_CustomZoomAmount
, vs
.m_CustomPixelRatio
,
138 vs
.m_CustomVerticalShift
, vs
.m_CustomNonLinStretch
);
140 else if (settingId
== SETTING_VIDEO_POSTPROCESS
)
142 CVideoSettings vs
= appPlayer
->GetVideoSettings();
143 vs
.m_PostProcess
= std::static_pointer_cast
<const CSettingBool
>(setting
)->GetValue();
144 appPlayer
->SetVideoSettings(vs
);
146 else if (settingId
== SETTING_VIDEO_BRIGHTNESS
)
148 CVideoSettings vs
= appPlayer
->GetVideoSettings();
149 vs
.m_Brightness
= static_cast<float>(std::static_pointer_cast
<const CSettingInt
>(setting
)->GetValue());
150 appPlayer
->SetVideoSettings(vs
);
152 else if (settingId
== SETTING_VIDEO_CONTRAST
)
154 CVideoSettings vs
= appPlayer
->GetVideoSettings();
155 vs
.m_Contrast
= static_cast<float>(std::static_pointer_cast
<const CSettingInt
>(setting
)->GetValue());
156 appPlayer
->SetVideoSettings(vs
);
158 else if (settingId
== SETTING_VIDEO_GAMMA
)
160 CVideoSettings vs
= appPlayer
->GetVideoSettings();
161 vs
.m_Gamma
= static_cast<float>(std::static_pointer_cast
<const CSettingInt
>(setting
)->GetValue());
162 appPlayer
->SetVideoSettings(vs
);
164 else if (settingId
== SETTING_VIDEO_VDPAU_NOISE
)
166 CVideoSettings vs
= appPlayer
->GetVideoSettings();
167 vs
.m_NoiseReduction
= static_cast<float>(std::static_pointer_cast
<const CSettingNumber
>(setting
)->GetValue());
168 appPlayer
->SetVideoSettings(vs
);
170 else if (settingId
== SETTING_VIDEO_VDPAU_SHARPNESS
)
172 CVideoSettings vs
= appPlayer
->GetVideoSettings();
173 vs
.m_Sharpness
= static_cast<float>(std::static_pointer_cast
<const CSettingNumber
>(setting
)->GetValue());
174 appPlayer
->SetVideoSettings(vs
);
176 else if (settingId
== SETTING_VIDEO_TONEMAP_METHOD
)
178 CVideoSettings vs
= appPlayer
->GetVideoSettings();
179 vs
.m_ToneMapMethod
= static_cast<ETONEMAPMETHOD
>(
180 std::static_pointer_cast
<const CSettingInt
>(setting
)->GetValue());
181 appPlayer
->SetVideoSettings(vs
);
183 else if (settingId
== SETTING_VIDEO_TONEMAP_PARAM
)
185 CVideoSettings vs
= appPlayer
->GetVideoSettings();
186 vs
.m_ToneMapParam
= static_cast<float>(std::static_pointer_cast
<const CSettingNumber
>(setting
)->GetValue());
187 appPlayer
->SetVideoSettings(vs
);
189 else if (settingId
== SETTING_VIDEO_ORIENTATION
)
191 CVideoSettings vs
= appPlayer
->GetVideoSettings();
192 vs
.m_Orientation
= std::static_pointer_cast
<const CSettingInt
>(setting
)->GetValue();
193 appPlayer
->SetVideoSettings(vs
);
195 else if (settingId
== SETTING_VIDEO_STEREOSCOPICMODE
)
197 CVideoSettings vs
= appPlayer
->GetVideoSettings();
198 vs
.m_StereoMode
= std::static_pointer_cast
<const CSettingInt
>(setting
)->GetValue();
199 appPlayer
->SetVideoSettings(vs
);
201 else if (settingId
== SETTING_VIDEO_STEREOSCOPICINVERT
)
203 CVideoSettings vs
= appPlayer
->GetVideoSettings();
204 vs
.m_StereoInvert
= std::static_pointer_cast
<const CSettingBool
>(setting
)->GetValue();
205 appPlayer
->SetVideoSettings(vs
);
209 void CGUIDialogVideoSettings::OnSettingAction(const std::shared_ptr
<const CSetting
>& setting
)
214 CGUIDialogSettingsManualBase::OnSettingChanged(setting
);
216 const std::string
&settingId
= setting
->GetId();
217 if (settingId
== SETTING_VIDEO_CALIBRATION
)
219 const std::shared_ptr
<CProfileManager
> profileManager
= CServiceBroker::GetSettingsComponent()->GetProfileManager();
221 auto settingsComponent
= CServiceBroker::GetSettingsComponent();
222 if (!settingsComponent
)
225 auto settings
= settingsComponent
->GetSettings();
229 auto calibsetting
= settings
->GetSetting(CSettings::SETTING_VIDEOSCREEN_GUICALIBRATION
);
232 CLog::Log(LOGERROR
, "Failed to load setting for: {}",
233 CSettings::SETTING_VIDEOSCREEN_GUICALIBRATION
);
237 // launch calibration window
238 if (profileManager
->GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE
&&
239 g_passwordManager
.CheckSettingLevelLock(calibsetting
->GetLevel()))
242 CServiceBroker::GetGUI()->GetWindowManager().ForceActivateWindow(WINDOW_SCREEN_CALIBRATION
);
245 else if (settingId
== SETTING_VIDEO_MAKE_DEFAULT
)
249 bool CGUIDialogVideoSettings::Save()
251 const std::shared_ptr
<CProfileManager
> profileManager
= CServiceBroker::GetSettingsComponent()->GetProfileManager();
253 if (profileManager
->GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE
&&
254 !g_passwordManager
.CheckSettingLevelLock(::SettingLevel::Expert
))
257 // prompt user if they are sure
258 if (CGUIDialogYesNo::ShowAndGetInput(CVariant(12376), CVariant(12377)))
259 { // reset the settings
263 db
.EraseAllVideoSettings();
266 const auto& components
= CServiceBroker::GetAppComponents();
267 const auto appPlayer
= components
.GetComponent
<CApplicationPlayer
>();
269 CMediaSettings::GetInstance().GetDefaultVideoSettings() = appPlayer
->GetVideoSettings();
270 CMediaSettings::GetInstance().GetDefaultVideoSettings().m_SubtitleStream
= -1;
271 CMediaSettings::GetInstance().GetDefaultVideoSettings().m_AudioStream
= -1;
272 CServiceBroker::GetSettingsComponent()->GetSettings()->Save();
278 void CGUIDialogVideoSettings::SetupView()
280 CGUIDialogSettingsManualBase::SetupView();
283 SET_CONTROL_HIDDEN(CONTROL_SETTINGS_OKAY_BUTTON
);
284 SET_CONTROL_HIDDEN(CONTROL_SETTINGS_CUSTOM_BUTTON
);
285 SET_CONTROL_LABEL(CONTROL_SETTINGS_CANCEL_BUTTON
, 15067);
288 void CGUIDialogVideoSettings::InitializeSettings()
290 CGUIDialogSettingsManualBase::InitializeSettings();
292 const std::shared_ptr
<CSettingCategory
> category
= AddCategory("videosettings", -1);
293 if (category
== NULL
)
295 CLog::Log(LOGERROR
, "CGUIDialogVideoSettings: unable to setup settings");
299 // get all necessary setting groups
300 const std::shared_ptr
<CSettingGroup
> groupVideoStream
= AddGroup(category
);
301 if (groupVideoStream
== NULL
)
303 CLog::Log(LOGERROR
, "CGUIDialogVideoSettings: unable to setup settings");
306 const std::shared_ptr
<CSettingGroup
> groupVideo
= AddGroup(category
);
307 if (groupVideo
== NULL
)
309 CLog::Log(LOGERROR
, "CGUIDialogVideoSettings: unable to setup settings");
312 const std::shared_ptr
<CSettingGroup
> groupStereoscopic
= AddGroup(category
);
313 if (groupStereoscopic
== NULL
)
315 CLog::Log(LOGERROR
, "CGUIDialogVideoSettings: unable to setup settings");
318 const std::shared_ptr
<CSettingGroup
> groupSaveAsDefault
= AddGroup(category
);
319 if (groupSaveAsDefault
== NULL
)
321 CLog::Log(LOGERROR
, "CGUIDialogVideoSettings: unable to setup settings");
325 bool usePopup
= g_SkinInfo
->HasSkinFile("DialogSlider.xml");
327 const auto& components
= CServiceBroker::GetAppComponents();
328 const auto appPlayer
= components
.GetComponent
<CApplicationPlayer
>();
330 const CVideoSettings videoSettings
= appPlayer
->GetVideoSettings();
332 TranslatableIntegerSettingOptions entries
;
335 entries
.emplace_back(16039, VS_INTERLACEMETHOD_NONE
);
336 entries
.emplace_back(16019, VS_INTERLACEMETHOD_AUTO
);
337 entries
.emplace_back(20131, VS_INTERLACEMETHOD_RENDER_BLEND
);
338 entries
.emplace_back(20129, VS_INTERLACEMETHOD_RENDER_WEAVE
);
339 entries
.emplace_back(16021, VS_INTERLACEMETHOD_RENDER_BOB
);
340 entries
.emplace_back(16020, VS_INTERLACEMETHOD_DEINTERLACE
);
341 entries
.emplace_back(16036, VS_INTERLACEMETHOD_DEINTERLACE_HALF
);
342 entries
.emplace_back(16311, VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL
);
343 entries
.emplace_back(16310, VS_INTERLACEMETHOD_VDPAU_TEMPORAL
);
344 entries
.emplace_back(16325, VS_INTERLACEMETHOD_VDPAU_BOB
);
345 entries
.emplace_back(16318, VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF
);
346 entries
.emplace_back(16317, VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF
);
347 entries
.emplace_back(16327, VS_INTERLACEMETHOD_VAAPI_BOB
);
348 entries
.emplace_back(16328, VS_INTERLACEMETHOD_VAAPI_MADI
);
349 entries
.emplace_back(16329, VS_INTERLACEMETHOD_VAAPI_MACI
);
350 entries
.emplace_back(16320, VS_INTERLACEMETHOD_DXVA_AUTO
);
352 /* remove unsupported methods */
353 for (TranslatableIntegerSettingOptions::iterator it
= entries
.begin(); it
!= entries
.end(); )
355 if (appPlayer
->Supports(static_cast<EINTERLACEMETHOD
>(it
->value
)))
358 it
= entries
.erase(it
);
361 if (!entries
.empty())
363 EINTERLACEMETHOD method
= videoSettings
.m_InterlaceMethod
;
364 if (!appPlayer
->Supports(method
))
366 method
= appPlayer
->GetDeinterlacingMethodDefault();
368 AddSpinner(groupVideo
, SETTING_VIDEO_INTERLACEMETHOD
, 16038, SettingLevel::Basic
, static_cast<int>(method
), entries
);
372 entries
.emplace_back(16301, VS_SCALINGMETHOD_NEAREST
);
373 entries
.emplace_back(16302, VS_SCALINGMETHOD_LINEAR
);
374 entries
.emplace_back(16303, VS_SCALINGMETHOD_CUBIC_B_SPLINE
);
375 entries
.emplace_back(16314, VS_SCALINGMETHOD_CUBIC_MITCHELL
);
376 entries
.emplace_back(16321, VS_SCALINGMETHOD_CUBIC_CATMULL
);
377 entries
.emplace_back(16326, VS_SCALINGMETHOD_CUBIC_0_075
);
378 entries
.emplace_back(16330, VS_SCALINGMETHOD_CUBIC_0_1
);
379 entries
.emplace_back(16304, VS_SCALINGMETHOD_LANCZOS2
);
380 entries
.emplace_back(16323, VS_SCALINGMETHOD_SPLINE36_FAST
);
381 entries
.emplace_back(16315, VS_SCALINGMETHOD_LANCZOS3_FAST
);
382 entries
.emplace_back(16322, VS_SCALINGMETHOD_SPLINE36
);
383 entries
.emplace_back(16305, VS_SCALINGMETHOD_LANCZOS3
);
384 entries
.emplace_back(16306, VS_SCALINGMETHOD_SINC8
);
385 entries
.emplace_back(16307, VS_SCALINGMETHOD_BICUBIC_SOFTWARE
);
386 entries
.emplace_back(16308, VS_SCALINGMETHOD_LANCZOS_SOFTWARE
);
387 entries
.emplace_back(16309, VS_SCALINGMETHOD_SINC_SOFTWARE
);
388 entries
.emplace_back(13120, VS_SCALINGMETHOD_VDPAU_HARDWARE
);
389 entries
.emplace_back(16319, VS_SCALINGMETHOD_DXVA_HARDWARE
);
390 entries
.emplace_back(16316, VS_SCALINGMETHOD_AUTO
);
392 /* remove unsupported methods */
393 for(TranslatableIntegerSettingOptions::iterator it
= entries
.begin(); it
!= entries
.end(); )
395 if (appPlayer
->Supports(static_cast<ESCALINGMETHOD
>(it
->value
)))
398 it
= entries
.erase(it
);
401 AddSpinner(groupVideo
, SETTING_VIDEO_SCALINGMETHOD
, 16300, SettingLevel::Basic
, static_cast<int>(videoSettings
.m_ScalingMethod
), entries
);
403 AddVideoStreams(groupVideoStream
, SETTING_VIDEO_STREAM
);
405 if (appPlayer
->Supports(RENDERFEATURE_STRETCH
) || appPlayer
->Supports(RENDERFEATURE_PIXEL_RATIO
))
407 AddList(groupVideo
, SETTING_VIDEO_VIEW_MODE
, 629, SettingLevel::Basic
, videoSettings
.m_ViewMode
, CViewModeSettings::ViewModesFiller
, 629);
409 if (appPlayer
->Supports(RENDERFEATURE_ZOOM
))
410 AddSlider(groupVideo
, SETTING_VIDEO_ZOOM
, 216, SettingLevel::Basic
,
411 videoSettings
.m_CustomZoomAmount
, "{:2.2f}", 0.5f
, 0.01f
, 2.0f
, 216, usePopup
);
412 if (appPlayer
->Supports(RENDERFEATURE_VERTICAL_SHIFT
))
413 AddSlider(groupVideo
, SETTING_VIDEO_VERTICAL_SHIFT
, 225, SettingLevel::Basic
,
414 videoSettings
.m_CustomVerticalShift
, "{:2.2f}", -2.0f
, 0.01f
, 2.0f
, 225, usePopup
);
415 if (appPlayer
->Supports(RENDERFEATURE_PIXEL_RATIO
))
416 AddSlider(groupVideo
, SETTING_VIDEO_PIXEL_RATIO
, 217, SettingLevel::Basic
,
417 videoSettings
.m_CustomPixelRatio
, "{:2.2f}", 0.5f
, 0.01f
, 2.0f
, 217, usePopup
);
419 AddList(groupVideo
, SETTING_VIDEO_ORIENTATION
, 21843, SettingLevel::Basic
, videoSettings
.m_Orientation
, CGUIDialogVideoSettings::VideoOrientationFiller
, 21843);
421 if (appPlayer
->Supports(RENDERFEATURE_POSTPROCESS
))
422 AddToggle(groupVideo
, SETTING_VIDEO_POSTPROCESS
, 16400, SettingLevel::Basic
, videoSettings
.m_PostProcess
);
423 if (appPlayer
->Supports(RENDERFEATURE_BRIGHTNESS
))
424 AddPercentageSlider(groupVideo
, SETTING_VIDEO_BRIGHTNESS
, 464, SettingLevel::Basic
, static_cast<int>(videoSettings
.m_Brightness
), 14047, 1, 464, usePopup
);
425 if (appPlayer
->Supports(RENDERFEATURE_CONTRAST
))
426 AddPercentageSlider(groupVideo
, SETTING_VIDEO_CONTRAST
, 465, SettingLevel::Basic
, static_cast<int>(videoSettings
.m_Contrast
), 14047, 1, 465, usePopup
);
427 if (appPlayer
->Supports(RENDERFEATURE_GAMMA
))
428 AddPercentageSlider(groupVideo
, SETTING_VIDEO_GAMMA
, 466, SettingLevel::Basic
, static_cast<int>(videoSettings
.m_Gamma
), 14047, 1, 466, usePopup
);
429 if (appPlayer
->Supports(RENDERFEATURE_NOISE
))
430 AddSlider(groupVideo
, SETTING_VIDEO_VDPAU_NOISE
, 16312, SettingLevel::Basic
,
431 videoSettings
.m_NoiseReduction
, "{:2.2f}", 0.0f
, 0.01f
, 1.0f
, 16312, usePopup
);
432 if (appPlayer
->Supports(RENDERFEATURE_SHARPNESS
))
433 AddSlider(groupVideo
, SETTING_VIDEO_VDPAU_SHARPNESS
, 16313, SettingLevel::Basic
,
434 videoSettings
.m_Sharpness
, "{:2.2f}", -1.0f
, 0.02f
, 1.0f
, 16313, usePopup
);
435 if (appPlayer
->Supports(RENDERFEATURE_NONLINSTRETCH
))
436 AddToggle(groupVideo
, SETTING_VIDEO_NONLIN_STRETCH
, 659, SettingLevel::Basic
, videoSettings
.m_CustomNonLinStretch
);
439 if (appPlayer
->Supports(RENDERFEATURE_TONEMAP
))
441 const bool visible
= !CServiceBroker::GetWinSystem()->IsHDRDisplaySettingEnabled();
443 entries
.emplace_back(36554, VS_TONEMAPMETHOD_OFF
);
444 entries
.emplace_back(36555, VS_TONEMAPMETHOD_REINHARD
);
445 entries
.emplace_back(36557, VS_TONEMAPMETHOD_ACES
);
446 entries
.emplace_back(36558, VS_TONEMAPMETHOD_HABLE
);
448 AddSpinner(groupVideo
, SETTING_VIDEO_TONEMAP_METHOD
, 36553, SettingLevel::Basic
,
449 videoSettings
.m_ToneMapMethod
, entries
, false, visible
);
450 AddSlider(groupVideo
, SETTING_VIDEO_TONEMAP_PARAM
, 36556, SettingLevel::Basic
,
451 videoSettings
.m_ToneMapParam
, "{:2.2f}", 0.1f
, 0.1f
, 5.0f
, 36556, usePopup
, false,
455 // stereoscopic settings
457 entries
.emplace_back(16316, RENDER_STEREO_MODE_OFF
);
458 entries
.emplace_back(36503, RENDER_STEREO_MODE_SPLIT_HORIZONTAL
);
459 entries
.emplace_back(36504, RENDER_STEREO_MODE_SPLIT_VERTICAL
);
460 AddSpinner(groupStereoscopic
, SETTING_VIDEO_STEREOSCOPICMODE
, 36535, SettingLevel::Basic
, videoSettings
.m_StereoMode
, entries
);
461 AddToggle(groupStereoscopic
, SETTING_VIDEO_STEREOSCOPICINVERT
, 36536, SettingLevel::Basic
, videoSettings
.m_StereoInvert
);
464 AddButton(groupSaveAsDefault
, SETTING_VIDEO_MAKE_DEFAULT
, 12376, SettingLevel::Basic
);
465 AddButton(groupSaveAsDefault
, SETTING_VIDEO_CALIBRATION
, 214, SettingLevel::Basic
);
468 void CGUIDialogVideoSettings::AddVideoStreams(const std::shared_ptr
<CSettingGroup
>& group
,
469 const std::string
& settingId
)
471 if (group
== NULL
|| settingId
.empty())
474 auto& components
= CServiceBroker::GetAppComponents();
475 const auto appPlayer
= components
.GetComponent
<CApplicationPlayer
>();
477 m_videoStream
= appPlayer
->GetVideoStream();
478 if (m_videoStream
< 0)
481 AddList(group
, settingId
, 38031, SettingLevel::Basic
, m_videoStream
, VideoStreamsOptionFiller
, 38031);
484 void CGUIDialogVideoSettings::VideoStreamsOptionFiller(
485 const std::shared_ptr
<const CSetting
>& setting
,
486 std::vector
<IntegerSettingOption
>& list
,
490 const auto& components
= CServiceBroker::GetAppComponents();
491 const auto appPlayer
= components
.GetComponent
<CApplicationPlayer
>();
493 int videoStreamCount
= appPlayer
->GetVideoStreamCount();
494 // cycle through each video stream and add it to our list control
495 for (int i
= 0; i
< videoStreamCount
; ++i
)
498 std::string strLanguage
;
500 VideoStreamInfo info
;
501 appPlayer
->GetVideoStreamInfo(i
, info
);
503 g_LangCodeExpander
.Lookup(info
.language
, strLanguage
);
505 if (!info
.name
.empty())
507 if (!strLanguage
.empty())
508 strItem
= StringUtils::Format("{} - {}", strLanguage
, info
.name
);
512 else if (!strLanguage
.empty())
514 strItem
= strLanguage
;
517 if (info
.codecName
.empty())
518 strItem
+= StringUtils::Format(" ({}x{}", info
.width
, info
.height
);
520 strItem
+= StringUtils::Format(" ({}, {}x{}", info
.codecName
, info
.width
, info
.height
);
523 strItem
+= StringUtils::Format(", {} bps)", info
.bitrate
);
527 strItem
+= FormatFlags(info
.flags
);
528 strItem
+= StringUtils::Format(" ({}/{})", i
+ 1, videoStreamCount
);
529 list
.emplace_back(strItem
, i
);
534 list
.emplace_back(g_localizeStrings
.Get(231), -1);
539 void CGUIDialogVideoSettings::VideoOrientationFiller(const std::shared_ptr
<const CSetting
>& setting
,
540 std::vector
<IntegerSettingOption
>& list
,
544 list
.emplace_back(g_localizeStrings
.Get(687), 0);
545 list
.emplace_back(g_localizeStrings
.Get(35229), 90);
546 list
.emplace_back(g_localizeStrings
.Get(35230), 180);
547 list
.emplace_back(g_localizeStrings
.Get(35231), 270);
550 std::string
CGUIDialogVideoSettings::FormatFlags(StreamFlags flags
)
552 std::vector
<std::string
> localizedFlags
;
553 if (flags
& StreamFlags::FLAG_DEFAULT
)
554 localizedFlags
.emplace_back(g_localizeStrings
.Get(39105));
555 if (flags
& StreamFlags::FLAG_FORCED
)
556 localizedFlags
.emplace_back(g_localizeStrings
.Get(39106));
557 if (flags
& StreamFlags::FLAG_HEARING_IMPAIRED
)
558 localizedFlags
.emplace_back(g_localizeStrings
.Get(39107));
559 if (flags
& StreamFlags::FLAG_VISUAL_IMPAIRED
)
560 localizedFlags
.emplace_back(g_localizeStrings
.Get(39108));
562 std::string formated
= StringUtils::Join(localizedFlags
, ", ");
564 if (!formated
.empty())
565 formated
= StringUtils::Format(" [{}]", formated
);