summaryrefslogtreecommitdiff
path: root/displaychannel.c
blob: b73d71ec0901199b9cfc3dfde4b84165e3e004ca (plain)
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
#include "displaychannel.h"
#include "flat.h"

cFlatDisplayChannel::cFlatDisplayChannel(bool WithInfo) : m_Receiver(NULL) {
    if (firstDisplay) {
        firstDisplay = false;
        doOutput = false;
        return;
    } else
        doOutput = true;

    present = NULL;
    channelName = "";
    chanInfoTopPixmap = NULL;
    chanInfoBottomPixmap = NULL;
    chanLogoPixmap = NULL;
    chanLogoBGPixmap = NULL;
    chanIconsPixmap = NULL;
    chanEpgImagesPixmap = NULL;

    isGroup = false;
    isRecording = false,
    isRadioChannel = false;

    screenWidth = lastScreenWidth = -1;
    LastSignalStrength = -1;
    LastSignalQuality = -1;

    SignalStrengthRight = BitrateRight = 0;

    CreateFullOsd();
    if ( !osd )
        return;
    TopBarCreate();
    MessageCreate();

    channelWidth = osdWidth - Config.decorBorderChannelSize*2;
    channelHeight = osdHeight - Config.decorBorderChannelSize*2;
    // von unten noch oben
    // 2*EPG + 2*EPGsml
    heightBottom = (fontHeight*2) + (fontSmlHeight*2) + marginItem; // Top, Buttom, Between
    heightImageLogo = heightBottom;
    if( Config.SignalQualityShow )
        heightBottom += max(fontSmlHeight, (Config.decorProgressSignalSize*2) + marginItem) + marginItem;
    else if( Config.ChannelIconsShow )
        heightBottom += fontSmlHeight + marginItem;

    int heightTop = fontHeight;

    int height = heightBottom;
    chanInfoBottomPixmap = osd->CreatePixmap(1, cRect(Config.decorBorderChannelSize,
        Config.decorBorderChannelSize+channelHeight - height, channelWidth, heightBottom));
    chanInfoBottomPixmap->Fill( Theme.Color(clrChannelBg) );

    chanIconsPixmap = osd->CreatePixmap(2, cRect(Config.decorBorderChannelSize,
        Config.decorBorderChannelSize+channelHeight - height, channelWidth, heightBottom));
    chanIconsPixmap->Fill( clrTransparent );

    TVSLeft = 20 + Config.decorBorderChannelEPGSize;
    TVSTop = topBarHeight + Config.decorBorderTopBarSize*2 + 20 + Config.decorBorderChannelEPGSize;
    TVSWidth = osdWidth - 40 - Config.decorBorderChannelEPGSize*2;
    TVSHeight = osdHeight - topBarHeight - heightBottom - 40 - Config.decorBorderChannelEPGSize*2;

    chanEpgImagesPixmap = osd->CreatePixmap(2, cRect(TVSLeft, TVSTop, TVSWidth, TVSHeight));
    chanEpgImagesPixmap->Fill( clrTransparent );

    chanLogoBGPixmap = osd->CreatePixmap(2, cRect(Config.decorBorderChannelSize,
        Config.decorBorderChannelSize+channelHeight - height, heightBottom*2, heightBottom*2));
    chanLogoBGPixmap->Fill( clrTransparent );

    chanLogoPixmap = osd->CreatePixmap(3, cRect(Config.decorBorderChannelSize,
        Config.decorBorderChannelSize+channelHeight - height, heightBottom*2, heightBottom*2));
    chanLogoPixmap->Fill( clrTransparent );

    height += Config.decorProgressChannelSize + marginItem*2;
    ProgressBarCreate(Config.decorBorderChannelSize, Config.decorBorderChannelSize+channelHeight - height + marginItem,
        channelWidth, Config.decorProgressChannelSize, marginItem, 0,
        Config.decorProgressChannelFg, Config.decorProgressChannelBarFg, Config.decorProgressChannelBg, Config.decorProgressChannelType, true);

    ProgressBarDrawBgColor();

    height += heightTop;
    chanInfoTopPixmap = osd->CreatePixmap(1, cRect(Config.decorBorderChannelSize,
        Config.decorBorderChannelSize+channelHeight - height, channelWidth, heightTop));
    chanInfoTopPixmap->Fill( clrTransparent );

    scrollers.SetOsd(osd);
    scrollers.SetScrollStep( Config.ScrollerStep );
    scrollers.SetScrollDelay( Config.ScrollerDelay );
    scrollers.SetScrollType( Config.ScrollerType );

    bitrateVideo = bitrateAudio = bitrateDolby = 0.0;
    m_Receiver = NULL;
    /*
    if( Config.ChannelBitrateShow ) {
        const cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel());
        eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack();
        if( channel ) {
            m_Receiver = new cFemonReceiver(channel, IS_AUDIO_TRACK(track) ? int(track - ttAudioFirst) : 0, IS_DOLBY_TRACK(track) ? int(track - ttDolbyFirst) : 0);
            cDevice::ActualDevice()->AttachReceiver(m_Receiver);
        }
    }
    */
    if( Config.ChannelWeatherShow )
        DrawWidgetWeather();

    DecorBorderDraw(Config.decorBorderChannelSize, Config.decorBorderChannelSize+channelHeight - height,
        channelWidth, heightTop + heightBottom + Config.decorProgressChannelSize+marginItem*2,
        Config.decorBorderChannelSize, Config.decorBorderChannelType, Config.decorBorderChannelFg, Config.decorBorderChannelBg);
}

