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 
77  std::string GetName() const;
78 
79  // proxy calls
80  void AddSubtitle(const std::string& strSubPath);
81  bool CanPause() const;
82  bool CanSeek() const;
83  int GetAudioDelay() const;
84  void GetAudioCapabilities(std::vector<int>& audioCaps) const;
85  int GetAudioStream();
86  int GetAudioStreamCount() const;
87  void GetAudioStreamInfo(int index, AudioStreamInfo& info) const;
88  int GetCacheLevel() const;
89  float GetCachePercentage() const;
90  int GetChapterCount() const;
91  int GetChapter() const;
92  void GetChapterName(std::string& strChapterName, int chapterIdx = -1) const;
93  int64_t GetChapterPos(int chapterIdx = -1) const;
94  float GetPercentage() const;
95  std::string GetPlayerState();
96  PLAYLIST::Id GetPreferredPlaylist() const;
97  int GetSubtitleDelay() const;
98  int GetSubtitle();
99  void GetSubtitleCapabilities(std::vector<int>& subCaps) const;
100  int GetSubtitleCount() const;
101  void GetSubtitleStreamInfo(int index, SubtitleStreamInfo& info) const;
102  bool GetSubtitleVisible() const;
103  bool HasTeletextCache() const;
104  std::shared_ptr<TextCacheStruct_t> GetTeletextCache();
105  int64_t GetTime() const;
106  int64_t GetMinTime() const;
107  int64_t GetMaxTime() const;
108  time_t GetStartTime() const;
109  int64_t GetTotalTime() const;
110  int GetVideoStream();
111  int GetVideoStreamCount() const;
112  void GetVideoStreamInfo(int streamId, VideoStreamInfo& info) const;
113  int GetPrograms(std::vector<ProgramInfo>& programs);
114  void SetProgram(int progId);
115  int GetProgramsCount() const;
116  bool HasAudio() const;
117 
122  MenuType GetSupportedMenuType() const;
123 
124  bool HasVideo() const;
125  bool HasGame() const;
126  bool HasRDS() const;
127  bool IsCaching() const;
128  bool IsInMenu() const;
129  bool IsPaused() const;
130  bool IsPausedPlayback() const;
131  bool IsPassthrough() const;
132  bool IsPlaying() const;
133  bool IsPlayingAudio() const;
134  bool IsPlayingVideo() const;
135  bool IsPlayingGame() const;
136  bool IsPlayingRDS() const;
137  void LoadPage(int p, int sp, unsigned char* buffer);
138  bool OnAction(const CAction &action);
139  void OnNothingToQueueNotify();
140  void Pause();
141  bool QueueNextFile(const CFileItem &file);
142  void Seek(bool bPlus = true, bool bLargeStep = false, bool bChapterOverride = false);
143  int SeekChapter(int iChapter);
144  void SeekPercentage(float fPercent = 0);
145  bool SeekScene(bool bPlus = true);
146  void SeekTime(int64_t iTime = 0);
147  void SeekTimeRelative(int64_t iTime = 0);
148  void SetAudioStream(int iStream);
149  void SetAVDelay(float fValue = 0.0f);
150  void SetDynamicRangeCompression(long drc);
151  void SetMute(bool bOnOff);
152  bool SetPlayerState(const std::string& state);
153  void SetSubtitle(int iStream);
154  void SetSubTitleDelay(float fValue = 0.0f);
155  void SetSubtitleVisible(bool bVisible);
156 
163  void SetSubtitleVerticalPosition(const int value, bool save);
164 
165  void SetTime(int64_t time);
166  void SetTotalTime(int64_t time);
167  void SetVideoStream(int iStream);
168  void SetVolume(float volume);
169  void SetSpeed(float speed);
170  bool SupportsTempo() const;
171 
172  CVideoSettings GetVideoSettings() const;
173  void SetVideoSettings(CVideoSettings& settings);
174 
175  CSeekHandler& GetSeekHandler();
176  const CSeekHandler& GetSeekHandler() const;
177 
178  void SetUpdateStreamDetails();
179 
183  bool HasGameAgent() const;
184 
185 private:
186  std::shared_ptr<const IPlayer> GetInternal() const;
187  std::shared_ptr<IPlayer> GetInternal();
188  void CreatePlayer(const CPlayerCoreFactory &factory, const std::string &player, IPlayerCallback& callback);
189  void CloseFile(bool reopen = false);
190 
191  std::shared_ptr<IPlayer> m_pPlayer;
192  mutable CCriticalSection m_playerLock;
193  CSeekHandler m_seekHandler;
194 
195  // cache player state
196  XbmcThreads::EndTime<> m_audioStreamUpdate;
197  int m_iAudioStream;
198  XbmcThreads::EndTime<> m_videoStreamUpdate;
199  int m_iVideoStream;
200  XbmcThreads::EndTime<> m_subtitleStreamUpdate;
201  int m_iSubtitleStream;
202 
203  struct SNextItem
204  {
205  std::shared_ptr<CFileItem> pItem;
206  CPlayerOptions options = {};
207  std::string playerName;
208  IPlayerCallback *callback = nullptr;
209  } m_nextItem;
210 };
Definition: ApplicationPlayer.h:33
Definition: StreamInfo.h:65
MenuType GetSupportedMenuType() const
Get the supported menu type.
Definition: ApplicationPlayer.cpp:415
std::string GetName() const
Get the name of the player in use.
Definition: ApplicationPlayer.cpp:992
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:21
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:1039
void SetSubtitleVerticalPosition(const int value, bool save)
Set the subtitle vertical position, it depends on current screen resolution.
Definition: ApplicationPlayer.cpp:692
Definition: IPlayer.h:31
Definition: VideoSettings.h:194
Represents a file on a share.
Definition: FileItem.h:102