kodi
PVRGUIChannelNavigator.h
1 /*
2  * Copyright (C) 2017-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 "threads/CriticalSection.h"
12 #include "utils/EventStream.h"
13 
14 #include <memory>
15 
16 namespace KODI
17 {
18 namespace GUILIB
19 {
20 namespace GUIINFO
21 {
22 struct PlayerShowInfoChangedEvent;
23 }
24 } // namespace GUILIB
25 } // namespace KODI
26 
27 namespace PVR
28 {
29 enum class ChannelSwitchMode
30 {
31  NO_SWITCH, // no channel switch
32  INSTANT_OR_DELAYED_SWITCH // switch according to SETTING_PVRPLAYBACK_CHANNELENTRYTIMEOUT
33 };
34 
36 {
37  explicit PVRPreviewAndPlayerShowInfoChangedEvent(bool previewAndPlayerShowInfo)
38  : m_previewAndPlayerShowInfo(previewAndPlayerShowInfo)
39  {
40  }
41  virtual ~PVRPreviewAndPlayerShowInfoChangedEvent() = default;
42 
43  bool m_previewAndPlayerShowInfo{false};
44 };
45 
47 
49 {
50 public:
52  virtual ~CPVRGUIChannelNavigator();
53 
59  template<typename A>
60  void Subscribe(A* owner, void (A::*fn)(const PVRPreviewAndPlayerShowInfoChangedEvent&))
61  {
62  SubscribeToShowInfoEventStream();
63  m_events.Subscribe(owner, fn);
64  }
65 
70  template<typename A>
71  void Unsubscribe(A* obj)
72  {
73  m_events.Unsubscribe(obj);
74  }
75 
80  void Notify(const KODI::GUILIB::GUIINFO::PlayerShowInfoChangedEvent& event);
81 
88  void SelectNextChannel(ChannelSwitchMode eSwitchMode);
89 
96  void SelectPreviousChannel(ChannelSwitchMode eSwitchMode);
97 
101  void SwitchToCurrentChannel();
102 
108  bool IsPreview() const;
109 
115  bool IsPreviewAndShowInfo() const;
116 
120  void ShowInfo();
121 
125  void HideInfo();
126 
130  void ToggleInfo();
131 
137  void SetPlayingChannel(const std::shared_ptr<CPVRChannelGroupMember>& groupMember);
138 
142  void ClearPlayingChannel();
143 
144 private:
152  std::shared_ptr<CPVRChannelGroupMember> GetNextOrPrevChannel(bool bNext);
153 
160  void SelectChannel(const std::shared_ptr<CPVRChannelGroupMember>& groupMember,
161  ChannelSwitchMode eSwitchMode);
162 
168  void ShowInfo(bool bForce);
169 
173  void SubscribeToShowInfoEventStream();
174 
178  void CheckAndPublishPreviewAndPlayerShowInfoChangedEvent();
179 
180  mutable CCriticalSection m_critSection;
181  std::shared_ptr<CPVRChannelGroupMember> m_playingChannel;
182  std::shared_ptr<CPVRChannelGroupMember> m_currentChannel;
183  int m_iChannelEntryJobId = -1;
184  int m_iChannelInfoJobId = -1;
186  bool m_playerShowInfo{false};
187  bool m_previewAndPlayerShowInfo{false};
188 };
189 } // namespace PVR
Definition: PVRGUIChannelNavigator.h:48
void Subscribe(A *owner, void(A::*fn)(const PVRPreviewAndPlayerShowInfoChangedEvent &))
Subscribe to the event stream for changes of channel preview and player show info.
Definition: PVRGUIChannelNavigator.h:60
Definition: ContextMenuManager.h:24
Definition: EventStream.h:65
Definition: ArraysTest1.cpp:27
Definition: PVRGUIChannelNavigator.h:35
Definition: PVRChannelGroupMember.h:23
Definition: AudioDecoder.h:18
void Unsubscribe(A *obj)
Unsubscribe from the event stream for changes of channel preview and player show info.
Definition: PVRGUIChannelNavigator.h:71