cFlatDisplayChannel::~cFlatDisplayChannel() {

    if (m_Receiver != NULL ) {
        m_Receiver->Deactivate();
        delete m_Receiver;
    }
    if( !doOutput )
        return;
    if (osd) {
        scrollers.Clear();

        if( chanInfoTopPixmap )
            osd->DestroyPixmap(chanInfoTopPixmap);
        if( chanInfoBottomPixmap )
            osd->DestroyPixmap(chanInfoBottomPixmap);
        if( chanLogoPixmap )
            osd->DestroyPixmap(chanLogoPixmap);
        if( chanLogoBGPixmap )
            osd->DestroyPixmap(chanLogoBGPixmap);
        if( chanIconsPixmap )
            osd->DestroyPixmap(chanIconsPixmap);
        if( chanEpgImagesPixmap )
            osd->DestroyPixmap(chanEpgImagesPixmap);
    }
}

void cFlatDisplayChannel::SetChannel(const cChannel *Channel, int Number) {
    if( !doOutput )
        return;
    cString channelNumber("");
    isRecording = false;
    chanIconsPixmap->Fill( clrTransparent );
    lastScreenWidth = -1;

    if (Channel) {
        isRadioChannel = ((!Channel->Vpid())&&(Channel->Apid(0))) ? true : false;
        isGroup = Channel->GroupSep();

        channelName = Channel->Name();
        if (!Channel->GroupSep())
            channelNumber = cString::sprintf("%d%s", Channel->Number(), Number ? "-" : "");
        else if (Number)
            channelNumber = cString::sprintf("%d-", Number);

        CurChannel = Channel;
    } else
        channelName = ChannelString(NULL, 0);

    cString channelString = cString::sprintf("%s  %s", *channelNumber, *channelName);

    chanInfoTopPixmap->Fill(Theme.Color(clrChannelBg));
    chanInfoTopPixmap->DrawText(cPoint(50, 0), channelString, Theme.Color(clrChannelFontTitle), Theme.Color(clrChannelBg), font);

    chanLogoPixmap->Fill(clrTransparent);
    chanLogoBGPixmap->Fill(clrTransparent);
    int imageHeight = heightImageLogo - marginItem*2;
    int imageBGHeight = imageHeight;
    int imageBGWidth = imageHeight;
    int imageLeft = marginItem*2;
    int imageTop = marginItem;
    cImage *imgBG = imgLoader.LoadIcon("logo_background", imageHeight*1.34, imageHeight);
    if( imgBG ) {
        imageBGHeight = imgBG->Height();
        imageBGWidth = imgBG->Width();
        chanLogoBGPixmap->DrawImage( cPoint(imageLeft, imageTop), *imgBG );
    }

    cImage *img = imgLoader.LoadLogo(*channelName, imageBGWidth - 4, imageBGHeight - 4);
    if( img ) {
        imageTop = marginItem + (imageBGHeight - img->Height()) / 2;
        imageLeft = marginItem*2 + (imageBGWidth - img->Width()) / 2;
        chanLogoPixmap->DrawImage( cPoint(imageLeft, imageTop), *img );
    } else if( !isGroup ) { // draw default logo
        if( isRadioChannel ) {
            img = imgLoader.LoadIcon("radio", imageBGWidth - 10, imageBGHeight - 10);
            if( img ) {
                imageTop = marginItem + (imageHeight - img->Height()) / 2;
                imageLeft = marginItem*2 + (imageBGWidth - img->Width()) / 2;
                chanLogoPixmap->DrawImage( cPoint(imageLeft, imageTop), *img );
            }
        } else {
            img = imgLoader.LoadIcon("tv", imageBGWidth - 10, imageBGHeight - 10);
            if( img ) {
                imageTop = marginItem + (imageHeight - img->Height()) / 2;
                imageLeft = marginItem*2 + (imageBGWidth - img->Width()) / 2;
                chanLogoPixmap->DrawImage( cPoint(imageLeft, imageTop), *img );
            }
        }
    }
}

