From a9dc32ef805f23f781fbcb65b8cf424611abce7b Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Tue, 9 Aug 2005 00:52:06 +0000 Subject: [PATCH] Channel unavailable detection, minor mod to live banner --- main.cc | 2 - message.h | 1 + viewman.cc | 7 +++ vinfo.cc | 8 +++ vinfo.h | 2 + vlivebanner.cc | 6 +- vlivebanner.h | 3 +- vvideolive.cc | 149 ++++++++++++++++++++++++++++++++++++------------- vvideolive.h | 11 +++- vvideorec.cc | 5 ++ 10 files changed, 149 insertions(+), 45 deletions(-) diff --git a/main.cc b/main.cc index a5c7aa0..6b6f21f 100644 --- a/main.cc +++ b/main.cc @@ -270,8 +270,6 @@ void shutdown(int code) if (viewman) { - printf("here st 3\n"); - viewman->shutdown(); delete viewman; logger->log("Core", Log::NOTICE, "ViewMan module shut down"); diff --git a/message.h b/message.h index abd09a4..a8783cf 100644 --- a/message.h +++ b/message.h @@ -50,6 +50,7 @@ class Message const static ULONG SERVER_SELECTED = 11; const static ULONG VDR_CONNECTED = 12; const static ULONG REDRAW_DATA = 13; + const static ULONG ADD_VIEW = 14; }; #endif diff --git a/viewman.cc b/viewman.cc index 4ab9ad4..1f4e592 100644 --- a/viewman.cc +++ b/viewman.cc @@ -386,6 +386,13 @@ void ViewMan::processMessage(Message* m) resetThread(); break; } + case Message::ADD_VIEW: + { + View* toAdd = (View*)m->parameter; + addNoLock(toAdd); + toAdd->draw(); + Box::showAll(); + } } } diff --git a/vinfo.cc b/vinfo.cc index b227959..bb43cff 100644 --- a/vinfo.cc +++ b/vinfo.cc @@ -24,6 +24,7 @@ VInfo::VInfo() { mainText = NULL; exitable = 0; + dropThrough = 0; setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); @@ -40,6 +41,11 @@ void VInfo::setExitable() exitable = 1; } +void VInfo::setDropThrough() +{ + dropThrough = 1; +} + void VInfo::setMainText(char* takeText) { int length = strlen(takeText); @@ -56,6 +62,8 @@ void VInfo::draw() int VInfo::handleCommand(int command) { + if (dropThrough) return 0; + switch(command) { case Remote::OK: diff --git a/vinfo.h b/vinfo.h index 7c156e2..c33cecd 100644 --- a/vinfo.h +++ b/vinfo.h @@ -37,6 +37,7 @@ class VInfo : public View void setMainText(char* title); void setExitable(); + void setDropThrough(); virtual int handleCommand(int command); void draw(); @@ -44,6 +45,7 @@ class VInfo : public View protected: char* mainText; UCHAR exitable; + UCHAR dropThrough; }; #endif diff --git a/vlivebanner.cc b/vlivebanner.cc index bd2db8a..a27de94 100644 --- a/vlivebanner.cc +++ b/vlivebanner.cc @@ -20,8 +20,10 @@ #include "vlivebanner.h" -VLiveBanner::VLiveBanner() +VLiveBanner::VLiveBanner(Channel* channel) { + currentChannel = channel; + if (Video::getInstance()->getFormat() == Video::PAL) { setScreenPos(130, 370); @@ -35,7 +37,7 @@ VLiveBanner::VLiveBanner() setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); - setTitleText("The channel name"); + setTitleText(currentChannel->name); setTitleBarColour(Colour::TITLEBARBACKGROUND); sl.setScreenPos(screenX, screenY + 30); diff --git a/vlivebanner.h b/vlivebanner.h index 8e5bd80..3427468 100644 --- a/vlivebanner.h +++ b/vlivebanner.h @@ -34,7 +34,7 @@ class VLiveBanner : public View { public: - VLiveBanner(); + VLiveBanner(Channel* channel); ~VLiveBanner(); int handleCommand(int command); @@ -42,6 +42,7 @@ class VLiveBanner : public View private: WSelectList sl; + Channel* currentChannel; }; diff --git a/vvideolive.cc b/vvideolive.cc index 96bb763..5c43bab 100644 --- a/vvideolive.cc +++ b/vvideolive.cc @@ -25,8 +25,11 @@ VVideoLive::VVideoLive(List* tchanList) player = new Player(NULL); player->init(); vdr = VDR::getInstance(); + viewman = ViewMan::getInstance(); chanList = tchanList; - currentChannel = 0; + currentChannel = NULL; + unavailable = 0; + unavailableView = NULL; Video* video = Video::getInstance(); setDimensions(video->getScreenHeight(), video->getScreenWidth()); @@ -50,7 +53,7 @@ int VVideoLive::handleCommand(int command) { case Remote::PLAY: { - player->play(); // do resync + if (!unavailable) player->play(); // do resync return 2; } @@ -58,42 +61,38 @@ int VVideoLive::handleCommand(int command) case Remote::BACK: case Remote::MENU: { - player->stop(); - vdr->stopStreaming(); + if (unavailable) showUnavailable(0); + else stop(); return 4; } case Remote::DF_UP: case Remote::UP: { - player->stop(); - vdr->stopStreaming(); + if (unavailable) showUnavailable(0); + else stop(); upChannel(); - doBanner(); - vdr->streamChannel(currentChannel); - player->play(); + play(); return 2; } case Remote::DF_DOWN: case Remote::DOWN: { - player->stop(); - vdr->stopStreaming(); + if (unavailable) showUnavailable(0); + else stop(); downChannel(); - doBanner(); - vdr->streamChannel(currentChannel); - player->play(); + play(); return 2; } case Remote::OK: { - doBanner(); + if (!unavailable) doBanner(); return 2; } case Remote::ZERO ... Remote::NINE: { VChannelSelect* v = new VChannelSelect(this, command); - ViewMan::getInstance()->addNoLock(v); + viewman->addNoLock(v); // ViewMan::getInstance()->timedDelete(v, 4, 0); v->draw(); v->show(); @@ -108,34 +107,95 @@ void VVideoLive::processMessage(Message* m) if (m->message == Message::CHANNEL_CHANGE) { // check channel number is valid - Channel* channel; - for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next()) - { - if (channel->number == m->parameter) - { - player->stop(); - vdr->stopStreaming(); - setChannel(channel->number); - } - } + currentChannel = channelFromNumber(m->parameter); + if (!currentChannel) return; // this should never happen + if (unavailable) showUnavailable(0); + else stop(); + play(); } } void VVideoLive::doBanner() { - VLiveBanner* v = new VLiveBanner(); - ViewMan::getInstance()->addNoLock(v); - ViewMan::getInstance()->timedDelete(v, 4, 0); - v->draw(); - v->show(); + VLiveBanner* v = new VLiveBanner(currentChannel); + viewman->timedDelete(v, 4, 0); + + Message* m = new Message(); + m->from = this; + m->to = viewman; + m->message = Message::ADD_VIEW; + m->parameter = (ULONG)v; + + viewman->postMessage(m); +} + +void VVideoLive::showUnavailable(int active) +{ + if (active == unavailable) return; + + if (active) + { + unavailable = 1; + + unavailableView = new VInfo(); + unavailableView->setDimensions(200, 400); + if (Video::getInstance()->getFormat() == Video::PAL) + { + unavailableView->setScreenPos(170, 200); + } + else + { + unavailableView->setScreenPos(160, 150); + } + unavailableView->setTitleText(currentChannel->name); + unavailableView->setMainText("\n Channel unavailable"); + unavailableView->setDropThrough(); + + Message* m = new Message(); + m->from = this; + m->to = viewman; + m->message = Message::ADD_VIEW; + m->parameter = (ULONG)unavailableView; + + viewman->postMessage(m); + } + else + { + unavailable = 0; + ViewMan::getInstance()->removeView(unavailableView, 1); + unavailableView = NULL; + } } void VVideoLive::setChannel(int number) { - currentChannel = number; -// doBanner(); - vdr->streamChannel(currentChannel); - player->play(); + currentChannel = channelFromNumber(number); + if (!currentChannel) return; // should never happen + play(); +} + +void VVideoLive::play() +{ + showUnavailable(0); + + int available = vdr->streamChannel(currentChannel->number); + + if (!available) + { + showUnavailable(1); + } + else + { + doBanner(); + player->play(); + } +} + +void VVideoLive::stop() +{ + if (unavailable) return; + player->stop(); + vdr->stopStreaming(); } void VVideoLive::upChannel() @@ -143,12 +203,12 @@ void VVideoLive::upChannel() Channel* channel; for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next()) { - if (channel->number == currentChannel) + if (channel == currentChannel) { chanList->next(); channel = (Channel*)chanList->getCurrent(); if (!channel) return; - currentChannel = channel->number; + currentChannel = channel; } } } @@ -159,11 +219,22 @@ void VVideoLive::downChannel() Channel* prevChannel = NULL; for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next()) { - if (channel->number == currentChannel) + if (channel == currentChannel) { if (!prevChannel) return; - currentChannel = prevChannel->number; + currentChannel = prevChannel; } prevChannel = channel; } } + +Channel* VVideoLive::channelFromNumber(int number) +{ + Channel* channel; + for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next()) + { + if (channel->number == (UINT)number) return channel; + } + return NULL; +} + diff --git a/vvideolive.h b/vvideolive.h index 925650d..3298c25 100644 --- a/vvideolive.h +++ b/vvideolive.h @@ -33,6 +33,7 @@ #include "vchannelselect.h" #include "colour.h" #include "osd.h" +#include "vinfo.h" class VVideoLive : public View { @@ -45,15 +46,23 @@ class VVideoLive : public View void setChannel(int number); + void play(); + void stop(); + private: + ViewMan* viewman; VDR* vdr; Player* player; List* chanList; - ULONG currentChannel; + Channel* currentChannel; + int unavailable; + VInfo* unavailableView; void upChannel(); void downChannel(); void doBanner(); + void showUnavailable(int active); + Channel* channelFromNumber(int number); }; #endif diff --git a/vvideorec.cc b/vvideorec.cc index 9ac4089..73cc08c 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -112,6 +112,11 @@ int VVideoRec::handleCommand(int command) player->test(); return 2; } + case Remote::GREEN: + { + player->test2(); + return 2; + } case Remote::ZERO: player->jumpToPercent(0); return 2; case Remote::ONE: player->jumpToPercent(10); return 2; -- 2.39.5