-
Notifications
You must be signed in to change notification settings - Fork 6
/
softhddevice-drm.cpp
1501 lines (1350 loc) · 36.8 KB
/
softhddevice-drm.cpp
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
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
///
/// @file softhddevice.cpp @brief A software HD device plugin for VDR.
///
/// Copyright (c) 2011 - 2015 by Johns. All Rights Reserved.
/// Copyright (c) 2018 zille. All Rights Reserved.
///
/// Contributor(s):
///
/// License: AGPLv3
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
///
/// $Id$
//////////////////////////////////////////////////////////////////////////////
#define __STDC_CONSTANT_MACROS ///< needed for ffmpeg UINT64_C
#include <string>
using std::string;
#include <fstream>
using std::ifstream;
#include <vdr/player.h>
#include <vdr/plugin.h>
#include <vdr/dvbspu.h>
#include "softhddevice-drm.h"
#include "softhddevice_service.h"
#include "mediaplayer.h"
extern "C"
{
#include <libavcodec/avcodec.h>
#include "softhddev.h"
#include "audio.h"
#include "video.h"
#include "codec.h"
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// OSD
//////////////////////////////////////////////////////////////////////////////
/**
** Sets this OSD to be the active one.
**
** @param on true on, false off
**
** @note only needed as workaround for text2skin plugin with
** undrawn areas.
*/
void cSoftOsd::SetActive(bool on)
{
#ifdef OSD_DEBUG
dsyslog("[softhddev] OSD %s: %d level %d\n", __FUNCTION__, on, OsdLevel);
#endif
if (Active() == on) {
return; // already active, no action
}
cOsd::SetActive(on);
if (on) {
Dirty = 1;
// only flush here if there are already bitmaps
if (GetBitmap(0)) {
Flush();
}
} else {
OsdClose();
}
}
/**
** Constructor OSD.
**
** Initializes the OSD with the given coordinates.
**
** @param left x-coordinate of osd on display
** @param top y-coordinate of osd on display
** @param level level of the osd (smallest is shown)
*/
cSoftOsd::cSoftOsd(int left, int top, uint level)
:cOsd(left, top, level)
{
#ifdef OSD_DEBUG
/* FIXME: OsdWidth/OsdHeight not correct!
*/
dsyslog("[softhddev] OSD %s: %dx%d%+d%+d, %d\n", __FUNCTION__, OsdWidth(),
OsdHeight(), left, top, level);
#endif
OsdLevel = level;
}
/**
** OSD Destructor.
**
** Shuts down the OSD.
*/
cSoftOsd::~cSoftOsd(void)
{
#ifdef OSD_DEBUG
dsyslog("[softhddev] OSD %s: level %d\n", __FUNCTION__, OsdLevel);
#endif
SetActive(false);
// done by SetActive: OsdClose();
}
/**
** Set the sub-areas to the given areas
*/
eOsdError cSoftOsd::SetAreas(const tArea * areas, int n)
{
#ifdef OSD_DEBUG
dsyslog("[softhddev] OSD %s: %d areas \n", __FUNCTION__, n);
#endif
// clear old OSD, when new areas are set
if (!IsTrueColor()) {
cBitmap *bitmap;
int i;
for (i = 0; (bitmap = GetBitmap(i)); i++) {
bitmap->Clean();
}
}
if (Active()) {
OsdClose();
Dirty = 1;
}
return cOsd::SetAreas(areas, n);
}
/**
** Actually commits all data to the OSD hardware.
*/
void cSoftOsd::Flush(void)
{
cPixmapMemory *pm;
#ifdef OSD_DEBUG
dsyslog("[softhddev] OSD %s: level %d active %d\n", __FUNCTION__, OsdLevel,
Active());
#endif
if (!Active()) { // this osd is not active
return;
}
if (!IsTrueColor()) {
cBitmap *bitmap;
int i;
#ifdef OSD_DEBUG
static char warned;
if (!warned) {
dsyslog("[softhddev] OSD %s: FIXME: should be truecolor\n",
__FUNCTION__);
warned = 1;
}
#endif
// draw all bitmaps
for (i = 0; (bitmap = GetBitmap(i)); ++i) {
uint8_t *argb;
int xs;
int ys;
int x;
int y;
int w;
int h;
int x1;
int y1;
int x2;
int y2;
// get dirty bounding box
if (Dirty) { // forced complete update
x1 = 0;
y1 = 0;
x2 = bitmap->Width() - 1;
y2 = bitmap->Height() - 1;
} else if (!bitmap->Dirty(x1, y1, x2, y2)) {
continue; // nothing dirty continue
}
// convert and upload only visible dirty areas
xs = bitmap->X0() + Left();
ys = bitmap->Y0() + Top();
// FIXME: negtative position bitmaps
w = x2 - x1 + 1;
h = y2 - y1 + 1;
// clip to screen
if (1) { // just for the case it makes trouble
int width;
int height;
double video_aspect;
if (xs < 0) {
if (xs + x1 < 0) {
x1 -= xs + x1;
w += xs + x1;
if (w <= 0) {
continue;
}
}
xs = 0;
}
if (ys < 0) {
if (ys + y1 < 0) {
y1 -= ys + y1;
h += ys + y1;
if (h <= 0) {
continue;
}
}
ys = 0;
}
::GetScreenSize(&width, &height, &video_aspect);
if (w > width - xs - x1) {
w = width - xs - x1;
if (w <= 0) {
continue;
}
x2 = x1 + w - 1;
}
if (h > height - ys - y1) {
h = height - ys - y1;
if (h <= 0) {
continue;
}
y2 = y1 + h - 1;
}
}
#ifdef DEBUG
if (w > bitmap->Width() || h > bitmap->Height()) {
esyslog(tr("[softhddev]: dirty area too big\n"));
abort();
}
#endif
argb = (uint8_t *) malloc(w * h * sizeof(uint32_t));
for (y = y1; y <= y2; ++y) {
for (x = x1; x <= x2; ++x) {
((uint32_t *) argb)[x - x1 + (y - y1) * w] =
bitmap->GetColor(x, y);
}
}
#ifdef OSD_DEBUG
dsyslog("[softhddev] OSD %s: draw %dx%d%+d%+d bm\n", __FUNCTION__, w, h,
xs + x1, ys + y1);
#endif
OsdDrawARGB(0, 0, w, h, w * sizeof(uint32_t), argb, xs + x1,
ys + y1);
bitmap->Clean();
// FIXME: reuse argb
free(argb);
}
Dirty = 0;
return;
}
LOCK_PIXMAPS;
while ((pm = (dynamic_cast < cPixmapMemory * >(RenderPixmaps())))) {
int xp;
int yp;
int stride;
int x;
int y;
int w;
int h;
x = pm->ViewPort().X();
y = pm->ViewPort().Y();
w = pm->ViewPort().Width();
h = pm->ViewPort().Height();
stride = w * sizeof(tColor);
// clip to osd
xp = 0;
if (x < 0) {
xp = -x;
w -= xp;
x = 0;
}
yp = 0;
if (y < 0) {
yp = -y;
h -= yp;
y = 0;
}
if (w > Width() - x) {
w = Width() - x;
}
if (h > Height() - y) {
h = Height() - y;
}
x += Left();
y += Top();
// clip to screen
if (1) { // just for the case it makes trouble
// and it can happen!
int width;
int height;
double video_aspect;
if (x < 0) {
w += x;
xp += -x;
x = 0;
}
if (y < 0) {
h += y;
yp += -y;
y = 0;
}
::GetScreenSize(&width, &height, &video_aspect);
if (w > width - x) {
w = width - x;
}
if (h > height - y) {
h = height - y;
}
}
#ifdef OSD_DEBUG
dsyslog("[softhddev] OSD %s: draw %dx%d%+d%+d*%d -> %+d%+d %p\n",
__FUNCTION__, w, h, xp, yp, stride, x, y, pm->Data());
#endif
OsdDrawARGB(xp, yp, w, h, stride, pm->Data(), x, y);
DestroyPixmap(pm);
}
Dirty = 0;
}
//////////////////////////////////////////////////////////////////////////////
// OSD provider
//////////////////////////////////////////////////////////////////////////////
/**
** Create a new OSD.
**
** @param left x-coordinate of OSD
** @param top y-coordinate of OSD
** @param level layer level of OSD
*/
cOsd *cSoftOsdProvider::CreateOsd(int left, int top, uint level)
{
#ifdef OSD_DEBUG
dsyslog("[softhddev] OSD %s: %d, %d, %d\n", __FUNCTION__, left, top, level);
#endif
return Osd = new cSoftOsd(left, top, level);
}
/**
** Check if this OSD provider is able to handle a true color OSD.
**
** @returns true we are able to handle a true color OSD.
*/
bool cSoftOsdProvider::ProvidesTrueColor(void)
{
return true;
}
/**
** Create cOsdProvider class.
*/
cSoftOsdProvider::cSoftOsdProvider(void)
: cOsdProvider()
{
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__);
#endif
#ifdef OSD_DEBUG
dsyslog("[softhddev] OSD %s:\n", __FUNCTION__);
#endif
}
/**
** Destroy cOsdProvider class.
cSoftOsdProvider::~cSoftOsdProvider()
{
dsyslog("[softhddev]%s:\n", __FUNCTION__);
}
*/
//////////////////////////////////////////////////////////////////////////////
// cMenuSetupPage
//////////////////////////////////////////////////////////////////////////////
/**
** Create a seperator item.
**
** @param label text inside separator
*/
static inline cOsdItem *SeparatorItem(const char *label)
{
cOsdItem *item;
item = new cOsdItem(cString::sprintf("* %s: ", label));
item->SetSelectable(false);
return item;
}
/**
** Create a collapsed item.
**
** @param label text inside collapsed
** @param flag flag handling collapsed or opened
** @param msg open message
*/
inline cOsdItem *cMenuSetupSoft::CollapsedItem(const char *label, int &flag,
const char *msg)
{
cOsdItem *item;
item =
new cMenuEditBoolItem(cString::sprintf("* %s", label), &flag,
msg ? msg : tr("show"), tr("hide"));
return item;
}
/**
** Create setup menu.
*/
void cMenuSetupSoft::Create(void)
{
int current;
current = Current(); // get current menu item index
Clear(); // clear the menu
//
// general
//
Add(CollapsedItem(tr("General"), General));
if (General) {
Add(new cMenuEditBoolItem(tr("Make primary device"), &MakePrimary,
trVDR("no"), trVDR("yes")));
Add(new cMenuEditBoolItem(tr("Hide main menu entry"),
&HideMainMenuEntry, trVDR("no"), trVDR("yes")));
//
// osd
//
}
//
// audio
//
Add(CollapsedItem(tr("Audio"), Audio));
if (Audio) {
Add(new cMenuEditIntItem(tr("Audio/Video delay (ms)"), &AudioDelay,
-1000, 1000));
Add(new cMenuEditBoolItem(tr("Volume control"), &AudioSoftvol,
tr("Hardware"), tr("Software")));
Add(new cMenuEditIntItem(tr("Audio buffer size (ms)"),
&AudioBufferTime, 0, 1000));
Add(new cMenuEditBoolItem(tr("Enable normalize volume"),
&AudioNormalize, trVDR("no"), trVDR("yes")));
if (AudioNormalize)
Add(new cMenuEditIntItem(tr(" Max normalize factor (/1000)"),
&AudioMaxNormalize, 0, 10000));
Add(new cMenuEditBoolItem(tr("Enable volume compression"),
&AudioCompression, trVDR("no"), trVDR("yes")));
if (AudioCompression)
Add(new cMenuEditIntItem(tr(" Max compression factor (/1000)"),
&AudioMaxCompression, 0, 10000));
Add(new cMenuEditIntItem(tr("Reduce stereo volume (/1000)"),
&AudioStereoDescent, 0, 1000));
Add(new cMenuEditBoolItem(tr("Enable Stereo downmix"),
&AudioDownmix, trVDR("no"), trVDR("yes")));
Add(new cMenuEditBoolItem(tr("Pass-through default"),
&AudioPassthroughDefault, trVDR("off"), trVDR("on")));
if (AudioPassthroughDefault) {
Add(new cMenuEditBoolItem(tr("\040\040PCM pass-through"),
&AudioPassthroughPCM, trVDR("no"), trVDR("yes")));
Add(new cMenuEditBoolItem(tr("\040\040AC-3 pass-through"),
&AudioPassthroughAC3, trVDR("no"), trVDR("yes")));
Add(new cMenuEditBoolItem(tr("\040\040E-AC-3 pass-through"),
&AudioPassthroughEAC3, trVDR("no"), trVDR("yes")));
Add(new cMenuEditBoolItem(tr("Enable automatic AES"), &AudioAutoAES,
trVDR("no"), trVDR("yes")));
}
}
Add(CollapsedItem(tr("Audio Filter"), AudioFilter));
if (AudioFilter) {
Add(new cMenuEditBoolItem(tr(" Enable Audio Equalizer"), &AudioEq,
trVDR("no"), trVDR("yes")));
if (AudioEq) {
Add(new cMenuEditIntItem(tr(" 60 Hz band gain"),
&AudioEqBand[0], -15, 1));
Add(new cMenuEditIntItem(tr(" 72 Hz band gain"),
&AudioEqBand[1], -15, 1));
Add(new cMenuEditIntItem(tr(" 107 Hz band gain"),
&AudioEqBand[2], -15, 1));
Add(new cMenuEditIntItem(tr(" 150 Hz band gain"),
&AudioEqBand[3], -15, 1));
Add(new cMenuEditIntItem(tr(" 220 Hz band gain"),
&AudioEqBand[4], -15, 1));
Add(new cMenuEditIntItem(tr(" 310 Hz band gain"),
&AudioEqBand[5], -15, 1));
Add(new cMenuEditIntItem(tr(" 430 Hz band gain"),
&AudioEqBand[6], -15, 1));
Add(new cMenuEditIntItem(tr(" 620 Hz band gain"),
&AudioEqBand[7], -15, 1));
Add(new cMenuEditIntItem(tr(" 860 Hz band gain"),
&AudioEqBand[8], -15, 1));
Add(new cMenuEditIntItem(tr(" 1200 Hz band gain"),
&AudioEqBand[9], -15, 1));
Add(new cMenuEditIntItem(tr(" 1700 Hz band gain"),
&AudioEqBand[10], -15, 1));
Add(new cMenuEditIntItem(tr(" 2500 Hz band gain"),
&AudioEqBand[11], -15, 1));
Add(new cMenuEditIntItem(tr(" 3500 Hz band gain"),
&AudioEqBand[12], -15, 1));
Add(new cMenuEditIntItem(tr(" 4800 Hz band gain"),
&AudioEqBand[13], -15, 1));
Add(new cMenuEditIntItem(tr(" 7000 Hz band gain"),
&AudioEqBand[14], -15, 1));
Add(new cMenuEditIntItem(tr(" 9500 Hz band gain"),
&AudioEqBand[15], -15, 1));
Add(new cMenuEditIntItem(tr(" 13500 Hz band gain"),
&AudioEqBand[16], -15, 1));
Add(new cMenuEditIntItem(tr(" 17200 Hz band gain"),
&AudioEqBand[17], -15, 1));
}
}
SetCurrent(Get(current)); // restore selected menu entry
Display(); // display build menu
}
/**
** Process key for setup menu.
*/
eOSState cMenuSetupSoft::ProcessKey(eKeys key)
{
int old_General = General;
int old_Audio = Audio;
int old_AudioFilter = AudioFilter;
int old_AudioEq = AudioEq;
int old_AudioNormalize = AudioNormalize;
int old_AudioCompression = AudioCompression;
int old_AudioPassthroughDefault = AudioPassthroughDefault;
eOSState state = cMenuSetupPage::ProcessKey(key);
if (key != kNone) {
// update menu only, if something on the structure has changed
// this is needed because VDR menus are evil slow
if (old_General != General ||
old_Audio != Audio || old_AudioFilter != AudioFilter ||
old_AudioEq != AudioEq || old_AudioNormalize != AudioNormalize ||
old_AudioCompression != AudioCompression ||
old_AudioPassthroughDefault != AudioPassthroughDefault) {
Create(); // update menu
}
}
return state;
}
/**
** Constructor setup menu.
**
** Import global config variables into setup.
*/
cMenuSetupSoft::cMenuSetupSoft(void)
{
//
// general
//
General = 0;
MakePrimary = ConfigMakePrimary;
HideMainMenuEntry = ConfigHideMainMenuEntry;
//
// audio
//
Audio = 0;
AudioDelay = ConfigVideoAudioDelay;
AudioPassthroughDefault = AudioPassthroughState;
AudioPassthroughPCM = ConfigAudioPassthrough & CodecPCM;
AudioPassthroughAC3 = ConfigAudioPassthrough & CodecAC3;
AudioPassthroughEAC3 = ConfigAudioPassthrough & CodecEAC3;
AudioDownmix = ConfigAudioDownmix;
AudioSoftvol = ConfigAudioSoftvol;
AudioNormalize = ConfigAudioNormalize;
AudioMaxNormalize = ConfigAudioMaxNormalize;
AudioCompression = ConfigAudioCompression;
AudioMaxCompression = ConfigAudioMaxCompression;
AudioStereoDescent = ConfigAudioStereoDescent;
AudioBufferTime = ConfigAudioBufferTime;
AudioAutoAES = ConfigAudioAutoAES;
//
// audio filter
//
AudioEq = ConfigAudioEq;
AudioFilter = 0;
for (int i = 0; i < 18; i++) {
AudioEqBand[i] = SetupAudioEqBand[i];
}
Create();
}
/**
** Store setup.
*/
void cMenuSetupSoft::Store(void)
{
SetupStore("MakePrimary", ConfigMakePrimary = MakePrimary);
SetupStore("HideMainMenuEntry", ConfigHideMainMenuEntry = HideMainMenuEntry);
SetupStore("AudioDelay", ConfigVideoAudioDelay = AudioDelay);
VideoSetAudioDelay(ConfigVideoAudioDelay);
// FIXME: can handle more audio state changes here
// downmix changed reset audio, to get change direct
if (ConfigAudioDownmix != AudioDownmix) {
ResetChannelId();
}
ConfigAudioPassthrough = (AudioPassthroughPCM ? CodecPCM : 0)
| (AudioPassthroughAC3 ? CodecAC3 : 0)
| (AudioPassthroughEAC3 ? CodecEAC3 : 0);
AudioPassthroughState = AudioPassthroughDefault;
if (AudioPassthroughState) {
SetupStore("AudioPassthrough", ConfigAudioPassthrough);
CodecSetAudioPassthrough(ConfigAudioPassthrough);
} else {
SetupStore("AudioPassthrough", -ConfigAudioPassthrough);
CodecSetAudioPassthrough(0);
}
SetupStore("AudioDownmix", ConfigAudioDownmix = AudioDownmix);
AudioSetDownmix(ConfigAudioDownmix);
SetupStore("AudioSoftvol", ConfigAudioSoftvol = AudioSoftvol);
AudioSetSoftvol(ConfigAudioSoftvol);
SetupStore("AudioNormalize", ConfigAudioNormalize = AudioNormalize);
SetupStore("AudioMaxNormalize", ConfigAudioMaxNormalize =
AudioMaxNormalize);
AudioSetNormalize(ConfigAudioNormalize, ConfigAudioMaxNormalize);
SetupStore("AudioCompression", ConfigAudioCompression = AudioCompression);
SetupStore("AudioMaxCompression", ConfigAudioMaxCompression =
AudioMaxCompression);
AudioSetCompression(ConfigAudioCompression, ConfigAudioMaxCompression);
SetupStore("AudioStereoDescent", ConfigAudioStereoDescent =
AudioStereoDescent);
AudioSetStereoDescent(ConfigAudioStereoDescent);
SetupStore("AudioBufferTime", ConfigAudioBufferTime = AudioBufferTime);
AudioSetBufferTime(ConfigAudioBufferTime);
SetupStore("AudioAutoAES", ConfigAudioAutoAES = AudioAutoAES);
AudioSetAutoAES(ConfigAudioAutoAES);
SetupStore("AudioEq", ConfigAudioEq = AudioEq);
SetupStore("AudioEqBand01b", SetupAudioEqBand[0] = AudioEqBand[0]);
SetupStore("AudioEqBand02b", SetupAudioEqBand[1] = AudioEqBand[1]);
SetupStore("AudioEqBand03b", SetupAudioEqBand[2] = AudioEqBand[2]);
SetupStore("AudioEqBand04b", SetupAudioEqBand[3] = AudioEqBand[3]);
SetupStore("AudioEqBand05b", SetupAudioEqBand[4] = AudioEqBand[4]);
SetupStore("AudioEqBand06b", SetupAudioEqBand[5] = AudioEqBand[5]);
SetupStore("AudioEqBand07b", SetupAudioEqBand[6] = AudioEqBand[6]);
SetupStore("AudioEqBand08b", SetupAudioEqBand[7] = AudioEqBand[7]);
SetupStore("AudioEqBand09b", SetupAudioEqBand[8] = AudioEqBand[8]);
SetupStore("AudioEqBand10b", SetupAudioEqBand[9] = AudioEqBand[9]);
SetupStore("AudioEqBand11b", SetupAudioEqBand[10] = AudioEqBand[10]);
SetupStore("AudioEqBand12b", SetupAudioEqBand[11] = AudioEqBand[11]);
SetupStore("AudioEqBand13b", SetupAudioEqBand[12] = AudioEqBand[12]);
SetupStore("AudioEqBand14b", SetupAudioEqBand[13] = AudioEqBand[13]);
SetupStore("AudioEqBand15b", SetupAudioEqBand[14] = AudioEqBand[14]);
SetupStore("AudioEqBand16b", SetupAudioEqBand[15] = AudioEqBand[15]);
SetupStore("AudioEqBand17b", SetupAudioEqBand[16] = AudioEqBand[16]);
SetupStore("AudioEqBand18b", SetupAudioEqBand[17] = AudioEqBand[17]);
AudioSetEq(SetupAudioEqBand, ConfigAudioEq);
}
//////////////////////////////////////////////////////////////////////////////
// cDevice
//////////////////////////////////////////////////////////////////////////////
/**
** Constructor device.
*/
cSoftHdDevice::cSoftHdDevice(void)
{
//dsyslog("[softhddev]%s\n", __FUNCTION__);
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__);
#endif
spuDecoder = NULL;
}
/**
** Destructor device.
*/
cSoftHdDevice::~cSoftHdDevice(void)
{
//dsyslog("[softhddev]%s:\n", __FUNCTION__);
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__);
#endif
delete spuDecoder;
}
/**
** Informs a device that it will be the primary device.
**
** @param on flag if becoming or loosing primary
*/
void cSoftHdDevice::MakePrimaryDevice(bool on)
{
dsyslog("[softhddev]%s: %d\n", __FUNCTION__, on);
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s: %d\n", __FUNCTION__, on);
#endif
if (!on) {
::SoftHdDeviceExit();
} else {
::Start();
}
cDevice::MakePrimaryDevice(on);
if (on) {
new cSoftOsdProvider();
}
}
/**
** Get the device SPU decoder.
**
** @returns a pointer to the device's SPU decoder (or NULL, if this
** device doesn't have an SPU decoder)
*/
cSpuDecoder *cSoftHdDevice::GetSpuDecoder(void)
{
dsyslog("[softhddev]%s:\n", __FUNCTION__);
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__);
#endif
if (!spuDecoder && IsPrimaryDevice()) {
spuDecoder = new cDvbSpuDecoder();
}
return spuDecoder;
}
/**
** Tells whether this device has a MPEG decoder.
*/
bool cSoftHdDevice::HasDecoder(void) const
{
return true;
}
/**
** Returns true if this device can currently start a replay session.
*/
bool cSoftHdDevice::CanReplay(void) const
{
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__);
#endif
return true;
}
/**
** Sets the device into the given play mode.
**
** @param play_mode new play mode (Audio/Video/External...)
*/
bool cSoftHdDevice::SetPlayMode(ePlayMode play_mode)
{
dsyslog("[softhddev]%s: %d\n", __FUNCTION__, play_mode);
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s: %d\n", __FUNCTION__, play_mode);
#endif
return::SetPlayMode(play_mode);
}
/**
** Gets the current System Time Counter, which can be used to
** synchronize audio, video and subtitles.
*/
int64_t cSoftHdDevice::GetSTC(void)
{
//dsyslog("[softhddev]%s:\n", __FUNCTION__);
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__);
#endif
return::GetSTC();
}
/**
** Set trick play speed.
**
** Every single frame shall then be displayed the given number of
** times.
**
** @param speed trick speed
** @param forward flag forward direction
*/
void cSoftHdDevice::TrickSpeed(int speed, bool forward)
{
dsyslog("[softhddev]%s: %d %d\n", __FUNCTION__, speed, forward);
#ifdef DEBUG
fprintf(stderr, "[softhddev]TrickSpeed: speed %d %s\n",
speed, forward ? "forward" : "backward");
#endif
::TrickSpeed(speed);
}
/**
** Clears all video and audio data from the device.
*/
void cSoftHdDevice::Clear(void)
{
dsyslog("[softhddev]%s:\n", __FUNCTION__);
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__);
#endif
cDevice::Clear();
::Clear();
}
/**
** Sets the device into play mode (after a previous trick mode)
*/
void cSoftHdDevice::Play(void)
{
dsyslog("[softhddev]%s:\n", __FUNCTION__);
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__);
#endif
cDevice::Play();
::Play();
}
/**
** Puts the device into "freeze frame" mode.
*/
void cSoftHdDevice::Freeze(void)
{
dsyslog("[softhddev]%s:\n", __FUNCTION__);
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__);
#endif
cDevice::Freeze();
::Freeze();
}
/**
** Turns off audio while replaying.
*/
void cSoftHdDevice::Mute(void)
{
dsyslog("[softhddev]%s:\n", __FUNCTION__);
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s:\n", __FUNCTION__);
#endif
cDevice::Mute();
::Mute();
}
/**
** Display the given I-frame as a still picture.
**
** @param data pes or ts data of a frame
** @param length length of data area
*/
void cSoftHdDevice::StillPicture(const uchar * data, int length)
{
if (data[0] == 0x47) { // ts sync
cDevice::StillPicture(data, length);
return;
}
dsyslog("[softhddev]%s: %s %p %d\n", __FUNCTION__,
data[0] == 0x47 ? "ts" : "pes", data, length);
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s: %s %p %d\n", __FUNCTION__,
data[0] == 0x47 ? "ts" : "pes", data, length);
#endif
::StillPicture(data, length);
}
/**
** Check if the device is ready for further action.
**
** @param poller file handles (unused)
** @param timeout_ms timeout in ms to become ready
**
** @retval true if ready
** @retval false if busy
*/
bool cSoftHdDevice::Poll(
__attribute__ ((unused)) cPoller & poller, int timeout_ms)
{
//dsyslog("[softhddev]%s: %d\n", __FUNCTION__, timeout_ms);
// fprintf(stderr, "[softhddev]%s: timeout %d\n", __FUNCTION__, timeout_ms);
return::Poll(timeout_ms);
}
/**
** Flush the device output buffers.
**
** @param timeout_ms timeout in ms to become ready
*/
bool cSoftHdDevice::Flush(int timeout_ms)
{
dsyslog("[softhddev]%s: %d ms\n", __FUNCTION__, timeout_ms);
#ifdef DEBUG
fprintf(stderr, "[softhddev]%s: %d ms\n", __FUNCTION__, timeout_ms);
#endif
return::Flush(timeout_ms);
}
// ----------------------------------------------------------------------------
/**
** Sets the video display format to the given one (only useful if this
** device has an MPEG decoder).
*/
void cSoftHdDevice:: SetVideoDisplayFormat(eVideoDisplayFormat
video_display_format)
{
dsyslog("[softhddev]%s: %d\n", __FUNCTION__, video_display_format);
cDevice::SetVideoDisplayFormat(video_display_format);
}
/**
** Sets the output video format to either 16:9 or 4:3 (only useful
** if this device has an MPEG decoder).
**
** Should call SetVideoDisplayFormat.
**
** @param video_format16_9 flag true 16:9.
*/
void cSoftHdDevice::SetVideoFormat(bool video_format16_9)
{
dsyslog("[softhddev]%s: %d\n", __FUNCTION__, video_format16_9);
// FIXME: 4:3 / 16:9 video format not supported.
SetVideoDisplayFormat(eVideoDisplayFormat(Setup.VideoDisplayFormat));
}
/**
** Returns the width, height and video_aspect ratio of the currently
** displayed video material.
**
** @note the video_aspect is used to scale the subtitle.
*/
void cSoftHdDevice::GetVideoSize(int &width, int &height, double &video_aspect)
{
::GetScreenSize(&width, &height, &video_aspect);
}
/**
** Returns the width, height and pixel_aspect ratio the OSD.
**
** FIXME: Called every second, for nothing (no OSD displayed)?
*/
void cSoftHdDevice::GetOsdSize(int &width, int &height, double &pixel_aspect)
{
::GetScreenSize(&width, &height, &pixel_aspect);
}
// ----------------------------------------------------------------------------
/**
** Play a audio packet.
**
** @param data exactly one complete PES packet (which is incomplete)
** @param length length of PES packet
** @param id type of audio data this packet holds
*/
int cSoftHdDevice::PlayAudio(const uchar * data, int length, uchar id)
{
//dsyslog("[softhddev]%s: %p %p %d %d\n", __FUNCTION__, this, data, length, id);
return::PlayAudio(data, length, id);