]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Audio channel selection code finished
authorChris Tallon <chris@vomp.tv>
Fri, 24 Nov 2006 16:57:45 +0000 (16:57 +0000)
committerChris Tallon <chris@vomp.tv>
Fri, 24 Nov 2006 16:57:45 +0000 (16:57 +0000)
14 files changed:
CREDITS
demuxer.cc
demuxer.h
message.h
recinfo.cc
recinfo.h
vaudioselector.cc
vaudioselector.h
view.h
vvideorec.cc
vvideorec.h
widget.cc
widget.h
wselectlist.cc

diff --git a/CREDITS b/CREDITS
index 9cff30a290962cfe90779d636484184752b82a0c..433092e0539a210d6e2eff8d6ce67e48dc31bc9d 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -38,6 +38,7 @@ Marten Richter
   Debian packages for the e-TOBI VDR repository
   Information about index.vdr and code to navigate recordings
   Windows port of vompclient
+  Audio channel selection
 
 
 Thanks to the following people for their work with the MVP:
index 686f847e1842c6728796996a954caaa700063b53..aea868c3ba2a020808c3eac04b8e50abd9b217fb 100644 (file)
@@ -92,7 +92,7 @@ void Demuxer::reset()
   aspect_ratio = (enum AspectRatio) 0;
   frame_rate = bit_rate = 0;
 
-  for (int i = 0; i < PESTYPE_AUDMAX - PESTYPE_AUD0; i++)
+  for (int i = 0; i <= (PESTYPE_AUDMAX - PESTYPE_AUD0); i++)
   {
     avail_mpaudchan[i] = false;
   }
index ea1d37ef2ea5057ebb3c09a8a1c81ffd271b9131..eb5881ceccfbd4e7274138048e20e702a7222f8b 100644 (file)
--- a/demuxer.h
+++ b/demuxer.h
@@ -161,7 +161,7 @@ protected:
       PESTYPE_VIDMAX = PESTYPE_VID15
     };
 
-    bool avail_mpaudchan[PESTYPE_AUDMAX-PESTYPE_AUD0];
+    bool avail_mpaudchan[PESTYPE_AUDMAX-PESTYPE_AUD0+1];
 };
 
 #endif
index 8a9b2938a9e8cc7ee8634275cd9ce9ac343b3023..4c98b999cfdc1564619906597020dab27a785368 100644 (file)
--- a/message.h
+++ b/message.h
@@ -65,6 +65,8 @@ class Message
     const static ULONG MOVE_RECORDING = 20;
     const static ULONG UDP_BUTTON = 21;
     const static ULONG PLAYER_EVENT = 22;
+    const static ULONG AUDIO_CHANGE_CHANNEL = 23;
+    const static ULONG CHILD_CLOSE = 24;
 };
 
 #endif
index 3a22c35f9bc3f0a1518e4bbc2d6342482fc5a573..faa370aad0150dba28f13700735209d4ace32b1e 100644 (file)
@@ -106,12 +106,15 @@ void RecInfo::print()
   }
 }
 
-bool RecInfo::hasVideo()
+bool RecInfo::hasNoVideo()
 {
+  // If no info (numComponents == 0) assume there is video
+  if (!numComponents) return false;
+
   // video = 1, audio = 2
 
   for (ULONG i = 0; i < numComponents; i++)
-    if (streams[i] == 1) return true;
+    if (streams[i] == 1) return false;
 
-  return false;
+  return true;
 }
index 9442f327c0d22ebea419537532015fe1820b7e91..031fcc5ea39f396be1f7088cd638b433a0f24d1d 100644 (file)
--- a/recinfo.h
+++ b/recinfo.h
@@ -49,7 +49,7 @@ class RecInfo
 
     void print();
 
-    bool hasVideo();
+    bool hasNoVideo();
 
   private:
 
