2 Copyright 2007-2008 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
22 #include "vchannellist.h"
25 #include "playerlive.h"
26 #include "playervideolive.h"
27 #include "playerradiolive.h"
37 #include "vaudioselector.h"
43 #include "vteletextview.h"
44 #include "vepgsummary.h"
45 #include "vepglistadvanced.h"
46 #include "staticartwork.h"
48 #include "messagequeue.h"
50 #include "vvideolivetv.h"
52 static const char* TAG = "VVideoLiveTV";
55 VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, VChannelList* tvchannelList)
57 vdr = VDR::getInstance();
58 boxstack = BoxStack::getInstance();
59 video = Video::getInstance();
64 vchannelList = tvchannelList;
65 numberWidth = VDR::getInstance()->getChannelNumberWidth();
67 currentChannelIndex = 0;
68 previousChannelIndex = 0;
75 // Convert channel number to index
76 for(UINT i = 0; i < chanList->size(); i++)
78 if ((*chanList)[i]->number == initialChannelNumber)
80 currentChannelIndex = i;
88 videoMode = video->getMode();
90 if ((*chanList)[currentChannelIndex]->type == VDR::VIDEO)
92 streamType = VDR::VIDEO;
93 player = new PlayerVideoLive(Control::getInstance(), this, this, chanList);
97 streamType = VDR::RADIO;
98 player = new PlayerRadioLive(Control::getInstance(), this, chanList);
102 setSize(video->getScreenWidth(), video->getScreenHeight());
104 setBackgroundColour(DrawStyle::TRANSPARENT);
106 OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
109 osdv->updateBackgroundColor(DrawStyle::BLACK);
112 // This variable is set to true if the user pressed OK to bring the OSD on screen
113 // This is only used on old remotes to stop up/down buttons being used for osd-epg scrolling
114 okTriggeredOSD = false;
117 info.setChannelLogo(initialChannelNumber);
119 if (osdv && streamType == VDR::RADIO) {
120 radioChannelLogo.setPosition(video->getScreenWidth()/4,video->getScreenHeight()/4);
121 radioChannelLogo.setSize(video->getScreenWidth()/2,video->getScreenHeight()/2);
122 radioChannelLogo.setVisible(true);
123 radioChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
124 add(&radioChannelLogo);
127 osdposterbanner.setPosition(20,20);
128 //osdposterbanner.setBackgroundColour(DrawStyle::OSDBACKGROUND);
129 osdposterbanner.setSize(video->getScreenWidth()*4/10,video->getScreenHeight()*4/10);
130 osdposterbanner.setVisible(false);
131 add(&osdposterbanner);
133 osd.setBackgroundColour(DrawStyle::OSDBACKGROUND);
134 osd.setPosition(0, video->getScreenHeight() - 150);
135 osd.setSize(video->getScreenWidth(), 150);
136 osd.setVisible(false);
139 int channellogomove=0;
143 //osdChannelLogo.setBackgroundColour(DrawStyle::OSDBACKGROUND);
144 osdChannelLogo.setPosition(30,5);
145 osdChannelLogo.setSize(60,60);
146 osdChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
147 osd.add(&osdChannelLogo);
148 channellogomove = 30-5;
152 //clock.setBackgroundColour(DrawStyle::OSDBACKGROUND);
153 clock.setPosition(osd.getWidth() - 100, 4);
154 clock.setSize(90, 30);
157 //osdChanNum.setBackgroundColour(DrawStyle::OSDBACKGROUND);
158 osdChanNum.setPosition(60 + channellogomove, 4);
159 osdChanNum.setSize((numberWidth * 10) + 22, getFontHeight() + 5); // 10 px = width of number chars in font
160 osd.add(&osdChanNum);
162 //osdChanName.setBackgroundColour(DrawStyle::OSDBACKGROUND);
163 osdChanName.setPosition(osdChanNum.getX2() + 10, 4);
164 osdChanName.setSize(300, 30);
165 osd.add(&osdChanName);
167 boxRed.setBackgroundColour(DrawStyle::RED);
168 boxRed.setPosition(54+0*boxdiff, 104);
169 boxRed.setSize(18, 16);
172 boxGreen.setBackgroundColour(DrawStyle::GREEN);
173 boxGreen.setPosition(54+1*boxdiff, 104);
174 boxGreen.setSize(18, 16);
177 boxYellow.setBackgroundColour(DrawStyle::YELLOW);
178 boxYellow.setPosition(54+2*boxdiff, 104);
179 boxYellow.setSize(18, 16);
182 boxBlue.setBackgroundColour(DrawStyle::BLUE);
183 boxBlue.setPosition(54+3*boxdiff, 104);
184 boxBlue.setSize(18, 16);
187 //textRed.setBackgroundColour(DrawStyle::OSDBACKGROUND);
188 textRed.setPosition(boxRed.getX2(), 98);
189 textRed.setSize(boxGreen.getX() - boxRed.getX2(), 30);
190 textRed.setText(tr("Summary"));
193 if (streamType == VDR::VIDEO)
195 //textGreen.setBackgroundColour(DrawStyle::OSDBACKGROUND);
196 textGreen.setPosition(boxGreen.getX2(), 98);
197 textGreen.setSize(boxYellow.getX() - boxGreen.getX2(), 30);
198 textGreen.setText(tr("Audio"));
202 //textYellow.setBackgroundColour(DrawStyle::OSDBACKGROUND);
203 textYellow.setPosition(boxYellow.getX2(), 98);
204 textYellow.setSize(boxBlue.getX() - boxYellow.getX2(), 30);
205 textYellow.setText(tr("Teletext"));
206 osd.add(&textYellow);
208 //textBlue.setBackgroundColour(DrawStyle::OSDBACKGROUND);
209 textBlue.setPosition(boxBlue.getX2(), 98);
210 textBlue.setSize(osd.getX2() - boxBlue.getX2(), 30);
211 textBlue.setText(tr("EPG"));
214 //sl.setBackgroundColour(DrawStyle::OSDBACKGROUND);
215 sl.setPosition(90, 36);
219 bufferBar.setPosition(osd.getWidth() - 90, 70);
220 bufferBar.setSize(40, 20);
221 bufferBar.setVisible(true);
226 sAspectRatio.setPosition(osd.getWidth() - 90, 40);
227 sAspectRatio.nextColour = DrawStyle::LIVETVSYMBOLS;
228 sAspectRatio.setVisible(false);
229 osd.add(&sAspectRatio);
231 sAudioChannels.setPosition(osd.getWidth() - 130, 40);
232 sAudioChannels.nextColour = DrawStyle::LIVETVSYMBOLS;
233 sAudioChannels.setVisible(false);
234 osd.add(&sAudioChannels);
240 ninfo.setStaticArtwork(sa_txtoff);
241 txtlogo.setPosition(54+4*boxdiff,104);
242 txtlogo.setSize(22,20);
243 txtlogo.setTVMedia(ninfo, WTVMedia::ZoomVertical);
246 ninfo.setStaticArtwork(sa_dolbyoff);
247 dolbylogo.setPosition(54+4*boxdiff+15,104);
248 dolbylogo.setSize(22,20);
249 dolbylogo.setTVMedia(ninfo, WTVMedia::ZoomVertical);
252 ninfo.setStaticArtwork(sa_sd576i);
253 reslogo.setPosition(54+4*boxdiff+30,104);
254 reslogo.setSize(22,20);
255 reslogo.setTVMedia(ninfo, WTVMedia::ZoomVertical);
258 reslogo.setVisible(false);
259 dolbylogo.setVisible(false);
260 txtlogo.setVisible(false);
263 //textUnavailable.setBackgroundColour(DrawStyle::OSDBACKGROUND);
264 textUnavailable.setPosition(60, 30);
265 textUnavailable.setSize(osd.getWidth() - 120, 30);
266 textUnavailable.setText(tr("Channel Unavailable"));
267 textUnavailable.setVisible(false);
268 add(&textUnavailable);
270 vdisplay.mode = Fullscreen;
271 vdisplay.fallbackMode = Fullscreen;
277 MessageQueue::getInstance()->addReceiver(this);
280 void VVideoLiveTV::preDelete()
285 VVideoLiveTV::~VVideoLiveTV()
287 MessageQueue::getInstance()->removeReceiver(this);
289 video->setDefaultAspect();
291 OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
294 osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
298 void VVideoLiveTV::delData()
302 int eventListSize = eventList->size();
303 for(int i = 0; i < eventListSize; i++)
305 delete (*eventList)[i];
312 int VVideoLiveTV::handleCommand(int command)
318 if (osd.getVisible() && !textUnavailable.getVisible())
321 return BoxStack::COMMAND_HANDLED;
323 // else drop through to stop
329 vchannelList->highlightChannel((*chanList)[currentChannelIndex]);
330 return BoxStack::DELETE_ME;
333 // navigate EPG, bring it onscreen if it's not there
336 if (InputMan::getInstance()->mayHaveFewButtons())
338 if (okTriggeredOSD) doUpDown(false);
339 else doChanUpDown(UP);
345 return BoxStack::COMMAND_HANDLED;
349 if (InputMan::getInstance()->mayHaveFewButtons())
351 if (okTriggeredOSD) doUpDown(true);
352 else doChanUpDown(DOWN);
358 return BoxStack::COMMAND_HANDLED;
363 return BoxStack::COMMAND_HANDLED;
368 return BoxStack::COMMAND_HANDLED;
370 case Input::CHANNELUP:
373 return BoxStack::COMMAND_HANDLED;
375 case Input::CHANNELDOWN:
378 return BoxStack::COMMAND_HANDLED;
380 case Input::PREVCHANNEL:
382 channelChange(PREVIOUS, 0);
383 osdChannelIndex = currentChannelIndex;
385 return BoxStack::COMMAND_HANDLED;
390 return BoxStack::COMMAND_HANDLED;
396 return BoxStack::COMMAND_HANDLED;
402 return BoxStack::COMMAND_HANDLED;
416 // key in channel number
418 return BoxStack::COMMAND_HANDLED;
423 if (streamType == VDR::VIDEO) doAudioSelector();
424 return BoxStack::COMMAND_HANDLED;
428 if (streamType ==VDR::VIDEO)
430 doTeletext(); //TODO: Add a selector for subtitles or teletext
432 return BoxStack::COMMAND_HANDLED;
438 return BoxStack::COMMAND_HANDLED;
441 if (streamType == VDR::VIDEO)
442 (static_cast<PlayerVideoLive*>(player))->toggleSubtitles();
443 return BoxStack::COMMAND_HANDLED;
446 return BoxStack::ABANDON_COMMAND;
449 void VVideoLiveTV::go()
453 boxstack->update(this);
458 player->go(currentChannelIndex);
461 void VVideoLiveTV::stop()
463 Timers::getInstance()->cancelTimer(this, 1);
464 Timers::getInstance()->cancelTimer(this, 2);
469 void VVideoLiveTV::doLeftRight(bool right)
471 if (osd.getVisible())
473 if (right) osdChannelIndex = upChannel(osdChannelIndex);
474 else osdChannelIndex = downChannel(osdChannelIndex);
478 osdChannelIndex = currentChannelIndex;
483 void VVideoLiveTV::doUpDown(bool /* down */)
485 if (osd.getVisible())
497 void VVideoLiveTV::doChanUpDown(int which)
499 channelChange(OFFSET, which);
500 osdChannelIndex = currentChannelIndex;
504 void VVideoLiveTV::doOK()
506 if (osd.getVisible())
511 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * static_cast<int>(pow(10.f, i));
513 channelChange(NUMBER, newChannel);
514 osdChannelIndex = currentChannelIndex;
517 else if (osdChannelIndex == currentChannelIndex)
523 channelChange(INDEX, osdChannelIndex);
529 osdChannelIndex = currentChannelIndex;
531 okTriggeredOSD = true;
535 void VVideoLiveTV::doSummary()
538 Channel* currentChannel = (*chanList)[osdChannelIndex];
539 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
544 sort(eventList->begin(), eventList->end(), EventSorter());
546 if (eventList->size() < 1) return;
547 Event* event = (*eventList)[0];
548 event->loadinfos(currentChannel->number);
550 VEpgSummary* vr = new VEpgSummary(event,currentChannel);
553 boxstack->update(vr);
556 void VVideoLiveTV::doKey(int command)
558 if (!osd.getVisible()) // First key. prep the data
561 updatePosterBanner();
566 for (i = keying - 1; i >= 0; i--) keyingInput[i+1] = keyingInput[i];
567 keyingInput[0] = command;
570 char* keyingString = new char[numberWidth + 1];
571 for (i = 0; i < numberWidth; i++) keyingString[i] = '_';
572 keyingString[numberWidth] = '\0';
574 for (i = 0; i < keying; i++) keyingString[i] = static_cast<char>(keyingInput[keying - 1 - i] + 48);
576 if (keying == numberWidth)
579 for(i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * static_cast<int>(pow(10.f, i));
581 channelChange(NUMBER, newChannel);
582 osdChannelIndex = currentChannelIndex;
583 Timers::getInstance()->cancelTimer(this, 1); // cancel the timer to react to keying input,
584 displayOSD(true); // this will put one back if required
588 osdChanNum.setText(keyingString);
590 if (!osd.getVisible())
592 osd.setVisible(true);
597 osdChanNum.fillColour(DrawStyle::VIEWBACKGROUND);
600 boxstack->update(this, osd.getRegion());
601 Timers::getInstance()->setTimerD(this, 1, 3); // 3s for keying input
603 delete[] keyingString;
606 void VVideoLiveTV::doTeletext(bool subtitlemode)
608 if (streamType != VDR::VIDEO) return;
610 PlayerVideoLive* playervl = static_cast<PlayerVideoLive*>(player);
612 playervl->tellSubtitlesOSDVisible(true);
619 // and reset the display - this is a copy from setNowNextData
620 char formatChanNum[20];
621 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
622 osdChanNum.setText(formatChanNum);
623 osdChanName.setText((*chanList)[osdChannelIndex]->name);
625 playervl->tellSubtitlesOSDVisible(true);
626 if (osd.getVisible()) clearScreen();
628 VTeletextView* vtxv = playervl->getTeletextDecoder()->getTeletxtView();
631 vtxv = new VTeletextView(playervl->getTeletextDecoder(), this, playervl);
632 playervl->getTeletextDecoder()->registerTeletextView(vtxv);
636 vtxv->setSubtitleMode(subtitlemode);
642 BoxStack::getInstance()->add(vtxv);
645 BoxStack::getInstance()->update(this);
646 BoxStack::getInstance()->update(vtxv);
649 void VVideoLiveTV::doAudioSelector()
651 // Only called if streamtype == VDR::VIDEO
652 PlayerVideoLive* playervl = static_cast<PlayerVideoLive*>(player);
654 // If the osd is already visisble there might be a timer for it
655 Timers::getInstance()->cancelTimer(this, 1);
656 //This causes a deadlock with the timertrhread itself is locked
662 // and reset the display - this is a copy from setNowNextData
663 char formatChanNum[20];
664 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
665 osdChanNum.setText(formatChanNum);
666 osdChanName.setText((*chanList)[osdChannelIndex]->name);
668 int subtitleChannel = playervl->getCurrentSubtitleChannel();
669 int subtitleType = 0x10;
670 if (!playervl->isSubtitlesOn())
672 if (playervl->getTeletextDecoder()->getTeletxtView() &&
673 playervl->getTeletextDecoder()->getTeletxtView()->isInSubtitleMode())
675 subtitleChannel = playervl->getTeletextDecoder()->getPage();
680 subtitleType = 0xFF; //turnedOff
686 vas = new VAudioSelector(this, (*chanList)[currentChannelIndex], playervl->getCurrentAudioChannel(),
687 subtitleType,subtitleChannel,NULL);
689 vas->setBackgroundColour(DrawStyle::OSDBACKGROUND);
690 vas->setPosition(0, osd.getScreenY() - vas->getHeight());
693 // make vas != null and displayOSD will not set a timer or do any boxstack update
694 if (osd.getVisible()) displayOSD(false);
695 else displayOSD(true);
698 BoxStack::getInstance()->add(vas);
699 BoxStack::getInstance()->update(this);
700 BoxStack::getInstance()->update(vas);
703 void VVideoLiveTV::doEPG()
705 if (osd.getVisible()) clearScreen();
707 if (!Control::getInstance()->isAdvMenus())
709 VEpg* vepg = new VEpg(this, currentChannelIndex, chanList);
712 boxstack->update(vepg);
716 Channel* currentChannel = (*chanList)[osdChannelIndex];
717 VEpgListAdvanced *vepg= new VEpgListAdvanced(this, chanList, currentChannel->number);
720 boxstack->update(vepg);
724 void VVideoLiveTV::setNowNextData()
728 Channel* currentChannel = (*chanList)[osdChannelIndex];
730 char formatChanNum[20];
731 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, currentChannel->number);
732 osdChanNum.setText(formatChanNum);
733 osdChanName.setText(currentChannel->name);
735 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
739 sl.setText(tr("No channel data available"));
743 sort(eventList->begin(), eventList->end(), EventSorter());
745 char tempString[300];
748 int eventListSize = eventList->size();
749 std::stringstream ss;
750 for(int i = 0; i < eventListSize; i++)
752 event = (*eventList)[i];
754 time_t etime = event->time;
755 LOCALTIME_R(&etime, &btime);
756 // FIXME convert following to std::strftime
758 strftime(tempString, 299, "%0H:%0M ", &btime);
760 strftime(tempString, 299, "%H:%M ", &btime);
762 ss << tempString << " " << event->title << "\n";
764 sl.setText(ss.str().c_str());
770 void VVideoLiveTV::displayOSD(bool newNowNextData)
772 PlayerVideoLive* playerlivetv = dynamic_cast<PlayerVideoLive*>(player);
773 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(true);
774 osd.setVisible(true);
778 updatePosterBanner();
782 if (osdposterbanner.getVisible()) osdposterbanner.draw();
787 toupdate=*osd.getRegion();
790 if (osdposterbanner.getVisible())
792 boxstack->update(this);
796 boxstack->update(this, &toupdate);
799 bool setTimer = true;
800 if (vas) setTimer = false;
801 if (textUnavailable.getVisible()) setTimer = false;
803 if (setTimer) Timers::getInstance()->setTimerD(this, 1, 4);
806 void VVideoLiveTV::clearScreen()
808 Timers::getInstance()->cancelTimer(this, 1);
810 textUnavailable.setVisible(false);
811 osd.setVisible(false);
812 osdposterbanner.setVisible(false);
814 okTriggeredOSD = false;
817 boxstack->update(this);
819 PlayerVideoLive* playerlivetv = dynamic_cast<PlayerVideoLive*>(player);
820 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false);
823 void VVideoLiveTV::showUnavailable()
825 LogNT::getInstance()->debug(TAG, "Show unavailable called");
826 textUnavailable.setVisible(true);
827 textUnavailable.draw();
829 if (!osd.getVisible()) displayOSD(true);
831 boxstack->update(this, textUnavailable.getRegion());
834 void VVideoLiveTV::setClock()
840 LOCALTIME_R(&t, &tms);
841 strftime(timeString, 19, "%H:%M", &tms);
842 clock.setText(timeString);
844 time_t dt = 60 - (t % 60); // seconds to the next minute
845 if (dt == 0) dt = 60; // advance a whole minute if necessary
846 dt += t; // get a time_t value for it rather than using duration
847 // (so it will occur at the actual second and not second and a half)
849 Timers::getInstance()->setTimerT(this, 2, dt);
852 void VVideoLiveTV::timercall(int ref)
858 LogNT::getInstance()->debug(TAG, "Timer Call 1 key start.");
860 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * static_cast<int>(pow(10.f, i));
862 Message* m = new Message();
863 m->message = Message::CHANNEL_CHANGE;
865 m->parameter = newChannel;
866 m->tag = 1; // signal to call displayOSD();
867 MessageQueue::getInstance()->postMessage(m);
868 LogNT::getInstance()->debug(TAG, "Timer Call 1 key end.");
872 LogNT::getInstance()->debug(TAG, "Timer Call 1 not key start.");
873 // We have received a timer, we are not keying. If still prebuffering, don't remove the bar
874 if (preBuffering < 100)
876 LogNT::getInstance()->debug(TAG, "Still prebuffering, not removing osd...");
877 Timers::getInstance()->setTimerD(this, 1, 2); // reset timer for another 2s
880 bool osdpbvisible=osdposterbanner.getVisible();
881 LogNT::getInstance()->debug(TAG, "Timer Call 1 notkey 1.");
882 osd.setVisible(false);
883 osdposterbanner.setVisible(false);
884 okTriggeredOSD = false;
885 LogNT::getInstance()->debug(TAG, "Timer Call 1 notkey 2.");
887 LogNT::getInstance()->debug(TAG, "Timer Call 1 notkey 4.");
888 if (osdpbvisible) boxstack->update(this);
889 else boxstack->update(this, osd.getRegion());
891 LogNT::getInstance()->debug(TAG, "Timer Call 1 notkey 3.");
892 PlayerVideoLive* playerlivetv = dynamic_cast<PlayerVideoLive*>(player);
893 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false);
894 LogNT::getInstance()->debug(TAG, "Timer Call 1 notkey end.");
899 LogNT::getInstance()->debug(TAG, "Timer Call 2 start.");
901 if (osd.getVisible())
904 boxstack->update(this, osd.getRegion());
906 LogNT::getInstance()->debug(TAG, "Timer Call 2 end.");
910 bool VVideoLiveTV::channelChange(UCHAR changeType, UINT newData)
913 if (streamType == VDR::VIDEO)
915 VTeletextView* vtxt = static_cast<PlayerVideoLive*>(player)->getTeletextDecoder()->getTeletxtView();
918 BoxStack::getInstance()->remove(vtxt);
921 if (changeType == INDEX)
923 newChannel = newData;
925 else if (changeType == NUMBER)
928 for(i = 0; i < chanList->size(); i++)
930 if ((*chanList)[i]->number == newData)
937 if (i == chanList->size())
943 else if (changeType == OFFSET)
945 if (newData == UP) newChannel = upChannel(currentChannelIndex);
946 else newChannel = downChannel(currentChannelIndex);
948 else if (changeType == PREVIOUS)
950 newChannel = previousChannelIndex;
954 return false; // bad input
957 if (newChannel == currentChannelIndex) return true;
959 previousChannelIndex = currentChannelIndex;
960 currentChannelIndex = newChannel;
964 LogNT::getInstance()->debug(TAG, "Set player to channel {}", currentChannelIndex);
965 player->setChannel(currentChannelIndex);
966 LogNT::getInstance()->debug(TAG, "Done Set player to channel {}", currentChannelIndex);
968 // Blank out the symbols
969 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
971 bufferBar.setPercent(0);
975 sAudioChannels.setVisible(false);
976 sAspectRatio.setVisible(false);
980 reslogo.setVisible(false);
981 dolbylogo.setVisible(false);
982 txtlogo.setVisible(false);
985 // Remove other stuff
986 if (textUnavailable.getVisible())
988 textUnavailable.setVisible(false);
994 Channel* currentChannel = (*chanList)[currentChannelIndex];
997 info.setChannelLogo(currentChannel->number);
998 if (streamType == VDR::RADIO)
1000 radioChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1001 radioChannelLogo.setVisible(true);
1003 osdChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1008 BoxStack::getInstance()->update(this);
1013 void VVideoLiveTV::processMessage(Message* m)
1015 if (m->message == Message::MOUSE_LBDOWN)
1017 //check if press is outside this view! then simulate cancel
1018 int x = m->parameter - osd.getScreenX();
1019 int y = m->tag - osd.getScreenY();
1020 if (osd.getVisible())
1022 if ((boxRed.getX() <= x) && (boxRed.getX() + static_cast<int>(boxRed.getWidth()) >= x) &&
1023 (boxRed.getY() <= y) && (boxRed.getY() + static_cast<int>(boxRed.getHeight()) >= y))
1025 BoxStack::getInstance()->handleCommand(Input::RED);
1027 else if ((boxGreen.getX() <= x) && (boxGreen.getX() + static_cast<int>(boxGreen.getWidth()) >= x) &&
1028 (boxGreen.getY() <= y) && (boxGreen.getY() + static_cast<int>(boxGreen.getHeight()) >= y))
1030 BoxStack::getInstance()->handleCommand(Input::GREEN);
1032 else if ((boxYellow.getX() <= x) && (boxYellow.getX() + static_cast<int>(boxYellow.getWidth()) >= x) &&
1033 (boxYellow.getY() <= y) && (boxYellow.getY() + static_cast<int>(boxYellow.getHeight()) >= y))
1035 BoxStack::getInstance()->handleCommand(Input::YELLOW);
1037 else if ((boxBlue.getX() <= x) && (boxBlue.getX() + static_cast<int>(boxBlue.getWidth()) >= x) &&
1038 (boxBlue.getY() <= y) && (boxBlue.getY() + static_cast<int>(boxBlue.getHeight()) >= y))
1040 BoxStack::getInstance()->handleCommand(Input::BLUE);
1044 BoxStack::getInstance()->handleCommand(Input::OK); //simulate rok press
1049 BoxStack::getInstance()->handleCommand(Input::OK); //simulate rok press
1052 else if (m->message == Message::CHANNEL_CHANGE)
1054 channelChange(NUMBER, m->parameter);
1055 osdChannelIndex = currentChannelIndex;
1056 if (m->tag == 1) displayOSD(true);
1058 else if (m->message == Message::CHILD_CLOSE)
1066 else if (m->message == Message::AUDIO_CHANGE_CHANNEL)
1068 LogNT::getInstance()->debug(TAG, "Received change audio channel to {:#x}", m->parameter);
1069 player->setAudioChannel((m->parameter & 0xFFFF), (m->parameter & 0xFF0000) >> 16, (m->parameter & 0xFF000000) >> 24);
1071 else if (m->message == Message::SUBTITLE_CHANGE_CHANNEL)
1073 if (streamType != VDR::VIDEO) return;
1075 PlayerVideoLive* playervl = static_cast<PlayerVideoLive*>(player);
1077 LogNT::getInstance()->debug(TAG, "Received change subtitle channel to {:#x}", m->parameter);
1078 int type = (m->parameter & 0xFF0000) >> 16;
1084 playervl->setSubtitleChannel((m->parameter & 0xFFFF));
1085 playervl->turnSubtitlesOn(true);
1086 VTeletextView* vtxt = playervl->getTeletextDecoder()->getTeletxtView();
1087 if (vtxt && vtxt->isInSubtitleMode())
1089 BoxStack::getInstance()->remove(vtxt);
1096 playervl->turnSubtitlesOn(false);
1097 VTeletextView* vtxt = playervl->getTeletextDecoder()->getTeletxtView();
1098 if (vtxt && vtxt->isInSubtitleMode())
1100 BoxStack::getInstance()->remove(vtxt);
1107 playervl->turnSubtitlesOn(false);
1109 playervl->getTeletextDecoder()->setPage((m->parameter & 0xFFFF));
1116 BoxStack::getInstance()->update(vas);
1117 //BoxStack::getInstance()->update(&osd); //eveil error
1119 BoxStack::getInstance()->update(this, osd.getRegion());
1121 else if (m->message == Message::PLAYER_EVENT)
1123 switch (m->parameter)
1125 case PlayerVideoLive::CONNECTION_LOST: // connection lost detected
1127 LogNT::getInstance()->debug(TAG, "Received connection lost from player");
1128 Control::getInstance()->connectionLost();
1132 case PlayerVideoLive::STREAM_END:
1134 // Message comes from playerlivetv through master mutex, so can do anything here
1139 case PlayerVideoLive::ASPECT43:
1141 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1144 osdv->updateBackgroundColor(DrawStyle::BLACK);
1147 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT43;
1148 sAspectRatio.setVisible(true);
1150 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1153 BoxStack::getInstance()->update(this, osd.getRegion());
1158 case PlayerVideoLive::ASPECT169:
1160 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT169;
1161 sAspectRatio.setVisible(true);
1163 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1166 osdv->updateBackgroundColor(DrawStyle::BLACK);
1170 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1173 BoxStack::getInstance()->update(this, osd.getRegion());
1178 case PlayerVideoLive::PREBUFFERING:
1180 preBuffering = m->tag;
1181 LogNT::getInstance()->debug(TAG, "Prebuffering - {}", preBuffering);
1182 bufferBar.setPercent(preBuffering);
1184 if (osd.getVisible())
1186 bufferBar.setVisible(true);
1189 bufferBar.getRootBoxRegion(&r); ///////// FIXME !!!
1190 BoxStack::getInstance()->update(this, &r);
1192 if (preBuffering == 100)
1194 doAudioChannelSymbol();
1202 void VVideoLiveTV::doAudioChannelSymbol()
1204 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1206 Channel* currentChannel = (*chanList)[osdChannelIndex];
1208 bool multiAudio = false;
1209 if (Audio::getInstance()->supportsAc3()) {
1210 if ((currentChannel->numDPids+currentChannel->numAPids) > 1) multiAudio = true;
1212 if (currentChannel->numAPids > 1) multiAudio = true;
1216 if (multiAudio) sAudioChannels.nextSymbol = WSymbol::MULTIAUDIO;
1217 else sAudioChannels.nextSymbol = WSymbol::SINGLEAUDIO;
1218 sAudioChannels.setVisible(true);
1222 dolbylogo.setVisible(true);
1223 txtlogo.setVisible(true);
1225 if (currentChannel->tpid!=0) info.setStaticArtwork(sa_txton);
1226 else info.setStaticArtwork(sa_txtoff);
1227 txtlogo.setTVMedia(info, WTVMedia::ZoomVertical);
1230 if (Audio::getInstance()->supportsAc3() && currentChannel->numDPids>1)
1231 info.setStaticArtwork(sa_dolbyon);
1232 else info.setStaticArtwork(sa_dolbyoff);
1233 dolbylogo.setTVMedia(info, WTVMedia::ZoomVertical);
1235 Demuxer* demux=Demuxer::getInstance();
1237 int vertical_size=demux->getVerticalSize();
1238 LogNT::getInstance()->debug(TAG, "TVMedia vertical size {}", vertical_size);
1239 reslogo.setVisible(true);
1240 switch (vertical_size) {
1242 info.setStaticArtwork(sa_sd576i);
1243 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1245 info.setStaticArtwork(sa_hd720p);
1246 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1248 info.setStaticArtwork(sa_hd1080i);
1249 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1250 default: // we assume sd
1251 reslogo.setVisible(false);
1255 reslogo.setVisible(false);
1261 if (osd.getVisible())
1263 sAudioChannels.draw();
1265 sAudioChannels.getRootBoxRegion(&r); ///////// FIXME !!!
1269 BoxStack::getInstance()->update(this, &r);
1273 UINT VVideoLiveTV::upChannel(UINT index)
1275 if (index == (chanList->size() - 1)) // at the end
1276 return 0; // so go to start
1281 UINT VVideoLiveTV::downChannel(UINT index)
1283 if (index == 0) // at the start
1284 return chanList->size() - 1; // so go to end
1289 void VVideoLiveTV::toggleChopSides()
1291 if (video->getTVsize() == Video::ASPECT16X9) return; // Means nothing for 16:9 TVs
1293 if (videoMode == Video::NORMAL)
1295 videoMode = Video::LETTERBOX;
1296 video->setMode(Video::LETTERBOX);
1300 videoMode = Video::NORMAL;
1301 video->setMode(Video::NORMAL);
1305 void VVideoLiveTV::updatePosterBanner()
1307 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1309 osdposterbanner.setVisible(false);
1312 Event* toShow = NULL;
1313 if (eventList && eventList->size()) {
1314 toShow = (*eventList)[0];
1315 Channel* currentChannel = (*chanList)[osdChannelIndex];
1316 toShow->loadinfos(currentChannel->number);
1323 bool posterscale=true;
1324 if (toShow->movieInfo) {
1325 poster=toShow->movieInfo->poster;
1327 if (toShow->seriesInfo) {
1328 if (toShow->seriesInfo->banners.size()) {
1329 poster=toShow->seriesInfo->banners[0];
1331 } else if (toShow->seriesInfo->seasonposter.height) {
1332 poster=toShow->seriesInfo->seasonposter;
1333 } else if (toShow->seriesInfo->posters.size()) {
1334 poster=toShow->seriesInfo->posters[0];
1337 if (poster.height) {
1338 osdposterbanner.setTVMedia(poster.info, posterscale ? WTVMedia::ZoomVertical : WTVMedia::ZoomHorizontal);
1339 osdposterbanner.setVisible(true);
1341 osdposterbanner.setVisible(false);
1344 osdposterbanner.setVisible(false);
1350 void VVideoLiveTV::drawOSDBitmap(UINT posX, UINT posY, const Bitmap& bm, const DisplayRegion& region)
1352 drawBitmap(posX, posY, bm,region);
1354 r.x = posX; r.y = posY; r.w = bm.getWidth(); r.h = bm.getHeight();
1355 boxstack->update(this, &r);
1358 void VVideoLiveTV::clearOSD()
1360 rectangle(area, DrawStyle::TRANSPARENT);
1361 boxstack->update(this, &area);
1364 void VVideoLiveTV::clearOSDArea(UINT posX, UINT posY, UINT width, UINT height, const DisplayRegion& region)
1367 r.x = posX+region.windowx; r.y = posY+region.windowy; r.w = width; r.h = height;
1368 //now convert to our display
1369 float scalex = 720.f / static_cast<float>(region.framewidth + 1);
1370 float scaley = 576.f / static_cast<float>(region.frameheight + 1);
1371 r.x = static_cast<UINT>(floor(scalex * static_cast<float>(r.x)));
1372 r.y = static_cast<UINT>(floor(scaley * static_cast<float>(r.y)));
1373 r.w = static_cast<UINT>(ceil(scalex * static_cast<float>(r.w)) + 1.f);
1374 r.h = static_cast<UINT>(ceil(scaley * static_cast<float>(r.h)) + 1.f);
1375 rectangle(r, DrawStyle::TRANSPARENT);
1376 boxstack->update(this, &r);