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