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"
25 #include "playerlive.h"
26 #include "playerlivetv.h"
27 #include "playerliveradio.h"
36 #include "vaudioselector.h"
43 #include "vteletextview.h"
45 VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, VChannelList* tvchannelList)
47 vdr = VDR::getInstance();
48 boxstack = BoxStack::getInstance();
49 video = Video::getInstance();
54 vchannelList = tvchannelList;
55 numberWidth = (int)VDR::getInstance()->getChannelNumberWidth();
57 currentChannelIndex = 0;
58 previousChannelIndex = 0;
65 // Convert channel number to index
67 for(i = 0; i < chanList->size(); i++)
69 if ((*chanList)[i]->number == (UINT)initialChannelNumber)
71 currentChannelIndex = i;
79 videoMode = video->getMode();
81 if ((*chanList)[currentChannelIndex]->type == VDR::VIDEO)
83 streamType = VDR::VIDEO;
84 player = new PlayerLiveTV(Command::getInstance(), this, this, chanList);
88 streamType = VDR::RADIO;
89 player = new PlayerLiveRadio(Command::getInstance(), this, chanList);
93 setSize(video->getScreenWidth(), video->getScreenHeight());
95 Colour transparent(0, 0, 0, 0);
96 setBackgroundColour(transparent);
99 char* optionWSS = vdr->configLoad("General", "WSS");
102 if (strstr(optionWSS, "Yes")) dowss = true;
105 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Do WSS: %u", dowss);
109 wss.setFormat(video->getFormat());
115 wssRegion.w = video->getScreenWidth();
119 // This variable is set to true if the user pressed OK to bring the OSD on screen
120 // This is only used on old remotes to stop up/down buttons being used for osd-epg scrolling
121 okTriggeredOSD = false;
123 Colour osdBack = Colour(0, 0, 0, 128);
125 osd.setBackgroundColour(osdBack);
126 osd.setPosition(0, video->getScreenHeight() - 150);
127 osd.setSize(video->getScreenWidth(), 150);
128 osd.setVisible(false);
131 clock.setBackgroundColour(osdBack);
132 clock.setPosition(osd.getWidth() - 100, 4);
133 clock.setSize(90, 30);
136 osdChanNum.setBackgroundColour(osdBack);
137 osdChanNum.setPosition(50, 4);
138 osdChanNum.setSize((numberWidth*10) + 22, 30); // 10 px = width of number chars in font
139 osd.add(&osdChanNum);
141 osdChanName.setBackgroundColour(osdBack);
142 osdChanName.setPosition(osdChanNum.getX2() + 10, 4);
143 osdChanName.setSize(300, 30);
144 osd.add(&osdChanName);
146 boxRed.setBackgroundColour(Colour::RED);
147 boxRed.setPosition(54, 104);
148 boxRed.setSize(18, 16);
151 boxGreen.setBackgroundColour(Colour::GREEN);
152 boxGreen.setPosition(220, 104);
153 boxGreen.setSize(18, 16);
156 boxYellow.setBackgroundColour(Colour::YELLOW);
157 boxYellow.setPosition(390, 104);
158 boxYellow.setSize(18, 16);
161 boxBlue.setBackgroundColour(Colour::BLUE);
162 boxBlue.setPosition(560, 104);
163 boxBlue.setSize(18, 16);
166 textRed.setBackgroundColour(osdBack);
167 textRed.setPosition(boxRed.getX2(), 98);
168 textRed.setSize(boxGreen.getX() - boxRed.getX2(), 30);
169 textRed.setText(tr("Summary"));
172 if (streamType == VDR::VIDEO)
174 textGreen.setBackgroundColour(osdBack);
175 textGreen.setPosition(boxGreen.getX2(), 98);
176 textGreen.setSize(boxYellow.getX() - boxGreen.getX2(), 30);
177 textGreen.setText(tr("Audio"));
181 textYellow.setBackgroundColour(osdBack);
182 textYellow.setPosition(boxYellow.getX2(), 98);
183 textYellow.setSize(boxBlue.getX() - boxYellow.getX2(), 30);
184 textYellow.setText("Teletext");
185 osd.add(&textYellow);
187 textBlue.setBackgroundColour(osdBack);
188 textBlue.setPosition(boxBlue.getX2(), 98);
189 textBlue.setSize(osd.getX2() - boxBlue.getX2(), 30);
190 textBlue.setText(tr("EPG"));
193 sl.setBackgroundColour(osdBack);
194 sl.setPosition(70, 36);
200 summary.setBackgroundColour(osdBack);
201 summary.setPosition(0, video->getScreenHeight() - 300);
202 summary.setSize(video->getScreenWidth(), 150);
203 summary.setVisible(false);
206 textSummary.setBackgroundColour(osdBack);
207 textSummary.setPosition(40, 10);
208 textSummary.setSize(video->getScreenWidth() - 80, 130);
209 textSummary.setParaMode(true);
210 summary.add(&textSummary);
212 summaryBlackLine.setBackgroundColour(Colour::BLACK);
213 summaryBlackLine.setPosition(0, summary.getHeight() - 4);
214 summaryBlackLine.setSize(summary.getWidth(), 4);
215 summary.add(&summaryBlackLine);
217 sAspectRatio.setPosition(osd.getWidth() - 90, 40);
218 sAspectRatio.nextColour = Colour::SELECTHIGHLIGHT;
219 sAspectRatio.setVisible(false);
220 osd.add(&sAspectRatio);
222 bufferBar.setPosition(osd.getWidth() - 90, 70);
223 bufferBar.setSize(40, 20);
224 bufferBar.setVisible(true);
227 sAudioChannels.setPosition(osd.getWidth() - 130, 40);
228 sAudioChannels.nextColour = Colour::SELECTHIGHLIGHT;
229 sAudioChannels.setVisible(false);
230 osd.add(&sAudioChannels);
232 textUnavailable.setBackgroundColour(osdBack);
233 textUnavailable.setPosition(60, 30);
234 textUnavailable.setSize(osd.getWidth() - 120, 30);
235 textUnavailable.setText(tr("Channel Unavailable"));
236 textUnavailable.setVisible(false);
237 add(&textUnavailable);
240 Region r1 = summary.getRegionR();
241 Region r2 = osd.getRegionR();
242 osdSummaryRegion = r1 + r2;
245 void VVideoLiveTV::preDelete()
250 VVideoLiveTV::~VVideoLiveTV()
253 video->setDefaultAspect();
257 void VVideoLiveTV::delData()
261 int eventListSize = eventList->size();
262 for(int i = 0; i < eventListSize; i++)
264 delete (*eventList)[i];
273 int VVideoLiveTV::handleCommand(int command)
279 if (osd.getVisible() && !textUnavailable.getVisible())
284 // else drop through to stop
289 vchannelList->highlightChannel((*chanList)[currentChannelIndex]);
293 // NEW REMOTE ONLY - navigate EPG, bring it onscreen if it's not there
314 // Continue new remote only...
315 case Remote::CHANNELUP:
320 case Remote::CHANNELDOWN:
326 // END NEW REMOTE ONLY, START OLD REMOTE ONLY
328 // DF_LEFT and DF_RIGHT never get here because they are stolen
329 // by command as vol- and vol+
331 // Old remote. Decide what to do based on whether
332 // OK was pressed - osd shown manually, use up/down for epg nav
333 // UP/DOWN was pressed to change channel, osd was shown auto, use up/down for ch+/ch-
337 // Old remote, decide what to do based on okTriggeredOSD
338 if (okTriggeredOSD) doUpDown(false);
339 else doChanUpDown(UP);
342 case Remote::DF_DOWN:
344 // Old remote, decide what to do based on okTriggeredOSD
345 if (okTriggeredOSD) doUpDown(true);
346 else doChanUpDown(DOWN);
350 // END NEW/OLD REMOTE STUFF
352 case Remote::PREVCHANNEL:
354 channelChange(PREVIOUS, 0);
355 osdChannelIndex = currentChannelIndex;
388 // key in channel number
395 if (streamType == VDR::VIDEO) doAudioSelector();
400 doTeletext(); //TODO: Add a selector for subtitles or teletext
410 if (streamType = VDR::VIDEO)
411 (static_cast<PlayerLiveTV*>(player))->toggleSubtitles();
418 void VVideoLiveTV::go()
422 boxstack->update(this);
427 player->go(currentChannelIndex);
430 void VVideoLiveTV::stop()
432 Timers::getInstance()->cancelTimer(this, 1);
433 Timers::getInstance()->cancelTimer(this, 2);
438 void VVideoLiveTV::doLeftRight(bool right)
440 if (osd.getVisible())
442 if (right) osdChannelIndex = upChannel(osdChannelIndex);
443 else osdChannelIndex = downChannel(osdChannelIndex);
447 osdChannelIndex = currentChannelIndex;
452 void VVideoLiveTV::doUpDown(bool down)
454 if (osd.getVisible())
468 void VVideoLiveTV::doChanUpDown(int which)
470 channelChange(OFFSET, which);
471 osdChannelIndex = currentChannelIndex;
475 void VVideoLiveTV::doOK()
477 if (osd.getVisible())
482 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
484 channelChange(NUMBER, newChannel);
485 osdChannelIndex = currentChannelIndex;
488 else if (osdChannelIndex == currentChannelIndex)
494 channelChange(INDEX, osdChannelIndex);
500 osdChannelIndex = currentChannelIndex;
502 okTriggeredOSD = true;
506 void VVideoLiveTV::doSummary()
508 if (summary.getVisible())
510 summary.setVisible(false);
512 boxstack->update(this, summary.getRegion());
513 Timers::getInstance()->setTimerD(this, 1, 8); // Restart a timer to get rid of osd
517 summary.setVisible(true);
519 if (osd.getVisible())
521 Timers::getInstance()->cancelTimer(this, 1);
530 void VVideoLiveTV::doKey(int command)
532 if (!osd.getVisible()) // First key. prep the data
539 for (i = keying - 1; i >= 0; i--) keyingInput[i+1] = keyingInput[i];
540 keyingInput[0] = command;
543 char* keyingString = new char[numberWidth + 1];
544 for (i = 0; i < numberWidth; i++) keyingString[i] = '_';
545 keyingString[numberWidth] = '\0';
547 for (i = 0; i < keying; i++) keyingString[i] = keyingInput[keying - 1 - i] + 48;
549 if (keying == numberWidth)
552 for(i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
554 channelChange(NUMBER, newChannel);
555 osdChannelIndex = currentChannelIndex;
556 Timers::getInstance()->cancelTimer(this, 1); // cancel the timer to react to keying input,
557 displayOSD(true); // this will put one back if required
561 osdChanNum.setText(keyingString);
563 if (!osd.getVisible())
565 osd.setVisible(true);
572 boxstack->update(this, osd.getRegion());
573 Timers::getInstance()->setTimerD(this, 1, 3); // 3s for keying input
575 delete[] keyingString;
578 void VVideoLiveTV::doTeletext(bool subtitlemode)
586 // and reset the display - this is a copy from setNowNextData
587 char formatChanNum[20];
588 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
589 osdChanNum.setText(formatChanNum);
590 osdChanName.setText((*chanList)[osdChannelIndex]->name);
592 if (osd.getVisible()) clearScreen();
594 VTeletextView *vtxv=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
596 vtxv= new VTeletextView(((PlayerLiveTV*)player)->getTeletextDecoder(),this);
597 ((PlayerLiveTV*)player)->getTeletextDecoder()->registerTeletextView(vtxv);
600 vtxv->setSubtitleMode(subtitlemode);
605 BoxStack::getInstance()->add(vtxv);
607 BoxStack::getInstance()->update(this);
608 BoxStack::getInstance()->update(vtxv);
611 void VVideoLiveTV::doAudioSelector()
613 // If the osd is already visisble there might be a timer for it
614 Timers::getInstance()->cancelTimer(this, 1);
615 //This causes a deadlock with the timertrhread itself is locked
622 // and reset the display - this is a copy from setNowNextData
623 char formatChanNum[20];
624 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number);
625 osdChanNum.setText(formatChanNum);
626 osdChanName.setText((*chanList)[osdChannelIndex]->name);
628 int subtitleChannel=((PlayerLiveTV*)player)->getCurrentSubtitleChannel();
629 int subtitleType=0x10;
630 if (!(static_cast<PlayerLiveTV*>(player))->isSubtitlesOn()) {
631 if (((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView() &&
632 ((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView()->isInSubtitleMode()
634 subtitleChannel=((PlayerLiveTV*)player)->getTeletextDecoder()->getPage();
638 subtitleType=0xFF; //turnedOff
644 vas = new VAudioSelector(this, (*chanList)[currentChannelIndex], ((PlayerLiveTV*)player)->getCurrentAudioChannel(),
645 subtitleType,subtitleChannel,player->getTeletxtSubtitlePages());
646 Colour osdBack = Colour(0, 0, 0, 128);
647 vas->setBackgroundColour(osdBack);
648 vas->setPosition(0, osd.getScreenY() - vas->getHeight());
651 // make vas != null and displayOSD will not set a timer or do any boxstack update
652 summary.setVisible(false);
653 if (osd.getVisible()) displayOSD(false);
654 else displayOSD(true);
657 BoxStack::getInstance()->add(vas);
658 BoxStack::getInstance()->update(this);
659 BoxStack::getInstance()->update(vas);
662 void VVideoLiveTV::doEPG()
664 if (osd.getVisible()) clearScreen();
666 video->setMode(Video::QUARTER);
667 video->setPosition(170, 5); //TODO need to deal with 4:3 switching
669 VEpg* vepg = new VEpg(this, currentChannelIndex, streamType);
672 boxstack->update(vepg);
675 void VVideoLiveTV::setNowNextData()
679 Channel* currentChannel = (*chanList)[osdChannelIndex];
681 char formatChanNum[20];
682 SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, currentChannel->number);
683 osdChanNum.setText(formatChanNum);
684 osdChanName.setText(currentChannel->name);
686 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
690 sl.addOption(tr("No channel data available"), 0, 1);
694 sort(eventList->begin(), eventList->end(), EventSorter());
696 char tempString[300];
697 char tempString2[300];
700 int eventListSize = eventList->size();
701 for(int i = 0; i < eventListSize; i++)
703 event = (*eventList)[i];
705 //btime = localtime((time_t*)&event->time);
706 time_t etime = event->time;
707 btime = localtime(&etime);
709 strftime(tempString2, 299, "%0H:%0M ", btime);
711 strftime(tempString2, 299, "%H:%M ", btime);
713 SNPRINTF(tempString, 299, "%s %s", tempString2, event->title);
715 sl.addOption(tempString, (ULONG)event, (i==0));
720 void VVideoLiveTV::setSummaryData()
722 // If osd is not being displayed, sl will be filled with now, current channel
723 // If the display was already on, sl will have programme to show summary for, not necessarily current channel and now
724 Event* selectedEvent = (Event*)sl.getCurrentOptionData();
728 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "No summary");
729 textSummary.setText(tr("No summary available"));
733 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Summary: %s", selectedEvent->description);
734 textSummary.setText(selectedEvent->description);
738 void VVideoLiveTV::displayOSD(bool newNowNextData)
740 osd.setVisible(true);
748 if (summary.getVisible())
752 boxstack->update(this, &osdSummaryRegion);
756 boxstack->update(this, osd.getRegion());
759 bool setTimer = true;
760 if (vas) setTimer = false;
761 if (summary.getVisible()) setTimer = false;
762 if (textUnavailable.getVisible()) setTimer = false;
764 if (setTimer) Timers::getInstance()->setTimerD(this, 1, 4);
767 void VVideoLiveTV::clearScreen()
769 if (!summary.getVisible()) Timers::getInstance()->cancelTimer(this, 1);
771 textUnavailable.setVisible(false);
772 osd.setVisible(false);
773 summary.setVisible(false);
775 okTriggeredOSD = false;
778 boxstack->update(this);
781 void VVideoLiveTV::showUnavailable()
783 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Show unavailable called");
784 textUnavailable.setVisible(true);
785 textUnavailable.draw();
787 if (!osd.getVisible()) displayOSD(true);
789 boxstack->update(this, textUnavailable.getRegion());
792 void VVideoLiveTV::setClock()
797 struct tm* tms = localtime(&t);
798 strftime(timeString, 19, "%H:%M", tms);
799 clock.setText(timeString);
801 time_t dt = 60 - (t % 60); // seconds to the next minute
802 if (dt == 0) dt = 60; // advance a whole minute if necessary
803 dt += t; // get a time_t value for it rather than using duration
804 // (so it will occur at the actual second and not second and a half)
806 Timers::getInstance()->setTimerT(this, 2, dt);
809 void VVideoLiveTV::timercall(int ref)
815 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key start.");
817 for(int i = keying - 1; i >= 0; i--) newChannel += keyingInput[i] * (ULONG)pow(10., i);
819 Message* m = new Message();
820 m->message = Message::CHANNEL_CHANGE;
822 m->parameter = newChannel;
823 m->tag = 1; // signal to call displayOSD();
824 Command::getInstance()->postMessageFromOuterSpace(m);
825 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key end.");
829 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 not key start.");
830 // We have received a timer, we are not keying. If still prebuffering, don't remove the bar
831 if (preBuffering < 100)
833 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Still prebuffering, not removing osd...");
834 Timers::getInstance()->setTimerD(this, 1, 2); // reset timer for another 2s
837 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 1.");
838 osd.setVisible(false);
839 okTriggeredOSD = false;
840 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 2.");
842 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 4.");
843 boxstack->update(this, osd.getRegion());
845 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 3.");
846 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey end.");
851 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 start.");
853 if (osd.getVisible())
856 boxstack->update(this, osd.getRegion());
858 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 2 end.");
862 bool VVideoLiveTV::channelChange(UCHAR changeType, UINT newData)
865 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
867 BoxStack::getInstance()->remove(vtxt);
871 if (changeType == INDEX)
873 newChannel = newData;
875 else if (changeType == NUMBER)
878 for(i = 0; i < chanList->size(); i++)
880 if ((*chanList)[i]->number == (UINT)newData)
887 if (i == chanList->size())
893 else if (changeType == OFFSET)
895 if (newData == UP) newChannel = upChannel(currentChannelIndex);
896 else newChannel = downChannel(currentChannelIndex);
898 else if (changeType == PREVIOUS)
900 newChannel = previousChannelIndex;
904 return false; // bad input
907 if (newChannel == currentChannelIndex) return true;
909 previousChannelIndex = currentChannelIndex;
910 currentChannelIndex = newChannel;
914 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Set player to channel %u", currentChannelIndex);
915 player->setChannel(currentChannelIndex);
916 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Done Set player to channel %u", currentChannelIndex);
918 // Blank out the symbols
919 sAspectRatio.setVisible(false);
920 bufferBar.setPercent(0);
921 sAudioChannels.setVisible(false);
923 // Remove other stuff
924 if (textUnavailable.getVisible())
926 textUnavailable.setVisible(false);
931 BoxStack::getInstance()->update(this);
936 void VVideoLiveTV::processMessage(Message* m)
938 if (m->message == Message::MOUSE_LBDOWN)
940 //check if press is outside this view! then simulate cancel
941 int x=(m->parameter>>16)-osd.getScreenX();
942 int y=(m->parameter&0xFFFF)-osd.getScreenY();
943 if (osd.getVisible()) {
945 if ((boxRed.getX()<=x) && (boxRed.getX()+(int)boxRed.getWidth()>=x ) &&
946 (boxRed.getY()<=y) && (boxRed.getY()+(int)boxRed.getHeight()>=y )) {
947 BoxStack::getInstance()->handleCommand(Remote::RED);
948 } else if ((boxGreen.getX()<=x) && (boxGreen.getX()+(int)boxGreen.getWidth()>=x ) &&
949 (boxGreen.getY()<=y) && (boxGreen.getY()+(int)boxGreen.getHeight()>=y)){
950 BoxStack::getInstance()->handleCommand(Remote::GREEN);
951 } else if ((boxYellow.getX()<=x) && (boxYellow.getX()+(int)boxYellow.getWidth()>=x ) &&
952 (boxYellow.getY()<=y) && (boxYellow.getY()+(int)boxYellow.getHeight()>=y )){
953 BoxStack::getInstance()->handleCommand(Remote::YELLOW);
954 } else if ((boxBlue.getX()<=x) && (boxBlue.getX()+(int)boxBlue.getWidth()>=x ) &&
955 (boxBlue.getY()<=y) && (boxBlue.getY()+(int)boxBlue.getHeight()>=y )){
956 BoxStack::getInstance()->handleCommand(Remote::BLUE);
958 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
962 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
965 else if (m->message == Message::CHANNEL_CHANGE)
967 channelChange(NUMBER, m->parameter);
968 osdChannelIndex = currentChannelIndex;
969 if (m->tag == 1) displayOSD(true);
971 else if (m->message == Message::EPG_CLOSE)
973 video->setMode(videoMode);
975 else if (m->message == Message::CHILD_CLOSE)
983 else if (m->message == Message::AUDIO_CHANGE_CHANNEL)
985 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change audio channel to %i", m->parameter);
986 player->setAudioChannel((m->parameter & 0xFFFF),(m->parameter & 0xFF0000)>>16);
988 else if (m->message == Message::SUBTITLE_CHANGE_CHANNEL)
990 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change subtitle channel to %i", m->parameter);
991 int type=((m->parameter & 0xFF0000)>>16);
993 case 0x10: { //dvbsubtitle
994 if (streamType = VDR::VIDEO){
995 player->setSubtitleChannel((m->parameter & 0xFFFF));
996 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(true);
997 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
998 if (vtxt && vtxt->isInSubtitleMode()) {
999 BoxStack::getInstance()->remove(vtxt);
1003 case 0xFF: { //nosubtitles
1004 if (streamType = VDR::VIDEO){
1005 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(false);
1006 VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
1007 if (vtxt && vtxt->isInSubtitleMode()) {
1008 BoxStack::getInstance()->remove(vtxt);
1012 case 0x11: { //videotext
1013 (static_cast<PlayerLiveTV*>(player))->turnSubtitlesOn(false);
1015 ((PlayerLiveTV*)player)->getTeletextDecoder()->setPage((m->parameter & 0xFFFF));
1019 BoxStack::getInstance()->update(vas);
1020 //BoxStack::getInstance()->update(&osd); //eveil error
1022 BoxStack::getInstance()->update(this, osd.getRegion());
1026 else if (m->message == Message::PLAYER_EVENT)
1028 switch(m->parameter)
1030 case PlayerLiveTV::CONNECTION_LOST: // connection lost detected
1032 Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received connection lost from player");
1033 Command::getInstance()->connectionLost();
1037 case PlayerLiveTV::STREAM_END:
1039 // Message comes from playerlivetv through master mutex, so can do anything here
1044 case PlayerLiveTV::ASPECT43:
1046 if ((video->getTVsize() == Video::ASPECT16X9) && dowss)
1048 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43");
1051 BoxStack::getInstance()->update(this, &wssRegion);
1054 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT43;
1055 sAspectRatio.setVisible(true);
1057 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1060 BoxStack::getInstance()->update(this, osd.getRegion());
1065 case PlayerLiveTV::ASPECT169:
1067 if ((video->getTVsize() == Video::ASPECT16X9) && dowss)
1069 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169");
1072 BoxStack::getInstance()->update(this, &wssRegion);
1075 sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT169;
1076 sAspectRatio.setVisible(true);
1078 if (osd.getVisible()) // don't wake up the whole osd just for a aspect change
1081 BoxStack::getInstance()->update(this, osd.getRegion());
1086 case PlayerLiveTV::PREBUFFERING:
1088 preBuffering = m->tag;
1089 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Prebuffering - %u", preBuffering);
1090 bufferBar.setPercent(preBuffering);
1092 if (osd.getVisible())
1094 bufferBar.setVisible(true);
1097 bufferBar.getRootBoxRegion(&r); ///////// FIXME !!!
1098 BoxStack::getInstance()->update(this, &r);
1100 if (preBuffering == 100)
1102 doAudioChannelSymbol();
1110 void VVideoLiveTV::doAudioChannelSymbol()
1113 Channel* currentChannel = (*chanList)[osdChannelIndex];
1115 bool multiAudio = false;
1117 if (currentChannel->numDPids > 1) multiAudio = true;
1119 if (currentChannel->numAPids > 1) multiAudio = true;
1123 if (multiAudio) sAudioChannels.nextSymbol = WSymbol::MULTIAUDIO;
1124 else sAudioChannels.nextSymbol = WSymbol::SINGLEAUDIO;
1125 sAudioChannels.setVisible(true);
1127 if (osd.getVisible())
1129 sAudioChannels.draw();
1131 sAudioChannels.getRootBoxRegion(&r); ///////// FIXME !!!
1135 BoxStack::getInstance()->update(this, &r);
1139 UINT VVideoLiveTV::upChannel(UINT index)
1141 if (index == (chanList->size() - 1)) // at the end
1142 return 0; // so go to start
1147 UINT VVideoLiveTV::downChannel(UINT index)
1149 if (index == 0) // at the start
1150 return chanList->size() - 1; // so go to end
1155 void VVideoLiveTV::toggleChopSides()
1157 if (video->getTVsize() == Video::ASPECT16X9) return; // Means nothing for 16:9 TVs
1159 if (videoMode == Video::NORMAL)
1161 videoMode = Video::LETTERBOX;
1162 video->setMode(Video::LETTERBOX);
1166 videoMode = Video::NORMAL;
1167 video->setMode(Video::NORMAL);
1171 void VVideoLiveTV::drawOSDBitmap(UINT posX, UINT posY, const Bitmap& bm)
1173 drawBitmap(posX, posY, bm);
1175 r.x = posX; r.y = posY; r.w = bm.getWidth(); r.h = bm.getHeight();
1176 boxstack->update(this, &r);
1179 void VVideoLiveTV::clearOSD()
1181 rectangle(area, Colour(0,0,0,0));
1182 boxstack->update(this, &area);
1185 void VVideoLiveTV::clearOSDArea(UINT posX, UINT posY, UINT width, UINT height)
1188 r.x = posX; r.y = posY; r.w = width; r.h = height;
1189 rectangle(r, Colour(0,0,0,0));
1190 boxstack->update(this, &r);