]> git.vomp.tv Git - vompclient.git/commitdiff
Channel unavailable detection, minor mod to live banner
authorChris Tallon <chris@vomp.tv>
Tue, 9 Aug 2005 00:52:06 +0000 (00:52 +0000)
committerChris Tallon <chris@vomp.tv>
Tue, 9 Aug 2005 00:52:06 +0000 (00:52 +0000)
main.cc
message.h
viewman.cc
vinfo.cc
vinfo.h
vlivebanner.cc
vlivebanner.h
vvideolive.cc
vvideolive.h
vvideorec.cc

diff --git a/main.cc b/main.cc
index a5c7aa020cb659292abb32dea171c8864b04c92a..6b6f21ff7416cb2835030bfc2d328b57996c9d8f 100644 (file)
--- 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");
index abd09a43e7e8e074a4c4b83d52e892bd5d5c6ef5..a8783cfea5bc2d7359fd40268e198e96e74259f0 100644 (file)
--- 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
index 4ab9ad488974a903f3ea0ff033d8966091bf8098..1f4e5921ee6c3bbf6ab0a4730efb8d2c1231a86b 100644 (file)
@@ -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();
+    }
   }
 }
 
index b227959b2e1709a907aa0da588e4aad7b1332182..bb43cff2e22d831774b84d418009bae68f257c7d 100644 (file)
--- 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 7c156e24ed48e523c6fbb06e1b502de8001edbe6..c33cecdcd697a3abd8c1520be5d34beefd2e0f9b 100644 (file)
--- 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
index bd2db8a211303ae8cd2f33466cb564ead5a58be0..a27de942a57d19c5580a96f1956b500c635d7417 100644 (file)
 
 #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);
index 8e5bd8003215c2a091f0295280495b55dafbb45d..3427468b453b3bbe570e1e554213c05c3d50eb58 100644 (file)
@@ -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;
 
 };
 
index 96bb763f0f756d95c333c2b777a33f69dafebf00..5c43babe849bfa7addf5b1ff3161e515306a584e 100644 (file)
@@ -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;
+}
+
index 925650d1104aa674ccb3cebfb521595a27f5322b..3298c25e694a7bf0f4f8e02ad6a3fac8f01d4814 100644 (file)
@@ -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
index 9ac408916af3e31f453a085ace4c1152f9ef7e7f..73cc08caf3d663530873cdf72659f315786a85df 100644 (file)
@@ -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;