void cFlatDisplayChannel::ChannelIconsDraw(const cChannel *Channel, bool Resolution) {
    if( !Resolution ) {
        chanIconsPixmap->Fill( clrTransparent );
    }

    int width = fontSmlHeight;
    int height = fontSmlHeight;
    int top = heightBottom - height - marginItem;
    int imageTop = 0;
    cImage *img = NULL;

    int left = channelWidth - width - marginItem*2;

    if( Channel ) {
        if (Channel->Ca()) {
            img = imgLoader.LoadIcon("crypted", 999, height);
            if( img ) {
                imageTop = top + (height - img->Height())/2;
                chanIconsPixmap->DrawImage(cPoint(left, imageTop), *img);
                left -= marginItem*2;
            }
        } else {
             img = imgLoader.LoadIcon("uncrypted", 999, height);
            if( img ) {
                imageTop = top + (height - img->Height())/2;
                chanIconsPixmap->DrawImage(cPoint(left, imageTop), *img);
                left -= marginItem*2;
            }
        }
    }

    if( Resolution && !isRadioChannel && screenWidth > 0 ) {
        if( Config.ChannelResolutionAspectShow ) {     // Show Aspect
            cString asp = "unknown_asp";                 // ???
            if(Config.ChannelSimpleAspectFormat && screenWidth > 720) {
                asp = "hd";                                // No aspect for HD
            } else {
                if( screenAspect == 4.0/3.0 )
                    asp = "43";
                else if( screenAspect == 16.0/9.0 )
                    asp = "169";
                else if( screenAspect == 20.0/11.0 || screenAspect == 15.0/11.0 )
                    asp = "169w";
                else if( screenAspect == 2.21 )
                    asp = "221";
            }
            img = imgLoader.LoadIcon(*asp, 999, height);
            if( img ) {
                imageTop = top + (height - img->Height())/2;
                left -= img->Width();
                chanIconsPixmap->DrawImage(cPoint(left, imageTop), *img);
                left -= marginItem*2;
            }
        }

        if( Config.ChannelResolutionAspectShow ) {    // Show Resolution
            cString res = "";

            switch (screenWidth) {
            case 1920:                        // 1920x1080 (HD1080 Full HDTV)
                res = "1920x1080";
                break;
            case 1440:                        // 1440x1080 (HD1080 DV)
                res = "1440x1080";
                break;
            case 1280:                        // 1280x720 (HD720)
                res = "1280x720";
                break;
            case 960:                         // 960x720 (HD720 DV)
                res = "960x720";
                break;
            case 704:                         // 704x576 (PAL)
                res = "704x576";
                break;
            case 720:                         // 720x576 (PAL)
                res = "720x576";
                break;
            case 544:                         // 544x576 (PAL)
                res = "544x576";
                break;
            case 528:                         // 528x576 (PAL)
                res = "528x576";
                break;
            case 480:                         // 480x576 (PAL SVCD)
                res = "480x576";
                break;
            case 352:                         // 352x576 (PAL CVD)
                res = "352x576";
                break;
            default:
                res = "unknown_res";         // TODO: Add Log line of resolution
                dsyslog("unkown resolution Width: %d Height: %d Aspect: %.2f\n", screenWidth, screenHeight, screenAspect);
                break;
            }

            img = imgLoader.LoadIcon(*res, 999, height);
            if( img ) {
                imageTop = top + (height - img->Height())/2;
                left -= img->Width();
                chanIconsPixmap->DrawImage(cPoint(left, imageTop), *img);
                left -= marginItem*2;
            }
        }
        if( Config.ChannelFormatShow && !Config.ChannelSimpleAspectFormat) {
            cString iconName("");      // Show Format
            switch (screenWidth) {
                case 1920:
                case 1440:
                case 1280:
                    iconName = "hd";
                    break;
                case 720:
                    iconName = "sd";
                    break;
                default:
                    iconName = "sd";
                    break;
            }

            img = imgLoader.LoadIcon(*iconName, 999, height);
            if( img ) {
                imageTop = top + (height - img->Height())/2;
                left -= img->Width();
                chanIconsPixmap->DrawImage(cPoint(left, imageTop), *img);
                left -= marginItem*2;
            }
        }
    }
}

void cFlatDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Following) {
    if( !doOutput )
        return;

    present = Present;
    cString epgShort("");
    cString epg("");

    scrollers.Clear();

    chanInfoBottomPixmap->Fill(Theme.Color(clrChannelBg));
    chanIconsPixmap->Fill( clrTransparent );

    bool isRec = false;
    int RecWidth = fontSml->Width("REC");

    int left = heightBottom * 1.34 + marginItem;

    if( Present ) {
        cString startTime = Present->GetTimeString();
        cString endTime = Present->GetEndTimeString();

        cString timeString = cString::sprintf("%s - %s", *startTime, *endTime);
        int timeStringWidth = fontSml->Width(*timeString) + fontSml->Width("  ");

        int epgWidth = font->Width(Present->Title()) + marginItem*2;
        int epgShortWidth = fontSml->Width(Present->ShortText()) + marginItem*2;

        if( Present->HasTimer() ) {
            isRec = true;
            epgWidth += marginItem + RecWidth;
        }

        int s = (int)(time(NULL) - Present->StartTime()) / 60;
        int sleft = (Present->Duration() / 60) - s;

        cString seen;
        if( Config.ChannelTimeLeft == 0 )
            seen = cString::sprintf("%d-/%d+ %d min", s, sleft, Present->Duration() / 60);
        else if( Config.ChannelTimeLeft == 1 )
            seen = cString::sprintf("%d- %d min", s, Present->Duration() / 60);
        else if( Config.ChannelTimeLeft == 2 )
            seen = cString::sprintf("%d+ %d min", sleft, Present->Duration() / 60);

        int seenWidth = fontSml->Width(*seen) + fontSml->Width("  ");

        epg = Present->Title();
        epgShort = Present->ShortText();
        int maxWidth = max(timeStringWidth, seenWidth);

        chanInfoBottomPixmap->DrawText(cPoint(channelWidth - timeStringWidth - marginItem * 2, 0), *timeString,
            Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), fontSml, timeStringWidth, 0, taRight);
        chanInfoBottomPixmap->DrawText(cPoint(channelWidth - seenWidth - marginItem * 2, fontSmlHeight), *seen,
                Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), fontSml, seenWidth, 0, taRight);

        if( (epgWidth > channelWidth - left - maxWidth) && Config.ScrollerEnable ) {
            scrollers.AddScroller(*epg, cRect(Config.decorBorderChannelSize + left, Config.decorBorderChannelSize+channelHeight - heightBottom, channelWidth - left - maxWidth, fontHeight), Theme.Color(clrChannelFontEpg), clrTransparent, font);
        } else {
            chanInfoBottomPixmap->DrawText(cPoint(left, 0), *epg, Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), font, channelWidth - left - maxWidth);
        }

        if( (epgShortWidth > channelWidth - left - maxWidth) && Config.ScrollerEnable ) {
            scrollers.AddScroller(*epgShort, cRect(Config.decorBorderChannelSize + left, Config.decorBorderChannelSize+channelHeight - heightBottom + fontHeight, channelWidth - left - maxWidth, fontSmlHeight), Theme.Color(clrChannelFontEpg), clrTransparent, fontSml);
        } else {
            chanInfoBottomPixmap->DrawText(cPoint(left, fontHeight), *epgShort, Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), fontSml, channelWidth - left - maxWidth);
        }

        if( isRec ) {
            chanInfoBottomPixmap->DrawText(cPoint(left + epgWidth + marginItem - RecWidth, 0), "REC",
                Theme.Color(clrChannelRecordingPresentFg), Theme.Color(clrChannelRecordingPresentBg), fontSml);
        }
    }

    if( Following ) {
        isRec = false;
        cString startTime = Following->GetTimeString();
        cString endTime = Following->GetEndTimeString();

        cString timeString = cString::sprintf("%s - %s", *startTime, *endTime);
        int timeStringWidth = fontSml->Width(*timeString) + fontSml->Width("  ");

        int epgWidth = font->Width(Following->Title()) + marginItem*2;
        int epgShortWidth = fontSml->Width(Following->ShortText()) + marginItem*2;

        if( Following->HasTimer() ) {
            epgWidth += marginItem + RecWidth;
            isRec = true;
        }

        cString dur = cString::sprintf("%d min", Following->Duration() / 60);
        int durWidth = fontSml->Width(*dur) + fontSml->Width("  ");

        int maxWidth = max(timeStringWidth, durWidth);

        epg = Following->Title();
        epgShort = Following->ShortText();

        chanInfoBottomPixmap->DrawText(cPoint(channelWidth - timeStringWidth - marginItem * 2, fontHeight + fontSmlHeight), *timeString,
                Theme.Color(clrChannelFontEpgFollow), Theme.Color(clrChannelBg), fontSml, timeStringWidth, 0, taRight);
        chanInfoBottomPixmap->DrawText(cPoint(channelWidth - durWidth - marginItem * 2, fontHeight + fontSmlHeight*2), *dur,
                Theme.Color(clrChannelFontEpgFollow), Theme.Color(clrChannelBg), fontSml, durWidth, 0, taRight);

        if( (epgWidth > channelWidth - left - maxWidth) && Config.ScrollerEnable ) {
            scrollers.AddScroller(*epg, cRect(Config.decorBorderChannelSize + left, Config.decorBorderChannelSize+channelHeight - heightBottom + fontHeight + fontSmlHeight, channelWidth - left - maxWidth, fontHeight), Theme.Color(clrChannelFontEpgFollow), clrTransparent, font);
        } else {
            chanInfoBottomPixmap->DrawText(cPoint(left, fontHeight + fontSmlHeight), *epg,
                Theme.Color(clrChannelFontEpgFollow), Theme.Color(clrChannelBg), font, channelWidth - left - maxWidth);
        }

        if( (epgShortWidth > channelWidth - left - maxWidth) && Config.ScrollerEnable ) {
            scrollers.AddScroller(*epgShort, cRect(Config.decorBorderChannelSize + left, Config.decorBorderChannelSize+channelHeight - heightBottom + fontHeight*2 + fontSmlHeight, channelWidth - left - maxWidth, fontSmlHeight), Theme.Color(clrChannelFontEpgFollow), clrTransparent, fontSml);
        } else {
            chanInfoBottomPixmap->DrawText(cPoint(left, fontHeight*2 + fontSmlHeight), *epgShort,
                Theme.Color(clrChannelFontEpgFollow), Theme.Color(clrChannelBg), fontSml, channelWidth - left - maxWidth);
        }

        if( isRec ) {
            chanInfoBottomPixmap->DrawText(cPoint(left + epgWidth + marginItem - RecWidth, fontHeight + fontSmlHeight), "REC",
                Theme.Color(clrChannelRecordingFollowFg), Theme.Color(clrChannelRecordingFollowBg), fontSml);
        }
    }

    if( Config.ChannelIconsShow && CurChannel ) {
        ChannelIconsDraw(CurChannel, false);
    }

    std::string mediaPath;
    int mediaWidth = 0;
    int mediaHeight = 0;

    // TVScraper
    // first try scraper2vdr
    static cPlugin *pScraper = cPluginManager::GetPlugin("scraper2vdr");
    if( !pScraper ) // if it doesn't exit, try tvscraper
        pScraper = cPluginManager::GetPlugin("tvscraper");
    if( Config.TVScraperChanInfoShowPoster && pScraper ) {
        ScraperGetPosterBanner call;
        call.event = Present;
        if (pScraper->Service("GetPosterBanner", &call)) {
            if ((call.type == tSeries) && call.banner.path.size() > 0) {
                mediaWidth = call.banner.width * Config.TVScraperChanInfoPosterSize*100;
                mediaHeight = call.banner.height * Config.TVScraperChanInfoPosterSize*100;
                mediaPath = call.banner.path;
            } else if (call.type == tMovie && call.poster.path.size() > 0) {
                mediaWidth = call.poster.width * 0.5 * Config.TVScraperChanInfoPosterSize*100;
                mediaHeight = call.poster.height * 0.5 * Config.TVScraperChanInfoPosterSize*100;
                mediaPath = call.poster.path;
            }
        }
    }

    chanEpgImagesPixmap->Fill(clrTransparent);
    DecorBorderClearByFrom(BorderTVSPoster);
    if( mediaPath.length() > 0 ) {
        cImage *img = imgLoader.LoadFile(mediaPath.c_str(), mediaWidth, mediaHeight);
        if( img ) {
            chanEpgImagesPixmap->DrawImage(cPoint(0, 0), *img);

            DecorBorderDraw(20 + Config.decorBorderChannelEPGSize, topBarHeight + Config.decorBorderTopBarSize*2 + 20 + Config.decorBorderChannelEPGSize, img->Width(), img->Height(),
                Config.decorBorderChannelEPGSize, Config.decorBorderChannelEPGType, Config.decorBorderChannelEPGFg, Config.decorBorderChannelEPGBg, BorderTVSPoster);
        }
    }
}

