]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Another stab at radio support, fix for chasing playback
authorChris Tallon <chris@vomp.tv>
Thu, 11 Aug 2005 23:15:01 +0000 (23:15 +0000)
committerChris Tallon <chris@vomp.tv>
Thu, 11 Aug 2005 23:15:01 +0000 (23:15 +0000)
14 files changed:
Makefile
audio.cc
player.cc
player.h
playerradio.cc
playerradio.h
vchannellist.cc
vdr.cc
vdr.h
vlivebanner.cc
vvideolive.cc
vvideolive.h
vvideorec.cc
vvideorec.h

index cef5d10fe9bf0811df69f38b0fa4a8d4c25d08fb..44c165191367cb66a10a2772121e67d8f63b304a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ CROSSLIBS = ../jpeg-6b/libjpeg.a
 
 OBJECTS = main.o command.o log.o remote.o led.o mtd.o video.o audio.o tcp.o directory.o thread.o \
           player.o demuxer.o stream.o vfeed.o afeed.o afeedr.o osd.o surface.o viewman.o vdr.o dsock.o box.o \
-          list.o queue.o node.o recording.o channel.o message.o playerradio.o messagequeue.o \
+          list.o queue.o node.o recording.o channel.o message.o playervideo.o playerradio.o messagequeue.o \
           view.o vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o \
           vrecordingmenu.o vquestion.o vchannellist.o vwelcome.o vvideolive.o vvideorec.o vradiolive.o \
           vchannelselect.o vserverselect.o colour.o vconnect.o voptions.o \
index bacdc8fef615361bdfb986651c1a54d8c08877f7..80179efc90abd78985595e291fc0bbe1d5893805 100644 (file)
--- a/audio.cc
+++ b/audio.cc
@@ -207,8 +207,21 @@ int Audio::setVolume(int volume)
 
 int Audio::test()
 {
-  ULLONG stc = 0;
-  return ioctl(fdAudio, AV_SET_AUD_STC, &stc);
+//  ULLONG stc = 0;
+//  return ioctl(fdAudio, AV_SET_AUD_STC, &stc);
+
+  aud_sync_parms_t a;
+  a.parm1 = 0;
+  a.parm2 = 0;
+
+  int b = ioctl(fdAudio, AV_SET_AUD_DISABLE_SYNC, &a);
+
+
+  printf("Audio sync disable = %i\n", b);
+
+  return 1;
+
+
 }
 
 int Audio::volumeUp()
index 27bb9b7d922a3cce0948b0137b6afc67eb117cae..3d07a1e1872b65856be0b11ff9b0c15c2bfd6f8d 100644 (file)
--- a/player.cc
+++ b/player.cc
 
 #include "player.h"
 
-Player::Player(MessageQueue* messageQueue)
-: vfeed(this), afeed(this)
+Player::Player()
 {
   initted = 0;
-  commandMessageQueue = messageQueue;
-
-  paused = 0;
-  playing = 0;
-  ffwd = 0;
-  fbwd = 0;
-  feedPosition = 0;
-  feedMode = MODE_NORMAL;
 
   streamLength = 0;
   // FIXME - this might need settings back to zero for new live play depending on what is done with it
-}
-
-Player::~Player()
-{
-  if (initted) shutdown();
-}
 
