4 * Copyright (C) 2005-2013 Team XBMC
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with XBMC; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
23 #include "system.h" // until we get sane int types used here
24 #include "IAudioCallback.h"
25 #include "IPlayerCallback.h"
26 #include "utils/StdString.h"
27 #include "guilib/Geometry.h"
29 struct TextCacheStruct_t;
50 double starttime; /* start time in seconds */
51 double startpercent; /* start time in percent */
52 bool identify; /* identify mode, used for checking format and length of a file */
53 CStdString state; /* potential playerstate to restore to */
54 bool fullscreen; /* player is allowed to switch to fullscreen */
55 bool video_only; /* player is not allowed to play audio streams, video streams only */
60 enum IPlayerAudioCapabilities
65 IPC_AUD_SELECT_STREAM,
66 IPC_AUD_OUTPUT_STEREO,
70 enum IPlayerSubtitleCapabilities
78 struct SPlayerAudioStreamInfo
86 std::string audioCodecName;
88 SPlayerAudioStreamInfo()
97 struct SPlayerSubtitleStreamInfo
103 struct SPlayerVideoStreamInfo
106 float videoAspectRatio;
109 std::string language;
111 std::string videoCodecName;
114 std::string stereoMode;
116 SPlayerVideoStreamInfo()
119 videoAspectRatio = 1.0f;
128 IPlayer(IPlayerCallback& callback): m_callback(callback){};
129 virtual ~IPlayer(){};
130 virtual bool Initialize(TiXmlElement* pConfig) { return true; };
131 virtual void RegisterAudioCallback(IAudioCallback* pCallback) {};
132 virtual void UnRegisterAudioCallback() {};
133 virtual bool OpenFile(const CFileItem& file, const CPlayerOptions& options){ return false;}
134 virtual bool QueueNextFile(const CFileItem &file) { return false; }
135 virtual void OnNothingToQueueNotify() {}
136 virtual bool CloseFile(bool reopen = false) = 0;
137 virtual bool IsPlaying() const { return false;}
138 virtual bool CanPause() { return true; };
139 virtual void Pause() = 0;
140 virtual bool IsPaused() const = 0;
141 virtual bool HasVideo() const = 0;
142 virtual bool HasAudio() const = 0;
143 virtual bool IsPassthrough() const { return false;}
144 virtual bool CanSeek() {return true;}
145 virtual void Seek(bool bPlus = true, bool bLargeStep = false, bool bChapterOverride = false) = 0;
146 virtual bool SeekScene(bool bPlus = true) {return false;}
147 virtual void SeekPercentage(float fPercent = 0){}
148 virtual float GetPercentage(){ return 0;}
149 virtual float GetCachePercentage(){ return 0;}
150 virtual void SetMute(bool bOnOff){}
151 virtual void SetVolume(float volume){}
152 virtual bool ControlsVolume(){ return false;}
153 virtual void SetDynamicRangeCompression(long drc){}
154 virtual void GetAudioInfo( CStdString& strAudioInfo) = 0;
155 virtual void GetVideoInfo( CStdString& strVideoInfo) = 0;
156 virtual void GetGeneralInfo( CStdString& strVideoInfo) = 0;
157 virtual bool CanRecord() { return false;};
158 virtual bool IsRecording() { return false;};
159 virtual bool Record(bool bOnOff) { return false;};
161 virtual void SetAVDelay(float fValue = 0.0f) { return; }
162 virtual float GetAVDelay() { return 0.0f;};
164 virtual void SetSubTitleDelay(float fValue = 0.0f){};
165 virtual float GetSubTitleDelay() { return 0.0f; }
166 virtual int GetSubtitleCount() { return 0; }
167 virtual int GetSubtitle() { return -1; }
168 virtual void GetSubtitleStreamInfo(int index, SPlayerSubtitleStreamInfo &info){};
169 virtual void SetSubtitle(int iStream){};
170 virtual bool GetSubtitleVisible(){ return false;};
171 virtual void SetSubtitleVisible(bool bVisible){};
172 virtual int AddSubtitle(const CStdString& strSubPath) {return -1;};
174 virtual int GetAudioStreamCount() { return 0; }
175 virtual int GetAudioStream() { return -1; }
176 virtual void SetAudioStream(int iStream){};
177 virtual void GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info){};
179 virtual TextCacheStruct_t* GetTeletextCache() { return NULL; };
180 virtual void LoadPage(int p, int sp, unsigned char* buffer) {};
182 virtual int GetChapterCount() { return 0; }
183 virtual int GetChapter() { return -1; }
184 virtual void GetChapterName(CStdString& strChapterName) { return; }
185 virtual int SeekChapter(int iChapter) { return -1; }
186 // virtual bool GetChapterInfo(int chapter, SChapterInfo &info) { return false; }
188 virtual float GetActualFPS() { return 0.0f; };
189 virtual void SeekTime(int64_t iTime = 0){};
191 \brief current time in milliseconds
193 virtual int64_t GetTime() { return 0; }
195 \brief total time in milliseconds
197 virtual int64_t GetTotalTime() { return 0; }
198 virtual void GetVideoStreamInfo(SPlayerVideoStreamInfo &info){};
199 virtual int GetSourceBitrate(){ return 0;}
200 virtual bool GetStreamDetails(CStreamDetails &details){ return false;}
201 virtual void ToFFRW(int iSpeed = 0){};
202 // Skip to next track/item inside the current media (if supported).
203 virtual bool SkipNext(){return false;}
205 //Returns true if not playback (paused or stopped beeing filled)
206 virtual bool IsCaching() const {return false;};
207 //Cache filled in Percent
208 virtual int GetCacheLevel() const {return -1;};
210 virtual bool IsInMenu() const {return false;};
211 virtual bool HasMenu() { return false; };
213 virtual void DoAudioWork(){};
214 virtual bool OnAction(const CAction &action) { return false; };
216 //returns a state that is needed for resuming from a specific time
217 virtual CStdString GetPlayerState() { return ""; };
218 virtual bool SetPlayerState(CStdString state) { return false;};
220 virtual CStdString GetPlayingTitle() { return ""; };
222 virtual bool SwitchChannel(const PVR::CPVRChannel &channel) { return false; }
225 \brief If the player uses bypass mode, define its rendering capabilities
227 virtual void GetRenderFeatures(std::vector<int> &renderFeatures) {};
229 \brief If the player uses bypass mode, define its deinterlace algorithms
231 virtual void GetDeinterlaceMethods(std::vector<int> &deinterlaceMethods) {};
233 \brief If the player uses bypass mode, define how deinterlace is set
235 virtual void GetDeinterlaceModes(std::vector<int> &deinterlaceModes) {};
237 \brief If the player uses bypass mode, define its scaling capabilities
239 virtual void GetScalingMethods(std::vector<int> &scalingMethods) {};
241 \brief define the audio capabilities of the player (default=all)
244 virtual void GetAudioCapabilities(std::vector<int> &audioCaps) { audioCaps.assign(1,IPC_AUD_ALL); };
246 \brief define the subtitle capabilities of the player
248 virtual void GetSubtitleCapabilities(std::vector<int> &subCaps) { subCaps.assign(1,IPC_SUBS_ALL); };
251 IPlayerCallback& m_callback;