Debian Codegraph @

xbmc/guilib/guiinfo/PlayerGUIInfo.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2012-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 "guilib/guiinfo/GUIInfoProvider.h"
12 #include "utils/EventStream.h"
13 #include "utils/TimeFormat.h"
14
15 #include <atomic>
16 #include <ctime>
17 #include <memory>
18 #include <utility>
19 #include <vector>
20
21 class CApplicationPlayer;
22 class CApplicationVolumeHandling;
23 class CDataCacheCore;
24
25 namespace KODI
26 {
27 namespace GUILIB
28 {
29 namespace GUIINFO
30 {
31
32 class CGUIInfo;
33
34 struct PlayerShowInfoChangedEvent
35 {
36 explicit PlayerShowInfoChangedEvent(bool showInfo) : m_showInfo(showInfo) {}
37 virtual ~PlayerShowInfoChangedEvent() = default;
38
39 bool m_showInfo{false};
40 };
41
42 class CPlayerGUIInfo : public CGUIInfoProvider
43 {
44 public:
45 CPlayerGUIInfo();
46 ~CPlayerGUIInfo() override;
47
48 CEventStream<PlayerShowInfoChangedEvent>& Events() { return m_events; }
49
50 // KODI::GUILIB::GUIINFO::IGUIInfoProvider implementation
51 bool InitCurrentItem(CFileItem *item) override;
52 bool GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const override;
53 bool GetInt(int& value, const CGUIListItem *item, int contextWindow, const CGUIInfo &info) const override;
54 bool GetBool(bool& value, const CGUIListItem *item, int contextWindow, const CGUIInfo &info) const override;
55
56 void SetShowTime(bool showtime) { m_playerShowTime = showtime; }
57 void SetShowInfo(bool showinfo);
58 bool GetShowInfo() const { return m_playerShowInfo; }
59 bool ToggleShowInfo();
60
61 private:
62 int GetTotalPlayTime() const;
63 int GetPlayTime() const;
64 int GetPlayTimeRemaining() const;
65 float GetSeekPercent() const;
66
67 std::string GetCurrentPlayTime(TIME_FORMAT format) const;
68 std::string GetCurrentPlayTimeRemaining(TIME_FORMAT format) const;
69 std::string GetDuration(TIME_FORMAT format) const;
70 std::string GetCurrentSeekTime(TIME_FORMAT format) const;
71 std::string GetSeekTime(TIME_FORMAT format) const;
72
73 std::string GetContentRanges(int iInfo) const;
74 std::vector<std::pair<float, float>> GetEditList(const CDataCacheCore& data,
75 std::time_t duration) const;
76 std::vector<std::pair<float, float>> GetCuts(const CDataCacheCore& data,
77 std::time_t duration) const;
78 std::vector<std::pair<float, float>> GetSceneMarkers(const CDataCacheCore& data,
79 std::time_t duration) const;
80 std::vector<std::pair<float, float>> GetChapters(const CDataCacheCore& data,
81 std::time_t duration) const;
82
83 std::unique_ptr<CFileItem> m_currentItem;
84 std::atomic_bool m_playerShowTime{false};
85 std::atomic_bool m_playerShowInfo{false};
86 const std::shared_ptr<CApplicationPlayer> m_appPlayer;
87 const std::shared_ptr<CApplicationVolumeHandling> m_appVolume;
88 CEventSource<PlayerShowInfoChangedEvent> m_events;
89 };
90
91 } // namespace GUIINFO
92 } // namespace GUILIB
93 } // namespace KODI