-int Player::init()
-{
-  if (initted) return 0;
-
-  video = Video::getInstance();
   audio = Audio::getInstance();
-
-  if (demuxer.init()) // inverted
-  {
-    Log::getInstance()->log("Player", Log::ERR, "Demuxer failed to init");
-    shutdown();
-    return 0;
-  }
-
-  vfeed.init(video->getFD());
-  afeed.init(audio->getFD());
-
-  video->stop();
-  video->blank();
-  audio->stop();
-
-  startup = 0;
-  initted = 1;
-  return 1;
-}
-
-int Player::shutdown()
-{
-  if (!initted) return 0;
-  initted = 0;
-
-  Log::getInstance()->log("Player", Log::DEBUG, "Player shutdown...");
-
-  // copy of stop
-  if (playing)
-  {
-    playing = 0;
-    threadStop();
-    video->stop();
-    video->blank();
-    audio->stop();
-    vfeed.stop();
-    afeed.stop();
-    video->reset();
-    demuxer.reset();
-    feedPosition = 0;
-  }
-
-  return 1;
-}
-
-int Player::play()
-{
-  if (!initted) return 0;
-
-  // If we are just paused, unpause!
-  if (paused)
-  {
-    togglePause();
-    return 1;
-  }
-
-  // If we are fast forwarding, set to normal
-  if (ffwd)
-  {
-    toggleFastForward();
-    return 1;
-  }
-
-  // If we are fast backwarding, set to normal
-  if (fbwd)
-  {
-    toggleFastBackward();
-    return 1;
-  }
-
-  // If we are already playing, bail // FIXME - resync?
-  if (playing)
-  {
-    Log::getInstance()->log("Player", Log::DEBUG, "DOING RESYNC");
-
-/*
-    vfeed.stop();
-    afeed.stop();
-    video->reset();
-    audio->reset();
-    demuxer.flush();
-    demuxer.seek();
-    vfeed.start();
-    afeed.start();
-
-
-    video->play();
-    audio->play();
-    video->sync();
-    audio->sync();
-    call();
-*/
-
-    // resync method 2..
-
-    video->pause();
-    usleep(500000);
-    video->play();
-    video->sync();
-
-
-    return 1;
-  }
-
-  // Standard play start
-
-  audio->reset();
-  video->reset();
-  demuxer.reset();
-  startup = 1;
-
-// ------------------------ This one works, but doesn't allow any pre-buffering.
-  threadStart();
-  vfeed.start();
-  afeed.start();
-  audio->play();
-  video->play();
-  video->sync();
-  audio->sync();
-
-  video->pause();
-      usleep(500000); // SYNC
-  video->sync();
-  video->unPause();
-  video->sync();
-
-// ------------------------ This one doesn't work, but it should, and would allow for prebuffering.
-
-/*
-
-  threadStart();
-  sleep(2);
-
-//  struct timespec delay;
-//  delay.tv_sec = 1;
-//  delay.tv_nsec = 500000000;
-//  nanosleep(&delay, NULL);
-
-  vfeed.start();
-  afeed.start();
-  video->play();
-  audio->play();
-  video->sync();
-  audio->sync();
-*/
-// ------------------------------------------------------------------------------------------------
-
-  playing = 1;
-  return 1;
-}
-
-void Player::stop()
-{
-  if (!initted) return;
-  if (!playing) return;
-
-  if (ffwd || fbwd)
-  {
-    ffwd = 0;
-    fbwd = 0;
-    afeed.enable();
-    video->unFastForward();
-    audio->systemMuteOff();
-    feedMode = MODE_NORMAL;
-  }
-
-  playing = 0;
-  paused = 0;
-
-  threadStop();
-  video->stop();
-  video->blank();
-  audio->stop();
-  audio->unPause();
-  vfeed.stop();
-  afeed.stop();
-  video->reset();
-  demuxer.reset();
-
-  feedPosition = 0;
 }
 
