11#include "AddonClass.h"
13#include "ServiceBroker.h"
14#include "application/ApplicationComponents.h"
15#include "application/ApplicationPlayer.h"
16#include "commons/Buffer.h"
17#include "rendering/capture/CaptureConvert.h"
18#include "rendering/capture/CaptureHandle.h"
19#include "rendering/capture/CaptureService.h"
29 XBMCCOMMONS_STANDARD_EXCEPTION(RenderCaptureException);
46 std::shared_ptr<KODI::RENDERING::CAPTURE::CCaptureService> m_service;
47 std::unique_ptr<KODI::RENDERING::CAPTURE::CCaptureHandle> m_handle;
48 unsigned int m_width{0};
49 unsigned int m_height{0};
50 std::unique_ptr<uint8_t[]> m_buffer;
56#ifdef DOXYGEN_SHOULD_USE_THIS
69 inline int getWidth() {
return m_width; }
72#ifdef DOXYGEN_SHOULD_USE_THIS
84 inline int getHeight() {
return m_height; }
87#ifdef DOXYGEN_SHOULD_USE_THIS
100 const auto& components = CServiceBroker::GetAppComponents();
101 const auto appPlayer = components.GetComponent<CApplicationPlayer>();
102 return appPlayer->GetRenderAspectRatio();
106#ifdef DOXYGEN_SHOULD_USE_THIS
126#ifdef DOXYGEN_SHOULD_USE_THIS
144 inline XbmcCommons::Buffer
getImage(
unsigned int msecs = 0)
147 if (!GetPixels(msecs))
148 return XbmcCommons::Buffer(0);
150 size_t size = m_width * m_height * 4;
151 return XbmcCommons::Buffer(m_buffer.get(), size);
154#ifdef DOXYGEN_SHOULD_USE_THIS
169 inline void capture(
int width,
int height)
177 m_buffer = std::make_unique<uint8_t[]>(
static_cast<size_t>(m_width) * m_height * 4);
179 m_service = CServiceBroker::GetCaptureService();
183 KODI::RENDERING::CAPTURE::CaptureSpec spec;
184 spec.content = KODI::RENDERING::CAPTURE::CaptureContent::VIDEO;
185 spec.cadence = KODI::RENDERING::CAPTURE::CaptureCadence::CONTINUOUS;
186 spec.width = m_width;
187 spec.height = m_height;
188 m_handle = m_service->Submit(spec);
193 inline bool GetPixels(
unsigned int msec)
197 if (!m_handle->WaitNext(std::chrono::milliseconds(msec ? msec : 1000)))
199 const KODI::RENDERING::CAPTURE::CaptureResult result = m_handle->CopyResult();
202 return KODI::RENDERING::CAPTURE::CaptureCopyBGRA8(result, m_width, m_height,
Definition RenderCapture.h:44
getImage(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
Definition RenderCapture.h:142
getAspectRatio()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getHeight()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getImageFormat()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
Definition RenderCapture.h:118
capture(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
Definition RenderCapture.h:167
getWidth()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...