2002-06-16 12:57:31 +02:00
|
|
|
/*
|
|
|
|
* device.h: The basic device interface
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2003-01-06 14:44:27 +01:00
|
|
|
* $Id: device.h 1.29 2003/01/03 15:43:48 kls Exp $
|
2002-06-16 12:57:31 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DEVICE_H
|
|
|
|
#define __DEVICE_H
|
|
|
|
|
2003-01-06 14:44:27 +01:00
|
|
|
#include "ci.h"
|
2002-06-16 12:57:31 +02:00
|
|
|
#include "thread.h"
|
2002-08-04 14:57:29 +02:00
|
|
|
#include "tools.h"
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2002-08-04 14:57:29 +02:00
|
|
|
#define MAXDEVICES 16 // the maximum number of devices in the system
|
|
|
|
#define MAXCACAPS 16 // the maximum number of different CA values per device
|
|
|
|
#define MAXPIDHANDLES 16 // the maximum number of different PIDs per device
|
|
|
|
#define MAXRECEIVERS 16 // the maximum number of receivers per device
|
2002-06-16 12:57:31 +02:00
|
|
|
#define MAXVOLUME 255
|
|
|
|
#define VOLUMEDELTA 5 // used to increase/decrease the volume
|
|
|
|
|
2002-08-04 14:57:29 +02:00
|
|
|
#define TS_SIZE 188
|
|
|
|
#define TS_SYNC_BYTE 0x47
|
|
|
|
#define PID_MASK_HI 0x1F
|
|
|
|
|
2002-09-04 17:26:02 +02:00
|
|
|
enum eSetChannelResult { scrOk, scrNotAvailable, scrNoTransfer, scrFailed };
|
2002-08-04 14:57:29 +02:00
|
|
|
|
2002-09-08 15:04:33 +02:00
|
|
|
enum ePlayMode { pmNone, // audio/video from decoder
|
|
|
|
pmAudioVideo, // audio/video from player
|
|
|
|
pmAudioOnly, // audio only from player, video from decoder
|
|
|
|
pmAudioOnlyBlack, // audio only from player, no video (black screen)
|
2002-08-15 11:16:34 +02:00
|
|
|
pmExtern_THIS_SHOULD_BE_AVOIDED
|
|
|
|
// external player (e.g. MPlayer), release the device
|
|
|
|
// WARNING: USE THIS MODE ONLY AS A LAST RESORT, IF YOU
|
|
|
|
// ABSOLUTELY, POSITIVELY CAN'T IMPLEMENT YOUR PLAYER
|
|
|
|
// THE WAY IT IS SUPPOSED TO WORK. FORCING THE DEVICE
|
|
|
|
// TO RELEASE ITS FILES HANDLES (OR WHATEVER RESOURCES
|
|
|
|
// IT MAY USE) TO ALLOW AN EXTERNAL PLAYER TO ACCESS
|
|
|
|
// THEM MEANS THAT SUCH A PLAYER WILL NEED TO HAVE
|
|
|
|
// DETAILED KNOWLEDGE ABOUT THE INTERNALS OF THE DEVICE
|
|
|
|
// IN USE. AS A CONSEQUENCE, YOUR PLAYER MAY NOT WORK
|
|
|
|
// IF A PARTICULAR VDR INSTALLATION USES A DEVICE NOT
|
|
|
|
// KNOWN TO YOUR PLAYER.
|
|
|
|
};
|
|
|
|
|
2002-08-25 09:36:09 +02:00
|
|
|
class cOsdBase;
|
2002-08-04 14:57:29 +02:00
|
|
|
class cChannel;
|
2002-06-16 12:57:31 +02:00
|
|
|
class cPlayer;
|
|
|
|
class cReceiver;
|
2002-09-08 14:17:51 +02:00
|
|
|
class cSpuDecoder;
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2002-12-15 15:36:02 +01:00
|
|
|
/// The cDevice class is the base from which actual devices can be derived.
|
|
|
|
|
2002-09-21 09:14:56 +02:00
|
|
|
class cDevice : public cThread {
|
2002-06-16 12:57:31 +02:00
|
|
|
private:
|
|
|
|
static int numDevices;
|
|
|
|
static int useDevice;
|
|
|
|
static cDevice *device[MAXDEVICES];
|
|
|
|
static cDevice *primaryDevice;
|
|
|
|
public:
|
|
|
|
static int NumDevices(void) { return numDevices; }
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns the total number of devices.
|
2002-06-16 12:57:31 +02:00
|
|
|
static void SetUseDevice(int n);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the 'useDevice' flag of the given device.
|
|
|
|
///< If this function is not called before initializing, all devices
|
|
|
|
///< will be used.
|
2002-08-04 14:57:29 +02:00
|
|
|
static bool UseDevice(int n) { return useDevice == 0 || (useDevice & (1 << n)) != 0; }
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Tells whether the device with the given card index shall be used in
|
|
|
|
///< this instance of VDR.
|
2002-06-16 12:57:31 +02:00
|
|
|
static bool SetPrimaryDevice(int n);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the primary device to 'n'.
|
|
|
|
///< \param n must be in the range 1...numDevices.
|
|
|
|
///< \return true if this was possible.
|
2002-06-16 12:57:31 +02:00
|
|
|
static cDevice *PrimaryDevice(void) { return primaryDevice; }
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns the primary device.
|
2002-09-04 17:26:02 +02:00
|
|
|
static cDevice *GetDevice(int Index);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Gets the device with the given Index.
|
|
|
|
///< \param Index must be in the range 0..numDevices-1.
|
|
|
|
///< \return A pointer to the device, or NULL if the Index was invalid.
|
2002-09-06 14:10:17 +02:00
|
|
|
static cDevice *GetDevice(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns a device that is able to receive the given Channel at the
|
|
|
|
///< given Priority.
|
|
|
|
///< See ProvidesChannel() for more information on how
|
|
|
|
///< priorities are handled, and the meaning of NeedsDetachReceivers.
|
2002-08-04 14:57:29 +02:00
|
|
|
static void SetCaCaps(int Index = -1);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the CaCaps of the given device according to the Setup data.
|
|
|
|
///< By default the CaCaps of all devices are set.
|
2002-06-16 12:57:31 +02:00
|
|
|
static void Shutdown(void);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Closes down all devices.
|
|
|
|
///< Must be called at the end of the program.
|
2002-06-16 12:57:31 +02:00
|
|
|
private:
|
2002-08-04 14:57:29 +02:00
|
|
|
static int nextCardIndex;
|
2002-06-16 12:57:31 +02:00
|
|
|
int cardIndex;
|
|
|
|
int caCaps[MAXCACAPS];
|
2002-08-04 14:57:29 +02:00
|
|
|
protected:
|
|
|
|
cDevice(void);
|
2002-06-16 12:57:31 +02:00
|
|
|
virtual ~cDevice();
|
2002-08-04 14:57:29 +02:00
|
|
|
static int NextCardIndex(int n = 0);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Calculates the next card index.
|
|
|
|
///< Each device in a given machine must have a unique card index, which
|
|
|
|
///< will be used to identify the device for assigning Ca parameters and
|
|
|
|
///< deciding whether to actually use that device in this particular
|
|
|
|
///< instance of VDR. Every time a new cDevice is created, it will be
|
|
|
|
///< given the current nextCardIndex, and then nextCardIndex will be
|
|
|
|
///< automatically incremented by 1. A derived class can determine whether
|
|
|
|
///< a given device shall be used by checking UseDevice(NextCardIndex()).
|
|
|
|
///< If a device is skipped, or if there are possible device indexes left
|
|
|
|
///< after a derived class has set up all its devices, NextCardIndex(n)
|
|
|
|
///< must be called, where n is the number of card indexes to skip.
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual void MakePrimaryDevice(bool On);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Informs a device that it will be the primary device. If there is
|
|
|
|
///< anything the device needs to set up when it becomes the primary
|
|
|
|
///< device (On = true) or to shut down when it no longer is the primary
|
|
|
|
///< device (On = false), it should do so in this function.
|
2002-08-04 14:57:29 +02:00
|
|
|
public:
|
2002-07-28 11:29:32 +02:00
|
|
|
bool IsPrimaryDevice(void) const { return this == primaryDevice; }
|
2002-06-16 12:57:31 +02:00
|
|
|
int CardIndex(void) const { return cardIndex; }
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns the card index of this device (0 ... MAXDEVICES - 1).
|
2002-10-07 16:21:46 +02:00
|
|
|
int DeviceNumber(void) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns the number of this device (0 ... MAXDEVICES - 1).
|
2002-09-29 13:40:45 +02:00
|
|
|
int ProvidesCa(int Ca) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Checks whether this device provides the given value in its
|
|
|
|
///< caCaps. Returns 0 if the value is not provided, 1 if only this
|
|
|
|
///< value is provided, and > 1 if this and other values are provided.
|
|
|
|
///< If the given value is equal to the number of this device,
|
|
|
|
///< 1 is returned. If it is 0 (FTA), 1 plus the number of other values
|
|
|
|
///< in caCaps is returned.
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual bool HasDecoder(void) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Tells whether this device has an MPEG decoder.
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2002-08-25 09:36:09 +02:00
|
|
|
// OSD facilities
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual cOsdBase *NewOsd(int x, int y);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Creates a new cOsdBase object that can be used by the cOsd class
|
|
|
|
///< to display information on the screen, with the upper left corner
|
|
|
|
///< of the OSD at the given coordinates. If a derived cDevice doesn't
|
|
|
|
///< implement this function, NULL will be returned by default (which
|
|
|
|
///< means the device has no OSD capabilities).
|
2002-09-08 14:17:51 +02:00
|
|
|
virtual cSpuDecoder *GetSpuDecoder(void);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns a pointer to the device's SPU decoder (or NULL, if this
|
|
|
|
///< device doesn't have an SPU decoder).
|
2002-08-25 09:36:09 +02:00
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
// Channel facilities
|
|
|
|
|
2002-08-04 14:57:29 +02:00
|
|
|
protected:
|
2002-09-08 11:46:53 +02:00
|
|
|
static int currentChannel;
|
2002-06-16 12:57:31 +02:00
|
|
|
public:
|
2002-10-06 10:25:42 +02:00
|
|
|
virtual bool ProvidesSource(int Source) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns true if this device can provide the given source.
|
2002-09-29 13:40:45 +02:00
|
|
|
virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns true if this device can provide the given channel.
|
|
|
|
///< In case the device has cReceivers attached to it or it is the primary
|
|
|
|
///< device, Priority is used to decide whether the caller's request can
|
|
|
|
///< be honored.
|
|
|
|
///< The special Priority value -1 will tell the caller whether this device
|
|
|
|
///< is principally able to provide the given Channel, regardless of any
|
|
|
|
///< attached cReceivers.
|
|
|
|
///< If NeedsDetachReceivers is given, the resulting value in it will tell the
|
|
|
|
///< caller whether or not it will have to detach any currently attached
|
|
|
|
///< receivers from this device before calling SwitchChannel. Note
|
|
|
|
///< that the return value in NeedsDetachReceivers is only meaningful if the
|
|
|
|
///< function itself actually returns true.
|
|
|
|
///< The default implementation always returns false, so a derived cDevice
|
|
|
|
///< class that can provide channels must implement this function.
|
2002-09-04 17:26:02 +02:00
|
|
|
bool SwitchChannel(const cChannel *Channel, bool LiveView);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Switches the device to the given Channel, initiating transfer mode
|
|
|
|
///< if necessary.
|
2002-09-08 11:46:53 +02:00
|
|
|
static bool SwitchChannel(int Direction);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Switches the primary device to the next available channel in the given
|
|
|
|
///< Direction (only the sign of Direction is evaluated, positive values
|
|
|
|
///< switch to higher channel numbers).
|
2002-09-04 17:26:02 +02:00
|
|
|
private:
|
|
|
|
eSetChannelResult SetChannel(const cChannel *Channel, bool LiveView);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the device to the given channel (general setup).
|
2002-09-04 17:26:02 +02:00
|
|
|
protected:
|
|
|
|
virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the device to the given channel (actual physical setup).
|
2002-09-04 17:26:02 +02:00
|
|
|
public:
|
2002-09-08 11:46:53 +02:00
|
|
|
static int CurrentChannel(void) { return primaryDevice ? currentChannel : 0; }
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns the number of the current channel on the primary device.
|
2002-06-16 12:57:31 +02:00
|
|
|
|
|
|
|
// PID handle facilities
|
|
|
|
|
|
|
|
private:
|
2002-08-04 14:57:29 +02:00
|
|
|
bool active;
|
|
|
|
virtual void Action(void);
|
|
|
|
protected:
|
2002-09-14 11:51:51 +02:00
|
|
|
enum ePidType { ptAudio, ptVideo, ptTeletext, ptDolby, ptOther };
|
2002-06-16 12:57:31 +02:00
|
|
|
class cPidHandle {
|
|
|
|
public:
|
|
|
|
int pid;
|
2002-08-04 14:57:29 +02:00
|
|
|
int handle;
|
2002-06-16 12:57:31 +02:00
|
|
|
int used;
|
2002-08-04 14:57:29 +02:00
|
|
|
cPidHandle(void) { pid = used = 0; handle = -1; }
|
2002-06-16 12:57:31 +02:00
|
|
|
};
|
|
|
|
cPidHandle pidHandles[MAXPIDHANDLES];
|
2002-09-29 13:40:45 +02:00
|
|
|
bool HasPid(int Pid) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns true if this device is currently receiving the given PID.
|
2002-06-16 12:57:31 +02:00
|
|
|
bool AddPid(int Pid, ePidType PidType = ptOther);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Adds a PID to the set of PIDs this device shall receive.
|
2002-08-04 14:57:29 +02:00
|
|
|
void DelPid(int Pid);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Deletes a PID from the set of PIDs this device shall receive.
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual bool SetPid(cPidHandle *Handle, int Type, bool On);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Does the actual PID setting on this device.
|
|
|
|
///< On indicates whether the PID shall be added or deleted.
|
|
|
|
///< Handle->handle can be used by the device to store information it
|
|
|
|
///< needs to receive this PID (for instance a file handle).
|
|
|
|
///< Handle->used indicated how many receivers are using this PID.
|
|
|
|
///< Type indicates some special types of PIDs, which the device may
|
|
|
|
///< need to set in a specific way.
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2003-01-06 14:44:27 +01:00
|
|
|
// Common Interface facilities:
|
|
|
|
|
|
|
|
protected:
|
|
|
|
cCiHandler *ciHandler;
|
|
|
|
public:
|
|
|
|
cCiHandler *CiHandler(void) { return ciHandler; }
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
// Image Grab facilities
|
|
|
|
|
|
|
|
public:
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual bool GrabImage(const char *FileName, bool Jpeg = true, int Quality = -1, int SizeX = -1, int SizeY = -1);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Capture a single frame as an image.
|
|
|
|
///< Grabs the currently visible screen image into the given file, with the
|
|
|
|
///< given parameters.
|
|
|
|
///< \param FileName The name of the file to write. Should include the proper extension.
|
|
|
|
///< \param Jpeg If true will write a JPEG file. Otherwise a PNM file will be written.
|
|
|
|
///< \param Quality The compression factor for JPEG. 1 will create a very blocky
|
|
|
|
///< and small image, 70..80 will yield reasonable quality images while keeping the
|
|
|
|
///< image file size around 50 KB for a full frame. The default will create a big
|
|
|
|
///< but very high quality image.
|
|
|
|
///< \param SizeX The number of horizontal pixels in the frame (default is the current screen width).
|
|
|
|
///< \param SizeY The number of vertical pixels in the frame (default is the current screen height).
|
|
|
|
///< \return True if all went well. */
|
2002-06-16 12:57:31 +02:00
|
|
|
|
|
|
|
// Video format facilities
|
|
|
|
|
|
|
|
public:
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual void SetVideoFormat(bool VideoFormat16_9);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the output video format to either 16:9 or 4:3 (only useful
|
|
|
|
///< if this device has an MPEG decoder).
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2002-10-12 14:29:46 +02:00
|
|
|
// Audio facilities
|
2002-06-16 12:57:31 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool mute;
|
|
|
|
int volume;
|
2002-08-04 14:57:29 +02:00
|
|
|
protected:
|
|
|
|
virtual void SetVolumeDevice(int Volume);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the audio volume on this device (Volume = 0...255).
|
2002-10-12 14:29:46 +02:00
|
|
|
virtual int NumAudioTracksDevice(void) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns the number of audio tracks that are currently available on this
|
|
|
|
///< device. The default return value is 0, meaning that this device
|
|
|
|
///< doesn't have multiple audio track capabilities. The return value may
|
|
|
|
///< change with every call and need not necessarily be the number of list
|
|
|
|
///< entries returned by GetAudioTracksDevice(). This function is mainly called to
|
|
|
|
///< decide whether there should be an "Audio" button in a menu.
|
2002-10-12 14:29:46 +02:00
|
|
|
virtual const char **GetAudioTracksDevice(int *CurrentTrack = NULL) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns a list of currently available audio tracks. The last entry in the
|
|
|
|
///< list must be NULL. The number of entries does not necessarily have to be
|
|
|
|
///< the same as returned by a previous call to NumAudioTracksDevice().
|
|
|
|
///< If CurrentTrack is given, it will be set to the index of the current track
|
|
|
|
///< in the returned list. Note that the list must not be changed after it has
|
|
|
|
///< been returned by a call to GetAudioTracksDevice()! The only time the list may
|
|
|
|
///< change is *inside* the GetAudioTracksDevice() function.
|
|
|
|
///< By default the return value is NULL and CurrentTrack, if given, will not
|
|
|
|
///< have any meaning.
|
2002-10-12 14:29:46 +02:00
|
|
|
virtual void SetAudioTrackDevice(int Index);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the current audio track to the given value, which should be within the
|
|
|
|
///< range of the list returned by a previous call to GetAudioTracksDevice()
|
|
|
|
///< (otherwise nothing will happen).
|
2002-06-16 12:57:31 +02:00
|
|
|
public:
|
2002-09-29 13:40:45 +02:00
|
|
|
bool IsMute(void) const { return mute; }
|
2002-06-16 12:57:31 +02:00
|
|
|
bool ToggleMute(void);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Turns the volume off or on and returns the new mute state.
|
2002-06-16 12:57:31 +02:00
|
|
|
void SetVolume(int Volume, bool Absolute = false);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the volume to the given value, either absolutely or relative to
|
|
|
|
///< the current volume.
|
2002-06-16 12:57:31 +02:00
|
|
|
static int CurrentVolume(void) { return primaryDevice ? primaryDevice->volume : 0; }//XXX???
|
2002-10-12 14:29:46 +02:00
|
|
|
int NumAudioTracks(void) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns the number of audio tracks that are currently available on this
|
|
|
|
///< device or a player attached to it.
|
2002-10-12 14:29:46 +02:00
|
|
|
const char **GetAudioTracks(int *CurrentTrack = NULL) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns a list of currently available audio tracks. The last entry in the
|
|
|
|
///< list is NULL. The number of entries does not necessarily have to be
|
|
|
|
///< the same as returned by a previous call to NumAudioTracks().
|
|
|
|
///< If CurrentTrack is given, it will be set to the index of the current track
|
|
|
|
///< in the returned list.
|
|
|
|
///< By default the return value is NULL and CurrentTrack, if given, will not
|
|
|
|
///< have any meaning.
|
2002-10-12 14:29:46 +02:00
|
|
|
void SetAudioTrack(int Index);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the current audio track to the given value, which should be within the
|
|
|
|
///< range of the list returned by a previous call to GetAudioTracks() (otherwise
|
|
|
|
///< nothing will happen).
|
2002-06-16 12:57:31 +02:00
|
|
|
|
|
|
|
// Player facilities
|
|
|
|
|
|
|
|
private:
|
|
|
|
cPlayer *player;
|
2002-09-15 11:08:35 +02:00
|
|
|
bool playerDetached;
|
2002-08-04 14:57:29 +02:00
|
|
|
protected:
|
2002-10-26 11:51:37 +02:00
|
|
|
virtual bool CanReplay(void) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns true if this device can currently start a replay session.
|
2002-08-15 11:16:34 +02:00
|
|
|
virtual bool SetPlayMode(ePlayMode PlayMode);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the device into the given play mode.
|
|
|
|
///< \return true if the operation was successful.
|
2002-06-16 12:57:31 +02:00
|
|
|
public:
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual void TrickSpeed(int Speed);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the device into a mode where replay is done slower.
|
|
|
|
///< Every single frame shall then be displayed the given number of
|
|
|
|
///< times.
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual void Clear(void);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Clears all video and audio data from the device.
|
|
|
|
///< A derived class must call the base class function to make sure
|
|
|
|
///< all registered cAudio objects are notified.
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual void Play(void);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the device into play mode (after a previous trick
|
|
|
|
///< mode).
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual void Freeze(void);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Puts the device into "freeze frame" mode.
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual void Mute(void);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Turns off audio while replaying.
|
|
|
|
///< A derived class must call the base class function to make sure
|
|
|
|
///< all registered cAudio objects are notified.
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual void StillPicture(const uchar *Data, int Length);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Displays the given I-frame as a still picture.
|
2002-08-16 09:22:29 +02:00
|
|
|
virtual bool Poll(cPoller &Poller, int TimeoutMs = 0);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns true if the device itself or any of the file handles in
|
|
|
|
///< Poller is ready for further action.
|
|
|
|
///< If TimeoutMs is not zero, the device will wait up to the given number
|
|
|
|
///< of milleseconds before returning in case there is no immediate
|
|
|
|
///< need for data.
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual int PlayVideo(const uchar *Data, int Length);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Actually plays the given data block as video. The data must be
|
|
|
|
///< part of a PES (Packetized Elementary Stream) which can contain
|
|
|
|
///< one video and one audio strem.
|
2002-11-03 11:53:58 +01:00
|
|
|
virtual void PlayAudio(const uchar *Data, int Length);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Plays additional audio streams, like Dolby Digital.
|
|
|
|
///< A derived class must call the base class function to make sure data
|
|
|
|
///< is distributed to all registered cAudio objects.
|
2002-09-29 13:40:45 +02:00
|
|
|
bool Replaying(void) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns true if we are currently replaying.
|
2002-06-16 12:57:31 +02:00
|
|
|
void StopReplay(void);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Stops the current replay session (if any).
|
2002-06-22 13:45:53 +02:00
|
|
|
bool AttachPlayer(cPlayer *Player);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Attaches the given player to this device.
|
2002-06-16 12:57:31 +02:00
|
|
|
void Detach(cPlayer *Player);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Detaches the given player from this device.
|
2002-09-15 11:08:35 +02:00
|
|
|
bool PlayerDetached(void);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns true if a player has been detached and resets the 'playerDetached' flag.
|
2002-06-16 12:57:31 +02:00
|
|
|
|
|
|
|
// Receiver facilities
|
|
|
|
|
|
|
|
private:
|
|
|
|
cReceiver *receiver[MAXRECEIVERS];
|
2002-09-29 13:40:45 +02:00
|
|
|
int CanShift(int Ca, int Priority, int UsedCards = 0) const;
|
2002-09-04 17:26:02 +02:00
|
|
|
protected:
|
2002-09-29 13:40:45 +02:00
|
|
|
int Priority(void) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns the priority of the current receiving session (0..MAXPRIORITY),
|
|
|
|
///< or -1 if no receiver is currently active. The primary device will
|
|
|
|
///< always return at least Setup.PrimaryLimit-1.
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual bool OpenDvr(void);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Opens the DVR of this device and prepares it to deliver a Transport
|
|
|
|
///< Stream for use in a cReceiver.
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual void CloseDvr(void);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Shuts down the DVR.
|
2002-09-08 09:03:10 +02:00
|
|
|
virtual bool GetTSPacket(uchar *&Data);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Gets exactly one TS packet from the DVR of this device and returns
|
|
|
|
///< a pointer to it in Data. Only the first 188 bytes (TS_SIZE) Data
|
|
|
|
///< points to are valid and may be accessed. If there is currently no
|
|
|
|
///< new data available, Data will be set to NULL. The function returns
|
|
|
|
///< false in case of a non recoverable error, otherwise it returns true,
|
|
|
|
///< even if Data is NULL.
|
2002-06-16 12:57:31 +02:00
|
|
|
public:
|
2002-10-26 09:43:11 +02:00
|
|
|
int Ca(void) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns the ca of the current receiving session(s).
|
2002-11-01 11:11:20 +01:00
|
|
|
bool Receiving(bool CheckAny = false) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns true if we are currently receiving.
|
2002-06-22 13:45:53 +02:00
|
|
|
bool AttachReceiver(cReceiver *Receiver);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Attaches the given receiver to this device.
|
2002-06-16 12:57:31 +02:00
|
|
|
void Detach(cReceiver *Receiver);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Detaches the given receiver from this device.
|
2002-06-16 12:57:31 +02:00
|
|
|
};
|
|
|
|
|
2002-12-15 15:36:02 +01:00
|
|
|
/// Derived cDevice classes that can receive channels will have to provide
|
|
|
|
/// Transport Stream (TS) packets one at a time. cTSBuffer implements a
|
|
|
|
/// simple buffer that allows the device to read a larger amount of data
|
|
|
|
/// from the driver with each call to Read(), thus avoiding the overhead
|
|
|
|
/// of getting each TS packet separately from the driver. It also makes
|
|
|
|
/// sure the returned data points to a TS packet and automatically
|
|
|
|
/// re-synchronizes after broken packet.
|
2002-09-08 09:03:10 +02:00
|
|
|
|
|
|
|
class cTSBuffer {
|
|
|
|
private:
|
|
|
|
int f;
|
|
|
|
int size;
|
|
|
|
int cardIndex;
|
|
|
|
int tsRead;
|
|
|
|
int tsWrite;
|
|
|
|
uchar *buf;
|
|
|
|
bool firstRead;
|
|
|
|
int Used(void) { return tsRead <= tsWrite ? tsWrite - tsRead : size - tsRead + tsWrite; }
|
|
|
|
public:
|
|
|
|
cTSBuffer(int File, int Size, int CardIndex);
|
|
|
|
~cTSBuffer();
|
|
|
|
int Read(void);
|
|
|
|
uchar *Get(void);
|
|
|
|
};
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
#endif //__DEVICE_H
|