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 "Direction.h"
12 #include "IPlayerCallback.h"
13 #include "Interface/StreamInfo.h"
15 #include "VideoSettings.h"
21 #define CURRENT_STREAM -1
22 #define CAPTUREFLAG_CONTINUOUS 0x01 //after a render is done, render a new one immediately
23 #define CAPTUREFLAG_IMMEDIATELY 0x02 //read out immediately after render, this can cause a busy wait
24 #define CAPTUREFORMAT_BGRA 0x01
26 struct TextCacheStruct_t
;
30 class IPlayerCallback
;
43 double starttime
; /* start time in seconds */
44 double startpercent
; /* start time in percent */
45 std::string state
; /* potential playerstate to restore to */
46 bool fullscreen
; /* player is allowed to switch to fullscreen */
47 bool videoOnly
; /* player is not allowed to play audio streams, video streams only */
48 bool preferStereo
; /* prefer stereo streams when selecting initial audio stream*/
53 // \brief Player Audio capabilities
54 enum class IPlayerAudioCaps
56 ALL
, // All capabilities supported
57 SELECT_STREAM
, // Support to change stream
58 SELECT_OUTPUT
, // Support to select an output device
59 OUTPUT_STEREO
, // Support output in stereo mode
60 OFFSET
, // Support to change sync offset
61 VOLUME_AMP
, // Support volume amplification
64 // \brief Player Subtitle capabilities
65 enum class IPlayerSubtitleCaps
67 ALL
, // All capabilities supported
68 SELECT_STREAM
, // Support to change stream
69 EXTERNAL
, // Support to load external subtitles
70 OFFSET
, // Support to change sync offset
76 RENDERFEATURE_BRIGHTNESS
,
77 RENDERFEATURE_CONTRAST
,
79 RENDERFEATURE_SHARPNESS
,
80 RENDERFEATURE_NONLINSTRETCH
,
81 RENDERFEATURE_ROTATION
,
82 RENDERFEATURE_STRETCH
,
84 RENDERFEATURE_VERTICAL_SHIFT
,
85 RENDERFEATURE_PIXEL_RATIO
,
86 RENDERFEATURE_POSTPROCESS
,
93 explicit IPlayer(IPlayerCallback
& callback
) : m_callback(callback
) {}
94 virtual ~IPlayer() = default;
95 virtual bool Initialize(TiXmlElement
* pConfig
) { return true; }
96 virtual bool OpenFile(const CFileItem
& file
, const CPlayerOptions
& options
){ return false;}
97 virtual bool QueueNextFile(const CFileItem
&file
) { return false; }
98 virtual void OnNothingToQueueNotify() {}
99 virtual bool CloseFile(bool reopen
= false) = 0;
100 virtual bool IsPlaying() const { return false;}
101 virtual bool CanPause() const { return true; }
102 virtual void Pause() = 0;
103 virtual bool HasVideo() const = 0;
104 virtual bool HasAudio() const = 0;
105 virtual bool HasGame() const { return false; }
106 virtual bool HasRDS() const { return false; }
107 virtual bool HasID3() const { return false; }
108 virtual bool IsPassthrough() const { return false;}
109 virtual bool CanSeek() const { return true; }
110 virtual void Seek(bool bPlus
= true, bool bLargeStep
= false, bool bChapterOverride
= false) = 0;
111 virtual bool SeekScene(Direction seekDirection
) { return false; }
112 virtual void SeekPercentage(float fPercent
= 0){}
113 virtual float GetCachePercentage() const { return 0; }
114 virtual void SetMute(bool bOnOff
){}
115 virtual void SetVolume(float volume
){}
116 virtual void SetDynamicRangeCompression(long drc
){}
118 virtual void SetAVDelay(float fValue
= 0.0f
) {}
119 virtual float GetAVDelay() { return 0.0f
; }
121 virtual void SetSubTitleDelay(float fValue
= 0.0f
) {}
122 virtual float GetSubTitleDelay() { return 0.0f
; }
123 virtual int GetSubtitleCount() const { return 0; }
124 virtual int GetSubtitle() { return -1; }
125 virtual void GetSubtitleStreamInfo(int index
, SubtitleStreamInfo
& info
) const {}
126 virtual void SetSubtitle(int iStream
) {}
127 virtual bool GetSubtitleVisible() const { return false; }
128 virtual void SetSubtitleVisible(bool bVisible
) {}
131 * \brief Set the subtitle vertical position,
132 * it depends on current screen resolution
133 * \param value The subtitle position in pixels
134 * \param save If true, the value will be saved to resolution info
136 virtual void SetSubtitleVerticalPosition(int value
, bool save
) {}
138 /** \brief Adds the subtitle(s) provided by the given file to the available player streams
139 * and actives the first of the added stream(s). E.g., vob subs can contain multiple streams.
140 * \param[in] strSubPath The full path of the subtitle file.
142 virtual void AddSubtitle(const std::string
& strSubPath
) {}
144 virtual int GetAudioStreamCount() const { return 0; }
145 virtual int GetAudioStream() { return -1; }
146 virtual void SetAudioStream(int iStream
) {}
147 virtual void GetAudioStreamInfo(int index
, AudioStreamInfo
& info
) const {}
149 virtual int GetVideoStream() const { return -1; }
150 virtual int GetVideoStreamCount() const { return 0; }
151 virtual void GetVideoStreamInfo(int streamId
, VideoStreamInfo
& info
) const {}
152 virtual void SetVideoStream(int iStream
) {}
154 virtual int GetPrograms(std::vector
<ProgramInfo
>& programs
) { return 0; }
155 virtual void SetProgram(int progId
) {}
156 virtual int GetProgramsCount() const { return 0; }
158 virtual bool HasTeletextCache() const { return false; }
159 virtual std::shared_ptr
<TextCacheStruct_t
> GetTeletextCache() { return nullptr; }
160 virtual void LoadPage(int p
, int sp
, unsigned char* buffer
) {}
162 virtual int GetChapterCount() const { return 0; }
163 virtual int GetChapter() const { return -1; }
164 virtual void GetChapterName(std::string
& strChapterName
, int chapterIdx
= -1) const {}
165 virtual int64_t GetChapterPos(int chapterIdx
= -1) const { return 0; }
166 virtual int SeekChapter(int iChapter
) { return -1; }
167 // virtual bool GetChapterInfo(int chapter, SChapterInfo &info) { return false; }
169 virtual void SeekTime(int64_t iTime
= 0) {}
171 \brief seek relative to current time, returns false if not implemented by player
172 \param iTime The time in milliseconds to seek. A positive value will seek forward, a negative backward.
173 \return True if the player supports relative seeking, otherwise false
175 virtual bool SeekTimeRelative(int64_t iTime
) { return false; }
178 \brief Sets the current time. This
179 can be used for injecting the current time.
180 This is not to be confused with a seek. It just
181 can be used if endless streams contain multiple
182 tracks in reality (like with airtunes)
184 virtual void SetTime(int64_t time
) { }
187 \brief Set the total time in milliseconds
188 this can be used for injecting the duration in case
189 its not available in the underlaying decoder (airtunes for example)
191 virtual void SetTotalTime(int64_t time
) { }
192 virtual void SetSpeed(float speed
) = 0;
193 virtual void SetTempo(float tempo
) {}
194 virtual bool SupportsTempo() const { return false; }
195 virtual void FrameAdvance(int frames
) {}
197 //Returns true if not playback (paused or stopped being filled)
198 virtual bool IsCaching() const { return false; }
199 //Cache filled in Percent
200 virtual int GetCacheLevel() const { return -1; }
202 virtual bool IsInMenu() const { return false; }
205 * \brief Get the supported menu type
206 * \return The supported menu type
208 virtual MenuType
GetSupportedMenuType() const { return MenuType::NONE
; }
210 virtual bool OnAction(const CAction
& action
) { return false; }
212 //returns a state that is needed for resuming from a specific time
213 virtual std::string
GetPlayerState() { return ""; }
214 virtual bool SetPlayerState(const std::string
& state
) { return false; }
217 * \brief Define the audio capabilities of the player
219 virtual void GetAudioCapabilities(std::vector
<IPlayerAudioCaps
>& caps
) const
221 caps
.assign(1, IPlayerAudioCaps::ALL
);
225 * \brief Define the subtitle capabilities of the player
227 virtual void GetSubtitleCapabilities(std::vector
<IPlayerSubtitleCaps
>& caps
) const
229 caps
.assign(1, IPlayerSubtitleCaps::ALL
);
233 \brief hook into render loop of render thread
235 virtual void Render(bool clear
, uint32_t alpha
= 255, bool gui
= true) {}
236 virtual void FlushRenderer() {}
237 virtual void SetRenderViewMode(int mode
, float zoom
, float par
, float shift
, bool stretch
) {}
238 virtual float GetRenderAspectRatio() const { return 1.0; }
239 virtual void TriggerUpdateResolution() {}
240 virtual bool IsRenderingVideo() const { return false; }
241 virtual void GetRects(CRect
& source
, CRect
& dest
, CRect
& view
) const
247 virtual unsigned int GetOrientation() const { return 0; }
248 virtual bool Supports(EINTERLACEMETHOD method
) const { return false; }
249 virtual EINTERLACEMETHOD
GetDeinterlacingMethodDefault() const
251 return EINTERLACEMETHOD::VS_INTERLACEMETHOD_NONE
;
253 virtual bool Supports(ESCALINGMETHOD method
) const { return false; }
254 virtual bool Supports(ERENDERFEATURE feature
) const { return false; }
256 virtual unsigned int RenderCaptureAlloc() { return 0; }
257 virtual void RenderCaptureRelease(unsigned int captureId
) {}
258 virtual void RenderCapture(unsigned int captureId
,
264 virtual bool RenderCaptureGetPixels(unsigned int captureId
,
272 // video and audio settings
273 virtual CVideoSettings
GetVideoSettings() const { return CVideoSettings(); }
274 virtual void SetVideoSettings(CVideoSettings
& settings
) {}
277 * \brief Check if any players are playing a game
279 * \return True if at least one player has an input device attached to the
280 * game, false otherwise
282 virtual bool HasGameAgent() const { return false; }
288 IPlayerCallback
& m_callback
;