diff options
| -rw-r--r-- | dvbapi.c | 112 | ||||
| -rw-r--r-- | dvbapi.h | 17 | ||||
| -rw-r--r-- | dvbosd.c | 12 | ||||
| -rw-r--r-- | dvbosd.h | 3 | ||||
| -rw-r--r-- | interface.c | 8 | ||||
| -rw-r--r-- | interface.h | 3 | ||||
| -rw-r--r-- | menu.c | 45 | ||||
| -rw-r--r-- | menu.h | 3 | 
8 files changed, 101 insertions, 102 deletions
| @@ -4,7 +4,7 @@   * See the main source file 'vdr.c' for copyright information and   * how to reach the author.   * - * $Id: dvbapi.c 1.41 2000/12/08 15:29:27 kls Exp $ + * $Id: dvbapi.c 1.42 2000/12/09 11:04:07 kls Exp $   */  #include "dvbapi.h" @@ -81,6 +81,18 @@ static void SetPlayMode(int VideoDev, int Mode)       }  } +const char *IndexToStr(int Index, bool WithFrame) +{ +  static char buffer[16]; +  int f = (Index % FRAMESPERSEC) + 1; +  int s = (Index / FRAMESPERSEC); +  int m = s / 60 % 60; +  int h = s / 3600; +  s %= 60; +  snprintf(buffer, sizeof(buffer), WithFrame ? "%d:%02d:%02d.%02d" : "%d:%02d:%02d", h, m, s, f); +  return buffer; +} +  // --- cResumeFile ------------------------------------------------------------  cResumeFile::cResumeFile(const char *FileName) @@ -152,7 +164,6 @@ public:    int Last(void) { return last; }    int GetResume(void) { return resumeFile.Read(); }    bool StoreResume(int Index) { return resumeFile.Save(Index); } -  static char *Str(int Index, bool WithFrame = false);    };  cIndexFile::cIndexFile(const char *FileName, bool Record) @@ -347,18 +358,6 @@ int cIndexFile::Get(uchar FileNumber, int FileOffset)    return -1;  } -char *cIndexFile::Str(int Index, bool WithFrame) -{ -  static char buffer[16]; -  int f = (Index % FRAMESPERSEC) + 1; -  int s = (Index / FRAMESPERSEC); -  int m = s / 60 % 60; -  int h = s / 3600; -  s %= 60; -  snprintf(buffer, sizeof(buffer), WithFrame ? "%d:%02d:%02d.%02d" : "%d:%02d:%02d", h, m, s, f); -  return buffer; -} -  // --- cRingBuffer -----------------------------------------------------------  /* cRingBuffer reads data from an input file, stores it in a buffer and writes @@ -913,7 +912,7 @@ void cReplayBuffer::Action(void)    int ResumeIndex = Resume();    if (ResumeIndex >= 0) -     isyslog(LOG_INFO, "resuming replay at index %d (%s)", ResumeIndex, cIndexFile::Str(ResumeIndex, true)); +     isyslog(LOG_INFO, "resuming replay at index %d (%s)", ResumeIndex, IndexToStr(ResumeIndex, true));    active = true;    for (; active;) {        usleep(1); // this keeps the CPU load low @@ -1290,8 +1289,6 @@ cDvbApi::cDvbApi(const char *VideoFileName, const char *VbiFileName)  #else    osd = NULL;  #endif -  lastProgress = lastTotal = -1; -  replayTitle = NULL;    currentChannel = 1;  } @@ -1310,7 +1307,6 @@ cDvbApi::~cDvbApi()  #if defined(DEBUG_OSD) || defined(REMOTE_KBD)    endwin();  #endif -  delete replayTitle;  }  bool cDvbApi::SetPrimaryDvbApi(int n) @@ -1717,8 +1713,6 @@ void cDvbApi::Open(int w, int h)    SETCOLOR(clrCyan,        0x00, 0xFC, 0xFC, 255);    SETCOLOR(clrMagenta,     0xB0, 0x00, 0xFC, 255);    SETCOLOR(clrWhite,       0xFC, 0xFC, 0xFC, 255); - -  lastProgress = lastTotal = -1;  }  void cDvbApi::Close(void) @@ -1732,7 +1726,6 @@ void cDvbApi::Close(void)    delete osd;    osd = NULL;  #endif -  lastProgress = lastTotal = -1;  }  void cDvbApi::Clear(void) @@ -1761,6 +1754,13 @@ void cDvbApi::Fill(int x, int y, int w, int h, eDvbColor color)  #endif  } +void cDvbApi::SetBitmap(int x, int y, const cBitmap &Bitmap) +{ +#ifndef DEBUG_OSD +  osd->SetBitmap(x, y, Bitmap); +#endif +} +  void cDvbApi::ClrEol(int x, int y, eDvbColor color)  {    Fill(x, y, cols - x, 1, color); @@ -1775,6 +1775,15 @@ int cDvbApi::CellWidth(void)  #endif  } +int cDvbApi::LineHeight(void) +{ +#ifdef DEBUG_OSD +  return 1; +#else +  return lineHeight; +#endif +} +  int cDvbApi::Width(unsigned char c)  {  #ifdef DEBUG_OSD @@ -1823,58 +1832,6 @@ void cDvbApi::Flush(void)  #endif  } -bool cDvbApi::ShowProgress(bool Initial) -{ -  int Current, Total; - -  if (GetIndex(Current, Total)) { -     if (Initial) { -        Clear(); -        if (replayTitle) -           Text(0, 0, replayTitle); -        } -     if (Total != lastTotal) -        Text(-7, 2, cIndexFile::Str(Total)); -     Flush(); -#ifdef DEBUG_OSD -     int p = cols * Current / Total; -     Fill(0, 1, p, 1, clrGreen); -     Fill(p, 1, cols - p, 1, clrWhite); -#else -     int w = cols * charWidth; -     int p = w * Current / Total; -     if (p != lastProgress) { -        int y1 = 1 * lineHeight; -        int y2 = 2 * lineHeight - 1; -        int x1, x2; -        eDvbColor color; -        if (lastProgress < p) { -           x1 = lastProgress + 1; -           x2 = p; -           if (p >= w) -              p = w - 1; -           color = clrGreen; -           } -        else { -           x1 = p + 1; -           x2 = lastProgress; -           color = clrWhite; -           } -        if (lastProgress < 0) -           osd->Fill(0, y1, w - 1, y2, clrWhite); -        osd->Fill(x1, y1, x2, y2, color); -        lastProgress = p; -        } -     Flush(); -#endif -     Text(0, 2, cIndexFile::Str(Current)); -     Flush(); -     lastTotal = Total; -     return true; -     } -  return false; -} -  bool cDvbApi::SetChannel(int ChannelNumber, int FrequencyMHz, char Polarization, int Diseqc, int Srate, int Vpid, int Apid, int Ca, int Pnr)  {    if (videoDev >= 0) { @@ -2010,7 +1967,7 @@ void cDvbApi::StopRecord(void)       }  } -bool cDvbApi::StartReplay(const char *FileName, const char *Title) +bool cDvbApi::StartReplay(const char *FileName)  {    if (Recording()) {       esyslog(LOG_ERR, "ERROR: StartReplay() called while recording - ignored!"); @@ -2020,13 +1977,6 @@ bool cDvbApi::StartReplay(const char *FileName, const char *Title)    StopReplay();    if (videoDev >= 0) { -     lastProgress = lastTotal = -1; -     delete replayTitle; -     if (Title) { -        if ((replayTitle = strdup(Title)) == NULL) -           esyslog(LOG_ERR, "ERROR: StartReplay: can't copy title '%s'", Title); -        } -       // Check FileName:       if (!FileName) { @@ -4,7 +4,7 @@   * See the main source file 'vdr.c' for copyright information and   * how to reach the author.   * - * $Id: dvbapi.h 1.27 2000/12/03 13:44:28 kls Exp $ + * $Id: dvbapi.h 1.28 2000/12/09 10:54:09 kls Exp $   */  #ifndef __DVBAPI_H @@ -42,6 +42,8 @@ public:    bool Save(int Index);    }; +const char *IndexToStr(int Index, bool WithFrame = false); +      // Converts the given index to a string, optionally containing the frame number.  class cRecordBuffer;  class cReplayBuffer;  class cTransferBuffer; @@ -131,22 +133,16 @@ public:    void Close(void);    void Clear(void);    void Fill(int x, int y, int w, int h, eDvbColor color = clrBackground); +  void SetBitmap(int x, int y, const cBitmap &Bitmap);    void ClrEol(int x, int y, eDvbColor color = clrBackground);    int CellWidth(void); +  int LineHeight(void);    int Width(unsigned char c);    int WidthInCells(const char *s);    eDvbFont SetFont(eDvbFont Font);    void Text(int x, int y, const char *s, eDvbColor colorFg = clrWhite, eDvbColor colorBg = clrBackground);    void Flush(void); -  // Progress Display facilities - -private: -  int lastProgress, lastTotal; -  char *replayTitle; -public: -  bool ShowProgress(bool Initial = false); -    // Channel facilities  private: @@ -201,11 +197,10 @@ public:         // returned.    void StopRecord(void);         // Stops the current recording session (if any). -  bool StartReplay(const char *FileName, const char *Title = NULL); +  bool StartReplay(const char *FileName);         // Starts replaying the given file.         // If there is already a replay session active, it will be stopped         // and the new file will be played back. -       // If provided Title will be used in the progress display.    void StopReplay(void);         // Stops the current replay session (if any).    void Pause(void); @@ -4,7 +4,7 @@   * See the main source file 'vdr.c' for copyright information and   * how to reach the author.   * - * $Id: dvbosd.c 1.6 2000/11/18 15:36:51 kls Exp $ + * $Id: dvbosd.c 1.7 2000/12/09 11:13:00 kls Exp $   */  #include "dvbosd.h" @@ -82,6 +82,16 @@ void cBitmap::SetPixel(int x, int y, eDvbColor Color)       }  } +void cBitmap::SetBitmap(int x, int y, const cBitmap &Bitmap) +{ +  if (bitmap && Bitmap.bitmap) { +     for (int ix = 0; ix < Bitmap.width; ix++) { +         for (int iy = 0; iy < Bitmap.height; iy++) +             SetPixel(x + ix, y + iy, eDvbColor(Bitmap.bitmap[Bitmap.width * iy + ix])); +         } +     } +} +  int cBitmap::Width(unsigned char c)  {    return font ? font->Width(c) : -1; @@ -4,7 +4,7 @@   * See the main source file 'vdr.c' for copyright information and   * how to reach the author.   * - * $Id: dvbosd.h 1.4 2000/11/18 15:25:25 kls Exp $ + * $Id: dvbosd.h 1.5 2000/12/09 10:32:47 kls Exp $   */  #ifndef __DVBOSD_H @@ -57,6 +57,7 @@ public:    eDvbFont SetFont(eDvbFont Font);    bool Dirty(void);    void SetPixel(int x, int y, eDvbColor Color); +  void SetBitmap(int x, int y, const cBitmap &Bitmap);    int Width(unsigned char c);    int Width(const char *s);    void Text(int x, int y, const char *s, eDvbColor ColorFg = clrWhite, eDvbColor ColorBg = clrBackground); diff --git a/interface.c b/interface.c index e5cc1d25..ef8368ae 100644 --- a/interface.c +++ b/interface.c @@ -4,7 +4,7 @@   * See the main source file 'vdr.c' for copyright information and   * how to reach the author.   * - * $Id: interface.c 1.32 2000/11/18 15:28:50 kls Exp $ + * $Id: interface.c 1.33 2000/12/09 11:04:10 kls Exp $   */  #include "interface.h" @@ -121,6 +121,12 @@ void cInterface::Fill(int x, int y, int w, int h, eDvbColor Color)       cDvbApi::PrimaryDvbApi->Fill(x, y, w, h, Color);  } +void cInterface::SetBitmap(int x, int y, const cBitmap &Bitmap) +{ +  if (open) +     cDvbApi::PrimaryDvbApi->SetBitmap(x, y, Bitmap); +} +  void cInterface::Flush(void)  {    if (open) diff --git a/interface.h b/interface.h index cd46fbaa..50c37615 100644 --- a/interface.h +++ b/interface.h @@ -4,7 +4,7 @@   * See the main source file 'vdr.c' for copyright information and   * how to reach the author.   * - * $Id: interface.h 1.20 2000/11/18 15:27:59 kls Exp $ + * $Id: interface.h 1.21 2000/12/09 10:48:41 kls Exp $   */  #ifndef __INTERFACE_H @@ -41,6 +41,7 @@ public:    void Clear(void);    void ClearEol(int x, int y, eDvbColor Color = clrBackground);    void Fill(int x, int y, int w, int h, eDvbColor color = clrBackground); +  void SetBitmap(int x, int y, const cBitmap &Bitmap);    void Flush(void);    void SetCols(int *c);    eDvbFont SetFont(eDvbFont Font); @@ -4,7 +4,7 @@   * See the main source file 'vdr.c' for copyright information and   * how to reach the author.   * - * $Id: menu.c 1.54 2000/12/03 11:43:35 kls Exp $ + * $Id: menu.c 1.55 2000/12/09 11:03:21 kls Exp $   */  #include "menu.h" @@ -2000,10 +2000,10 @@ char *cReplayControl::title = NULL;  cReplayControl::cReplayControl(void)  { -  dvbApi = cDvbApi::PrimaryDvbApi;//XXX +  dvbApi = cDvbApi::PrimaryDvbApi;    visible = shown = false;    if (fileName) -     dvbApi->StartReplay(fileName, title); +     dvbApi->StartReplay(fileName);  }  cReplayControl::~cReplayControl() @@ -2038,7 +2038,7 @@ void cReplayControl::Show(void)    if (!visible) {       Interface->Open(MenuColumns, -3);       needsFastResponse = visible = true; -     shown = dvbApi->ShowProgress(true); +     shown = ShowProgress(true);       }  } @@ -2050,12 +2050,47 @@ void cReplayControl::Hide(void)       }  } +bool cReplayControl::ShowProgress(bool Initial) +{ +  int Current, Total; + +  if (dvbApi->GetIndex(Current, Total)) { +     if (Initial) { +        Interface->Clear(); +        if (title) +           Interface->Write(0, 0, title); +        } +     Interface->Write(-7, 2, IndexToStr(Total)); +     Interface->Flush(); +#ifdef DEBUG_OSD +     int p = Width() * Current / Total; +     Interface->Fill(0, 1, p, 1, clrGreen); +     Interface->Fill(p, 1, Width() - p, 1, clrWhite); +#else +     int w = Width() * dvbApi->CellWidth(); +     int h = dvbApi->LineHeight(); +     int p = w * Current / Total; +     cBitmap ProgressBar(w, h); + +     ProgressBar.Fill(0, 0, p, h - 1, clrGreen); +     ProgressBar.Fill(p + 1, 0, w - 1, h - 1, clrWhite); +     Interface->SetBitmap(0, dvbApi->LineHeight(), ProgressBar); + +     Interface->Flush(); +#endif +     Interface->Write(0, 2, IndexToStr(Current)); +     Interface->Flush(); +     return true; +     } +  return false; +} +  eOSState cReplayControl::ProcessKey(eKeys Key)  {    if (!dvbApi->Replaying())       return osEnd;    if (visible) -     shown = dvbApi->ShowProgress(!shown) || shown; +     shown = ShowProgress(!shown) || shown;    switch (Key) {      case kUp:      dvbApi->Play(); break;      case kDown:    dvbApi->Pause(); break; @@ -4,7 +4,7 @@   * See the main source file 'vdr.c' for copyright information and   * how to reach the author.   * - * $Id: menu.h 1.14 2000/11/12 12:33:00 kls Exp $ + * $Id: menu.h 1.15 2000/12/09 10:40:13 kls Exp $   */  #ifndef _MENU_H @@ -84,6 +84,7 @@ private:    void Hide(void);    static char *fileName;    static char *title; +  bool ShowProgress(bool Initial);  public:    cReplayControl(void);    virtual ~cReplayControl(); | 
