From 799da4f762571d8eb0fd839ea0366a4df84e16bc Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 19 Apr 2008 14:30:40 +0000 Subject: [PATCH] Live tv audio selector --- vaudioselector.cc | 2 +- vvideolivetv.cc | 75 +++++++++++++++++++++++++++++++++++++---------- vvideolivetv.h | 5 ++++ 3 files changed, 65 insertions(+), 17 deletions(-) diff --git a/vaudioselector.cc b/vaudioselector.cc index d349820..2d89a34 100644 --- a/vaudioselector.cc +++ b/vaudioselector.cc @@ -307,7 +307,7 @@ int VAudioSelector::handleCommand(int command) } } - return 0; + return 1; } void VAudioSelector::processMessage(Message* m) diff --git a/vvideolivetv.cc b/vvideolivetv.cc index b25a543..0fbd44b 100644 --- a/vvideolivetv.cc +++ b/vvideolivetv.cc @@ -44,6 +44,8 @@ VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, V vdr = VDR::getInstance(); boxstack = BoxStack::getInstance(); video = Video::getInstance(); + + vas = NULL; chanList = tchanList; vchannelList = tvchannelList; @@ -74,10 +76,12 @@ VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, V if ((*chanList)[currentChannelIndex]->type == VDR::VIDEO) { + streamType = VDR::VIDEO; player = new PlayerLiveTV(Command::getInstance(), this, chanList); } else { + streamType = VDR::RADIO; player = new PlayerLiveRadio(Command::getInstance(), this, chanList); } player->init(); @@ -157,11 +161,14 @@ VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, V textRed.setText("Summary"); osd.add(&textRed); - textGreen.setBackgroundColour(osdBack); - textGreen.setPosition(boxGreen.getX()+18, 98); - textGreen.setSize(120, 30); - textGreen.setText("Audio"); - osd.add(&textGreen); + if (streamType == VDR::VIDEO) + { + textGreen.setBackgroundColour(osdBack); + textGreen.setPosition(boxGreen.getX()+18, 98); + textGreen.setSize(120, 30); + textGreen.setText("Audio"); + osd.add(&textGreen); + } textYellow.setBackgroundColour(osdBack); textYellow.setPosition(boxYellow.getX()+18, 98); @@ -189,8 +196,8 @@ VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, V add(&summary); textSummary.setBackgroundColour(osdBack); - textSummary.setPosition(30, 10); - textSummary.setSize(video->getScreenWidth() - 60, 130); + textSummary.setPosition(40, 10); + textSummary.setSize(video->getScreenWidth() - 80, 130); textSummary.setParaMode(true); summary.add(&textSummary); @@ -330,14 +337,8 @@ int VVideoLiveTV::handleCommand(int command) case Remote::GREEN: { - /* - VAudioSelector* vas = new VAudioSelector(this, (*chanList)[currentChannelIndex], ((Player*)player)->getCurrentAudioChannel()); - vas->setBackgroundColour(Colour::VIEWBACKGROUND); - vas->setPosition(0, getHeight()-200); - vas->draw(); - BoxStack::getInstance()->add(vas); - BoxStack::getInstance()->update(vas); - */ + if (streamType == VDR::VIDEO) doAudioSelector(); + return 2; } case Remote::YELLOW: { @@ -513,6 +514,40 @@ void VVideoLiveTV::doKey(int command) delete[] keyingString; } +void VVideoLiveTV::doAudioSelector() +{ + // If the osd is already visisble there might be a timer for it + Timers::getInstance()->cancelTimer(this, 1); + + // Cancel keying + if (keying) + { + keying = 0; + // and reset the display - this is a copy from setNowNextData + char formatChanNum[20]; + SNPRINTF(formatChanNum, 19, "%0*lu", numberWidth, (*chanList)[osdChannelIndex]->number); + osdChanNum.setText(formatChanNum); + osdChanName.setText((*chanList)[osdChannelIndex]->name); + } + + // Draw the selector + vas = new VAudioSelector(this, (*chanList)[currentChannelIndex], ((PlayerLiveTV*)player)->getCurrentAudioChannel()); + Colour osdBack = Colour(0, 0, 0, 128); + vas->setBackgroundColour(osdBack); + vas->setPosition(0, osd.getScreenY() - vas->getHeight()); + vas->draw(); + + // make vas != null and displayOSD will not set a timer or do any boxstack update + summary.setVisible(false); + if (osd.getVisible()) displayOSD(false); + else displayOSD(true); + draw(); + + BoxStack::getInstance()->add(vas); + BoxStack::getInstance()->update(this); + BoxStack::getInstance()->update(vas); +} + void VVideoLiveTV::doEPG() { if (osd.getVisible()) clearScreen(); @@ -605,7 +640,7 @@ void VVideoLiveTV::displayOSD(bool newNowNextData) summary.draw(); boxstack->update(this, &osdSummaryRegion); } - else + else if (!vas) { boxstack->update(this, osd.getRegion()); Timers::getInstance()->setTimerD(this, 1, 4); @@ -762,6 +797,14 @@ void VVideoLiveTV::processMessage(Message* m) { video->setMode(videoMode); } + else if (m->message == Message::CHILD_CLOSE) + { + if (m->from == vas) + { + vas = NULL; + displayOSD(false); + } + } else if (m->message == Message::AUDIO_CHANGE_CHANNEL) { Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change audio channel to %i", m->parameter); diff --git a/vvideolivetv.h b/vvideolivetv.h index d5e2047..c1c2aab 100644 --- a/vvideolivetv.h +++ b/vvideolivetv.h @@ -39,6 +39,7 @@ class VChannelList; class BoxStack; class WTextbox; class PlayerLive; +class VAudioSelector; class VVideoLiveTV : public Boxx, public TimerReceiver { @@ -75,6 +76,7 @@ class VVideoLiveTV : public Boxx, public TimerReceiver EventList* eventList; int numberWidth; int videoMode; + ULONG streamType; UINT currentChannelIndex; UINT previousChannelIndex; @@ -89,6 +91,7 @@ class VVideoLiveTV : public Boxx, public TimerReceiver void doKey(int command); void doEPG(); void doSummary(); + void doAudioSelector(); void stop(); UINT upChannel(UINT index); UINT downChannel(UINT index); @@ -101,6 +104,8 @@ class VVideoLiveTV : public Boxx, public TimerReceiver void setNowNextData(); void setSummaryData(); + VAudioSelector* vas; + Wwss wss; Region wssRegion; bool dowss; -- 2.39.5