index 01b8c29446fa1914a9990612da6db5df58d862af..a310df0ac6de4ac738315e470acb0301294eca2f 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    Copyright 2004-2005 Chris Tallon\r
+    Copyright 2006 Chris Tallon, Marten Richter\r
 \r
     This file is part of VOMP.\r
 \r
 \r
 #include "vaudioselector.h"\r
 \r
-VAudioSelector::VAudioSelector(View* tparent, bool* availableAudioChannels, int currentAudioChannel, RecInfo* recInfo)\r
+VAudioSelector::VAudioSelector(void* tparent, bool* availableAudioChannels, int currentAudioChannel, RecInfo* recInfo)\r
 {\r
+  Log::getInstance()->log("VAS", Log::DEBUG, "%i", currentAudioChannel);\r
+\r
   parent = tparent;\r
 \r
   create(200, 120);\r
-  if (Video::getInstance()->getFormat() == Video::PAL)\r
-  {\r
-    setScreenPos(62, 410);\r
-  }\r
-  else\r
-  {\r
-    setScreenPos(57, 320);\r
-  }\r
 \r
-\r
-  setTitleText(tr("Audio"));\r
-  setBackgroundColour(Colour::VIEWBACKGROUND);\r
-  setTitleBarOn(1);\r
-  setTitleBarColour(Colour::TITLEBARBACKGROUND);\r
+//  setTitleText(tr("Audio"));\r
+//  setTitleBarOn(1);\r
+//  setTitleBarColour(Colour::TITLEBARBACKGROUND);\r
 \r
   sl.setSurface(surface);\r
-  sl.setSurfaceOffset(0, 30);\r
-  sl.setDimensions(area.w, area.h - 30);\r
+  sl.setSurfaceOffset(40, 30);\r
+  sl.setDimensions(area.w - 45, area.h - 30);\r
 \r
   // Load data from availableAudioChannels, currentAudioChannel and recInfo\r
 \r
   int i;\r
-  int selected = 0;\r
 \r
-  for (i = 0; i < PES_AUDIO_END - PES_AUDIO_START; i++)\r
+  for (i = 0; i < PES_AUDIO_MAXCHANNELS; i++)\r
   {\r
     if (availableAudioChannels[i])\r
     {\r
@@ -57,7 +48,6 @@ VAudioSelector::VAudioSelector(View* tparent, bool* availableAudioChannels, int
       ac->type = 0;\r
       ac->name = NULL;\r
       ac->pestype = PES_AUDIO_START + i;\r
-      if (i == currentAudioChannel) selected = i;\r
       acl.push_back(ac);\r
     }\r
   }\r
@@ -138,7 +128,6 @@ VAudioSelector::VAudioSelector(View* tparent, bool* availableAudioChannels, int
   // Now do display\r
 \r
   char tempString[300];\r
-  int slSelected;\r
   int audioChannelListSize = acl.size();\r
 \r
   if (audioChannelListSize)\r
@@ -146,19 +135,15 @@ VAudioSelector::VAudioSelector(View* tparent, bool* availableAudioChannels, int
     for(i = 0; i < audioChannelListSize; i++)\r
     {\r
       AudioChannel* ac = acl[i];\r
-      if (i == currentAudioChannel)\r
-        slSelected = 1;\r
-      else\r
-        slSelected = 0;\r
 \r
       if (ac->name)\r
       {\r
-        sl.addOption(ac->name, (ULONG)ac, slSelected);\r
+        sl.addOption(ac->name, (ULONG)ac, (ac->pestype == currentAudioChannel));\r
       }\r
       else\r
       {\r
         SNPRINTF(tempString, 299, "%lu", (ULONG)(ac->pestype - PES_AUDIO_START));\r
-        sl.addOption(tempString, (ULONG)ac, slSelected);\r
+        sl.addOption(tempString, (ULONG)ac, (ac->pestype == currentAudioChannel));\r
       }\r
     }\r
   }\r
@@ -178,11 +163,21 @@ VAudioSelector::~VAudioSelector()
   acl.clear();\r
 \r
   sl.clear();\r
+\r
+  Message* m = new Message();\r
+  m->from = this;\r
+  m->to = parent;\r
+  m->message = Message::CHILD_CLOSE;\r
+  Command::getInstance()->postMessageNoLock(m);\r
 }\r
 \r
 void VAudioSelector::draw()\r
 {\r
   View::draw();\r
+  rectangle(0, 0, area.w, 30, Colour::TITLEBARBACKGROUND);\r
+  drawText(tr("Audio"), 45, 5, Colour::LIGHTTEXT);\r
+\r
+  sl.setBackgroundColour(backgroundColour);\r
   sl.draw();\r
 }\r
 \r
@@ -192,26 +187,41 @@ int VAudioSelector::handleCommand(int command)
   {\r
     case Remote::BACK:\r
     case Remote::OK:\r
+    case Remote::GREEN:\r
     {\r
       return 4;\r
     }\r
     case Remote::DF_UP:\r
+    case Remote::UP:\r
     {\r
       sl.up();\r
       sl.draw();\r
 \r
       ViewMan::getInstance()->updateView(this);\r
-      //player->setAudioChannel((AudioChannel*)sl.getCurrentOptionData());\r
+\r
+      Message* m = new Message();\r
+      m->from = this;\r
+      m->to = parent;\r
+      m->message = Message::AUDIO_CHANGE_CHANNEL;\r
+      m->parameter = ((AudioChannel*)sl.getCurrentOptionData())->pestype;\r
+      Command::getInstance()->postMessageNoLock(m);\r
 \r
       return 2;\r
     }\r
     case Remote::DF_DOWN:\r
+    case Remote::DOWN:\r
     {\r
       sl.down();\r
       sl.draw();\r
 \r
       ViewMan::getInstance()->updateView(this);\r
-      //player->setAudioChannel((AudioChannel*)sl.getCurrentOptionData());\r
+\r
+      Message* m = new Message();\r
+      m->from = this;\r
+      m->to = parent;\r
+      m->message = Message::AUDIO_CHANGE_CHANNEL;\r
+      m->parameter = ((AudioChannel*)sl.getCurrentOptionData())->pestype;\r
+      Command::getInstance()->postMessageNoLock(m);\r
 \r
       return 2;\r
     }\r
index 6f4754be82d87c8d4e9e2ec683d4077f408e6d5a..5a5c9ea018af4ca92f8cf3d19d19ef59235156d4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright 2004-2005 Chris Tallon
+    Copyright 2006 Chris Tallon, Marten Richter
 
     This file is part of VOMP.
 
 #include "video.h"
 #include "viewman.h"
 #include "i18n.h"
+#include "message.h"
+#include "command.h"
 
 #define PES_AUDIO_START 0xc0
-#define PES_AUDIO_END 0xcf
+#define PES_AUDIO_MAXCHANNELS 0x20
 
 class AudioChannel
 {
@@ -50,14 +52,14 @@ typedef vector<AudioChannel*> AudioChannelList;
 class VAudioSelector : public View
 {
   public:
-    VAudioSelector(View* parent, bool* availableAudioChannels, int currentAudioChannel, RecInfo* recInfo);
+    VAudioSelector(void* parent, bool* availableAudioChannels, int currentAudioChannel, RecInfo* recInfo);
     ~VAudioSelector();
 
     int handleCommand(int command);
     void draw();
 
   private:
-    View* parent;
+    void* parent;
     WSelectList sl;
 
     AudioChannelList acl;
diff --git a/view.h b/view.h
index 5cc6009e64c4f9baa49e32bfed1899324ee97399..739a3978e65f1831901f2cee4963c2e0ed157159 100644 (file)
--- a/view.h
+++ b/view.h
@@ -49,12 +49,12 @@ class View : public Box
   private:
     static char numViews;
 
-    Colour backgroundColour;
 
     char* titleText;
     UCHAR borderOn;
 
   protected:
+    Colour backgroundColour;
     Colour titleBarColour;
     UCHAR titleBarOn;
 };
index e11d950908c784c69696c6cb39ddeb63284f4f17..9fde5dcf22206e1ad5ca3d8810ae0ac1f00c1632 100644 (file)
@@ -26,10 +26,11 @@ VVideoRec::VVideoRec(Recording* rec)
   vdr = VDR::getInstance();
   video = Video::getInstance();
   timers = Timers::getInstance();
+  vas = NULL;
 
-  isRadio = !(rec->recInfo->hasVideo());
+  isRadio = rec->recInfo->hasNoVideo();
 
-  Log::getInstance()->log("VVideoRec", Log::DEBUG, "hasVideo = %i", isRadio);
+  Log::getInstance()->log("VVideoRec", Log::DEBUG, "Radio = %i", isRadio);
 
   player = new Player(Command::getInstance(), this, true, isRadio);
   player->init();
@@ -83,7 +84,9 @@ VVideoRec::VVideoRec(Recording* rec)
   barBlue.set(0, 0, 150, 150);
 
   barShowing = false;
-  stickyBar = false;
+  barGenHold = false;
+  barScanHold = false;
+  barVasHold = false;
 
   dowss = false;
   char* optionWSS = vdr->configLoad("General", "WSS");
@@ -112,6 +115,12 @@ VVideoRec::VVideoRec(Recording* rec)
 
 VVideoRec::~VVideoRec()
 {
+  if (vas)
+  {
+    viewman->removeView(vas);
+    vas = NULL;
+  }
+
   if (playing) stopPlay();
   video->setDefaultAspect();
 
@@ -142,12 +151,20 @@ void VVideoRec::go(bool resume)
   ULLONG lengthBytes = vdr->streamRecording(myRec->getFileName(), &lengthFrames);
   if (lengthBytes)
   {
-    doBar(0);
     player->setLengthBytes(lengthBytes);
-    if (!isRadio) player->setLengthFrames(lengthFrames);
+    if (!isRadio)
+    {
+      Log::getInstance()->log("VVideoRec", Log::DEBUG, "GO is setting length frames = %lu", lengthFrames);
+      player->setLengthFrames(lengthFrames);
+    }
+    else
+    {
+      Log::getInstance()->log("VVideoRec", Log::DEBUG, "GO is NOT setting length frames");
+    }
     player->setStartFrame(startFrameNum); // means bytes if radio (FIXME not done yet!)
     player->play();
     playing = true;
+    doBar(0);
   }
   else
   {
@@ -281,6 +298,8 @@ int VVideoRec::handleCommand(int command)
 #ifdef DEV
     case Remote::RED:
     {
+      //Don't use RED for anything. It will eventually be recording summary
+
       //player->test1();
 
 
@@ -306,52 +325,67 @@ int VVideoRec::handleCommand(int command)
 
 void VVideoRec::processMessage(Message* m)
 {
-  if (m->from != player) return;
-  if (m->message != Message::PLAYER_EVENT) return;
-
   Log::getInstance()->log("VVideoRec", Log::DEBUG, "Message received");
 
-  switch(m->parameter)
+  if (m->from == player)
   {
-    case Player::CONNECTION_LOST: // connection lost detected
+    if (m->message != Message::PLAYER_EVENT) return;
+    switch(m->parameter)
     {
-      // I can't handle this, send it to command
-      Message* m = new Message();
-      m->to = Command::getInstance();
-      m->message = Message::CONNECTION_LOST;
-      Command::getInstance()->postMessageNoLock(m);
-      break;
-    }
-    case Player::STOP_PLAYBACK:
-    {
-      // FIXME Obselete ish - improve this
-      Message* m = new Message(); // Must be done after this thread finishes, and must break into master mutex
-      m->to = Command::getInstance();
-      m->message = Message::STOP_PLAYBACK;
-      Command::getInstance()->postMessageNoLock(m);
-      break;
-    }
-    case Player::ASPECT43:
-    {
-      if (dowss)
+      case Player::CONNECTION_LOST: // connection lost detected
       {
-        Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43");
-        wss.setWide(false);
-        wss.draw();
-        viewman->updateView(this, &wssRegion);
+        // I can't handle this, send it to command
+        Message* m = new Message();
+        m->to = Command::getInstance();
+        m->message = Message::CONNECTION_LOST;
+        Command::getInstance()->postMessageNoLock(m);
+        break;
       }
-      break;
-    }
-    case Player::ASPECT169:
-    {
-      if (dowss)
+      case Player::STOP_PLAYBACK:
       {
-        Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169");
-        wss.setWide(true);
-        wss.draw();
-        viewman->updateView(this, &wssRegion);
+        // FIXME Obselete ish - improve this
+        Message* m = new Message(); // Must be done after this thread finishes, and must break into master mutex
+        m->to = Command::getInstance();
+        m->message = Message::STOP_PLAYBACK;
+        Command::getInstance()->postMessageNoLock(m);
+        break;
       }
-      break;
+      case Player::ASPECT43:
+      {
+        if (dowss)
+        {
+          Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43");
+          wss.setWide(false);
+          wss.draw();
+          viewman->updateView(this, &wssRegion);
+        }
+        break;
+      }
+      case Player::ASPECT169:
+      {
+        if (dowss)
+        {
+          Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169");
+          wss.setWide(true);
+          wss.draw();
+          viewman->updateView(this, &wssRegion);
+        }
+        break;
+      }
+    }
+  }
+  else if (m->message == Message::AUDIO_CHANGE_CHANNEL)
+  {
+    Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received change audio channel to %i", m->parameter);
+    player->setAudioChannel(m->parameter);
+  }
+  else if (m->message == Message::CHILD_CLOSE)
+  {
+    if (m->from == vas)
+    {
+      vas = NULL;
+      barVasHold = false;
+      if (!barGenHold && !barScanHold && !barVasHold) removeBar();
     }
   }
 }
@@ -399,7 +433,22 @@ void VVideoRec::doAudioSelector()
 {
   bool* availableAudioChannels = player->getDemuxerAudioChannels();
   int currentAudioChannel = player->getCurrentAudioChannel();
-  VAudioSelector* vas = new VAudioSelector(this, availableAudioChannels, currentAudioChannel, myRec->recInfo);
+
+  vas = new VAudioSelector(this, availableAudioChannels, currentAudioChannel, myRec->recInfo);
+  vas->setBackgroundColour(barBlue);
+  if (video->getFormat() == Video::PAL)
+  {
+//    vas->setScreenPos(62, barRegion.y - 120);
+    vas->setScreenPos(0, barRegion.y - 120);
+  }
+  else
+  {
+//    vas->setScreenPos(57, barRegion.y - 120);
+    vas->setScreenPos(0, barRegion.y - 120);
+  }
+
+  barVasHold = true;
+  doBar(0);
 
   vas->draw();
   viewman->add(vas);
@@ -470,16 +519,14 @@ void VVideoRec::doBar(int action)
 
   viewman->updateView(this, &barRegion);
 
-  if ((playerState == Player::S_FFWD) || (playerState == Player::S_FBWD))
-  {
-    timers->cancelTimer(this, 1);
-    stickyBar = true;
-  }
-  else
-  {
-    timers->setTimerD(this, 1, 4); // only set the getridofbar timer if not ffwd/fbwd
-    stickyBar = false;
-  }
+  timers->cancelTimer(this, 1);
+
+
+  if ((playerState == Player::S_FFWD) || (playerState == Player::S_FBWD)) barScanHold = true;
+  else barScanHold = false;
+
+  if (!barGenHold && !barScanHold && !barVasHold) timers->setTimerD(this, 1, 4);
+
   timers->setTimerD(this, 2, 0, 200000000);
 }
 
@@ -507,17 +554,17 @@ void VVideoRec::timercall(int clientReference)
 
 void VVideoRec::drawBarClocks()
 {
-  if (stickyBar)
+  if (barScanHold)
   {
     UCHAR playerState = player->getState();
     // sticky bar is set if we are in ffwd/fbwd mode
     // if player has gone to S_PLAY then kill stickyBar, and run doBar(0) which
     // will repaint all the bar (it will call this function again, but
-    // this section won't run because stickyBar will then == false)
+    // this section won't run because stickyBarF will then == false)
 
     if ((playerState != Player::S_FFWD) && (playerState != Player::S_FBWD))
     {
-      stickyBar = false;
+      barScanHold = false;
       doBar(0);
       return; // doBar will call this function and do the rest
     }
@@ -617,7 +664,9 @@ void VVideoRec::removeBar()
   if (!barShowing) return;
   timers->cancelTimer(this, 2);
   barShowing = false;
-  stickyBar = false;
+  barGenHold = false;
+  barScanHold = false;
+  barVasHold = false;
   rectangle(barRegion, transparent);
   viewman->updateView(this, &barRegion);
 }
index 0a24aa6c71cf24d9ffa292b0a97781d15488836f..b03a40f87b5712e0d972af846f268d54e8ae695e 100644 (file)
@@ -40,6 +40,7 @@
 //#include "vepg.h" // for testing EPG in NTSC with a NTSC test video
 
 class Timers;
+class VAudioSelector;
 
 class VVideoRec : public View, public TimerReceiver
 {
@@ -61,6 +62,8 @@ class VVideoRec : public View, public TimerReceiver
     Player* player;
     Recording* myRec;
 
+    VAudioSelector* vas;
+
     Colour transparent;
     Colour barBlue;
 
@@ -68,10 +71,13 @@ class VVideoRec : public View, public TimerReceiver
     void toggleChopSides();
 
     bool playing;
-    bool barShowing;
-    bool stickyBar;
     bool isRadio;
 
+    bool barShowing;
+    bool barGenHold;
+    bool barScanHold;
+    bool barVasHold;
+
     void doAudioSelector();
     void doBar(int action);
     void drawBarClocks();
index a5255192b9cbed83b23d37ba4ae759cc65a414e6..dc332c359955b2a64a5f62d268b8b4b2bb77c17c 100644 (file)
--- a/widget.cc
+++ b/widget.cc
@@ -22,6 +22,7 @@
 
 Widget::Widget()
 {
+  backgroundColour = Colour::VIEWBACKGROUND;
 }
 
 Widget::~Widget()
@@ -39,6 +40,11 @@ void Widget::setDimensions(int twidth, int theight)
   area.h = theight;
 }
 
+void Widget::setBackgroundColour(Colour& Tcolour)
+{
+  backgroundColour = Tcolour;
+}
+
 int Widget::getOffsetY()
 {
   return offsetY;
index fee77ddd46612f5f422670459ca6e0126843d8b4..c57200978811839dfc144959557f80c354bdbdd2 100644 (file)
--- a/widget.h
+++ b/widget.h
@@ -34,6 +34,7 @@ class Widget : public Box
     virtual void draw()=0;
     void setSurface(Surface* tsurface);
     void setDimensions(int width, int height);
+    void setBackgroundColour(Colour& colour);
     int getOffsetY();
     int getOffsetX();
 
@@ -41,6 +42,7 @@ class Widget : public Box
   private:
 
   protected:
+    Colour backgroundColour;
 };
 
 #endif
index e27593c9cb88c625db3c2cf2aaa43064c4c47803..21b6d98251f99e2ef575d1beebfdce7284c6f86d 100644 (file)
@@ -98,7 +98,7 @@ void WSelectList::draw()
 
 
 
-  fillColour(Colour::VIEWBACKGROUND);
+  fillColour(backgroundColour);
 
   UINT ypos = 5;
   for (UINT i = topOption; i < (topOption + numOptionsDisplayable); i++)