1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00
vdr/dvbapi.h

262 lines
9.0 KiB
C
Raw Permalink Normal View History

2000-02-19 13:36:48 +01:00
/*
* dvbapi.h: Interface to the DVB driver
*
2000-04-24 09:46:05 +02:00
* See the main source file 'vdr.c' for copyright information and
2000-02-19 13:36:48 +01:00
* how to reach the author.
*
* $Id: dvbapi.h 1.35 2001/02/11 10:41:10 kls Exp $
2000-02-19 13:36:48 +01:00
*/
#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;
2000-02-19 13:36:48 +01:00
2000-07-15 12:39:20 +02:00
#if defined(DEBUG_OSD) || defined(REMOTE_KBD)
#include <ncurses.h>
#endif
#include <stdio.h>
#include <dvb.h>
2000-10-03 10:34:48 +02:00
#include "dvbosd.h"
2000-10-29 13:17:22 +01:00
#include "eit.h"
2000-12-28 12:57:16 +01:00
#include "thread.h"
2000-09-17 13:47:06 +02:00
// Overlay facilities
#define MAXCLIPRECTS 100
typedef struct CRect {
signed short x, y, width, height;
};
2000-04-22 13:51:48 +02:00
#define MenuLines 15
#define MenuColumns 40
2000-12-28 12:57:16 +01:00
const char *IndexToHMSF(int Index, bool WithFrame = false);
2000-12-09 11:13:00 +01:00
// Converts the given index to a string, optionally containing the frame number.
2000-12-28 12:57:16 +01:00
int HMSFToIndex(const char *HMSF);
// Converts the given string (format: "hh:mm:ss.ff") to an index.
class cChannel;
2000-12-08 16:23:32 +01:00
class cRecordBuffer;
class cReplayBuffer;
2000-11-19 16:49:14 +01:00
class cTransferBuffer;
2000-12-28 12:57:16 +01:00
class cCuttingBuffer;
class cVideoCutter {
private:
static cCuttingBuffer *cuttingBuffer;
public:
static bool Start(const char *FileName);
static void Stop(void);
static bool Active(void);
};
2000-11-19 16:49:14 +01:00
class cDvbApi {
private:
int videoDev;
2000-10-29 13:17:22 +01:00
cDvbApi(const char *VideoFileName, const char *VbiFileName);
2000-02-19 13:36:48 +01:00
public:
~cDvbApi();
2001-02-10 13:13:49 +01:00
#define MAXDVBAPI 4
2000-05-01 16:29:46 +02:00
static int NumDvbApis;
private:
static cDvbApi *dvbApi[MAXDVBAPI];
2001-02-02 15:49:46 +01:00
static int useDvbApi;
2000-05-01 16:29:46 +02:00
public:
static cDvbApi *PrimaryDvbApi;
2001-02-02 15:49:46 +01:00
static void SetUseDvbApi(int n);
// Sets the 'useDvbApi' flag of the given DVB device.
// If this function is not called before Init(), all DVB devices
// will be used.
2000-09-10 10:51:58 +02:00
static bool SetPrimaryDvbApi(int n);
// Sets the primary DVB device to 'n' (which must be in the range
// 1...NumDvbApis) and returns true if this was possible.
static cDvbApi *GetDvbApi(int Ca, int Priority);
2000-09-10 10:51:58 +02:00
// Selects a free DVB device, starting with the highest device number
// (but avoiding, if possible, the PrimaryDvbApi).
// If Ca is not 0, the device with the given number will be returned.
// If all DVB devices are currently recording, the one recording the
// lowest priority timer (if any) that is lower than the given Priority
// will be returned.
// The caller must check whether the returned DVB device is actually
// recording and stop recording if necessary.
2000-05-01 16:29:46 +02:00
int Index(void);
// Returns the index of this DvbApi.
static bool Init(void);
// Initializes the DVB API and probes for existing DVB devices.
// Must be called before accessing any DVB functions.
static void Cleanup(void);
// Closes down all DVB devices.
// Must be called at the end of the program.
2000-10-29 13:17:22 +01:00
// EIT facilities
private:
cSIProcessor *siProcessor;
public:
2000-10-29 13:17:22 +01:00
const cSchedules *Schedules(cThreadLock *ThreadLock) const;
// Caller must provide a cThreadLock which has to survive the entire
// time the returned cSchedules is accessed. Once the cSchedules is no
// longer used, the cThreadLock must be destroyed.
void SetUseTSTime(bool On) { if (siProcessor) siProcessor->SetUseTSTime(On); }
2000-09-17 11:53:35 +02:00
// Image Grab facilities
bool GrabImage(const char *FileName, bool Jpeg = true, int Quality = -1, int SizeX = -1, int SizeY = -1);
2000-09-17 13:47:06 +02:00
// Overlay facilities
private:
bool ovlStat, ovlGeoSet, ovlFbSet;
int ovlSizeX, ovlSizeY, ovlPosX, ovlPosY, ovlBpp, ovlPalette, ovlClips, ovlClipCount;
int ovlFbSizeX, ovlFbSizeY;
__u16 ovlBrightness, ovlColour, ovlHue, ovlContrast;
struct video_clip ovlClipRects[MAXCLIPRECTS];
public:
bool OvlF(int SizeX, int SizeY, int FbAddr, int Bpp, int Palette);
bool OvlG(int SizeX, int SizeY, int PosX, int PosY);
bool OvlC(int ClipCount, CRect *Cr);
bool OvlP(__u16 Brightness, __u16 Color, __u16 Hue, __u16 Contrast);
bool OvlO(bool Value);
// On Screen Display facilities
2000-02-19 13:36:48 +01:00
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);
2000-10-03 10:34:48 +02:00
#else
cDvbOsd *osd;
#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:
2000-04-23 15:38:16 +02:00
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);
2000-12-09 11:13:00 +01:00
void SetBitmap(int x, int y, const cBitmap &Bitmap);
void ClrEol(int x, int y, eDvbColor color = clrBackground);
2000-11-01 11:45:05 +01:00
int CellWidth(void);
2000-12-09 11:13:00 +01:00
int LineHeight(void);
2000-11-01 11:45:05 +01:00
int Width(unsigned char c);
int WidthInCells(const char *s);
2000-11-18 15:46:00 +01:00
eDvbFont SetFont(eDvbFont Font);
void Text(int x, int y, const char *s, eDvbColor colorFg = clrWhite, eDvbColor colorBg = clrBackground);
2000-10-03 10:34:48 +02:00
void Flush(void);
// Channel facilities
2000-11-05 18:39:17 +01:00
private:
int currentChannel;
public:
2001-02-03 16:28:03 +01:00
bool SetChannel(int ChannelNumber, int FrequencyMHz, char Polarization, int Diseqc, int Srate, int Vpid, int Apid, int Tpid, int Ca, int Pnr);
2000-11-05 18:39:17 +01:00
static int CurrentChannel(void) { return PrimaryDvbApi ? PrimaryDvbApi->currentChannel : 0; }
int Channel(void) { return currentChannel; }
2000-11-19 16:49:14 +01:00
// Transfer facilities
private:
cTransferBuffer *transferBuffer;
cDvbApi *transferringFromDvbApi;
public:
bool Transferring(void);
// Returns true if we are currently transferring video data.
private:
cDvbApi *StartTransfer(int TransferToVideoDev);
// Starts transferring video data from this DVB device to TransferToVideoDev.
void StopTransfer(void);
// Stops transferring video data (in case a transfer is currently active).
// Record/Replay facilities
private:
2000-12-08 16:23:32 +01:00
cRecordBuffer *recordBuffer;
cReplayBuffer *replayBuffer;
int ca;
int priority;
protected:
int Ca(void) { return ca; }
// Returns the ca of the current recording session (0..MAXDVBAPI).
int Priority(void) { return priority; }
// Returns the priority of the current recording session (0..99),
// or -1 if no recording is currently active.
public:
2000-12-28 12:57:16 +01:00
int SecondsToFrames(int Seconds);
// Returns the number of frames corresponding to the given number of seconds.
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, int Ca, int Priority);
// Starts recording the current channel into the given file, with
// the given ca and priority.
// 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).
2000-12-09 11:13:00 +01:00
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.
2000-12-08 16:23:32 +01:00
void StopReplay(void);
// Stops the current replay session (if any).
void Pause(void);
// Pauses the current replay session, or resumes a paused session.
void Play(void);
// Resumes normal replay mode.
void Forward(void);
// Runs the current replay session forward at a higher speed.
void Backward(void);
// Runs the current replay session backwards at a higher speed.
2000-12-28 12:57:16 +01:00
void SkipSeconds(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.
2000-12-28 12:57:16 +01:00
int SkipFrames(int Frames);
// Returns the new index into the current replay session after skipping
// the given number of frames (no actual repositioning is done!).
// The sign of 'Frames' determines the direction in which to skip.
bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false);
// Returns the current and total frame index, optionally snapped to the
// nearest I-frame.
2001-01-07 17:00:50 +01:00
void Goto(int Index, bool Still = false);
// Positions to the given index and displays that frame as a still picture
// if Still is true.
};
2000-05-01 16:29:46 +02:00
class cEITScanner {
private:
enum { ActivityTimeout = 60,
ScanTimeout = 20
};
time_t lastScan, lastActivity;
int currentChannel, lastChannel;
int numTransponders, *transponders;
bool TransponderScanned(cChannel *Channel);
public:
cEITScanner(void);
~cEITScanner();
bool Active(void) { return currentChannel; }
void Activity(void);
void Process(void);
};
2000-02-19 13:36:48 +01:00
#endif //__DVBAPI_H