2 Copyright 2007-2008 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
22 #include "vchannellist.h"
25 #include "playerlive.h"
26 #include "playervideolive.h"
27 #include "playerradiolive.h"
37 #include "vaudioselector.h"
43 #include "vteletextview.h"
44 #include "vepgsummary.h"
45 #include "vepglistadvanced.h"
46 #include "staticartwork.h"
48 #include "messagequeue.h"
50 #include "vvideolivetv.h"
53 VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, VChannelList* tvchannelList)
55 vdr = VDR::getInstance();
56 boxstack = BoxStack::getInstance();
57 video = Video::getInstance();
62 vchannelList = tvchannelList;
63 numberWidth = VDR::getInstance()->getChannelNumberWidth();
65 currentChannelIndex = 0;
66 previousChannelIndex = 0;
73 // Convert channel number to index
74 for(UINT i = 0; i < chanList->size(); i++)
76 if ((*chanList)[i]->number == initialChannelNumber)
78 currentChannelIndex = i;
86 videoMode = video->getMode();
88 if ((*chanList)[currentChannelIndex]->type == VDR::VIDEO)
90 streamType = VDR::VIDEO;
91 player = new PlayerVideoLive(Control::getInstance(), this, this, chanList);
95 streamType = VDR::RADIO;
96 player = new PlayerRadioLive(Control::getInstance(), this, chanList);
100 setSize(video->getScreenWidth(), video->getScreenHeight());
102 DrawStyle transparent(0, 0, 0, 0);
103 setBackgroundColour(transparent);
105 OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
108 osdv->updateBackgroundColor(DrawStyle::BLACK);
111 // This variable is set to true if the user pressed OK to bring the OSD on screen
112 // This is only used on old remotes to stop up/down buttons being used for osd-epg scrolling
113 okTriggeredOSD = false;
116 info.setChannelLogo(initialChannelNumber);
118 if (osdv && streamType == VDR::RADIO) {
119 radioChannelLogo.setPosition(video->getScreenWidth()/4,video->getScreenHeight()/4);
120 radioChannelLogo.setSize(video->getScreenWidth()/2,video->getScreenHeight()/2);
121 radioChannelLogo.setVisible(true);
122 radioChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
123 add(&radioChannelLogo);
126 osdposterbanner.setPosition(20,20);
127 //osdposterbanner.setBackgroundColour(DrawStyle::OSDBACKGROUND);
128 osdposterbanner.setSize(video->getScreenWidth()*4/10,video->getScreenHeight()*4/10);
129 osdposterbanner.setVisible(false);
130 add(&osdposterbanner);
132 osd.setBackgroundColour(DrawStyle::OSDBACKGROUND);
133 osd.setPosition(0, video->getScreenHeight() - 150);
134 osd.setSize(video->getScreenWidth(), 150);
135 osd.setVisible(false);
138 int channellogomove=0;
142 //osdChannelLogo.setBackgroundColour(DrawStyle::OSDBACKGROUND);
143 osdChannelLogo.setPosition(30,5);
144 osdChannelLogo.setSize(60,60);
145 osdChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
146 osd.add(&osdChannelLogo);
147 channellogomove = 30-5;
151 //clock.setBackgroundColour(DrawStyle::OSDBACKGROUND);
152 clock.setPosition(osd.getWidth() - 100, 4);
153 clock.setSize(90, 30);
156 //osdChanNum.setBackgroundColour(DrawStyle::OSDBACKGROUND);
157 osdChanNum.setPosition(60 + channellogomove, 4);
158 osdChanNum.setSize((numberWidth * 10) + 22, getFontHeight() + 5); // 10 px = width of number chars in font
159 osd.add(&osdChanNum);
161 //osdChanName.setBackgroundColour(DrawStyle::OSDBACKGROUND);
162 osdChanName.setPosition(osdChanNum.getX2() + 10, 4);
163 osdChanName.setSize(300, 30);
164 osd.add(&osdChanName);
166 boxRed.setBackgroundColour(DrawStyle::RED);
167 boxRed.setPosition(54+0*boxdiff, 104);
168 boxRed.setSize(18, 16);
171 boxGreen.setBackgroundColour(DrawStyle::GREEN);
172 boxGreen.setPosition(54+1*boxdiff, 104);
173 boxGreen.setSize(18, 16);
176 boxYellow.setBackgroundColour(DrawStyle::YELLOW);
177 boxYellow.setPosition(54+2*boxdiff, 104);
178 boxYellow.setSize(18, 16);
181 boxBlue.setBackgroundColour(DrawStyle::BLUE);
182 boxBlue.setPosition(54+3*boxdiff, 104);
183 boxBlue.setSize(18, 16);
186 //textRed.setBackgroundColour(DrawStyle::OSDBACKGROUND);
187 textRed.setPosition(boxRed.getX2(), 98);
188 textRed.setSize(boxGreen.getX() - boxRed.getX2(), 30);
189 textRed.setText(tr("Summary"));
192 if (streamType == VDR::VIDEO)
194 //textGreen.setBackgroundColour(DrawStyle::OSDBACKGROUND);
195 textGreen.setPosition(boxGreen.getX2(), 98);
196 textGreen.setSize(boxYellow.getX() - boxGreen.getX2(), 30);
197 textGreen.setText(tr("Audio"));
201 //textYellow.setBackgroundColour(DrawStyle::OSDBACKGROUND);
202 textYellow.setPosition(boxYellow.getX2(), 98);
203 textYellow.setSize(boxBlue.getX() - boxYellow.getX2(), 30);
204 textYellow.setText(tr("Teletext"));
205 osd.add(&textYellow);
207 //textBlue.setBackgroundColour(DrawStyle::OSDBACKGROUND);
208 textBlue.setPosition(boxBlue.getX2(), 98);
209 textBlue.setSize(osd.getX2() - boxBlue.getX2(), 30);
210 textBlue.setText(tr("EPG"));
213 //sl.setBackgroundColour(DrawStyle::OSDBACKGROUND);
214 sl.setPosition(90, 36);
218 bufferBar.setPosition(osd.getWidth() - 90, 70);
219 bufferBar.setSize(40, 20);
220 bufferBar.setVisible(true);
225 sAspectRatio.setPosition(osd.getWidth() - 90, 40);
226 sAspectRatio.nextColour = DrawStyle::LIVETVSYMBOLS;
227 sAspectRatio.setVisible(false);
228 osd.add(&sAspectRatio);
230 sAudioChannels.setPosition(osd.getWidth() - 130, 40);
231 sAudioChannels.nextColour = DrawStyle::LIVETVSYMBOLS;
232 sAudioChannels.setVisible(false);
233 osd.add(&sAudioChannels);
239 ninfo.setStaticArtwork(sa_txtoff);
240 txtlogo.setPosition(54+4*boxdiff,104);
241 txtlogo.setSize(22,20);
242 txtlogo.setTVMedia(ninfo, WTVMedia::ZoomVertical);
245 ninfo.setStaticArtwork(sa_dolbyoff);
246 dolbylogo.setPosition(54+4*boxdiff+15,104);
247 dolbylogo.setSize(22,20);
248 dolbylogo.setTVMedia(ninfo, WTVMedia::ZoomVertical);
251 ninfo.setStaticArtwork(sa_sd576i);
252 reslogo.setPosition(54+4*boxdiff+30,104);
253 reslogo.setSize(22,20);
254 reslogo.setTVMedia(ninfo, WTVMedia::ZoomVertical);
257 reslogo.setVisible(false);
258 dolbylogo.setVisible(false);
259 txtlogo.setVisible(false);
262 //textUnavailable.setBackgroundColour(DrawStyle::OSDBACKGROUND);
263 textUnavailable.setPosition(60, 30);
264 textUnavailable.setSize(osd.getWidth() - 120, 30);
265 textUnavailable.setText(tr("Channel Unavailable"));
266 textUnavailable.setVisible(false);
267 add(&textUnavailable);
269 vdisplay.mode = Fullscreen;
270 vdisplay.fallbackMode = Fullscreen;
277 void VVideoLiveTV::preDelete()
282 VVideoLiveTV::~VVideoLiveTV()
285 video->setDefaultAspect();
287 OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
290 osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
294 void VVideoLiveTV::delData()
298 int eventListSize = eventList->size();
299 for(int i = 0; i < eventListSize; i++)
301 delete (*eventList)[i];
308 int VVideoLiveTV::handleCommand(int command)
314 if (osd.getVisible() && !textUnavailable.getVisible())
319 // else drop through to stop
325 vchannelList->highlightChannel((*chanList)[currentChannelIndex]);
329 // navigate EPG, bring it onscreen if it's not there
332 if (InputMan::getInstance()->mayHaveFewButtons())
334 if (okTriggeredOSD) doUpDown(false);
335 else doChanUpDown(UP);
345 if (InputMan::getInstance()->mayHaveFewButtons())
347 if (okTriggeredOSD) doUpDown(true);
348 else doChanUpDown(DOWN);
366 case Input::CHANNELUP:
371 case Input::CHANNELDOWN:
376 case Input::PREVCHANNEL:
378 channelChange(PREVIOUS, 0);
379 osdChannelIndex = currentChannelIndex;
412 // key in channel number
419 if (streamType == VDR::VIDEO) doAudioSelector();
424 if (streamType ==VDR::VIDEO)
426 doTeletext(); //TODO: Add a selector for subtitles or teletext
437 if (streamType == VDR::VIDEO)
438 (static_cast<PlayerVideoLive*>(player))->toggleSubtitles();
445 void VVideoLiveTV::go()
449 boxstack->update(this);
454 player->go(currentChannelIndex);
457 void VVideoLiveTV::stop()
459 Timers::getInstance()->cancelTimer(this, 1);
460 Timers::getInstance()->cancelTimer(this, 2);
465 void VVideoLiveTV::doLeftRight(bool right)
467 if (osd.getVisible())
469 if (right) osdChannelIndex = upChannel(osdChannelIndex);
470 else osdChannelIndex = downChannel(osdChannelIndex);
474 osdChannelIndex = currentChannelIndex;
479 void VVideoLiveTV::doUpDown(bool /* down */)
481 if (osd.getVisible())
493 void VVideoLiveTV::doChanUpDown(int which)
495 channelChange(OFFSET, which);
496 osdChannelIndex = currentChannelIndex;
500 void VVideoLiveTV::doOK()
502 if (osd.getVisible())
507 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * static_cast<int>(pow(10.f, i));
509 channelChange(NUMBER, newChannel);
510 osdChannelIndex = currentChannelIndex;
513 else if (osdChannelIndex == currentChannelIndex)
519 channelChange(INDEX, osdChannelIndex);
525 osdChannelIndex = currentChannelIndex;
527 okTriggeredOSD = true;
531 void VVideoLiveTV::doSummary()
534 Channel* currentChannel = (*chanList)[osdChannelIndex];
535 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
540 sort(eventList->begin(), eventList->end(), EventSorter());
542 if (eventList->size() < 1) return;
543 Event* event = (*eventList)[0];
544 event->loadinfos(currentChannel->number);
546 VEpgSummary* vr = new VEpgSummary(event,currentChannel);
549 boxstack->update(vr);
552 void VVideoLiveTV::doKey(int command)
554 if (!osd.getVisible()) // First key. prep the data
557 updatePosterBanner();
562 for (i = keying - 1; i >= 0; i--) keyingInput[i+1] = keyingInput[i];
563 keyingInput[0] = command;
566 char* keyingString = new char[numberWidth + 1];
567 for (i = 0; i < numberWidth; i++) keyingString[i] = '_';
568 keyingString[numberWidth] = '\0';
570 for (i = 0; i < keying; i++) keyingString[i] = static_cast<char>(keyingInput[keying - 1 - i] + 48);
572 if (keying == numberWidth)
575 for(i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * static_cast<int>(pow(10.f, i));
577 channelChange(NUMBER, newChannel);
578 osdChannelIndex = currentChannelIndex;
579 Timers::getInstance()->cancelTimer(this, 1); // cancel the timer to react to keying input,
580 displayOSD(true); // this will put one back if required
584 osdChanNum.setText(keyingString);
586 if (!osd.getVisible())
588 osd.setVisible(true);
595 boxstack->update(this, osd.getRegion());
596 Timers::getInstance()->setTimerD(this, 1, 3); // 3s for keying input
598 delete[] keyingString;
601 void VVideoLiveTV::doTeletext(bool subtitlemode)
603 if (streamType != VDR::VIDEO) return;
605 PlayerVideoLive* playervl = static_cast<PlayerVideoLive*>(player);
607 playervl->tellSubtitlesOSDVisible(true);
614 // and reset the display - this is a copy from setNowNextData
615 char formatChanNum[20];
616 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
617 osdChanNum.setText(formatChanNum);
618 osdChanName.setText((*chanList)[osdChannelIndex]->name);
620 playervl->tellSubtitlesOSDVisible(true);
621 if (osd.getVisible()) clearScreen();
623 VTeletextView* vtxv = playervl->getTeletextDecoder()->getTeletxtView();
626 vtxv = new VTeletextView(playervl->getTeletextDecoder(), this, playervl);
627 playervl->getTeletextDecoder()->registerTeletextView(vtxv);
631 vtxv->setSubtitleMode(subtitlemode);
637 BoxStack::getInstance()->add(vtxv);
640 BoxStack::getInstance()->update(this);
641 BoxStack::getInstance()->update(vtxv);
644 void VVideoLiveTV::doAudioSelector()
646 // Only called if streamtype == VDR::VIDEO
647 PlayerVideoLive* playervl = static_cast<PlayerVideoLive*>(player);
649 // If the osd is already visisble there might be a timer for it
650 Timers::getInstance()->cancelTimer(this, 1);
651 //This causes a deadlock with the timertrhread itself is locked
657 // and reset the display - this is a copy from setNowNextData
658 char formatChanNum[20];
659 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
660 osdChanNum.setText(formatChanNum);
661 osdChanName.setText((*chanList)[osdChannelIndex]->name);
663 int subtitleChannel = playervl->getCurrentSubtitleChannel();
664 int subtitleType = 0x10;
665 if (!playervl->isSubtitlesOn())
667 if (playervl->getTeletextDecoder()->getTeletxtView() &&
668 playervl->getTeletextDecoder()->getTeletxtView()->isInSubtitleMode())
670 subtitleChannel = playervl->getTeletextDecoder()->getPage();
675 subtitleType = 0xFF; //turnedOff
681 vas = new VAudioSelector(this, (*chanList)[currentChannelIndex], playervl->getCurrentAudioChannel(),
682 subtitleType,subtitleChannel,NULL);
684 vas->setBackgroundColour(DrawStyle::OSDBACKGROUND);
685 vas->setPosition(0, osd.getScreenY() - vas->getHeight());
688 // make vas != null and displayOSD will not set a timer or do any boxstack update
689 if (osd.getVisible()) displayOSD(false);
690 else displayOSD(true);
693 BoxStack::getInstance()->add(vas);
694 BoxStack::getInstance()->update(this);
695 BoxStack::getInstance()->update(vas);
698 void VVideoLiveTV::doEPG()
700 if (osd.getVisible()) clearScreen();
702 if (!Control::getInstance()->isAdvMenus())
704 VEpg* vepg = new VEpg(this, currentChannelIndex, chanList);
707 boxstack->update(vepg);
711 Channel* currentChannel = (*chanList)[osdChannelIndex];
712 VEpgListAdvanced *vepg= new VEpgListAdvanced(this, chanList, currentChannel->number);
715 boxstack->update(vepg);
719 void VVideoLiveTV::setNowNextData()
723 Channel* currentChannel = (*chanList)[osdChannelIndex];
725 char formatChanNum[20];
726 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, currentChannel->number);
727 osdChanNum.setText(formatChanNum);
728 osdChanName.setText(currentChannel->name);
730 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
734 sl.setText(tr("No channel data available"));
738 sort(eventList->begin(), eventList->end(), EventSorter());
740 char tempString[300];
743 int eventListSize = eventList->size();
744 std::stringstream ss;
745 for(int i = 0; i < eventListSize; i++)
747 event = (*eventList)[i];
749 time_t etime = event->time;
750 LOCALTIME_R(&etime, &btime);
751 // FIXME convert following to std::strftime
753 strftime(tempString, 299, "%0H:%0M ", &btime);
755 strftime(tempString, 299, "%H:%M ", &btime);
757 ss << tempString << " " << event->title << "\n";
759 sl.setText(ss.str().c_str());
765 void VVideoLiveTV::displayOSD(bool newNowNextData)
767 PlayerVideoLive* playerlivetv = dynamic_cast<PlayerVideoLive*>(player);
768 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(true);
769 osd.setVisible(true);
773 updatePosterBanner();
777 if (osdposterbanner.getVisible()) osdposterbanner.draw();
782 toupdate=*osd.getRegion();
785 if (osdposterbanner.getVisible())
787 boxstack->update(this);
791 boxstack->update(this, &toupdate);
794 bool setTimer = true;
795 if (vas) setTimer = false;
796 if (textUnavailable.getVisible()) setTimer = false;
798 if (setTimer) Timers::getInstance()->setTimerD(this, 1, 4);
801 void VVideoLiveTV::clearScreen()
803 Timers::getInstance()->cancelTimer(this, 1);
805 textUnavailable.setVisible(false);
806 osd.setVisible(false);
807 osdposterbanner.setVisible(false);
809 okTriggeredOSD = false;
812 boxstack->update(this);
814 PlayerVideoLive* playerlivetv = dynamic_cast<PlayerVideoLive*>(player);
815 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false);
818 void VVideoLiveTV::showUnavailable()
820 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Show unavailable called");
821 textUnavailable.setVisible(true);
822 textUnavailable.draw();
824 if (!osd.getVisible()) displayOSD(true);
826 boxstack->update(this, textUnavailable.getRegion());
829 void VVideoLiveTV::setClock()
835 LOCALTIME_R(&t, &tms);
836 strftime(timeString, 19, "%H:%M", &tms);
837 clock.setText(timeString);
839 time_t dt = 60 - (t % 60); // seconds to the next minute
840 if (dt == 0) dt = 60; // advance a whole minute if necessary
841 dt += t; // get a time_t value for it rather than using duration
842 // (so it will occur at the actual second and not second and a half)
844 Timers::getInstance()->setTimerT(this, 2, dt);
847 void VVideoLiveTV::timercall(int ref)
853 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key start.");
855 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * static_cast<int>(pow(10.f, i));
857 Message* m = new Message();
858 m->message = Message::CHANNEL_CHANGE;
860 m->parameter = newChannel;
861 m->tag = 1; // signal to call displayOSD();
862 MessageQueue::getInstance()->postMessage(m);
863 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key end.");
867 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 not key start.");
868 // We have received a timer, we are not keying. If still prebuffering, don't remove the bar
869 if (preBuffering < 100)
871 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Still prebuffering, not removing osd...");
872 Timers::getInstance()->setTimerD(this, 1, 2); // reset timer for another 2s
875 bool osdpbvisible=osdposterbanner.getVisible();
876 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 1.");
877 osd.setVisible(false);
878 osdposterbanner.setVisible(false);
879 okTriggeredOSD = false;
880 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 2.");
882 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 4.");
883 if (osdpbvisible) boxstack->update(this);
884 else boxstack->update(this, osd.getRegion());
886 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 3.");
887 PlayerVideoLive* playerlivetv = dynamic_cast<PlayerVideoLive*>(player);
888 if (playerlivetv) playerlivetv->tellSubtitlesOSDVisible(false);
889 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey end.");
894 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 start.");
896 if (osd.getVisible())
899 boxstack->update(this, osd.getRegion());
901 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 end.");
905 bool VVideoLiveTV::channelChange(UCHAR changeType, UINT newData)
908 if (streamType == VDR::VIDEO)
910 VTeletextView* vtxt = static_cast<PlayerVideoLive*>(player)->getTeletextDecoder()->getTeletxtView();
913 BoxStack::getInstance()->remove(vtxt);
916 if (changeType == INDEX)
918 newChannel = newData;
920 else if (changeType == NUMBER)
923 for(i = 0; i < chanList->size(); i++)
925 if ((*chanList)[i]->number == newData)
932 if (i == chanList->size())
938 else if (changeType == OFFSET)
940 if (newData == UP) newChannel = upChannel(currentChannelIndex);
941 else newChannel = downChannel(currentChannelIndex);
943 else if (changeType == PREVIOUS)
945 newChannel = previousChannelIndex;
949 return false; // bad input
952 if (newChannel == currentChannelIndex) return true;
954 previousChannelIndex = currentChannelIndex;
955 currentChannelIndex = newChannel;
959 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Set player to channel %u", currentChannelIndex);
960 player->setChannel(currentChannelIndex);
961 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Done Set player to channel %u", currentChannelIndex);
963 // Blank out the symbols
964 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
966 bufferBar.setPercent(0);
970 sAudioChannels.setVisible(false);
971 sAspectRatio.setVisible(false);
975 reslogo.setVisible(false);
976 dolbylogo.setVisible(false);
977 txtlogo.setVisible(false);
980 // Remove other stuff
981 if (textUnavailable.getVisible())
983 textUnavailable.setVisible(false);
989 Channel* currentChannel = (*chanList)[currentChannelIndex];
992 info.setChannelLogo(currentChannel->number);
993 if (streamType == VDR::RADIO)
995 radioChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
996 radioChannelLogo.setVisible(true);
998 osdChannelLogo.setTVMedia(info, WTVMedia::ZoomVertical);
1003 BoxStack::getInstance()->update(this);
1008 void VVideoLiveTV::processMessage(Message* m)
1010 if (m->message == Message::MOUSE_LBDOWN)
1012 //check if press is outside this view! then simulate cancel
1013 int x = m->parameter - osd.getScreenX();
1014 int y = m->tag - osd.getScreenY();
1015 if (osd.getVisible())
1017 if ((boxRed.getX() <= x) && (boxRed.getX() + static_cast<int>(boxRed.getWidth()) >= x) &&
1018 (boxRed.getY() <= y) && (boxRed.getY() + static_cast<int>(boxRed.getHeight()) >= y))
1020 BoxStack::getInstance()->handleCommand(Input::RED);
1022 else if ((boxGreen.getX() <= x) && (boxGreen.getX() + static_cast<int>(boxGreen.getWidth()) >= x) &&
1023 (boxGreen.getY() <= y) && (boxGreen.getY() + static_cast<int>(boxGreen.getHeight()) >= y))
1025 BoxStack::getInstance()->handleCommand(Input::GREEN);
1027 else if ((boxYellow.getX() <= x) && (boxYellow.getX() + static_cast<int>(boxYellow.getWidth()) >= x) &&
1028 (boxYellow.getY() <= y) && (boxYellow.getY() + static_cast<int>(boxYellow.getHeight()) >= y))
1030 BoxStack::getInstance()->handleCommand(Input::YELLOW);
1032 else if ((boxBlue.getX() <= x) && (boxBlue.getX() + static_cast<int>(boxBlue.getWidth()) >= x) &&
1033 (boxBlue.getY() <= y) && (boxBlue.getY() + static_cast<int>(boxBlue.getHeight()) >= y))
1035 BoxStack::getInstance()->handleCommand(Input::BLUE);
1039 BoxStack::getInstance()->handleCommand(Input::OK); //simulate rok press
1044 BoxStack::getInstance()->handleCommand(Input::OK); //simulate rok press
1047 else if (m->message == Message::CHANNEL_CHANGE)
1049 channelChange(NUMBER, m->parameter);
1050 osdChannelIndex = currentChannelIndex;
1051 if (m->tag == 1) displayOSD(true);
1053 else if (m->message == Message::CHILD_CLOSE)
1061 else if (m->message == Message::AUDIO_CHANGE_CHANNEL)
1063 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change audio channel to %x", m->parameter);
1064 player->setAudioChannel((m->parameter & 0xFFFF), (m->parameter & 0xFF0000) >> 16, (m->parameter & 0xFF000000) >> 24);
1066 else if (m->message == Message::SUBTITLE_CHANGE_CHANNEL)
1068 if (streamType != VDR::VIDEO) return;
1070 PlayerVideoLive* playervl = static_cast<PlayerVideoLive*>(player);
1072 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change subtitle channel to %x", m->parameter);
1073 int type = (m->parameter & 0xFF0000) >> 16;
1079 playervl->setSubtitleChannel((m->parameter & 0xFFFF));
1080 playervl->turnSubtitlesOn(true);
1081 VTeletextView* vtxt = playervl->getTeletextDecoder()->getTeletxtView();
1082 if (vtxt && vtxt->isInSubtitleMode())
1084 BoxStack::getInstance()->remove(vtxt);
1091 playervl->turnSubtitlesOn(false);
1092 VTeletextView* vtxt = playervl->getTeletextDecoder()->getTeletxtView();
1093 if (vtxt && vtxt->isInSubtitleMode())
1095 BoxStack::getInstance()->remove(vtxt);
1102 playervl->turnSubtitlesOn(false);
1104 playervl->getTeletextDecoder()->setPage((m->parameter & 0xFFFF));
1111 BoxStack::getInstance()->update(vas);
1112 //BoxStack::getInstance()->update(&osd); //eveil error
1114 BoxStack::getInstance()->update(this, osd.getRegion());
1116 else if (m->message == Message::PLAYER_EVENT)
1118 switch (m->parameter)
1120 case PlayerVideoLive::CONNECTION_LOST: // connection lost detected
1122 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received connection lost from player");
1123 Control::getInstance()->connectionLost();
1127 case PlayerVideoLive::STREAM_END:
1129 // Message comes from playerlivetv through master mutex, so can do anything here
1134 case PlayerVideoLive::ASPECT43:
1136 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1139 osdv->updateBackgroundColor(DrawStyle::BLACK);
1142 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT43;
1143 sAspectRatio.setVisible(true);
1145 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1148 BoxStack::getInstance()->update(this, osd.getRegion());
1153 case PlayerVideoLive::ASPECT169:
1155 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT169;
1156 sAspectRatio.setVisible(true);
1158 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1161 osdv->updateBackgroundColor(DrawStyle::BLACK);
1165 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1168 BoxStack::getInstance()->update(this, osd.getRegion());
1173 case PlayerVideoLive::PREBUFFERING:
1175 preBuffering = m->tag;
1176 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Prebuffering - %u", preBuffering);
1177 bufferBar.setPercent(preBuffering);
1179 if (osd.getVisible())
1181 bufferBar.setVisible(true);
1184 bufferBar.getRootBoxRegion(&r); ///////// FIXME !!!
1185 BoxStack::getInstance()->update(this, &r);
1187 if (preBuffering == 100)
1189 doAudioChannelSymbol();
1197 void VVideoLiveTV::doAudioChannelSymbol()
1199 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1201 Channel* currentChannel = (*chanList)[osdChannelIndex];
1203 bool multiAudio = false;
1204 if (Audio::getInstance()->supportsAc3()) {
1205 if ((currentChannel->numDPids+currentChannel->numAPids) > 1) multiAudio = true;
1207 if (currentChannel->numAPids > 1) multiAudio = true;
1211 if (multiAudio) sAudioChannels.nextSymbol = WSymbol::MULTIAUDIO;
1212 else sAudioChannels.nextSymbol = WSymbol::SINGLEAUDIO;
1213 sAudioChannels.setVisible(true);
1217 dolbylogo.setVisible(true);
1218 txtlogo.setVisible(true);
1220 if (currentChannel->tpid!=0) info.setStaticArtwork(sa_txton);
1221 else info.setStaticArtwork(sa_txtoff);
1222 txtlogo.setTVMedia(info, WTVMedia::ZoomVertical);
1225 if (Audio::getInstance()->supportsAc3() && currentChannel->numDPids>1)
1226 info.setStaticArtwork(sa_dolbyon);
1227 else info.setStaticArtwork(sa_dolbyoff);
1228 dolbylogo.setTVMedia(info, WTVMedia::ZoomVertical);
1230 Demuxer* demux=Demuxer::getInstance();
1232 int vertical_size=demux->getVerticalSize();
1233 Log::getInstance()->log("VVideoRec", Log::DEBUG, "TVMedia vertical size %d", vertical_size);
1234 reslogo.setVisible(true);
1235 switch (vertical_size) {
1237 info.setStaticArtwork(sa_sd576i);
1238 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1240 info.setStaticArtwork(sa_hd720p);
1241 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1243 info.setStaticArtwork(sa_hd1080i);
1244 reslogo.setTVMedia(info, WTVMedia::ZoomVertical);break;
1245 default: // we assume sd
1246 reslogo.setVisible(false);
1250 reslogo.setVisible(false);
1256 if (osd.getVisible())
1258 sAudioChannels.draw();
1260 sAudioChannels.getRootBoxRegion(&r); ///////// FIXME !!!
1264 BoxStack::getInstance()->update(this, &r);
1268 UINT VVideoLiveTV::upChannel(UINT index)
1270 if (index == (chanList->size() - 1)) // at the end
1271 return 0; // so go to start
1276 UINT VVideoLiveTV::downChannel(UINT index)
1278 if (index == 0) // at the start
1279 return chanList->size() - 1; // so go to end
1284 void VVideoLiveTV::toggleChopSides()
1286 if (video->getTVsize() == Video::ASPECT16X9) return; // Means nothing for 16:9 TVs
1288 if (videoMode == Video::NORMAL)
1290 videoMode = Video::LETTERBOX;
1291 video->setMode(Video::LETTERBOX);
1295 videoMode = Video::NORMAL;
1296 video->setMode(Video::NORMAL);
1300 void VVideoLiveTV::updatePosterBanner()
1302 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
1304 osdposterbanner.setVisible(false);
1307 Event* toShow = NULL;
1308 if (eventList && eventList->size()) {
1309 toShow = (*eventList)[0];
1310 Channel* currentChannel = (*chanList)[osdChannelIndex];
1311 toShow->loadinfos(currentChannel->number);
1318 bool posterscale=true;
1319 if (toShow->movieInfo) {
1320 poster=toShow->movieInfo->poster;
1322 if (toShow->seriesInfo) {
1323 if (toShow->seriesInfo->banners.size()) {
1324 poster=toShow->seriesInfo->banners[0];
1326 } else if (toShow->seriesInfo->seasonposter.height) {
1327 poster=toShow->seriesInfo->seasonposter;
1328 } else if (toShow->seriesInfo->posters.size()) {
1329 poster=toShow->seriesInfo->posters[0];
1332 if (poster.height) {
1333 osdposterbanner.setTVMedia(poster.info, posterscale ? WTVMedia::ZoomVertical : WTVMedia::ZoomHorizontal);
1334 osdposterbanner.setVisible(true);
1336 osdposterbanner.setVisible(false);
1339 osdposterbanner.setVisible(false);
1345 void VVideoLiveTV::drawOSDBitmap(UINT posX, UINT posY, const Bitmap& bm, const DisplayRegion& region)
1347 drawBitmap(posX, posY, bm,region);
1349 r.x = posX; r.y = posY; r.w = bm.getWidth(); r.h = bm.getHeight();
1350 boxstack->update(this, &r);
1353 void VVideoLiveTV::clearOSD()
1355 rectangle(area, DrawStyle(0,0,0,0));
1356 boxstack->update(this, &area);
1359 void VVideoLiveTV::clearOSDArea(UINT posX, UINT posY, UINT width, UINT height, const DisplayRegion& region)
1362 r.x = posX+region.windowx; r.y = posY+region.windowy; r.w = width; r.h = height;
1363 //now convert to our display
1364 float scalex = 720.f / static_cast<float>(region.framewidth + 1);
1365 float scaley = 576.f / static_cast<float>(region.frameheight + 1);
1366 r.x = static_cast<UINT>(floor(scalex * static_cast<float>(r.x)));
1367 r.y = static_cast<UINT>(floor(scaley * static_cast<float>(r.y)));
1368 r.w = static_cast<UINT>(ceil(scalex * static_cast<float>(r.w)) + 1.f);
1369 r.h = static_cast<UINT>(ceil(scaley * static_cast<float>(r.h)) + 1.f);
1370 rectangle(r, DrawStyle(0,0,0,0));
1371 boxstack->update(this, &r);