-void Player::togglePause()
-{
-  if (!initted) return;
-  if (!playing) return;
-
-  if (ffwd) toggleFastForward();
-  if (fbwd) toggleFastBackward();
-
-  if (paused)
-  {
-    video->unPause();
-    audio->unPause();
-    paused = 0;
-  }
-  else
-  {
-    video->pause();
-    audio->pause();
-    paused = 1;
-  }
-}
-
-void Player::test()
-{
-  Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST");
-
-/*
-
-//  video->test();
-
-  static int flipflop = 0;
-
-  int a;
-  if (flipflop) a = video->setAspectRatio(Video::ASPECT16X9);
-  else a = video->setAspectRatio(Video::ASPECT4X3);
-
-  flipflop = !flipflop;
-
-  printf("A = %i\n", a);
-*/
-}
-
-void Player::test2()
-{
-  Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST");
-
-  video->test2();
-}
-
-void Player::setPosition(ULLONG position)
-{
-  feedPosition = position;
-}
-
-void Player::setLength(ULLONG length)
-{
-  streamLength = length;
-  Log::getInstance()->log("Player", Log::DEBUG, "Player has received length of %llu", streamLength);
-}
-
-void Player::skipForward(int seconds)
-{
-  // skip forward 1 minute
-  Log::getInstance()->log("Player", Log::DEBUG, "SKIP FORWARD %i SECONDS", seconds);
-
-  if (paused) togglePause();
-
-  ULLONG moveBy = seconds * 500000;
-
-  threadStop();
-  vfeed.stop();
-  afeed.stop();
-  video->stop();
-  video->reset();
-  audio->reset();
-  audio->doMuting();  // ???
-  demuxer.flush();
-  feedPosition += moveBy;
-
-  printf("Audio test %i\n", audio->test());
-
-  vfeed.start();
-  afeed.start();
-  threadStart();
-  audio->play();
-  video->play();
-  video->sync();
-  audio->sync();
-
-  video->pause();
-      usleep(500000); // SYNC
-  video->sync();
-  video->unPause();
-  video->sync();
-
-}
-
-void Player::skipBackward(int seconds)
-{
-  // skip forward 1 minute
-  Log::getInstance()->log("Player", Log::DEBUG, "SKIP BACKWARD %i SECONDS", seconds);
-
-  if (paused) togglePause();
-
-  ULLONG moveBy = seconds * 500000;
-
-  threadStop();
-  vfeed.stop();
-  afeed.stop();
-  video->stop();
-  audio->stop();
-  video->reset();
-  audio->reset();
-  audio->doMuting(); // ???
-  demuxer.flush();
-  if (feedPosition > moveBy) feedPosition -= moveBy;
-  vfeed.start();
-  afeed.start();
-  threadStart();
-  audio->play();
-  video->play();
-  video->sync();
-  audio->sync();
-
-  video->pause();
-      usleep(500000); // SYNC
-  video->sync();
-  video->unPause();
-  video->sync();
-
-}
-
-void Player::toggleFastForward()
-{
-  if (!initted) return;
-  if (!playing) return;
-
-  if (paused) togglePause();
-  if (fbwd) toggleFastBackward();
-
-  if (ffwd)
-  {
-    ffwd = 0;
-//    video->unFastForward();
-
-
-    threadStop();
-    vfeed.stop();
-    afeed.stop();
-    video->stop();
-    audio->stop();
-    video->reset();
-    audio->reset();
-    demuxer.flush();
-//    demuxer.seek();
-    vfeed.start();
-    afeed.enable();
-    afeed.start();
-    threadStart();
-    video->play();
-    audio->play();
-    video->sync();
-    audio->sync();
-
-    audio->systemMuteOff();
-
-    video->pause();
-        usleep(500000); // SYNC
-    video->sync();
-    video->unPause();
-    video->sync();
-
-/*
-    demuxer.flushAudio();
-    audio->reset();
-    afeed.enable();
-    //video->reset();
-    audio->play();
-    video->play();
-    video->sync();
-    audio->sync();
-    audio->systemMuteOff();
-*/
-  }
-  else
-  {
-    ffwd = 1;
-    afeed.disable();
-    audio->systemMuteOn();
-    video->fastForward();
-  }
-}
-
-void Player::toggleFastBackward()
-{
-  if (!initted) return;
-  if (!playing) return;
-
-  if (paused) togglePause();
-  if (ffwd) toggleFastForward();
-
-  if (fbwd)
-  {
-    fbwd = 0;
-    afeed.enable();
-    audio->systemMuteOff();
-
-//    threadStop();
-    feedMode = MODE_NORMAL;
-//    threadStart();
-  }
-  else
-  {
-    fbwd = 1;
-    afeed.disable();
-    audio->systemMuteOn();
-
-    threadStop();
-    feedMode = MODE_BACKWARDS;
-    video->reset();
-    video->play();
-    demuxer.flush();
-    threadStart();
-  }
-}
-
-void Player::jumpToPercent(int percent)
-{
-  threadStop();
-  vfeed.stop();
-  afeed.stop();
-  video->stop();
-  audio->stop();
-  video->reset();
-  audio->reset();
-  demuxer.flush();
-  demuxer.seek();
-  feedPosition = streamLength * percent / 100;
-  vfeed.start();
-  afeed.start();
-  threadStart();
-  audio->play();
-  video->play();
-  video->sync();
-  audio->sync();
-
-  video->pause();
-      usleep(500000); // SYNC
-  video->sync();
-  video->unPause();
-  video->sync();
-}
-
-
-void Player::call()
-{
-  threadSignalNoLock();
-}
-
-// Feed thread
-
-void Player::threadMethod()
-{
-  UCHAR buf[blockSize];
-  int thisRead;
-  int writeLength;
-  int thisWrite;
-
-  VDR* vdr = VDR::getInstance();
-
-  int askFor;
-  while(1)
-  {
-    thisRead = 0;
-    writeLength = 0;
-    thisWrite = 0;
-
-    threadCheckExit();
-
-    // a bit hackey. this needs to be split to live and rec players
-    if (streamLength && (feedPosition >= streamLength)) break;
-    askFor = blockSize;
-    if (streamLength && ((feedPosition + blockSize) > streamLength))
-    {
-      askFor = streamLength - feedPosition;
-    }
-    thisRead = vdr->getBlock(buf, feedPosition, askFor);
-    if (startup)
-    {
-      int a_stream = demuxer.scan(buf, thisRead);
-      demuxer.setAudioStream(a_stream);
-      Log::getInstance()->log("Player", Log::DEBUG, "Startup Audio stream chosen %x", a_stream);
-      startup = 0;
-    }
-
-    if (feedMode == MODE_NORMAL)
-    {
-      feedPosition += thisRead;
-    }
-    else if (feedMode == MODE_BACKWARDS)
-    {
-      if (feedPosition >= 100000)
-      {
-        feedPosition -= 100000;
-        demuxer.seek();
-      }
-      else
-      {
-        // got to the start of the recording.. revert to play mode? how?
-        feedPosition += thisRead;
-      }
-    }
-
-    threadCheckExit();
-
-    while(writeLength < thisRead)
-    {
-      thisWrite = demuxer.put(buf + writeLength, thisRead - writeLength);
-      writeLength += thisWrite;
-
-      if (!thisWrite)
-      {
-        Log::getInstance()->log("Player", Log::DEBUG, "DEMUXER FULL!!!");
-        // demuxer is full and cant take anymore
-        threadWaitForSignal();
-        Log::getInstance()->log("Player", Log::DEBUG, "BACK FROM WAIT");
-      }
-
-      threadCheckExit();
-    }
-  }
-
-  // end of recording
-  Log::getInstance()->log("Player", Log::DEBUG, "Recording playback ends");
-  Message* m = new Message();
-  m->message = Message::STOP_PLAYBACK;
-  Log::getInstance()->log("Player", Log::DEBUG, "Posting message...");
-  commandMessageQueue->postMessage(m);
-  Log::getInstance()->log("Player", Log::DEBUG, "Message posted...");
-
-
-}
+Player::~Player() {}
index ca9183ba0bf4d584cbeb0c525373f49029dcff38..65bf70f45e93fd8c01f6f62dcdbbbb2a8bd57095 100644 (file)
--- a/player.h
+++ b/player.h
 #ifndef PLAYER_H
 #define PLAYER_H
 
