Debian Codegraph @

xbmc/cores/IPlayer.h

raw symbols SCIP
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 "IPlayerCallback.h"
12 #include "Interface/StreamInfo.h"
13 #include "MenuType.h"
14 #include "VideoSettings.h"
15
16 #include <memory>
17 #include <string>
18 #include <vector>
19
20 #define CURRENT_STREAM -1
21 #define CAPTUREFLAG_CONTINUOUS 0x01 //after a render is done, render a new one immediately
22 #define CAPTUREFLAG_IMMEDIATELY 0x02 //read out immediately after render, this can cause a busy wait
23 #define CAPTUREFORMAT_BGRA 0x01
24
25 struct TextCacheStruct_t;
26 class TiXmlElement;
27 class CStreamDetails;
28 class CAction;
29 class IPlayerCallback;
30
31 class CPlayerOptions
32 {
33 public:
34 CPlayerOptions()
35 {
36 starttime = 0LL;
37 startpercent = 0LL;
38 fullscreen = false;
39 videoOnly = false;
40 preferStereo = false;
41 }
42 double starttime; /* start time in seconds */
43 double startpercent; /* start time in percent */
44 std::string state; /* potential playerstate to restore to */
45 bool fullscreen; /* player is allowed to switch to fullscreen */
46 bool videoOnly; /* player is not allowed to play audio streams, video streams only */
47 bool preferStereo; /* prefer stereo streams when selecting initial audio stream*/
48 };
49
50 class CFileItem;
51
52 enum IPlayerAudioCapabilities
53 {
54 IPC_AUD_ALL,
55 IPC_AUD_OFFSET,
56 IPC_AUD_AMP,
57 IPC_AUD_SELECT_STREAM,
58 IPC_AUD_OUTPUT_STEREO,
59 IPC_AUD_SELECT_OUTPUT
60 };
61
62 enum IPlayerSubtitleCapabilities
63 {
64 IPC_SUBS_ALL,
65 IPC_SUBS_SELECT,
66 IPC_SUBS_EXTERNAL,
67 IPC_SUBS_OFFSET
68 };
69
70 enum ERENDERFEATURE
71 {
72 RENDERFEATURE_GAMMA,
73 RENDERFEATURE_BRIGHTNESS,
74 RENDERFEATURE_CONTRAST,
75 RENDERFEATURE_NOISE,
76 RENDERFEATURE_SHARPNESS,
77 RENDERFEATURE_NONLINSTRETCH,
78 RENDERFEATURE_ROTATION,
79 RENDERFEATURE_STRETCH,
80 RENDERFEATURE_ZOOM,
81 RENDERFEATURE_VERTICAL_SHIFT,
82 RENDERFEATURE_PIXEL_RATIO,
83 RENDERFEATURE_POSTPROCESS,
84 RENDERFEATURE_TONEMAP
85 };
86
87 class IPlayer
88 {
89 public:
90 explicit IPlayer(IPlayerCallback& callback) : m_callback(callback) {}
91 virtual ~IPlayer() = default;
92 virtual bool Initialize(TiXmlElement* pConfig) { return true; }
93 virtual bool OpenFile(const CFileItem& file, const CPlayerOptions& options){ return false;}
94 virtual bool QueueNextFile(const CFileItem &file) { return false; }
95 virtual void OnNothingToQueueNotify() {}
96 virtual bool CloseFile(bool reopen = false) = 0;
97 virtual bool IsPlaying() const { return false;}
98 virtual bool CanPause() const { return true; }
99 virtual void Pause() = 0;
100 virtual bool HasVideo() const = 0;
101 virtual bool HasAudio() const = 0;
102 virtual bool HasGame() const { return false; }
103 virtual bool HasRDS() const { return false; }
104 virtual bool HasID3() const { return false; }
105 virtual bool IsPassthrough() const { return false;}
106 virtual bool CanSeek() const { return true; }
107 virtual void Seek(bool bPlus = true, bool bLargeStep = false, bool bChapterOverride = false) = 0;
108 virtual bool SeekScene(bool bPlus = true) {return false;}
109 virtual void SeekPercentage(float fPercent = 0){}
110 virtual float GetCachePercentage() const { return 0; }
111 virtual void SetMute(bool bOnOff){}
112 virtual void SetVolume(float volume){}
113 virtual void SetDynamicRangeCompression(long drc){}
114
115 virtual void SetAVDelay(float fValue = 0.0f) {}
116 virtual float GetAVDelay() { return 0.0f; }
117
118 virtual void SetSubTitleDelay(float fValue = 0.0f) {}
119 virtual float GetSubTitleDelay() { return 0.0f; }
120 virtual int GetSubtitleCount() const { return 0; }
121 virtual int GetSubtitle() { return -1; }
122 virtual void GetSubtitleStreamInfo(int index, SubtitleStreamInfo& info) const {}
123 virtual void SetSubtitle(int iStream) {}
124 virtual bool GetSubtitleVisible() const { return false; }
125 virtual void SetSubtitleVisible(bool bVisible) {}
126
127 /*!
128 * \brief Set the subtitle vertical position,
129 * it depends on current screen resolution
130 * \param value The subtitle position in pixels
131 * \param save If true, the value will be saved to resolution info
132 */
133 virtual void SetSubtitleVerticalPosition(int value, bool save) {}
134
135 /** \brief Adds the subtitle(s) provided by the given file to the available player streams
136 * and actives the first of the added stream(s). E.g., vob subs can contain multiple streams.
137 * \param[in] strSubPath The full path of the subtitle file.
138 */
139 virtual void AddSubtitle(const std::string& strSubPath) {}
140
141 virtual int GetAudioStreamCount() const { return 0; }
142 virtual int GetAudioStream() { return -1; }
143 virtual void SetAudioStream(int iStream) {}
144 virtual void GetAudioStreamInfo(int index, AudioStreamInfo& info) const {}
145
146 virtual int GetVideoStream() const { return -1; }
147 virtual int GetVideoStreamCount() const { return 0; }
148 virtual void GetVideoStreamInfo(int streamId, VideoStreamInfo& info) const {}
149 virtual void SetVideoStream(int iStream) {}
150
151 virtual int GetPrograms(std::vector<ProgramInfo>& programs) { return 0; }
152 virtual void SetProgram(int progId) {}
153 virtual int GetProgramsCount() const { return 0; }
154
155 virtual bool HasTeletextCache() const { return false; }
156 virtual std::shared_ptr<TextCacheStruct_t> GetTeletextCache() { return nullptr; }
157 virtual void LoadPage(int p, int sp, unsigned char* buffer) {}
158
159 virtual int GetChapterCount() const { return 0; }
160 virtual int GetChapter() const { return -1; }
161 virtual void GetChapterName(std::string& strChapterName, int chapterIdx = -1) const {}
162 virtual int64_t GetChapterPos(int chapterIdx = -1) const { return 0; }
163 virtual int SeekChapter(int iChapter) { return -1; }
164 // virtual bool GetChapterInfo(int chapter, SChapterInfo &info) { return false; }
165
166 virtual void SeekTime(int64_t iTime = 0) {}
167 /*
168 \brief seek relative to current time, returns false if not implemented by player
169 \param iTime The time in milliseconds to seek. A positive value will seek forward, a negative backward.
170 \return True if the player supports relative seeking, otherwise false
171 */
172 virtual bool SeekTimeRelative(int64_t iTime) { return false; }
173
174 /*!
175 \brief Sets the current time. This
176 can be used for injecting the current time.
177 This is not to be confused with a seek. It just
178 can be used if endless streams contain multiple
179 tracks in reality (like with airtunes)
180 */
181 virtual void SetTime(int64_t time) { }
182
183 /*!
184 \brief Set the total time in milliseconds
185 this can be used for injecting the duration in case
186 its not available in the underlaying decoder (airtunes for example)
187 */
188 virtual void SetTotalTime(int64_t time) { }
189 virtual void SetSpeed(float speed) = 0;
190 virtual void SetTempo(float tempo) {}
191 virtual bool SupportsTempo() const { return false; }
192 virtual void FrameAdvance(int frames) {}
193
194 //Returns true if not playback (paused or stopped being filled)
195 virtual bool IsCaching() const { return false; }
196 //Cache filled in Percent
197 virtual int GetCacheLevel() const { return -1; }
198
199 virtual bool IsInMenu() const { return false; }
200
201 /*!
202 * \brief Get the supported menu type
203 * \return The supported menu type
204 */
205 virtual MenuType GetSupportedMenuType() const { return MenuType::NONE; }
206
207 virtual bool OnAction(const CAction& action) { return false; }
208
209 //returns a state that is needed for resuming from a specific time
210 virtual std::string GetPlayerState() { return ""; }
211 virtual bool SetPlayerState(const std::string& state) { return false; }
212
213 virtual void GetAudioCapabilities(std::vector<int>& audioCaps) const
214 {
215 audioCaps.assign(1, IPC_AUD_ALL);
216 }
217 /*!
218 \brief define the subtitle capabilities of the player
219 */
220 virtual void GetSubtitleCapabilities(std::vector<int>& subCaps) const
221 {
222 subCaps.assign(1, IPC_SUBS_ALL);
223 }
224
225 /*!
226 \brief hook into render loop of render thread
227 */
228 virtual void Render(bool clear, uint32_t alpha = 255, bool gui = true) {}
229 virtual void FlushRenderer() {}
230 virtual void SetRenderViewMode(int mode, float zoom, float par, float shift, bool stretch) {}
231 virtual float GetRenderAspectRatio() const { return 1.0; }
232 virtual void TriggerUpdateResolution() {}
233 virtual bool IsRenderingVideo() const { return false; }
234
235 virtual bool Supports(EINTERLACEMETHOD method) const { return false; }
236 virtual EINTERLACEMETHOD GetDeinterlacingMethodDefault() const
237 {
238 return EINTERLACEMETHOD::VS_INTERLACEMETHOD_NONE;
239 }
240 virtual bool Supports(ESCALINGMETHOD method) const { return false; }
241 virtual bool Supports(ERENDERFEATURE feature) const { return false; }
242
243 virtual unsigned int RenderCaptureAlloc() { return 0; }
244 virtual void RenderCaptureRelease(unsigned int captureId) {}
245 virtual void RenderCapture(unsigned int captureId,
246 unsigned int width,
247 unsigned int height,
248 int flags)
249 {
250 }
251 virtual bool RenderCaptureGetPixels(unsigned int captureId,
252 unsigned int millis,
253 uint8_t* buffer,
254 unsigned int size)
255 {
256 return false;
257 }
258
259 // video and audio settings
260 virtual CVideoSettings GetVideoSettings() const { return CVideoSettings(); }
261 virtual void SetVideoSettings(CVideoSettings& settings) {}
262
263 /*!
264 * \brief Check if any players are playing a game
265 *
266 * \return True if at least one player has an input device attached to the
267 * game, false otherwise
268 */
269 virtual bool HasGameAgent() const { return false; }
270
271 std::string m_name;
272 std::string m_type;
273
274 protected:
275 IPlayerCallback& m_callback;
276 };