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"
48 VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, VChannelList* tvchannelList)
49 : osdBack(0, 0, 0, 128)
51 vdr = VDR::getInstance();
52 boxstack = BoxStack::getInstance();
53 video = Video::getInstance();
58 vchannelList = tvchannelList;
59 numberWidth = (int)VDR::getInstance()->getChannelNumberWidth();
61 currentChannelIndex = 0;
62 previousChannelIndex = 0;
69 // Convert channel number to index
71 for(i = 0; i < chanList->size(); i++)
73 if ((*chanList)[i]->number == (UINT)initialChannelNumber)
75 currentChannelIndex = i;
83 videoMode = video->getMode();
85 if ((*chanList)[currentChannelIndex]->type == VDR::VIDEO)
87 streamType = VDR::VIDEO;
88 player = new PlayerLiveTV(Command::getInstance(), this, this, chanList);
92 streamType = VDR::RADIO;
93 player = new PlayerLiveRadio(Command::getInstance(), this, chanList);
97 setSize(video->getScreenWidth(), video->getScreenHeight());
99 DrawStyle transparent(0, 0, 0, 0);
100 setBackgroundColour(transparent);
103 char* optionWSS = vdr->configLoad("General", "WSS");
106 if (strstr(optionWSS, "Yes")) dowss = true;
109 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Do WSS: %u", dowss);
113 wss.setFormat(video->getFormat());
119 wssRegion.w = video->getScreenWidth();
123 // This variable is set to true if the user pressed OK to bring the OSD on screen
124 // This is only used on old remotes to stop up/down buttons being used for osd-epg scrolling
125 okTriggeredOSD = false;
128 info.setChannelLogo(initialChannelNumber);
129 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
131 if (osdv && streamType == VDR::RADIO) {
132 radioChannelLogo.setPosition(video->getScreenWidth()/4,video->getScreenHeight()/4);
133 radioChannelLogo.setSize(video->getScreenWidth()/2,video->getScreenHeight()/2);
134 radioChannelLogo.setVisible(true);
135 radioChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
136 add(&radioChannelLogo);
139 osdposterbanner.setPosition(20,20);
140 osdposterbanner.setBackgroundColour(osdBack);
141 osdposterbanner.setSize(video->getScreenWidth()*4/10,video->getScreenHeight()*4/10);
142 osdposterbanner.setVisible(false);
143 add(&osdposterbanner);
147 osd.setBackgroundColour(osdBack);
148 osd.setPosition(0, video->getScreenHeight() - 150);
149 osd.setSize(video->getScreenWidth(), 150);
150 osd.setVisible(false);
153 int channellogomove=0;
155 osdChannelLogo.setBackgroundColour(osdBack);
156 osdChannelLogo.setPosition(30,5);
157 osdChannelLogo.setSize(60,60);
158 osdChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
159 osd.add(&osdChannelLogo);
160 channellogomove=30-5;
163 clock.setBackgroundColour(osdBack);
164 clock.setPosition(osd.getWidth() - 100, 4);
165 clock.setSize(90, 30);
168 osdChanNum.setBackgroundColour(osdBack);
169 osdChanNum.setPosition(60+channellogomove, 4);
170 osdChanNum.setSize((numberWidth*10) + 22, getFontHeight()+5); // 10 px = width of number chars in font
171 osd.add(&osdChanNum);
173 osdChanName.setBackgroundColour(osdBack);
174 osdChanName.setPosition(osdChanNum.getX2() + 10, 4);
175 osdChanName.setSize(300, 30);
176 osd.add(&osdChanName);
178 boxRed.setBackgroundColour(DrawStyle::RED);
179 boxRed.setPosition(54, 104);
180 boxRed.setSize(18, 16);
183 boxGreen.setBackgroundColour(DrawStyle::GREEN);
184 boxGreen.setPosition(220, 104);
185 boxGreen.setSize(18, 16);
188 boxYellow.setBackgroundColour(DrawStyle::YELLOW);
189 boxYellow.setPosition(390, 104);
190 boxYellow.setSize(18, 16);
193 boxBlue.setBackgroundColour(DrawStyle::BLUE);
194 boxBlue.setPosition(560, 104);
195 boxBlue.setSize(18, 16);
198 textRed.setBackgroundColour(osdBack);
199 textRed.setPosition(boxRed.getX2(), 98);
200 textRed.setSize(boxGreen.getX() - boxRed.getX2(), 30);
201 textRed.setText(tr("Summary"));
204 if (streamType == VDR::VIDEO)
206 textGreen.setBackgroundColour(osdBack);
207 textGreen.setPosition(boxGreen.getX2(), 98);
208 textGreen.setSize(boxYellow.getX() - boxGreen.getX2(), 30);
209 textGreen.setText(tr("Audio"));
213 textYellow.setBackgroundColour(osdBack);
214 textYellow.setPosition(boxYellow.getX2(), 98);
215 textYellow.setSize(boxBlue.getX() - boxYellow.getX2(), 30);
216 textYellow.setText(tr("Teletext"));
217 osd.add(&textYellow);
219 textBlue.setBackgroundColour(osdBack);
220 textBlue.setPosition(boxBlue.getX2(), 98);
221 textBlue.setSize(osd.getX2() - boxBlue.getX2(), 30);
222 textBlue.setText(tr("EPG"));
225 sl.setBackgroundColour(osdBack);
226 sl.setPosition(90, 36);
232 summary.setBackgroundColour(osdBack);
233 summary.setPosition(0, video->getScreenHeight() - 300);
234 summary.setSize(video->getScreenWidth(), 150);
235 summary.setVisible(false);
238 textSummary.setBackgroundColour(osdBack);
239 textSummary.setPosition(40, 10);
240 textSummary.setSize(video->getScreenWidth() - 80, 130);
241 textSummary.setParaMode(true);
242 summary.add(&textSummary);
244 summaryBlackLine.setBackgroundColour(DrawStyle::BLACK);
245 summaryBlackLine.setPosition(0, summary.getHeight() - 4);
246 summaryBlackLine.setSize(summary.getWidth(), 4);
247 summary.add(&summaryBlackLine);
249 sAspectRatio.setPosition(osd.getWidth() - 90, 40);
250 sAspectRatio.nextColour = DrawStyle::SELECTHIGHLIGHT;
251 sAspectRatio.setVisible(false);
252 osd.add(&sAspectRatio);
254 bufferBar.setPosition(osd.getWidth() - 90, 70);
255 bufferBar.setSize(40, 20);
256 bufferBar.setVisible(true);
259 sAudioChannels.setPosition(osd.getWidth() - 130, 40);
260 sAudioChannels.nextColour = DrawStyle::SELECTHIGHLIGHT;
261 sAudioChannels.setVisible(false);
262 osd.add(&sAudioChannels);
264 textUnavailable.setBackgroundColour(osdBack);
265 textUnavailable.setPosition(60, 30);
266 textUnavailable.setSize(osd.getWidth() - 120, 30);
267 textUnavailable.setText(tr("Channel Unavailable"));
268 textUnavailable.setVisible(false);
269 add(&textUnavailable);
272 Region r1 = summary.getRegionR();
273 Region r2 = osd.getRegionR();
274 osdSummaryRegion = r1 + r2;
277 void VVideoLiveTV::preDelete()
282 VVideoLiveTV::~VVideoLiveTV()
285 video->setDefaultAspect();
289 void VVideoLiveTV::delData()
293 int eventListSize = eventList->size();
294 for(int i = 0; i < eventListSize; i++)
296 delete (*eventList)[i];
305 int VVideoLiveTV::handleCommand(int command)
311 if (osd.getVisible() && !textUnavailable.getVisible())
316 // else drop through to stop
321 vchannelList->highlightChannel((*chanList)[currentChannelIndex]);
325 // NEW REMOTE ONLY - navigate EPG, bring it onscreen if it's not there
328 if (Remote::getInstance()->mayHaveFewButtons()) {
329 if (okTriggeredOSD) doUpDown(false);
330 else doChanUpDown(UP);
338 if (Remote::getInstance()->mayHaveFewButtons()) {
339 if (okTriggeredOSD) doUpDown(true);
340 else doChanUpDown(DOWN);
356 // Continue new remote only...
357 case Remote::CHANNELUP:
362 case Remote::CHANNELDOWN:
368 // END NEW REMOTE ONLY, START OLD REMOTE ONLY
370 // DF_LEFT and DF_RIGHT never get here because they are stolen
371 // by command as vol- and vol+
373 // Old remote. Decide what to do based on whether
374 // OK was pressed - osd shown manually, use up/down for epg nav
375 // UP/DOWN was pressed to change channel, osd was shown auto, use up/down for ch+/ch-
379 // Old remote, decide what to do based on okTriggeredOSD
380 if (okTriggeredOSD) doUpDown(false);
381 else doChanUpDown(UP);
384 case Remote::DF_DOWN:
386 // Old remote, decide what to do based on okTriggeredOSD
387 if (okTriggeredOSD) doUpDown(true);
388 else doChanUpDown(DOWN);
392 // END NEW/OLD REMOTE STUFF
394 case Remote::PREVCHANNEL:
396 channelChange(PREVIOUS, 0);
397 osdChannelIndex = currentChannelIndex;
430 // key in channel number
437 if (streamType == VDR::VIDEO) doAudioSelector();
442 if (streamType ==VDR::VIDEO)
444 doTeletext(); //TODO: Add a selector for subtitles or teletext
455 if (streamType == VDR::VIDEO)
456 (static_cast<PlayerLiveTV*>(player))->toggleSubtitles();
463 void VVideoLiveTV::go()
467 boxstack->update(this);
472 player->go(currentChannelIndex);
475 void VVideoLiveTV::stop()
477 Timers::getInstance()->cancelTimer(this, 1);
478 Timers::getInstance()->cancelTimer(this, 2);
483 void VVideoLiveTV::doLeftRight(bool right)
485 if (osd.getVisible())
487 if (right) osdChannelIndex = upChannel(osdChannelIndex);
488 else osdChannelIndex = downChannel(osdChannelIndex);
492 osdChannelIndex = currentChannelIndex;
497 void VVideoLiveTV::doUpDown(bool down)
499 if (osd.getVisible())
513 void VVideoLiveTV::doChanUpDown(int which)
515 channelChange(OFFSET, which);
516 osdChannelIndex = currentChannelIndex;
520 void VVideoLiveTV::doOK()
522 if (osd.getVisible())
527 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
529 channelChange(NUMBER, newChannel);
530 osdChannelIndex = currentChannelIndex;
533 else if (osdChannelIndex == currentChannelIndex)
539 channelChange(INDEX, osdChannelIndex);
545 osdChannelIndex = currentChannelIndex;
547 okTriggeredOSD = true;
551 void VVideoLiveTV::doSummary()
554 Channel* currentChannel = (*chanList)[osdChannelIndex];
555 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
560 sort(eventList->begin(), eventList->end(), EventSorter());
562 if (eventList->size() < 1) return;
563 Event* event = (*eventList)[0];
564 event->loadinfos(currentChannel->number);
566 VEpgSummary* vr = new VEpgSummary(event,currentChannel);
569 boxstack->update(vr);
571 if (summary.getVisible())
573 summary.setVisible(false);
575 boxstack->update(this, summary.getRegion());
576 Timers::getInstance()->setTimerD(this, 1, 8); // Restart a timer to get rid of osd
580 summary.setVisible(true);
582 if (osd.getVisible())
584 Timers::getInstance()->cancelTimer(this, 1);
593 void VVideoLiveTV::doKey(int command)
595 if (!osd.getVisible()) // First key. prep the data
598 updatePosterBanner();
603 for (i = keying - 1; i >= 0; i--) keyingInput[i+1] = keyingInput[i];
604 keyingInput[0] = command;
607 char* keyingString = new char[numberWidth + 1];
608 for (i = 0; i < numberWidth; i++) keyingString[i] = '_';
609 keyingString[numberWidth] = '\0';
611 for (i = 0; i < keying; i++) keyingString[i] = keyingInput[keying - 1 - i] + 48;
613 if (keying == numberWidth)
616 for(i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
618 channelChange(NUMBER, newChannel);
619 osdChannelIndex = currentChannelIndex;
620 Timers::getInstance()->cancelTimer(this, 1); // cancel the timer to react to keying input,
621 displayOSD(true); // this will put one back if required
625 osdChanNum.setText(keyingString);
627 if (!osd.getVisible())
629 osd.setVisible(true);
636 boxstack->update(this, osd.getRegion());
637 Timers::getInstance()->setTimerD(this, 1, 3); // 3s for keying input
639 delete[] keyingString;
642 void VVideoLiveTV::doTeletext(bool subtitlemode)
644 if (streamType !=VDR::VIDEO) return;
645 (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(true);
652 // and reset the display - this is a copy from setNowNextData
653 char formatChanNum[20];
654 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
655 osdChanNum.setText(formatChanNum);
656 osdChanName.setText((*chanList)[osdChannelIndex]->name);
658 (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(true);
659 if (osd.getVisible()) clearScreen();
661 VTeletextView *vtxv=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
663 vtxv= new VTeletextView(((PlayerLiveTV*)player)->getTeletextDecoder(),this, (PlayerLiveTV*)player);
664 ((PlayerLiveTV*)player)->getTeletextDecoder()->registerTeletextView(vtxv);
667 vtxv->setSubtitleMode(subtitlemode);
672 BoxStack::getInstance()->add(vtxv);
674 BoxStack::getInstance()->update(this);
675 BoxStack::getInstance()->update(vtxv);
678 void VVideoLiveTV::doAudioSelector()
680 // If the osd is already visisble there might be a timer for it
681 Timers::getInstance()->cancelTimer(this, 1);
682 //This causes a deadlock with the timertrhread itself is locked
689 // and reset the display - this is a copy from setNowNextData
690 char formatChanNum[20];
691 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
692 osdChanNum.setText(formatChanNum);
693 osdChanName.setText((*chanList)[osdChannelIndex]->name);
695 int subtitleChannel=((PlayerLiveTV*)player)->getCurrentSubtitleChannel();
696 int subtitleType=0x10;
697 if (!(static_cast<PlayerLiveTV*>(player))->isSubtitlesOn()) {
698 if (((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView() &&
699 ((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView()->isInSubtitleMode()
701 subtitleChannel=((PlayerLiveTV*)player)->getTeletextDecoder()->getPage();
705 subtitleType=0xFF; //turnedOff
711 vas = new VAudioSelector(this, (*chanList)[currentChannelIndex], ((PlayerLiveTV*)player)->getCurrentAudioChannel(),
712 subtitleType,subtitleChannel,NULL);
714 vas->setBackgroundColour(osdBack);
715 vas->setPosition(0, osd.getScreenY() - vas->getHeight());
718 // make vas != null and displayOSD will not set a timer or do any boxstack update
719 summary.setVisible(false);
720 if (osd.getVisible()) displayOSD(false);
721 else displayOSD(true);
724 BoxStack::getInstance()->add(vas);
725 BoxStack::getInstance()->update(this);
726 BoxStack::getInstance()->update(vas);
729 void VVideoLiveTV::doEPG()
731 if (osd.getVisible()) clearScreen();
733 if (!Command::getInstance()->advMenues()) {
734 video->setMode(Video::QUARTER);
735 video->setPosition(170, 5); //TODO need to deal with 4:3 switching
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.addOption(tr("No channel data available"), 0, 1);
769 sort(eventList->begin(), eventList->end(), EventSorter());
771 char tempString[300];
772 char tempString2[300];
775 int eventListSize = eventList->size();
776 for(int i = 0; i < eventListSize; i++)
778 event = (*eventList)[i];
780 //btime = localtime((time_t*)&event->time);
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);
790 sl.addOption(tempString, (ULONG)event, (i==0));
795 void VVideoLiveTV::setSummaryData()
797 // If osd is not being displayed, sl will be filled with now, current channel
798 // If the display was already on, sl will have programme to show summary for, not necessarily current channel and now
799 Event* selectedEvent = (Event*)sl.getCurrentOptionData();
803 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "No summary");
804 textSummary.setText(tr("No summary available"));
808 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Summary: %s", selectedEvent->description);
809 textSummary.setText(selectedEvent->description);
813 void VVideoLiveTV::displayOSD(bool newNowNextData)
815 (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(true);
816 osd.setVisible(true);
820 updatePosterBanner();
824 if (osdposterbanner.getVisible()) osdposterbanner.draw();
828 if (summary.getVisible())
832 toupdate=osdSummaryRegion;
836 toupdate=*osd.getRegion();
839 if (osdposterbanner.getVisible()) {
840 boxstack->update(this);
842 boxstack->update(this, &toupdate);
845 bool setTimer = true;
846 if (vas) setTimer = false;
847 if (summary.getVisible()) setTimer = false;
848 if (textUnavailable.getVisible()) setTimer = false;
850 if (setTimer) Timers::getInstance()->setTimerD(this, 1, 4);
853 void VVideoLiveTV::clearScreen()
855 if (!summary.getVisible()) Timers::getInstance()->cancelTimer(this, 1);
857 textUnavailable.setVisible(false);
858 osd.setVisible(false);
859 summary.setVisible(false);
860 osdposterbanner.setVisible(false);
862 okTriggeredOSD = false;
865 boxstack->update(this);
867 (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(false);
870 void VVideoLiveTV::showUnavailable()
872 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Show unavailable called");
873 textUnavailable.setVisible(true);
874 textUnavailable.draw();
876 if (!osd.getVisible()) displayOSD(true);
878 boxstack->update(this, textUnavailable.getRegion());
881 void VVideoLiveTV::setClock()
886 struct tm* tms = localtime(&t);
887 strftime(timeString, 19, "%H:%M", tms);
888 clock.setText(timeString);
890 time_t dt = 60 - (t % 60); // seconds to the next minute
891 if (dt == 0) dt = 60; // advance a whole minute if necessary
892 dt += t; // get a time_t value for it rather than using duration
893 // (so it will occur at the actual second and not second and a half)
895 Timers::getInstance()->setTimerT(this, 2, dt);
898 void VVideoLiveTV::timercall(int ref)
904 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key start.");
906 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
908 Message* m = new Message();
909 m->message = Message::CHANNEL_CHANGE;
911 m->parameter = newChannel;
912 m->tag = 1; // signal to call displayOSD();
913 Command::getInstance()->postMessageFromOuterSpace(m);
914 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key end.");
918 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 not key start.");
919 // We have received a timer, we are not keying. If still prebuffering, don't remove the bar
920 if (preBuffering < 100)
922 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Still prebuffering, not removing osd...");
923 Timers::getInstance()->setTimerD(this, 1, 2); // reset timer for another 2s
926 bool osdpbvisible=osdposterbanner.getVisible();
927 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 1.");
928 osd.setVisible(false);
929 osdposterbanner.setVisible(false);
930 okTriggeredOSD = false;
931 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 2.");
933 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 4.");
934 if (osdpbvisible) boxstack->update(this);
935 else boxstack->update(this, osd.getRegion());
937 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 3.");
938 (static_cast<PlayerLiveTV*>(player))->tellSubtitlesOSDVisible(false);
939 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey end.");
944 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 start.");
946 if (osd.getVisible())
949 boxstack->update(this, osd.getRegion());
951 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 end.");
955 bool VVideoLiveTV::channelChange(UCHAR changeType, UINT newData)
958 if (streamType ==VDR::VIDEO) {
959 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
961 BoxStack::getInstance()->remove(vtxt);
965 if (changeType == INDEX)
967 newChannel = newData;
969 else if (changeType == NUMBER)
972 for(i = 0; i < chanList->size(); i++)
974 if ((*chanList)[i]->number == (UINT)newData)
981 if (i == chanList->size())
987 else if (changeType == OFFSET)
989 if (newData == UP) newChannel = upChannel(currentChannelIndex);
990 else newChannel = downChannel(currentChannelIndex);
992 else if (changeType == PREVIOUS)
994 newChannel = previousChannelIndex;
998 return false; // bad input
1001 if (newChannel == currentChannelIndex) return true;
1003 previousChannelIndex = currentChannelIndex;
1004 currentChannelIndex = newChannel;
1008 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Set player to channel %u", currentChannelIndex);
1009 player->setChannel(currentChannelIndex);
1010 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Done Set player to channel %u", currentChannelIndex);
1012 // Blank out the symbols
1013 sAspectRatio.setVisible(false);
1014 bufferBar.setPercent(0);
1015 sAudioChannels.setVisible(false);
1017 // Remove other stuff
1018 if (textUnavailable.getVisible())
1020 textUnavailable.setVisible(false);
1023 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1026 Channel* currentChannel = (*chanList)[currentChannelIndex];
1027 if (currentChannel) {
1028 info.setChannelLogo(currentChannel->number);
1029 if (streamType == VDR::RADIO) {
1030 radioChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1031 radioChannelLogo.setVisible(true);
1033 osdChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1039 BoxStack::getInstance()->update(this);
1044 void VVideoLiveTV::processMessage(Message* m)
1046 if (m->message == Message::MOUSE_LBDOWN)
1048 //check if press is outside this view! then simulate cancel
1049 int x=(m->parameter>>16)-osd.getScreenX();
1050 int y=(m->parameter&0xFFFF)-osd.getScreenY();
1051 if (osd.getVisible()) {
1053 if ((boxRed.getX()<=x) && (boxRed.getX()+(int)boxRed.getWidth()>=x ) &&
1054 (boxRed.getY()<=y) && (boxRed.getY()+(int)boxRed.getHeight()>=y )) {
1055 BoxStack::getInstance()->handleCommand(Remote::RED);
1056 } else if ((boxGreen.getX()<=x) && (boxGreen.getX()+(int)boxGreen.getWidth()>=x ) &&
1057 (boxGreen.getY()<=y) && (boxGreen.getY()+(int)boxGreen.getHeight()>=y)){
1058 BoxStack::getInstance()->handleCommand(Remote::GREEN);
1059 } else if ((boxYellow.getX()<=x) && (boxYellow.getX()+(int)boxYellow.getWidth()>=x ) &&
1060 (boxYellow.getY()<=y) && (boxYellow.getY()+(int)boxYellow.getHeight()>=y )){
1061 BoxStack::getInstance()->handleCommand(Remote::YELLOW);
1062 } else if ((boxBlue.getX()<=x) && (boxBlue.getX()+(int)boxBlue.getWidth()>=x ) &&
1063 (boxBlue.getY()<=y) && (boxBlue.getY()+(int)boxBlue.getHeight()>=y )){
1064 BoxStack::getInstance()->handleCommand(Remote::BLUE);
1066 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
1070 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
1073 else if (m->message == Message::CHANNEL_CHANGE)
1075 channelChange(NUMBER, m->parameter);
1076 osdChannelIndex = currentChannelIndex;
1077 if (m->tag == 1) displayOSD(true);
1079 else if (m->message == Message::EPG_CLOSE)
1081 video->setMode(videoMode);
1083 else if (m->message == Message::CHILD_CLOSE)
1091 else if (m->message == Message::AUDIO_CHANGE_CHANNEL)
1093 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change audio channel to %x", m->parameter);
1094 player->setAudioChannel((m->parameter & 0xFFFF),(m->parameter & 0xFF0000)>>16,(m->parameter & 0xFF000000)>>24);
1096 else if (m->message == Message::SUBTITLE_CHANGE_CHANNEL)
1098 if (streamType !=VDR::VIDEO) return;
1099 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change subtitle channel to %x", m->parameter);
1100 int type=((m->parameter & 0xFF0000)>>16);
1102 case 0x10: { //dvbsubtitle
1103 if (streamType == VDR::VIDEO){
1104 player->setSubtitleChannel((m->parameter & 0xFFFF));
1105 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(true);
1106 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
1107 if (vtxt && vtxt->isInSubtitleMode()) {
1108 BoxStack::getInstance()->remove(vtxt);
1112 case 0xFF: { //nosubtitles
1113 if (streamType == VDR::VIDEO){
1114 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(false);
1115 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
1116 if (vtxt && vtxt->isInSubtitleMode()) {
1117 BoxStack::getInstance()->remove(vtxt);
1121 case 0x11: { //videotext
1122 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(false);
1124 ((PlayerLiveTV*)player)->getTeletextDecoder()->setPage((m->parameter & 0xFFFF));
1128 BoxStack::getInstance()->update(vas);
1129 //BoxStack::getInstance()->update(&osd); //eveil error
1131 BoxStack::getInstance()->update(this, osd.getRegion());
1135 else if (m->message == Message::PLAYER_EVENT)
1137 switch(m->parameter)
1139 case PlayerLiveTV::CONNECTION_LOST: // connection lost detected
1141 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received connection lost from player");
1142 Command::getInstance()->connectionLost();
1146 case PlayerLiveTV::STREAM_END:
1148 // Message comes from playerlivetv through master mutex, so can do anything here
1153 case PlayerLiveTV::ASPECT43:
1156 if ((video->getTVsize() == Video::ASPECT16X9) && dowss)
1158 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43");
1161 BoxStack::getInstance()->update(this, &wssRegion);
1165 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT43;
1166 sAspectRatio.setVisible(true);
1168 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1171 BoxStack::getInstance()->update(this, osd.getRegion());
1176 case PlayerLiveTV::ASPECT169:
1179 if ((video->getTVsize() == Video::ASPECT16X9) && dowss)
1181 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169");
1184 BoxStack::getInstance()->update(this, &wssRegion);
1188 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT169;
1189 sAspectRatio.setVisible(true);
1191 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1194 BoxStack::getInstance()->update(this, osd.getRegion());
1199 case PlayerLiveTV::PREBUFFERING:
1201 preBuffering = m->tag;
1202 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Prebuffering - %u", preBuffering);
1203 bufferBar.setPercent(preBuffering);
1205 if (osd.getVisible())
1207 bufferBar.setVisible(true);
1210 bufferBar.getRootBoxRegion(&r); ///////// FIXME !!!
1211 BoxStack::getInstance()->update(this, &r);
1213 if (preBuffering == 100)
1215 doAudioChannelSymbol();
1223 void VVideoLiveTV::doAudioChannelSymbol()
1226 Channel* currentChannel = (*chanList)[osdChannelIndex];
1228 bool multiAudio = false;
1229 if (Audio::getInstance()->supportsAc3()) {
1230 if ((currentChannel->numDPids+currentChannel->numAPids) > 1) multiAudio = true;
1232 if (currentChannel->numAPids > 1) multiAudio = true;
1236 if (multiAudio) sAudioChannels.nextSymbol = WSymbol::MULTIAUDIO;
1237 else sAudioChannels.nextSymbol = WSymbol::SINGLEAUDIO;
1238 sAudioChannels.setVisible(true);
1240 if (osd.getVisible())
1242 sAudioChannels.draw();
1244 sAudioChannels.getRootBoxRegion(&r); ///////// FIXME !!!
1248 BoxStack::getInstance()->update(this, &r);
1252 UINT VVideoLiveTV::upChannel(UINT index)
1254 if (index == (chanList->size() - 1)) // at the end
1255 return 0; // so go to start
1260 UINT VVideoLiveTV::downChannel(UINT index)
1262 if (index == 0) // at the start
1263 return chanList->size() - 1; // so go to end
1268 void VVideoLiveTV::toggleChopSides()
1270 if (video->getTVsize() == Video::ASPECT16X9) return; // Means nothing for 16:9 TVs
1272 if (videoMode == Video::NORMAL)
1274 videoMode = Video::LETTERBOX;
1275 video->setMode(Video::LETTERBOX);
1279 videoMode = Video::NORMAL;
1280 video->setMode(Video::NORMAL);
1284 void VVideoLiveTV::updatePosterBanner()
1286 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1288 osdposterbanner.setVisible(false);
1291 Event* toShow = NULL;
1292 if (eventList && eventList->size()) {
1293 toShow = (*eventList)[0];
1294 Channel* currentChannel = (*chanList)[osdChannelIndex];
1295 toShow->loadinfos(currentChannel->number);
1302 bool posterscale=true;
1303 if (toShow->movieInfo) {
1304 poster=toShow->movieInfo->poster;
1306 if (toShow->seriesInfo) {
1307 if (toShow->seriesInfo->banners.size()) {
1308 poster=toShow->seriesInfo->banners[0];
1310 } else if (toShow->seriesInfo->seasonposter.height) {
1311 poster=toShow->seriesInfo->seasonposter;
1312 } else if (toShow->seriesInfo->posters.size()) {
1313 poster=toShow->seriesInfo->posters[0];
1316 if (poster.height) {
1317 osdposterbanner.setTVMedia(poster.info, posterscale ? WTVMedia::ZoomVertical : WTVMedia::ZoomHorizontal);
1318 osdposterbanner.setVisible(true);
1320 osdposterbanner.setVisible(false);
1323 osdposterbanner.setVisible(false);
1329 void VVideoLiveTV::drawOSDBitmap(UINT posX, UINT posY, const Bitmap& bm, const DisplayRegion& region)
1331 drawBitmap(posX, posY, bm,region);
1333 r.x = posX; r.y = posY; r.w = bm.getWidth(); r.h = bm.getHeight();
1334 boxstack->update(this, &r);
1337 void VVideoLiveTV::clearOSD()
1339 rectangle(area, DrawStyle(0,0,0,0));
1340 boxstack->update(this, &area);
1343 void VVideoLiveTV::clearOSDArea(UINT posX, UINT posY, UINT width, UINT height, const DisplayRegion& region)
1346 r.x = posX+region.windowx; r.y = posY+region.windowy; r.w = width; r.h = height;
1347 //now convert to our display
1348 float scalex=720.f/((float) (region.framewidth+1));
1349 float scaley=576.f/((float) (region.frameheight+1));
1350 r.x=floor(scalex*((float)r.x));
1351 r.y=floor(scaley*((float)r.y));
1352 r.w=ceil(scalex*((float)r.w))+1.f;
1353 r.h=ceil(scaley*((float)r.h))+1.f;
1354 rectangle(r, DrawStyle(0,0,0,0));
1355 boxstack->update(this, &r);