From 941c2a5af4de007f24b6f5535194d982306aa16f Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 24 Nov 2012 09:19:07 +0100 Subject: [PATCH] Apply JTE subtitles patch for not destroying OSD --- dvbsubtitles.cc | 21 +++++++++++++++------ dvbsubtitles.h | 2 ++ player.cc | 4 ++++ player.h | 1 + playerlivetv.cc | 6 ++++++ playerlivetv.h | 1 + vteletextview.cc | 7 +++++-- vteletextview.h | 8 ++++++-- vvideolivetv.cc | 13 +++++++++++-- vvideorec.cc | 8 +++++++- 10 files changed, 58 insertions(+), 13 deletions(-) diff --git a/dvbsubtitles.cc b/dvbsubtitles.cc index 1a6f22c..e581a18 100644 --- a/dvbsubtitles.cc +++ b/dvbsubtitles.cc @@ -777,7 +777,7 @@ bool DVBSubtitles::decodePacket(const PESPacket& packet) void DVBSubtitles::finishPage(const DVBSubtitlePage& page) { - if (page.dirty) + if (page.dirty && !osdMenuShowing) { osd->clearOSD(); } @@ -795,7 +795,7 @@ void DVBSubtitles::finishPage(const DVBSubtitlePage& page) region_iter = page.regions.find(i->first); if (region_iter == page.regions.end()) continue; Log::getInstance()->log("SUBTITLES", Log::DEBUG, "Clear region %d", i->first); - osd->clearOSDArea(i->second.x, i->second.y, + if (!osdMenuShowing) osd->clearOSDArea(i->second.x, i->second.y, region_iter->second.getWidth(), region_iter->second.getHeight(),dds); } } @@ -806,7 +806,8 @@ void DVBSubtitles::finishPage(const DVBSubtitlePage& page) region_iter = page.regions.find(i->first); if (region_iter == page.regions.end()) continue; Log::getInstance()->log("SUBTITLES", Log::DEBUG, "Display region %d", i->first); - osd->drawOSDBitmap(i->second.x, i->second.y, region_iter->second,dds); + if (!osdMenuShowing) osd->drawOSDBitmap(i->second.x, i->second.y, + region_iter->second,dds); } // after displaying regions set the page timeout timer SubtitleTimeout.Set(page.timeout * 1000); @@ -876,7 +877,7 @@ void DVBSubtitles::stop() DVBSubtitlePage::RegionMap::const_iterator region_iter; region_iter = page.regions.find(i->first); if (region_iter == page.regions.end()) continue; - osd->clearOSDArea(i->second.x, i->second.y, + if (!osdMenuShowing) osd->clearOSDArea(i->second.x, i->second.y, region_iter->second.getWidth(), region_iter->second.getHeight(),dds); } } @@ -907,7 +908,7 @@ void DVBSubtitles::hide() DVBSubtitlePage::RegionMap::const_iterator region_iter; region_iter = page.regions.find(i->first); if (region_iter == page.regions.end()) continue; - osd->clearOSDArea(i->second.x, i->second.y, + if (!osdMenuShowing) osd->clearOSDArea(i->second.x, i->second.y, region_iter->second.getWidth(), region_iter->second.getHeight(),dds); } } @@ -945,7 +946,7 @@ void DVBSubtitles::threadMethod() if (SubtitleTimeout.TimedOut()) // do we have a subtitle timeout { lockOutput(); - if(showing) + if (showing && !osdMenuShowing) osd->clearOSD(); // if we have the timeout, lets clear the OSD unlockOutput(); } @@ -1059,3 +1060,11 @@ void DVBSubtitles::threadMethod() } } } + +void DVBSubtitles::setOSDMenuVisibility(bool visible) +{ + lockOutput(); + osdMenuShowing = visible; + unlockOutput(); +} + diff --git a/dvbsubtitles.h b/dvbsubtitles.h index 1fb4452..d08f3c3 100644 --- a/dvbsubtitles.h +++ b/dvbsubtitles.h @@ -126,6 +126,7 @@ class DVBSubtitles : public Thread_TYPE void stop(); void show(); void hide(); + void setOSDMenuVisibility(bool visible); private: OSDReceiver* osd; @@ -137,6 +138,7 @@ class DVBSubtitles : public Thread_TYPE void finishPage(const DVBSubtitlePage&); DVBSubtitleDisplayDefinition dds; + bool osdMenuShowing; bool running; bool showing; bool threadNudged; diff --git a/player.cc b/player.cc index 091fb0a..790ed9a 100644 --- a/player.cc +++ b/player.cc @@ -265,6 +265,10 @@ void Player::turnSubtitlesOn(bool ison) { } +void Player::tellSubtitlesOSDVisible(bool visible){ +subtitles->setOSDMenuVisibility(visible); +} + Channel * Player::getDemuxerChannel() { if (!is_pesrecording) { return ((DemuxerTS*) demuxer)->getChannelInfo(); diff --git a/player.h b/player.h index 12de87a..a798750 100644 --- a/player.h +++ b/player.h @@ -64,6 +64,7 @@ class Player : public Thread_TYPE, public Callback bool toggleSubtitles(); void turnSubtitlesOn(bool ison); bool isSubtitlesOn() { return subtitlesShowing; } + void tellSubtitlesOSDVisible(bool visible); void play(); void stop(); diff --git a/playerlivetv.cc b/playerlivetv.cc index 20f25c4..16eff3c 100644 --- a/playerlivetv.cc +++ b/playerlivetv.cc @@ -183,6 +183,12 @@ void PlayerLiveTV::turnSubtitlesOn(bool ison) { } } + +void PlayerLiveTV::tellSubtitlesOSDVisible(bool visible) +{ +subtitles->setOSDMenuVisibility(visible); +} + // ----------------------------------- Externally called events void PlayerLiveTV::go(ULONG index) diff --git a/playerlivetv.h b/playerlivetv.h index 4fba1c8..49bc9fe 100644 --- a/playerlivetv.h +++ b/playerlivetv.h @@ -72,6 +72,7 @@ class PlayerLiveTV : public PlayerLive, public Thread_TYPE, public Callback, pub virtual bool toggleSubtitles(); virtual void turnSubtitlesOn(bool ison); virtual bool isSubtitlesOn() {return subtitlesShowing;}; + virtual void tellSubtitlesOSDVisible(bool visible); virtual bool* getDemuxerMpegAudioChannels(); virtual bool* getDemuxerAc3AudioChannels(); diff --git a/vteletextview.cc b/vteletextview.cc index de95dc1..975a58a 100644 --- a/vteletextview.cc +++ b/vteletextview.cc @@ -23,12 +23,14 @@ #include "timers.h" #include "boxstack.h" #include "remote.h" +#include "playerlivetv.h" -VTeletextView::VTeletextView(TeletextDecoderVBIEBU* TTdecoder,Boxx* playerview) +VTeletextView::VTeletextView(TeletextDecoderVBIEBU* TTdecoder,Boxx* playerview, PlayerLiveTV* playerObj) { ttdecoder=TTdecoder; pv=playerview; + player=playerObj; subtitlemode=false; @@ -108,8 +110,9 @@ int VTeletextView::handleCommand(int command) { case Remote::OK: return 2; case Remote::BACK: + if(player) player->tellSubtitlesOSDVisible(false); // Only on liveTV return 4; - case Remote::ZERO: + case Remote::ZERO: case Remote::ONE: case Remote::TWO: case Remote::THREE: diff --git a/vteletextview.h b/vteletextview.h index 01bf5e0..d3d1f35 100644 --- a/vteletextview.h +++ b/vteletextview.h @@ -27,10 +27,13 @@ #include "timerreceiver.h" #include "teletextdecodervbiebu.h" +class PlayerLiveTV; + class VTeletextView : public Boxx, public TimerReceiver { public: - VTeletextView (TeletextDecoderVBIEBU* TTdecoder, Boxx* playerview); + VTeletextView (TeletextDecoderVBIEBU* TTdecoder, Boxx* playerview, + PlayerLiveTV* palyerObj); ~VTeletextView (); void draw(bool completedraw, bool onlyfirstline); void draw() {draw(true,false);}; @@ -56,7 +59,8 @@ class VTeletextView : public Boxx, public TimerReceiver int keyindigit; int page; bool subtitlemode; - Boxx* pv; + Boxx* pv; + PlayerLiveTV* player; }; diff --git a/vvideolivetv.cc b/vvideolivetv.cc index 4c2f1be..e75adef 100644 --- a/vvideolivetv.cc +++ b/vvideolivetv.cc @@ -409,7 +409,10 @@ int VVideoLiveTV::handleCommand(int command) } case Remote::YELLOW: { - if (streamType ==VDR::VIDEO) doTeletext(); //TODO: Add a selector for subtitles or teletext + if (streamType ==VDR::VIDEO) + { + doTeletext(); //TODO: Add a selector for subtitles or teletext + } return 2; } case Remote::GUIDE: @@ -590,6 +593,7 @@ void VVideoLiveTV::doKey(int command) void VVideoLiveTV::doTeletext(bool subtitlemode) { if (streamType !=VDR::VIDEO) return; + (static_cast(player))->tellSubtitlesOSDVisible(true); bool exists=true; // Cancel keying @@ -602,11 +606,12 @@ void VVideoLiveTV::doTeletext(bool subtitlemode) osdChanNum.setText(formatChanNum); osdChanName.setText((*chanList)[osdChannelIndex]->name); } + (static_cast(player))->tellSubtitlesOSDVisible(true); if (osd.getVisible()) clearScreen(); // Draw the teletxt VTeletextView *vtxv=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView(); if (vtxv==NULL) { - vtxv= new VTeletextView(((PlayerLiveTV*)player)->getTeletextDecoder(),this); + vtxv= new VTeletextView(((PlayerLiveTV*)player)->getTeletextDecoder(),this, (PlayerLiveTV*)player); ((PlayerLiveTV*)player)->getTeletextDecoder()->registerTeletextView(vtxv); exists=false; } @@ -750,6 +755,7 @@ void VVideoLiveTV::setSummaryData() void VVideoLiveTV::displayOSD(bool newNowNextData) { + (static_cast(player))->tellSubtitlesOSDVisible(true); osd.setVisible(true); if (newNowNextData) { @@ -789,6 +795,8 @@ void VVideoLiveTV::clearScreen() draw(); boxstack->update(this); + + (static_cast(player))->tellSubtitlesOSDVisible(false); } void VVideoLiveTV::showUnavailable() @@ -856,6 +864,7 @@ void VVideoLiveTV::timercall(int ref) boxstack->update(this, osd.getRegion()); Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey 3."); + (static_cast(player))->tellSubtitlesOSDVisible(false); Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 notkey end."); } } diff --git a/vvideorec.cc b/vvideorec.cc index 654bc77..d5d2e08 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -427,7 +427,7 @@ void VVideoRec::doTeletext() // Draw the teletxt VTeletextView *vtxv=player->getTeletextDecoder()->getTeletxtView(); if (vtxv==NULL) { - vtxv= new VTeletextView((player)->getTeletextDecoder(),this); + vtxv= new VTeletextView((player)->getTeletextDecoder(),this,NULL); (player)->getTeletextDecoder()->registerTeletextView(vtxv); exists=false; } @@ -787,6 +787,8 @@ void VVideoRec::doAudioSelector() void VVideoRec::doBar(int action) { + clearOSD(); // remove dvbsubtitles + player->tellSubtitlesOSDVisible(true); barShowing = true; rectangle(barRegion, barBlue); @@ -1039,10 +1041,13 @@ void VVideoRec::removeBar() barVasHold = false; rectangle(barRegion, transparent); boxstack->update(this, &barRegion); + player->tellSubtitlesOSDVisible(false); } void VVideoRec::doSummary() { + clearOSD(); // remove dvbsubtitles + player->tellSubtitlesOSDVisible(true); vsummary = new VInfo(); vsummary->setTitleText(myRec->getProgName()); vsummary->setBorderOn(1); @@ -1073,6 +1078,7 @@ void VVideoRec::removeSummary() vsummary = NULL; draw(); BoxStack::getInstance()->update(this); + player->tellSubtitlesOSDVisible(false); } } -- 2.39.5