forked from zillevdr/vdr-plugin-softhddevice-drm
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsofthddevice-drm-gles.cpp
More file actions
465 lines (409 loc) · 12.3 KB
/
Copy pathsofthddevice-drm-gles.cpp
File metadata and controls
465 lines (409 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
// SPDX-License-Identifier: AGPL-3.0-or-later
/**
* @file softhddevice-drm-gles.cpp
* Main Plugin Interface
*
* This file defines cPluginSoftHdDevice, which is the main class
* for initializing the plugin itselft.
*
* @copyright 2011, 2015 by Johns. All Rights Reserved.
* @copyright 2018 zille. All Rights Reserved.
* @copyright 2025 - 2026 by Andreas Baierl. All Rights Reserved.
*
* @license{AGPL-3.0-or-later}
*/
#include <libintl.h>
#include <vdr/player.h>
#include <vdr/plugin.h>
#include "logger.h"
#include "softhddevice-drm-gles.h"
#include "config.h"
#include "mediaplayer.h"
#include "softhddevice.h"
#include "softhdmenu.h"
#include "softhdsetupmenu.h"
/**
* @addtogroup plugin
* @{
*/
/*****************************************************************************
* Static variables
****************************************************************************/
static const char *const VERSION = "1.6.8" GIT_DESCRIBE; ///< vdr-plugin version number
///< Makefile extracts the version number for generating the file name
///< for the distribution archive.
static const char *const DESCRIPTION = trNOOP("A software and GPU emulated HD device");
///< vdr-plugin description.
static const char *const MAINMENUENTRY = trNOOP("Softhddevice");
///< what is displayed in the main menu entry
cSoftHdMenu *cSoftHdMenu::pSoftHdMenu = NULL; ///< Main Menu Instance
/** @} */
/*****************************************************************************
* cPluginSoftHdDevice
****************************************************************************/
/**
* cPluginSoftHdDevice constructor
*
* Initialize any member variables here.
*
* @note DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
* VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
*
* We only create the config and the device itself, because Plugin->SetupParse
* is done next and that one needs config to be available.
* SetupParse must not access any other objects!
*/
cPluginSoftHdDevice::cPluginSoftHdDevice(void)
{
m_pConfig = new cSoftHdConfig();
m_pDevice = new cSoftHdDevice(m_pConfig); // no need to delete m_pDevice, because VDR does it for us
}
/**
* cPluginSoftHdDevice destructor
*
* Clean up after yourself!
*/
cPluginSoftHdDevice::~cPluginSoftHdDevice(void)
{
delete m_pConfig;
}
/**
* Return plugin version number
*
* @return the version number as constant string
*/
const char *cPluginSoftHdDevice::Version(void)
{
return VERSION;
}
/**
* Return plugin short description
*
* @return a short description as constant string
*/
const char *cPluginSoftHdDevice::Description(void)
{
return tr(DESCRIPTION);
}
/**
* Return a string that describes all known command line options
*
* @return the command line help as constant string
*/
const char *cPluginSoftHdDevice::CommandLineHelp(void)
{
return " -a device\taudio device (e.g. alsa: hw:0,0)\n"
" -c channel\taudio mixer channel name (e.g. PCM)\n"
" -o device\tdrm device (e.g. /dev/dri/card0)\n"
" -d resolution\tdisplay resolution (e.g. 1920x1080@50)\n"
" -g resolution\tosd resolution (e.g. 1920x1080)\n"
" -D start in detached state\n"
" -w workaround\tenable/disable workarounds\n"
#ifdef USE_GLES
"\tdisable-ogl-osd disable openGL osd\n"
#endif
"\tdisable-pip disable picture-in-picture\n"
"\n";
}
/**
* Process the command line arguments.
*
* @param argc number of arguments
* @param argv arguments vector
*/
bool cPluginSoftHdDevice::ProcessArgs(int argc, char *argv[])
{
// LOGDEBUG("plugin: %s:", __FUNCTION__);
//
// Parse arguments.
//
for (;;) {
#ifdef USE_GLES
switch (getopt(argc, argv, "-a:c:o:x:d:g:Dw:")) {
#else
switch (getopt(argc, argv, "-a:c:o:x:d:g:D")) {
#endif
case 'a': // audio device for pcm
m_pConfig->ConfigAudioPCMDevice = optarg;
continue;
case 'c': // channel of audio mixer
m_pConfig->ConfigAudioMixerChannel = optarg;
continue;
case 'o': // set display drm device
m_pConfig->ConfigDrmDevice = optarg;
continue;
case 'x': // set display drm connector
m_pConfig->ConfigDrmConnector = optarg;
continue;
case 'd': { // set display output
m_pConfig->ConfigDisplayResolution = optarg;
int w = 0;
int h = 0;
double rate = 0.0;
if (sscanf(m_pConfig->ConfigDisplayResolution, "%dx%d@%lf", &w, &h, &rate) != 3) {
fprintf(stderr, gettext("Wring argument for option '%c'\n"), optopt);
return 0;
}
m_pConfig->UserSetDrmMode = { w, h, rate, false };
continue;
}
case 'g': // set osd (rendering) size
m_pConfig->ConfigOsdResolution = optarg;
continue;
case 'D': // start plugin in detached state
m_pDevice->SetStartDetached();
continue;
case 'w': // workarounds
if (!strcasecmp("disable-pip", optarg)) {
m_pDevice->SetDisablePip();
#ifdef USE_GLES
} else if (!strcasecmp("disable-ogl-osd", optarg)) {
m_pDevice->SetDisableOglOsd();
#endif
} else {
fprintf(stderr, gettext("Workaround '%s' unsupported\n"),
optarg);
return 0;
}
continue;
case EOF:
break;
case '-':
fprintf(stderr, gettext("We need no long options\n"));
return 0;
case ':':
fprintf(stderr, gettext("Missing argument for option '%c'\n"), optopt);
return 0;
default:
fprintf(stderr, gettext("Unknown option '%c'\n"), optopt);
return 0;
}
break;
}
while (optind < argc) {
fprintf(stderr, gettext("Unhandled argument '%s'\n"), argv[optind++]);
}
return 1;
}
/**
* Initializes the DVB devices
*
* Must be called before accessing any DVB functions
*/
bool cPluginSoftHdDevice::Initialize(void)
{
// LOGDEBUG("plugin: %s:", __FUNCTION__);
return m_pDevice->Initialize();
}
/**
* Start any background activities the plugin shall perform
*/
bool cPluginSoftHdDevice::Start(void)
{
// LOGDEBUG("plugin: %s:", __FUNCTION__);
return m_pDevice->Start();
}
/**
* Shutdown plugin
*
* Stop any background activities the plugin is performing
*/
void cPluginSoftHdDevice::Stop(void)
{
//LOGDEBUG("plugin: %s:", __FUNCTION__);
m_pDevice->Stop();
}
/**
* Create main menu entry
*/
const char *cPluginSoftHdDevice::MainMenuEntry(void)
{
//LOGDEBUG("plugin: %s:", __FUNCTION__);
return m_pConfig->ConfigHideMainMenuEntry ? NULL : tr(MAINMENUENTRY);
}
/**
* Perform the action when selected from the main VDR menu
*/
cOsdObject *cPluginSoftHdDevice::MainMenuAction(void)
{
//LOGDEBUG("plugin: %s:", __FUNCTION__);
return new cSoftHdMenu("SoftHdDevice", m_pDevice);
}
/**
* Return our setup menu
*/
cMenuSetupPage *cPluginSoftHdDevice::SetupMenu(void)
{
//LOGDEBUG("plugin: %s:", __FUNCTION__);
return new cMenuSetupSoft(m_pDevice);
}
/*****************************************************************************
* cPluginSoftHdDevice - Setup parameters
****************************************************************************/
/**
* Parse setup parameters
*
* @param name paramter name (case sensetive)
* @param value value as string
*
* @retval true if the parameter is supported
* @retval false if the parameter is unsupported
*/
bool cPluginSoftHdDevice::SetupParse(const char *name, const char *value)
{
return m_pConfig->SetupParse(name, value);
}
/**
* Receive requests or messages
*
* @param id unique identification string that identifies the
* service protocol
* @param data custom data structure
*/
bool cPluginSoftHdDevice::Service(const char *id, void *data)
{
//LOGDEBUG("plugin: %s: id %s", __FUNCTION__, id);
(void)id;
(void)data;
return false;
}
/*****************************************************************************
* cPluginSoftHdDevice - SVDRP
****************************************************************************/
/**
* SVDRP commands help text
*
* @ingroup plugin
*/
static const char *SVDRPHelpText[] = {
"PLAY Url\n" " Play the media from the given url.\n",
"DETA\n" " Detach the plugin.\n",
"ATTA\n" " Attach the plugin.\n",
"STAT\n" " Get attached/detached status.\n"
" ATTACHED -> 910\n"
" DETACHED -> 911\n",
"PION\n" " Enable picture-in-picture.\n",
"PIOF\n" " Disable picture-in-picture.\n",
"PITO\n" " Toggle picture-in-picture.\n",
"PIPU\n" " Pip channel up.\n",
"PIPD\n" " Pip channel down.\n",
"PIPC\n" " Pip swap channels.\n",
"PIPS\n" " Pip switch main stream to pip channel and close pip.\n",
"PIIP\n" " Pip swap positions.\n",
NULL
};
/**
* Return SVDRP commands help pages
*
* return a pointer to a list of help strings for all of the plugin's
* SVDRP commands.
*/
const char **cPluginSoftHdDevice::SVDRPHelpPages(void)
{
return SVDRPHelpText;
}
/**
* Handle SVDRP commands
*
* @param command SVDRP command
* @param option all command arguments
* @param reply_code reply code
*/
cString cPluginSoftHdDevice::SVDRPCommand(const char *command, const char *option, int &reply_code)
{
// mediaplayer
if (!strcasecmp(command, "PLAY")) {
LOGDEBUG2(L_MEDIA, "plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
cControl::Launch(new cSoftHdControl(option, m_pDevice));
return "PLAY url";
}
// attach/detach
if (!strcasecmp(command, "DETA")) {
LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
if (m_pDevice->IsDetached())
return "SoftHdDevice is already detached";
m_pDevice->Detach();
return "Detached SoftHdDevice";
}
if (!strcasecmp(command, "ATTA")) {
LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
if (!m_pDevice->IsDetached())
return "SoftHdDevice is not detached";
m_pDevice->Attach();
return "Attached SoftHdDevice";
}
if (!strcasecmp(command, "STAT")) {
LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
if (!m_pDevice->IsDetached()) {
reply_code = 910;
return "SoftHdDevice is attached";
} else {
reply_code = 911;
return "SoftHdDevice is detached";
}
}
// pip
if (m_pDevice->UsePip()) {
if (!strcasecmp(command, "PION")) {
LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
if (m_pDevice->PipIsEnabled())
return "Pip is already enabled";
m_pDevice->PipEnable();
return "Pip was enabled";
}
if (!strcasecmp(command, "PIOF")) {
LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
if (!m_pDevice->PipIsEnabled())
return "Pip isn't enabled";
m_pDevice->PipDisable();
return "Pip was disabled";
}
if (!strcasecmp(command, "PITO")) {
LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
if (!m_pDevice->PipIsEnabled()) {
m_pDevice->PipEnable();
return "Pip was enabled";
} else {
m_pDevice->PipDisable();
return "Pip was disabled";
}
}
if (!strcasecmp(command, "PIPU")) {
LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
if (!m_pDevice->PipIsEnabled())
return "Pip isn't enabled";
m_pDevice->PipChannelChange(1);
return "Pip channel up";
}
if (!strcasecmp(command, "PIPD")) {
LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
if (!m_pDevice->PipIsEnabled())
return "Pip isn't enabled";
m_pDevice->PipChannelChange(-1);
return "Pip channel down";
}
if (!strcasecmp(command, "PIPC")) {
LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
if (!m_pDevice->PipIsEnabled())
return "Pip isn't enabled";
m_pDevice->PipChannelSwap(false);
return "Pip swap channels";
}
if (!strcasecmp(command, "PIPS")) {
LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
if (!m_pDevice->PipIsEnabled())
return "Pip isn't enabled";
m_pDevice->PipChannelSwap(true);
return "Pip switch main stream to pip channel and close pip";
}
if (!strcasecmp(command, "PIPP")) {
LOGDEBUG("plugin: %s: SVDRPCommand: %s %s", __FUNCTION__, command, option);
if (!m_pDevice->PipIsEnabled())
return "Pip isn't enabled";
m_pDevice->PipSwapPosition();
return "Pip swap position";
}
}
return NULL;
}
VDRPLUGINCREATOR(cPluginSoftHdDevice); // Don't touch this!