-#include <stdio.h>
-
-#include "audio.h"
-#include "video.h"
-#include "demuxer.h"
-#include "vfeed.h"
-#include "afeed.h"
-#include "remote.h"
 #include "thread.h"
-#include "vdr.h"
 #include "callback.h"
-#include "message.h"
-#include "messagequeue.h"
+#include "defines.h"
+#include "log.h"
+#include "audio.h"
 
 class Player : public Thread, public Callback
 {
   public:
-    Player(MessageQueue* messageQueue);
+    Player();
     virtual ~Player();
-
-    int init();
-    int shutdown();
-
-    int play();
-    void stop();
-    void togglePause();
-    void toggleFastForward();
-    void toggleFastBackward();
-    void jumpToPercent(int percent);
-    void skipForward(int seconds);
-    void skipBackward(int seconds);
-    void test();
-    void test2();
-    void call(); // for callback interface
-    void setPosition(ULLONG position);
-    void setLength(ULLONG length);
-
-    void threadMethod();
-
-  private:
+    virtual int init()=0;
+    virtual int shutdown()=0;
+    virtual int play()=0;
+    virtual void stop()=0;
+    virtual void togglePause()=0;
+    virtual void toggleFastForward()=0;
+    virtual void toggleFastBackward()=0;
+    virtual void jumpToPercent(int percent)=0;
+    virtual void skipForward(int seconds)=0;
+    virtual void skipBackward(int seconds)=0;
+    virtual void test()=0;
+    virtual void test2()=0;
+    virtual void setPosition(ULLONG position)=0;
+    virtual void setLength(ULLONG length)=0;
+
+    virtual void call()=0; // for callback interface
+    virtual void threadMethod()=0; // for thread interface
+
+  protected:
     int initted;
-    MessageQueue* commandMessageQueue;
-    Video* video;
-    Audio* audio;
-    Demuxer demuxer;
-    int startup;
-    VFeed vfeed;
-    AFeed afeed;
     ULLONG streamLength;
-    ULLONG feedPosition;
-    UCHAR feedMode;
-    const static UCHAR MODE_NORMAL = 1;
-    const static UCHAR MODE_BACKWARDS = 2;
-    const static int blockSize = 100000;
+    Audio* audio;
 
-    UCHAR playing;    // As in not stopped, (playing && paused) can == TRUE
-    UCHAR paused;     // Must be in playing state as well
-    UCHAR ffwd;       // Must be in playing state as well
-    UCHAR fbwd;       // Must be in playing state as well
 };
 
 #endif
