vdr-plugin-drmdevice 2.0.0-46418f1
osdprovider.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: AGPL-3.0-or-later
2
18#include "dummyosd.h"
19#include "logger.h"
20#ifdef USE_GLES
21#include "openglosd.h"
22#endif
23#include "device.h"
24#include "softosd.h"
25#include "osdprovider.h"
26
27/*****************************************************************************
28 * OSD provider
29 ****************************************************************************/
30
35 : cOsdProvider(),
36 m_pDevice(device)
37{
38 LOGDEBUG2(L_OSD, "osdprovider: %s:", __FUNCTION__);
39}
40
45{
46 LOGDEBUG2(L_OSD, "osdprovider %s:", __FUNCTION__);
47
50#ifdef USE_GLES
53#endif
54 }
55}
56
67{
68#ifdef USE_GLES
69 if (m_pDevice->IsDetached()) {
70 LOGDEBUG("osdprovider: %s: %d, %d, %d, device detached, using dummy osd", __FUNCTION__, left, top, level);
71 return m_pOsd = new cDummyOsd(left, top, level);
72 }
73
75 LOGDEBUG("osdprovider: %s: %d, %d, %d, OpenGL disabled, using software rendering", __FUNCTION__, left, top, level);
76 return m_pOsd = new cSoftOsd(left, top, level, m_pDevice);
77 }
78
79 if (StartOpenGlThread()) {
80 LOGDEBUG2(L_OSD, "osdprovider: %s: %d, %d, %d, using OpenGL OSD support", __FUNCTION__, left, top, level);
82 }
83
84 LOGDEBUG("osdprovider: %s: %d, %d, %d, OpenGL failed, using software rendering", __FUNCTION__, left, top, 999);
86 return m_pOsd = new cSoftOsd(left, top, 999, m_pDevice);
87#else
88 if (m_pDevice->IsDetached()) {
89 LOGDEBUG("osdprovider: %s: %d, %d, %d, device detached, using dummy osd", __FUNCTION__, left, top, level);
90 return m_pOsd = new cDummyOsd(left, top, level);
91 }
92
93 LOGDEBUG2(L_OSD, "osdprovider: %s: %d, %d, %d", __FUNCTION__, left, top, level);
94 return m_pOsd = new cSoftOsd(left, top, level, m_pDevice);
95#endif
96}
97
98#ifdef USE_GLES
103 // cleanup OpenGL context
106 cDeviceOsdProvider::UpdateOsdSize();
107}
108
114 LOGDEBUG2(L_OPENGL, "osdprovider: %s: OpenGL OSD disabled, OpenGL worker thread NOT started", __FUNCTION__);
115 return false;
116 }
117
118 if (m_pOglThread.get()) {
119 if (m_pOglThread->Active()) {
120 return true;
121 }
122 m_pOglThread.reset();
123 }
125 LOGDEBUG2(L_OPENGL, "osdprovider: %s: Trying to start OpenGL worker thread", __FUNCTION__);
127 wait.Wait();
128
129 if (m_pOglThread->Active()) {
130 LOGINFO("OpenGL worker thread started");
131 return true;
132 }
133
134 LOGDEBUG2(L_OPENGL, "osdprovider: %s: OpenGL worker thread NOT started", __FUNCTION__);
135 return false;
136}
137
142 if (m_pOglThread) {
143 LOGDEBUG2(L_OPENGL, "osdprovider: %s: request stopping OpenGL worker thread", __FUNCTION__);
144 m_pOglThread->RequestStop();
145 }
146}
147
152 if (m_pOglThread) {
153 LOGDEBUG2(L_OPENGL, "osdprovider: %s: stop OpenGL worker thread", __FUNCTION__);
154 m_pOglThread->Stop();
155 }
156 m_pOglThread.reset();
157}
158
163 if (m_pOglThread) {
164 LOGDEBUG2(L_OPENGL, "osdprovider: %s: lock OpenGL worker thread", __FUNCTION__);
165 m_pOglThread->LockOutputFb();
166 return true;
167 }
168
169 return false;
170}
171
176 if (m_pOglThread) {
177 LOGDEBUG2(L_OPENGL, "osdprovider: %s: unlock OpenGL worker thread", __FUNCTION__);
178 m_pOglThread->UnlockOutputFb();
179 }
180}
181
186{
187 if (StartOpenGlThread()) {
188 int imgHandle = m_pOglThread->StoreImage(Image);
189 return imgHandle;
190 }
191 return 0;
192}
193
198 return cOsdProvider::GetImageData(ImageHandle);
199}
200
205{
206 if (StartOpenGlThread())
207 m_pOglThread->DropImageData(imgHandle);
208}
209#endif
virtual ~cDeviceOsdProvider()
Delete the OSD provider and stop the OpenGL thread if running.
void RequestStopOpenGlThread(void)
Initiate a stop of the OpenGL thread without waiting.
virtual void DropImageData(int ImageHandle)
Drop stored image data.
virtual int StoreImageData(const cImage &Image)
Store image data.
void StopOpenGlThread(void)
Stop the OpenGL thread and cancel it if necessary.
cOsd * m_pOsd
pointer to single OSD (currently not really used in cDeviceOsdProvider?)
Definition osdprovider.h:50
void UnlockOpenGlThread(void)
Unlock the OpenGL thread.
virtual cOsd * CreateOsd(int, int, uint)
Create a new OSD.
cDeviceOsdProvider(cOutputDevice *)
Create a new OSD provider.
std::shared_ptr< cOglThread > m_pOglThread
OpenGL OSD thread.
Definition osdprovider.h:53
cOutputDevice * m_pDevice
pointer to the cOutputDevice object
Definition osdprovider.h:51
void OsdSizeChanged(void)
Stop the OpenGL thread, if the osd size changed and update the size.
const cImage * GetImageData(int ImageHandle)
Get stored image data.
bool LockOpenGlThread(void)
Lock the OpenGL thread.
bool StartOpenGlThread(void)
Start the OpenGL thread.
Dummy OSD.
Definition dummyosd.h:61
OpenGL OSD Implementation (GPU accelerated)
Definition openglosd.h:833
OpenGL Commands Processing Thread.
Definition openglosd.h:736
Output Device Implementation.
Definition device.h:72
int MaxSizeGPUImageCache(void)
Get the maximum GPU image cache size.
Definition device.cpp:1125
int OglOsdIsDisabled(void)
Is the OpenGL/ES osd disabled?
Definition device.cpp:1133
bool IsDetached(void) const
Returns true, if the device is detached.
Definition device.cpp:1380
bool IsOsdProviderSet(void) const
Definition device.h:190
void ResetOsdProvider(void)
Definition device.h:189
void SetDisableOglOsd(void)
Disables OpenGL/ES Osd (called from setup menu or conf)
Definition device.cpp:1141
Software Based OSD (CPU)
Definition softosd.h:31
Output Device Header File.
Dummy OSD.
#define LOGDEBUG2
log to LOG_DEBUG and add a prefix
Definition logger.h:48
#define LOGDEBUG
log to LOG_DEBUG
Definition logger.h:46
#define LOGINFO
log to LOG_INFO
Definition logger.h:44
@ L_OSD
osd logs
Definition logger.h:63
@ L_OPENGL
opengl osd logs
Definition logger.h:69
Logger Header File.
OpenGL OSD Header File.
OSD Provider Header File.
Software OSD Header File.