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/>.
20 #include "vvideolivetv.h"
22 #include "vchannellist.h"
25 #include "playerlive.h"
26 #include "playerlivetv.h"
27 #include "playerliveradio.h"
36 #include "vaudioselector.h"
43 #include "vteletextview.h"
44 #include "vepgsummary.h"
45 #include "vepglistadvanced.h"
46 #include "staticartwork.h"
48 #include "messagequeue.h"
52 VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, VChannelList* tvchannelList)
54 vdr = VDR::getInstance();
55 boxstack = BoxStack::getInstance();
56 video = Video::getInstance();
61 vchannelList = tvchannelList;
62 numberWidth = (int)VDR::getInstance()->getChannelNumberWidth();
64 currentChannelIndex = 0;
65 previousChannelIndex = 0;
72 // Convert channel number to index
74 for(i = 0; i < chanList->size(); i++)
76 if ((*chanList)[i]->number == (UINT)initialChannelNumber)
78 currentChannelIndex = i;
86 videoMode = video->getMode();
88 if ((*chanList)[currentChannelIndex]->type == VDR::VIDEO)
90 streamType = VDR::VIDEO;
91 player = new PlayerLiveTV(Command::getInstance(), this, this, chanList);
95 streamType = VDR::RADIO;
96 player = new PlayerLiveRadio(Command::getInstance(), this, chanList);
100 setSize(video->getScreenWidth(), video->getScreenHeight());
102 DrawStyle transparent(0, 0, 0, 0);
103 setBackgroundColour(transparent);
105 // This variable is set to true if the user pressed OK to bring the OSD on screen
106 // This is only used on old remotes to stop up/down buttons being used for osd-epg scrolling
107 okTriggeredOSD = false;
110 info.setChannelLogo(initialChannelNumber);
111 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
113 if (osdv && streamType == VDR::RADIO) {
114 radioChannelLogo.setPosition(video->getScreenWidth()/4,video->getScreenHeight()/4);
115 radioChannelLogo.setSize(video->getScreenWidth()/2,video->getScreenHeight()/2);
116 radioChannelLogo.setVisible(true);
117 radioChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
118 add(&radioChannelLogo);
121 osdposterbanner.setPosition(20,20);
122 //osdposterbanner.setBackgroundColour(DrawStyle::OSDBACKGROUND);
123 osdposterbanner.setSize(video->getScreenWidth()*4/10,video->getScreenHeight()*4/10);
124 osdposterbanner.setVisible(false);
125 add(&osdposterbanner);
127 osd.setBackgroundColour(DrawStyle::OSDBACKGROUND);
128 osd.setPosition(0, video->getScreenHeight() - 150);
129 osd.setSize(video->getScreenWidth(), 150);
130 osd.setVisible(false);
133 int channellogomove=0;
137 //osdChannelLogo.setBackgroundColour(DrawStyle::OSDBACKGROUND);
138 osdChannelLogo.setPosition(30,5);
139 osdChannelLogo.setSize(60,60);
140 osdChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
141 osd.add(&osdChannelLogo);
142 channellogomove = 30-5;
146 //clock.setBackgroundColour(DrawStyle::OSDBACKGROUND);
147 clock.setPosition(osd.getWidth() - 100, 4);
148 clock.setSize(90, 30);
151 //osdChanNum.setBackgroundColour(DrawStyle::OSDBACKGROUND);
152 osdChanNum.setPosition(60 + channellogomove, 4);
153 osdChanNum.setSize((numberWidth * 10) + 22, getFontHeight() + 5); // 10 px = width of number chars in font
154 osd.add(&osdChanNum);
156 //osdChanName.setBackgroundColour(DrawStyle::OSDBACKGROUND);
157 osdChanName.setPosition(osdChanNum.getX2() + 10, 4);
158 osdChanName.setSize(300, 30);
159 osd.add(&osdChanName);
161 boxRed.setBackgroundColour(DrawStyle::RED);
162 boxRed.setPosition(54+0*boxdiff, 104);
163 boxRed.setSize(18, 16);
166 boxGreen.setBackgroundColour(DrawStyle::GREEN);
167 boxGreen.setPosition(54+1*boxdiff, 104);
168 boxGreen.setSize(18, 16);
171 boxYellow.setBackgroundColour(DrawStyle::YELLOW);
172 boxYellow.setPosition(54+2*boxdiff, 104);
173 boxYellow.setSize(18, 16);
176 boxBlue.setBackgroundColour(DrawStyle::BLUE);
177 boxBlue.setPosition(54+3*boxdiff, 104);
178 boxBlue.setSize(18, 16);
181 //textRed.setBackgroundColour(DrawStyle::OSDBACKGROUND);
182 textRed.setPosition(boxRed.getX2(), 98);
183 textRed.setSize(boxGreen.getX() - boxRed.getX2(), 30);
184 textRed.setText(tr("Summary"));
187 if (streamType == VDR::VIDEO)
189 //textGreen.setBackgroundColour(DrawStyle::OSDBACKGROUND);
190 textGreen.setPosition(boxGreen.getX2(), 98);
191 textGreen.setSize(boxYellow.getX() - boxGreen.getX2(), 30);
192 textGreen.setText(tr("Audio"));
196 //textYellow.setBackgroundColour(DrawStyle::OSDBACKGROUND);
197 textYellow.setPosition(boxYellow.getX2(), 98);
198 textYellow.setSize(boxBlue.getX() - boxYellow.getX2(), 30);
199 textYellow.setText(tr("Teletext"));
200 osd.add(&textYellow);
202 //textBlue.setBackgroundColour(DrawStyle::OSDBACKGROUND);
203 textBlue.setPosition(boxBlue.getX2(), 98);
204 textBlue.setSize(osd.getX2() - boxBlue.getX2(), 30);
205 textBlue.setText(tr("EPG"));
208 //sl.setBackgroundColour(DrawStyle::OSDBACKGROUND);
209 sl.setPosition(90, 36);
213 bufferBar.setPosition(osd.getWidth() - 90, 70);
214 bufferBar.setSize(40, 20);
215 bufferBar.setVisible(true);
220 sAspectRatio.setPosition(osd.getWidth() - 90, 40);
221 sAspectRatio.nextColour = DrawStyle::LIVETVSYMBOLS;
222 sAspectRatio.setVisible(false);
223 osd.add(&sAspectRatio);
225 sAudioChannels.setPosition(osd.getWidth() - 130, 40);
226 sAudioChannels.nextColour = DrawStyle::LIVETVSYMBOLS;
227 sAudioChannels.setVisible(false);
228 osd.add(&sAudioChannels);
234 ninfo.setStaticArtwork(sa_txtoff);
235 txtlogo.setPosition(54+4*boxdiff,104);
236 txtlogo.setSize(22,20);
237 txtlogo.setTVMedia(ninfo, WTVMedia::ZoomVertical);
240 ninfo.setStaticArtwork(sa_dolbyoff);
241 dolbylogo.setPosition(54+4*boxdiff+15,104);
242 dolbylogo.setSize(22,20);
243 dolbylogo.setTVMedia(ninfo, WTVMedia::ZoomVertical);
246 ninfo.setStaticArtwork(sa_sd576i);
247 reslogo.setPosition(54+4*boxdiff+30,104);
248 reslogo.setSize(22,20);
249 reslogo.setTVMedia(ninfo, WTVMedia::ZoomVertical);
252 reslogo.setVisible(false);
253 dolbylogo.setVisible(false);
254 txtlogo.setVisible(false);
257 //textUnavailable.setBackgroundColour(DrawStyle::OSDBACKGROUND);
258 textUnavailable.setPosition(60, 30);
259 textUnavailable.setSize(osd.getWidth() - 120, 30);
260 textUnavailable.setText(tr("Channel Unavailable"));
261 textUnavailable.setVisible(false);
262 add(&textUnavailable);
264 vdisplay.mode = Fullscreen;
265 vdisplay.fallbackMode = Fullscreen;
272 void VVideoLiveTV::preDelete()
277 VVideoLiveTV::~VVideoLiveTV()
280 video->setDefaultAspect();
282 OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
285 osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
289 void VVideoLiveTV::delData()
293 int eventListSize = eventList->size();
294 for(int i = 0; i < eventListSize; i++)
296 delete (*eventList)[i];
303 int VVideoLiveTV::handleCommand(int command)
309 if (osd.getVisible() && !textUnavailable.getVisible())
314 // else drop through to stop
320 vchannelList->highlightChannel((*chanList)[currentChannelIndex]);
324 // NEW REMOTE ONLY - navigate EPG, bring it onscreen if it's not there
327 if (Remote::getInstance()->mayHaveFewButtons())
329 if (okTriggeredOSD) doUpDown(false);
330 else doChanUpDown(UP);
340 if (Remote::getInstance()->mayHaveFewButtons())
342 if (okTriggeredOSD) doUpDown(true);
343 else doChanUpDown(DOWN);
361 // Continue new remote only...
362 case Remote::CHANNELUP:
367 case Remote::CHANNELDOWN:
373 // END NEW REMOTE ONLY, START OLD REMOTE ONLY
375 // DF_LEFT and DF_RIGHT never get here because they are stolen
376 // by command as vol- and vol+
378 // Old remote. Decide what to do based on whether
379 // OK was pressed - osd shown manually, use up/down for epg nav
380 // UP/DOWN was pressed to change channel, osd was shown auto, use up/down for ch+/ch-
384 // Old remote, decide what to do based on okTriggeredOSD
385 if (okTriggeredOSD) doUpDown(false);
386 else doChanUpDown(UP);
389 case Remote::DF_DOWN:
391 // Old remote, decide what to do based on okTriggeredOSD
392 if (okTriggeredOSD) doUpDown(true);
393 else doChanUpDown(DOWN);
397 // END NEW/OLD REMOTE STUFF
399 case Remote::PREVCHANNEL:
401 channelChange(PREVIOUS, 0);
402 osdChannelIndex = currentChannelIndex;
435 // key in channel number
442 if (streamType == VDR::VIDEO) doAudioSelector();
447 if (streamType ==VDR::VIDEO)
449 doTeletext(); //TODO: Add a selector for subtitles or teletext
460 if (streamType == VDR::VIDEO)
461 (static_cast<PlayerLiveTV*>(player))->toggleSubtitles();
468 void VVideoLiveTV::go()
472 boxstack->update(this);
477 player->go(currentChannelIndex);
480 void VVideoLiveTV::stop()
482 Timers::getInstance()->cancelTimer(this, 1);
483 Timers::getInstance()->cancelTimer(this, 2);
488 void VVideoLiveTV::doLeftRight(bool right)
490 if (osd.getVisible())
492 if (right) osdChannelIndex = upChannel(osdChannelIndex);
493 else osdChannelIndex = downChannel(osdChannelIndex);
497 osdChannelIndex = currentChannelIndex;
502 void VVideoLiveTV::doUpDown(bool down)
504 if (osd.getVisible())
516 void VVideoLiveTV::doChanUpDown(int which)
518 channelChange(OFFSET, which);
519 osdChannelIndex = currentChannelIndex;
523 void VVideoLiveTV::doOK()
525 if (osd.getVisible())
530 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
532 channelChange(NUMBER, newChannel);
533 osdChannelIndex = currentChannelIndex;
536 else if (osdChannelIndex == currentChannelIndex)
542 channelChange(INDEX, osdChannelIndex);
548 osdChannelIndex = currentChannelIndex;
550 okTriggeredOSD = true;
554 void VVideoLiveTV::doSummary()
557 Channel* currentChannel = (*chanList)[osdChannelIndex];
558 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
563 sort(eventList->begin(), eventList->end(), EventSorter());
565 if (eventList->size() < 1) return;
566 Event* event = (*eventList)[0];
567 event->loadinfos(currentChannel->number);
569 VEpgSummary* vr = new VEpgSummary(event,currentChannel);
572 boxstack->update(vr);
575 void VVideoLiveTV::doKey(int command)
577 if (!osd.getVisible()) // First key. prep the data
580 updatePosterBanner();
585 for (i = keying - 1; i >= 0; i--) keyingInput[i+1] = keyingInput[i];
586 keyingInput[0] = command;
589 char* keyingString = new char[numberWidth + 1];
590 for (i = 0; i < numberWidth; i++) keyingString[i] = '_';
591 keyingString[numberWidth] = '\0';
593 for (i = 0; i < keying; i++) keyingString[i] = keyingInput[keying - 1 - i] + 48;
595 if (keying == numberWidth)
598 for(i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
600 channelChange(NUMBER, newChannel);
601 osdChannelIndex = currentChannelIndex;
602 Timers::getInstance()->cancelTimer(this, 1); // cancel the timer to react to keying input,
603 displayOSD(true); // this will put one back if required
607 osdChanNum.setText(keyingString);
609 if (!osd.getVisible())
611 osd.setVisible(true);
618 boxstack->update(this, osd.getRegion());
619 Timers::getInstance()->setTimerD(this, 1, 3); // 3s for keying input
621 delete[] keyingString;
624 void VVideoLiveTV::doTeletext(bool subtitlemode)
626 if (streamType !=VDR::VIDEO) return;
627 (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(true);
634 // and reset the display - this is a copy from setNowNextData
635 char formatChanNum[20];
636 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
637 osdChanNum.setText(formatChanNum);
638 osdChanName.setText((*chanList)[osdChannelIndex]->name);
640 (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(true);
641 if (osd.getVisible()) clearScreen();
643 VTeletextView *vtxv=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
646 vtxv= new VTeletextView(((PlayerLiveTV*)player)->getTeletextDecoder(),this, (PlayerLiveTV*)player);
647 ((PlayerLiveTV*)player)->getTeletextDecoder()->registerTeletextView(vtxv);
651 vtxv->setSubtitleMode(subtitlemode);
657 BoxStack::getInstance()->add(vtxv);
660 BoxStack::getInstance()->update(this);
661 BoxStack::getInstance()->update(vtxv);
664 void VVideoLiveTV::doAudioSelector()
666 // If the osd is already visisble there might be a timer for it
667 Timers::getInstance()->cancelTimer(this, 1);
668 //This causes a deadlock with the timertrhread itself is locked
674 // and reset the display - this is a copy from setNowNextData
675 char formatChanNum[20];
676 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
677 osdChanNum.setText(formatChanNum);
678 osdChanName.setText((*chanList)[osdChannelIndex]->name);
680 int subtitleChannel=((PlayerLiveTV*)player)->getCurrentSubtitleChannel();
681 int subtitleType=0x10;
682 if (!(static_cast<PlayerLiveTV*>(player))->isSubtitlesOn()) {
683 if (((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView() &&
684 ((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView()->isInSubtitleMode()
686 subtitleChannel=((PlayerLiveTV*)player)->getTeletextDecoder()->getPage();
690 subtitleType=0xFF; //turnedOff
696 vas = new VAudioSelector(this, (*chanList)[currentChannelIndex], ((PlayerLiveTV*)player)->getCurrentAudioChannel(),
697 subtitleType,subtitleChannel,NULL);
699 vas->setBackgroundColour(DrawStyle::OSDBACKGROUND);
700 vas->setPosition(0, osd.getScreenY() - vas->getHeight());
703 // make vas != null and displayOSD will not set a timer or do any boxstack update
704 if (osd.getVisible()) displayOSD(false);
705 else displayOSD(true);
708 BoxStack::getInstance()->add(vas);
709 BoxStack::getInstance()->update(this);
710 BoxStack::getInstance()->update(vas);
713 void VVideoLiveTV::doEPG()
715 if (osd.getVisible()) clearScreen();
717 if (!Command::getInstance()->isAdvMenus())
719 VEpg* vepg = new VEpg(this, currentChannelIndex, chanList);
722 boxstack->update(vepg);
726 Channel* currentChannel = (*chanList)[osdChannelIndex];
727 VEpgListAdvanced *vepg= new VEpgListAdvanced(this, chanList, currentChannel->number);
730 boxstack->update(vepg);
734 void VVideoLiveTV::setNowNextData()
738 Channel* currentChannel = (*chanList)[osdChannelIndex];
740 char formatChanNum[20];
741 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, currentChannel->number);
742 osdChanNum.setText(formatChanNum);
743 osdChanName.setText(currentChannel->name);
745 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
749 sl.setText(tr("No channel data available"));
753 sort(eventList->begin(), eventList->end(), EventSorter());
755 char tempString[300];
756 char tempString2[300];
759 int eventListSize = eventList->size();
760 std::stringstream string;
761 for(int i = 0; i < eventListSize; i++)
763 event = (*eventList)[i];
765 time_t etime = event->time;
766 LOCALTIME_R(&etime, &btime);
768 strftime(tempString2, 299, "%0H:%0M ", &btime);
770 strftime(tempString2, 299, "%H:%M ", &btime);
772 SNPRINTF(tempString, 299, "%s %s", tempString2, event->title);
773 string << tempString << "\n";
775 sl.setText(string.str().c_str());
781 void VVideoLiveTV::displayOSD(bool newNowNextData)
783 PlayerLiveTV* playerlivetv = dynamic_cast<PlayerLiveTV*>(player);
784 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(true);
785 osd.setVisible(true);
789 updatePosterBanner();
793 if (osdposterbanner.getVisible()) osdposterbanner.draw();
798 toupdate=*osd.getRegion();
801 if (osdposterbanner.getVisible())
803 boxstack->update(this);
807 boxstack->update(this, &toupdate);
810 bool setTimer = true;
811 if (vas) setTimer = false;
812 if (textUnavailable.getVisible()) setTimer = false;
814 if (setTimer) Timers::getInstance()->setTimerD(this, 1, 4);
817 void VVideoLiveTV::clearScreen()
819 Timers::getInstance()->cancelTimer(this, 1);
821 textUnavailable.setVisible(false);
822 osd.setVisible(false);
823 osdposterbanner.setVisible(false);
825 okTriggeredOSD = false;
828 boxstack->update(this);
830 PlayerLiveTV* playerlivetv = dynamic_cast<PlayerLiveTV*>(player);
831 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false);
834 void VVideoLiveTV::showUnavailable()
836 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Show unavailable called");
837 textUnavailable.setVisible(true);
838 textUnavailable.draw();
840 if (!osd.getVisible()) displayOSD(true);
842 boxstack->update(this, textUnavailable.getRegion());
845 void VVideoLiveTV::setClock()
851 LOCALTIME_R(&t, &tms);
852 strftime(timeString, 19, "%H:%M", &tms);
853 clock.setText(timeString);
855 time_t dt = 60 - (t % 60); // seconds to the next minute
856 if (dt == 0) dt = 60; // advance a whole minute if necessary
857 dt += t; // get a time_t value for it rather than using duration
858 // (so it will occur at the actual second and not second and a half)
860 Timers::getInstance()->setTimerT(this, 2, dt);
863 void VVideoLiveTV::timercall(int ref)
869 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key start.");
871 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
873 Message* m = new Message();
874 m->message = Message::CHANNEL_CHANGE;
876 m->parameter = newChannel;
877 m->tag = 1; // signal to call displayOSD();
878 MessageQueue::getInstance()->postMessage(m);
879 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key end.");
883 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 not key start.");
884 // We have received a timer, we are not keying. If still prebuffering, don't remove the bar
885 if (preBuffering < 100)
887 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Still prebuffering, not removing osd...");
888 Timers::getInstance()->setTimerD(this, 1, 2); // reset timer for another 2s
891 bool osdpbvisible=osdposterbanner.getVisible();
892 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 1.");
893 osd.setVisible(false);
894 osdposterbanner.setVisible(false);
895 okTriggeredOSD = false;
896 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 2.");
898 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 4.");
899 if (osdpbvisible) boxstack->update(this);
900 else boxstack->update(this, osd.getRegion());
902 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 3.");
903 PlayerLiveTV* playerlivetv = dynamic_cast<PlayerLiveTV*>(player);
904 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false);
905 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey end.");
910 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 start.");
912 if (osd.getVisible())
915 boxstack->update(this, osd.getRegion());
917 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 end.");
921 bool VVideoLiveTV::channelChange(UCHAR changeType, UINT newData)
924 if (streamType == VDR::VIDEO)
926 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
929 BoxStack::getInstance()->remove(vtxt);
932 if (changeType == INDEX)
934 newChannel = newData;
936 else if (changeType == NUMBER)
939 for(i = 0; i < chanList->size(); i++)
941 if ((*chanList)[i]->number == (UINT)newData)
948 if (i == chanList->size())
954 else if (changeType == OFFSET)
956 if (newData == UP) newChannel = upChannel(currentChannelIndex);
957 else newChannel = downChannel(currentChannelIndex);
959 else if (changeType == PREVIOUS)
961 newChannel = previousChannelIndex;
965 return false; // bad input
968 if (newChannel == currentChannelIndex) return true;
970 previousChannelIndex = currentChannelIndex;
971 currentChannelIndex = newChannel;
975 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Set player to channel %u", currentChannelIndex);
976 player->setChannel(currentChannelIndex);
977 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Done Set player to channel %u", currentChannelIndex);
979 // Blank out the symbols
980 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
982 bufferBar.setPercent(0);
986 sAudioChannels.setVisible(false);
987 sAspectRatio.setVisible(false);
991 reslogo.setVisible(false);
992 dolbylogo.setVisible(false);
993 txtlogo.setVisible(false);
996 // Remove other stuff
997 if (textUnavailable.getVisible())
999 textUnavailable.setVisible(false);
1005 Channel* currentChannel = (*chanList)[currentChannelIndex];
1008 info.setChannelLogo(currentChannel->number);
1009 if (streamType == VDR::RADIO)
1011 radioChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1012 radioChannelLogo.setVisible(true);
1014 osdChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1019 BoxStack::getInstance()->update(this);
1024 void VVideoLiveTV::processMessage(Message* m)
1026 if (m->message == Message::MOUSE_LBDOWN)
1028 //check if press is outside this view! then simulate cancel
1029 int x = (m->parameter >> 16) - osd.getScreenX();
1030 int y = (m->parameter & 0xFFFF) - osd.getScreenY();
1031 if (osd.getVisible())
1033 if ((boxRed.getX()<=x) && (boxRed.getX()+(int)boxRed.getWidth()>=x ) &&
1034 (boxRed.getY()<=y) && (boxRed.getY()+(int)boxRed.getHeight()>=y ))
1036 BoxStack::getInstance()->handleCommand(Remote::RED);
1038 else if ((boxGreen.getX()<=x) && (boxGreen.getX()+(int)boxGreen.getWidth()>=x ) &&
1039 (boxGreen.getY()<=y) && (boxGreen.getY()+(int)boxGreen.getHeight()>=y))
1041 BoxStack::getInstance()->handleCommand(Remote::GREEN);
1043 else if ((boxYellow.getX()<=x) && (boxYellow.getX()+(int)boxYellow.getWidth()>=x ) &&
1044 (boxYellow.getY()<=y) && (boxYellow.getY()+(int)boxYellow.getHeight()>=y )){
1045 BoxStack::getInstance()->handleCommand(Remote::YELLOW);
1047 else if ((boxBlue.getX()<=x) && (boxBlue.getX()+(int)boxBlue.getWidth()>=x ) &&
1048 (boxBlue.getY()<=y) && (boxBlue.getY()+(int)boxBlue.getHeight()>=y ))
1050 BoxStack::getInstance()->handleCommand(Remote::BLUE);
1054 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
1059 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
1062 else if (m->message == Message::CHANNEL_CHANGE)
1064 channelChange(NUMBER, m->parameter);
1065 osdChannelIndex = currentChannelIndex;
1066 if (m->tag == 1) displayOSD(true);
1068 else if (m->message == Message::CHILD_CLOSE)
1076 else if (m->message == Message::AUDIO_CHANGE_CHANNEL)
1078 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change audio channel to %x", m->parameter);
1079 player->setAudioChannel((m->parameter & 0xFFFF), (m->parameter & 0xFF0000) >> 16, (m->parameter & 0xFF000000) >> 24);
1081 else if (m->message == Message::SUBTITLE_CHANGE_CHANNEL)
1083 if (streamType != VDR::VIDEO) return;
1084 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change subtitle channel to %x", m->parameter);
1085 int type = (m->parameter & 0xFF0000) >> 16;
1091 if (streamType == VDR::VIDEO)
1093 player->setSubtitleChannel((m->parameter & 0xFFFF));
1094 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(true);
1095 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
1096 if (vtxt && vtxt->isInSubtitleMode())
1098 BoxStack::getInstance()->remove(vtxt);
1104 if (streamType == VDR::VIDEO){
1105 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(false);
1106 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
1107 if (vtxt && vtxt->isInSubtitleMode()) {
1108 BoxStack::getInstance()->remove(vtxt);
1115 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(false);
1117 ((PlayerLiveTV*)player)->getTeletextDecoder()->setPage((m->parameter & 0xFFFF));
1123 BoxStack::getInstance()->update(vas);
1124 //BoxStack::getInstance()->update(&osd); //eveil error
1126 BoxStack::getInstance()->update(this, osd.getRegion());
1128 else if (m->message == Message::PLAYER_EVENT)
1130 switch (m->parameter)
1132 case PlayerLiveTV::CONNECTION_LOST: // connection lost detected
1134 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received connection lost from player");
1135 Command::getInstance()->connectionLost();
1139 case PlayerLiveTV::STREAM_END:
1141 // Message comes from playerlivetv through master mutex, so can do anything here
1146 case PlayerLiveTV::ASPECT43:
1148 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1151 osdv->updateBackgroundColor(DrawStyle::BLACK);
1154 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT43;
1155 sAspectRatio.setVisible(true);
1157 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1160 BoxStack::getInstance()->update(this, osd.getRegion());
1165 case PlayerLiveTV::ASPECT169:
1167 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT169;
1168 sAspectRatio.setVisible(true);
1170 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1173 osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
1177 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1180 BoxStack::getInstance()->update(this, osd.getRegion());
1185 case PlayerLiveTV::PREBUFFERING:
1187 preBuffering = m->tag;
1188 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Prebuffering - %u", preBuffering);
1189 bufferBar.setPercent(preBuffering);
1191 if (osd.getVisible())
1193 bufferBar.setVisible(true);
1196 bufferBar.getRootBoxRegion(&r); ///////// FIXME !!!
1197 BoxStack::getInstance()->update(this, &r);
1199 if (preBuffering == 100)
1201 doAudioChannelSymbol();
1209 void VVideoLiveTV::doAudioChannelSymbol()
1211 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1213 Channel* currentChannel = (*chanList)[osdChannelIndex];
1215 bool multiAudio = false;
1216 if (Audio::getInstance()->supportsAc3()) {
1217 if ((currentChannel->numDPids+currentChannel->numAPids) > 1) multiAudio = true;
1219 if (currentChannel->numAPids > 1) multiAudio = true;
1223 if (multiAudio) sAudioChannels.nextSymbol = WSymbol::MULTIAUDIO;
1224 else sAudioChannels.nextSymbol = WSymbol::SINGLEAUDIO;
1225 sAudioChannels.setVisible(true);
1229 dolbylogo.setVisible(true);
1230 txtlogo.setVisible(true);
1232 if (currentChannel->tpid!=0) info.setStaticArtwork(sa_txton);
1233 else info.setStaticArtwork(sa_txtoff);
1234 txtlogo.setTVMedia(info, WTVMedia::ZoomVertical);
1237 if (Audio::getInstance()->supportsAc3() && currentChannel->numDPids>1)
1238 info.setStaticArtwork(sa_dolbyon);
1239 else info.setStaticArtwork(sa_dolbyoff);
1240 dolbylogo.setTVMedia(info, WTVMedia::ZoomVertical);
1242 Demuxer* demux=Demuxer::getInstance();
1244 int vertical_size=demux->getVerticalSize();
1245 Log::getInstance()->log("VVideoRec", Log::DEBUG, "TVMedia vertical size %d", vertical_size);
1246 reslogo.setVisible(true);
1247 switch (vertical_size) {
1249 info.setStaticArtwork(sa_sd576i);
1250 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1252 info.setStaticArtwork(sa_hd720p);
1253 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1255 info.setStaticArtwork(sa_hd1080i);
1256 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1257 default: // we assume sd
1258 reslogo.setVisible(false);
1262 reslogo.setVisible(false);
1268 if (osd.getVisible())
1270 sAudioChannels.draw();
1272 sAudioChannels.getRootBoxRegion(&r); ///////// FIXME !!!
1276 BoxStack::getInstance()->update(this, &r);
1280 UINT VVideoLiveTV::upChannel(UINT index)
1282 if (index == (chanList->size() - 1)) // at the end
1283 return 0; // so go to start
1288 UINT VVideoLiveTV::downChannel(UINT index)
1290 if (index == 0) // at the start
1291 return chanList->size() - 1; // so go to end
1296 void VVideoLiveTV::toggleChopSides()
1298 if (video->getTVsize() == Video::ASPECT16X9) return; // Means nothing for 16:9 TVs
1300 if (videoMode == Video::NORMAL)
1302 videoMode = Video::LETTERBOX;
1303 video->setMode(Video::LETTERBOX);
1307 videoMode = Video::NORMAL;
1308 video->setMode(Video::NORMAL);
1312 void VVideoLiveTV::updatePosterBanner()
1314 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1316 osdposterbanner.setVisible(false);
1319 Event* toShow = NULL;
1320 if (eventList && eventList->size()) {
1321 toShow = (*eventList)[0];
1322 Channel* currentChannel = (*chanList)[osdChannelIndex];
1323 toShow->loadinfos(currentChannel->number);
1330 bool posterscale=true;
1331 if (toShow->movieInfo) {
1332 poster=toShow->movieInfo->poster;
1334 if (toShow->seriesInfo) {
1335 if (toShow->seriesInfo->banners.size()) {
1336 poster=toShow->seriesInfo->banners[0];
1338 } else if (toShow->seriesInfo->seasonposter.height) {
1339 poster=toShow->seriesInfo->seasonposter;
1340 } else if (toShow->seriesInfo->posters.size()) {
1341 poster=toShow->seriesInfo->posters[0];
1344 if (poster.height) {
1345 osdposterbanner.setTVMedia(poster.info, posterscale ? WTVMedia::ZoomVertical : WTVMedia::ZoomHorizontal);
1346 osdposterbanner.setVisible(true);
1348 osdposterbanner.setVisible(false);
1351 osdposterbanner.setVisible(false);
1357 void VVideoLiveTV::drawOSDBitmap(UINT posX, UINT posY, const Bitmap& bm, const DisplayRegion& region)
1359 drawBitmap(posX, posY, bm,region);
1361 r.x = posX; r.y = posY; r.w = bm.getWidth(); r.h = bm.getHeight();
1362 boxstack->update(this, &r);
1365 void VVideoLiveTV::clearOSD()
1367 rectangle(area, DrawStyle(0,0,0,0));
1368 boxstack->update(this, &area);
1371 void VVideoLiveTV::clearOSDArea(UINT posX, UINT posY, UINT width, UINT height, const DisplayRegion& region)
1374 r.x = posX+region.windowx; r.y = posY+region.windowy; r.w = width; r.h = height;
1375 //now convert to our display
1376 float scalex=720.f/((float) (region.framewidth+1));
1377 float scaley=576.f/((float) (region.frameheight+1));
1378 r.x = (UINT)floor(scalex*((float)r.x));
1379 r.y = (UINT)floor(scaley*((float)r.y));
1380 r.w = (UINT)(ceil(scalex*((float)r.w))+1.f);
1381 r.h = (UINT)(ceil(scaley*((float)r.h))+1.f);
1382 rectangle(r, DrawStyle(0,0,0,0));
1383 boxstack->update(this, &r);