From 140c38273a06390ff9c53e72d310a8fc39dbc939 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 1 May 2008 20:28:32 +0000 Subject: [PATCH] Buffering progress bar --- GNUmakefile | 2 +- objects.mk | 3 ++- playerlivetv.cc | 29 ++++++++++++++++-------- playerlivetv.h | 2 +- vaudioselector.cc | 22 ++++++++++-------- vvideolivetv.cc | 41 +++++++++++++++++++++++++++------ vvideolivetv.h | 2 ++ wprogressbar.cc | 58 +++++++++++++++++++++++++++++++++++++++++++++++ wprogressbar.h | 48 +++++++++++++++++++++++++++++++++++++++ 9 files changed, 177 insertions(+), 30 deletions(-) create mode 100644 wprogressbar.cc create mode 100644 wprogressbar.h diff --git a/GNUmakefile b/GNUmakefile index ebef069..ec80be7 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -53,7 +53,7 @@ debug: ../../gdb/gdb-6.7/gdb/gdb /diskless/nfs/mvp/vompclient /diskless/nfs/mvp/core.* debug2: - ../../gdb/gdb-6.7/gdb/gdb /diskless/nfs/wmvp/vompclient /diskless/nfs/wmvp/core.* + ../../gdb/gdb-6.7/gdb/gdb /mnt/auto/defiant/diskless/nfs/mvp-dev/vompclient /mnt/auto/defiant/diskless/nfs/mvp-dev/core.* dev: CXXFLAGS := $(CXXFLAGS_DEV) dev: vompclient diff --git a/objects.mk b/objects.mk index 0478427..2305844 100644 --- a/objects.mk +++ b/objects.mk @@ -18,4 +18,5 @@ OBJECTS1 = command.o log.o tcp.o dsock.o thread.o timers.o i18n.o mutex.o \ vaudioplayer.o audioplayer.o demuxeraudio.o abstractoption.o \ eventdispatcher.o vdrrequestpacket.o vdrresponsepacket.o \ vvideolivetv.o \ - vvideolive.o vlivebanner.o playerlivetv.o playerliveradio.o + vvideolive.o vlivebanner.o playerlivetv.o playerliveradio.o \ + wprogressbar.o diff --git a/playerlivetv.cc b/playerlivetv.cc index 9e83595..16fef2d 100644 --- a/playerlivetv.cc +++ b/playerlivetv.cc @@ -153,17 +153,18 @@ void PlayerLiveTV::call(void* caller) { logger->log("PlayerLiveTV", Log::DEBUG, "Callback from demuxer"); - if (video->getTVsize() == Video::ASPECT4X3) - { - logger->log("PlayerLiveTV", Log::DEBUG, "TV is 4:3, ignoring aspect switching"); - return; - } - int dxCurrentAspect = demuxer->getAspectRatio(); if (dxCurrentAspect == Demuxer::ASPECT_4_3) { - logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer said video is 4:3 aspect, switching TV"); - video->setAspectRatio(Video::ASPECT4X3); + if (video->getTVsize() == Video::ASPECT16X9) + { + logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer said video is 4:3 aspect, switching TV"); + video->setAspectRatio(Video::ASPECT4X3); + } + else + { + logger->log("PlayerLiveTV", Log::DEBUG, "TV is 4:3, ignoring aspect switching"); + } Message* m = new Message(); m->from = this; @@ -174,8 +175,15 @@ void PlayerLiveTV::call(void* caller) } else if (dxCurrentAspect == Demuxer::ASPECT_16_9) { - logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer said video is 16:9 aspect, switching TV"); - video->setAspectRatio(Video::ASPECT16X9); + if (video->getTVsize() == Video::ASPECT16X9) + { + logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer said video is 16:9 aspect, switching TV"); + video->setAspectRatio(Video::ASPECT16X9); + } + else + { + logger->log("PlayerLiveTV", Log::DEBUG, "TV is 4:3, ignoring aspect switching"); + } Message* m = new Message(); m->from = this; @@ -554,6 +562,7 @@ void PlayerLiveTV::threadMethod() { ++preBufferCount; ULONG percentDone = (ULONG)(preBufferCount / (float)preBufferAmount * 100); + logger->log("PlayerLiveTV", Log::DEBUG, "Prebuffering %lu%%", percentDone); Message* m = new Message(); m->from = this; diff --git a/playerlivetv.h b/playerlivetv.h index c06a55b..0d2c5c6 100644 --- a/playerlivetv.h +++ b/playerlivetv.h @@ -117,7 +117,7 @@ class PlayerLiveTV : public PlayerLive, public Thread_TYPE, public Callback, pub bool videoStartup; bool stopNow; int preBufferCount; - const static int preBufferAmount = 3; + const static int preBufferAmount = 10; void clearStreamChunks(); void chunkToDemuxer(); diff --git a/vaudioselector.cc b/vaudioselector.cc index 857d10a..97306ff 100644 --- a/vaudioselector.cc +++ b/vaudioselector.cc @@ -214,16 +214,18 @@ VAudioSelector::VAudioSelector(void* tparent, Channel* channel, int currentAudio ac->pestype = channel->apids[i].pid; acl.push_back(ac); } - if (Audio::getInstance()->supportsAc3()) { - for (UINT i = 0; i < channel->numDPids; i++) - { - AudioChannel* ac = new AudioChannel(); - ac->type = 1; - ac->name = new char[strlen(channel->dpids[i].name) + 1]; - strcpy(ac->name, channel->dpids[i].name); - ac->pestype = channel->dpids[i].pid; - acl.push_back(ac); - } + + if (Audio::getInstance()->supportsAc3()) + { + for (UINT i = 0; i < channel->numDPids; i++) + { + AudioChannel* ac = new AudioChannel(); + ac->type = 1; + ac->name = new char[strlen(channel->dpids[i].name) + 1]; + strcpy(ac->name, channel->dpids[i].name); + ac->pestype = channel->dpids[i].pid; + acl.push_back(ac); + } } int audioChannelListSize = acl.size(); diff --git a/vvideolivetv.cc b/vvideolivetv.cc index 8a939e3..b3c5f27 100644 --- a/vvideolivetv.cc +++ b/vvideolivetv.cc @@ -211,6 +211,11 @@ VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, V sAspectRatio.setVisible(false); osd.add(&sAspectRatio); + bufferBar.setPosition(osd.getWidth() - 94, 70); + bufferBar.setSize(50, 20); + bufferBar.setVisible(true); + osd.add(&bufferBar); + // FIXME painful Region r1 = summary.getRegionR(); Region r2 = osd.getRegionR(); @@ -635,7 +640,7 @@ void VVideoLiveTV::displayOSD(bool newNowNextData) if (newNowNextData) { setNowNextData(); - keying = 0; + keying = 0; } osd.draw(); @@ -783,6 +788,10 @@ bool VVideoLiveTV::channelChange(UCHAR changeType, UINT newData) player->setChannel(currentChannelIndex); Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Done Set player to channel %u", currentChannelIndex); + // Blank out the symbols + sAspectRatio.setVisible(false); + bufferBar.setPercent(0); + return true; } @@ -867,7 +876,7 @@ void VVideoLiveTV::processMessage(Message* m) case PlayerLiveTV::ASPECT43: { - if (dowss) + if ((video->getTVsize() == Video::ASPECT16X9) && dowss) { Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43"); wss.setWide(false); @@ -877,14 +886,18 @@ void VVideoLiveTV::processMessage(Message* m) sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT43; sAspectRatio.setVisible(true); - osd.draw(); - BoxStack::getInstance()->update(this, osd.getRegion()); + + if (osd.getVisible()) // don't wake up the whole osd just for a aspect change + { + osd.draw(); + BoxStack::getInstance()->update(this, osd.getRegion()); + } break; } case PlayerLiveTV::ASPECT169: { - if (dowss) + if ((video->getTVsize() == Video::ASPECT16X9) && dowss) { Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169"); wss.setWide(true); @@ -894,14 +907,28 @@ void VVideoLiveTV::processMessage(Message* m) sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT169; sAspectRatio.setVisible(true); - osd.draw(); - BoxStack::getInstance()->update(this, osd.getRegion()); + + if (osd.getVisible()) // don't wake up the whole osd just for a aspect change + { + osd.draw(); + BoxStack::getInstance()->update(this, osd.getRegion()); + } break; } case PlayerLiveTV::PREBUFFERING: { Log::getInstance()->log("VVideoRec", Log::DEBUG, "Prebuffering - %u", m->tag); + bufferBar.setVisible(true); + bufferBar.setPercent(m->tag); + bufferBar.draw(); + + if (osd.getVisible()) + { + Region r; + bufferBar.getRootBoxRegion(&r); + BoxStack::getInstance()->update(this, &r); + } } } } diff --git a/vvideolivetv.h b/vvideolivetv.h index c814a1f..cb04e41 100644 --- a/vvideolivetv.h +++ b/vvideolivetv.h @@ -33,6 +33,7 @@ #include "wselectlist.h" #include "timerreceiver.h" #include "wsymbol.h" +#include "wprogressbar.h" class VChannelList; class Video; @@ -125,6 +126,7 @@ class VVideoLiveTV : public Boxx, public TimerReceiver WTextbox textYellow; WTextbox textBlue; WSymbol sAspectRatio; + WProgressBar bufferBar; Boxx summary; WTextbox textSummary; diff --git a/wprogressbar.cc b/wprogressbar.cc new file mode 100644 index 0000000..d61daa0 --- /dev/null +++ b/wprogressbar.cc @@ -0,0 +1,58 @@ +/* + Copyright 2008 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "wprogressbar.h" + +#include "colour.h" + +WProgressBar::WProgressBar() +{ + percent = 0; +} + +WProgressBar::~WProgressBar() +{ +} + +void WProgressBar::setPercent(UINT tpercent) +{ + percent = tpercent; + if (percent > 100) percent = 0; +} + +void WProgressBar::draw() +{ + if (area.w < 5) return; + if (area.h < 5) return; + + printf("progress bar: %u\n", percent); + + // Hmm, can't draw two boxes because should not paint on areas + // not needing it - this class does not know the background colour + + rectangle(0, 0, area.w, 2, Colour::LIGHTTEXT); // top + rectangle(0, area.h - 2, area.w, 2, Colour::LIGHTTEXT); // bottom + rectangle(0, 0, 2, area.h, Colour::LIGHTTEXT); // left + rectangle(area.w - 2, 0, 2, area.h, Colour::LIGHTTEXT); // right + + int progressWidth = (int)((area.w - 4) * (float)percent / 100); + rectangle(2, 2, progressWidth, area.h - 4, Colour::SELECTHIGHLIGHT); +} + diff --git a/wprogressbar.h b/wprogressbar.h new file mode 100644 index 0000000..7db78e2 --- /dev/null +++ b/wprogressbar.h @@ -0,0 +1,48 @@ +/* + Copyright 2008 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/* +For now this will be a simple progress bar, but in future maybe the +recording playback bar could be rolled into this class +*/ + +#ifndef WPROGRESSBAR_H +#define WPROGRESSBAR_H + +#include +#include + +#include "defines.h" +#include "boxx.h" + +class WProgressBar : public Boxx +{ + public: + WProgressBar(); + ~WProgressBar(); + void setPercent(UINT percent); + void draw(); + + private: + UINT percent; +}; + +#endif + -- 2.39.5