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.
11 #include "IPlayerCallback.h"
12 #include "Interface/StreamInfo.h"
14 #include "VideoSettings.h"
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
25 struct TextCacheStruct_t
;
29 class IPlayerCallback
;
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*/
52 enum IPlayerAudioCapabilities
57 IPC_AUD_SELECT_STREAM
,
58 IPC_AUD_OUTPUT_STEREO
,
62 enum IPlayerSubtitleCapabilities
73 RENDERFEATURE_BRIGHTNESS
,
74 RENDERFEATURE_CONTRAST
,
76 RENDERFEATURE_SHARPNESS
,
77 RENDERFEATURE_NONLINSTRETCH
,
78 RENDERFEATURE_ROTATION
,
79 RENDERFEATURE_STRETCH
,
81 RENDERFEATURE_VERTICAL_SHIFT
,
82 RENDERFEATURE_PIXEL_RATIO
,
83 RENDERFEATURE_POSTPROCESS
,
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
){}
115 virtual void SetAVDelay(float fValue
= 0.0f
) {}
116 virtual float GetAVDelay() { return 0.0f
; }
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
) {}
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
133 virtual void SetSubtitleVerticalPosition(int value
, bool save
) {}
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.
139 virtual void AddSubtitle(const std::string
& strSubPath
) {}
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 {}
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
) {}
151 virtual int GetPrograms(std::vector
<ProgramInfo
>& programs
) { return 0; }
152 virtual void SetProgram(int progId
) {}
153 virtual int GetProgramsCount() const { return 0; }
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
) {}
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; }
166 virtual void SeekTime(int64_t iTime
= 0) {}
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
172 virtual bool SeekTimeRelative(int64_t iTime
) { return false; }
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)
181 virtual void SetTime(int64_t time
) { }
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)
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
) {}
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; }
199 virtual bool IsInMenu() const { return false; }
202 * \brief Get the supported menu type
203 * \return The supported menu type
205 virtual MenuType
GetSupportedMenuType() const { return MenuType::NONE
; }
207 virtual bool OnAction(const CAction
& action
) { return false; }
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; }
213 virtual void GetAudioCapabilities(std::vector
<int>& audioCaps
) const
215 audioCaps
.assign(1, IPC_AUD_ALL
);
218 \brief define the subtitle capabilities of the player
220 virtual void GetSubtitleCapabilities(std::vector
<int>& subCaps
) const
222 subCaps
.assign(1, IPC_SUBS_ALL
);
226 \brief hook into render loop of render thread
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 virtual void GetRects(CRect
& source
, CRect
& dest
, CRect
& view
) const
240 virtual bool Supports(EINTERLACEMETHOD method
) const { return false; }
241 virtual EINTERLACEMETHOD
GetDeinterlacingMethodDefault() const
243 return EINTERLACEMETHOD::VS_INTERLACEMETHOD_NONE
;
245 virtual bool Supports(ESCALINGMETHOD method
) const { return false; }
246 virtual bool Supports(ERENDERFEATURE feature
) const { return false; }
248 virtual unsigned int RenderCaptureAlloc() { return 0; }
249 virtual void RenderCaptureRelease(unsigned int captureId
) {}
250 virtual void RenderCapture(unsigned int captureId
,
256 virtual bool RenderCaptureGetPixels(unsigned int captureId
,
264 // video and audio settings
265 virtual CVideoSettings
GetVideoSettings() const { return CVideoSettings(); }
266 virtual void SetVideoSettings(CVideoSettings
& settings
) {}
269 * \brief Check if any players are playing a game
271 * \return True if at least one player has an input device attached to the
272 * game, false otherwise
274 virtual bool HasGameAgent() const { return false; }
280 IPlayerCallback
& m_callback
;