void cFlatDisplayChannel::SetMessage(eMessageType Type, const char *Text) {
    if( !doOutput )
        return;

    // Wenn es einen Text gibt, diesen Anzeigen ansonsten Message ausblenden
    if( Text )
        MessageSet(Type, Text);
    else
        MessageClear();
}

void cFlatDisplayChannel::SignalQualityDraw(void) {
    int SignalStrength = cDevice::ActualDevice()->SignalStrength();
    int SignalQuality = cDevice::ActualDevice()->SignalQuality();
    int signalWidth = channelWidth / 2;

    if( LastSignalStrength == SignalStrength && LastSignalQuality == SignalQuality )
        return;
    LastSignalStrength = SignalStrength;
    LastSignalQuality = SignalQuality;

    cFont *SignalFont = cFont::CreateFont(Setup.FontOsd, Config.decorProgressSignalSize);

    int top = fontHeight*2 + fontSmlHeight*2 + marginItem;
    top += max(fontSmlHeight, Config.decorProgressSignalSize) - (Config.decorProgressSignalSize*2) - marginItem;
    int left = marginItem * 2;
    int progressTop = fontHeight*2 + fontSmlHeight*2 + marginItem;
    progressTop += max(fontSmlHeight, Config.decorProgressSignalSize) / 2 - Config.decorProgressSignalSize / 2;

    progressTop = top;

    chanInfoBottomPixmap->DrawText(cPoint(left, top), "STR",
        Theme.Color(clrChannelSignalFont), Theme.Color(clrChannelBg), SignalFont);
    int progressLeft = left + SignalFont->Width("STR") + SignalFont->Width(" ") + marginItem;
    int progressWidth = signalWidth / 2 - progressLeft - marginItem;
    ProgressBarDrawRaw(chanInfoBottomPixmap, chanInfoBottomPixmap, cRect(progressLeft, progressTop, progressWidth, Config.decorProgressSignalSize),
        cRect(progressLeft, progressTop, progressWidth, Config.decorProgressSignalSize), SignalStrength, 100,
        Config.decorProgressSignalFg, Config.decorProgressSignalBarFg, Config.decorProgressSignalBg, Config.decorProgressSignalType, false, Config.SignalQualityUseColors);

    //left = signalWidth / 2 + marginItem;
    top += Config.decorProgressSignalSize + marginItem;
    progressTop = top;

    chanInfoBottomPixmap->DrawText(cPoint(left, top), "SNR",
        Theme.Color(clrChannelSignalFont), Theme.Color(clrChannelBg), SignalFont);
    progressLeft = left + SignalFont->Width("STR") + SignalFont->Width(" ") + marginItem;
    //progressWidth = signalWidth - progressLeft - marginItem;

    ProgressBarDrawRaw(chanInfoBottomPixmap, chanInfoBottomPixmap, cRect(progressLeft, progressTop, progressWidth, Config.decorProgressSignalSize),
        cRect(progressLeft, progressTop, progressWidth, Config.decorProgressSignalSize), SignalQuality, 100,
        Config.decorProgressSignalFg, Config.decorProgressSignalBarFg, Config.decorProgressSignalBg, Config.decorProgressSignalType, false, Config.SignalQualityUseColors);

    SignalStrengthRight = progressLeft + progressWidth;

    delete SignalFont;
}

