forked from vdr-projects/vdr-plugin-skinflatplus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisplayreplay.c
820 lines (719 loc) · 39.6 KB
/
displayreplay.c
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
/*
* Skin flatPlus: A plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
* $Id$
*/
#include "./displayreplay.h"
#include "./flat.h"
cFlatDisplayReplay::cFlatDisplayReplay(bool ModeOnly) : cThread("DisplayReplay") {
m_LabelHeight = m_FontHeight + m_FontSmlHeight;
if (Config.PlaybackShowEndTime > 0) // 1 = End time, 2 = End time and cutted end time
m_LabelHeight += m_FontHeight; // Use second line for displaying end time of recording
m_ModeOnly = ModeOnly;
CreateFullOsd();
TopBarCreate();
MessageCreate();
m_TVSRect.Set(20 + Config.decorBorderChannelEPGSize,
m_TopBarHeight + Config.decorBorderTopBarSize * 2 + 20 + Config.decorBorderChannelEPGSize,
m_OsdWidth - 40 - Config.decorBorderChannelEPGSize * 2,
m_OsdHeight - m_TopBarHeight - m_LabelHeight - 40 - Config.decorBorderChannelEPGSize * 2);
ChanEpgImagesPixmap = CreatePixmap(m_Osd, "ChanEpgImagesPixmap", 2, m_TVSRect);
LabelPixmap =
CreatePixmap(m_Osd, "LabelPixmap", 1,
cRect(Config.decorBorderReplaySize, m_OsdHeight - m_LabelHeight - Config.decorBorderReplaySize,
m_OsdWidth - Config.decorBorderReplaySize * 2, m_LabelHeight));
IconsPixmap =
CreatePixmap(m_Osd, "IconsPixmap", 2,
cRect(Config.decorBorderReplaySize, m_OsdHeight - m_LabelHeight - Config.decorBorderReplaySize,
m_OsdWidth - Config.decorBorderReplaySize * 2, m_LabelHeight));
/* Make Config.decorProgressReplaySize even
https://stackoverflow.com/questions/4739388/make-an-integer-even
number = (number / 2) * 2; */
const int ProgressBarHeight {((Config.decorProgressReplaySize + 1) / 2) * 2}; // Make it even (And round up)
ProgressBarCreate(
cRect(Config.decorBorderReplaySize,
m_OsdHeight - m_LabelHeight - ProgressBarHeight - Config.decorBorderReplaySize - m_MarginItem,
m_OsdWidth - Config.decorBorderReplaySize * 2, ProgressBarHeight),
m_MarginItem, 0, Config.decorProgressReplayFg, Config.decorProgressReplayBarFg, Config.decorProgressReplayBg,
Config.decorProgressReplayType);
LabelJumpPixmap = CreatePixmap(m_Osd, "LabelJumpPixmap", 1,
cRect(Config.decorBorderReplaySize,
m_OsdHeight - m_LabelHeight - ProgressBarHeight * 2 - m_MarginItem3 -
m_FontHeight - Config.decorBorderReplaySize * 2,
m_OsdWidth - Config.decorBorderReplaySize * 2, m_FontHeight));
DimmPixmap = CreatePixmap(m_Osd, "DimmPixmap", MAXPIXMAPLAYERS-1, cRect(0, 0, m_OsdWidth, m_OsdHeight));
PixmapFill(ChanEpgImagesPixmap, clrTransparent);
PixmapFill(LabelPixmap, Theme.Color(clrReplayBg));
PixmapFill(LabelJumpPixmap, clrTransparent);
PixmapFill(IconsPixmap, clrTransparent);
PixmapFill(DimmPixmap, clrTransparent);
m_FontSecs = cFont::CreateFont(Setup.FontOsd, Setup.FontOsdSize * Config.TimeSecsScale * 100.0);
if (Config.PlaybackWeatherShow)
DrawWidgetWeather();
}
cFlatDisplayReplay::~cFlatDisplayReplay() {
if (m_FontSecs)
delete m_FontSecs;
m_Osd->DestroyPixmap(LabelPixmap);
m_Osd->DestroyPixmap(LabelJumpPixmap);
m_Osd->DestroyPixmap(IconsPixmap);
m_Osd->DestroyPixmap(ChanEpgImagesPixmap);
m_Osd->DestroyPixmap(DimmPixmap);
}
void cFlatDisplayReplay::SetRecording(const cRecording *Recording) {
#ifdef DEBUGFUNCSCALL
dsyslog("flatPlus: cFlatDisplayReplay::SetRecording()");
#endif
if (!IconsPixmap || !LabelPixmap || m_ModeOnly) return;
const cRecordingInfo *RecInfo = Recording->Info();
m_Recording = Recording;
PixmapFill(IconsPixmap, clrTransparent);
SetTitle(RecInfo->Title());
// First line for current, total and cutted length, second for end time
const int SmallTop {(Config.PlaybackShowEndTime > 0) ? m_FontHeight2 : m_FontHeight};
// Show if still recording
int left {m_MarginItem}; // Position for recording symbol/short text/date
cImage *img {nullptr};
if ((Recording->IsInUse() & ruTimer) != 0) { // The recording is currently written to by a timer
img = ImgLoader.LoadIcon("timerRecording", ICON_WIDTH_UNLIMITED, m_FontSmlHeight); // Small image
if (img) {
const int ImageTop {SmallTop};
IconsPixmap->DrawImage(cPoint(left, ImageTop), *img);
left += img->Width() + m_MarginItem;
}
}
cString InfoText {""};
if (isempty(RecInfo->ShortText())) { // No short text. Show date and time instead
InfoText = cString::sprintf("%s %s", *ShortDateString(Recording->Start()),
*TimeString(Recording->Start()));
} else {
if (Config.PlaybackShowRecordingDate) // Date Time - ShortText
InfoText = cString::sprintf("%s %s - %s", *ShortDateString(Recording->Start()),
*TimeString(Recording->Start()), RecInfo->ShortText());
else
InfoText = RecInfo->ShortText();
}
const int InfoWidth {m_FontSml->Width(*InfoText)}; // Width of infotext
// TODO: How to get width of aspect and format icons?
// Done: Substract 'left' in case of displayed recording icon
// Done: Substract 'm_FontSmlHeight' in case of recording error icon is displayed later
//* Workaround: Substract width of aspect and format icons (ResolutionAspectDraw()) ???
int MaxWidth {m_OsdWidth - left - Config.decorBorderReplaySize * 2};
#if APIVERSNUM >= 20505
if (Config.PlaybackShowRecordingErrors)
MaxWidth -= m_FontSmlHeight; // Substract width of imgRecErr
#endif
img = ImgLoader.LoadIcon("1920x1080", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
if (img)
MaxWidth -= img->Width() * 3; //* Substract guessed max. used space of aspect and format icons
if (InfoWidth > MaxWidth) { // Infotext too long
if (Config.ScrollerEnable) {
MessageScroller.AddScroller(*InfoText,
cRect(Config.decorBorderReplaySize + left,
m_OsdHeight - m_LabelHeight - Config.decorBorderReplaySize + SmallTop,
MaxWidth, m_FontSmlHeight),
Theme.Color(clrMenuEventFontInfo), clrTransparent, m_FontSml);
left += MaxWidth;
} else { // Add ... if info ist too long
dsyslog("flatPlus: Short text too long! (%d) Setting MaxWidth to %d", InfoWidth, MaxWidth);
const int DotsWidth {m_FontSml->Width("...")};
LabelPixmap->DrawText(cPoint(left, SmallTop), *InfoText, Theme.Color(clrReplayFont),
Theme.Color(clrReplayBg), m_FontSml, MaxWidth - DotsWidth);
left += (MaxWidth - DotsWidth);
LabelPixmap->DrawText(cPoint(left, SmallTop), "...", Theme.Color(clrReplayFont),
Theme.Color(clrReplayBg), m_FontSml, DotsWidth);
left += DotsWidth;
}
} else { // Short text fits into maxwidth
LabelPixmap->DrawText(cPoint(left, SmallTop), *InfoText, Theme.Color(clrReplayFont),
Theme.Color(clrReplayBg), m_FontSml, InfoWidth);
left += InfoWidth;
}
#if APIVERSNUM >= 20505
if (Config.PlaybackShowRecordingErrors) { // Separate config option
const cString RecErrIcon = cString::sprintf("%s_replay", *GetRecordingErrorIcon(RecInfo->Errors()));
img = ImgLoader.LoadIcon(*RecErrIcon, ICON_WIDTH_UNLIMITED, m_FontSmlHeight); // Small image
if (img) {
left += m_MarginItem;
const int ImageTop {SmallTop};
IconsPixmap->DrawImage(cPoint(left, ImageTop), *img);
}
} // PlaybackShowRecordingErrors
#endif
}
void cFlatDisplayReplay::SetTitle(const char *Title) {
TopBarSetTitle(Title);
TopBarSetMenuIcon("extraIcons/Playing");
}
void cFlatDisplayReplay::Action() {
time_t CurTime;
while (Running()) {
time(&CurTime);
if ((CurTime - m_DimmStartTime) > Config.RecordingDimmOnPauseDelay) {
m_DimmActive = true;
for (int alpha {0}; (alpha <= Config.RecordingDimmOnPauseOpaque) && Running(); alpha += 2) {
PixmapFill(DimmPixmap, ArgbToColor(alpha, 0, 0, 0));
Flush();
}
Cancel(-1);
return;
}
cCondWait::SleepMs(100);
}
}
void cFlatDisplayReplay::SetMode(bool Play, bool Forward, int Speed) {
#ifdef DEBUGFUNCSCALL
dsyslog("flatPlus: cFlatDisplayReplay::SetMode()");
dsyslog(" Setup.ShowReplayMode: %d, Speed %d", Setup.ShowReplayMode, Speed);
#endif
if (!LabelPixmap || !IconsPixmap) return;
if (Config.RecordingDimmOnPause) {
if (Play == false) {
time(&m_DimmStartTime);
Start();
} else {
Cancel(-1);
while (Active())
cCondWait::SleepMs(10);
if (m_DimmActive) {
PixmapFill(DimmPixmap, clrTransparent);
Flush();
}
}
}
int left {0};
if (Setup.ShowReplayMode) {
left = (m_OsdWidth - Config.decorBorderReplaySize * 2 - (m_FontHeight * 4 + m_MarginItem3)) / 2;
if (m_ModeOnly)
PixmapFill(LabelPixmap, clrTransparent);
// PixmapFill(IconsPixmap, clrTransparent); //* Moved to SetRecording
LabelPixmap->DrawRectangle(cRect(left - m_Font->Width("99") - m_MarginItem, 0,
m_FontHeight * 4 + m_MarginItem * 6 + m_Font->Width("99") * 2, m_FontHeight),
Theme.Color(clrReplayBg));
cString rewind {"rewind"}, pause {"pause"}, play {"play"}, forward {"forward"};
if (Speed == -1) { // Replay or pause
(Play) ? play = "play_sel" : pause = "pause_sel";
} else {
const cString speed = cString::sprintf("%d", Speed);
if (Forward) {
forward = "forward_sel";
LabelPixmap->DrawText(cPoint(left + m_FontHeight * 4 + m_MarginItem * 4, 0), speed,
Theme.Color(clrReplayFontSpeed), Theme.Color(clrReplayBg), m_Font);
} else {
rewind = "rewind_sel";
LabelPixmap->DrawText(cPoint(left - m_Font->Width(speed) - m_MarginItem, 0), speed,
Theme.Color(clrReplayFontSpeed), Theme.Color(clrReplayBg), m_Font);
}
}
cImage *img {ImgLoader.LoadIcon(*rewind, m_FontHeight, m_FontHeight)};
if (img)
IconsPixmap->DrawImage(cPoint(left, 0), *img);
img = ImgLoader.LoadIcon(*pause, m_FontHeight, m_FontHeight);
if (img)
IconsPixmap->DrawImage(cPoint(left + m_FontHeight + m_MarginItem, 0), *img);
img = ImgLoader.LoadIcon(*play, m_FontHeight, m_FontHeight);
if (img)
IconsPixmap->DrawImage(cPoint(left + m_FontHeight2 + m_MarginItem2, 0), *img);
img = ImgLoader.LoadIcon(*forward, m_FontHeight, m_FontHeight);
if (img)
IconsPixmap->DrawImage(cPoint(left + m_FontHeight * 3 + m_MarginItem3, 0), *img);
}
if (m_ProgressShown) {
const sDecorBorder ib {Config.decorBorderReplaySize,
m_OsdHeight - m_LabelHeight - m_ProgressBarHeight -
Config.decorBorderReplaySize - m_MarginItem,
m_OsdWidth - Config.decorBorderReplaySize * 2,
m_LabelHeight + m_ProgressBarHeight + m_MarginItem,
Config.decorBorderReplaySize,
Config.decorBorderReplayType,
Config.decorBorderReplayFg,
Config.decorBorderReplayBg};
DecorBorderDraw(ib);
} else {
if (m_ModeOnly) {
const sDecorBorder ib {left - m_Font->Width("99") - m_MarginItem + Config.decorBorderReplaySize,
m_OsdHeight - m_LabelHeight - Config.decorBorderReplaySize,
m_FontHeight * 4 + m_MarginItem * 6 + m_Font->Width("99") * 2,
m_FontHeight,
Config.decorBorderReplaySize,
Config.decorBorderReplayType,
Config.decorBorderReplayFg,
Config.decorBorderReplayBg};
DecorBorderDraw(ib);
} else {
const sDecorBorder ib {Config.decorBorderReplaySize,
m_OsdHeight - m_LabelHeight - Config.decorBorderReplaySize,
m_OsdWidth - Config.decorBorderReplaySize * 2,
m_LabelHeight,
Config.decorBorderReplaySize,
Config.decorBorderReplayType,
Config.decorBorderReplayFg,
Config.decorBorderReplayBg};
DecorBorderDraw(ib);
}
}
ResolutionAspectDraw();
}
void cFlatDisplayReplay::SetProgress(int Current, int Total) {
if (m_DimmActive) {
PixmapFill(DimmPixmap, clrTransparent);
Flush();
}
if (m_ModeOnly) return;
m_CurrentFrame = Current;
m_ProgressShown = true;
#if APIVERSNUM >= 30004
ProgressBarDrawMarks(Current, Total, marks, errors, Theme.Color(clrReplayMarkFg),
Theme.Color(clrReplayMarkCurrentFg));
#else
ProgressBarDrawMarks(Current, Total, marks, Theme.Color(clrReplayMarkFg), Theme.Color(clrReplayMarkCurrentFg));
#endif
}
void cFlatDisplayReplay::SetCurrent(const char *Current) {
#ifdef DEBUGFUNCSCALL
dsyslog("flatPlus: cFlatDisplayReplay::SetCurrent() '%s'", Current);
#endif
if (m_ModeOnly) return;
m_Current = Current;
UpdateInfo();
}
void cFlatDisplayReplay::SetTotal(const char *Total) {
if (m_ModeOnly) return;
m_Total = Total;
if (!isempty(*m_Current)) // Do not call 'UpdateInfo()' when 'm_Current' is not set
UpdateInfo();
}
void cFlatDisplayReplay::UpdateInfo() {
#ifdef DEBUGFUNCSCALL
dsyslog("flatPlus: cFlatDisplayReplay::UpdateInfo()");
#endif
if (!LabelPixmap || !ChanEpgImagesPixmap || !IconsPixmap || m_ModeOnly) return;
// const int FontAscender {GetFontAscender(Setup.FontOsd, Setup.FontOsdSize)};
const int FontSecsAscender {GetFontAscender(Setup.FontOsd, Setup.FontOsdSize * Config.TimeSecsScale * 100.0)};
const int TopSecs {m_FontAscender - FontSecsAscender};
constexpr ulong CharCode {0x0030}; // U+0030 DIGIT ZERO
const int GlyphSize = GetGlyphSize(Setup.FontOsd, CharCode, Setup.FontOsdSize); // Narrowing conversion
const int TopOffset {m_FontAscender - GlyphSize};
#ifdef DEBUGFUNCSCALL
dsyslog(" GlyphSize %d, Setup.FontOsdSize %d, m_FontHeight %d, FontAscender %d",
GlyphSize, Setup.FontOsdSize, m_FontHeight, m_FontAscender);
#endif
//* Draw current position with symbol (1. line)
int left {m_MarginItem};
cImage *img {ImgLoader.LoadIcon("recording_pos", ICON_WIDTH_UNLIMITED, GlyphSize)};
if (img) {
IconsPixmap->DrawImage(cPoint(left, TopOffset), *img);
left += img->Width() + m_MarginItem;
}
if (Config.TimeSecsScale < 1.0) {
std::string_view cur {*m_Current};
const std::size_t found {cur.find_last_of(':')};
if (found != std::string::npos) {
const std::string hm {cur.substr(0, found)};
const std::string secs {cur.substr(found, cur.length() - found)};
// Fix for leftover .00 when in edit mode. Add margin to fix extra pixel glitch
const int FontSecsWidth {std::max(m_FontSecs->Width(secs.c_str()) + m_MarginItem, m_LastCurrentWidth)};
m_LastCurrentWidth = FontSecsWidth;
LabelPixmap->DrawText(cPoint(left, 0), hm.c_str(), Theme.Color(clrReplayFont),
Theme.Color(clrReplayBg), m_Font, m_Font->Width(hm.c_str()), m_FontHeight);
left += m_Font->Width(hm.c_str());
LabelPixmap->DrawText(cPoint(left, TopSecs), secs.c_str(),
Theme.Color(clrReplayFont), Theme.Color(clrReplayBg), m_FontSecs,
FontSecsWidth, m_FontSecs->Height());
left += FontSecsWidth;
} else {
// Fix for leftover .00 when in edit mode. Add margin to fix extra pixel glitch
const int CurrentWidth {std::max(m_Font->Width(*m_Current) + m_MarginItem, m_LastCurrentWidth)};
m_LastCurrentWidth = CurrentWidth;
LabelPixmap->DrawText(cPoint(left, 0), *m_Current, Theme.Color(clrReplayFont),
Theme.Color(clrReplayBg), m_Font, CurrentWidth, m_FontHeight);
left += CurrentWidth;
}
} else {
// Fix for leftover .00 when in edit mode. Add margin to fix extra pixel glitch
const int CurrentWidth {std::max(m_Font->Width(*m_Current) + m_MarginItem, m_LastCurrentWidth)};
m_LastCurrentWidth = CurrentWidth;
LabelPixmap->DrawText(cPoint(left, 0), *m_Current, Theme.Color(clrReplayFont), Theme.Color(clrReplayBg),
m_Font, CurrentWidth, m_FontHeight);
left += CurrentWidth;
}
int FramesAfterEdit {-1};
int CurrentFramesAfterEdit {-1};
const int NumFrames {m_Recording->NumFrames()}; // Total frames in recording
if (marks && m_Recording->HasMarks()) {
#if (APIVERSNUM >= 20608)
FramesAfterEdit = marks->GetFrameAfterEdit(NumFrames, NumFrames);
if (FramesAfterEdit >= 0)
CurrentFramesAfterEdit = marks->GetFrameAfterEdit(m_CurrentFrame, NumFrames);
#else
FramesAfterEdit = GetFrameAfterEdit(marks, NumFrames, NumFrames);
if (FramesAfterEdit >= 0)
CurrentFramesAfterEdit = GetFrameAfterEdit(marks, m_CurrentFrame, NumFrames);
#endif
}
const double FramesPerSecond {m_Recording->FramesPerSecond()};
if (FramesPerSecond == 0.0) { // Avoid DIV/0
esyslog("flatPlus: Error in cFlatDisplayReplay::UpdateInfo() FramesPerSecond is 0!");
return;
}
//* Draw total and cutted length with cutted symbol (Right side, 1. line)
const int Spacer {m_Font->Width("0")}; // One digit width space between total and cutted length
img = ImgLoader.LoadIcon("recording_total", ICON_WIDTH_UNLIMITED, GlyphSize);
const int ImgWidth {(img) ? img->Width() : 0};
if (FramesAfterEdit > 0) {
const cString cutted = *IndexToHMSF(FramesAfterEdit, false, FramesPerSecond);
cImage *ImgCutted {ImgLoader.LoadIcon("recording_cutted_extra", ICON_WIDTH_UNLIMITED, GlyphSize)};
const int ImgCuttedWidth {(ImgCutted) ? ImgCutted->Width() : 0};
int right {m_OsdWidth - Config.decorBorderReplaySize * 2 - ImgWidth - m_MarginItem -
m_Font->Width(m_Total) - Spacer - ImgCuttedWidth - m_MarginItem - m_Font->Width(cutted)};
if (Config.TimeSecsScale < 1.0) {
std::string_view tot {*m_Total}; // Total length
const std::size_t found {tot.find_last_of(':')};
if (found != std::string::npos) {
const std::string hm {tot.substr(0, found)};
const std::string secs {tot.substr(found, tot.length() - found)};
std::string_view cutt {*cutted}; // Cutted length
const std::size_t found2 {cutt.find_last_of(':')};
if (found2 != std::string::npos) {
const std::string hm2 {cutt.substr(0, found)};
const std::string secs2 {cutt.substr(found, cutt.length() - found)};
right = m_OsdWidth - Config.decorBorderReplaySize * 2 - ImgWidth - m_MarginItem -
m_Font->Width(hm.c_str()) - m_FontSecs->Width(secs.c_str()) - Spacer -
ImgCuttedWidth - m_MarginItem - m_Font->Width(hm2.c_str()) -
m_FontSecs->Width(secs2.c_str());
} else {
right = m_OsdWidth - Config.decorBorderReplaySize * 2 - ImgWidth - m_MarginItem -
m_Font->Width(hm.c_str()) - m_FontSecs->Width(secs.c_str()) - Spacer -
ImgCuttedWidth - m_MarginItem - m_Font->Width(cutted);
}
if (img) { // Draw preloaded 'recording_total' icon
IconsPixmap->DrawImage(cPoint(right, TopOffset), *img);
right += ImgWidth + m_MarginItem; // 'ImgWidth' is already set
}
LabelPixmap->DrawText(cPoint(right, 0), hm.c_str(), Theme.Color(clrReplayFont),
Theme.Color(clrReplayBg), m_Font, m_Font->Width(hm.c_str()), m_FontHeight);
LabelPixmap->DrawText(cPoint(right + m_Font->Width(hm.c_str()), TopSecs),
secs.c_str(), Theme.Color(clrReplayFont), Theme.Color(clrReplayBg), m_FontSecs,
m_FontSecs->Width(secs.c_str()), m_FontSecs->Height());
right += m_Font->Width(hm.c_str()) + m_FontSecs->Width(secs.c_str()) + Spacer;
} else {
if (img) { // Draw preloaded 'recording_total' icon
IconsPixmap->DrawImage(cPoint(right, TopOffset), *img);
right += ImgWidth + m_MarginItem; // 'ImgWidth' is already set
}
LabelPixmap->DrawText(cPoint(right, 0), m_Total, Theme.Color(clrReplayFont),
Theme.Color(clrReplayBg), m_Font, m_Font->Width(m_Total), m_FontHeight);
right += m_Font->Width(m_Total) + Spacer;
}
} else {
if (img) { // Draw preloaded 'recording_total' icon
IconsPixmap->DrawImage(cPoint(right, TopOffset), *img);
right += ImgWidth + m_MarginItem; // 'ImgWidth' is already set
}
LabelPixmap->DrawText(cPoint(right, 0), m_Total, Theme.Color(clrReplayFont),
Theme.Color(clrReplayBg), m_Font, m_Font->Width(m_Total), m_FontHeight);
right += m_Font->Width(m_Total) + Spacer;
} // Config.TimeSecsScale < 1.0
if (ImgCutted) { // Draw preloaded 'recording_cutted_extra' icon
IconsPixmap->DrawImage(cPoint(right, TopOffset), *ImgCutted);
right += ImgCuttedWidth + m_MarginItem; // 'ImgCuttedWidth' is already set
}
if (Config.TimeSecsScale < 1.0) {
std::string_view cutt {*cutted};
const std::size_t found {cutt.find_last_of(':')};
if (found != std::string::npos) {
const std::string hm {cutt.substr(0, found)};
const std::string secs {cutt.substr(found, cutt.length() - found)};
LabelPixmap->DrawText(cPoint(right, 0), hm.c_str(),
Theme.Color(clrMenuItemExtraTextFont), Theme.Color(clrReplayBg), m_Font,
m_Font->Width(hm.c_str()), m_FontHeight);
LabelPixmap->DrawText(cPoint(right + m_Font->Width(hm.c_str()), TopSecs),
secs.c_str(), Theme.Color(clrMenuItemExtraTextFont), Theme.Color(clrReplayBg),
m_FontSecs, m_FontSecs->Width(secs.c_str()), m_FontSecs->Height());
} else {
LabelPixmap->DrawText(cPoint(right, 0), *cutted,
Theme.Color(clrMenuItemExtraTextFont), Theme.Color(clrReplayBg), m_Font,
m_Font->Width(cutted), m_FontHeight);
}
} else {
LabelPixmap->DrawText(cPoint(right, 0), *cutted, Theme.Color(clrMenuItemExtraTextFont),
Theme.Color(clrReplayBg), m_Font, m_Font->Width(cutted), m_FontHeight);
}
} else { // Not cutted
int right =
m_OsdWidth - Config.decorBorderReplaySize * 2 - ImgWidth - m_MarginItem - m_Font->Width(m_Total);
if (Config.TimeSecsScale < 1.0) {
std::string_view tot {*m_Total};
const std::size_t found {tot.find_last_of(':')};
if (found != std::string::npos) {
const std::string hm {tot.substr(0, found)};
const std::string secs {tot.substr(found, tot.length() - found)};
right = m_OsdWidth - Config.decorBorderReplaySize * 2 - ImgWidth - m_MarginItem -
m_Font->Width(hm.c_str()) - m_FontSecs->Width(secs.c_str());
if (img) { // Draw preloaded 'recording_total' icon
IconsPixmap->DrawImage(cPoint(right, TopOffset), *img);
right += ImgWidth + m_MarginItem; // 'ImgWidth' is already set
}
LabelPixmap->DrawText(cPoint(right, 0), hm.c_str(), Theme.Color(clrReplayFont),
Theme.Color(clrReplayBg), m_Font, m_Font->Width(hm.c_str()), m_FontHeight);
LabelPixmap->DrawText(cPoint(right + m_Font->Width(hm.c_str()), TopSecs),
secs.c_str(), Theme.Color(clrReplayFont), Theme.Color(clrReplayBg), m_FontSecs,
m_FontSecs->Width(secs.c_str()), m_FontSecs->Height());
} else {
if (img) { // Draw preloaded 'recording_total' icon
IconsPixmap->DrawImage(cPoint(right, TopOffset), *img);
right += ImgWidth + m_MarginItem; // 'ImgWidth' is already set
}
LabelPixmap->DrawText(cPoint(right, 0), *m_Total, Theme.Color(clrReplayFont),
Theme.Color(clrReplayBg), m_Font, m_Font->Width(m_Total), m_FontHeight);
}
} else {
if (img) { // Draw preloaded 'recording_total' icon
IconsPixmap->DrawImage(cPoint(right, TopOffset), *img);
right += ImgWidth + m_MarginItem; // 'ImgWidth' is already set
}
LabelPixmap->DrawText(cPoint(right, 0), *m_Total, Theme.Color(clrReplayFont),
Theme.Color(clrReplayBg), m_Font, m_Font->Width(m_Total), m_FontHeight);
}
} // HasMarks
//* Draw end time of recording with symbol for cutted end time (2. line)
const time_t CurTime {time(0)}; // Fix 'jumping' end times - Update once per second or 'm_Current' current changed
if (Config.PlaybackShowEndTime > 0 && (m_LastEndTimeUpdate != CurTime || strcmp(*m_Current, *m_LastCurrent) != 0)) {
// 1 = End time, 2 = End time and cutted end time
m_LastEndTimeUpdate = CurTime;
m_LastCurrent = m_Current;
left = m_MarginItem;
//* Image instead of 'ends at:' text
/* img = ImgLoader.LoadIcon("recording_finish", m_FontHeight, m_FontHeight);
if (img) {
IconsPixmap->DrawImage(cPoint(left, m_FontHeight), *img);
left += img->Width() + m_MarginItem;
} */
const int Rest {NumFrames - m_CurrentFrame};
const cString TimeStr = cString::sprintf("%s" , *TimeString(time(0) + (Rest / FramesPerSecond))); // HH:MM
cString EndTime = cString::sprintf("%s: %s", tr("ends at"), *TimeStr);
LabelPixmap->DrawText(cPoint(left, m_FontHeight), *EndTime, Theme.Color(clrReplayFont),
Theme.Color(clrReplayBg), m_Font, m_Font->Width(*EndTime), m_FontHeight);
left += m_Font->Width(*EndTime) + Spacer;
//* Draw end time of cutted recording with cutted symbol
if (Config.PlaybackShowEndTime == 2 && FramesAfterEdit > 0) {
const int RestCutted {FramesAfterEdit - CurrentFramesAfterEdit};
EndTime = *TimeString(time(0) + (RestCutted / FramesPerSecond)); // HH:MM
if (strcmp(TimeStr, EndTime) != 0) { // Only if not equal
img = ImgLoader.LoadIcon("recording_cutted_extra", ICON_WIDTH_UNLIMITED, GlyphSize);
if (img) {
IconsPixmap->DrawImage(cPoint(left, m_FontHeight + TopOffset), *img);
left += img->Width() + m_MarginItem;
}
LabelPixmap->DrawText(cPoint(left, m_FontHeight), *EndTime, Theme.Color(clrMenuItemExtraTextFont),
Theme.Color(clrReplayBg), m_Font, m_Font->Width(*EndTime), m_FontHeight);
// left += m_Font->Width(*EndTime) + m_MarginItem; //* 'left' is not used anymore from here
}
}
} // Config.PlaybackShowEndTime
//* Draw Banner/Poster
if (m_Recording) {
cString MediaPath {""};
cSize MediaSize {0, 0};
static cPlugin *pScraper = GetScraperPlugin();
if (Config.TVScraperReplayInfoShowPoster && pScraper) {
ScraperGetEventType call;
call.recording = m_Recording;
int seriesId {0}, episodeId {0}, movieId {0};
if (pScraper->Service("GetEventType", &call)) {
seriesId = call.seriesId;
episodeId = call.episodeId;
movieId = call.movieId;
}
if (call.type == tSeries) {
cSeries series;
series.seriesId = seriesId;
series.episodeId = episodeId;
if (pScraper->Service("GetSeries", &series)) {
if (series.banners.size() > 1) { // Use random banner
// Gets 'entropy' from device that generates random numbers itself
// to seed a mersenne twister (pseudo) random generator
std::mt19937 generator(std::random_device {}());
// Make sure all numbers have an equal chance.
// Range is inclusive (so we need -1 for vector index)
std::uniform_int_distribution<std::size_t> distribution(0, series.banners.size() - 1);
const std::size_t number {distribution(generator)};
MediaPath = series.banners[number].path.c_str();
MediaSize.Set(series.banners[number].width, series.banners[number].height);
dsyslog("flatPlus: Using random image %d (%s) out of %d available images",
static_cast<int>(number + 1), *MediaPath,
static_cast<int>(series.banners.size())); // Log result
} else if (series.banners.size() == 1) { // Just one banner
MediaPath = series.banners[0].path.c_str();
MediaSize.Set(series.banners[0].width, series.banners[0].height);
}
}
} else if (call.type == tMovie) {
cMovie movie;
movie.movieId = movieId;
if (pScraper->Service("GetMovie", &movie)) {
MediaPath = movie.poster.path.c_str();
MediaSize.Set(movie.poster.width, movie.poster.height);
}
}
if (isempty(*MediaPath)) { // Prio for tvscraper poster
const cString RecPath = m_Recording->FileName();
if (ImgLoader.SearchRecordingPoster(RecPath, MediaPath)) {
img = ImgLoader.LoadFile(*MediaPath, m_TVSRect.Width(), m_TVSRect.Height());
if (img)
MediaSize.Set(img->Width(), img->Height()); // Get values for SetMediaSize()
else
MediaPath = ""; // Just in case image can not be loaded
}
}
}
PixmapFill(ChanEpgImagesPixmap, clrTransparent);
PixmapSetAlpha(ChanEpgImagesPixmap, 255 * Config.TVScraperPosterOpacity * 100); // Set transparency
DecorBorderClearByFrom(BorderTVSPoster);
if (!isempty(*MediaPath)) {
SetMediaSize(MediaSize, m_TVSRect.Size()); // Check for too big images
MediaSize.SetWidth(MediaSize.Width() * Config.TVScraperReplayInfoPosterSize * 100);
MediaSize.SetHeight(MediaSize.Height() * Config.TVScraperReplayInfoPosterSize * 100);
img = ImgLoader.LoadFile(*MediaPath, MediaSize.Width(), MediaSize.Height());
if (img) {
ChanEpgImagesPixmap->DrawImage(cPoint(0, 0), *img);
const sDecorBorder ib {20 + Config.decorBorderChannelEPGSize,
m_TopBarHeight + Config.decorBorderTopBarSize * 2 + 20 +
Config.decorBorderChannelEPGSize,
img->Width(),
img->Height(),
Config.decorBorderChannelEPGSize,
Config.decorBorderChannelEPGType,
Config.decorBorderChannelEPGFg,
Config.decorBorderChannelEPGBg,
BorderTVSPoster};
DecorBorderDraw(ib);
}
}
} // m_Recording
}
void cFlatDisplayReplay::SetJump(const char *Jump) {
if (!LabelJumpPixmap) return;
DecorBorderClearByFrom(BorderRecordJump);
if (!Jump) {
PixmapFill(LabelJumpPixmap, clrTransparent);
return;
}
const int JumpWidth {m_Font->Width(Jump)};
const int left {(m_OsdWidth - Config.decorBorderReplaySize * 2 - JumpWidth) / 2};
LabelJumpPixmap->DrawText(cPoint(left, 0), Jump, Theme.Color(clrReplayFont), Theme.Color(clrReplayBg), m_Font,
JumpWidth, m_FontHeight, taCenter);
const sDecorBorder ib {left + Config.decorBorderReplaySize,
m_OsdHeight - m_LabelHeight - m_ProgressBarHeight * 2 - m_MarginItem3 -
m_FontHeight - Config.decorBorderReplaySize * 2,
JumpWidth,
m_FontHeight,
Config.decorBorderReplaySize,
Config.decorBorderReplayType,
Config.decorBorderReplayFg,
Config.decorBorderReplayBg,
BorderRecordJump};
DecorBorderDraw(ib);
}
void cFlatDisplayReplay::ResolutionAspectDraw() {
if (!IconsPixmap || m_ModeOnly) return;
if (m_ScreenWidth > 0) {
// First line for current, total and cutted length, second line for end time
const int ImageTop {(Config.PlaybackShowEndTime > 0) ? m_FontHeight2 : m_FontHeight};
int left {m_OsdWidth - Config.decorBorderReplaySize * 2};
cImage *img {nullptr};
cString IconName {""};
if (Config.RecordingResolutionAspectShow) { // Show Aspect (16:9)
IconName = *GetAspectIcon(m_ScreenWidth, m_ScreenAspect);
img = ImgLoader.LoadIcon(*IconName, ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
if (img) {
left -= img->Width();
IconsPixmap->DrawImage(cPoint(left, ImageTop), *img);
left -= m_MarginItem2;
}
IconName = *GetScreenResolutionIcon(m_ScreenWidth, m_ScreenHeight); // Show Resolution (1920x1080)
img = ImgLoader.LoadIcon(*IconName, ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
if (img) {
left -= img->Width();
IconsPixmap->DrawImage(cPoint(left, ImageTop), *img);
left -= m_MarginItem2;
}
}
if (Config.RecordingFormatShow && !Config.RecordingSimpleAspectFormat) {
IconName = *GetFormatIcon(m_ScreenWidth); // Show Format (HD)
img = ImgLoader.LoadIcon(*IconName, ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
if (img) {
left -= img->Width();
IconsPixmap->DrawImage(cPoint(left, ImageTop), *img);
left -= m_MarginItem2;
}
}
// Show audio icon (Dolby, Stereo)
if (Config.RecordingResolutionAspectShow) { //? Add separate config option
IconName = *GetCurrentAudioIcon();
img = ImgLoader.LoadIcon(*IconName, ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
if (img) {
left -= img->Width();
IconsPixmap->DrawImage(cPoint(left, ImageTop), *img);
// left -= m_MarginItem2;
}
}
}
}
void cFlatDisplayReplay::SetMessage(eMessageType Type, const char *Text) {
(Text) ? MessageSet(Type, Text) : MessageClear();
}
void cFlatDisplayReplay::Flush() {
TopBarUpdate();
if (Config.RecordingResolutionAspectShow) {
cDevice::PrimaryDevice()->GetVideoSize(m_ScreenWidth, m_ScreenHeight, m_ScreenAspect);
if (m_ScreenWidth != m_LastScreenWidth) {
m_LastScreenWidth = m_ScreenWidth;
ResolutionAspectDraw();
}
}
m_Osd->Flush();
}
void cFlatDisplayReplay::PreLoadImages() {
ImgLoader.LoadIcon("rewind", m_FontHeight, m_FontHeight);
ImgLoader.LoadIcon("pause", m_FontHeight, m_FontHeight);
ImgLoader.LoadIcon("play", m_FontHeight, m_FontHeight);
ImgLoader.LoadIcon("forward", m_FontHeight, m_FontHeight);
ImgLoader.LoadIcon("rewind_sel", m_FontHeight, m_FontHeight);
ImgLoader.LoadIcon("pause_sel", m_FontHeight, m_FontHeight);
ImgLoader.LoadIcon("play_sel", m_FontHeight, m_FontHeight);
ImgLoader.LoadIcon("forward_sel", m_FontHeight, m_FontHeight);
constexpr ulong CharCode {0x0030}; // U+0030 DIGIT ZERO
const int GlyphSize = GetGlyphSize(Setup.FontOsd, CharCode, Setup.FontOsdSize); // Narrowing conversion
ImgLoader.LoadIcon("recording_pos", ICON_WIDTH_UNLIMITED, GlyphSize);
ImgLoader.LoadIcon("recording_total", ICON_WIDTH_UNLIMITED, GlyphSize);
ImgLoader.LoadIcon("recording_cutted_extra", ICON_WIDTH_UNLIMITED, GlyphSize);
ImgLoader.LoadIcon("recording_untested_replay", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("recording_ok_replay", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("recording_warning_replay", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("recording_error_replay", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("43", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("169", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("169w", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("221", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("7680x4320", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("3840x2160", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("1920x1080", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("1440x1080", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("1280x720", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("960x720", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("704x576", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("720x576", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("544x576", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("528x576", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("480x576", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("352x576", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("unknown_res", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("uhd", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("hd", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("sd", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("audio_stereo", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
ImgLoader.LoadIcon("audio_dolby", ICON_WIDTH_UNLIMITED, m_FontSmlHeight);
}