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();
308 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
311 osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
315 void VVideoLiveTV::delData()
319 int eventListSize = eventList->size();
320 for(int i = 0; i < eventListSize; i++)
322 delete (*eventList)[i];
330 int VVideoLiveTV::handleCommand(int command)
336 if (osd.getVisible() && !textUnavailable.getVisible())
341 // else drop through to stop
346 vchannelList->highlightChannel((*chanList)[currentChannelIndex]);
350 // NEW REMOTE ONLY - navigate EPG, bring it onscreen if it's not there
353 if (Remote::getInstance()->mayHaveFewButtons()) {
354 if (okTriggeredOSD) doUpDown(false);
355 else doChanUpDown(UP);
363 if (Remote::getInstance()->mayHaveFewButtons()) {
364 if (okTriggeredOSD) doUpDown(true);
365 else doChanUpDown(DOWN);
381 // Continue new remote only...
382 case Remote::CHANNELUP:
387 case Remote::CHANNELDOWN:
393 // END NEW REMOTE ONLY, START OLD REMOTE ONLY
395 // DF_LEFT and DF_RIGHT never get here because they are stolen
396 // by command as vol- and vol+
398 // Old remote. Decide what to do based on whether
399 // OK was pressed - osd shown manually, use up/down for epg nav
400 // UP/DOWN was pressed to change channel, osd was shown auto, use up/down for ch+/ch-
404 // Old remote, decide what to do based on okTriggeredOSD
405 if (okTriggeredOSD) doUpDown(false);
406 else doChanUpDown(UP);
409 case Remote::DF_DOWN:
411 // Old remote, decide what to do based on okTriggeredOSD
412 if (okTriggeredOSD) doUpDown(true);
413 else doChanUpDown(DOWN);
417 // END NEW/OLD REMOTE STUFF
419 case Remote::PREVCHANNEL:
421 channelChange(PREVIOUS, 0);
422 osdChannelIndex = currentChannelIndex;
455 // key in channel number
462 if (streamType == VDR::VIDEO) doAudioSelector();
467 if (streamType ==VDR::VIDEO)
469 doTeletext(); //TODO: Add a selector for subtitles or teletext
480 if (streamType == VDR::VIDEO)
481 (static_cast<PlayerLiveTV*>(player))->toggleSubtitles();
488 void VVideoLiveTV::go()
492 boxstack->update(this);
497 player->go(currentChannelIndex);
500 void VVideoLiveTV::stop()
502 Timers::getInstance()->cancelTimer(this, 1);
503 Timers::getInstance()->cancelTimer(this, 2);
508 void VVideoLiveTV::doLeftRight(bool right)
510 if (osd.getVisible())
512 if (right) osdChannelIndex = upChannel(osdChannelIndex);
513 else osdChannelIndex = downChannel(osdChannelIndex);
517 osdChannelIndex = currentChannelIndex;
522 void VVideoLiveTV::doUpDown(bool down)
524 if (osd.getVisible())
536 void VVideoLiveTV::doChanUpDown(int which)
538 channelChange(OFFSET, which);
539 osdChannelIndex = currentChannelIndex;
543 void VVideoLiveTV::doOK()
545 if (osd.getVisible())
550 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
552 channelChange(NUMBER, newChannel);
553 osdChannelIndex = currentChannelIndex;
556 else if (osdChannelIndex == currentChannelIndex)
562 channelChange(INDEX, osdChannelIndex);
568 osdChannelIndex = currentChannelIndex;
570 okTriggeredOSD = true;
574 void VVideoLiveTV::doSummary()
577 Channel* currentChannel = (*chanList)[osdChannelIndex];
578 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
583 sort(eventList->begin(), eventList->end(), EventSorter());
585 if (eventList->size() < 1) return;
586 Event* event = (*eventList)[0];
587 event->loadinfos(currentChannel->number);
589 VEpgSummary* vr = new VEpgSummary(event,currentChannel);
592 boxstack->update(vr);
596 void VVideoLiveTV::doKey(int command)
598 if (!osd.getVisible()) // First key. prep the data
601 updatePosterBanner();
606 for (i = keying - 1; i >= 0; i--) keyingInput[i+1] = keyingInput[i];
607 keyingInput[0] = command;
610 char* keyingString = new char[numberWidth + 1];
611 for (i = 0; i < numberWidth; i++) keyingString[i] = '_';
612 keyingString[numberWidth] = '\0';
614 for (i = 0; i < keying; i++) keyingString[i] = keyingInput[keying - 1 - i] + 48;
616 if (keying == numberWidth)
619 for(i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
621 channelChange(NUMBER, newChannel);
622 osdChannelIndex = currentChannelIndex;
623 Timers::getInstance()->cancelTimer(this, 1); // cancel the timer to react to keying input,
624 displayOSD(true); // this will put one back if required
628 osdChanNum.setText(keyingString);
630 if (!osd.getVisible())
632 osd.setVisible(true);
639 boxstack->update(this, osd.getRegion());
640 Timers::getInstance()->setTimerD(this, 1, 3); // 3s for keying input
642 delete[] keyingString;
645 void VVideoLiveTV::doTeletext(bool subtitlemode)
647 if (streamType !=VDR::VIDEO) return;
648 (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(true);
655 // and reset the display - this is a copy from setNowNextData
656 char formatChanNum[20];
657 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
658 osdChanNum.setText(formatChanNum);
659 osdChanName.setText((*chanList)[osdChannelIndex]->name);
661 (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(true);
662 if (osd.getVisible()) clearScreen();
664 VTeletextView *vtxv=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
666 vtxv= new VTeletextView(((PlayerLiveTV*)player)->getTeletextDecoder(),this, (PlayerLiveTV*)player);
667 ((PlayerLiveTV*)player)->getTeletextDecoder()->registerTeletextView(vtxv);
670 vtxv->setSubtitleMode(subtitlemode);
675 BoxStack::getInstance()->add(vtxv);
677 BoxStack::getInstance()->update(this);
678 BoxStack::getInstance()->update(vtxv);
681 void VVideoLiveTV::doAudioSelector()
683 // If the osd is already visisble there might be a timer for it
684 Timers::getInstance()->cancelTimer(this, 1);
685 //This causes a deadlock with the timertrhread itself is locked
692 // and reset the display - this is a copy from setNowNextData
693 char formatChanNum[20];
694 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
695 osdChanNum.setText(formatChanNum);
696 osdChanName.setText((*chanList)[osdChannelIndex]->name);
698 int subtitleChannel=((PlayerLiveTV*)player)->getCurrentSubtitleChannel();
699 int subtitleType=0x10;
700 if (!(static_cast<PlayerLiveTV*>(player))->isSubtitlesOn()) {
701 if (((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView() &&
702 ((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView()->isInSubtitleMode()
704 subtitleChannel=((PlayerLiveTV*)player)->getTeletextDecoder()->getPage();
708 subtitleType=0xFF; //turnedOff
714 vas = new VAudioSelector(this, (*chanList)[currentChannelIndex], ((PlayerLiveTV*)player)->getCurrentAudioChannel(),
715 subtitleType,subtitleChannel,NULL);
717 vas->setBackgroundColour(DrawStyle::OSDBACKGROUND);
718 vas->setPosition(0, osd.getScreenY() - vas->getHeight());
721 // make vas != null and displayOSD will not set a timer or do any boxstack update
722 if (osd.getVisible()) displayOSD(false);
723 else displayOSD(true);
726 BoxStack::getInstance()->add(vas);
727 BoxStack::getInstance()->update(this);
728 BoxStack::getInstance()->update(vas);
731 void VVideoLiveTV::doEPG()
733 if (osd.getVisible()) clearScreen();
735 if (!Command::getInstance()->advMenues()) {
737 VEpg* vepg = new VEpg(this, currentChannelIndex, chanList);
740 boxstack->update(vepg);
742 Channel* currentChannel = (*chanList)[osdChannelIndex];
743 VEpgListAdvanced *vepg= new VEpgListAdvanced(this, chanList, currentChannel->number);
746 boxstack->update(vepg);
750 void VVideoLiveTV::setNowNextData()
754 Channel* currentChannel = (*chanList)[osdChannelIndex];
756 char formatChanNum[20];
757 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, currentChannel->number);
758 osdChanNum.setText(formatChanNum);
759 osdChanName.setText(currentChannel->name);
761 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
765 sl.setText(tr("No channel data available"));
769 sort(eventList->begin(), eventList->end(), EventSorter());
771 char tempString[300];
772 char tempString2[300];
775 int eventListSize = eventList->size();
776 std::stringstream string;
777 for(int i = 0; i < eventListSize; i++)
779 event = (*eventList)[i];
781 time_t etime = event->time;
782 btime = localtime(&etime);
784 strftime(tempString2, 299, "%0H:%0M ", btime);
786 strftime(tempString2, 299, "%H:%M ", btime);
788 SNPRINTF(tempString, 299, "%s %s", tempString2, event->title);
789 string << tempString << "\n";
791 sl.setText(string.str().c_str());
797 void VVideoLiveTV::displayOSD(bool newNowNextData)
799 PlayerLiveTV* playerlivetv = dynamic_cast<PlayerLiveTV*>(player);
800 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(true);
801 osd.setVisible(true);
805 updatePosterBanner();
809 if (osdposterbanner.getVisible()) osdposterbanner.draw();
814 toupdate=*osd.getRegion();
817 if (osdposterbanner.getVisible()) {
818 boxstack->update(this);
820 boxstack->update(this, &toupdate);
823 bool setTimer = true;
824 if (vas) setTimer = false;
825 if (textUnavailable.getVisible()) setTimer = false;
827 if (setTimer) Timers::getInstance()->setTimerD(this, 1, 4);
830 void VVideoLiveTV::clearScreen()
832 Timers::getInstance()->cancelTimer(this, 1);
834 textUnavailable.setVisible(false);
835 osd.setVisible(false);
836 osdposterbanner.setVisible(false);
838 okTriggeredOSD = false;
841 boxstack->update(this);
843 PlayerLiveTV* playerlivetv = dynamic_cast<PlayerLiveTV*>(player);
844 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false);
847 void VVideoLiveTV::showUnavailable()
849 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Show unavailable called");
850 textUnavailable.setVisible(true);
851 textUnavailable.draw();
853 if (!osd.getVisible()) displayOSD(true);
855 boxstack->update(this, textUnavailable.getRegion());
858 void VVideoLiveTV::setClock()
863 struct tm* tms = localtime(&t);
864 strftime(timeString, 19, "%H:%M", tms);
865 clock.setText(timeString);
867 time_t dt = 60 - (t % 60); // seconds to the next minute
868 if (dt == 0) dt = 60; // advance a whole minute if necessary
869 dt += t; // get a time_t value for it rather than using duration
870 // (so it will occur at the actual second and not second and a half)
872 Timers::getInstance()->setTimerT(this, 2, dt);
875 void VVideoLiveTV::timercall(int ref)
881 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key start.");
883 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
885 Message* m = new Message();
886 m->message = Message::CHANNEL_CHANGE;
888 m->parameter.num = newChannel;
889 m->tag = 1; // signal to call displayOSD();
890 Command::getInstance()->postMessageFromOuterSpace(m);
891 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key end.");
895 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 not key start.");
896 // We have received a timer, we are not keying. If still prebuffering, don't remove the bar
897 if (preBuffering < 100)
899 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Still prebuffering, not removing osd...");
900 Timers::getInstance()->setTimerD(this, 1, 2); // reset timer for another 2s
903 bool osdpbvisible=osdposterbanner.getVisible();
904 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 1.");
905 osd.setVisible(false);
906 osdposterbanner.setVisible(false);
907 okTriggeredOSD = false;
908 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 2.");
910 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 4.");
911 if (osdpbvisible) boxstack->update(this);
912 else boxstack->update(this, osd.getRegion());
914 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 3.");
915 PlayerLiveTV* playerlivetv = dynamic_cast<PlayerLiveTV*>(player);
916 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false);
917 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey end.");
922 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 start.");
924 if (osd.getVisible())
927 boxstack->update(this, osd.getRegion());
929 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 end.");
933 bool VVideoLiveTV::channelChange(UCHAR changeType, UINT newData)
936 if (streamType ==VDR::VIDEO) {
937 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
939 BoxStack::getInstance()->remove(vtxt);
943 if (changeType == INDEX)
945 newChannel = newData;
947 else if (changeType == NUMBER)
950 for(i = 0; i < chanList->size(); i++)
952 if ((*chanList)[i]->number == (UINT)newData)
959 if (i == chanList->size())
965 else if (changeType == OFFSET)
967 if (newData == UP) newChannel = upChannel(currentChannelIndex);
968 else newChannel = downChannel(currentChannelIndex);
970 else if (changeType == PREVIOUS)
972 newChannel = previousChannelIndex;
976 return false; // bad input
979 if (newChannel == currentChannelIndex) return true;
981 previousChannelIndex = currentChannelIndex;
982 currentChannelIndex = newChannel;
986 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Set player to channel %u", currentChannelIndex);
987 player->setChannel(currentChannelIndex);
988 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Done Set player to channel %u", currentChannelIndex);
990 // Blank out the symbols
991 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
993 bufferBar.setPercent(0);
996 sAudioChannels.setVisible(false);
997 sAspectRatio.setVisible(false);
999 reslogo.setVisible(false);
1000 dolbylogo.setVisible(false);
1001 txtlogo.setVisible(false);
1004 // Remove other stuff
1005 if (textUnavailable.getVisible())
1007 textUnavailable.setVisible(false);
1013 Channel* currentChannel = (*chanList)[currentChannelIndex];
1014 if (currentChannel) {
1015 info.setChannelLogo(currentChannel->number);
1016 if (streamType == VDR::RADIO) {
1017 radioChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1018 radioChannelLogo.setVisible(true);
1020 osdChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1026 BoxStack::getInstance()->update(this);
1031 void VVideoLiveTV::processMessage(Message* m)
1033 if (m->message == Message::MOUSE_LBDOWN)
1035 //check if press is outside this view! then simulate cancel
1036 int x = (m->parameter.num >> 16) - osd.getScreenX();
1037 int y = (m->parameter.num & 0xFFFF) - osd.getScreenY();
1038 if (osd.getVisible()) {
1040 if ((boxRed.getX()<=x) && (boxRed.getX()+(int)boxRed.getWidth()>=x ) &&
1041 (boxRed.getY()<=y) && (boxRed.getY()+(int)boxRed.getHeight()>=y )) {
1042 BoxStack::getInstance()->handleCommand(Remote::RED);
1043 } else if ((boxGreen.getX()<=x) && (boxGreen.getX()+(int)boxGreen.getWidth()>=x ) &&
1044 (boxGreen.getY()<=y) && (boxGreen.getY()+(int)boxGreen.getHeight()>=y)){
1045 BoxStack::getInstance()->handleCommand(Remote::GREEN);
1046 } else if ((boxYellow.getX()<=x) && (boxYellow.getX()+(int)boxYellow.getWidth()>=x ) &&
1047 (boxYellow.getY()<=y) && (boxYellow.getY()+(int)boxYellow.getHeight()>=y )){
1048 BoxStack::getInstance()->handleCommand(Remote::YELLOW);
1049 } else if ((boxBlue.getX()<=x) && (boxBlue.getX()+(int)boxBlue.getWidth()>=x ) &&
1050 (boxBlue.getY()<=y) && (boxBlue.getY()+(int)boxBlue.getHeight()>=y )){
1051 BoxStack::getInstance()->handleCommand(Remote::BLUE);
1053 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
1057 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
1060 else if (m->message == Message::CHANNEL_CHANGE)
1062 channelChange(NUMBER, m->parameter.num);
1063 osdChannelIndex = currentChannelIndex;
1064 if (m->tag == 1) displayOSD(true);
1066 else if (m->message == Message::CHILD_CLOSE)
1074 else if (m->message == Message::AUDIO_CHANGE_CHANNEL)
1076 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change audio channel to %x", m->parameter.num);
1077 player->setAudioChannel((m->parameter.num & 0xFFFF), (m->parameter.num & 0xFF0000) >> 16, (m->parameter.num & 0xFF000000) >> 24);
1079 else if (m->message == Message::SUBTITLE_CHANGE_CHANNEL)
1081 if (streamType !=VDR::VIDEO) return;
1082 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change subtitle channel to %x", m->parameter.num);
1083 int type=((m->parameter.num & 0xFF0000)>>16);
1085 case 0x10: { //dvbsubtitle
1086 if (streamType == VDR::VIDEO){
1087 player->setSubtitleChannel((m->parameter.num & 0xFFFF));
1088 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(true);
1089 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
1090 if (vtxt && vtxt->isInSubtitleMode()) {
1091 BoxStack::getInstance()->remove(vtxt);
1095 case 0xFF: { //nosubtitles
1096 if (streamType == VDR::VIDEO){
1097 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(false);
1098 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
1099 if (vtxt && vtxt->isInSubtitleMode()) {
1100 BoxStack::getInstance()->remove(vtxt);
1104 case 0x11: { //videotext
1105 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(false);
1107 ((PlayerLiveTV*)player)->getTeletextDecoder()->setPage((m->parameter.num & 0xFFFF));
1111 BoxStack::getInstance()->update(vas);
1112 //BoxStack::getInstance()->update(&osd); //eveil error
1114 BoxStack::getInstance()->update(this, osd.getRegion());
1118 else if (m->message == Message::PLAYER_EVENT)
1120 switch (m->parameter.num)
1122 case PlayerLiveTV::CONNECTION_LOST: // connection lost detected
1124 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received connection lost from player");
1125 Command::getInstance()->connectionLost();
1129 case PlayerLiveTV::STREAM_END:
1131 // Message comes from playerlivetv through master mutex, so can do anything here
1136 case PlayerLiveTV::ASPECT43:
1139 if ((video->getTVsize() == Video::ASPECT16X9) && dowss)
1141 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43");
1144 BoxStack::getInstance()->update(this, &wssRegion);
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:
1168 if ((video->getTVsize() == Video::ASPECT16X9) && dowss)
1170 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169");
1173 BoxStack::getInstance()->update(this, &wssRegion);
1177 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT169;
1178 sAspectRatio.setVisible(true);
1180 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1183 osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
1187 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1190 BoxStack::getInstance()->update(this, osd.getRegion());
1195 case PlayerLiveTV::PREBUFFERING:
1197 preBuffering = m->tag;
1198 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Prebuffering - %u", preBuffering);
1199 bufferBar.setPercent(preBuffering);
1201 if (osd.getVisible())
1203 bufferBar.setVisible(true);
1206 bufferBar.getRootBoxRegion(&r); ///////// FIXME !!!
1207 BoxStack::getInstance()->update(this, &r);
1209 if (preBuffering == 100)
1211 doAudioChannelSymbol();
1219 void VVideoLiveTV::doAudioChannelSymbol()
1221 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1223 Channel* currentChannel = (*chanList)[osdChannelIndex];
1225 bool multiAudio = false;
1226 if (Audio::getInstance()->supportsAc3()) {
1227 if ((currentChannel->numDPids+currentChannel->numAPids) > 1) multiAudio = true;
1229 if (currentChannel->numAPids > 1) multiAudio = true;
1233 if (multiAudio) sAudioChannels.nextSymbol = WSymbol::MULTIAUDIO;
1234 else sAudioChannels.nextSymbol = WSymbol::SINGLEAUDIO;
1235 sAudioChannels.setVisible(true);
1239 dolbylogo.setVisible(true);
1240 txtlogo.setVisible(true);
1242 if (currentChannel->tpid!=0) info.setStaticArtwork(sa_txton);
1243 else info.setStaticArtwork(sa_txtoff);
1244 txtlogo.setTVMedia(info, WTVMedia::ZoomVertical);
1247 if (Audio::getInstance()->supportsAc3() && currentChannel->numDPids>1)
1248 info.setStaticArtwork(sa_dolbyon);
1249 else info.setStaticArtwork(sa_dolbyoff);
1250 dolbylogo.setTVMedia(info, WTVMedia::ZoomVertical);
1252 Demuxer* demux=Demuxer::getInstance();
1254 int vertical_size=demux->getVerticalSize();
1255 Log::getInstance()->log("VVideoRec", Log::DEBUG, "TVMedia vertical size %d", vertical_size);
1256 reslogo.setVisible(true);
1257 switch (vertical_size) {
1259 info.setStaticArtwork(sa_sd576i);
1260 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1262 info.setStaticArtwork(sa_hd720p);
1263 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1265 info.setStaticArtwork(sa_hd1080i);
1266 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1267 default: // we assume sd
1268 reslogo.setVisible(false);
1272 reslogo.setVisible(false);
1278 if (osd.getVisible())
1280 sAudioChannels.draw();
1282 sAudioChannels.getRootBoxRegion(&r); ///////// FIXME !!!
1286 BoxStack::getInstance()->update(this, &r);
1290 UINT VVideoLiveTV::upChannel(UINT index)
1292 if (index == (chanList->size() - 1)) // at the end
1293 return 0; // so go to start
1298 UINT VVideoLiveTV::downChannel(UINT index)
1300 if (index == 0) // at the start
1301 return chanList->size() - 1; // so go to end
1306 void VVideoLiveTV::toggleChopSides()
1308 if (video->getTVsize() == Video::ASPECT16X9) return; // Means nothing for 16:9 TVs
1310 if (videoMode == Video::NORMAL)
1312 videoMode = Video::LETTERBOX;
1313 video->setMode(Video::LETTERBOX);
1317 videoMode = Video::NORMAL;
1318 video->setMode(Video::NORMAL);
1322 void VVideoLiveTV::updatePosterBanner()
1324 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1326 osdposterbanner.setVisible(false);
1329 Event* toShow = NULL;
1330 if (eventList && eventList->size()) {
1331 toShow = (*eventList)[0];
1332 Channel* currentChannel = (*chanList)[osdChannelIndex];
1333 toShow->loadinfos(currentChannel->number);
1340 bool posterscale=true;
1341 if (toShow->movieInfo) {
1342 poster=toShow->movieInfo->poster;
1344 if (toShow->seriesInfo) {
1345 if (toShow->seriesInfo->banners.size()) {
1346 poster=toShow->seriesInfo->banners[0];
1348 } else if (toShow->seriesInfo->seasonposter.height) {
1349 poster=toShow->seriesInfo->seasonposter;
1350 } else if (toShow->seriesInfo->posters.size()) {
1351 poster=toShow->seriesInfo->posters[0];
1354 if (poster.height) {
1355 osdposterbanner.setTVMedia(poster.info, posterscale ? WTVMedia::ZoomVertical : WTVMedia::ZoomHorizontal);
1356 osdposterbanner.setVisible(true);
1358 osdposterbanner.setVisible(false);
1361 osdposterbanner.setVisible(false);
1367 void VVideoLiveTV::drawOSDBitmap(UINT posX, UINT posY, const Bitmap& bm, const DisplayRegion& region)
1369 drawBitmap(posX, posY, bm,region);
1371 r.x = posX; r.y = posY; r.w = bm.getWidth(); r.h = bm.getHeight();
1372 boxstack->update(this, &r);
1375 void VVideoLiveTV::clearOSD()
1377 rectangle(area, DrawStyle(0,0,0,0));
1378 boxstack->update(this, &area);
1381 void VVideoLiveTV::clearOSDArea(UINT posX, UINT posY, UINT width, UINT height, const DisplayRegion& region)
1384 r.x = posX+region.windowx; r.y = posY+region.windowy; r.w = width; r.h = height;
1385 //now convert to our display
1386 float scalex=720.f/((float) (region.framewidth+1));
1387 float scaley=576.f/((float) (region.frameheight+1));
1388 r.x=floor(scalex*((float)r.x));
1389 r.y=floor(scaley*((float)r.y));
1390 r.w=ceil(scalex*((float)r.w))+1.f;
1391 r.h=ceil(scaley*((float)r.h))+1.f;
1392 rectangle(r, DrawStyle(0,0,0,0));
1393 boxstack->update(this, &r);