// you need oscam min rev 10653
// you need dvbapi min commit 85da7b2
void cFlatDisplayChannel::DvbapiInfoDraw(void) {
    dsyslog("DvbapiInfoDraw");
    int ChannelSid = CurChannel->Sid();

    static cPlugin *pDVBApi = cPluginManager::GetPlugin("dvbapi");
    if (!pDVBApi)
        return;
    sDVBAPIEcmInfo ecmInfo;
    ecmInfo.ecmtime = -1;
    ecmInfo.hops = -1;

    /*
    ecmInfo.cardsystem = "nagravision";
    ecmInfo.reader = "kd";
    ecmInfo.ecmtime = 200;
    */

    dsyslog("ChannelSid: %d Channel: %s", ChannelSid, CurChannel->Name());

    ecmInfo.sid = ChannelSid;
    if (!pDVBApi->Service("GetEcmInfo", &ecmInfo)) {
        return;
    }
    dsyslog("caid: %d", ecmInfo.caid);
    dsyslog("cardsystem: %s", *ecmInfo.cardsystem);
    dsyslog("reader: %s", *ecmInfo.reader);
    dsyslog("from: %s", *ecmInfo.from);
    dsyslog("protocol: %s", *ecmInfo.protocol);

    if (ecmInfo.hops < 0 || ecmInfo.ecmtime <= 0)
        return;
    int top = fontHeight*2 + fontSmlHeight*2 + marginItem;
    top += max(fontSmlHeight, Config.decorProgressSignalSize) - (Config.decorProgressSignalSize*2) - marginItem;
    int left = BitrateRight + marginItem * 2;
    if (BitrateRight == 0 )
        left = SignalStrengthRight + marginItem * 2;

    cFont *dvbapiInfoFont = cFont::CreateFont(Setup.FontOsd, (Config.decorProgressSignalSize*2));
    cString dvbapiInfoText;
    dvbapiInfoText = cString::sprintf("DVBAPI - %s %s %s %s (%d)", tr("System"), *ecmInfo.cardsystem, tr("from"), *ecmInfo.reader, ecmInfo.ecmtime);

    chanInfoBottomPixmap->DrawText(cPoint(left, top), dvbapiInfoText, Theme.Color(clrChannelSignalFont), Theme.Color(clrChannelBg), dvbapiInfoFont, dvbapiInfoFont->Width(dvbapiInfoText) * 2);

}

