Merge pull request #4955 from Memphiz/osxfixoptical2
[vuplus_xbmc] / xbmc / cores / IPlayer.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://xbmc.org
6  *
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)
10  *  any later version.
11  *
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.
16  *
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/>.
20  *
21  */
22
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"
28
29 struct TextCacheStruct_t;
30 class TiXmlElement;
31 class CStreamDetails;
32 class CAction;
33
34 namespace PVR
35 {
36   class CPVRChannel;
37 }
38
39 class CPlayerOptions
40 {
41 public:
42   CPlayerOptions()
43   {
44     starttime = 0LL;
45     startpercent = 0LL;
46     identify = false;
47     fullscreen = false;
48     video_only = false;
49   }
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 */
56 };
57
58 class CFileItem;
59
60 enum IPlayerAudioCapabilities
61 {
62   IPC_AUD_ALL,
63   IPC_AUD_OFFSET,
64   IPC_AUD_AMP,
65   IPC_AUD_SELECT_STREAM,
66   IPC_AUD_OUTPUT_STEREO,
67   IPC_AUD_SELECT_OUTPUT
68 };
69
70 enum IPlayerSubtitleCapabilities
71 {
72   IPC_SUBS_ALL,
73   IPC_SUBS_SELECT,
74   IPC_SUBS_EXTERNAL,
75   IPC_SUBS_OFFSET
76 };
77
78 struct SPlayerAudioStreamInfo
79 {
80   int bitrate;
81   int channels;
82   int samplerate;
83   int bitspersample;
84   std::string language;
85   std::string name;
86   std::string audioCodecName;
87
88   SPlayerAudioStreamInfo()
89   {
90     bitrate = 0;
91     channels = 0;
92     samplerate = 0;
93     bitspersample = 0;
94   }
95 };
96
97 struct SPlayerSubtitleStreamInfo
98 {
99   std::string language;
100   std::string name;
101 };
102
103 struct SPlayerVideoStreamInfo
104 {
105   int bitrate;
106   float videoAspectRatio;
107   int height;
108   int width;
109   std::string language;
110   std::string name;
111   std::string videoCodecName;
112   CRect SrcRect;
113   CRect DestRect;
114   std::string stereoMode;
115
116   SPlayerVideoStreamInfo()
117   {
118     bitrate = 0;
119     videoAspectRatio = 1.0f;
120     height = 0;
121     width = 0;
122   }
123 };
124
125 class IPlayer
126 {
127 public:
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;};
160
161   virtual void  SetAVDelay(float fValue = 0.0f) { return; }
162   virtual float GetAVDelay()                    { return 0.0f;};
163
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;};
173
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){};
178
179   virtual TextCacheStruct_t* GetTeletextCache() { return NULL; };
180   virtual void LoadPage(int p, int sp, unsigned char* buffer) {};
181
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; }
187
188   virtual float GetActualFPS() { return 0.0f; };
189   virtual void SeekTime(int64_t iTime = 0){};
190   /*!
191    \brief current time in milliseconds
192    */
193   virtual int64_t GetTime() { return 0; }
194   /*!
195    \brief total time in milliseconds
196    */
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;}
204
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;};
209
210   virtual bool IsInMenu() const {return false;};
211   virtual bool HasMenu() { return false; };
212
213   virtual void DoAudioWork(){};
214   virtual bool OnAction(const CAction &action) { return false; };
215
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;};
219   
220   virtual CStdString GetPlayingTitle() { return ""; };
221
222   virtual bool SwitchChannel(const PVR::CPVRChannel &channel) { return false; }
223
224   /*!
225    \brief If the player uses bypass mode, define its rendering capabilities
226    */
227   virtual void GetRenderFeatures(std::vector<int> &renderFeatures) {};
228   /*!
229    \brief If the player uses bypass mode, define its deinterlace algorithms
230    */
231   virtual void GetDeinterlaceMethods(std::vector<int> &deinterlaceMethods) {};
232   /*!
233    \brief If the player uses bypass mode, define how deinterlace is set
234    */
235   virtual void GetDeinterlaceModes(std::vector<int> &deinterlaceModes) {};
236   /*!
237    \brief If the player uses bypass mode, define its scaling capabilities
238    */
239   virtual void GetScalingMethods(std::vector<int> &scalingMethods) {};
240   /*!
241    \brief define the audio capabilities of the player (default=all)
242    */
243
244   virtual void GetAudioCapabilities(std::vector<int> &audioCaps) { audioCaps.assign(1,IPC_AUD_ALL); };
245   /*!
246    \brief define the subtitle capabilities of the player
247    */
248   virtual void GetSubtitleCapabilities(std::vector<int> &subCaps) { subCaps.assign(1,IPC_SUBS_ALL); };
249
250 protected:
251   IPlayerCallback& m_callback;
252 };