diff options
33 files changed, 611 insertions, 286 deletions
diff --git a/cmake/scripts/android/Install.cmake b/cmake/scripts/android/Install.cmake index 5b7b411fe3..1dc33af71f 100644 --- a/cmake/scripts/android/Install.cmake +++ b/cmake/scripts/android/Install.cmake @@ -70,6 +70,7 @@ set(package_files strings.xml src/XBMCProperties.java src/XBMCVideoView.java src/XBMCFile.java + src/XBMCURIUtils.java src/channels/SyncChannelJobService.java src/channels/SyncProgramsJobService.java src/channels/model/XBMCDatabase.java diff --git a/tools/android/packaging/xbmc/src/XBMCURIUtils.java.in b/tools/android/packaging/xbmc/src/XBMCURIUtils.java.in new file mode 100644 index 0000000000..915af91602 --- /dev/null +++ b/tools/android/packaging/xbmc/src/XBMCURIUtils.java.in @@ -0,0 +1,29 @@ +package @APP_PACKAGE@; + +import android.util.Log; + +public class XBMCURIUtils +{ + native String _substitutePath(String path); + + private static String TAG = "@APP_NAME@uriutils"; + + public XBMCURIUtils() + { + } + + public String substitutePath(String path) + { + try + { + return _substitutePath(path); + } + catch (Exception e) + { + e.printStackTrace(); + Log.e(TAG, "substitutePath: Exception"); + return null; + } + } + +} diff --git a/tools/android/packaging/xbmc/src/channels/SyncChannelJobService.java.in b/tools/android/packaging/xbmc/src/channels/SyncChannelJobService.java.in index 76a9c7437c..4a6ce76da2 100644 --- a/tools/android/packaging/xbmc/src/channels/SyncChannelJobService.java.in +++ b/tools/android/packaging/xbmc/src/channels/SyncChannelJobService.java.in @@ -29,6 +29,7 @@ import androidx.tvprovider.media.tv.TvContractCompat; import @APP_PACKAGE@.R; import @APP_PACKAGE@.XBMCJsonRPC; +import @APP_PACKAGE@.XBMCURIUtils; import @APP_PACKAGE@.channels.model.Subscription; import @APP_PACKAGE@.channels.model.XBMCDatabase; import @APP_PACKAGE@.channels.util.TvUtil; @@ -85,52 +86,14 @@ public class SyncChannelJobService extends JobService this.mContext = context; } - @Override - protected Boolean doInBackground(Void... voids) + List<File> getFilesFromUrl(String url) { - XBMCJsonRPC json = new XBMCJsonRPC(); - if (!json.Ping()) - return false; - json = null; + List<File> list = new ArrayList<>(); - List<Subscription> subscriptions = XBMCDatabase.getSubscriptions(mContext); - List<Subscription> freshsubscriptions = new ArrayList<>(); - List<File> playlistsContent = new ArrayList<>(); - - try (Cursor cursor = - mContext.getContentResolver() - .query( - XBMCFileContentProvider.buildUri("special://profile/playlists/video/"), - null, - null, - null, - null)) - { - if (cursor != null) - { - while (cursor.moveToNext()) - playlistsContent.add(File.fromCursor(cursor)); - } - } - try (Cursor cursor = - mContext.getContentResolver() - .query( - XBMCFileContentProvider.buildUri("special://profile/playlists/mixed/"), - null, - null, - null, - null)) - { - if (cursor != null) - { - while (cursor.moveToNext()) - playlistsContent.add(File.fromCursor(cursor)); - } - } try (Cursor cursor = mContext.getContentResolver() .query( - XBMCFileContentProvider.buildUri("special://profile/playlists/music/"), + XBMCFileContentProvider.buildUri(url), null, null, null, @@ -139,9 +102,28 @@ public class SyncChannelJobService extends JobService if (cursor != null) { while (cursor.moveToNext()) - playlistsContent.add(File.fromCursor(cursor)); + list.add(File.fromCursor(cursor)); } } + return list; + } + + @Override + protected Boolean doInBackground(Void... voids) + { + XBMCJsonRPC json = new XBMCJsonRPC(); + if (!json.Ping()) + return false; + json = null; + + List<Subscription> subscriptions = XBMCDatabase.getSubscriptions(mContext); + List<Subscription> freshsubscriptions = new ArrayList<>(); + List<File> playlistsContent = new ArrayList<>(); + XBMCURIUtils uriutils = new XBMCURIUtils(); + + playlistsContent.addAll(getFilesFromUrl(uriutils.substitutePath("special://profile/playlists/video/"))); + playlistsContent.addAll(getFilesFromUrl(uriutils.substitutePath("special://profile/playlists/mixed/"))); + playlistsContent.addAll(getFilesFromUrl(uriutils.substitutePath("special://profile/playlists/music/"))); Subscription sub = Subscription.createSubscription(mContext.getString(R.string.suggestion_channel), "", R.drawable.ic_recommendation_80dp); freshsubscriptions.add(sub); diff --git a/tools/depends/target/config.site.in b/tools/depends/target/config.site.in index 142624fcaa..bb8a591bcd 100644 --- a/tools/depends/target/config.site.in +++ b/tools/depends/target/config.site.in @@ -70,6 +70,14 @@ ac_cv_file__dev_ptc=no #gnutls gl_cv_func_gettimeofday_clobber=no +#wayland +if test "${PACKAGE_NAME}" = "wayland"; then + # wayland insists on building tests which rely on assert, which cannot work with -DNDEBUG + # Maybe it would be better not to define -DNDEBUG globally for release builds? + export CFLAGS=`echo ${CFLAGS} | sed 's/-DNDEBUG=1//g'` + export CPPFLAGS=`echo ${CPPFLAGS} | sed 's/-DNDEBUG=1//g'` +fi + if test "@platform_os@" = "android"; then ac_cv_func_srand=yes diff --git a/tools/depends/target/darwin-embedded-entitlements/darwin_embedded_entitlements.xml b/tools/depends/target/darwin-embedded-entitlements/darwin_embedded_entitlements.xml index 9b60556849..4c7fc926f8 100644 --- a/tools/depends/target/darwin-embedded-entitlements/darwin_embedded_entitlements.xml +++ b/tools/depends/target/darwin-embedded-entitlements/darwin_embedded_entitlements.xml @@ -30,9 +30,32 @@ </array> <key>com.apple.security.iokit-user-client-class</key> <array> + <string>AGXCommandQueue</string> + <string>AGXDevice</string> <string>AGXDeviceUserClient</string> + <string>AGXGLContext</string> + <string>AGXSharedUserClient</string> + <string>AppleCredentialManagerUserClient</string> + <string>AppleHPMUserClient</string> + <string>AppleJPEGDriverUserClient</string> + <string>AppleUSBHostDeviceUserClient</string> + <string>H11ANEInDirectPathClient</string> + <string>IOAVControllerConcreteUserClient</string> + <string>IOAccelContext</string> + <string>IOAccelContext2</string> + <string>IOAccelDevice</string> + <string>IOAccelDevice2</string> + <string>IOAccelSharedUserClient</string> + <string>IOAccelSharedUserClient2</string> + <string>IOAccelSubmitter2</string> <string>IOHDIXControllerUserClient</string> + <string>IOHIDEventServiceFastPathUserClient</string> + <string>IOHIDLibUserClient</string> + <string>IOMobileFramebufferUserClient</string> + <string>IOReportUserClient</string> + <string>IOSurfaceAcceleratorClient</string> <string>IOSurfaceRootUserClient</string> + <string>RootDomainUserClient</string> </array> </dict> </plist> diff --git a/version.txt b/version.txt index bc76b7c8cf..636c446a5c 100644 --- a/version.txt +++ b/version.txt @@ -4,9 +4,9 @@ COPYRIGHT_YEARS 2005-2020 WEBSITE http://kodi.tv VERSION_MAJOR 19 VERSION_MINOR 0 -VERSION_TAG BETA1 -VERSION_CODE 18.9.801 -ADDON_API 18.9.801 +VERSION_TAG BETA2 +VERSION_CODE 18.9.821 +ADDON_API 18.9.821 ADDON_REPOS repository.xbmc.org|https://mirrors.kodi.tv APP_PACKAGE org.xbmc.kodi PACKAGE_IDENTITY XBMCFoundation.Kodi diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index 629bfb713f..672fe6ba92 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -796,7 +796,14 @@ bool CApplication::Initialize() CServiceBroker::GetRenderSystem()->ShowSplash(""); m_confirmSkinChange = true; - std::string defaultSkin = std::static_pointer_cast<const CSettingString>(settings->GetSetting(CSettings::SETTING_LOOKANDFEEL_SKIN))->GetDefault(); + auto setting = settings->GetSetting(CSettings::SETTING_LOOKANDFEEL_SKIN); + if (!setting) + { + CLog::Log(LOGFATAL, "Failed to load setting for: {}", CSettings::SETTING_LOOKANDFEEL_SKIN); + return false; + } + + std::string defaultSkin = std::static_pointer_cast<const CSettingString>(setting)->GetDefault(); if (!LoadSkin(settings->GetString(CSettings::SETTING_LOOKANDFEEL_SKIN))) { CLog::Log(LOGERROR, "Failed to load skin '%s'", settings->GetString(CSettings::SETTING_LOOKANDFEEL_SKIN).c_str()); @@ -1164,11 +1171,18 @@ void CApplication::ReloadSkin(bool confirm/*=false*/) else { // skin failed to load - we revert to the default only if we didn't fail loading the default - std::string defaultSkin = std::static_pointer_cast<CSettingString>(settings->GetSetting(CSettings::SETTING_LOOKANDFEEL_SKIN))->GetDefault(); + auto setting = settings->GetSetting(CSettings::SETTING_LOOKANDFEEL_SKIN); + if (!setting) + { + CLog::Log(LOGFATAL, "Failed to load setting for: {}", CSettings::SETTING_LOOKANDFEEL_SKIN); + return; + } + + std::string defaultSkin = std::static_pointer_cast<CSettingString>(setting)->GetDefault(); if (newSkin != defaultSkin) { m_confirmSkinChange = false; - settings->GetSetting(CSettings::SETTING_LOOKANDFEEL_SKIN)->Reset(); + setting->Reset(); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(24102), g_localizeStrings.Get(24103)); } } diff --git a/xbmc/LangInfo.cpp b/xbmc/LangInfo.cpp index d8b3dc643e..738f7e11ea 100644 --- a/xbmc/LangInfo.cpp +++ b/xbmc/LangInfo.cpp @@ -319,6 +319,14 @@ void CLangInfo::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) if (setting == NULL) return; + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return; + const std::string &settingId = setting->GetId(); if (settingId == CSettings::SETTING_LOCALE_AUDIOLANGUAGE) SetAudioLanguage(std::static_pointer_cast<const CSettingString>(setting)->GetValue()); @@ -327,7 +335,16 @@ void CLangInfo::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) else if (settingId == CSettings::SETTING_LOCALE_LANGUAGE) { if (!SetLanguage(std::static_pointer_cast<const CSettingString>(setting)->GetValue())) - std::static_pointer_cast<CSettingString>(CServiceBroker::GetSettingsComponent()->GetSettings()->GetSetting(CSettings::SETTING_LOCALE_LANGUAGE))->Reset(); + { + auto setting = settings->GetSetting(CSettings::SETTING_LOCALE_LANGUAGE); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", CSettings::SETTING_LOCALE_LANGUAGE); + return; + } + + std::static_pointer_cast<CSettingString>(setting)->Reset(); + } } else if (settingId == CSettings::SETTING_LOCALE_COUNTRY) SetCurrentRegion(std::static_pointer_cast<const CSettingString>(setting)->GetValue()); @@ -342,7 +359,8 @@ void CLangInfo::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) Set24HourClock(std::static_pointer_cast<const CSettingString>(setting)->GetValue()); // update the time format - CServiceBroker::GetSettingsComponent()->GetSettings()->SetString(CSettings::SETTING_LOCALE_TIMEFORMAT, PrepareTimeFormat(GetTimeFormat(), m_use24HourClock)); + settings->SetString(CSettings::SETTING_LOCALE_TIMEFORMAT, + PrepareTimeFormat(GetTimeFormat(), m_use24HourClock)); } else if (settingId == CSettings::SETTING_LOCALE_TEMPERATUREUNIT) SetTemperatureUnit(std::static_pointer_cast<const CSettingString>(setting)->GetValue()); diff --git a/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.cpp b/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.cpp index 25da2de9e9..b85097d37b 100644 --- a/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.cpp @@ -19,34 +19,34 @@ extern "C" namespace DRMPRIME { -int GetColorEncoding(const VideoPicture& picture) +std::string GetColorEncoding(const VideoPicture& picture) { switch (picture.color_space) { case AVCOL_SPC_BT2020_CL: case AVCOL_SPC_BT2020_NCL: - return DRM_COLOR_YCBCR_BT2020; + return "ITU-R BT.2020 YCbCr"; case AVCOL_SPC_SMPTE170M: case AVCOL_SPC_BT470BG: case AVCOL_SPC_FCC: - return DRM_COLOR_YCBCR_BT601; + return "ITU-R BT.601 YCbCr"; case AVCOL_SPC_BT709: - return DRM_COLOR_YCBCR_BT709; + return "ITU-R BT.709 YCbCr"; case AVCOL_SPC_RESERVED: case AVCOL_SPC_UNSPECIFIED: default: if (picture.iWidth > 1024 || picture.iHeight >= 600) - return DRM_COLOR_YCBCR_BT709; + return "ITU-R BT.709 YCbCr"; else - return DRM_COLOR_YCBCR_BT601; + return "ITU-R BT.601 YCbCr"; } } -int GetColorRange(const VideoPicture& picture) +std::string GetColorRange(const VideoPicture& picture) { if (picture.color_range) - return DRM_COLOR_YCBCR_FULL_RANGE; - return DRM_COLOR_YCBCR_LIMITED_RANGE; + return "YCbCr full range"; + return "YCbCr limited range"; } uint8_t GetEOTF(const VideoPicture& picture) diff --git a/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h b/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h index 822c00fd20..ebced6f5ef 100644 --- a/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h +++ b/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h @@ -21,19 +21,6 @@ extern "C" namespace DRMPRIME { -// Color enums is copied from linux include/drm/drm_color_mgmt.h (strangely not part of uapi) -enum drm_color_encoding -{ - DRM_COLOR_YCBCR_BT601, - DRM_COLOR_YCBCR_BT709, - DRM_COLOR_YCBCR_BT2020, -}; -enum drm_color_range -{ - DRM_COLOR_YCBCR_LIMITED_RANGE, - DRM_COLOR_YCBCR_FULL_RANGE, -}; - // HDR enums is copied from linux include/linux/hdmi.h (strangely not part of uapi) enum hdmi_metadata_type { @@ -47,8 +34,8 @@ enum hdmi_eotf HDMI_EOTF_BT_2100_HLG, }; -int GetColorEncoding(const VideoPicture& picture); -int GetColorRange(const VideoPicture& picture); +std::string GetColorEncoding(const VideoPicture& picture); +std::string GetColorRange(const VideoPicture& picture); uint8_t GetEOTF(const VideoPicture& picture); const AVMasteringDisplayMetadata* GetMasteringDisplayMetadata(const VideoPicture& picture); const AVContentLightMetadata* GetContentLightMetadata(const VideoPicture& picture); diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecSSA.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecSSA.cpp index d75737e097..517a5d2ac6 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecSSA.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecSSA.cpp @@ -61,7 +61,15 @@ int CDVDOverlayCodecSSA::Decode(DemuxPacket *pPacket) double pts = pPacket->dts != DVD_NOPTS_VALUE ? pPacket->dts : pPacket->pts; if (pts == DVD_NOPTS_VALUE) + { pts = 0; + } + else + { + // libass only has a precision of msec + pts = round(pts / 1000) * 1000; + } + uint8_t *data = pPacket->pData; int size = pPacket->iSize; double duration = pPacket->duration; diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp index 3937e25aed..8024c20816 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp @@ -96,10 +96,32 @@ CDVDVideoCodec* CDVDVideoCodecDRMPRIME::Create(CProcessInfo& processInfo) void CDVDVideoCodecDRMPRIME::Register() { - auto settings = CServiceBroker::GetSettingsComponent()->GetSettings(); + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return; + + auto setting = settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEPRIMEDECODER); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", + CSettings::SETTING_VIDEOPLAYER_USEPRIMEDECODER); + return; + } + + setting->SetVisible(true); + + setting = settings->GetSetting(SETTING_VIDEOPLAYER_USEPRIMEDECODERFORHW); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", SETTING_VIDEOPLAYER_USEPRIMEDECODERFORHW); + return; + } - settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEPRIMEDECODER)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEPRIMEDECODERFORHW)->SetVisible(true); + setting->SetVisible(true); CDVDFactoryCodec::RegisterHWVideoCodec("drm_prime", CDVDVideoCodecDRMPRIME::Create); } diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp index 3ad67df4e2..6d254e3063 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp @@ -51,14 +51,14 @@ extern "C" { using namespace VAAPI; #define NUM_RENDER_PICS 7 -const std::string SETTING_VIDEOPLAYER_USEVAAPI = "videoplayer.usevaapi"; -const std::string SETTING_VIDEOPLAYER_USEVAAPIHEVC = "videoplayer.usevaapihevc"; -const std::string SETTING_VIDEOPLAYER_USEVAAPIMPEG2 = "videoplayer.usevaapimpeg2"; -const std::string SETTING_VIDEOPLAYER_USEVAAPIMPEG4 = "videoplayer.usevaapimpeg4"; -const std::string SETTING_VIDEOPLAYER_USEVAAPIVC1 = "videoplayer.usevaapivc1"; -const std::string SETTING_VIDEOPLAYER_USEVAAPIVP8 = "videoplayer.usevaapivp8"; -const std::string SETTING_VIDEOPLAYER_USEVAAPIVP9 = "videoplayer.usevaapivp9"; -const std::string SETTING_VIDEOPLAYER_PREFERVAAPIRENDER = "videoplayer.prefervaapirender"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPI = "videoplayer.usevaapi"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPIHEVC = "videoplayer.usevaapihevc"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPIMPEG2 = "videoplayer.usevaapimpeg2"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPIMPEG4 = "videoplayer.usevaapimpeg4"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPIVC1 = "videoplayer.usevaapivc1"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPIVP8 = "videoplayer.usevaapivp8"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPIVP9 = "videoplayer.usevaapivp9"; +constexpr auto SETTING_VIDEOPLAYER_PREFERVAAPIRENDER = "videoplayer.prefervaapirender"; void VAAPI::VaErrorCallback(void *user_context, const char *message) { @@ -543,8 +543,22 @@ bool CDecoder::Open(AVCodecContext* avctx, AVCodecContext* mainctx, const enum A auto entry = settings_map.find(avctx->codec_id); if (entry != settings_map.end()) { - const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings(); - bool enabled = settings->GetBool(entry->second) && settings->GetSetting(entry->second)->IsVisible(); + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return false; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return false; + + auto setting = settings->GetSetting(entry->second); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", entry->second); + return false; + } + + bool enabled = setting->IsEnabled() && setting->IsVisible(); if (!enabled) return false; } @@ -1229,14 +1243,31 @@ void CDecoder::Register(IVaapiWinSystem *winSystem, bool deepColor) CDVDFactoryCodec::RegisterHWAccel("vaapi", CDecoder::Create); config.context->Release(nullptr); - const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings(); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPI)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPIMPEG4)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPIVC1)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPIMPEG2)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPIVP8)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPIVP9)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPIHEVC)->SetVisible(true); + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return; + + constexpr std::array<const char*, 8> vaapiSettings = { + SETTING_VIDEOPLAYER_USEVAAPI, SETTING_VIDEOPLAYER_USEVAAPIMPEG4, + SETTING_VIDEOPLAYER_USEVAAPIVC1, SETTING_VIDEOPLAYER_USEVAAPIMPEG2, + SETTING_VIDEOPLAYER_USEVAAPIVP8, SETTING_VIDEOPLAYER_USEVAAPIVP9, + SETTING_VIDEOPLAYER_USEVAAPIHEVC, SETTING_VIDEOPLAYER_PREFERVAAPIRENDER}; + + for (const auto vaapiSetting : vaapiSettings) + { + auto setting = settings->GetSetting(vaapiSetting); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", vaapiSetting); + continue; + } + + setting->SetVisible(true); + } } //----------------------------------------------------------------------------- diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp index 66a6358491..53a3da2f61 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp @@ -516,11 +516,26 @@ bool CDecoder::Open(AVCodecContext* avctx, AVCodecContext* mainctx, const enum A { AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1 }, { AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG2 }, }; + + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return false; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return false; + auto entry = settings_map.find(avctx->codec_id); if (entry != settings_map.end()) { - const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings(); - bool enabled = settings->GetBool(entry->second) && settings->GetSetting(entry->second)->IsVisible(); + auto setting = settings->GetSetting(entry->second); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", entry->second); + return false; + } + + bool enabled = setting->IsEnabled() && setting->IsVisible(); if (!enabled) return false; } @@ -1327,17 +1342,38 @@ void CDecoder::Register() std::transform(gpuvendor.begin(), gpuvendor.end(), gpuvendor.begin(), ::tolower); bool isNvidia = (gpuvendor.compare(0, 6, "nvidia") == 0); - const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings(); - settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVDPAU)->SetVisible(true); + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return; + + auto setting = settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVDPAU); + if (!setting) + CLog::Log(LOGERROR, "Failed to load setting for: {}", CSettings::SETTING_VIDEOPLAYER_USEVDPAU); + else + setting->SetVisible(true); if (!isNvidia) { - settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4)->SetVisible(true); - settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1)->SetVisible(true); - settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG2)->SetVisible(true); - settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVDPAUMIXER)->SetVisible(true); - } + constexpr std::array<const char*, 4> vdpauSettings = { + CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1, + CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG2, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMIXER}; + + for (const auto& vdpauSetting : vdpauSettings) + { + setting = settings->GetSetting(vdpauSetting); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", vdpauSetting); + continue; + } + setting->SetVisible(true); + } + } } //----------------------------------------------------------------------------- diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp index d60adf4889..dfc34dd6be 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp @@ -12,6 +12,42 @@ using namespace DRMPRIME; +namespace +{ + +int GetEGLColorSpace(const VideoPicture& picture) +{ + switch (picture.color_space) + { + case AVCOL_SPC_BT2020_CL: + case AVCOL_SPC_BT2020_NCL: + return EGL_ITU_REC2020_EXT; + case AVCOL_SPC_SMPTE170M: + case AVCOL_SPC_BT470BG: + case AVCOL_SPC_FCC: + return EGL_ITU_REC601_EXT; + case AVCOL_SPC_BT709: + return EGL_ITU_REC709_EXT; + case AVCOL_SPC_RESERVED: + case AVCOL_SPC_UNSPECIFIED: + default: + if (picture.iWidth > 1024 || picture.iHeight >= 600) + return EGL_ITU_REC709_EXT; + else + return EGL_ITU_REC601_EXT; + } +} + +int GetEGLColorRange(const VideoPicture& picture) +{ + if (picture.color_range) + return EGL_YUV_FULL_RANGE_EXT; + + return EGL_YUV_NARROW_RANGE_EXT; +} + +} // namespace + CDRMPRIMETexture::~CDRMPRIMETexture() { glDeleteTextures(1, &m_texture); @@ -55,8 +91,8 @@ bool CDRMPRIMETexture::Map(CVideoBufferDRMPRIME* buffer) attribs.width = m_texWidth; attribs.height = m_texHeight; attribs.format = layer->format; - attribs.colorSpace = GetColorSpace(DRMPRIME::GetColorEncoding(buffer->GetPicture())); - attribs.colorRange = GetColorRange(DRMPRIME::GetColorRange(buffer->GetPicture())); + attribs.colorSpace = GetEGLColorSpace(buffer->GetPicture()); + attribs.colorRange = GetEGLColorRange(buffer->GetPicture()); attribs.planes = planes; if (!m_eglImage->CreateImage(attribs)) @@ -94,29 +130,3 @@ void CDRMPRIMETexture::Unmap() m_primebuffer->Release(); m_primebuffer = nullptr; } - -int CDRMPRIMETexture::GetColorSpace(int colorSpace) -{ - switch (colorSpace) - { - case DRM_COLOR_YCBCR_BT2020: - return EGL_ITU_REC2020_EXT; - case DRM_COLOR_YCBCR_BT601: - return EGL_ITU_REC601_EXT; - case DRM_COLOR_YCBCR_BT709: - default: - return EGL_ITU_REC709_EXT; - } -} - -int CDRMPRIMETexture::GetColorRange(int colorRange) -{ - switch (colorRange) - { - case DRM_COLOR_YCBCR_FULL_RANGE: - return EGL_YUV_FULL_RANGE_EXT; - case DRM_COLOR_YCBCR_LIMITED_RANGE: - default: - return EGL_YUV_NARROW_RANGE_EXT; - } -} diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h index d39c5f2b96..e1e1310f28 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h +++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h @@ -35,8 +35,4 @@ protected: GLuint m_texture{0}; int m_texWidth{0}; int m_texHeight{0}; - -private: - static int GetColorSpace(int colorSpace); - static int GetColorRange(int colorRange); }; diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp index 1f514c659a..4f07ffc0b8 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp @@ -161,11 +161,16 @@ void CVideoLayerBridgeDRMPRIME::Configure(CVideoBufferDRMPRIME* buffer) const VideoPicture& picture = buffer->GetPicture(); auto plane = m_DRM->GetVideoPlane(); - if (plane->SupportsPropertyAndValue("COLOR_ENCODING", GetColorEncoding(picture))) - m_DRM->AddProperty(plane, "COLOR_ENCODING", GetColorEncoding(picture)); - if (plane->SupportsPropertyAndValue("COLOR_RANGE", GetColorRange(picture))) - m_DRM->AddProperty(plane, "COLOR_RANGE", GetColorRange(picture)); + bool result; + uint64_t value; + std::tie(result, value) = plane->GetPropertyValue("COLOR_ENCODING", GetColorEncoding(picture)); + if (result) + m_DRM->AddProperty(plane, "COLOR_ENCODING", value); + + std::tie(result, value) = plane->GetPropertyValue("COLOR_RANGE", GetColorRange(picture)); + if (result) + m_DRM->AddProperty(plane, "COLOR_RANGE", value); auto connector = m_DRM->GetConnector(); if (connector->SupportsProperty("HDR_OUTPUT_METADATA")) diff --git a/xbmc/interfaces/legacy/Control.cpp b/xbmc/interfaces/legacy/Control.cpp index f4398fec7d..1e87083802 100644 --- a/xbmc/interfaces/legacy/Control.cpp +++ b/xbmc/interfaces/legacy/Control.cpp @@ -537,6 +537,7 @@ namespace XBMCAddon ControlRadioButton::ControlRadioButton(long x, long y, long width, long height, const String& label, const char* focusOnTexture, const char* noFocusOnTexture, const char* focusOffTexture, const char* noFocusOffTexture, + const char* focusTexture, const char* noFocusTexture, long _textOffsetX, long _textOffsetY, long alignment, const char* font, const char* _textColor, const char* _disabledColor, long angle, @@ -554,6 +555,11 @@ namespace XBMCAddon strText = label; // if texture is supplied use it, else get default ones + strTextureFocus = focusTexture ? focusTexture : + XBMCAddonUtils::getDefaultImage("button", "texturefocus"); + strTextureNoFocus = noFocusTexture ? noFocusTexture : + XBMCAddonUtils::getDefaultImage("button", "texturenofocus"); + if (focusOnTexture && noFocusOnTexture) { strTextureRadioOnFocus = focusOnTexture; diff --git a/xbmc/interfaces/legacy/Control.h b/xbmc/interfaces/legacy/Control.h index cc9a8f4ae7..b962597675 100644 --- a/xbmc/interfaces/legacy/Control.h +++ b/xbmc/interfaces/legacy/Control.h @@ -215,7 +215,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control /// @brief \python_func{ setEnabled(enabled) } - /// Set's the control's enabled/disabled state. + /// Sets the control's enabled/disabled state. /// /// @param enabled bool - True=enabled / False=disabled. /// @@ -238,7 +238,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control /// @brief \python_func{ setVisible(visible) } - /// Set's the control's visible/hidden state. + /// Sets the control's visible/hidden state. /// \anchor python_xbmcgui_control_setVisible /// /// @param visible bool - True=visible / False=hidden. @@ -290,7 +290,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control /// @brief \python_func{ setVisibleCondition(visible[,allowHiddenFocus]) } - /// Set's the control's visible condition. + /// Sets the control's visible condition. /// /// Allows Kodi to control the visible status of the control. /// @@ -320,7 +320,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control /// @brief \python_func{ setEnableCondition(enable) } - /// Set's the control's enabled condition. + /// Sets the control's enabled condition. /// /// Allows Kodi to control the enabled status of the control. /// @@ -348,7 +348,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control /// @brief \python_func{ setAnimations([(event, attr,)*]) } - /// Set's the control's animations. + /// Sets the control's animations. /// /// <b>[(event,attr,)*]</b>: list - A list of tuples consisting of event /// and attributes pairs. @@ -379,7 +379,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control /// @brief \python_func{ setPosition(x, y) } - /// Set's the controls position. + /// Sets the controls position. /// /// @param x integer - x coordinate of control. /// @param y integer - y coordinate of control. @@ -405,7 +405,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control /// @brief \python_func{ setWidth(width) } - /// Set's the controls width. + /// Sets the controls width. /// /// @param width integer - width of control. /// @@ -428,7 +428,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control /// @brief \python_func{ setHeight(height) } - /// Set's the controls height. + /// Sets the controls height. /// /// @param height integer - height of control. /// @@ -451,7 +451,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control /// @brief \python_func{ setNavigation(up, down, left, right) } - /// Set's the controls navigation. + /// Sets the controls navigation. /// /// @param up control object - control to navigate to on up. /// @param down control object - control to navigate to on down. @@ -485,7 +485,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control /// @brief \python_func{ controlUp(control) } - /// Set's the controls up navigation. + /// Sets the controls up navigation. /// /// @param control control object - control to navigate to on up. /// @throw TypeError if one of the supplied arguments is not a @@ -515,7 +515,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control /// @brief \python_func{ controlDown(control) } - /// Set's the controls down navigation. + /// Sets the controls down navigation. /// /// @param control control object - control to navigate to on down. /// @throw TypeError if one of the supplied arguments is not a @@ -545,7 +545,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control /// @brief \python_func{ controlLeft(control) } - /// Set's the controls left navigation. + /// Sets the controls left navigation. /// /// @param control control object - control to navigate to on left. /// @throw TypeError if one of the supplied arguments is not a @@ -575,7 +575,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control /// @brief \python_func{ controlRight(control) } - /// Set's the controls right navigation. + /// Sets the controls right navigation. /// /// @param control control object - control to navigate to on right. /// @throw TypeError if one of the supplied arguments is not a @@ -654,7 +654,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control_spin /// @brief \python_func{ setTextures(up, down, upFocus, downFocus) } - /// Set's textures for this control. + /// Sets textures for this control. /// /// Texture are image files that are used for example in the skin /// @@ -799,7 +799,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control_label /// @brief \python_func{ setLabel(label[, font, textColor, disabledColor, shadowColor, focusedColor, label2]) } - /// Set's text for this label. + /// Sets text for this label. /// /// @param label string or unicode - text string. /// @param font [opt] string - font used for label text. @@ -923,7 +923,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control_edit /// @brief \python_func{ setLabel(label[, font, textColor, disabledColor, shadowColor, focusedColor, label2]) } - /// Set's text heading for this edit control. + /// Sets text heading for this edit control. /// /// @param label string or unicode - text string. /// @param font [opt] string - font used for label text. @@ -986,7 +986,7 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// \ingroup python_xbmcgui_control_edit /// @brief \python_func{ setText(value) } - /// Set's text value for this edit control. + /// Sets text value for this edit control. /// /// @param value string or unicode - text string. /// @@ -1425,7 +1425,7 @@ namespace XBMCAddon /// /// \ingroup python_xbmcgui_control_list /// @brief \python_func{ setSpace(space) } - /// Set's the space between items. + /// Sets the space between items. /// /// @param space [opt] integer - space between items. /// @@ -1831,7 +1831,7 @@ namespace XBMCAddon /// /// \ingroup python_xbmcgui_control_textbox /// @brief \python_func{ setText(text) } - /// Set's the text for this textbox. + /// Sets the text for this textbox. /// \anchor python_xbmcgui_control_textbox_settext /// /// @param text string - text string. @@ -2313,7 +2313,7 @@ namespace XBMCAddon /// /// \ingroup python_xbmcgui_control_button /// @brief \python_func{ setLabel([label, font, textColor, disabledColor, shadowColor, focusedColor, label2]) } - /// Set's this buttons text attributes. + /// Sets this buttons text attributes. /// /// @param label [opt] string or unicode - text string. /// @param font [opt] string - font used for label text. (e.g. 'font13') @@ -2354,7 +2354,7 @@ namespace XBMCAddon /// /// \ingroup python_xbmcgui_control_button /// @brief \python_func{ setDisabledColor(disabledColor) } - /// Set's this buttons disabled color. + /// Sets this buttons disabled color. /// /// @param disabledColor hexstring - color of disabled button's label. (e.g. '0xFFFF3300') /// @@ -2503,16 +2503,15 @@ namespace XBMCAddon /// \defgroup python_xbmcgui_control_radiobutton Subclass - ControlRadioButton /// \ingroup python_xbmcgui_control /// @{ - /// @brief **For control a radio button (as used for on/off settings).** + /// @brief **A radio button control (as used for on/off settings).** /// /// \python_class{ ControlRadioButton(x, y, width, height, label[, focusOnTexture, noFocusOnTexture, - /// focusOffTexture, noFocusOffTexture, + /// focusOffTexture, noFocusOffTexture, focusTexture, noFocusTexture, /// textOffsetX, textOffsetY, alignment, font, textColor, disabledColor]) } /// /// The radio button control is used for creating push button on/off /// settings in Kodi. You can choose the position, size, and look of the - /// button. When the user clicks on the radio button, the state will change, - /// toggling the extra textures (textureradioon and textureradiooff). Used + /// button, as well as the focused and unfocused radio textures. Used /// for settings controls. /// /// @note This class include also all calls from \ref python_xbmcgui_control "Control" @@ -2530,6 +2529,10 @@ namespace XBMCAddon /// focused texture. /// @param noFocusOffTexture [opt] string - filename for radio OFF /// not focused texture. + /// @param focusTexture [opt] string - filename for focused button + /// texture. + /// @param noFocusTexture [opt] string - filename for not focused button + /// texture. /// @param textOffsetX [opt] integer - horizontal text offset /// @param textOffsetY [opt] integer - vertical text offset /// @param alignment [opt] integer - alignment of label @@ -2560,8 +2563,6 @@ namespace XBMCAddon /// ///-------------------------------------------------------------------------- /// @python_v13 New function added. - /// @python_v18 Deprecated **focusTexture** and **noFocusTexture**. Use **focusOnTexture** and **noFocusOnTexture**. - /// @python_v19 Removed **focusTexture** and **noFocusTexture**. /// /// **Example:** /// ~~~~~~~~~~~~~{.py} @@ -2576,6 +2577,7 @@ namespace XBMCAddon ControlRadioButton(long x, long y, long width, long height, const String& label, const char* focusOnTexture = NULL, const char* noFocusOnTexture = NULL, const char* focusOffTexture = NULL, const char* noFocusOffTexture = NULL, + const char* focusTexture = NULL, const char* noFocusTexture = NULL, long textOffsetX = CONTROL_TEXT_OFFSET_X, long textOffsetY = CONTROL_TEXT_OFFSET_Y, long _alignment = (XBFONT_LEFT | XBFONT_CENTER_Y), @@ -2642,7 +2644,7 @@ namespace XBMCAddon /// /// \ingroup python_xbmcgui_control_radiobutton /// @brief \python_func{ setLabel(label[, font, textColor, disabledColor, shadowColor, focusedColor]) } - /// Set's the radio buttons text attributes. + /// Sets the radio buttons text attributes. /// /// @param label string or unicode - text string. /// @param font [opt] string - font used for label diff --git a/xbmc/network/upnp/UPnPInternal.cpp b/xbmc/network/upnp/UPnPInternal.cpp index 652ff364b1..c232e972f2 100644 --- a/xbmc/network/upnp/UPnPInternal.cpp +++ b/xbmc/network/upnp/UPnPInternal.cpp @@ -363,6 +363,14 @@ BuildObject(CFileItem& item, logger->debug("Building didl for object '{}'", item.GetPath()); + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return nullptr; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return nullptr; + EClientQuirks quirks = GetClientQuirks(context); // get list of ip addresses @@ -513,7 +521,11 @@ BuildObject(CFileItem& item, break; case VIDEODATABASEDIRECTORY::NODE_TYPE_ACTOR: container->m_ObjectClass.type += ".person.videoArtist"; - container->m_Creator = StringUtils::Join(tag.m_artist, CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_videoItemSeparator).c_str(); + container->m_Creator = + StringUtils::Join( + tag.m_artist, + settingsComponent->GetAdvancedSettings()->m_videoItemSeparator) + .c_str(); container->m_Title = tag.m_strTitle.c_str(); break; case VIDEODATABASEDIRECTORY::NODE_TYPE_SEASONS: @@ -619,8 +631,8 @@ BuildObject(CFileItem& item, // we are being called by a UPnP player or renderer or the user has chosen // to look for external subtitles if (upnp_server != NULL && item.IsVideo() && - (upnp_service == UPnPPlayer || upnp_service == UPnPRenderer || - CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_SERVICES_UPNPLOOKFOREXTERNALSUBTITLES))) + (upnp_service == UPnPPlayer || upnp_service == UPnPRenderer || + settings->GetBool(CSettings::SETTING_SERVICES_UPNPLOOKFOREXTERNALSUBTITLES))) { // find any available external subtitles std::vector<std::string> filenames; @@ -649,20 +661,28 @@ BuildObject(CFileItem& item, } else if (!subtitles.empty()) { - /* trying to find subtitle with prefered language settings */ - std::string preferredLanguage = (CServiceBroker::GetSettingsComponent()->GetSettings()->GetSetting("locale.subtitlelanguage"))->ToString(); - std::string preferredLanguageCode; - g_LangCodeExpander.ConvertToISO6392B(preferredLanguage, preferredLanguageCode); + std::string preferredLanguage{"en"}; - for (unsigned int i = 0; i < subtitles.size(); i++) - { - ExternalStreamInfo info = CUtil::GetExternalStreamDetailsFromFilename(file_path.GetChars(), subtitles[i]); + /* trying to find subtitle with prefered language settings */ + auto setting = settings->GetSetting("locale.subtitlelanguage"); + if (!setting) + CLog::Log(LOGERROR, "Failed to load setting for: {}", "locale.subtitlelanguage"); + else + preferredLanguage = setting->ToString(); + + std::string preferredLanguageCode; + g_LangCodeExpander.ConvertToISO6392B(preferredLanguage, preferredLanguageCode); - if (preferredLanguageCode == info.language) - { - subtitlePath = subtitles[i]; - break; - } + for (unsigned int i = 0; i < subtitles.size(); i++) + { + ExternalStreamInfo info = + CUtil::GetExternalStreamDetailsFromFilename(file_path.GetChars(), subtitles[i]); + + if (preferredLanguageCode == info.language) + { + subtitlePath = subtitles[i]; + break; + } } /* if not found subtitle with prefered language, get the first one */ if (subtitlePath.empty()) diff --git a/xbmc/platform/android/activity/CMakeLists.txt b/xbmc/platform/android/activity/CMakeLists.txt index aa82f924b0..e37a67ee7c 100644 --- a/xbmc/platform/android/activity/CMakeLists.txt +++ b/xbmc/platform/android/activity/CMakeLists.txt @@ -17,6 +17,7 @@ set(SOURCES android_main.cpp JNIXBMCNsdManagerResolveListener.cpp JNIXBMCJsonHandler.cpp JNIXBMCFile.cpp + JNIXBMCURIUtils.cpp JNIXBMCDisplayManagerDisplayListener.cpp ${NDKROOT}/sources/android/native_app_glue/android_native_app_glue.c ${NDKROOT}/sources/android/cpufeatures/cpu-features.c) @@ -42,6 +43,7 @@ set(HEADERS AndroidExtra.h JNIXBMCNsdManagerResolveListener.h JNIXBMCJsonHandler.h JNIXBMCFile.h + JNIXBMCURIUtils.h JNIXBMCDisplayManagerDisplayListener.h XBMCApp.h) diff --git a/xbmc/platform/android/activity/JNIXBMCURIUtils.cpp b/xbmc/platform/android/activity/JNIXBMCURIUtils.cpp new file mode 100644 index 0000000000..ea961441e8 --- /dev/null +++ b/xbmc/platform/android/activity/JNIXBMCURIUtils.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 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 "JNIXBMCURIUtils.h" + +#include "CompileInfo.h" +#include "utils/URIUtils.h" + +#include <androidjni/Context.h> +#include <androidjni/jutils-details.hpp> + +using namespace jni; + +static std::string s_className = std::string(CCompileInfo::GetClass()) + "/XBMCURIUtils"; + +void CJNIXBMCURIUtils::RegisterNatives(JNIEnv *env) +{ + jclass cClass = env->FindClass(s_className.c_str()); + if(cClass) + { + JNINativeMethod methods[] = + { + {"_substitutePath", "(Ljava/lang/String;)Ljava/lang/String;", (void*)&CJNIXBMCURIUtils::_substitutePath}, + }; + + env->RegisterNatives(cClass, methods, sizeof(methods)/sizeof(methods[0])); + } +} + +jstring CJNIXBMCURIUtils::_substitutePath(JNIEnv *env, jobject thiz, jstring path) +{ + std::string strPath = jcast<std::string>(jhstring::fromJNI(path)); + std::string responseData = URIUtils::SubstitutePath(strPath); + + jstring jres = env->NewStringUTF(responseData.c_str()); + return jres; +} diff --git a/xbmc/platform/android/activity/JNIXBMCURIUtils.h b/xbmc/platform/android/activity/JNIXBMCURIUtils.h new file mode 100644 index 0000000000..4f6237708f --- /dev/null +++ b/xbmc/platform/android/activity/JNIXBMCURIUtils.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 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. + */ + +#pragma once + +#include <androidjni/JNIBase.h> + +namespace jni +{ + + class CJNIXBMCURIUtils : public CJNIBase + { + public: + CJNIXBMCURIUtils(const jni::jhobject &object) : CJNIBase(object) {} + + static void RegisterNatives(JNIEnv* env); + + + protected: + ~CJNIXBMCURIUtils() override = default; + + static jstring _substitutePath(JNIEnv* env, jobject thiz, jstring path); + + }; + +} diff --git a/xbmc/platform/android/activity/android_main.cpp b/xbmc/platform/android/activity/android_main.cpp index 578c204631..121042701f 100644 --- a/xbmc/platform/android/activity/android_main.cpp +++ b/xbmc/platform/android/activity/android_main.cpp @@ -22,6 +22,7 @@ #include "platform/android/activity/JNIXBMCNsdManagerRegistrationListener.h" #include "platform/android/activity/JNIXBMCNsdManagerResolveListener.h" #include "platform/android/activity/JNIXBMCSurfaceTextureOnFrameAvailableListener.h" +#include "platform/android/activity/JNIXBMCURIUtils.h" #include "platform/android/activity/JNIXBMCVideoView.h" #include <errno.h> @@ -146,6 +147,7 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) jni::CJNIXBMCMediaSession::RegisterNatives(env); jni::CJNIXBMCJsonHandler::RegisterNatives(env); jni::CJNIXBMCFile::RegisterNatives(env); + jni::CJNIXBMCURIUtils::RegisterNatives(env); jclass cMain = env->FindClass(mainClass.c_str()); if(cMain) diff --git a/xbmc/platform/linux/input/LibInputSettings.cpp b/xbmc/platform/linux/input/LibInputSettings.cpp index 76facff5f9..071c384bd9 100644 --- a/xbmc/platform/linux/input/LibInputSettings.cpp +++ b/xbmc/platform/linux/input/LibInputSettings.cpp @@ -34,12 +34,32 @@ namespace CLibInputSettings::CLibInputSettings(CLibInputHandler *handler) : m_libInputHandler(handler) { + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return; + + auto settingsManager = settings->GetSettingsManager(); + if (!settingsComponent) + return; + + auto setting = settings->GetSetting(SETTING_INPUT_LIBINPUTKEYBOARDLAYOUT); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", SETTING_INPUT_LIBINPUTKEYBOARDLAYOUT); + return; + } + + setting->SetVisible(true); + std::set<std::string> settingSet; settingSet.insert(SETTING_INPUT_LIBINPUTKEYBOARDLAYOUT); - const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings(); - settings->GetSettingsManager()->RegisterCallback(this, settingSet); - settings->GetSettingsManager()->RegisterSettingOptionsFiller("libinputkeyboardlayout", SettingOptionsKeyboardLayoutsFiller); - settings->GetSetting(SETTING_INPUT_LIBINPUTKEYBOARDLAYOUT)->SetVisible(true); + settingsManager->RegisterCallback(this, settingSet); + settingsManager->RegisterSettingOptionsFiller("libinputkeyboardlayout", + SettingOptionsKeyboardLayoutsFiller); /* load the keyboard layouts from xkeyboard-config */ std::string xkbFile("/usr/share/X11/xkb/rules/base.xml"); diff --git a/xbmc/powermanagement/PowerManager.cpp b/xbmc/powermanagement/PowerManager.cpp index a2714feabb..491d4f3443 100644 --- a/xbmc/powermanagement/PowerManager.cpp +++ b/xbmc/powermanagement/PowerManager.cpp @@ -52,6 +52,14 @@ void CPowerManager::Initialize() void CPowerManager::SetDefaults() { + auto setting = m_settings->GetSetting(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", + CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE); + return; + } + int defaultShutdown = m_settings->GetInt(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE); switch (defaultShutdown) @@ -91,7 +99,7 @@ void CPowerManager::SetDefaults() break; } - std::static_pointer_cast<CSettingInt>(m_settings->GetSetting(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE))->SetDefault(defaultShutdown); + std::static_pointer_cast<CSettingInt>(setting)->SetDefault(defaultShutdown); } bool CPowerManager::Powerdown() diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp index d4bd941376..2b487339d6 100644 --- a/xbmc/settings/Settings.cpp +++ b/xbmc/settings/Settings.cpp @@ -725,18 +725,37 @@ void CSettings::InitializeDefaults() // when we do this (eg non-Aero on ATI in particular) and on others (AppleTV) we can't get XBMC to // the front if (g_sysinfo.IsAeroDisabled()) - std::static_pointer_cast<CSettingBool>(GetSettingsManager()->GetSetting(CSettings::SETTING_VIDEOSCREEN_FAKEFULLSCREEN))->SetDefault(false); + { + auto setting = GetSettingsManager()->GetSetting(CSettings::SETTING_VIDEOSCREEN_FAKEFULLSCREEN); + if (!setting) + CLog::Log(LOGERROR, "Failed to load setting for: {}", + CSettings::SETTING_VIDEOSCREEN_FAKEFULLSCREEN); + else + std::static_pointer_cast<CSettingBool>(setting)->SetDefault(false); + } #endif if (g_application.IsStandAlone()) - std::static_pointer_cast<CSettingInt>(GetSettingsManager()->GetSetting(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE))->SetDefault(POWERSTATE_SHUTDOWN); + { + auto setting = + GetSettingsManager()->GetSetting(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE); + if (!setting) + CLog::Log(LOGERROR, "Failed to load setting for: {}", + CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE); + else + std::static_pointer_cast<CSettingInt>(setting)->SetDefault(POWERSTATE_SHUTDOWN); + } // Initialize deviceUUID if not already set, used in zeroconf advertisements. std::shared_ptr<CSettingString> deviceUUID = std::static_pointer_cast<CSettingString>(GetSettingsManager()->GetSetting(CSettings::SETTING_SERVICES_DEVICEUUID)); if (deviceUUID->GetValue().empty()) { const std::string& uuid = StringUtils::CreateUUID(); - std::static_pointer_cast<CSettingString>(GetSettingsManager()->GetSetting(CSettings::SETTING_SERVICES_DEVICEUUID))->SetValue(uuid); + auto setting = GetSettingsManager()->GetSetting(CSettings::SETTING_SERVICES_DEVICEUUID); + if (!setting) + CLog::Log(LOGERROR, "Failed to load setting for: {}", CSettings::SETTING_SERVICES_DEVICEUUID); + else + std::static_pointer_cast<CSettingString>(setting)->SetValue(uuid); } } diff --git a/xbmc/utils/EGLImage.cpp b/xbmc/utils/EGLImage.cpp index 1c8d4d780a..725aa0ed82 100644 --- a/xbmc/utils/EGLImage.cpp +++ b/xbmc/utils/EGLImage.cpp @@ -8,6 +8,7 @@ #include "EGLImage.h" +#include "ServiceBroker.h" #include "utils/EGLUtils.h" #include "utils/log.h" @@ -154,11 +155,8 @@ bool CEGLImage::CreateImage(EglAttrs imageAttrs) m_image = m_eglCreateImageKHR(m_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, nullptr, attribs.Get()); - if(!m_image) + if (!m_image || CServiceBroker::GetLogging().CanLogComponent(LOGVIDEO)) { - CLog::Log(LOGERROR, "CEGLImage::{} - failed to import buffer into EGL image: {:#4x}", - __FUNCTION__, eglGetError()); - const EGLint* attrs = attribs.Get(); std::string eglString; @@ -168,31 +166,39 @@ bool CEGLImage::CreateImage(EglAttrs imageAttrs) std::string keyStr; std::string valueStr; - auto eglAttr = eglAttributes.find(attrs[i]); - if (eglAttr != eglAttributes.end()) + auto eglAttrKey = eglAttributes.find(attrs[i]); + if (eglAttrKey != eglAttributes.end()) { - keyStr = eglAttr->second; + keyStr = eglAttrKey->second; } else { keyStr = std::to_string(attrs[i]); } - eglAttr = eglAttributes.find(attrs[i + 1]); - if (eglAttr != eglAttributes.end()) + auto eglAttrValue = eglAttributes.find(attrs[i + 1]); + if (eglAttrValue != eglAttributes.end()) { - valueStr = eglAttr->second; + valueStr = eglAttrValue->second; } else { - valueStr = std::to_string(attrs[i + 1]); + if (eglAttrKey->first == EGL_LINUX_DRM_FOURCC_EXT) + valueStr = FourCCToString(attrs[i + 1]); + else + valueStr = std::to_string(attrs[i + 1]); } eglString.append(StringUtils::Format("%s: %s\n", keyStr, valueStr)); } CLog::Log(LOGDEBUG, "CEGLImage::{} - attributes:\n{}", __FUNCTION__, eglString); + } + if (!m_image) + { + CLog::Log(LOGERROR, "CEGLImage::{} - failed to import buffer into EGL image: {:#4x}", + __FUNCTION__, eglGetError()); return false; } diff --git a/xbmc/video/GUIViewStateVideo.cpp b/xbmc/video/GUIViewStateVideo.cpp index 38828fd99f..ca64394fc8 100644 --- a/xbmc/video/GUIViewStateVideo.cpp +++ b/xbmc/video/GUIViewStateVideo.cpp @@ -259,14 +259,16 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it break; case NODE_TYPE_TITLE_MUSICVIDEOS: { - AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty - AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O")); - AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty + AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T - %A", "%Y")); // Title, Artist, Year | empty, empty + AddSortMethod(SortByAlbum, sortAttributes, 558, LABEL_MASKS("%B - %T - %A", "%Y")); // Album, Title, Artist, Year | empty, empty AddSortMethod(SortByArtist, sortAttributes, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty - AddSortMethod(SortByAlbum, sortAttributes, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty - AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded - AddSortMethod(SortByPlaycount, 567, - LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty + AddSortMethod(SortByArtistThenYear, sortAttributes, 578, LABEL_MASKS("%A - %T", "%Y")); // Artist, Title, Year| empty, empty + AddSortMethod(SortByYear, 562, LABEL_MASKS("%T - %A", "%Y")); // Title, Artist, Year| empty, empty + AddSortMethod(SortByTime, 180, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty + AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T - %A", "%a")); // Title - Artist, DateAdded | empty, empty + AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T - %A", "%V")); // Titel - Artist, PlayCount + AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T - %A", "%O")); // Title - Artist, MPAARating + AddSortMethod(SortByUserRating, 38018, LABEL_MASKS("%T - %A", "%r")); // Title - Artist, UserRating std::string strTrack=CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT); AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrack, "%N")); // Userdefined, Track Number | empty, empty @@ -471,12 +473,16 @@ CGUIViewStateVideoMusicVideos::CGUIViewStateVideoMusicVideos(const CFileItemList if (settings->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING)) sortAttributes = SortAttributeIgnoreArticle; - AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty - AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O")); - AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty + AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T - %A", "%Y")); // Title, Artist, Year | empty, empty + AddSortMethod(SortByAlbum, sortAttributes, 558, LABEL_MASKS("%B - %T - %A", "%Y")); // Album, Title, Artist, Year | empty, empty AddSortMethod(SortByArtist, sortAttributes, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty - AddSortMethod(SortByAlbum, sortAttributes, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty - AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty + AddSortMethod(SortByArtistThenYear, sortAttributes, 578, LABEL_MASKS("%A - %T", "%Y")); // Artist, Title, Year| empty, empty + AddSortMethod(SortByYear, 562, LABEL_MASKS("%T - %A", "%Y")); // Title, Artist, Year| empty, empty + AddSortMethod(SortByTime, 180, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty + AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T - %A", "%a")); // Title - Artist, DateAdded | empty, empty + AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T - %A", "%V")); // Titel - Artist, PlayCount + AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T - %A", "%O")); // Title - Artist, MPAARating + AddSortMethod(SortByUserRating, 38018, LABEL_MASKS("%T - %A", "%r")); // Title - Artist, UserRating std::string strTrack = settings->GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT); AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrack, "%N")); // Userdefined, Track Number | empty, empty diff --git a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp index e3f99a54d4..2a47300c56 100644 --- a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp @@ -213,10 +213,27 @@ void CGUIDialogVideoSettings::OnSettingAction(const std::shared_ptr<const CSetti { const std::shared_ptr<CProfileManager> profileManager = CServiceBroker::GetSettingsComponent()->GetProfileManager(); + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return; + + auto setting = settings->GetSetting(CSettings::SETTING_VIDEOSCREEN_GUICALIBRATION); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", + CSettings::SETTING_VIDEOSCREEN_GUICALIBRATION); + return; + } + // launch calibration window - if (profileManager->GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && - g_passwordManager.CheckSettingLevelLock(CServiceBroker::GetSettingsComponent()->GetSettings()->GetSetting(CSettings::SETTING_VIDEOSCREEN_GUICALIBRATION)->GetLevel())) + if (profileManager->GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && + g_passwordManager.CheckSettingLevelLock(setting->GetLevel())) return; + CServiceBroker::GetGUI()->GetWindowManager().ForceActivateWindow(WINDOW_SCREEN_CALIBRATION); } //! @todo implement diff --git a/xbmc/windowing/gbm/drm/DRMAtomic.cpp b/xbmc/windowing/gbm/drm/DRMAtomic.cpp index 9270aa7e99..37166b8dcd 100644 --- a/xbmc/windowing/gbm/drm/DRMAtomic.cpp +++ b/xbmc/windowing/gbm/drm/DRMAtomic.cpp @@ -46,19 +46,21 @@ uint32_t GetScalingFactor(uint32_t srcWidth, bool CDRMAtomic::SetScalingFilter(CDRMObject* object, const char* name, const char* type) { - uint64_t filter_type{}; - if (m_gui_plane->GetPropertyValue(name, type, filter_type)) - { - if (AddProperty(object, name, filter_type)) - { - uint32_t mar_scale_factor = - GetScalingFactor(m_width, m_height, m_mode->hdisplay, m_mode->vdisplay); - AddProperty(object, "CRTC_W", (mar_scale_factor * m_width)); - AddProperty(object, "CRTC_H", (mar_scale_factor * m_height)); - return true; - } - } - return false; + bool result; + uint64_t value; + std::tie(result, value) = m_gui_plane->GetPropertyValue(name, type); + if (!result) + return false; + + if (!AddProperty(object, name, value)) + return false; + + uint32_t mar_scale_factor = + GetScalingFactor(m_width, m_height, m_mode->hdisplay, m_mode->vdisplay); + AddProperty(object, "CRTC_W", (mar_scale_factor * m_width)); + AddProperty(object, "CRTC_H", (mar_scale_factor * m_height)); + + return true; } void CDRMAtomic::DrmAtomicCommit(int fb_id, int flags, bool rendered, bool videoLayer) diff --git a/xbmc/windowing/gbm/drm/DRMObject.cpp b/xbmc/windowing/gbm/drm/DRMObject.cpp index 6449cfd86e..7d27c6f059 100644 --- a/xbmc/windowing/gbm/drm/DRMObject.cpp +++ b/xbmc/windowing/gbm/drm/DRMObject.cpp @@ -8,7 +8,6 @@ #include "DRMObject.h" -#include "utils/StringUtils.h" #include "utils/log.h" #include <algorithm> @@ -54,11 +53,10 @@ std::string CDRMObject::GetPropertyName(uint32_t propertyId) const return "invalid property"; } -uint32_t CDRMObject::GetPropertyId(const char* name) const +uint32_t CDRMObject::GetPropertyId(const std::string& name) const { - auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), [&name](auto& prop) { - return StringUtils::EqualsNoCase(prop->name, name); - }); + auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), + [&name](auto& prop) { return prop->name == name; }); if (property != m_propsInfo.end()) return property->get()->prop_id; @@ -82,37 +80,36 @@ bool CDRMObject::GetProperties(uint32_t id, uint32_t type) return true; } -bool CDRMObject::GetPropertyValue(std::string name, const std::string& type, uint64_t& value) const +//! @todo: improve with c++17 +std::tuple<bool, uint64_t> CDRMObject::GetPropertyValue(const std::string& name, + const std::string& valueName) const { - auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), [&name](auto& prop) { - return StringUtils::EqualsNoCase(prop->name, name); - }); + auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), + [&name](auto& prop) { return prop->name == name; }); if (property == m_propsInfo.end()) - return false; + return std::make_tuple(false, 0); auto prop = property->get(); - if (drm_property_type_is(prop, DRM_MODE_PROP_ENUM) != 0) + if (!static_cast<bool>(drm_property_type_is(prop, DRM_MODE_PROP_ENUM))) + return std::make_tuple(false, 0); + + for (int j = 0; j < prop->count_enums; j++) { - for (int j = 0; j < prop->count_enums; j++) - { - if (std::strcmp(prop->enums[j].name, type.c_str()) == 0) - { - value = prop->enums[j].value; - return true; - } - } + if (prop->enums[j].name != valueName) + continue; + + return {true, prop->enums[j].value}; } - return false; + return std::make_tuple(false, 0); } -bool CDRMObject::SetProperty(const char* name, uint64_t value) +bool CDRMObject::SetProperty(const std::string& name, uint64_t value) { - auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), [&name](auto& prop) { - return StringUtils::EqualsNoCase(prop->name, name); - }); + auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), + [&name](auto& prop) { return prop->name == name; }); if (property != m_propsInfo.end()) { @@ -124,38 +121,13 @@ bool CDRMObject::SetProperty(const char* name, uint64_t value) return false; } -bool CDRMObject::SupportsProperty(const char* name) +bool CDRMObject::SupportsProperty(const std::string& name) { - auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), [&name](auto& prop) { - return StringUtils::EqualsNoCase(prop->name, name); - }); + auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), + [&name](auto& prop) { return prop->name == name; }); if (property != m_propsInfo.end()) return true; return false; } - -bool CDRMObject::SupportsPropertyAndValue(const char* name, uint64_t value) -{ - auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), [&name](auto& prop) { - return StringUtils::EqualsNoCase(prop->name, name); - }); - - if (property != m_propsInfo.end()) - { - if (drm_property_type_is(property->get(), DRM_MODE_PROP_ENUM) != 0) - { - for (int j = 0; j < property->get()->count_enums; j++) - { - if (property->get()->enums[j].value == value) - return true; - } - } - - CLog::Log(LOGDEBUG, "CDRMObject::{} - property '{}' does not support value '{}'", __FUNCTION__, - name, value); - } - - return false; -} diff --git a/xbmc/windowing/gbm/drm/DRMObject.h b/xbmc/windowing/gbm/drm/DRMObject.h index 836418813f..e2ae32652c 100644 --- a/xbmc/windowing/gbm/drm/DRMObject.h +++ b/xbmc/windowing/gbm/drm/DRMObject.h @@ -33,12 +33,12 @@ public: std::string GetPropertyName(uint32_t propertyId) const; uint32_t GetId() const { return m_id; } - uint32_t GetPropertyId(const char* name) const; - bool GetPropertyValue(std::string name, const std::string& type, uint64_t& value) const; + uint32_t GetPropertyId(const std::string& name) const; + std::tuple<bool, uint64_t> GetPropertyValue(const std::string& name, + const std::string& valueName) const; - bool SetProperty(const char* name, uint64_t value); - bool SupportsProperty(const char* name); - bool SupportsPropertyAndValue(const char* name, uint64_t value); + bool SetProperty(const std::string& name, uint64_t value); + bool SupportsProperty(const std::string& name); protected: explicit CDRMObject(int fd); |