void cFlatDisplayChannel::BitrateDraw(void) {
    int top = fontHeight*2 + fontSmlHeight*2 + marginItem;
    top += max(fontSmlHeight, Config.decorProgressSignalSize) - (Config.decorProgressSignalSize*2) - marginItem;
    int left = SignalStrengthRight + marginItem * 4;
    cFont *SignalFont = cFont::CreateFont(Setup.FontOsd, Config.decorProgressSignalSize);
    cFont *BitrateFont = cFont::CreateFont(Setup.FontOsd, (Config.decorProgressSignalSize*2));

/*
    if( Config.SignalQualityShow ) {
        int signalWidth = channelWidth / 2;
        int progressLeft = bottomLeft + SignalFont->Width("STR") + SignalFont->Width(" ") + marginItem;
        int progressWidth = signalWidth / 2 - progressLeft - marginItem;

        left = progressLeft + progressWidth + marginItem * 4;
    }
*/
    cString bitrateText;
    if( bitrateAudio > 0.0 || bitrateDolby == 0.0 )
        bitrateText = cString::sprintf("Video: %.2f Mbit/s | Audio: %.2f kbit/s", bitrateVideo / 1000000.0, bitrateAudio / 1000.0 );
    else
        bitrateText = cString::sprintf("Video: %.2f Mbit/s | Dolby: %.2f kbit/s", bitrateVideo / 1000000.0, bitrateDolby / 1000.0 );

    chanInfoBottomPixmap->DrawText(cPoint(left, top), bitrateText, Theme.Color(clrChannelSignalFont), Theme.Color(clrChannelBg), BitrateFont, BitrateFont->Width(bitrateText) * 2);

    BitrateRight = left + BitrateFont->Width(bitrateText) + marginItem;

    delete SignalFont;
    delete BitrateFont;
}

// Indicates a channel switch on the given DVB device.
// If ChannelNumber is 0, this is before the channel is being switched,
// otherwise ChannelNumber is the number of the channel that has been switched to.
// LiveView tells whether this channel switch is for live viewing.
void cFlatDisplayChannel::ChannelSwitch(const cDevice * device, int channelNumber, bool liveView)
{
    if( liveView == false) // ChannelSwitch from EPG-Scan, streamdev or other?
        return;
    if( channelNumber == 0 ) { // before the channel is being switched -> remove receiver
        if (m_Receiver) {
            //dsyslog("ChannelSwitch: Receiver REMOVE");
            m_Receiver->Deactivate();
            DELETENULL(m_Receiver);
        }
        return;
    }

    // at this point we finally switch to a new channel on liveView
    bitrateVideo = bitrateAudio = bitrateDolby = 0.0;
    eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack();
    const cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel());

    if( channel && Config.ChannelBitrateShow && doOutput ) {
        if ( m_Receiver ) { // this should not be happen!!!
            //dsyslog("ChannelSwitch: Receiver is still Active -> remove it!");
            m_Receiver->Deactivate();
            DELETENULL(m_Receiver);
        }
        //dsyslog("ChannelSwitch: Receiver ATTACH %d - %s", cDevice::PrimaryDevice()->DeviceNumber(), channel->Name());

        m_Receiver = new cFemonReceiver(channel, IS_AUDIO_TRACK(track) ? int(track - ttAudioFirst) : 0, IS_DOLBY_TRACK(track) ? int(track - ttDolbyFirst) : 0);
        cDevice::ActualDevice()->AttachReceiver(m_Receiver);
    }
}

void cFlatDisplayChannel::SetAudioTrack(int Index, const char * const *Tracks)
{
    bitrateVideo = bitrateAudio = bitrateDolby = 0.0;
    eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack();
    if( m_Receiver ) {
        dsyslog("SetAudioTrack: Receiver remove");
        m_Receiver->Deactivate();
        DELETENULL(m_Receiver);
    }

    if( !Config.ChannelBitrateShow )
        return;

    const cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel());
    if( channel && doOutput ) {
        dsyslog("SetAudioTrack: Receiver attach - %s", channel->Name());
        m_Receiver = new cFemonReceiver(channel, IS_AUDIO_TRACK(track) ? int(track - ttAudioFirst) : 0, IS_DOLBY_TRACK(track) ? int(track - ttDolbyFirst) : 0);
        cDevice::ActualDevice()->AttachReceiver(m_Receiver);
    }
}

