2 * Copyright (C) 2017-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.
11 #include "threads/CriticalSection.h"
12 #include "utils/EventStream.h"
22 struct PlayerShowInfoChangedEvent
;
29 enum class ChannelSwitchMode
31 NO_SWITCH
, // no channel switch
32 INSTANT_OR_DELAYED_SWITCH
// switch according to SETTING_PVRPLAYBACK_CHANNELENTRYTIMEOUT
35 struct PVRPreviewAndPlayerShowInfoChangedEvent
37 explicit PVRPreviewAndPlayerShowInfoChangedEvent(bool previewAndPlayerShowInfo
)
38 : m_previewAndPlayerShowInfo(previewAndPlayerShowInfo
)
41 virtual ~PVRPreviewAndPlayerShowInfoChangedEvent() = default;
43 bool m_previewAndPlayerShowInfo
{false};
46 class CPVRChannelGroupMember
;
48 class CPVRGUIChannelNavigator
51 CPVRGUIChannelNavigator();
52 virtual ~CPVRGUIChannelNavigator();
55 * @brief Subscribe to the event stream for changes of channel preview and player show info.
56 * @param owner The subscriber.
57 * @param fn The callback function of the subscriber for the events.
60 void Subscribe(A
* owner
, void (A::*fn
)(const PVRPreviewAndPlayerShowInfoChangedEvent
&))
62 SubscribeToShowInfoEventStream();
63 m_events
.Subscribe(owner
, fn
);
67 * @brief Unsubscribe from the event stream for changes of channel preview and player show info.
68 * @param obj The subscriber.
71 void Unsubscribe(A
* obj
)
73 m_events
.Unsubscribe(obj
);
77 * @brief CEventStream callback for player show info flag changes.
78 * @param event The event.
80 void Notify(const KODI::GUILIB::GUIINFO::PlayerShowInfoChangedEvent
& event
);
83 * @brief Select the next channel in currently playing channel group, relative to the currently
85 * @param eSwitchMode controls whether only the channel info OSD is triggered or whether
86 * additionally a (delayed) channel switch will be done.
88 void SelectNextChannel(ChannelSwitchMode eSwitchMode
);
91 * @brief Select the previous channel in currently playing channel group, relative to the
92 * currently selected channel.
93 * @param eSwitchMode controls whether only the channel info OSD is triggered or whether
94 * additionally a (delayed) channel switch will be done.
96 void SelectPreviousChannel(ChannelSwitchMode eSwitchMode
);
99 * @brief Switch to the currently selected channel.
101 void SwitchToCurrentChannel();
104 * @brief Query the state of channel preview.
105 * @return True, if the currently selected channel is different from the currently playing
106 * channel, False otherwise.
108 bool IsPreview() const;
111 * @brief Query the state of channel preview and channel info OSD.
112 * @return True, if the currently selected channel is different from the currently playing channel
113 * and channel info OSD is active, False otherwise.
115 bool IsPreviewAndShowInfo() const;
118 * @brief Show the channel info OSD.
123 * @brief Hide the channel info OSD.
128 * @brief Toggle the channel info OSD visibility.
133 * @brief Set a new playing channel group member and show the channel info OSD for the new
135 * @param groupMember The new playing channel group member
137 void SetPlayingChannel(const std::shared_ptr
<CPVRChannelGroupMember
>& groupMember
);
140 * @brief Clear the currently playing channel and hide the channel info OSD.
142 void ClearPlayingChannel();
146 * @brief Get next or previous channel group member of the playing channel group, relative to the
147 * currently selected channel group member.
148 * @param bNext True to get the next channel group member, false to get the previous channel group
150 * @param return The channel or nullptr if not found.
152 std::shared_ptr
<CPVRChannelGroupMember
> GetNextOrPrevChannel(bool bNext
);
155 * @brief Select a given channel group member, display channel info OSD, switch according to given
157 * @param groupMember The channel group member to select.
158 * @param eSwitchMode The channel switch mode.
160 void SelectChannel(const std::shared_ptr
<CPVRChannelGroupMember
>& groupMember
,
161 ChannelSwitchMode eSwitchMode
);
164 * @brief Show the channel info OSD.
165 * @param bForce True ignores value of SETTING_PVRMENU_DISPLAYCHANNELINFO and always activates the
166 * info, False acts aaccording settings value.
168 void ShowInfo(bool bForce
);
171 * @brief Subscribe to the event stream for changes of player show info.
173 void SubscribeToShowInfoEventStream();
176 * @brief Check if property preview and show info value changed, inform subscribers in case.
178 void CheckAndPublishPreviewAndPlayerShowInfoChangedEvent();
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;
185 CEventSource
<PVRPreviewAndPlayerShowInfoChangedEvent
> m_events
;
186 bool m_playerShowInfo
{false};
187 bool m_previewAndPlayerShowInfo
{false};