xbmc
ProcessInfo.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "cores/VideoPlayer/Buffers/VideoBuffer.h"
12 #include "cores/VideoPlayer/VideoRenderers/RenderInfo.h"
13 #include "cores/VideoSettings.h"
14 #include "threads/CriticalSection.h"
15 
16 #include <atomic>
17 #include <list>
18 #include <map>
19 #include <string>
20 
21 class CProcessInfo;
22 class CDataCacheCore;
23 
24 using CreateProcessControl = CProcessInfo* (*)();
25 
27 {
28 public:
29  static CProcessInfo* CreateInstance();
30  static void RegisterProcessControl(const std::string& id, CreateProcessControl createFunc);
31  virtual ~CProcessInfo() = default;
32  void SetDataCache(CDataCacheCore *cache);
33 
34  // player video
35  void ResetVideoCodecInfo();
36  void SetVideoDecoderName(const std::string &name, bool isHw);
37  std::string GetVideoDecoderName();
38  bool IsVideoHwDecoder();
39  void SetVideoDeintMethod(const std::string &method);
40  std::string GetVideoDeintMethod();
41  void SetVideoPixelFormat(const std::string &pixFormat);
42  std::string GetVideoPixelFormat();
43  void SetVideoStereoMode(const std::string &mode);
44  std::string GetVideoStereoMode();
45  void SetVideoDimensions(int width, int height);
46  void GetVideoDimensions(int &width, int &height);
47  void SetVideoFps(float fps);
48  float GetVideoFps();
49  void SetVideoDAR(float dar);
50  float GetVideoDAR();
51  void SetVideoInterlaced(bool interlaced);
52  bool GetVideoInterlaced();
53  virtual EINTERLACEMETHOD GetFallbackDeintMethod();
54  virtual void SetSwDeinterlacingMethods();
55  void UpdateDeinterlacingMethods(std::list<EINTERLACEMETHOD> &methods);
56  bool Supports(EINTERLACEMETHOD method) const;
57  void SetDeinterlacingMethodDefault(EINTERLACEMETHOD method);
58  EINTERLACEMETHOD GetDeinterlacingMethodDefault() const;
59  CVideoBufferManager& GetVideoBufferManager();
60  std::vector<AVPixelFormat> GetPixFormats();
61  void SetPixFormats(std::vector<AVPixelFormat> &formats);
62 
63  // player audio info
64  void ResetAudioCodecInfo();
65  void SetAudioDecoderName(const std::string &name);
66  std::string GetAudioDecoderName();
67  void SetAudioChannels(const std::string &channels);
68  std::string GetAudioChannels();
69  void SetAudioSampleRate(int sampleRate);
70  int GetAudioSampleRate();
71  void SetAudioBitsPerSample(int bitsPerSample);
72  int GetAudioBitsPerSample();
73  virtual bool AllowDTSHDDecode();
74  virtual bool WantsRawPassthrough() { return false; }
75 
76  // render info
77  void SetRenderClockSync(bool enabled);
78  bool IsRenderClockSync();
79  void UpdateRenderInfo(CRenderInfo &info);
80  void UpdateRenderBuffers(int queued, int discard, int free);
81  void GetRenderBuffers(int &queued, int &discard, int &free);
82  virtual std::vector<AVPixelFormat> GetRenderFormats();
83 
84  // player states
89  void SeekFinished(int64_t offset);
90 
91  void SetStateSeeking(bool active);
92  bool IsSeeking();
93  void SetStateRealtime(bool state);
94  bool IsRealtimeStream();
95  void SetSpeed(float speed);
96  void SetNewSpeed(float speed);
97  float GetNewSpeed();
98  void SetFrameAdvance(bool fa);
99  bool IsFrameAdvance();
100  void SetTempo(float tempo);
101  void SetNewTempo(float tempo);
102  float GetNewTempo();
103  bool IsTempoAllowed(float tempo);
104  virtual float MinTempoPlatform();
105  virtual float MaxTempoPlatform();
106  void SetLevelVQ(int level);
107  int GetLevelVQ();
108  void SetGuiRender(bool gui);
109  bool GetGuiRender();
110  void SetVideoRender(bool video);
111  bool GetVideoRender();
112  unsigned int GetMaxPassthroughOffSyncDuration() const;
113 
114  void SetPlayTimes(time_t start, int64_t current, int64_t min, int64_t max);
115  int64_t GetMaxTime();
116 
117  // settings
118  CVideoSettings GetVideoSettings();
119  void SetVideoSettings(CVideoSettings &settings);
120  CVideoSettingsLocked& GetVideoSettingsLocked();
121 
122 protected:
123  CProcessInfo();
124  static std::map<std::string, CreateProcessControl> m_processControls;
125  CDataCacheCore *m_dataCache = nullptr;
126 
127  // player video info
128  bool m_videoIsHWDecoder;
129  std::string m_videoDecoderName;
130  std::string m_videoDeintMethod;
131  std::string m_videoPixelFormat;
132  std::string m_videoStereoMode;
133  int m_videoWidth;
134  int m_videoHeight;
135  float m_videoFPS;
136  float m_videoDAR;
137  bool m_videoIsInterlaced;
138  std::list<EINTERLACEMETHOD> m_deintMethods;
139  EINTERLACEMETHOD m_deintMethodDefault;
140  mutable CCriticalSection m_videoCodecSection;
141  CVideoBufferManager m_videoBufferManager;
142  std::vector<AVPixelFormat> m_pixFormats;
143 
144  // player audio info
145  std::string m_audioDecoderName;
146  std::string m_audioChannels;
147  int m_audioSampleRate;
148  int m_audioBitsPerSample;
149  CCriticalSection m_audioCodecSection;
150 
151  // render info
152  CCriticalSection m_renderSection;
153  bool m_isClockSync;
154  CRenderInfo m_renderInfo;
155  int m_renderBufQueued = 0;
156  int m_renderBufFree = 0;
157  int m_renderBufDiscard = 0;
158 
159  // player states
160  CCriticalSection m_stateSection;
161  bool m_stateSeeking;
162  std::atomic_int m_levelVQ;
163  std::atomic_bool m_renderGuiLayer;
164  std::atomic_bool m_renderVideoLayer;
165  float m_tempo;
166  float m_newTempo;
167  float m_speed;
168  float m_newSpeed;
169  bool m_frameAdvance;
170  time_t m_startTime;
171  int64_t m_time;
172  int64_t m_timeMax;
173  int64_t m_timeMin;
174  bool m_realTimeStream;
175 
176  // settings
177  CCriticalSection m_settingsSection;
178  CVideoSettings m_videoSettings;
179  std::unique_ptr<CVideoSettingsLocked> m_videoSettingsLocked;
180 };
Definition: RenderInfo.h:19
Definition: VideoBuffer.h:177
Definition: VideoSettings.h:234
Definition: DataCacheCore.h:19
Definition: ProcessInfo.h:26
Definition: settings.py:1
void SeekFinished(int64_t offset)
Notifies that a seek operation has finished.
Definition: ProcessInfo.cpp:470
Definition: VideoSettings.h:194
Definition: cache.py:1