void cFlatDisplayChannel::Flush(void) {
    if( !doOutput )
        return;

    int Current = 0;
    int Total = 0;
    if( present ) {
        time_t t = time(NULL);
        if (t > present->StartTime())
            Current = t - present->StartTime();
        Total = present->Duration();
        ProgressBarDraw(Current, Total);
    }
    if( Config.SignalQualityShow )
        SignalQualityDraw();

    if( Config.ChannelIconsShow ) {
        cDevice::PrimaryDevice()->GetVideoSize(screenWidth, screenHeight, screenAspect);
        if (screenWidth != lastScreenWidth) {
            lastScreenWidth = screenWidth;
            ChannelIconsDraw(CurChannel, true);
        }
    }

    if( Config.ChannelBitrateShow && doOutput && !m_Receiver ) {
        const cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel());
        eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack();
        if( channel ) {
            //dsyslog("ChannelSwitch: Receiver ATTACH %d - %s FLUSH", cDevice::PrimaryDevice()->DeviceNumber(), channel->Name());
            m_Receiver = new cFemonReceiver(channel, IS_AUDIO_TRACK(track) ? int(track - ttAudioFirst) : 0, IS_DOLBY_TRACK(track) ? int(track - ttDolbyFirst) : 0);
            cDevice::ActualDevice()->AttachReceiver(m_Receiver);
        }
    }

    if( Config.ChannelBitrateShow && m_Receiver ) {
        bitrateVideo = m_Receiver->VideoBitrate();
        bitrateAudio = m_Receiver->AudioBitrate();
        bitrateDolby = m_Receiver->AC3Bitrate();

        BitrateDraw();
    }

    if( Config.ChannelDvbapiInfoShow )
        DvbapiInfoDraw();

    TopBarUpdate();
    osd->Flush();
}

void cFlatDisplayChannel::PreLoadImages(void) {
    int height = (fontHeight*2) + (fontSmlHeight*2) + marginItem - marginItem*2;
    imgLoader.LoadIcon("logo_background", height, height);
    int imageBGHeight, imageBGWidth;
    imageBGHeight = imageBGWidth = height;

    cImage *imgBG = imgLoader.LoadIcon("logo_background", height*1.34, height);
    if( imgBG ) {
        imageBGHeight = imgBG->Height();
        imageBGWidth = imgBG->Width();
    }
    imgLoader.LoadIcon("radio", imageBGWidth - 10, imageBGHeight - 10);
    imgLoader.LoadIcon("tv", imageBGWidth - 10, imageBGHeight - 10);

    int index = 0;
    height = ((fontHeight*2) + (fontSmlHeight*2) + marginItem) - marginItem*2;
    cImage *img = NULL;
    for(cChannel *Channel = Channels.First(); Channel && index < LOGO_PRE_CACHE; Channel = Channels.Next(Channel) )
    {
        img = imgLoader.LoadLogo(Channel->Name(), imageBGWidth - 4, imageBGHeight - 4);
        if( img )
            index++;
    }

    height = max(fontSmlHeight, Config.decorProgressSignalSize);
    imgLoader.LoadIcon("crypted", 999, height);
    imgLoader.LoadIcon("uncrypted", 999, height);
    imgLoader.LoadIcon("unknown_asp", 999, height);
    imgLoader.LoadIcon("43", 999, height);
    imgLoader.LoadIcon("169", 999, height);
    imgLoader.LoadIcon("169w", 999, height);
    imgLoader.LoadIcon("221", 999, height);
    imgLoader.LoadIcon("1920x1080", 999, height);
    imgLoader.LoadIcon("1440x1080", 999, height);
    imgLoader.LoadIcon("1280x720", 999, height);
    imgLoader.LoadIcon("960x720", 999, height);
    imgLoader.LoadIcon("704x576", 999, height);
    imgLoader.LoadIcon("720x576", 999, height);
    imgLoader.LoadIcon("544x576", 999, height);
    imgLoader.LoadIcon("528x576", 999, height);
    imgLoader.LoadIcon("480x576", 999, height);
    imgLoader.LoadIcon("352x576", 999, height);
    imgLoader.LoadIcon("unknown_res", 999, height);
    imgLoader.LoadIcon("hd", 999, height);
    imgLoader.LoadIcon("sd", 999, height);
}