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 LOCALTIME_R(&etime, &btime);
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()
864 LOCALTIME_R(&t, &tms);
865 strftime(timeString, 19, "%H:%M", &tms);
866 clock.setText(timeString);
868 time_t dt = 60 - (t % 60); // seconds to the next minute
869 if (dt == 0) dt = 60; // advance a whole minute if necessary
870 dt += t; // get a time_t value for it rather than using duration
871 // (so it will occur at the actual second and not second and a half)
873 Timers::getInstance()->setTimerT(this, 2, dt);
876 void VVideoLiveTV::timercall(int ref)
882 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key start.");
884 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
886 Message* m = new Message();
887 m->message = Message::CHANNEL_CHANGE;
889 m->parameter.num = newChannel;
890 m->tag = 1; // signal to call displayOSD();
891 Command::getInstance()->postMessageFromOuterSpace(m);
892 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key end.");
896 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 not key start.");
897 // We have received a timer, we are not keying. If still prebuffering, don't remove the bar
898 if (preBuffering < 100)
900 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Still prebuffering, not removing osd...");
901 Timers::getInstance()->setTimerD(this, 1, 2); // reset timer for another 2s
904 bool osdpbvisible=osdposterbanner.getVisible();
905 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 1.");
906 osd.setVisible(false);
907 osdposterbanner.setVisible(false);
908 okTriggeredOSD = false;
909 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 2.");
911 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 4.");
912 if (osdpbvisible) boxstack->update(this);
913 else boxstack->update(this, osd.getRegion());
915 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 3.");
916 PlayerLiveTV* playerlivetv = dynamic_cast<PlayerLiveTV*>(player);
917 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false);
918 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey end.");
923 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 start.");
925 if (osd.getVisible())
928 boxstack->update(this, osd.getRegion());
930 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 end.");
934 bool VVideoLiveTV::channelChange(UCHAR changeType, UINT newData)
937 if (streamType ==VDR::VIDEO) {
938 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
940 BoxStack::getInstance()->remove(vtxt);
944 if (changeType == INDEX)
946 newChannel = newData;
948 else if (changeType == NUMBER)
951 for(i = 0; i < chanList->size(); i++)
953 if ((*chanList)[i]->number == (UINT)newData)
960 if (i == chanList->size())
966 else if (changeType == OFFSET)
968 if (newData == UP) newChannel = upChannel(currentChannelIndex);
969 else newChannel = downChannel(currentChannelIndex);
971 else if (changeType == PREVIOUS)
973 newChannel = previousChannelIndex;
977 return false; // bad input
980 if (newChannel == currentChannelIndex) return true;
982 previousChannelIndex = currentChannelIndex;
983 currentChannelIndex = newChannel;
987 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Set player to channel %u", currentChannelIndex);
988 player->setChannel(currentChannelIndex);
989 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Done Set player to channel %u", currentChannelIndex);
991 // Blank out the symbols
992 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
994 bufferBar.setPercent(0);
997 sAudioChannels.setVisible(false);
998 sAspectRatio.setVisible(false);
1000 reslogo.setVisible(false);
1001 dolbylogo.setVisible(false);
1002 txtlogo.setVisible(false);
1005 // Remove other stuff
1006 if (textUnavailable.getVisible())
1008 textUnavailable.setVisible(false);
1014 Channel* currentChannel = (*chanList)[currentChannelIndex];
1015 if (currentChannel) {
1016 info.setChannelLogo(currentChannel->number);
1017 if (streamType == VDR::RADIO) {
1018 radioChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1019 radioChannelLogo.setVisible(true);
1021 osdChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1027 BoxStack::getInstance()->update(this);
1032 void VVideoLiveTV::processMessage(Message* m)
1034 if (m->message == Message::MOUSE_LBDOWN)
1036 //check if press is outside this view! then simulate cancel
1037 int x = (m->parameter.num >> 16) - osd.getScreenX();
1038 int y = (m->parameter.num & 0xFFFF) - osd.getScreenY();
1039 if (osd.getVisible()) {
1041 if ((boxRed.getX()<=x) && (boxRed.getX()+(int)boxRed.getWidth()>=x ) &&
1042 (boxRed.getY()<=y) && (boxRed.getY()+(int)boxRed.getHeight()>=y )) {
1043 BoxStack::getInstance()->handleCommand(Remote::RED);
1044 } else if ((boxGreen.getX()<=x) && (boxGreen.getX()+(int)boxGreen.getWidth()>=x ) &&
1045 (boxGreen.getY()<=y) && (boxGreen.getY()+(int)boxGreen.getHeight()>=y)){
1046 BoxStack::getInstance()->handleCommand(Remote::GREEN);
1047 } else if ((boxYellow.getX()<=x) && (boxYellow.getX()+(int)boxYellow.getWidth()>=x ) &&
1048 (boxYellow.getY()<=y) && (boxYellow.getY()+(int)boxYellow.getHeight()>=y )){
1049 BoxStack::getInstance()->handleCommand(Remote::YELLOW);
1050 } else if ((boxBlue.getX()<=x) && (boxBlue.getX()+(int)boxBlue.getWidth()>=x ) &&
1051 (boxBlue.getY()<=y) && (boxBlue.getY()+(int)boxBlue.getHeight()>=y )){
1052 BoxStack::getInstance()->handleCommand(Remote::BLUE);
1054 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
1058 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
1061 else if (m->message == Message::CHANNEL_CHANGE)
1063 channelChange(NUMBER, m->parameter.num);
1064 osdChannelIndex = currentChannelIndex;
1065 if (m->tag == 1) displayOSD(true);
1067 else if (m->message == Message::CHILD_CLOSE)
1075 else if (m->message == Message::AUDIO_CHANGE_CHANNEL)
1077 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change audio channel to %x", m->parameter.num);
1078 player->setAudioChannel((m->parameter.num & 0xFFFF), (m->parameter.num & 0xFF0000) >> 16, (m->parameter.num & 0xFF000000) >> 24);
1080 else if (m->message == Message::SUBTITLE_CHANGE_CHANNEL)
1082 if (streamType !=VDR::VIDEO) return;
1083 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change subtitle channel to %x", m->parameter.num);
1084 int type=((m->parameter.num & 0xFF0000)>>16);
1086 case 0x10: { //dvbsubtitle
1087 if (streamType == VDR::VIDEO){
1088 player->setSubtitleChannel((m->parameter.num & 0xFFFF));
1089 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(true);
1090 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
1091 if (vtxt && vtxt->isInSubtitleMode()) {
1092 BoxStack::getInstance()->remove(vtxt);
1096 case 0xFF: { //nosubtitles
1097 if (streamType == VDR::VIDEO){
1098 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(false);
1099 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
1100 if (vtxt && vtxt->isInSubtitleMode()) {
1101 BoxStack::getInstance()->remove(vtxt);
1105 case 0x11: { //videotext
1106 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(false);
1108 ((PlayerLiveTV*)player)->getTeletextDecoder()->setPage((m->parameter.num & 0xFFFF));
1112 BoxStack::getInstance()->update(vas);
1113 //BoxStack::getInstance()->update(&osd); //eveil error
1115 BoxStack::getInstance()->update(this, osd.getRegion());
1119 else if (m->message == Message::PLAYER_EVENT)
1121 switch (m->parameter.num)
1123 case PlayerLiveTV::CONNECTION_LOST: // connection lost detected
1125 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received connection lost from player");
1126 Command::getInstance()->connectionLost();
1130 case PlayerLiveTV::STREAM_END:
1132 // Message comes from playerlivetv through master mutex, so can do anything here
1137 case PlayerLiveTV::ASPECT43:
1140 if ((video->getTVsize() == Video::ASPECT16X9) && dowss)
1142 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43");
1145 BoxStack::getInstance()->update(this, &wssRegion);
1149 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1152 osdv->updateBackgroundColor(DrawStyle::BLACK);
1155 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT43;
1156 sAspectRatio.setVisible(true);
1158 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1161 BoxStack::getInstance()->update(this, osd.getRegion());
1166 case PlayerLiveTV::ASPECT169:
1169 if ((video->getTVsize() == Video::ASPECT16X9) && dowss)
1171 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169");
1174 BoxStack::getInstance()->update(this, &wssRegion);
1178 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT169;
1179 sAspectRatio.setVisible(true);
1181 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1184 osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
1188 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1191 BoxStack::getInstance()->update(this, osd.getRegion());
1196 case PlayerLiveTV::PREBUFFERING:
1198 preBuffering = m->tag;
1199 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Prebuffering - %u", preBuffering);
1200 bufferBar.setPercent(preBuffering);
1202 if (osd.getVisible())
1204 bufferBar.setVisible(true);
1207 bufferBar.getRootBoxRegion(&r); ///////// FIXME !!!
1208 BoxStack::getInstance()->update(this, &r);
1210 if (preBuffering == 100)
1212 doAudioChannelSymbol();
1218 #ifdef VOMP_PLATTFORM_MVP
1219 // See vepg.cc ~ line 480
1220 else if (m->message == Message::HACK_MVP_RETURN_FROM_QUARTER)
1222 video->setMode(videoMode);
1227 void VVideoLiveTV::doAudioChannelSymbol()
1229 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1231 Channel* currentChannel = (*chanList)[osdChannelIndex];
1233 bool multiAudio = false;
1234 if (Audio::getInstance()->supportsAc3()) {
1235 if ((currentChannel->numDPids+currentChannel->numAPids) > 1) multiAudio = true;
1237 if (currentChannel->numAPids > 1) multiAudio = true;
1241 if (multiAudio) sAudioChannels.nextSymbol = WSymbol::MULTIAUDIO;
1242 else sAudioChannels.nextSymbol = WSymbol::SINGLEAUDIO;
1243 sAudioChannels.setVisible(true);
1247 dolbylogo.setVisible(true);
1248 txtlogo.setVisible(true);
1250 if (currentChannel->tpid!=0) info.setStaticArtwork(sa_txton);
1251 else info.setStaticArtwork(sa_txtoff);
1252 txtlogo.setTVMedia(info, WTVMedia::ZoomVertical);
1255 if (Audio::getInstance()->supportsAc3() && currentChannel->numDPids>1)
1256 info.setStaticArtwork(sa_dolbyon);
1257 else info.setStaticArtwork(sa_dolbyoff);
1258 dolbylogo.setTVMedia(info, WTVMedia::ZoomVertical);
1260 Demuxer* demux=Demuxer::getInstance();
1262 int vertical_size=demux->getVerticalSize();
1263 Log::getInstance()->log("VVideoRec", Log::DEBUG, "TVMedia vertical size %d", vertical_size);
1264 reslogo.setVisible(true);
1265 switch (vertical_size) {
1267 info.setStaticArtwork(sa_sd576i);
1268 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1270 info.setStaticArtwork(sa_hd720p);
1271 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1273 info.setStaticArtwork(sa_hd1080i);
1274 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1275 default: // we assume sd
1276 reslogo.setVisible(false);
1280 reslogo.setVisible(false);
1286 if (osd.getVisible())
1288 sAudioChannels.draw();
1290 sAudioChannels.getRootBoxRegion(&r); ///////// FIXME !!!
1294 BoxStack::getInstance()->update(this, &r);
1298 UINT VVideoLiveTV::upChannel(UINT index)
1300 if (index == (chanList->size() - 1)) // at the end
1301 return 0; // so go to start
1306 UINT VVideoLiveTV::downChannel(UINT index)
1308 if (index == 0) // at the start
1309 return chanList->size() - 1; // so go to end
1314 void VVideoLiveTV::toggleChopSides()
1316 if (video->getTVsize() == Video::ASPECT16X9) return; // Means nothing for 16:9 TVs
1318 if (videoMode == Video::NORMAL)
1320 videoMode = Video::LETTERBOX;
1321 video->setMode(Video::LETTERBOX);
1325 videoMode = Video::NORMAL;
1326 video->setMode(Video::NORMAL);
1330 void VVideoLiveTV::updatePosterBanner()
1332 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1334 osdposterbanner.setVisible(false);
1337 Event* toShow = NULL;
1338 if (eventList && eventList->size()) {
1339 toShow = (*eventList)[0];
1340 Channel* currentChannel = (*chanList)[osdChannelIndex];
1341 toShow->loadinfos(currentChannel->number);
1348 bool posterscale=true;
1349 if (toShow->movieInfo) {
1350 poster=toShow->movieInfo->poster;
1352 if (toShow->seriesInfo) {
1353 if (toShow->seriesInfo->banners.size()) {
1354 poster=toShow->seriesInfo->banners[0];
1356 } else if (toShow->seriesInfo->seasonposter.height) {
1357 poster=toShow->seriesInfo->seasonposter;
1358 } else if (toShow->seriesInfo->posters.size()) {
1359 poster=toShow->seriesInfo->posters[0];
1362 if (poster.height) {
1363 osdposterbanner.setTVMedia(poster.info, posterscale ? WTVMedia::ZoomVertical : WTVMedia::ZoomHorizontal);
1364 osdposterbanner.setVisible(true);
1366 osdposterbanner.setVisible(false);
1369 osdposterbanner.setVisible(false);
1375 void VVideoLiveTV::drawOSDBitmap(UINT posX, UINT posY, const Bitmap& bm, const DisplayRegion& region)
1377 drawBitmap(posX, posY, bm,region);
1379 r.x = posX; r.y = posY; r.w = bm.getWidth(); r.h = bm.getHeight();
1380 boxstack->update(this, &r);
1383 void VVideoLiveTV::clearOSD()
1385 rectangle(area, DrawStyle(0,0,0,0));
1386 boxstack->update(this, &area);
1389 void VVideoLiveTV::clearOSDArea(UINT posX, UINT posY, UINT width, UINT height, const DisplayRegion& region)
1392 r.x = posX+region.windowx; r.y = posY+region.windowy; r.w = width; r.h = height;
1393 //now convert to our display
1394 float scalex=720.f/((float) (region.framewidth+1));
1395 float scaley=576.f/((float) (region.frameheight+1));
1396 r.x = (UINT)floor(scalex*((float)r.x));
1397 r.y = (UINT)floor(scaley*((float)r.y));
1398 r.w = (UINT)(ceil(scalex*((float)r.w))+1.f);
1399 r.h = (UINT)(ceil(scaley*((float)r.h))+1.f);
1400 rectangle(r, DrawStyle(0,0,0,0));
1401 boxstack->update(this, &r);