VTB: release CVBuffer after it actually has been rendered
[xbmc.git] / xbmc / ApplicationPlayer.h
bloba0567a67273319c287bfdf7eba1f056518e9a193
1 #pragma once
3 /*
4 * Copyright (C) 2005-2013 Team XBMC
5 * http://xbmc.org
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.
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 <memory>
24 #include <string>
25 #include <vector>
27 #include "threads/CriticalSection.h"
28 #include "threads/SystemClock.h"
29 #include "guilib/Resolution.h"
30 #include "cores/IPlayer.h"
32 typedef enum
34 PLAYBACK_CANCELED = -1,
35 PLAYBACK_FAIL = 0,
36 PLAYBACK_OK = 1,
37 } PlayBackRet;
39 namespace PVR
41 class CPVRChannel;
42 typedef std::shared_ptr<PVR::CPVRChannel> CPVRChannelPtr;
45 class CAction;
46 class CPlayerOptions;
47 class CStreamDetails;
49 struct SPlayerAudioStreamInfo;
50 struct SPlayerVideoStreamInfo;
51 struct SPlayerSubtitleStreamInfo;
52 struct TextCacheStruct_t;
54 class CApplicationPlayer
56 std::shared_ptr<IPlayer> m_pPlayer;
57 unsigned int m_iPlayerOPSeq; // used to detect whether an OpenFile request on player is canceled by us.
59 CCriticalSection m_player_lock;
61 // cache player state
62 XbmcThreads::EndTime m_audioStreamUpdate;
63 int m_iAudioStream;
64 XbmcThreads::EndTime m_videoStreamUpdate;
65 int m_iVideoStream;
66 XbmcThreads::EndTime m_subtitleStreamUpdate;
67 int m_iSubtitleStream;
68 XbmcThreads::EndTime m_speedUpdate;
69 float m_fPlaySpeed;
71 public:
72 CApplicationPlayer();
74 // player management
75 void CloseFile(bool reopen = false);
76 void ClosePlayer();
77 void ClosePlayerGapless(std::string &playername);
78 void CreatePlayer(const std::string &player, IPlayerCallback& callback);
79 std::string GetCurrentPlayer();
80 float GetPlaySpeed();
81 bool HasPlayer() const;
82 PlayBackRet OpenFile(const CFileItem& item, const CPlayerOptions& options);
83 void SetPlaySpeed(float speed);
85 void FrameMove();
86 void Render(bool clear, uint32_t alpha = 255, bool gui = true);
87 void FlushRenderer();
88 void SetRenderViewMode(int mode);
89 float GetRenderAspectRatio();
90 void TriggerUpdateResolution();
91 bool IsRenderingVideo();
92 bool IsRenderingGuiLayer();
93 bool IsRenderingVideoLayer();
94 bool Supports(EINTERLACEMETHOD method);
95 EINTERLACEMETHOD GetDeinterlacingMethodDefault();
96 bool Supports(ESCALINGMETHOD method);
97 bool Supports(ERENDERFEATURE feature);
98 unsigned int RenderCaptureAlloc();
99 void RenderCapture(unsigned int captureId, unsigned int width, unsigned int height, int flags = 0);
100 void RenderCaptureRelease(unsigned int captureId);
101 bool RenderCaptureGetPixels(unsigned int captureId, unsigned int millis, uint8_t *buffer, unsigned int size);
102 bool IsExternalPlaying();
104 // proxy calls
105 void AddSubtitle(const std::string& strSubPath);
106 bool CanPause();
107 bool CanRecord();
108 bool CanSeek();
109 void DoAudioWork();
110 void GetAudioCapabilities(std::vector<int> &audioCaps);
111 int GetAudioStream();
112 int GetAudioStreamCount();
113 void GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info);
114 int GetCacheLevel() const;
115 float GetCachePercentage() const;
116 int GetChapterCount();
117 int GetChapter();
118 void GetChapterName(std::string& strChapterName, int chapterIdx=-1);
119 int64_t GetChapterPos(int chapterIdx=-1);
120 float GetPercentage() const;
121 std::string GetPlayerState();
122 std::string GetPlayingTitle();
123 int GetPreferredPlaylist() const;
124 bool GetStreamDetails(CStreamDetails &details);
125 int GetSubtitle();
126 void GetSubtitleCapabilities(std::vector<int> &subCaps);
127 int GetSubtitleCount();
128 void GetSubtitleStreamInfo(int index, SPlayerSubtitleStreamInfo &info);
129 bool GetSubtitleVisible();
130 TextCacheStruct_t* GetTeletextCache();
131 std::string GetRadioText(unsigned int line);
132 int64_t GetTime() const;
133 int64_t GetTotalTime() const;
134 int GetVideoStream();
135 int GetVideoStreamCount();
136 void GetVideoStreamInfo(int streamId, SPlayerVideoStreamInfo &info);
137 bool HasAudio() const;
138 bool HasMenu() const;
139 bool HasVideo() const;
140 bool HasRDS() const;
141 bool IsCaching() const;
142 bool IsInMenu() const;
143 bool IsPaused();
144 bool IsPausedPlayback();
145 bool IsPassthrough() const;
146 bool IsPlaying() const;
147 bool IsPlayingAudio() const;
148 bool IsPlayingVideo() const;
149 bool IsPlayingRDS() const;
150 bool IsRecording() const;
151 void LoadPage(int p, int sp, unsigned char* buffer);
152 bool OnAction(const CAction &action);
153 void OnNothingToQueueNotify();
154 void Pause();
155 bool QueueNextFile(const CFileItem &file);
156 bool Record(bool bOnOff);
157 void Seek(bool bPlus = true, bool bLargeStep = false, bool bChapterOverride = false);
158 int SeekChapter(int iChapter);
159 void SeekPercentage(float fPercent = 0);
160 bool SeekScene(bool bPlus = true);
161 void SeekTime(int64_t iTime = 0);
162 void SeekTimeRelative(int64_t iTime = 0);
163 void SetAudioStream(int iStream);
164 void SetAVDelay(float fValue = 0.0f);
165 void SetDynamicRangeCompression(long drc);
166 void SetMute(bool bOnOff);
167 bool SetPlayerState(const std::string& state);
168 void SetSubtitle(int iStream);
169 void SetSubTitleDelay(float fValue = 0.0f);
170 void SetSubtitleVisible(bool bVisible);
171 void SetTime(int64_t time);
172 void SetTotalTime(int64_t time);
173 void SetVideoStream(int iStream);
174 void SetVolume(float volume);
175 bool SwitchChannel(const PVR::CPVRChannelPtr &channel);
176 void SetSpeed(float speed);
177 bool SupportsTempo();
179 protected:
180 std::shared_ptr<IPlayer> GetInternal() const;