xbmc
ApplicationPlayer.h
1 /*
2  * Copyright (C) 2005-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 "SeekHandler.h"
12 #include "application/IApplicationComponent.h"
13 #include "cores/IPlayer.h"
14 #include "cores/MenuType.h"
15 #include "playlists/PlayListTypes.h"
16 #include "threads/CriticalSection.h"
17 #include "threads/SystemClock.h"
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 class CAction;
24 class CPlayerCoreFactory;
25 class CPlayerOptions;
26 class CStreamDetails;
27 
28 struct AudioStreamInfo;
29 struct VideoStreamInfo;
30 struct SubtitleStreamInfo;
31 struct TextCacheStruct_t;
32 
34 {
35 public:
36  CApplicationPlayer() = default;
37 
38  // player management
39  void ClosePlayer();
40  void ResetPlayer();
41  std::string GetCurrentPlayer() const;
42  float GetPlaySpeed() const;
43  float GetPlayTempo() const;
44  bool HasPlayer() const;
45  bool OpenFile(const CFileItem& item, const CPlayerOptions& options,
46  const CPlayerCoreFactory &factory,
47  const std::string &playerName, IPlayerCallback& callback);
48  void OpenNext(const CPlayerCoreFactory &factory);
49  void SetPlaySpeed(float speed);
50  void SetTempo(float tempo);
51  void FrameAdvance(int frames);
52 
53  void FrameMove();
54  void Render(bool clear, uint32_t alpha = 255, bool gui = true);
55  void FlushRenderer();
56  void SetRenderViewMode(int mode, float zoom, float par, float shift, bool stretch);
57  float GetRenderAspectRatio() const;
58  void TriggerUpdateResolution();
59  bool IsRenderingVideo() const;
60  bool IsRenderingGuiLayer() const;
61  bool IsRenderingVideoLayer() const;
62  bool Supports(EINTERLACEMETHOD method) const;
63  EINTERLACEMETHOD GetDeinterlacingMethodDefault() const;
64  bool Supports(ESCALINGMETHOD method) const;
65  bool Supports(ERENDERFEATURE feature) const;
66  unsigned int RenderCaptureAlloc();
67  void RenderCapture(unsigned int captureId, unsigned int width, unsigned int height, int flags = 0);
68  void RenderCaptureRelease(unsigned int captureId);
69  bool RenderCaptureGetPixels(unsigned int captureId, unsigned int millis, uint8_t *buffer, unsigned int size);
70  bool IsExternalPlaying() const;
71  bool IsRemotePlaying() const;
72 
73  // proxy calls
74  void AddSubtitle(const std::string& strSubPath);
75  bool CanPause() const;
76  bool CanSeek() const;
77  void DoAudioWork();
78  int GetAudioDelay() const;
79  void GetAudioCapabilities(std::vector<int>& audioCaps) const;
80  int GetAudioStream();
81  int GetAudioStreamCount() const;
82  void GetAudioStreamInfo(int index, AudioStreamInfo& info) const;
83  int GetCacheLevel() const;
84  float GetCachePercentage() const;
85  int GetChapterCount() const;
86  int GetChapter() const;
87  void GetChapterName(std::string& strChapterName, int chapterIdx = -1) const;
88  int64_t GetChapterPos(int chapterIdx = -1) const;
89  float GetPercentage() const;
90  std::string GetPlayerState();
91  PLAYLIST::Id GetPreferredPlaylist() const;
92  int GetSubtitleDelay() const;
93  int GetSubtitle();
94  void GetSubtitleCapabilities(std::vector<int>& subCaps) const;
95  int GetSubtitleCount() const;
96  void GetSubtitleStreamInfo(int index, SubtitleStreamInfo& info) const;
97  bool GetSubtitleVisible() const;
98  bool HasTeletextCache() const;
99  std::shared_ptr<TextCacheStruct_t> GetTeletextCache();
100  int64_t GetTime() const;
101  int64_t GetMinTime() const;
102  int64_t GetMaxTime() const;
103  time_t GetStartTime() const;
104  int64_t GetTotalTime() const;
105  int GetVideoStream();
106  int GetVideoStreamCount() const;
107  void GetVideoStreamInfo(int streamId, VideoStreamInfo& info) const;
108  int GetPrograms(std::vector<ProgramInfo>& programs);
109  void SetProgram(int progId);
110  int GetProgramsCount() const;
111  bool HasAudio() const;
112 
117  MenuType GetSupportedMenuType() const;
118 
119  bool HasVideo() const;
120  bool HasGame() const;
121  bool HasRDS() const;
122  bool IsCaching() const;
123  bool IsInMenu() const;
124  bool IsPaused() const;
125  bool IsPausedPlayback() const;
126  bool IsPassthrough() const;
127  bool IsPlaying() const;
128  bool IsPlayingAudio() const;
129  bool IsPlayingVideo() const;
130  bool IsPlayingGame() const;
131  bool IsPlayingRDS() const;
132  void LoadPage(int p, int sp, unsigned char* buffer);
133  bool OnAction(const CAction &action);
134  void OnNothingToQueueNotify();
135  void Pause();
136  bool QueueNextFile(const CFileItem &file);
137  void Seek(bool bPlus = true, bool bLargeStep = false, bool bChapterOverride = false);
138  int SeekChapter(int iChapter);
139  void SeekPercentage(float fPercent = 0);
140  bool SeekScene(bool bPlus = true);
141  void SeekTime(int64_t iTime = 0);
142  void SeekTimeRelative(int64_t iTime = 0);
143  void SetAudioStream(int iStream);
144  void SetAVDelay(float fValue = 0.0f);
145  void SetDynamicRangeCompression(long drc);
146  void SetMute(bool bOnOff);
147  bool SetPlayerState(const std::string& state);
148  void SetSubtitle(int iStream);
149  void SetSubTitleDelay(float fValue = 0.0f);
150  void SetSubtitleVisible(bool bVisible);
151 
158  void SetSubtitleVerticalPosition(const int value, bool save);
159 
160  void SetTime(int64_t time);
161  void SetTotalTime(int64_t time);
162  void SetVideoStream(int iStream);
163  void SetVolume(float volume);
164  void SetSpeed(float speed);
165  bool SupportsTempo() const;
166 
167  CVideoSettings GetVideoSettings() const;
168  void SetVideoSettings(CVideoSettings& settings);
169 
170  CSeekHandler& GetSeekHandler();
171  const CSeekHandler& GetSeekHandler() const;
172 
173  void SetUpdateStreamDetails();
174 
178  bool HasGameAgent() const;
179 
180 private:
181  std::shared_ptr<const IPlayer> GetInternal() const;
182  std::shared_ptr<IPlayer> GetInternal();
183  void CreatePlayer(const CPlayerCoreFactory &factory, const std::string &player, IPlayerCallback& callback);
184  void CloseFile(bool reopen = false);
185 
186  std::shared_ptr<IPlayer> m_pPlayer;
187  mutable CCriticalSection m_playerLock;
188  CSeekHandler m_seekHandler;
189 
190  // cache player state
191  XbmcThreads::EndTime<> m_audioStreamUpdate;
192  int m_iAudioStream;
193  XbmcThreads::EndTime<> m_videoStreamUpdate;
194  int m_iVideoStream;
195  XbmcThreads::EndTime<> m_subtitleStreamUpdate;
196  int m_iSubtitleStream;
197 
198  struct SNextItem
199  {
200  std::shared_ptr<CFileItem> pItem;
201  CPlayerOptions options = {};
202  std::string playerName;
203  IPlayerCallback *callback = nullptr;
204  } m_nextItem;
205 };
Definition: ApplicationPlayer.h:33
Definition: StreamInfo.h:65
MenuType GetSupportedMenuType() const
Get the supported menu type.
Definition: ApplicationPlayer.cpp:415
Definition: SystemClock.h:31
Definition: PlayerCoreFactory.h:30
Definition: StreamInfo.h:55
Definition: StreamDetails.h:92
Definition: StreamInfo.h:62
class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:22
Definition: IPlayerCallback.h:18
Base class for application components.
Definition: IApplicationComponent.h:12
Definition: SeekHandler.h:28
Definition: TeletextDefines.h:393
Definition: settings.py:1
bool HasGameAgent() const
Check if any players are playing a game.
Definition: ApplicationPlayer.cpp:1036
void SetSubtitleVerticalPosition(const int value, bool save)
Set the subtitle vertical position, it depends on current screen resolution.
Definition: ApplicationPlayer.cpp:699
Definition: IPlayer.h:31
Definition: VideoSettings.h:194
Represents a file on a share.
Definition: FileItem.h:102