summaryrefslogtreecommitdiff
path: root/dvbapi.h
blob: 3c447cf1f69cff620067aae91e1c7a4897510f7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * dvbapi.h: Interface to the DVB driver
 *
 * See the main source file 'osm.c' for copyright information and
 * how to reach the author.
 *
 * $Id: dvbapi.h 1.3 2000/04/15 13:36:10 kls Exp $
 */

#ifndef __DVBAPI_H
#define __DVBAPI_H

// FIXME: these should be defined in ../DVB/driver/dvb.h!!!
typedef unsigned int __u32;
typedef unsigned short __u16;
typedef unsigned char __u8;

#if defined(DEBUG_OSD) || defined(DEBUG_REMOTE)
#include <ncurses.h>
#endif
#include <stdio.h>
#include "../DVB/driver/dvb.h"

enum eDvbColor { clrBackground,
#ifndef DEBUG_OSD
                 clrOBSOLETE, //FIXME apparently color '1' can't be used as FgColor with e.g. clrRed as BgColor???
                 clrBlack,
#else
                 clrBlack = clrBackground,
#endif
                 clrRed,
                 clrGreen,
                 clrYellow,
                 clrBlue,
                 clrMagenta,
                 clrCyan,
                 clrWhite,
               };
                  
class cDvbApi {
private:
  int videoDev;
public:
  cDvbApi(void);
  ~cDvbApi();

  // On Screen Display facilities

private:
  enum { charWidth  = 12, // average character width
         lineHeight = 27  // smallest text height
       };
#ifdef DEBUG_OSD
  WINDOW *window;
  enum { MaxColorPairs = 16 };
  int colorPairs[MaxColorPairs];
  void SetColor(eDvbColor colorFg, eDvbColor colorBg = clrBackground);
#endif
  int cols, rows;
  void Cmd(OSD_Command cmd, int color = 0, int x0 = 0, int y0 = 0, int x1 = 0, int y1 = 0, const void *data = NULL);
public:
  void Open(int w, int h);
  void Close(void);
  void Clear(void);
  void Fill(int x, int y, int w, int h, eDvbColor color = clrBackground);
  void ClrEol(int x, int y, eDvbColor color = clrBackground);
  void Text(int x, int y, const char *s, eDvbColor colorFg = clrWhite, eDvbColor colorBg = clrBackground);

  // Channel facilities

  bool SetChannel(int FrequencyMHz, char Polarization, int Diseqc, int Srate, int Vpid, int Apid, int Ca, int Pnr);

  // Record/Replay facilities

private:
  enum { dvbStop = 1, // let's not have 0 as a command
         dvbPauseReplay,
         dvbFastForward,
         dvbFastRewind,
         dvbSkip,
       };
  bool isMainProcess;
  pid_t pidRecord, pidReplay;
  int fromRecord, toRecord;
  int fromReplay, toReplay;
  void SetReplayMode(int Mode);
  void KillProcess(pid_t pid);
public:
  bool Recording(void);
       // Returns true if we are currently recording.
  bool Replaying(void);
       // Returns true if we are currently replaying.
  bool StartRecord(const char *FileName);
       // Starts recording the current channel into the given file.
       // In order to be able to record longer movies,
       // a numerical suffix will be appended to the file name. The inital
       // value of that suffix will be larger than any existing file under
       // the given name, thus allowing an interrupted recording to continue
       // gracefully.
       // Returns true if recording was started successfully.
       // If there is already a recording session active, false will be
       // returned.
  void StopRecord(void);
       // Stops the current recording session (if any).
  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.
  void StopReplay(void);
       // Stops the current replay session (if any).
  void PauseReplay(void);
       // Pauses the current replay session, or resumes a paused session.
  void FastForward(void);
       // Runs the current replay session forward at a higher speed.
  void FastRewind(void);
       // Runs the current replay session backwards at a higher speed.
  void Skip(int Seconds);
       // Skips the given number of seconds in the current replay session.
       // The sign of 'Seconds' determines the direction in which to skip.
       // Use a very large negative value to go all the way back to the
       // beginning of the recording.
  };
  
#endif //__DVBAPI_H