index b8f05cefdf4b0313bec2c332ea64340d3e429844..0c791345b2c4a8eb4e3926394d6ad9763e12aad7 100644 (file)
 PlayerRadio::PlayerRadio()
 : afeedr(this, &stream)
 {
-  initted = 0;
-
   paused = 0;
   playing = 0;
   ffwd = 0;
   fbwd = 0;
   feedPosition = 0;
   feedMode = MODE_NORMAL;
-
-  streamLength = 0;
-  // FIXME - this might need settings back to zero for new live play depending on what is done with it
 }
 
 PlayerRadio::~PlayerRadio()
@@ -49,12 +44,12 @@ int PlayerRadio::init()
 {
   if (initted) return 0;
 
-  audio = Audio::getInstance();
   stream.init(120000);
   afeedr.init(audio->getFD());
 
   audio->stop();
 
+
   initted = 1;
   return 1;
 }
@@ -113,6 +108,7 @@ int PlayerRadio::play()
     audio->reset();
     afeedr.start();
 
+
     audio->play();
     call();
 
@@ -122,6 +118,7 @@ int PlayerRadio::play()
   // Standard play start
 
   audio->reset();
+  audio->stop();
 
 /*
 // ------------------------ This one works, but doesn't allow any pre-buffering.
@@ -133,6 +130,7 @@ int PlayerRadio::play()
 // ------------------------ This one doesn't work, but it should, and would allow for prebuffering.
 */
 
+    audio->test();
   threadStart();
     sleep(6);
 
@@ -141,6 +139,7 @@ int PlayerRadio::play()
 //  delay.tv_nsec = 500000000;
 //  nanosleep(&delay, NULL);
 
+
   afeedr.start();
   audio->play();
 //  audio->sync();
@@ -191,7 +190,7 @@ void PlayerRadio::setPosition(ULLONG position)
 void PlayerRadio::setLength(ULLONG length)
 {
   streamLength = length;
-  Log::getInstance()->log("PlayerRadio", Log::DEBUG, "PlayerRadio has received length of %llu", streamLength);
+  Log::getInstance()->log("PlayerRadio", Log::DEBUG, "Player has received length of %llu", streamLength);
 }
 
 void PlayerRadio::skipForward()
@@ -299,7 +298,8 @@ void PlayerRadio::jumpToPercent(int percent)
 
 void PlayerRadio::call()
 {
-  threadSignalNoLock();
+  Log::getInstance()->log("PlayerRadio", Log::DEBUG, "playerradio called\n");
+//  threadSignalNoLock();
 }
 
 // Feed thread
@@ -331,6 +331,11 @@ void PlayerRadio::threadMethod()
     }
     thisRead = vdr->getBlock(buf, feedPosition, askFor);
 
