xbmc
PVRPlaybackState.h
1 /*
2  * Copyright (C) 2012-2019 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 
13 #include <memory>
14 #include <string>
15 
16 class CDateTime;
17 class CFileItem;
18 
19 namespace PVR
20 {
21 class CPVRChannel;
22 class CPVRChannelGroup;
23 class CPVRChannelGroupMember;
24 class CPVREpgInfoTag;
25 class CPVRRecording;
26 
28 {
29 public:
34 
38  virtual ~CPVRPlaybackState();
39 
43  void Clear();
44 
48  void ReInit();
49 
54  void OnPlaybackStarted(const CFileItem& item);
55 
61  bool OnPlaybackStopped(const CFileItem& item);
62 
67  void OnPlaybackEnded(const CFileItem& item);
68 
73  bool IsPlaying() const;
74 
79  bool IsPlayingTV() const;
80 
85  bool IsPlayingRadio() const;
86 
91  bool IsPlayingEncryptedChannel() const;
92 
97  bool IsPlayingRecording() const;
98 
103  bool IsPlayingEpgTag() const;
104 
111  bool IsPlayingChannel(int iClientID, int iUniqueChannelID) const;
112 
118  bool IsPlayingChannel(const std::shared_ptr<CPVRChannel>& channel) const;
119 
125  bool IsPlayingRecording(const std::shared_ptr<CPVRRecording>& recording) const;
126 
132  bool IsPlayingEpgTag(const std::shared_ptr<CPVREpgInfoTag>& epgTag) const;
133 
138  std::shared_ptr<CPVRChannel> GetPlayingChannel() const;
139 
144  std::shared_ptr<CPVRChannelGroupMember> GetPlayingChannelGroupMember() const;
145 
150  std::shared_ptr<CPVRRecording> GetPlayingRecording() const;
151 
156  std::shared_ptr<CPVREpgInfoTag> GetPlayingEpgTag() const;
157 
162  int GetPlayingChannelUniqueID() const;
163 
168  std::string GetPlayingClientName() const;
169 
174  int GetPlayingClientID() const;
175 
180  bool IsRecording() const;
181 
186  bool IsRecordingOnPlayingChannel() const;
187 
192  bool IsPlayingActiveRecording() const;
193 
198  bool CanRecordOnPlayingChannel() const;
199 
204  void SetActiveChannelGroup(const std::shared_ptr<CPVRChannelGroup>& group);
205 
211  std::shared_ptr<CPVRChannelGroup> GetActiveChannelGroup(bool bRadio) const;
212 
218  std::shared_ptr<CPVRChannelGroupMember> GetLastPlayedChannelGroupMember(bool bRadio) const;
219 
225  std::shared_ptr<CPVRChannelGroupMember> GetPreviousToLastPlayedChannelGroupMember(
226  bool bRadio) const;
227 
235  CDateTime GetPlaybackTime(int iClientID, int iUniqueChannelID) const;
236 
243  CDateTime GetChannelPlaybackTime(int iClientID, int iUniqueChannelID) const;
244 
245 private:
246  void ClearData();
247 
252  void SetActiveChannelGroup(const std::shared_ptr<CPVRChannelGroupMember>& channel);
253 
259  void UpdateLastWatched(const std::shared_ptr<CPVRChannelGroupMember>& channel,
260  const CDateTime& time);
261 
262  mutable CCriticalSection m_critSection;
263 
264  std::shared_ptr<CPVRChannelGroupMember> m_playingChannel;
265  std::shared_ptr<CPVRRecording> m_playingRecording;
266  std::shared_ptr<CPVREpgInfoTag> m_playingEpgTag;
267  std::shared_ptr<CPVRChannelGroupMember> m_lastPlayedChannelTV;
268  std::shared_ptr<CPVRChannelGroupMember> m_lastPlayedChannelRadio;
269  std::shared_ptr<CPVRChannelGroupMember> m_previousToLastPlayedChannelTV;
270  std::shared_ptr<CPVRChannelGroupMember> m_previousToLastPlayedChannelRadio;
271  std::string m_strPlayingClientName;
272  int m_playingGroupId = -1;
273  int m_playingClientId = -1;
274  int m_playingChannelUniqueId = -1;
275  std::string m_strPlayingRecordingUniqueId;
276  int m_playingEpgTagChannelUniqueId = -1;
277  unsigned int m_playingEpgTagUniqueId = 0;
278  std::shared_ptr<CPVRChannelGroup> m_activeGroupTV;
279  std::shared_ptr<CPVRChannelGroup> m_activeGroupRadio;
280 
282  std::unique_ptr<CLastWatchedUpdateTimer> m_lastWatchedUpdateTimer;
283 };
284 } // namespace PVR
bool IsPlayingActiveRecording() const
Check if an active recording is playing.
Definition: PVRPlaybackState.cpp:428
bool IsPlayingChannel(int iClientID, int iUniqueChannelID) const
Check whether playing channel matches given uids.
Definition: PVRPlaybackState.cpp:328
Definition: PVRPlaybackState.cpp:39
virtual ~CPVRPlaybackState()
dtor.
bool IsPlaying() const
Check if a TV channel, radio channel or recording is playing.
Definition: PVRPlaybackState.cpp:292
bool IsPlayingTV() const
Check if a TV channel is playing.
Definition: PVRPlaybackState.cpp:298
Definition: ContextMenuManager.h:24
void Clear()
clear instances, keep stored UIDs.
Definition: PVRPlaybackState.cpp:128
bool IsPlayingRadio() const
Check if a radio channel is playing.
Definition: PVRPlaybackState.cpp:304
bool IsPlayingRecording() const
Check if a recording is playing.
Definition: PVRPlaybackState.cpp:316
CDateTime GetChannelPlaybackTime(int iClientID, int iUniqueChannelID) const
Get current playback time for the given channel, taking timeshifting into account.
Definition: PVRPlaybackState.cpp:527
std::shared_ptr< CPVRRecording > GetPlayingRecording() const
Return the recording that is currently playing.
Definition: PVRPlaybackState.cpp:386
bool OnPlaybackStopped(const CFileItem &item)
Inform that playback of an item was stopped due to user interaction.
Definition: PVRPlaybackState.cpp:227
bool IsRecordingOnPlayingChannel() const
Check whether there is an active recording on the currenlyt playing channel.
Definition: PVRPlaybackState.cpp:421
bool IsRecording() const
Check whether there are active recordings.
Definition: PVRPlaybackState.cpp:416
std::string GetPlayingClientName() const
Get the name of the playing client, if there is one.
Definition: PVRPlaybackState.cpp:404
std::shared_ptr< CPVRChannel > GetPlayingChannel() const
Return the channel that is currently playing.
Definition: PVRPlaybackState.cpp:374
bool CanRecordOnPlayingChannel() const
Check whether the currently playing channel can be recorded.
Definition: PVRPlaybackState.cpp:434
std::shared_ptr< CPVRChannelGroup > GetActiveChannelGroup(bool bRadio) const
Get the active channel group.
Definition: PVRPlaybackState.cpp:505
int GetPlayingChannelUniqueID() const
Return playing channel unique identifier.
Definition: PVRPlaybackState.cpp:398
std::shared_ptr< CPVREpgInfoTag > GetPlayingEpgTag() const
Return the epg tag that is currently playing.
Definition: PVRPlaybackState.cpp:392
bool IsPlayingEpgTag() const
Check if an epg tag is playing.
Definition: PVRPlaybackState.cpp:322
std::shared_ptr< CPVRChannelGroupMember > GetLastPlayedChannelGroupMember(bool bRadio) const
Get the last played channel group member.
Definition: PVRPlaybackState.cpp:557
CDateTime GetPlaybackTime(int iClientID, int iUniqueChannelID) const
Get current playback time for the given channel, taking timeshifting and playing epg tags into accoun...
Definition: PVRPlaybackState.cpp:513
DateTime class, which uses FileTime as it&#39;s base.
Definition: XBDateTime.h:63
std::shared_ptr< CPVRChannelGroupMember > GetPreviousToLastPlayedChannelGroupMember(bool bRadio) const
Get the channel group member that was played before the last played member.
Definition: PVRPlaybackState.cpp:565
Definition: SmartPlayList.cpp:137
bool IsPlayingEncryptedChannel() const
Check if a an encrypted TV or radio channel is playing.
Definition: PVRPlaybackState.cpp:310
void ReInit()
re-init using stored UIDs.
Definition: PVRPlaybackState.cpp:64
void SetActiveChannelGroup(const std::shared_ptr< CPVRChannelGroup > &group)
Set the active channel group.
Definition: PVRPlaybackState.cpp:469
void OnPlaybackStarted(const CFileItem &item)
Inform that playback of an item just started.
Definition: PVRPlaybackState.cpp:144
int GetPlayingClientID() const
Get the ID of the playing client, if there is one.
Definition: PVRPlaybackState.cpp:410
void OnPlaybackEnded(const CFileItem &item)
Inform that playback of an item has stopped without user interaction.
Definition: PVRPlaybackState.cpp:286
Definition: PVRPlaybackState.h:27
std::shared_ptr< CPVRChannelGroupMember > GetPlayingChannelGroupMember() const
Return the channel group member that is currently playing.
Definition: PVRPlaybackState.cpp:380
Represents a file on a share.
Definition: FileItem.h:102