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, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "vvideolivetv.h"
23 #include "vchannellist.h"
26 #include "playerlive.h"
27 #include "playerlivetv.h"
28 #include "playerliveradio.h"
37 #include "vaudioselector.h"
44 #include "vteletextview.h"
45 #include "vepgsummary.h"
46 #include "vepglistadvanced.h"
47 #include "staticartwork.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);
106 char* optionWSS = vdr->configLoad("General", "WSS");
109 if (strstr(optionWSS, "Yes")) dowss = true;
112 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Do WSS: %u", dowss);
116 wss.setFormat(video->getFormat());
122 wssRegion.w = video->getScreenWidth();
126 // This variable is set to true if the user pressed OK to bring the OSD on screen
127 // This is only used on old remotes to stop up/down buttons being used for osd-epg scrolling
128 okTriggeredOSD = false;
131 info.setChannelLogo(initialChannelNumber);
132 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
134 if (osdv && streamType == VDR::RADIO) {
135 radioChannelLogo.setPosition(video->getScreenWidth()/4,video->getScreenHeight()/4);
136 radioChannelLogo.setSize(video->getScreenWidth()/2,video->getScreenHeight()/2);
137 radioChannelLogo.setVisible(true);
138 radioChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
139 add(&radioChannelLogo);
142 osdposterbanner.setPosition(20,20);
143 //osdposterbanner.setBackgroundColour(DrawStyle::OSDBACKGROUND);
144 osdposterbanner.setSize(video->getScreenWidth()*4/10,video->getScreenHeight()*4/10);
145 osdposterbanner.setVisible(false);
146 add(&osdposterbanner);
150 osd.setBackgroundColour(DrawStyle::OSDBACKGROUND);
151 osd.setPosition(0, video->getScreenHeight() - 150);
152 osd.setSize(video->getScreenWidth(), 150);
153 osd.setVisible(false);
156 int channellogomove=0;
159 //osdChannelLogo.setBackgroundColour(DrawStyle::OSDBACKGROUND);
160 osdChannelLogo.setPosition(30,5);
161 osdChannelLogo.setSize(60,60);
162 osdChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
163 osd.add(&osdChannelLogo);
164 channellogomove=30-5;
169 //clock.setBackgroundColour(DrawStyle::OSDBACKGROUND);
170 clock.setPosition(osd.getWidth() - 100, 4);
171 clock.setSize(90, 30);
174 //osdChanNum.setBackgroundColour(DrawStyle::OSDBACKGROUND);
175 osdChanNum.setPosition(60+channellogomove, 4);
176 osdChanNum.setSize((numberWidth*10) + 22, getFontHeight()+5); // 10 px = width of number chars in font
177 osd.add(&osdChanNum);
179 //osdChanName.setBackgroundColour(DrawStyle::OSDBACKGROUND);
180 osdChanName.setPosition(osdChanNum.getX2() + 10, 4);
181 osdChanName.setSize(300, 30);
182 osd.add(&osdChanName);
184 boxRed.setBackgroundColour(DrawStyle::RED);
185 boxRed.setPosition(54+0*boxdiff, 104);
186 boxRed.setSize(18, 16);
189 boxGreen.setBackgroundColour(DrawStyle::GREEN);
190 boxGreen.setPosition(54+1*boxdiff, 104);
191 boxGreen.setSize(18, 16);
194 boxYellow.setBackgroundColour(DrawStyle::YELLOW);
195 boxYellow.setPosition(54+2*boxdiff, 104);
196 boxYellow.setSize(18, 16);
199 boxBlue.setBackgroundColour(DrawStyle::BLUE);
200 boxBlue.setPosition(54+3*boxdiff, 104);
201 boxBlue.setSize(18, 16);
204 //textRed.setBackgroundColour(DrawStyle::OSDBACKGROUND);
205 textRed.setPosition(boxRed.getX2(), 98);
206 textRed.setSize(boxGreen.getX() - boxRed.getX2(), 30);
207 textRed.setText(tr("Summary"));
210 if (streamType == VDR::VIDEO)
212 //textGreen.setBackgroundColour(DrawStyle::OSDBACKGROUND);
213 textGreen.setPosition(boxGreen.getX2(), 98);
214 textGreen.setSize(boxYellow.getX() - boxGreen.getX2(), 30);
215 textGreen.setText(tr("Audio"));
219 //textYellow.setBackgroundColour(DrawStyle::OSDBACKGROUND);
220 textYellow.setPosition(boxYellow.getX2(), 98);
221 textYellow.setSize(boxBlue.getX() - boxYellow.getX2(), 30);
222 textYellow.setText(tr("Teletext"));
223 osd.add(&textYellow);
225 //textBlue.setBackgroundColour(DrawStyle::OSDBACKGROUND);
226 textBlue.setPosition(boxBlue.getX2(), 98);
227 textBlue.setSize(osd.getX2() - boxBlue.getX2(), 30);
228 textBlue.setText(tr("EPG"));
231 //sl.setBackgroundColour(DrawStyle::OSDBACKGROUND);
232 sl.setPosition(90, 36);
238 bufferBar.setPosition(osd.getWidth() - 90, 70);
239 bufferBar.setSize(40, 20);
240 bufferBar.setVisible(true);
244 sAspectRatio.setPosition(osd.getWidth() - 90, 40);
245 sAspectRatio.nextColour = DrawStyle::LIVETVSYMBOLS;
246 sAspectRatio.setVisible(false);
247 osd.add(&sAspectRatio);
249 sAudioChannels.setPosition(osd.getWidth() - 130, 40);
250 sAudioChannels.nextColour = DrawStyle::LIVETVSYMBOLS;
251 sAudioChannels.setVisible(false);
252 osd.add(&sAudioChannels);
257 ninfo.setStaticArtwork(sa_txtoff);
258 txtlogo.setPosition(54+4*boxdiff,104);
259 txtlogo.setSize(22,20);
260 txtlogo.setTVMedia(ninfo, WTVMedia::ZoomVertical);
263 ninfo.setStaticArtwork(sa_dolbyoff);
264 dolbylogo.setPosition(54+4*boxdiff+15,104);
265 dolbylogo.setSize(22,20);
266 dolbylogo.setTVMedia(ninfo, WTVMedia::ZoomVertical);
269 ninfo.setStaticArtwork(sa_sd576i);
270 reslogo.setPosition(54+4*boxdiff+30,104);
271 reslogo.setSize(22,20);
272 reslogo.setTVMedia(ninfo, WTVMedia::ZoomVertical);
275 reslogo.setVisible(false);
276 dolbylogo.setVisible(false);
277 txtlogo.setVisible(false);
281 //textUnavailable.setBackgroundColour(DrawStyle::OSDBACKGROUND);
282 textUnavailable.setPosition(60, 30);
283 textUnavailable.setSize(osd.getWidth() - 120, 30);
284 textUnavailable.setText(tr("Channel Unavailable"));
285 textUnavailable.setVisible(false);
286 add(&textUnavailable);
289 vdisplay.mode=Fullscreen;
290 vdisplay.fallbackMode=Fullscreen;
298 void VVideoLiveTV::preDelete()
303 VVideoLiveTV::~VVideoLiveTV()
306 video->setDefaultAspect();
310 void VVideoLiveTV::delData()
314 int eventListSize = eventList->size();
315 for(int i = 0; i < eventListSize; i++)
317 delete (*eventList)[i];
325 int VVideoLiveTV::handleCommand(int command)
331 if (osd.getVisible() && !textUnavailable.getVisible())
336 // else drop through to stop
341 vchannelList->highlightChannel((*chanList)[currentChannelIndex]);
345 // NEW REMOTE ONLY - navigate EPG, bring it onscreen if it's not there
348 if (Remote::getInstance()->mayHaveFewButtons()) {
349 if (okTriggeredOSD) doUpDown(false);
350 else doChanUpDown(UP);
358 if (Remote::getInstance()->mayHaveFewButtons()) {
359 if (okTriggeredOSD) doUpDown(true);
360 else doChanUpDown(DOWN);
376 // Continue new remote only...
377 case Remote::CHANNELUP:
382 case Remote::CHANNELDOWN:
388 // END NEW REMOTE ONLY, START OLD REMOTE ONLY
390 // DF_LEFT and DF_RIGHT never get here because they are stolen
391 // by command as vol- and vol+
393 // Old remote. Decide what to do based on whether
394 // OK was pressed - osd shown manually, use up/down for epg nav
395 // UP/DOWN was pressed to change channel, osd was shown auto, use up/down for ch+/ch-
399 // Old remote, decide what to do based on okTriggeredOSD
400 if (okTriggeredOSD) doUpDown(false);
401 else doChanUpDown(UP);
404 case Remote::DF_DOWN:
406 // Old remote, decide what to do based on okTriggeredOSD
407 if (okTriggeredOSD) doUpDown(true);
408 else doChanUpDown(DOWN);
412 // END NEW/OLD REMOTE STUFF
414 case Remote::PREVCHANNEL:
416 channelChange(PREVIOUS, 0);
417 osdChannelIndex = currentChannelIndex;
450 // key in channel number
457 if (streamType == VDR::VIDEO) doAudioSelector();
462 if (streamType ==VDR::VIDEO)
464 doTeletext(); //TODO: Add a selector for subtitles or teletext
475 if (streamType == VDR::VIDEO)
476 (static_cast<PlayerLiveTV*>(player))->toggleSubtitles();
483 void VVideoLiveTV::go()
487 boxstack->update(this);
492 player->go(currentChannelIndex);
495 void VVideoLiveTV::stop()
497 Timers::getInstance()->cancelTimer(this, 1);
498 Timers::getInstance()->cancelTimer(this, 2);
503 void VVideoLiveTV::doLeftRight(bool right)
505 if (osd.getVisible())
507 if (right) osdChannelIndex = upChannel(osdChannelIndex);
508 else osdChannelIndex = downChannel(osdChannelIndex);
512 osdChannelIndex = currentChannelIndex;
517 void VVideoLiveTV::doUpDown(bool down)
519 if (osd.getVisible())
531 void VVideoLiveTV::doChanUpDown(int which)
533 channelChange(OFFSET, which);
534 osdChannelIndex = currentChannelIndex;
538 void VVideoLiveTV::doOK()
540 if (osd.getVisible())
545 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
547 channelChange(NUMBER, newChannel);
548 osdChannelIndex = currentChannelIndex;
551 else if (osdChannelIndex == currentChannelIndex)
557 channelChange(INDEX, osdChannelIndex);
563 osdChannelIndex = currentChannelIndex;
565 okTriggeredOSD = true;
569 void VVideoLiveTV::doSummary()
572 Channel* currentChannel = (*chanList)[osdChannelIndex];
573 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
578 sort(eventList->begin(), eventList->end(), EventSorter());
580 if (eventList->size() < 1) return;
581 Event* event = (*eventList)[0];
582 event->loadinfos(currentChannel->number);
584 VEpgSummary* vr = new VEpgSummary(event,currentChannel);
587 boxstack->update(vr);
591 void VVideoLiveTV::doKey(int command)
593 if (!osd.getVisible()) // First key. prep the data
596 updatePosterBanner();
601 for (i = keying - 1; i >= 0; i--) keyingInput[i+1] = keyingInput[i];
602 keyingInput[0] = command;
605 char* keyingString = new char[numberWidth + 1];
606 for (i = 0; i < numberWidth; i++) keyingString[i] = '_';
607 keyingString[numberWidth] = '\0';
609 for (i = 0; i < keying; i++) keyingString[i] = keyingInput[keying - 1 - i] + 48;
611 if (keying == numberWidth)
614 for(i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
616 channelChange(NUMBER, newChannel);
617 osdChannelIndex = currentChannelIndex;
618 Timers::getInstance()->cancelTimer(this, 1); // cancel the timer to react to keying input,
619 displayOSD(true); // this will put one back if required
623 osdChanNum.setText(keyingString);
625 if (!osd.getVisible())
627 osd.setVisible(true);
634 boxstack->update(this, osd.getRegion());
635 Timers::getInstance()->setTimerD(this, 1, 3); // 3s for keying input
637 delete[] keyingString;
640 void VVideoLiveTV::doTeletext(bool subtitlemode)
642 if (streamType !=VDR::VIDEO) return;
643 (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(true);
650 // and reset the display - this is a copy from setNowNextData
651 char formatChanNum[20];
652 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
653 osdChanNum.setText(formatChanNum);
654 osdChanName.setText((*chanList)[osdChannelIndex]->name);
656 (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(true);
657 if (osd.getVisible()) clearScreen();
659 VTeletextView *vtxv=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
661 vtxv= new VTeletextView(((PlayerLiveTV*)player)->getTeletextDecoder(),this, (PlayerLiveTV*)player);
662 ((PlayerLiveTV*)player)->getTeletextDecoder()->registerTeletextView(vtxv);
665 vtxv->setSubtitleMode(subtitlemode);
670 BoxStack::getInstance()->add(vtxv);
672 BoxStack::getInstance()->update(this);
673 BoxStack::getInstance()->update(vtxv);
676 void VVideoLiveTV::doAudioSelector()
678 // If the osd is already visisble there might be a timer for it
679 Timers::getInstance()->cancelTimer(this, 1);
680 //This causes a deadlock with the timertrhread itself is locked
687 // and reset the display - this is a copy from setNowNextData
688 char formatChanNum[20];
689 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
690 osdChanNum.setText(formatChanNum);
691 osdChanName.setText((*chanList)[osdChannelIndex]->name);
693 int subtitleChannel=((PlayerLiveTV*)player)->getCurrentSubtitleChannel();
694 int subtitleType=0x10;
695 if (!(static_cast<PlayerLiveTV*>(player))->isSubtitlesOn()) {
696 if (((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView() &&
697 ((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView()->isInSubtitleMode()
699 subtitleChannel=((PlayerLiveTV*)player)->getTeletextDecoder()->getPage();
703 subtitleType=0xFF; //turnedOff
709 vas = new VAudioSelector(this, (*chanList)[currentChannelIndex], ((PlayerLiveTV*)player)->getCurrentAudioChannel(),
710 subtitleType,subtitleChannel,NULL);
712 vas->setBackgroundColour(DrawStyle::OSDBACKGROUND);
713 vas->setPosition(0, osd.getScreenY() - vas->getHeight());
716 // make vas != null and displayOSD will not set a timer or do any boxstack update
717 if (osd.getVisible()) displayOSD(false);
718 else displayOSD(true);
721 BoxStack::getInstance()->add(vas);
722 BoxStack::getInstance()->update(this);
723 BoxStack::getInstance()->update(vas);
726 void VVideoLiveTV::doEPG()
728 if (osd.getVisible()) clearScreen();
730 if (!Command::getInstance()->advMenues()) {
732 VEpg* vepg = new VEpg(this, currentChannelIndex, chanList);
735 boxstack->update(vepg);
737 Channel* currentChannel = (*chanList)[osdChannelIndex];
738 VEpgListAdvanced *vepg= new VEpgListAdvanced(this, chanList, currentChannel->number);
741 boxstack->update(vepg);
745 void VVideoLiveTV::setNowNextData()
749 Channel* currentChannel = (*chanList)[osdChannelIndex];
751 char formatChanNum[20];
752 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, currentChannel->number);
753 osdChanNum.setText(formatChanNum);
754 osdChanName.setText(currentChannel->name);
756 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
760 sl.setText(tr("No channel data available"));
764 sort(eventList->begin(), eventList->end(), EventSorter());
766 char tempString[300];
767 char tempString2[300];
770 int eventListSize = eventList->size();
771 std::stringstream string;
772 for(int i = 0; i < eventListSize; i++)
774 event = (*eventList)[i];
776 time_t etime = event->time;
777 btime = localtime(&etime);
779 strftime(tempString2, 299, "%0H:%0M ", btime);
781 strftime(tempString2, 299, "%H:%M ", btime);
783 SNPRINTF(tempString, 299, "%s %s", tempString2, event->title);
784 string << tempString << "\n";
786 sl.setText(string.str().c_str());
792 void VVideoLiveTV::displayOSD(bool newNowNextData)
794 PlayerLiveTV* playerlivetv = dynamic_cast<PlayerLiveTV*>(player);
795 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(true);
796 osd.setVisible(true);
800 updatePosterBanner();
804 if (osdposterbanner.getVisible()) osdposterbanner.draw();
809 toupdate=*osd.getRegion();
812 if (osdposterbanner.getVisible()) {
813 boxstack->update(this);
815 boxstack->update(this, &toupdate);
818 bool setTimer = true;
819 if (vas) setTimer = false;
820 if (textUnavailable.getVisible()) setTimer = false;
822 if (setTimer) Timers::getInstance()->setTimerD(this, 1, 4);
825 void VVideoLiveTV::clearScreen()
827 Timers::getInstance()->cancelTimer(this, 1);
829 textUnavailable.setVisible(false);
830 osd.setVisible(false);
831 osdposterbanner.setVisible(false);
833 okTriggeredOSD = false;
836 boxstack->update(this);
838 PlayerLiveTV* playerlivetv = dynamic_cast<PlayerLiveTV*>(player);
839 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false);
842 void VVideoLiveTV::showUnavailable()
844 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Show unavailable called");
845 textUnavailable.setVisible(true);
846 textUnavailable.draw();
848 if (!osd.getVisible()) displayOSD(true);
850 boxstack->update(this, textUnavailable.getRegion());
853 void VVideoLiveTV::setClock()
858 struct tm* tms = localtime(&t);
859 strftime(timeString, 19, "%H:%M", tms);
860 clock.setText(timeString);
862 time_t dt = 60 - (t % 60); // seconds to the next minute
863 if (dt == 0) dt = 60; // advance a whole minute if necessary
864 dt += t; // get a time_t value for it rather than using duration
865 // (so it will occur at the actual second and not second and a half)
867 Timers::getInstance()->setTimerT(this, 2, dt);
870 void VVideoLiveTV::timercall(int ref)
876 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key start.");
878 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
880 Message* m = new Message();
881 m->message = Message::CHANNEL_CHANGE;
883 m->parameter.num = newChannel;
884 m->tag = 1; // signal to call displayOSD();
885 Command::getInstance()->postMessageFromOuterSpace(m);
886 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key end.");
890 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 not key start.");
891 // We have received a timer, we are not keying. If still prebuffering, don't remove the bar
892 if (preBuffering < 100)
894 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Still prebuffering, not removing osd...");
895 Timers::getInstance()->setTimerD(this, 1, 2); // reset timer for another 2s
898 bool osdpbvisible=osdposterbanner.getVisible();
899 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 1.");
900 osd.setVisible(false);
901 osdposterbanner.setVisible(false);
902 okTriggeredOSD = false;
903 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 2.");
905 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 4.");
906 if (osdpbvisible) boxstack->update(this);
907 else boxstack->update(this, osd.getRegion());
909 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 3.");
910 PlayerLiveTV* playerlivetv = dynamic_cast<PlayerLiveTV*>(player);
911 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false);
912 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey end.");
917 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 start.");
919 if (osd.getVisible())
922 boxstack->update(this, osd.getRegion());
924 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 end.");
928 bool VVideoLiveTV::channelChange(UCHAR changeType, UINT newData)
931 if (streamType ==VDR::VIDEO) {
932 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
934 BoxStack::getInstance()->remove(vtxt);
938 if (changeType == INDEX)
940 newChannel = newData;
942 else if (changeType == NUMBER)
945 for(i = 0; i < chanList->size(); i++)
947 if ((*chanList)[i]->number == (UINT)newData)
954 if (i == chanList->size())
960 else if (changeType == OFFSET)
962 if (newData == UP) newChannel = upChannel(currentChannelIndex);
963 else newChannel = downChannel(currentChannelIndex);
965 else if (changeType == PREVIOUS)
967 newChannel = previousChannelIndex;
971 return false; // bad input
974 if (newChannel == currentChannelIndex) return true;
976 previousChannelIndex = currentChannelIndex;
977 currentChannelIndex = newChannel;
981 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Set player to channel %u", currentChannelIndex);
982 player->setChannel(currentChannelIndex);
983 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Done Set player to channel %u", currentChannelIndex);
985 // Blank out the symbols
986 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
988 bufferBar.setPercent(0);
991 sAudioChannels.setVisible(false);
992 sAspectRatio.setVisible(false);
994 reslogo.setVisible(false);
995 dolbylogo.setVisible(false);
996 txtlogo.setVisible(false);
999 // Remove other stuff
1000 if (textUnavailable.getVisible())
1002 textUnavailable.setVisible(false);
1008 Channel* currentChannel = (*chanList)[currentChannelIndex];
1009 if (currentChannel) {
1010 info.setChannelLogo(currentChannel->number);
1011 if (streamType == VDR::RADIO) {
1012 radioChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1013 radioChannelLogo.setVisible(true);
1015 osdChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1021 BoxStack::getInstance()->update(this);
1026 void VVideoLiveTV::processMessage(Message* m)
1028 if (m->message == Message::MOUSE_LBDOWN)
1030 //check if press is outside this view! then simulate cancel
1031 int x = (m->parameter.num >> 16) - osd.getScreenX();
1032 int y = (m->parameter.num & 0xFFFF) - osd.getScreenY();
1033 if (osd.getVisible()) {
1035 if ((boxRed.getX()<=x) && (boxRed.getX()+(int)boxRed.getWidth()>=x ) &&
1036 (boxRed.getY()<=y) && (boxRed.getY()+(int)boxRed.getHeight()>=y )) {
1037 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)){
1040 BoxStack::getInstance()->handleCommand(Remote::GREEN);
1041 } else if ((boxYellow.getX()<=x) && (boxYellow.getX()+(int)boxYellow.getWidth()>=x ) &&
1042 (boxYellow.getY()<=y) && (boxYellow.getY()+(int)boxYellow.getHeight()>=y )){
1043 BoxStack::getInstance()->handleCommand(Remote::YELLOW);
1044 } else if ((boxBlue.getX()<=x) && (boxBlue.getX()+(int)boxBlue.getWidth()>=x ) &&
1045 (boxBlue.getY()<=y) && (boxBlue.getY()+(int)boxBlue.getHeight()>=y )){
1046 BoxStack::getInstance()->handleCommand(Remote::BLUE);
1048 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
1052 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
1055 else if (m->message == Message::CHANNEL_CHANGE)
1057 channelChange(NUMBER, m->parameter.num);
1058 osdChannelIndex = currentChannelIndex;
1059 if (m->tag == 1) displayOSD(true);
1061 else if (m->message == Message::CHILD_CLOSE)
1069 else if (m->message == Message::AUDIO_CHANGE_CHANNEL)
1071 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change audio channel to %x", m->parameter.num);
1072 player->setAudioChannel((m->parameter.num & 0xFFFF), (m->parameter.num & 0xFF0000) >> 16, (m->parameter.num & 0xFF000000) >> 24);
1074 else if (m->message == Message::SUBTITLE_CHANGE_CHANNEL)
1076 if (streamType !=VDR::VIDEO) return;
1077 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change subtitle channel to %x", m->parameter.num);
1078 int type=((m->parameter.num & 0xFF0000)>>16);
1080 case 0x10: { //dvbsubtitle
1081 if (streamType == VDR::VIDEO){
1082 player->setSubtitleChannel((m->parameter.num & 0xFFFF));
1083 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(true);
1084 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
1085 if (vtxt && vtxt->isInSubtitleMode()) {
1086 BoxStack::getInstance()->remove(vtxt);
1090 case 0xFF: { //nosubtitles
1091 if (streamType == VDR::VIDEO){
1092 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(false);
1093 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
1094 if (vtxt && vtxt->isInSubtitleMode()) {
1095 BoxStack::getInstance()->remove(vtxt);
1099 case 0x11: { //videotext
1100 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(false);
1102 ((PlayerLiveTV*)player)->getTeletextDecoder()->setPage((m->parameter.num & 0xFFFF));
1106 BoxStack::getInstance()->update(vas);
1107 //BoxStack::getInstance()->update(&osd); //eveil error
1109 BoxStack::getInstance()->update(this, osd.getRegion());
1113 else if (m->message == Message::PLAYER_EVENT)
1115 switch (m->parameter.num)
1117 case PlayerLiveTV::CONNECTION_LOST: // connection lost detected
1119 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received connection lost from player");
1120 Command::getInstance()->connectionLost();
1124 case PlayerLiveTV::STREAM_END:
1126 // Message comes from playerlivetv through master mutex, so can do anything here
1131 case PlayerLiveTV::ASPECT43:
1134 if ((video->getTVsize() == Video::ASPECT16X9) && dowss)
1136 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43");
1139 BoxStack::getInstance()->update(this, &wssRegion);
1143 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT43;
1144 sAspectRatio.setVisible(true);
1146 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1149 BoxStack::getInstance()->update(this, osd.getRegion());
1154 case PlayerLiveTV::ASPECT169:
1157 if ((video->getTVsize() == Video::ASPECT16X9) && dowss)
1159 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169");
1162 BoxStack::getInstance()->update(this, &wssRegion);
1166 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT169;
1167 sAspectRatio.setVisible(true);
1169 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1172 BoxStack::getInstance()->update(this, osd.getRegion());
1177 case PlayerLiveTV::PREBUFFERING:
1179 preBuffering = m->tag;
1180 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Prebuffering - %u", preBuffering);
1181 bufferBar.setPercent(preBuffering);
1183 if (osd.getVisible())
1185 bufferBar.setVisible(true);
1188 bufferBar.getRootBoxRegion(&r); ///////// FIXME !!!
1189 BoxStack::getInstance()->update(this, &r);
1191 if (preBuffering == 100)
1193 doAudioChannelSymbol();
1201 void VVideoLiveTV::doAudioChannelSymbol()
1203 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1205 Channel* currentChannel = (*chanList)[osdChannelIndex];
1207 bool multiAudio = false;
1208 if (Audio::getInstance()->supportsAc3()) {
1209 if ((currentChannel->numDPids+currentChannel->numAPids) > 1) multiAudio = true;
1211 if (currentChannel->numAPids > 1) multiAudio = true;
1215 if (multiAudio) sAudioChannels.nextSymbol = WSymbol::MULTIAUDIO;
1216 else sAudioChannels.nextSymbol = WSymbol::SINGLEAUDIO;
1217 sAudioChannels.setVisible(true);
1221 dolbylogo.setVisible(true);
1222 txtlogo.setVisible(true);
1224 if (currentChannel->tpid!=0) info.setStaticArtwork(sa_txton);
1225 else info.setStaticArtwork(sa_txtoff);
1226 txtlogo.setTVMedia(info, WTVMedia::ZoomVertical);
1229 if (Audio::getInstance()->supportsAc3() && currentChannel->numDPids>1)
1230 info.setStaticArtwork(sa_dolbyon);
1231 else info.setStaticArtwork(sa_dolbyoff);
1232 dolbylogo.setTVMedia(info, WTVMedia::ZoomVertical);
1234 Demuxer* demux=Demuxer::getInstance();
1236 int vertical_size=demux->getVerticalSize();
1237 Log::getInstance()->log("VVideoRec", Log::DEBUG, "TVMedia vertical size %d", vertical_size);
1238 reslogo.setVisible(true);
1239 switch (vertical_size) {
1241 info.setStaticArtwork(sa_sd576i);
1242 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1244 info.setStaticArtwork(sa_hd720p);
1245 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1247 info.setStaticArtwork(sa_hd1080i);
1248 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1249 default: // we assume sd
1250 reslogo.setVisible(false);
1254 reslogo.setVisible(false);
1260 if (osd.getVisible())
1262 sAudioChannels.draw();
1264 sAudioChannels.getRootBoxRegion(&r); ///////// FIXME !!!
1268 BoxStack::getInstance()->update(this, &r);
1272 UINT VVideoLiveTV::upChannel(UINT index)
1274 if (index == (chanList->size() - 1)) // at the end
1275 return 0; // so go to start
1280 UINT VVideoLiveTV::downChannel(UINT index)
1282 if (index == 0) // at the start
1283 return chanList->size() - 1; // so go to end
1288 void VVideoLiveTV::toggleChopSides()
1290 if (video->getTVsize() == Video::ASPECT16X9) return; // Means nothing for 16:9 TVs
1292 if (videoMode == Video::NORMAL)
1294 videoMode = Video::LETTERBOX;
1295 video->setMode(Video::LETTERBOX);
1299 videoMode = Video::NORMAL;
1300 video->setMode(Video::NORMAL);
1304 void VVideoLiveTV::updatePosterBanner()
1306 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1308 osdposterbanner.setVisible(false);
1311 Event* toShow = NULL;
1312 if (eventList && eventList->size()) {
1313 toShow = (*eventList)[0];
1314 Channel* currentChannel = (*chanList)[osdChannelIndex];
1315 toShow->loadinfos(currentChannel->number);
1322 bool posterscale=true;
1323 if (toShow->movieInfo) {
1324 poster=toShow->movieInfo->poster;
1326 if (toShow->seriesInfo) {
1327 if (toShow->seriesInfo->banners.size()) {
1328 poster=toShow->seriesInfo->banners[0];
1330 } else if (toShow->seriesInfo->seasonposter.height) {
1331 poster=toShow->seriesInfo->seasonposter;
1332 } else if (toShow->seriesInfo->posters.size()) {
1333 poster=toShow->seriesInfo->posters[0];
1336 if (poster.height) {
1337 osdposterbanner.setTVMedia(poster.info, posterscale ? WTVMedia::ZoomVertical : WTVMedia::ZoomHorizontal);
1338 osdposterbanner.setVisible(true);
1340 osdposterbanner.setVisible(false);
1343 osdposterbanner.setVisible(false);
1349 void VVideoLiveTV::drawOSDBitmap(UINT posX, UINT posY, const Bitmap& bm, const DisplayRegion& region)
1351 drawBitmap(posX, posY, bm,region);
1353 r.x = posX; r.y = posY; r.w = bm.getWidth(); r.h = bm.getHeight();
1354 boxstack->update(this, &r);
1357 void VVideoLiveTV::clearOSD()
1359 rectangle(area, DrawStyle(0,0,0,0));
1360 boxstack->update(this, &area);
1363 void VVideoLiveTV::clearOSDArea(UINT posX, UINT posY, UINT width, UINT height, const DisplayRegion& region)
1366 r.x = posX+region.windowx; r.y = posY+region.windowy; r.w = width; r.h = height;
1367 //now convert to our display
1368 float scalex=720.f/((float) (region.framewidth+1));
1369 float scaley=576.f/((float) (region.frameheight+1));
1370 r.x=floor(scalex*((float)r.x));
1371 r.y=floor(scaley*((float)r.y));
1372 r.w=ceil(scalex*((float)r.w))+1.f;
1373 r.h=ceil(scaley*((float)r.h))+1.f;
1374 rectangle(r, DrawStyle(0,0,0,0));
1375 boxstack->update(this, &r);