+    // temp
+    printf("Written direct: %i\n", write(audio->getFD(), buf, thisRead));
+
+
+
     if (feedMode == MODE_NORMAL)
     {
       feedPosition += thisRead;
@@ -350,23 +355,25 @@ void PlayerRadio::threadMethod()
 
     threadCheckExit();
 
-    while(writeLength < thisRead)
+/*    while(writeLength < thisRead)
     {
       thisWrite = stream.put(buf + writeLength, thisRead - writeLength);
+      Log::getInstance()->log("PlayerRadio", Log::DEBUG, "Just put %i to stream", thisWrite);
+
       writeLength += thisWrite;
 
       if (!thisWrite)
       {
-        Log::getInstance()->log("Player", Log::DEBUG, "RADIO OUTPUT STREAM FULL!!!");
+        Log::getInstance()->log("PlayerRadio", Log::DEBUG, "RADIO OUTPUT STREAM FULL!!!");
         // stream is full and cant take anymore
         threadWaitForSignal();
-        Log::getInstance()->log("Player", Log::DEBUG, "BACK FROM WAIT");
+        Log::getInstance()->log("PlayerRadio", Log::DEBUG, "BACK FROM WAIT");
       }
 
       threadCheckExit();
     }
 
     Log::getInstance()->log("PlayerRadio", Log::DEBUG, "Written audio");
-
+*/
   }
 }
index ba172953e294a6d5131494e93d9879aa95ef9a5a..eb79b851fe4800c628aecca22280b7a41156051a 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <stdio.h>
 
+#include "player.h"
 #include "audio.h"
 #include "afeedr.h"
 #include "remote.h"
@@ -31,7 +32,7 @@
 #include "callback.h"
 #include "stream.h"
 
-class PlayerRadio : public Thread, public Callback
+class PlayerRadio : public Player
 {
   public:
     PlayerRadio();
@@ -54,18 +55,19 @@ class PlayerRadio : public Thread, public Callback
 
     void threadMethod();
 
+    void skipForward(int) {};
+    void skipBackward(int) {};
+    void test() {};
+    void test2() {};
+
   private:
-    int initted;
-    Audio* audio;
-    int startup;
     Stream stream;
     AFeedR afeedr;
-    ULLONG streamLength;
     ULLONG feedPosition;
     UCHAR feedMode;
     const static UCHAR MODE_NORMAL = 1;
     const static UCHAR MODE_BACKWARDS = 2;
-    const static int blockSize = 30000;
+    const static int blockSize = 2000;
 
     UCHAR playing;    // As in not stopped, (playing && paused) can == TRUE
     UCHAR paused;     // Must be in playing state as well
index 1dcdeabdc6484b17d8f0950dd3fd1ff4daa1ebd1..b6207917b8d8328bf95752c0ed6507acb20601f2 100644 (file)
@@ -191,21 +191,8 @@ int VChannelList::handleCommand(int command)
 
       if (chan == NULL) return 2;
 
-      View* v = NULL;
-
-  // stop radio
-  //    if (chan->type == VDR::RADIO) return 2;
-
-      if (chan->type == VDR::VIDEO)
-      {
-        v = new VVideoLive(chanList);
-        ((VVideoLive*)v)->setChannel(chan->number);
-      }
-      else if (chan->type == VDR::RADIO)
-      {
-        v = new VRadioLive(chanList);
-        ((VRadioLive*)v)->setChannel(chan->number);
-      }
+      VVideoLive* v = new VVideoLive(chanList, chan->type);
+      v->setChannel(chan->number);
 
       ViewMan::getInstance()->addNoLock(v);
       v->draw();
diff --git a/vdr.cc b/vdr.cc
index 093fcc971d8ec64c36e098524f94ef1b66a6fbe5..e1a899953d051fc1080c64b09f267c9e18a0f4ea 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -537,6 +537,40 @@ ULLONG VDR::streamRecording(Recording* rec)
   return recordingLength;
 }
 
