kodi
MediaSettings.h
1 /*
2  * Copyright (C) 2013-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "cores/VideoSettings.h"
12 #include "settings/GameSettings.h"
13 #include "settings/ISubSettings.h"
14 #include "settings/LibExportSettings.h"
15 #include "settings/lib/ISettingCallback.h"
16 #include "settings/lib/ISettingsHandler.h"
17 #include "threads/CriticalSection.h"
18 
19 #include <map>
20 #include <string>
21 
22 #define VOLUME_DRC_MINIMUM 0 // 0dB
23 #define VOLUME_DRC_MAXIMUM 6000 // 60dB
24 
25 class TiXmlNode;
26 
27 // Step used to increase/decrease audio delay
28 static constexpr float AUDIO_DELAY_STEP = 0.025f;
29 
30 typedef enum {
31  WatchedModeAll = 0,
32  WatchedModeUnwatched,
33  WatchedModeWatched
34 } WatchedMode;
35 
37 {
38 public:
39  static CMediaSettings& GetInstance();
40 
41  bool Load(const TiXmlNode *settings) override;
42  bool Save(TiXmlNode *settings) const override;
43 
44  void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override;
45  void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override;
46 
47  const CVideoSettings& GetDefaultVideoSettings() const { return m_defaultVideoSettings; }
48  CVideoSettings& GetDefaultVideoSettings() { return m_defaultVideoSettings; }
49 
50  const CGameSettings& GetDefaultGameSettings() const { return m_defaultGameSettings; }
51  CGameSettings& GetDefaultGameSettings() { return m_defaultGameSettings; }
52  const CGameSettings& GetCurrentGameSettings() const { return m_currentGameSettings; }
53  CGameSettings& GetCurrentGameSettings() { return m_currentGameSettings; }
54 
60  int GetWatchedMode(const std::string &content) const;
61 
67  void SetWatchedMode(const std::string &content, WatchedMode mode);
68 
73  void CycleWatchedMode(const std::string &content);
74 
75  void SetMusicPlaylistRepeat(bool repeats) { m_musicPlaylistRepeat = repeats; }
76  void SetMusicPlaylistShuffled(bool shuffled) { m_musicPlaylistShuffle = shuffled; }
77 
78  void SetVideoPlaylistRepeat(bool repeats) { m_videoPlaylistRepeat = repeats; }
79  void SetVideoPlaylistShuffled(bool shuffled) { m_videoPlaylistShuffle = shuffled; }
80 
81  bool DoesMediaStartWindowed() const { return m_mediaStartWindowed; }
82  void SetMediaStartWindowed(bool windowed) { m_mediaStartWindowed = windowed; }
83  int GetAdditionalSubtitleDirectoryChecked() const { return m_additionalSubtitleDirectoryChecked; }
84  void SetAdditionalSubtitleDirectoryChecked(int checked) { m_additionalSubtitleDirectoryChecked = checked; }
85 
86  int GetMusicNeedsUpdate() const { return m_musicNeedsUpdate; }
87  void SetMusicNeedsUpdate(int version) { m_musicNeedsUpdate = version; }
88  int GetVideoNeedsUpdate() const { return m_videoNeedsUpdate; }
89  void SetVideoNeedsUpdate(int version) { m_videoNeedsUpdate = version; }
90 
91 protected:
93  CMediaSettings(const CMediaSettings&) = delete;
94  CMediaSettings& operator=(CMediaSettings const&) = delete;
95  ~CMediaSettings() override;
96 
97  static std::string GetWatchedContent(const std::string &content);
98 
99 private:
100  CVideoSettings m_defaultVideoSettings;
101 
102  CGameSettings m_defaultGameSettings;
103  CGameSettings m_currentGameSettings;
104 
105  typedef std::map<std::string, WatchedMode> WatchedModes;
106  WatchedModes m_watchedModes;
107 
108  bool m_musicPlaylistRepeat;
109  bool m_musicPlaylistShuffle;
110  bool m_videoPlaylistRepeat;
111  bool m_videoPlaylistShuffle;
112 
113  bool m_mediaStartWindowed;
114  int m_additionalSubtitleDirectoryChecked;
115 
116  int m_musicNeedsUpdate;
117  int m_videoNeedsUpdate;
118 
119  mutable CCriticalSection m_critical;
120 };
int GetWatchedMode(const std::string &content) const
Retrieve the watched mode for the given content type.
Definition: MediaSettings.cpp:379
Definition: ISettingCallback.h:16
Definition: GameSettings.h:16
bool Save(TiXmlNode *settings) const override
Save settings to the given XML node.
Definition: MediaSettings.cpp:206
void OnSettingChanged(const std::shared_ptr< const CSetting > &setting) override
The value of the given setting has changed.
Definition: MediaSettings.cpp:370
void CycleWatchedMode(const std::string &content)
Cycle the watched mode for the given content type.
Definition: MediaSettings.cpp:397
Definition: MediaSettings.h:36
bool Load(const TiXmlNode *settings) override
Load settings from the given XML node.
Definition: MediaSettings.cpp:70
Definition: settings.py:1
Interface defining methods being called by the settings system if an action is performed on multiple/...
Definition: ISettingsHandler.h:16
void SetWatchedMode(const std::string &content, WatchedMode mode)
Set the watched mode for the given content type.
Definition: MediaSettings.cpp:389
void OnSettingAction(const std::shared_ptr< const CSetting > &setting) override
The given setting has been activated.
Definition: MediaSettings.cpp:303
Definition: VideoSettings.h:194
Interface defining methods to load additional setting values from an XML file being loaded by the set...
Definition: ISubSettings.h:18