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.");
900 clock.fillColour(DrawStyle::OSDBACKGROUND);
902 if (osd.getVisible())
905 boxstack->update(this, osd.getRegion());
907 LogNT::getInstance()->debug(TAG, "Timer Call 2 end.");
911 bool VVideoLiveTV::channelChange(UCHAR changeType, UINT newData)
914 if (streamType == VDR::VIDEO)
916 VTeletextView* vtxt = static_cast<PlayerVideoLive*>(player)->getTeletextDecoder()->getTeletxtView();
919 BoxStack::getInstance()->remove(vtxt);
922 if (changeType == INDEX)
924 newChannel = newData;
926 else if (changeType == NUMBER)
929 for(i = 0; i < chanList->size(); i++)
931 if ((*chanList)[i]->number == newData)
938 if (i == chanList->size())
944 else if (changeType == OFFSET)
946 if (newData == UP) newChannel = upChannel(currentChannelIndex);
947 else newChannel = downChannel(currentChannelIndex);
949 else if (changeType == PREVIOUS)
951 newChannel = previousChannelIndex;
955 return false; // bad input
958 if (newChannel == currentChannelIndex) return true;
960 previousChannelIndex = currentChannelIndex;
961 currentChannelIndex = newChannel;
965 LogNT::getInstance()->debug(TAG, "Set player to channel {}", currentChannelIndex);
966 player->setChannel(currentChannelIndex);
967 LogNT::getInstance()->debug(TAG, "Done Set player to channel {}", currentChannelIndex);
969 // Blank out the symbols
970 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
972 bufferBar.setPercent(0);
976 sAudioChannels.setVisible(false);
977 sAspectRatio.setVisible(false);
981 reslogo.setVisible(false);
982 dolbylogo.setVisible(false);
983 txtlogo.setVisible(false);
986 // Remove other stuff
987 if (textUnavailable.getVisible())
989 textUnavailable.setVisible(false);
995 Channel* currentChannel = (*chanList)[currentChannelIndex];
998 info.setChannelLogo(currentChannel->number);
999 if (streamType == VDR::RADIO)
1001 radioChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1002 radioChannelLogo.setVisible(true);
1004 osdChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1009 BoxStack::getInstance()->update(this);
1014 void VVideoLiveTV::processMessage(Message* m)
1016 if (m->message == Message::MOUSE_LBDOWN)
1018 //check if press is outside this view! then simulate cancel
1019 int x = m->parameter - osd.getScreenX();
1020 int y = m->tag - osd.getScreenY();
1021 if (osd.getVisible())
1023 if ((boxRed.getX() <= x) && (boxRed.getX() + static_cast<int>(boxRed.getWidth()) >= x) &&
1024 (boxRed.getY() <= y) && (boxRed.getY() + static_cast<int>(boxRed.getHeight()) >= y))
1026 BoxStack::getInstance()->handleCommand(Input::RED);
1028 else if ((boxGreen.getX() <= x) && (boxGreen.getX() + static_cast<int>(boxGreen.getWidth()) >= x) &&
1029 (boxGreen.getY() <= y) && (boxGreen.getY() + static_cast<int>(boxGreen.getHeight()) >= y))
1031 BoxStack::getInstance()->handleCommand(Input::GREEN);
1033 else if ((boxYellow.getX() <= x) && (boxYellow.getX() + static_cast<int>(boxYellow.getWidth()) >= x) &&
1034 (boxYellow.getY() <= y) && (boxYellow.getY() + static_cast<int>(boxYellow.getHeight()) >= y))
1036 BoxStack::getInstance()->handleCommand(Input::YELLOW);
1038 else if ((boxBlue.getX() <= x) && (boxBlue.getX() + static_cast<int>(boxBlue.getWidth()) >= x) &&
1039 (boxBlue.getY() <= y) && (boxBlue.getY() + static_cast<int>(boxBlue.getHeight()) >= y))
1041 BoxStack::getInstance()->handleCommand(Input::BLUE);
1045 BoxStack::getInstance()->handleCommand(Input::OK); //simulate rok press
1050 BoxStack::getInstance()->handleCommand(Input::OK); //simulate rok press
1053 else if (m->message == Message::CHANNEL_CHANGE)
1055 channelChange(NUMBER, m->parameter);
1056 osdChannelIndex = currentChannelIndex;
1057 if (m->tag == 1) displayOSD(true);
1059 else if (m->message == Message::CHILD_CLOSE)
1067 else if (m->message == Message::AUDIO_CHANGE_CHANNEL)
1069 LogNT::getInstance()->debug(TAG, "Received change audio channel to {:#x}", m->parameter);
1070 player->setAudioChannel((m->parameter & 0xFFFF), (m->parameter & 0xFF0000) >> 16, (m->parameter & 0xFF000000) >> 24);
1072 else if (m->message == Message::SUBTITLE_CHANGE_CHANNEL)
1074 if (streamType != VDR::VIDEO) return;
1076 PlayerVideoLive* playervl = static_cast<PlayerVideoLive*>(player);
1078 LogNT::getInstance()->debug(TAG, "Received change subtitle channel to {:#x}", m->parameter);
1079 int type = (m->parameter & 0xFF0000) >> 16;
1085 playervl->setSubtitleChannel((m->parameter & 0xFFFF));
1086 playervl->turnSubtitlesOn(true);
1087 VTeletextView* vtxt = playervl->getTeletextDecoder()->getTeletxtView();
1088 if (vtxt && vtxt->isInSubtitleMode())
1090 BoxStack::getInstance()->remove(vtxt);
1097 playervl->turnSubtitlesOn(false);
1098 VTeletextView* vtxt = playervl->getTeletextDecoder()->getTeletxtView();
1099 if (vtxt && vtxt->isInSubtitleMode())
1101 BoxStack::getInstance()->remove(vtxt);
1108 playervl->turnSubtitlesOn(false);
1110 playervl->getTeletextDecoder()->setPage((m->parameter & 0xFFFF));
1117 BoxStack::getInstance()->update(vas);
1118 //BoxStack::getInstance()->update(&osd); //eveil error
1120 BoxStack::getInstance()->update(this, osd.getRegion());
1122 else if (m->message == Message::PLAYER_EVENT)
1124 switch (m->parameter)
1126 case PlayerVideoLive::CONNECTION_LOST: // connection lost detected
1128 LogNT::getInstance()->debug(TAG, "Received connection lost from player");
1129 Control::getInstance()->connectionLost();
1133 case PlayerVideoLive::STREAM_END:
1135 // Message comes from playerlivetv through master mutex, so can do anything here
1140 case PlayerVideoLive::ASPECT43:
1142 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1145 osdv->updateBackgroundColor(DrawStyle::BLACK);
1148 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT43;
1149 sAspectRatio.setVisible(true);
1151 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1154 BoxStack::getInstance()->update(this, osd.getRegion());
1159 case PlayerVideoLive::ASPECT169:
1161 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT169;
1162 sAspectRatio.setVisible(true);
1164 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1167 osdv->updateBackgroundColor(DrawStyle::BLACK);
1171 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1174 BoxStack::getInstance()->update(this, osd.getRegion());
1179 case PlayerVideoLive::PREBUFFERING:
1181 preBuffering = m->tag;
1182 LogNT::getInstance()->debug(TAG, "Prebuffering - {}", preBuffering);
1183 bufferBar.setPercent(preBuffering);
1185 if (osd.getVisible())
1187 bufferBar.setVisible(true);
1190 bufferBar.getRootBoxRegion(&r); ///////// FIXME !!!
1191 BoxStack::getInstance()->update(this, &r);
1193 if (preBuffering == 100)
1195 doAudioChannelSymbol();
1203 void VVideoLiveTV::doAudioChannelSymbol()
1205 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1207 Channel* currentChannel = (*chanList)[osdChannelIndex];
1209 bool multiAudio = false;
1210 if (Audio::getInstance()->supportsAc3()) {
1211 if ((currentChannel->numDPids+currentChannel->numAPids) > 1) multiAudio = true;
1213 if (currentChannel->numAPids > 1) multiAudio = true;
1217 if (multiAudio) sAudioChannels.nextSymbol = WSymbol::MULTIAUDIO;
1218 else sAudioChannels.nextSymbol = WSymbol::SINGLEAUDIO;
1219 sAudioChannels.setVisible(true);
1223 dolbylogo.setVisible(true);
1224 txtlogo.setVisible(true);
1226 if (currentChannel->tpid!=0) info.setStaticArtwork(sa_txton);
1227 else info.setStaticArtwork(sa_txtoff);
1228 txtlogo.setTVMedia(info, WTVMedia::ZoomVertical);
1231 if (Audio::getInstance()->supportsAc3() && currentChannel->numDPids>1)
1232 info.setStaticArtwork(sa_dolbyon);
1233 else info.setStaticArtwork(sa_dolbyoff);
1234 dolbylogo.setTVMedia(info, WTVMedia::ZoomVertical);
1236 Demuxer* demux=Demuxer::getInstance();
1238 int vertical_size=demux->getVerticalSize();
1239 LogNT::getInstance()->debug(TAG, "TVMedia vertical size {}", vertical_size);
1240 reslogo.setVisible(true);
1241 switch (vertical_size) {
1243 info.setStaticArtwork(sa_sd576i);
1244 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1246 info.setStaticArtwork(sa_hd720p);
1247 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1249 info.setStaticArtwork(sa_hd1080i);
1250 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1251 default: // we assume sd
1252 reslogo.setVisible(false);
1256 reslogo.setVisible(false);
1262 if (osd.getVisible())
1264 sAudioChannels.draw();
1266 sAudioChannels.getRootBoxRegion(&r); ///////// FIXME !!!
1270 BoxStack::getInstance()->update(this, &r);
1274 UINT VVideoLiveTV::upChannel(UINT index)
1276 if (index == (chanList->size() - 1)) // at the end
1277 return 0; // so go to start
1282 UINT VVideoLiveTV::downChannel(UINT index)
1284 if (index == 0) // at the start
1285 return chanList->size() - 1; // so go to end
1290 void VVideoLiveTV::toggleChopSides()
1292 if (video->getTVsize() == Video::ASPECT16X9) return; // Means nothing for 16:9 TVs
1294 if (videoMode == Video::NORMAL)
1296 videoMode = Video::LETTERBOX;
1297 video->setMode(Video::LETTERBOX);
1301 videoMode = Video::NORMAL;
1302 video->setMode(Video::NORMAL);
1306 void VVideoLiveTV::updatePosterBanner()
1308 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1310 osdposterbanner.setVisible(false);
1313 Event* toShow = NULL;
1314 if (eventList && eventList->size()) {
1315 toShow = (*eventList)[0];
1316 Channel* currentChannel = (*chanList)[osdChannelIndex];
1317 toShow->loadinfos(currentChannel->number);
1324 bool posterscale=true;
1325 if (toShow->movieInfo) {
1326 poster=toShow->movieInfo->poster;
1328 if (toShow->seriesInfo) {
1329 if (toShow->seriesInfo->banners.size()) {
1330 poster=toShow->seriesInfo->banners[0];
1332 } else if (toShow->seriesInfo->seasonposter.height) {
1333 poster=toShow->seriesInfo->seasonposter;
1334 } else if (toShow->seriesInfo->posters.size()) {
1335 poster=toShow->seriesInfo->posters[0];
1338 if (poster.height) {
1339 osdposterbanner.setTVMedia(poster.info, posterscale ? WTVMedia::ZoomVertical : WTVMedia::ZoomHorizontal);
1340 osdposterbanner.setVisible(true);
1342 osdposterbanner.setVisible(false);
1345 osdposterbanner.setVisible(false);
1351 void VVideoLiveTV::drawOSDBitmap(UINT posX, UINT posY, const Bitmap& bm, const DisplayRegion& region)
1353 drawBitmap(posX, posY, bm,region);
1355 r.x = posX; r.y = posY; r.w = bm.getWidth(); r.h = bm.getHeight();
1356 boxstack->update(this, &r);
1359 void VVideoLiveTV::clearOSD()
1361 rectangle(area, DrawStyle::TRANSPARENT);
1362 boxstack->update(this, &area);
1365 void VVideoLiveTV::clearOSDArea(UINT posX, UINT posY, UINT width, UINT height, const DisplayRegion& region)
1368 r.x = posX+region.windowx; r.y = posY+region.windowy; r.w = width; r.h = height;
1369 //now convert to our display
1370 float scalex = 720.f / static_cast<float>(region.framewidth + 1);
1371 float scaley = 576.f / static_cast<float>(region.frameheight + 1);
1372 r.x = static_cast<UINT>(floor(scalex * static_cast<float>(r.x)));
1373 r.y = static_cast<UINT>(floor(scaley * static_cast<float>(r.y)));
1374 r.w = static_cast<UINT>(ceil(scalex * static_cast<float>(r.w)) + 1.f);
1375 r.h = static_cast<UINT>(ceil(scaley * static_cast<float>(r.h)) + 1.f);
1376 rectangle(r, DrawStyle::TRANSPARENT);
1377 boxstack->update(this, &r);