+ULLONG VDR::rescanRecording()
+{
+  unsigned long totalLength = 8;
+  UCHAR buffer[totalLength];
+
+  *(unsigned long*)&buffer[0] = htonl(totalLength - 4);
+  *(unsigned long*)&buffer[4] = htonl(VDR_RESCANRECORDING);
+
+  pthread_mutex_lock(&mutex);
+  unsigned int a = tcp->sendPacket(buffer, totalLength);
+  if (a != totalLength)
+  {
+    pthread_mutex_unlock(&mutex);
+    return 0;
+  }
+
+  unsigned char* p = (unsigned char*)tcp->receivePacket();
+  pthread_mutex_unlock(&mutex);
+  if (!p) return 0;
+
+  if (tcp->getDataLength() != 8)
+  {
+    free(p);
+    return 0;
+  }
+
+  ULLONG recordingLength = ntohll(*(ULLONG*)p);
+
+  Log::getInstance()->log("VDR", Log::DEBUG, "VDR said length is: %llu", recordingLength);
+  free(p);
+
+  return recordingLength;
+}
+
 int VDR::getChannelSchedule(ULONG number)
 {
   UCHAR buffer[12];
diff --git a/vdr.h b/vdr.h
index 9144a151a9eb452697db2de0069437db3a05a04b..072adf8a263e6c25954f4269ddca19e434120195 100644 (file)
--- a/vdr.h
+++ b/vdr.h
@@ -62,6 +62,7 @@ class VDR
     char*      getRecordingSummary(char* fileName);
     int        deleteRecording(char* fileName);
     ULLONG     streamRecording(Recording* rec);
+    ULLONG     rescanRecording();
 
     List*      getChannelsList(ULONG type);
     int        streamChannel(ULONG number);
@@ -99,6 +100,7 @@ class VDR
     const static ULONG VDR_GETCHANNELSCHEDULE  = 10;
     const static ULONG VDR_CONFIGSAVE          = 11;
     const static ULONG VDR_CONFIGLOAD          = 12;
+    const static ULONG VDR_RESCANRECORDING     = 13;
 
     long getSimpleReply();
     char* getStringReply();
index a27de942a57d19c5580a96f1956b500c635d7417..6d830e57e105084a5d338346d7e8aaa340bec2c8 100644 (file)
@@ -50,7 +50,8 @@ VLiveBanner::~VLiveBanner()
 
 void VLiveBanner::draw()
 {
-  int success = VDR::getInstance()->getChannelSchedule(1);
+//int success = VDR::getInstance()->getChannelSchedule(1);
+int success = 0;
 
   if (!success)
   {
index 5c43babe849bfa7addf5b1ff3161e515306a584e..e1d1a67eb71f7ba36c3395ea969ac3f65d62e7f2 100644 (file)
 
 #include "vvideolive.h"
 
-VVideoLive::VVideoLive(List* tchanList)
+VVideoLive::VVideoLive(List* tchanList, ULONG tstreamType)
 {
-  player = new Player(NULL);
-  player->init();
   vdr = VDR::getInstance();
   viewman = ViewMan::getInstance();
   chanList = tchanList;
   currentChannel = NULL;
   unavailable = 0;
   unavailableView = NULL;
+  streamType = tstreamType;
+  if (streamType == VDR::VIDEO)
+  {
+    player = new PlayerVideo(NULL, 0);
+  }
+  else
+  {
+    player = new PlayerRadio();
+  }
+  player->init();
 
   Video* video = Video::getInstance();
   setDimensions(video->getScreenHeight(), video->getScreenWidth());
index 3298c25e694a7bf0f4f8e02ad6a3fac8f01d4814..ad75714cb1fa96ba6d108b11d337985d81044603 100644 (file)
@@ -24,7 +24,8 @@
 #include <stdio.h>
 
 #include "view.h"
-#include "player.h"
+#include "playervideo.h"
+#include "playerradio.h"
 #include "vdr.h"
 #include "list.h"
 #include "channel.h"
@@ -38,7 +39,7 @@
 class VVideoLive : public View
 {
   public:
-    VVideoLive(List* chanList);
+    VVideoLive(List* chanList, ULONG streamType);
     ~VVideoLive();
     void draw();
     int handleCommand(int command);
@@ -57,6 +58,7 @@ class VVideoLive : public View
     Channel* currentChannel;
     int unavailable;
     VInfo* unavailableView;
+    ULONG streamType;
 
     void upChannel();
     void downChannel();
index 73cc08caf3d663530873cdf72659f315786a85df..5325dbc6b5c80521f9eafa5e8644206f9ea1844d 100644 (file)
@@ -22,7 +22,7 @@
 
 VVideoRec::VVideoRec(Recording* rec)
 {
-  player = new Player(Command::getInstance());
+  player = new PlayerVideo(Command::getInstance(), 1);
   player->init();
   vdr = VDR::getInstance();
 
index c1d2632a92f2c12a4ad2d213da0c46e5a2aef5f0..f33c1c73fdcdb0638c6ba47ca6656ae391feef93 100644 (file)
@@ -24,7 +24,7 @@
 #include <stdio.h>
 
 #include "view.h"
-#include "player.h"
+#include "playervideo.h"
 #include "vdr.h"
 #include "recording.h"
 #include "command.h"