xbmc
RPProcessInfo.h
1 /*
2  * Copyright (C) 2017-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/GameSettings.h"
12 #include "cores/RetroPlayer/RetroPlayerTypes.h"
13 #include "threads/CriticalSection.h"
14 
15 #include <functional>
16 #include <memory>
17 #include <string>
18 #include <vector>
19 
20 #include <libavutil/pixfmt.h>
21 
22 class CDataCacheCore;
23 
24 namespace KODI
25 {
26 namespace RETRO
27 {
28 class CRenderBufferManager;
29 class CRenderContext;
30 class CRenderSettings;
31 class CRPBaseRenderer;
32 class CRPProcessInfo;
33 class IRenderBufferPool;
34 
38 using CreateRPProcessControl = std::function<std::unique_ptr<CRPProcessInfo>()>;
39 
44 {
45 public:
46  virtual ~IRendererFactory() = default;
47 
51  virtual std::string RenderSystemName() const = 0;
52 
61  CRenderContext& context,
62  std::shared_ptr<IRenderBufferPool> bufferPool) = 0;
63 
71  virtual RenderBufferPoolVector CreateBufferPools(CRenderContext& context) = 0;
72 };
73 
78 {
79 public:
80  static std::unique_ptr<CRPProcessInfo> CreateInstance();
81  static void RegisterProcessControl(const CreateRPProcessControl& createFunc);
82  static void RegisterRendererFactory(IRendererFactory* factory);
83 
84  virtual ~CRPProcessInfo();
85 
91  const std::string& GetPlatformName() const { return m_platformName; }
92 
100  std::string GetRenderSystemName(IRenderBufferPool* renderBufferPool) const;
101 
111  const CRenderSettings& renderSettings);
112 
116  void SetDataCache(CDataCacheCore* cache);
117 
121  void ResetInfo();
122 
125 
129  CRenderContext& GetRenderContext() { return *m_renderContext; }
130 
134  CRenderBufferManager& GetBufferManager() { return *m_renderBufferManager; }
135 
139  bool HasScalingMethod(SCALINGMETHOD scalingMethod) const;
140 
144  SCALINGMETHOD GetDefaultScalingMethod() const { return m_defaultScalingMethod; }
145 
147 
150  void SetVideoPixelFormat(AVPixelFormat pixFormat);
151  void SetVideoDimensions(int width, int height);
152  void SetVideoFps(float fps);
154 
157  void SetAudioChannels(const std::string& channels);
158  void SetAudioSampleRate(int sampleRate);
159  void SetAudioBitsPerSample(int bitsPerSample);
161 
164  void SetSpeed(float speed);
165  void SetPlayTimes(time_t start, int64_t current, int64_t min, int64_t max);
167 
168 protected:
174  CRPProcessInfo(std::string platformName);
175 
179  static std::vector<SCALINGMETHOD> GetScalingMethods();
180 
181  // Static factories
182  static CreateRPProcessControl m_processControl;
183  static std::vector<std::unique_ptr<IRendererFactory>> m_rendererFactories;
184  static CCriticalSection m_createSection;
185 
186  // Construction parameters
187  const std::string m_platformName;
188 
189  // Info parameters
190  CDataCacheCore* m_dataCache = nullptr;
191 
192  // Rendering parameters
193  std::unique_ptr<CRenderBufferManager> m_renderBufferManager;
194 
195 private:
196  // Rendering parameters
197  std::unique_ptr<CRenderContext> m_renderContext;
198  SCALINGMETHOD m_defaultScalingMethod = SCALINGMETHOD::AUTO;
199 };
200 
201 } // namespace RETRO
202 } // namespace KODI
SCALINGMETHOD GetDefaultScalingMethod() const
Get the default scaling method for this rendering system.
Definition: RPProcessInfo.h:144
Definition: DataCacheCore.h:19
virtual CRPBaseRenderer * CreateRenderer(const CRenderSettings &settings, CRenderContext &context, std::shared_ptr< IRenderBufferPool > bufferPool)=0
Create a renderer.
CRenderContext & GetRenderContext()
Get the context shared by the rendering system.
Definition: RPProcessInfo.h:129
Definition: RenderBufferManager.h:25
Controller configuration window.
Definition: AudioDecoder.h:18
Definition: IRenderBufferPool.h:28
virtual std::string RenderSystemName() const =0
Get a description name of the rendering system.
Rendering factory.
Definition: RPProcessInfo.h:43
Definition: RenderContext.h:43
Definition: settings.py:1
virtual RenderBufferPoolVector CreateBufferPools(CRenderContext &context)=0
Create buffer pools to manager buffers.
const std::string & GetPlatformName() const
Get the descriptive name of the platform.
Definition: RPProcessInfo.h:91
Definition: RPBaseRenderer.h:32
Player process info.
Definition: RPProcessInfo.h:77
Definition: RenderSettings.h:17
CRenderBufferManager & GetBufferManager()
Get the buffer manager that owns the buffer pools.
Definition: RPProcessInfo.h:134
Definition: cache.py:1