vdr-plugin-softhddevice-drm-gles 1.6.7
softhddevice-drm-gles.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: AGPL-3.0-or-later
2
17#include <libintl.h>
18
19#include <vdr/player.h>
20#include <vdr/plugin.h>
21
22#include "logger.h"
23
25
26#include "config.h"
27#include "mediaplayer.h"
28#include "softhddevice.h"
29#include "softhdmenu.h"
30#include "softhdsetupmenu.h"
31
37/*****************************************************************************
38 * Static variables
39 ****************************************************************************/
40static const char *const VERSION = "1.6.7" GIT_DESCRIBE;
43
44static const char *const DESCRIPTION = trNOOP("A software and GPU emulated HD device");
46
47static const char *const MAINMENUENTRY = trNOOP("Softhddevice");
49
51
54/*****************************************************************************
55 * cPluginSoftHdDevice
56 ****************************************************************************/
57
71{
73 m_pDevice = new cSoftHdDevice(m_pConfig); // no need to delete m_pDevice, because VDR does it for us
74}
75
85
92{
93 return VERSION;
94}
95
102{
103 return tr(DESCRIPTION);
104}
105
112{
113 return " -a device\taudio device (e.g. alsa: hw:0,0)\n"
114 " -c channel\taudio mixer channel name (e.g. PCM)\n"
115 " -o device\tdrm device (e.g. /dev/dri/card0)\n"
116 " -d resolution\tdisplay resolution (e.g. 1920x1080@50)\n"
117 " -g resolution\tosd resolution (e.g. 1920x1080)\n"
118 " -D start in detached state\n"
119 " -w workaround\tenable/disable workarounds\n"
120#ifdef USE_GLES
121 "\tdisable-ogl-osd disable openGL osd\n"
122#endif
123 "\tdisable-pip disable picture-in-picture\n"
124 "\n";
125}
126
134{
135// LOGDEBUG("plugin: %s:", __FUNCTION__);
136
137 //
138 // Parse arguments.
139 //
140
141 for (;;) {
142#ifdef USE_GLES
143 switch (getopt(argc, argv, "-a:c:o:x:d:g:Dw:")) {
144#else
145 switch (getopt(argc, argv, "-a:c:o:x:d:g:D")) {
146#endif
147 case 'a': // audio device for pcm
149 continue;
150 case 'c': // channel of audio mixer
152 continue;
153 case 'o': // set display drm device
155 continue;
156 case 'x': // set display drm connector
158 continue;
159 case 'd': { // set display output
161 int w = 0;
162 int h = 0;
163 double rate = 0.0;
164 if (sscanf(m_pConfig->ConfigDisplayResolution, "%dx%d@%lf", &w, &h, &rate) != 3) {
165 fprintf(stderr, gettext("Wring argument for option '%c'\n"), optopt);
166 return 0;
167 }
168 m_pConfig->UserSetDrmMode = { w, h, rate, false };
169 continue;
170 }
171 case 'g': // set osd (rendering) size
173 continue;
174 case 'D': // start plugin in detached state
176 continue;
177 case 'w': // workarounds
178 if (!strcasecmp("disable-pip", optarg)) {
180#ifdef USE_GLES
181 } else if (!strcasecmp("disable-ogl-osd", optarg)) {
183#endif
184 } else {
185 fprintf(stderr, gettext("Workaround '%s' unsupported\n"),
186 optarg);
187 return 0;
188 }
189 continue;
190 case EOF:
191 break;
192 case '-':
193 fprintf(stderr, gettext("We need no long options\n"));
194 return 0;
195 case ':':
196 fprintf(stderr, gettext("Missing argument for option '%c'\n"), optopt);
197 return 0;
198 default:
199 fprintf(stderr, gettext("Unknown option '%c'\n"), optopt);
200 return 0;
201 }
202 break;
203 }
204
205 while (optind < argc) {
206 fprintf(stderr, gettext("Unhandled argument '%s'\n"), argv[optind++]);
207 }
208
209 return 1;
210}
211
218{
219// LOGDEBUG("plugin: %s:", __FUNCTION__);
220
221 return m_pDevice->Initialize();
222}
223
228{
229// LOGDEBUG("plugin: %s:", __FUNCTION__);
230
231 return m_pDevice->Start();
232}
233
240{
241 //LOGDEBUG("plugin: %s:", __FUNCTION__);
242
243 m_pDevice->Stop();
244}
245
250{
251 //LOGDEBUG("plugin: %s:", __FUNCTION__);
252
254}
255
260{
261 //LOGDEBUG("plugin: %s:", __FUNCTION__);
262
263 return new cSoftHdMenu("SoftHdDevice", m_pDevice);
264}
265
270{
271 //LOGDEBUG("plugin: %s:", __FUNCTION__);
272
273 return new cMenuSetupSoft(m_pDevice);
274}
275
276/*****************************************************************************
277 * cPluginSoftHdDevice - Setup parameters
278 ****************************************************************************/
279
289bool cPluginSoftHdDevice::SetupParse(const char *name, const char *value)
290{
291 return m_pConfig->SetupParse(name, value);
292}
293
301bool cPluginSoftHdDevice::Service(const char *id, void *data)
302{
303 //LOGDEBUG("plugin: %s: id %s", __FUNCTION__, id);
304 (void)id;
305 (void)data;
306
307 return false;
308}
309
310/*****************************************************************************
311 * cPluginSoftHdDevice - SVDRP
312 ****************************************************************************/
313
319static const char *SVDRPHelpText[] = {
320 "PLAY Url\n" " Play the media from the given url.\n",
321 "DETA\n" " Detach the plugin.\n",
322 "ATTA\n" " Attach the plugin.\n",
323 "STAT\n" " Get attached/detached status.\n"
324 " ATTACHED -> 910\n"
325 " DETACHED -> 911\n",
326 "PION\n" " Enable picture-in-picture.\n",
327 "PIOF\n" " Disable picture-in-picture.\n",
328 "PITO\n" " Toggle picture-in-picture.\n",
329 "PIPU\n" " Pip channel up.\n",
330 "PIPD\n" " Pip channel down.\n",
331 "PIPC\n" " Pip swap channels.\n",
332 "PIPS\n" " Pip switch main stream to pip channel and close pip.\n",
333 "PIIP\n" " Pip swap positions.\n",
334 NULL
335};
336
344{
345 return SVDRPHelpText;
346}
347
356{
357 // mediaplayer
358 if (!strcasecmp(command, "PLAY")) {
359 LOGDEBUG2(L_MEDIA, "plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
360 cControl::Launch(new cSoftHdControl(option, m_pDevice));
361 return "PLAY url";
362 }
363
364 // attach/detach
365 if (!strcasecmp(command, "DETA")) {
366 LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
367 if (m_pDevice->IsDetached())
368 return "SoftHdDevice is already detached";
369
370 m_pDevice->Detach();
371 return "Detached SoftHdDevice";
372 }
373 if (!strcasecmp(command, "ATTA")) {
374 LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
375 if (!m_pDevice->IsDetached())
376 return "SoftHdDevice is not detached";
377
378 m_pDevice->Attach();
379 return "Attached SoftHdDevice";
380 }
381 if (!strcasecmp(command, "STAT")) {
382 LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
383 if (!m_pDevice->IsDetached()) {
384 reply_code = 910;
385 return "SoftHdDevice is attached";
386 } else {
387 reply_code = 911;
388 return "SoftHdDevice is detached";
389 }
390 }
391
392 // pip
393 if (m_pDevice->UsePip()) {
394 if (!strcasecmp(command, "PION")) {
395 LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
396 if (m_pDevice->PipIsEnabled())
397 return "Pip is already enabled";
398
400 return "Pip was enabled";
401 }
402 if (!strcasecmp(command, "PIOF")) {
403 LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
404 if (!m_pDevice->PipIsEnabled())
405 return "Pip isn't enabled";
406
408 return "Pip was disabled";
409 }
410 if (!strcasecmp(command, "PITO")) {
411 LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
412 if (!m_pDevice->PipIsEnabled()) {
414 return "Pip was enabled";
415 } else {
417 return "Pip was disabled";
418 }
419 }
420 if (!strcasecmp(command, "PIPU")) {
421 LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
422 if (!m_pDevice->PipIsEnabled())
423 return "Pip isn't enabled";
424
426 return "Pip channel up";
427 }
428 if (!strcasecmp(command, "PIPD")) {
429 LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
430 if (!m_pDevice->PipIsEnabled())
431 return "Pip isn't enabled";
432
434 return "Pip channel down";
435 }
436 if (!strcasecmp(command, "PIPC")) {
437 LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
438 if (!m_pDevice->PipIsEnabled())
439 return "Pip isn't enabled";
440
442 return "Pip swap channels";
443 }
444 if (!strcasecmp(command, "PIPS")) {
445 LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
446 if (!m_pDevice->PipIsEnabled())
447 return "Pip isn't enabled";
448
450 return "Pip switch main stream to pip channel and close pip";
451 }
452 if (!strcasecmp(command, "PIPP")) {
453 LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
454 if (!m_pDevice->PipIsEnabled())
455 return "Pip isn't enabled";
456
458 return "Pip swap position";
459 }
460 }
461
462 return NULL;
463}
464
Plugin Setup Menu.
virtual void Stop(void)
Shutdown plugin.
virtual const char * CommandLineHelp(void)
Return a string that describes all known command line options.
virtual cMenuSetupPage * SetupMenu(void)
Return our setup menu.
virtual bool SetupParse(const char *, const char *)
Parse setup parameters.
virtual cOsdObject * MainMenuAction(void)
Perform the action when selected from the main VDR menu.
virtual const char * Description(void)
Return plugin short description.
cPluginSoftHdDevice(void)
cPluginSoftHdDevice constructor
virtual bool Start(void)
Start any background activities the plugin shall perform.
virtual const char ** SVDRPHelpPages(void)
Return SVDRP commands help pages.
cSoftHdConfig * m_pConfig
pointer to cSoftHdConfig object
virtual ~cPluginSoftHdDevice(void)
cPluginSoftHdDevice destructor
virtual bool Initialize(void)
Initializes the DVB devices.
cSoftHdDevice * m_pDevice
pointer to cSoftHdDevice object
virtual bool ProcessArgs(int, char *[])
Process the command line arguments.
virtual const char * Version(void)
Return plugin version number.
virtual const char * MainMenuEntry(void)
Create main menu entry.
virtual cString SVDRPCommand(const char *, const char *, int &)
Handle SVDRP commands.
virtual bool Service(const char *, void *=nullptr)
Receive requests or messages.
Plugin Configuration.
Definition config.h:49
const char * ConfigDrmDevice
user requested drm device (e.g. "/dev/dri/card0")
Definition config.h:116
const char * ConfigDisplayResolution
display resolution (syntax: "1920x1080@50")
Definition config.h:117
const char * ConfigAudioPCMDevice
audio PCM device
Definition config.h:113
const char * ConfigAudioMixerChannel
audio mixer channel name
Definition config.h:114
bool SetupParse(const char *, const char *)
Parse setup parameters.
Definition config.cpp:33
const char * ConfigDrmConnector
user requested drm connector (e.g. "HDMI-A-1")
Definition config.h:115
const char * ConfigOsdResolution
osd resolution (syntax: "1920x1080")
Definition config.h:118
sDrmMode UserSetDrmMode
user requested drm mode on the current connector
Definition config.h:134
bool ConfigHideMainMenuEntry
config hide main menu entry
Definition config.h:56
Media Player Control.
Output Device Implementation.
void Stop(void)
Called by VDR when the plugin is stopped.
void PipChannelSwap(bool)
void PipSwapPosition(void)
int Start(void)
Called by VDR when the plugin is started.
bool UsePip(void)
void Detach(void)
Detach the device.
void SetStartDetached(void)
void SetDisablePip(void)
bool IsDetached(void) const
Returns true, if the device is detached.
bool PipIsEnabled(void)
Returns true, if pip is currently enabled.
bool Initialize(void)
Initialize the device.
void SetDisableOglOsd(void)
Disables OpenGL/ES Osd (called from setup menu or conf)
void PipDisable(void)
void PipEnable(void)
void PipChannelChange(int)
void Attach(void)
Attach the device again.
Plugin Main Menu.
Definition softhdmenu.h:43
Plugin Configuration Header File.
#define LOGDEBUG2
log to LOG_DEBUG and add a prefix
Definition logger.h:47
#define LOGDEBUG
log to LOG_DEBUG
Definition logger.h:45
@ L_MEDIA
mediaplayer logs
Definition logger.h:64
static cSoftHdMenu * pSoftHdMenu
Main Menu Instance.
Definition softhdmenu.h:47
static const char *const DESCRIPTION
vdr-plugin description.
static const char * SVDRPHelpText[]
SVDRP commands help text.
static const char *const MAINMENUENTRY
what is displayed in the main menu entry
static const char *const VERSION
vdr-plugin version number Makefile extracts the version number for generating the file name for the d...
Logger Header File.
Mediaplayer Header File.
VDRPLUGINCREATOR(cPluginSoftHdDevice)
Main Plugin Interface Header File.
#define GIT_DESCRIBE
Output Device Header File.
Plugin Main Menu Header File.
Plugin Setup Menu Header File.