Merge pull request #2566 from louis89/master
[vuplus_xbmc] / xbmc / ApplicationPlayer.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 <boost/shared_ptr.hpp>
24 #include "threads/SingleLock.h"
25 #include "cores/playercorefactory/PlayerCoreFactory.h"
26
27 typedef enum
28 {
29   PLAYBACK_CANCELED = -1,
30   PLAYBACK_FAIL = 0,
31   PLAYBACK_OK = 1,
32 } PlayBackRet;
33
34 namespace PVR
35 {
36   class CPVRChannel;
37 }
38
39 class IAudioCallback;
40 class CAction;
41 class CPlayerOptions;
42 class CStreamDetails;
43
44 struct SPlayerAudioStreamInfo;
45 struct SPlayerVideoStreamInfo;
46 struct SPlayerSubtitleStreamInfo;
47 struct TextCacheStruct_t;
48
49 class CApplicationPlayer
50 {
51   boost::shared_ptr<IPlayer> m_pPlayer;
52   unsigned int m_iPlayerOPSeq;  // used to detect whether an OpenFile request on player is canceled by us.
53   PLAYERCOREID m_eCurrentPlayer;
54
55   CCriticalSection  m_player_lock;
56   
57 public:
58   CApplicationPlayer();
59
60   int m_iPlaySpeed;
61
62   // player management
63   void CloseFile();
64   void ClosePlayer();
65   void ClosePlayerGapless(PLAYERCOREID newCore);
66   void CreatePlayer(PLAYERCOREID newCore, IPlayerCallback& callback);
67   PLAYERCOREID GetCurrentPlayer() const { return m_eCurrentPlayer; }
68   boost::shared_ptr<IPlayer> GetInternal() const;
69   int  GetPlaySpeed() const;
70   bool HasPlayer() const;
71   PlayBackRet OpenFile(const CFileItem& item, const CPlayerOptions& options);
72   void ResetPlayer() { m_eCurrentPlayer = EPC_NONE; }
73   void SetPlaySpeed(int iSpeed, bool bApplicationMuted);
74
75   // proxy calls
76   int   AddSubtitle(const CStdString& strSubPath);
77   bool  CanPause();
78   bool  CanRecord();
79   bool  CanSeek();
80   bool  ControlsVolume() const;
81   void  DoAudioWork();
82   void  GetAudioCapabilities(std::vector<int> &audioCaps);
83   void  GetAudioInfo( CStdString& strAudioInfo);
84   int   GetAudioStream();
85   int   GetAudioStreamCount();
86   void  GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info);
87   int   GetBitsPerSample();
88   int   GetCacheLevel() const;
89   float GetCachePercentage() const;
90   int   GetChapterCount();
91   int   GetChapter();  
92   void  GetChapterName(CStdString& strChapterName);
93   void  GetDeinterlaceMethods(std::vector<int> &deinterlaceMethods);
94   void  GetDeinterlaceModes(std::vector<int> &deinterlaceModes);
95   bool  GetCurrentSubtitle(CStdString& strSubtitle);
96   void  GetGeneralInfo( CStdString& strVideoInfo);
97   float GetPercentage() const;
98   int   GetPictureHeight();
99   int   GetPictureWidth();
100   CStdString GetPlayerState();
101   CStdString GetPlayingTitle();
102   void  GetRenderFeatures(std::vector<int> &renderFeatures);
103   int   GetSampleRate();
104   void  GetScalingMethods(std::vector<int> &scalingMethods);
105   bool  GetStreamDetails(CStreamDetails &details);
106   int   GetSubtitle();
107   void  GetSubtitleCapabilities(std::vector<int> &subCaps);
108   int   GetSubtitleCount();
109   void  GetSubtitleStreamInfo(int index, SPlayerSubtitleStreamInfo &info);
110   bool  GetSubtitleVisible();
111   TextCacheStruct_t* GetTeletextCache();
112   int64_t GetTime() const;
113   int64_t GetTotalTime() const;
114   void  GetVideoInfo( CStdString& strVideoInfo);
115   void  GetVideoStreamInfo(SPlayerVideoStreamInfo &info);
116   bool  HasAudio() const;
117   bool  HasMenu() const;
118   bool  HasVideo() const;
119   bool  IsCaching() const;
120   bool  IsInMenu() const;
121   bool  IsPaused() const;
122   bool  IsPausedPlayback() const;
123   bool  IsPassthrough() const;
124   bool  IsPlaying() const;
125   bool  IsPlayingAudio() const;
126   bool  IsPlayingVideo() const;
127   bool  IsRecording() const;
128   void  LoadPage(int p, int sp, unsigned char* buffer);
129   bool  OnAction(const CAction &action);
130   void  OnNothingToQueueNotify();
131   void  Pause();
132   bool  QueueNextFile(const CFileItem &file);
133   bool  Record(bool bOnOff);
134   void  RegisterAudioCallback(IAudioCallback* pCallback);
135   void  Seek(bool bPlus = true, bool bLargeStep = false, bool bChapterOverride = false);
136   int   SeekChapter(int iChapter);
137   void  SeekPercentage(float fPercent = 0);
138   bool  SeekScene(bool bPlus = true);
139   void  SeekTime(int64_t iTime = 0);
140   void  SetAudioStream(int iStream);
141   void  SetAVDelay(float fValue = 0.0f);
142   void  SetDynamicRangeCompression(long drc);
143   void  SetMute(bool bOnOff);
144   bool  SetPlayerState(CStdString state);
145   void  SetSubtitle(int iStream);
146   void  SetSubTitleDelay(float fValue = 0.0f);
147   void  SetSubtitleVisible(bool bVisible);
148   void  SetVolume(float volume);
149   bool  SwitchChannel(const PVR::CPVRChannel &channel);
150   void  ToFFRW(int iSpeed = 0);
151   void  UnRegisterAudioCallback();
152 };