kodi
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 extern "C"
21 {
22 #include <libavutil/pixfmt.h>
23 }
24 
25 class CDataCacheCore;
26 
27 namespace KODI
28 {
29 namespace RETRO
30 {
31 class CRenderBufferManager;
32 class CRenderContext;
33 class CRenderSettings;
34 class CRPBaseRenderer;
35 class CRPProcessInfo;
36 class IRenderBufferPool;
37 
41 using CreateRPProcessControl = std::function<std::unique_ptr<CRPProcessInfo>()>;
42 
47 {
48 public:
49  virtual ~IRendererFactory() = default;
50 
54  virtual std::string RenderSystemName() const = 0;
55 
64  CRenderContext& context,
65  std::shared_ptr<IRenderBufferPool> bufferPool) = 0;
66 
74  virtual RenderBufferPoolVector CreateBufferPools(CRenderContext& context) = 0;
75 };
76 
81 {
82 public:
83  static std::unique_ptr<CRPProcessInfo> CreateInstance();
84  static void RegisterProcessControl(const CreateRPProcessControl& createFunc);
85  static void RegisterRendererFactory(IRendererFactory* factory);
86 
87  virtual ~CRPProcessInfo();
88 
94  const std::string& GetPlatformName() const { return m_platformName; }
95 
103  std::string GetRenderSystemName(IRenderBufferPool* renderBufferPool) const;
104 
114  const CRenderSettings& renderSettings);
115 
119  void SetDataCache(CDataCacheCore* cache);
120 
124  void ResetInfo();
125 
128 
132  CRenderContext& GetRenderContext() { return *m_renderContext; }
133 
137  CRenderBufferManager& GetBufferManager() { return *m_renderBufferManager; }
138 
142  bool HasScalingMethod(SCALINGMETHOD scalingMethod) const;
143 
147  SCALINGMETHOD GetDefaultScalingMethod() const { return m_defaultScalingMethod; }
148 
150 
153  void SetVideoPixelFormat(AVPixelFormat pixFormat);
154  void SetVideoDimensions(int width, int height);
155  void SetVideoFps(float fps);
157 
160  void SetAudioChannels(const std::string& channels);
161  void SetAudioSampleRate(int sampleRate);
162  void SetAudioBitsPerSample(int bitsPerSample);
164 
167  void SetSpeed(float speed);
168  void SetPlayTimes(time_t start, int64_t current, int64_t min, int64_t max);
170 
171 protected:
177  CRPProcessInfo(std::string platformName);
178 
182  static std::vector<SCALINGMETHOD> GetScalingMethods();
183 
184  // Static factories
185  static CreateRPProcessControl m_processControl;
186  static std::vector<std::unique_ptr<IRendererFactory>> m_rendererFactories;
187  static CCriticalSection m_createSection;
188 
189  // Construction parameters
190  const std::string m_platformName;
191 
192  // Info parameters
193  CDataCacheCore* m_dataCache = nullptr;
194 
195  // Rendering parameters
196  std::unique_ptr<CRenderBufferManager> m_renderBufferManager;
197 
198 private:
199  // Rendering parameters
200  std::unique_ptr<CRenderContext> m_renderContext;
201  SCALINGMETHOD m_defaultScalingMethod = SCALINGMETHOD::AUTO;
202 };
203 
204 } // namespace RETRO
205 } // namespace KODI
SCALINGMETHOD GetDefaultScalingMethod() const
Get the default scaling method for this rendering system.
Definition: RPProcessInfo.h:147
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:132
Definition: RenderBufferManager.h:25
Definition: AudioDecoder.h:18
Definition: IRenderBufferPool.h:30
virtual std::string RenderSystemName() const =0
Get a description name of the rendering system.
Rendering factory.
Definition: RPProcessInfo.h:46
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:94
Definition: RPBaseRenderer.h:32
Player process info.
Definition: RPProcessInfo.h:80
Definition: RenderSettings.h:17
CRenderBufferManager & GetBufferManager()
Get the buffer manager that owns the buffer pools.
Definition: RPProcessInfo.h:137
Definition: cache.py:1