[Test] Added tests for CUtil::SplitParams
[xbmc.git] / xbmc / application / ApplicationPlayer.h
blob2a641d081584917979163501087e743d731ee1e1
1 /*
2 * Copyright (C) 2005-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.
7 */
9 #pragma once
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"
19 #include <memory>
20 #include <string>
21 #include <vector>
23 class CAction;
24 class CPlayerCoreFactory;
25 class CPlayerOptions;
26 class CStreamDetails;
28 struct AudioStreamInfo;
29 struct VideoStreamInfo;
30 struct SubtitleStreamInfo;
31 struct TextCacheStruct_t;
33 class CApplicationPlayer : public IApplicationComponent
35 public:
36 CApplicationPlayer() = default;
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);
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;
73 /*!
74 * \brief Get the name of the player in use
75 * \return the player name if a player is active, otherwise it returns an empty string
77 std::string GetName() const;
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;
119 * \brief Get the supported menu type
120 * \return The supported menu type
122 MenuType GetSupportedMenuType() const;
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);
158 * \brief Set the subtitle vertical position,
159 * it depends on current screen resolution
160 * \param value The subtitle position in pixels
161 * \param save If true, the value will be saved to resolution info
163 void SetSubtitleVerticalPosition(const int value, bool save);
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;
172 CVideoSettings GetVideoSettings() const;
173 void SetVideoSettings(CVideoSettings& settings);
175 CSeekHandler& GetSeekHandler();
176 const CSeekHandler& GetSeekHandler() const;
178 void SetUpdateStreamDetails();
181 * \copydoc IPlayer::HasGameAgent
183 bool HasGameAgent() const;
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);
191 std::shared_ptr<IPlayer> m_pPlayer;
192 mutable CCriticalSection m_playerLock;
193 CSeekHandler m_seekHandler;
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;
203 struct SNextItem
205 std::shared_ptr<CFileItem> pItem;
206 CPlayerOptions options = {};
207 std::string playerName;
208 IPlayerCallback *callback = nullptr;
209 } m_nextItem;