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.
|
|
|
|
*
|
2017-01-09 13:42:41 +01:00
|
|
|
* $Id: device.h 4.3 2017/01/09 12:51:05 kls Exp $
|
2002-06-16 12:57:31 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DEVICE_H
|
|
|
|
#define __DEVICE_H
|
|
|
|
|
2005-09-04 14:48:39 +02:00
|
|
|
#include "channels.h"
|
2003-01-06 14:44:27 +01:00
|
|
|
#include "ci.h"
|
2007-10-12 14:52:30 +02:00
|
|
|
#include "dvbsubtitle.h"
|
2003-12-22 13:29:24 +01:00
|
|
|
#include "eit.h"
|
|
|
|
#include "filter.h"
|
2004-01-11 15:54:37 +01:00
|
|
|
#include "nit.h"
|
2003-12-22 13:29:24 +01:00
|
|
|
#include "pat.h"
|
2013-08-21 11:02:52 +02:00
|
|
|
#include "positioner.h"
|
2008-08-15 14:49:34 +02:00
|
|
|
#include "remux.h"
|
2004-10-16 09:36:28 +02:00
|
|
|
#include "ringbuffer.h"
|
2004-01-04 12:30:00 +01:00
|
|
|
#include "sdt.h"
|
2003-12-22 13:29:24 +01:00
|
|
|
#include "sections.h"
|
2005-02-20 12:01:05 +01:00
|
|
|
#include "spu.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
|
2005-01-16 14:40:47 +01:00
|
|
|
#define MAXPIDHANDLES 64 // the maximum number of different PIDs per device
|
2002-08-04 14:57:29 +02:00
|
|
|
#define MAXRECEIVERS 16 // the maximum number of receivers per device
|
2002-06-16 12:57:31 +02:00
|
|
|
#define MAXVOLUME 255
|
2015-01-12 14:56:42 +01:00
|
|
|
#define VOLUMEDELTA (MAXVOLUME / Setup.VolumeSteps) // used to increase/decrease the volume
|
2011-10-16 14:02:34 +02:00
|
|
|
#define MAXOCCUPIEDTIMEOUT 99 // max. time (in seconds) a device may be occupied
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2002-09-04 17:26:02 +02:00
|
|
|
enum eSetChannelResult { scrOk, scrNotAvailable, scrNoTransfer, scrFailed };
|
2002-08-04 14:57:29 +02:00
|
|
|
|
2013-12-25 13:55:39 +01:00
|
|
|
// Note that VDR itself always uses pmAudioVideo when replaying a recording!
|
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)
|
2004-05-23 10:12:44 +02:00
|
|
|
pmVideoOnly, // video only from player, audio from decoder
|
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.
|
|
|
|
};
|
|
|
|
|
2015-04-19 12:15:00 +02:00
|
|
|
//#define DEPRECATED_VIDEOSYSTEM
|
2014-03-15 14:05:15 +01:00
|
|
|
#ifdef DEPRECATED_VIDEOSYSTEM
|
2003-08-15 13:05:50 +02:00
|
|
|
enum eVideoSystem { vsPAL,
|
|
|
|
vsNTSC
|
|
|
|
};
|
2014-03-15 14:05:15 +01:00
|
|
|
#endif
|
2003-08-15 13:05:50 +02:00
|
|
|
|
2005-02-20 12:01:05 +01:00
|
|
|
enum eVideoDisplayFormat { vdfPanAndScan,
|
|
|
|
vdfLetterBox,
|
|
|
|
vdfCenterCutOut
|
|
|
|
};
|
|
|
|
|
2004-12-17 14:55:49 +01:00
|
|
|
enum eTrackType { ttNone,
|
|
|
|
ttAudio,
|
|
|
|
ttAudioFirst = ttAudio,
|
2005-01-16 14:40:47 +01:00
|
|
|
ttAudioLast = ttAudioFirst + 31, // MAXAPIDS - 1
|
2004-12-17 14:55:49 +01:00
|
|
|
ttDolby,
|
|
|
|
ttDolbyFirst = ttDolby,
|
2005-02-20 14:07:52 +01:00
|
|
|
ttDolbyLast = ttDolbyFirst + 15, // MAXDPIDS - 1
|
2004-12-17 14:55:49 +01:00
|
|
|
ttSubtitle,
|
|
|
|
ttSubtitleFirst = ttSubtitle,
|
2007-10-12 14:52:30 +02:00
|
|
|
ttSubtitleLast = ttSubtitleFirst + 31, // MAXSPIDS - 1
|
2004-12-17 14:55:49 +01:00
|
|
|
ttMaxTrackTypes
|
|
|
|
};
|
|
|
|
|
|
|
|
#define IS_AUDIO_TRACK(t) (ttAudioFirst <= (t) && (t) <= ttAudioLast)
|
|
|
|
#define IS_DOLBY_TRACK(t) (ttDolbyFirst <= (t) && (t) <= ttDolbyLast)
|
2007-10-12 14:52:30 +02:00
|
|
|
#define IS_SUBTITLE_TRACK(t) (ttSubtitleFirst <= (t) && (t) <= ttSubtitleLast)
|
2004-12-17 14:55:49 +01:00
|
|
|
|
|
|
|
struct tTrackId {
|
2005-09-04 14:48:39 +02:00
|
|
|
uint16_t id; // The PES packet id or the PID.
|
|
|
|
char language[MAXLANGCODE2]; // something like either "eng" or "deu+eng"
|
|
|
|
char description[32]; // something like "Dolby Digital 5.1"
|
2004-12-17 14:55:49 +01:00
|
|
|
};
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
class cPlayer;
|
|
|
|
class cReceiver;
|
2007-10-12 14:52:30 +02:00
|
|
|
class cLiveSubtitle;
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2010-02-06 14:23:03 +01:00
|
|
|
class cDeviceHook : public cListObject {
|
|
|
|
public:
|
|
|
|
cDeviceHook(void);
|
2010-04-05 09:52:11 +02:00
|
|
|
///< Creates a new device hook object.
|
|
|
|
///< Do not delete this object - it will be automatically deleted when the
|
|
|
|
///< program ends.
|
2010-02-06 14:23:03 +01:00
|
|
|
virtual bool DeviceProvidesTransponder(const cDevice *Device, const cChannel *Channel) const;
|
|
|
|
///< Returns true if the given Device can provide the given Channel's transponder.
|
|
|
|
};
|
|
|
|
|
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 {
|
2007-10-12 14:52:30 +02:00
|
|
|
friend class cLiveSubtitle;
|
2010-02-06 14:23:03 +01:00
|
|
|
friend class cDeviceHook;
|
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.
|
2005-08-21 08:56:49 +02:00
|
|
|
static bool WaitForAllDevicesReady(int Timeout = 0);
|
|
|
|
///< Waits until all devices have become ready, or the given Timeout
|
|
|
|
///< (seconds) has expired. While waiting, the Ready() function of each
|
|
|
|
///< device is called in turn, until they all return true.
|
2013-02-16 15:26:45 +01:00
|
|
|
///< Returns true if all devices have become ready within the given
|
2005-08-21 08:56:49 +02:00
|
|
|
///< timeout.
|
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'.
|
2013-02-16 15:26:45 +01:00
|
|
|
///< n must be in the range 1...numDevices.
|
|
|
|
///< Returns 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.
|
2003-05-11 09:01:51 +02:00
|
|
|
static cDevice *ActualDevice(void);
|
|
|
|
///< Returns the actual receiving device in case of Transfer Mode, or the
|
|
|
|
///< primary device otherwise.
|
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.
|
2013-02-16 15:26:45 +01:00
|
|
|
///< Index must be in the range 0..numDevices-1.
|
|
|
|
///< Returns a pointer to the device, or NULL if the Index was invalid.
|
2012-03-02 10:43:26 +01:00
|
|
|
static cDevice *GetDevice(const cChannel *Channel, int Priority, bool LiveView, bool Query = false);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns a device that is able to receive the given Channel at the
|
2006-06-15 10:00:40 +02:00
|
|
|
///< given Priority, with the least impact on active recordings and
|
2007-01-07 14:46:14 +01:00
|
|
|
///< live viewing. The LiveView parameter tells whether the device will
|
|
|
|
///< be used for live viewing or a recording.
|
|
|
|
///< If the Channel is encrypted, a CAM slot that claims to be able to
|
|
|
|
///< decrypt the channel is automatically selected and assigned to the
|
|
|
|
///< returned device. Whether or not this combination of device and CAM
|
|
|
|
///< slot is actually able to decrypt the channel can only be determined
|
|
|
|
///< by checking the "scrambling control" bits of the received TS packets.
|
|
|
|
///< The Action() function automatically does this and takes care that
|
|
|
|
///< after detaching any receivers because the channel can't be decrypted,
|
|
|
|
///< this device/CAM combination will be skipped in the next call to
|
|
|
|
///< GetDevice().
|
2012-03-02 10:43:26 +01:00
|
|
|
///< If Query is true, no actual CAM assignments or receiver detachments will
|
|
|
|
///< be done, so that this function can be called without any side effects
|
|
|
|
///< in order to just determine whether a device is available for the given
|
|
|
|
///< Channel.
|
2007-01-07 14:46:14 +01:00
|
|
|
///< See also ProvidesChannel().
|
2012-03-06 12:32:38 +01:00
|
|
|
static cDevice *GetDeviceForTransponder(const cChannel *Channel, int Priority);
|
|
|
|
///< Returns a device that is not currently "occupied" and can be tuned to
|
|
|
|
///< the transponder of the given Channel, without disturbing any receiver
|
|
|
|
///< at priorities higher or equal to Priority.
|
|
|
|
///< If no such device is currently available, NULL will be returned.
|
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;
|
2002-08-04 14:57:29 +02:00
|
|
|
protected:
|
|
|
|
cDevice(void);
|
2002-06-16 12:57:31 +02:00
|
|
|
virtual ~cDevice();
|
2005-08-21 08:56:49 +02:00
|
|
|
virtual bool Ready(void);
|
|
|
|
///< Returns true if this device is ready. Devices with conditional
|
|
|
|
///< access hardware may need some time until they are up and running.
|
|
|
|
///< This function is called in a loop at startup until all devices
|
|
|
|
///< are ready (see WaitForAllDevicesReady()).
|
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.
|
2010-01-01 15:15:36 +01:00
|
|
|
///< A derived class must call the MakePrimaryDevice() function of its
|
|
|
|
///< base class.
|
2002-08-04 14:57:29 +02:00
|
|
|
public:
|
2013-08-22 12:00:03 +02:00
|
|
|
bool IsPrimaryDevice(void) const { return this == primaryDevice && HasDecoder(); }
|
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;
|
2013-10-10 13:23:30 +02:00
|
|
|
///< Returns the number of this device (0 ... numDevices - 1).
|
2012-04-04 09:52:15 +02:00
|
|
|
virtual cString DeviceType(void) const;
|
|
|
|
///< Returns a string identifying the type of this device (like "DVB-S").
|
|
|
|
///< If this device can receive different delivery systems, the returned
|
|
|
|
///< string shall be that of the currently used system.
|
|
|
|
///< The length of the returned string should not exceed 6 characters.
|
|
|
|
///< The default implementation returns an empty string.
|
2012-03-13 10:20:42 +01:00
|
|
|
virtual cString DeviceName(void) const;
|
|
|
|
///< Returns a string identifying the name of this device.
|
|
|
|
///< The default implementation returns an empty string.
|
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.
|
2011-05-21 13:40:47 +02:00
|
|
|
virtual bool AvoidRecording(void) const { return false; }
|
|
|
|
///< Returns true if this device should only be used for recording
|
|
|
|
///< if no other device is available.
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2010-02-06 14:23:03 +01:00
|
|
|
// Device hooks
|
|
|
|
|
|
|
|
private:
|
|
|
|
static cList<cDeviceHook> deviceHooks;
|
|
|
|
protected:
|
|
|
|
bool DeviceHooksProvidesTransponder(const cChannel *Channel) const;
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
// SPU facilities
|
2002-08-25 09:36:09 +02:00
|
|
|
|
2007-10-12 14:52:30 +02:00
|
|
|
private:
|
|
|
|
cLiveSubtitle *liveSubtitle;
|
|
|
|
cDvbSubtitleConverter *dvbSubtitleConverter;
|
2002-08-25 09:36:09 +02:00
|
|
|
public:
|
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
|
|
|
|
|
2011-10-16 14:02:34 +02:00
|
|
|
private:
|
|
|
|
time_t occupiedTimeout;
|
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.
|
2004-01-04 12:30:00 +01:00
|
|
|
virtual bool ProvidesTransponder(const cChannel *Channel) const;
|
2007-01-07 14:46:14 +01:00
|
|
|
///< Returns true if this device can provide the transponder of the
|
|
|
|
///< given Channel (which implies that it can provide the Channel's
|
|
|
|
///< source).
|
2005-06-12 14:09:45 +02:00
|
|
|
virtual bool ProvidesTransponderExclusively(const cChannel *Channel) const;
|
|
|
|
///< Returns true if this is the only device that is able to provide
|
|
|
|
///< the given channel's transponder.
|
2012-03-02 10:19:00 +01:00
|
|
|
virtual bool ProvidesChannel(const cChannel *Channel, int Priority = IDLEPRIORITY, bool *NeedsDetachReceivers = NULL) const;
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Returns true if this device can provide the given channel.
|
2012-02-25 14:44:43 +01:00
|
|
|
///< In case the device has cReceivers attached to it, Priority is used to
|
|
|
|
///< decide whether the caller's request can be honored.
|
2012-03-02 10:19:00 +01:00
|
|
|
///< The special Priority value IDLEPRIORITY will tell the caller whether this device
|
2002-12-15 15:36:02 +01:00
|
|
|
///< 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.
|
2011-08-26 13:03:14 +02:00
|
|
|
virtual bool ProvidesEIT(void) const;
|
|
|
|
///< Returns true if this device provides EIT data and thus wants to be tuned
|
|
|
|
///< to the channels it can receive regularly to update the data.
|
|
|
|
///< The default implementation returns false.
|
2008-04-12 13:39:12 +02:00
|
|
|
virtual int NumProvidedSystems(void) const;
|
|
|
|
///< Returns the number of individual "delivery systems" this device provides.
|
|
|
|
///< The default implementation returns 0, so any derived class that can
|
|
|
|
///< actually provide channels must implement this function.
|
|
|
|
///< The result of this function is used when selecting a device, in order
|
|
|
|
///< to avoid devices that provide more than one system.
|
2013-08-21 11:02:52 +02:00
|
|
|
virtual const cPositioner *Positioner(void) const;
|
|
|
|
///< Returns a pointer to the positioner (if any) this device has used to
|
|
|
|
///< move the satellite dish to the requested position (only applies to DVB-S
|
|
|
|
///< devices). If no positioner is involved, or this is not a DVB-S device,
|
|
|
|
///< NULL will be returned.
|
2011-06-02 13:28:42 +02:00
|
|
|
virtual int SignalStrength(void) const;
|
|
|
|
///< Returns the "strength" of the currently received signal.
|
|
|
|
///< This is a value in the range 0 (no signal at all) through
|
|
|
|
///< 100 (best possible signal). A value of -1 indicates that this
|
|
|
|
///< device has no concept of a "signal strength".
|
|
|
|
virtual int SignalQuality(void) const;
|
|
|
|
///< Returns the "quality" of the currently received signal.
|
|
|
|
///< This is a value in the range 0 (worst quality) through
|
|
|
|
///< 100 (best possible quality). A value of -1 indicates that this
|
|
|
|
///< device has no concept of a "signal quality".
|
2010-02-06 14:43:42 +01:00
|
|
|
virtual const cChannel *GetCurrentlyTunedTransponder(void) const;
|
|
|
|
///< Returns a pointer to the currently tuned transponder.
|
|
|
|
///< This is not one of the channels in the global cChannels list, but rather
|
|
|
|
///< a local copy. The result may be NULL if the device is not tuned to any
|
|
|
|
///< transponder.
|
2011-12-04 12:45:26 +01:00
|
|
|
virtual bool IsTunedToTransponder(const cChannel *Channel) const;
|
2006-04-09 09:12:47 +02:00
|
|
|
///< Returns true if this device is currently tuned to the given Channel's
|
|
|
|
///< transponder.
|
2011-12-04 12:45:26 +01:00
|
|
|
virtual bool MaySwitchTransponder(const cChannel *Channel) const;
|
|
|
|
///< Returns true if it is ok to switch to the Channel's transponder on this
|
|
|
|
///< device, without disturbing any other activities. If an occupied timeout
|
|
|
|
///< has been set for this device, and that timeout has not yet expired,
|
|
|
|
///< this function returns false,
|
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.
|
2016-12-06 14:17:39 +01:00
|
|
|
#define DEPRECATED_SETCURRENTCHANNEL
|
|
|
|
#ifdef DEPRECATED_SETCURRENTCHANNEL
|
2006-05-28 09:19:30 +02:00
|
|
|
static void SetCurrentChannel(const cChannel *Channel) { currentChannel = Channel ? Channel->Number() : 0; }
|
2016-12-06 14:17:39 +01:00
|
|
|
#endif
|
|
|
|
static void SetCurrentChannel(int ChannelNumber) { currentChannel = ChannelNumber; }
|
2006-05-28 09:19:30 +02:00
|
|
|
///< Sets the number of the current channel on the primary device, without
|
|
|
|
///< actually switching to it. This can be used to correct the current
|
|
|
|
///< channel number while replaying.
|
2006-03-26 09:46:58 +02:00
|
|
|
void ForceTransferMode(void);
|
|
|
|
///< Forces the device into transfermode for the current channel.
|
2011-10-16 14:02:34 +02:00
|
|
|
int Occupied(void) const;
|
|
|
|
///< Returns the number of seconds this device is still occupied for.
|
|
|
|
void SetOccupied(int Seconds);
|
|
|
|
///< Sets the occupied timeout for this device to the given number of
|
|
|
|
///< Seconds, This can be used to tune a device to a particular transponder
|
|
|
|
///< and make sure it will stay there for a certain amount of time, for
|
|
|
|
///< instance to collect EPG data. This function shall only be called
|
|
|
|
///< after the device has been successfully tuned to the requested transponder.
|
|
|
|
///< Seconds will be silently limited to MAXOCCUPIEDTIMEOUT. Values less than
|
|
|
|
///< 0 will be silently ignored.
|
2013-02-16 13:06:16 +01:00
|
|
|
virtual bool HasLock(int TimeoutMs = 0) const;
|
2004-01-04 12:30:00 +01:00
|
|
|
///< Returns true if the device has a lock on the requested transponder.
|
|
|
|
///< Default is true, a specific device implementation may return false
|
|
|
|
///< to indicate that it is not ready yet.
|
2004-10-30 15:10:50 +02:00
|
|
|
///< If TimeoutMs is not zero, waits for the given number of milliseconds
|
|
|
|
///< before returning false.
|
2013-02-16 13:06:16 +01:00
|
|
|
virtual bool HasProgramme(void) const;
|
2003-05-03 13:42:37 +02:00
|
|
|
///< Returns true if the device is currently showing any programme to
|
|
|
|
///< the user, either through replaying or live.
|
2002-06-16 12:57:31 +02:00
|
|
|
|
|
|
|
// PID handle facilities
|
|
|
|
|
|
|
|
private:
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual void Action(void);
|
|
|
|
protected:
|
2003-04-26 11:58:54 +02:00
|
|
|
enum ePidType { ptAudio, ptVideo, ptPcr, ptTeletext, ptDolby, ptOther };
|
2002-06-16 12:57:31 +02:00
|
|
|
class cPidHandle {
|
|
|
|
public:
|
|
|
|
int pid;
|
2009-12-25 15:26:16 +01:00
|
|
|
int streamType;
|
2002-08-04 14:57:29 +02:00
|
|
|
int handle;
|
2002-06-16 12:57:31 +02:00
|
|
|
int used;
|
2009-12-25 15:26:16 +01:00
|
|
|
cPidHandle(void) { pid = streamType = 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.
|
2009-12-25 15:26:16 +01:00
|
|
|
bool AddPid(int Pid, ePidType PidType = ptOther, int StreamType = 0);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Adds a PID to the set of PIDs this device shall receive.
|
2003-05-02 09:24:31 +02:00
|
|
|
void DelPid(int Pid, ePidType PidType = ptOther);
|
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).
|
2005-09-10 11:54:02 +02:00
|
|
|
///< Handle->used indicates how many receivers are using this PID.
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Type indicates some special types of PIDs, which the device may
|
|
|
|
///< need to set in a specific way.
|
2012-01-17 15:37:52 +01:00
|
|
|
public:
|
|
|
|
void DelLivePids(void);
|
|
|
|
///< Deletes the live viewing PIDs.
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
// Section filter facilities
|
|
|
|
|
|
|
|
private:
|
|
|
|
cSectionHandler *sectionHandler;
|
|
|
|
cEitFilter *eitFilter;
|
|
|
|
cPatFilter *patFilter;
|
2004-01-04 12:30:00 +01:00
|
|
|
cSdtFilter *sdtFilter;
|
2004-01-11 15:54:37 +01:00
|
|
|
cNitFilter *nitFilter;
|
2003-12-22 13:29:24 +01:00
|
|
|
protected:
|
|
|
|
void StartSectionHandler(void);
|
|
|
|
///< A derived device that provides section data must call
|
2008-02-09 16:28:15 +01:00
|
|
|
///< this function (typically in its constructor) to actually set
|
|
|
|
///< up the section handler.
|
|
|
|
void StopSectionHandler(void);
|
|
|
|
///< A device that has called StartSectionHandler() must call this
|
|
|
|
///< function (typically in its destructor) to stop the section
|
|
|
|
///< handler.
|
2003-12-22 13:29:24 +01:00
|
|
|
public:
|
|
|
|
virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask);
|
|
|
|
///< Opens a file handle for the given filter data.
|
|
|
|
///< A derived device that provides section data must
|
|
|
|
///< implement this function.
|
2012-08-26 13:09:01 +02:00
|
|
|
virtual int ReadFilter(int Handle, void *Buffer, size_t Length);
|
|
|
|
///< Reads data from a handle for the given filter.
|
|
|
|
///< A derived class need not implement this function, because this
|
|
|
|
///< is done by the default implementation.
|
2007-10-14 13:11:23 +02:00
|
|
|
virtual void CloseFilter(int Handle);
|
|
|
|
///< Closes a file handle that has previously been opened
|
|
|
|
///< by OpenFilter(). If this is as simple as calling close(Handle),
|
|
|
|
///< a derived class need not implement this function, because this
|
|
|
|
///< is done by the default implementation.
|
2003-12-22 13:29:24 +01:00
|
|
|
void AttachFilter(cFilter *Filter);
|
|
|
|
///< Attaches the given filter to this device.
|
|
|
|
void Detach(cFilter *Filter);
|
|
|
|
///< Detaches the given filter from this device.
|
|
|
|
|
2003-01-06 14:44:27 +01:00
|
|
|
// Common Interface facilities:
|
|
|
|
|
2007-01-07 14:46:14 +01:00
|
|
|
private:
|
|
|
|
time_t startScrambleDetection;
|
2017-01-09 13:42:41 +01:00
|
|
|
int scramblingTimeout;
|
2007-01-07 14:46:14 +01:00
|
|
|
cCamSlot *camSlot;
|
2003-01-06 14:44:27 +01:00
|
|
|
public:
|
2007-01-13 12:14:51 +01:00
|
|
|
virtual bool HasCi(void);
|
|
|
|
///< Returns true if this device has a Common Interface.
|
2012-08-26 13:59:37 +02:00
|
|
|
virtual bool HasInternalCam(void) { return false; }
|
|
|
|
///< Returns true if this device handles encrypted channels itself
|
|
|
|
///< without VDR assistance. This can be e.g. if the device is a
|
|
|
|
///< client that gets the stream from another VDR instance that has
|
|
|
|
///< already decrypted the stream. In this case ProvidesChannel()
|
|
|
|
///< shall check whether the channel can be decrypted.
|
2007-01-07 14:46:14 +01:00
|
|
|
void SetCamSlot(cCamSlot *CamSlot);
|
|
|
|
///< Sets the given CamSlot to be used with this device.
|
|
|
|
cCamSlot *CamSlot(void) const { return camSlot; }
|
|
|
|
///< Returns the CAM slot that is currently used with this device,
|
|
|
|
///< or NULL if no CAM slot is in use.
|
2003-01-06 14:44:27 +01:00
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
// Image Grab facilities
|
|
|
|
|
|
|
|
public:
|
2005-12-29 14:51:59 +01:00
|
|
|
virtual uchar *GrabImage(int &Size, bool Jpeg = true, int Quality = -1, int SizeX = -1, int SizeY = -1);
|
|
|
|
///< Grabs the currently visible screen image.
|
2013-02-16 15:26:45 +01:00
|
|
|
///< Size is the size of the returned data block.
|
|
|
|
///< If Jpeg is true it will write a JPEG file. Otherwise a PNM file will be written.
|
|
|
|
///< Quality is 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.
|
|
|
|
///< SizeX is the number of horizontal pixels in the frame (default is the current screen width).
|
|
|
|
///< SizeY is the number of vertical pixels in the frame (default is the current screen height).
|
|
|
|
///< Returns a pointer to the grabbed image data, or NULL in case of an error.
|
2005-12-29 14:51:59 +01:00
|
|
|
///< The caller takes ownership of the returned memory and must free() it once it isn't needed any more.
|
|
|
|
bool GrabImageFile(const char *FileName, bool Jpeg = true, int Quality = -1, int SizeX = -1, int SizeY = -1);
|
|
|
|
///< Calls GrabImage() and stores the resulting image in a file with the given name.
|
2013-02-16 15:26:45 +01:00
|
|
|
///< Returns true if all went well.
|
2005-12-29 14:51:59 +01:00
|
|
|
///< The caller is responsible for making sure that the given file name
|
|
|
|
///< doesn't lead to overwriting any important other file.
|
2002-06-16 12:57:31 +02:00
|
|
|
|
|
|
|
// Video format facilities
|
|
|
|
|
|
|
|
public:
|
2005-02-20 12:01:05 +01:00
|
|
|
virtual void SetVideoDisplayFormat(eVideoDisplayFormat VideoDisplayFormat);
|
|
|
|
///< Sets the video display format to the given one (only useful
|
|
|
|
///< if this device has an MPEG decoder).
|
|
|
|
///< A derived class must first call the base class function!
|
2014-03-15 14:05:15 +01:00
|
|
|
///< NOTE: this is only for SD devices. HD devices shall implement their
|
|
|
|
///< own setup menu with the necessary parameters for controlling output.
|
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).
|
2014-03-15 14:05:15 +01:00
|
|
|
///< NOTE: this is only for SD devices. HD devices shall implement their
|
|
|
|
///< own setup menu with the necessary parameters for controlling output.
|
|
|
|
#ifdef DEPRECATED_VIDEOSYSTEM
|
|
|
|
virtual eVideoSystem GetVideoSystem(void) { return vsPAL; }
|
2003-08-15 13:05:50 +02:00
|
|
|
///< Returns the video system of the currently displayed material
|
|
|
|
///< (default is PAL).
|
2014-03-15 14:05:15 +01:00
|
|
|
///< This function is deprecated and will be removed in a future version!
|
|
|
|
#endif
|
2009-06-06 11:20:52 +02:00
|
|
|
virtual void GetVideoSize(int &Width, int &Height, double &VideoAspect);
|
2012-01-18 12:12:49 +01:00
|
|
|
///< Returns the Width, Height and VideoAspect ratio of the currently
|
2011-03-26 10:45:05 +01:00
|
|
|
///< displayed video material. Width and Height are given in pixel
|
|
|
|
///< (e.g. 720x576) and VideoAspect is e.g. 1.33333 for a 4:3 broadcast,
|
|
|
|
///< or 1.77778 for 16:9.
|
2009-06-01 14:56:28 +02:00
|
|
|
///< The default implementation returns 0 for Width and Height
|
2009-06-06 11:20:52 +02:00
|
|
|
///< and 1.0 for VideoAspect.
|
|
|
|
virtual void GetOsdSize(int &Width, int &Height, double &PixelAspect);
|
2012-01-18 12:12:49 +01:00
|
|
|
///< Returns the Width, Height and PixelAspect ratio the OSD should use
|
2009-06-06 11:20:52 +02:00
|
|
|
///< to best fit the resolution of the output device. If PixelAspect
|
|
|
|
///< is not 1.0, the OSD may take this as a hint to scale its
|
2009-06-01 14:56:28 +02:00
|
|
|
///< graphics in a way that, e.g., a circle will actually
|
|
|
|
///< show up as a circle on the screen, and not as an ellipse.
|
2009-06-06 11:20:52 +02:00
|
|
|
///< Values greater than 1.0 mean to stretch the graphics in the
|
|
|
|
///< vertical direction (or shrink it in the horizontal direction,
|
|
|
|
///< depending on which dimension shall be fixed). Values less than
|
|
|
|
///< 1.0 work the other way round. Note that the OSD is not guaranteed
|
|
|
|
///< to actually use this hint.
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2004-12-17 14:55:49 +01:00
|
|
|
// Track facilities
|
|
|
|
|
|
|
|
private:
|
|
|
|
tTrackId availableTracks[ttMaxTrackTypes];
|
|
|
|
eTrackType currentAudioTrack;
|
2007-10-12 14:52:30 +02:00
|
|
|
eTrackType currentSubtitleTrack;
|
2006-01-08 10:13:38 +01:00
|
|
|
cMutex mutexCurrentAudioTrack;
|
2007-10-12 14:52:30 +02:00
|
|
|
cMutex mutexCurrentSubtitleTrack;
|
2005-02-06 11:33:13 +01:00
|
|
|
int currentAudioTrackMissingCount;
|
2007-10-12 14:52:30 +02:00
|
|
|
bool autoSelectPreferredSubtitleLanguage;
|
2013-02-01 12:06:50 +01:00
|
|
|
bool keepTracks;
|
2007-11-03 14:32:03 +01:00
|
|
|
int pre_1_3_19_PrivateStream;
|
2004-12-17 14:55:49 +01:00
|
|
|
protected:
|
|
|
|
virtual void SetAudioTrackDevice(eTrackType Type);
|
|
|
|
///< Sets the current audio track to the given value.
|
2008-02-16 13:59:09 +01:00
|
|
|
virtual void SetSubtitleTrackDevice(eTrackType Type);
|
|
|
|
///< Sets the current subtitle track to the given value.
|
2004-12-17 14:55:49 +01:00
|
|
|
public:
|
2006-04-14 14:47:01 +02:00
|
|
|
void ClrAvailableTracks(bool DescriptionsOnly = false, bool IdsOnly = false);
|
2011-12-04 13:40:52 +01:00
|
|
|
///< Clears the list of currently available tracks. If DescriptionsOnly
|
2006-04-14 14:47:01 +02:00
|
|
|
///< is true, only the track descriptions will be cleared. With IdsOnly
|
|
|
|
///< set to true only the ids will be cleared. IdsOnly is only taken
|
|
|
|
///< into account if DescriptionsOnly is false.
|
2005-02-06 11:44:56 +01:00
|
|
|
bool SetAvailableTrack(eTrackType Type, int Index, uint16_t Id, const char *Language = NULL, const char *Description = NULL);
|
2004-12-17 14:55:49 +01:00
|
|
|
///< Sets the track of the given Type and Index to the given values.
|
|
|
|
///< Type must be one of the basic eTrackType values, like ttAudio or ttDolby.
|
|
|
|
///< Index tells which track of the given basic type is meant.
|
2005-02-06 11:44:56 +01:00
|
|
|
///< If Id is 0 any existing id will be left untouched and only the
|
2005-01-02 15:11:44 +01:00
|
|
|
///< given Language and Description will be set.
|
2013-02-16 15:26:45 +01:00
|
|
|
///< Returns true if the track was set correctly, false otherwise.
|
2004-12-17 14:55:49 +01:00
|
|
|
const tTrackId *GetTrack(eTrackType Type);
|
|
|
|
///< Returns a pointer to the given track id, or NULL if Type is not
|
|
|
|
///< less than ttMaxTrackTypes.
|
2007-10-12 14:52:30 +02:00
|
|
|
int NumTracks(eTrackType FirstTrack, eTrackType LastTrack) const;
|
|
|
|
///< Returns the number of tracks in the given range that are currently
|
|
|
|
///< available.
|
2004-12-17 14:55:49 +01:00
|
|
|
int NumAudioTracks(void) const;
|
|
|
|
///< Returns the number of audio tracks that are currently available.
|
|
|
|
///< This is just for information, to quickly find out whether there
|
|
|
|
///< is more than one audio track.
|
2007-10-12 14:52:30 +02:00
|
|
|
int NumSubtitleTracks(void) const;
|
|
|
|
///< Returns the number of subtitle tracks that are currently available.
|
2012-02-14 14:47:59 +01:00
|
|
|
eTrackType GetCurrentAudioTrack(void) const { return currentAudioTrack; }
|
2004-12-17 14:55:49 +01:00
|
|
|
bool SetCurrentAudioTrack(eTrackType Type);
|
|
|
|
///< Sets the current audio track to the given Type.
|
2013-02-16 15:26:45 +01:00
|
|
|
///< Returns true if Type is a valid audio track, false otherwise.
|
2012-02-14 14:47:59 +01:00
|
|
|
eTrackType GetCurrentSubtitleTrack(void) const { return currentSubtitleTrack; }
|
2007-10-12 14:52:30 +02:00
|
|
|
bool SetCurrentSubtitleTrack(eTrackType Type, bool Manual = false);
|
|
|
|
///< Sets the current subtitle track to the given Type.
|
|
|
|
///< IF Manual is true, no automatic preferred subtitle language selection
|
|
|
|
///< will be done for the rest of the current replay session, or until
|
|
|
|
///< the channel is changed.
|
2013-02-16 15:26:45 +01:00
|
|
|
///< Returns true if Type is a valid subtitle track, false otherwise.
|
2005-02-06 11:33:13 +01:00
|
|
|
void EnsureAudioTrack(bool Force = false);
|
|
|
|
///< Makes sure an audio track is selected that is actually available.
|
|
|
|
///< If Force is true, the language and Dolby Digital settings will
|
|
|
|
///< be verified even if the current audio track is available.
|
2007-10-12 14:52:30 +02:00
|
|
|
void EnsureSubtitleTrack(void);
|
|
|
|
///< Makes sure one of the preferred language subtitle tracks is selected.
|
|
|
|
///< Only has an effect if Setup.DisplaySubtitles is on.
|
2013-02-01 12:06:50 +01:00
|
|
|
void SetKeepTracks(bool KeepTracks) { keepTracks = KeepTracks; }
|
|
|
|
///< Controls whether the current audio and subtitle track settings shall
|
|
|
|
///< be kept as they currently are, or if they shall be automatically
|
|
|
|
///< adjusted. This is used when pausing live video.
|
2004-12-17 14:55:49 +01: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:
|
2005-01-06 13:50:17 +01:00
|
|
|
virtual int GetAudioChannelDevice(void);
|
|
|
|
///< Gets the current audio channel, which is stereo (0), mono left (1) or
|
|
|
|
///< mono right (2).
|
|
|
|
virtual void SetAudioChannelDevice(int AudioChannel);
|
|
|
|
///< Sets the audio channel to stereo (0), mono left (1) or mono right (2).
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual void SetVolumeDevice(int Volume);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Sets the audio volume on this device (Volume = 0...255).
|
2005-01-06 13:50:17 +01:00
|
|
|
virtual void SetDigitalAudioDevice(bool On);
|
2014-03-15 14:05:15 +01:00
|
|
|
///< Tells the output device that the current audio track is Dolby Digital.
|
|
|
|
///< Only used by the original "full featured" DVB cards - do not use for new
|
|
|
|
///< developments!
|
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.
|
2005-01-06 13:50:17 +01:00
|
|
|
int GetAudioChannel(void);
|
|
|
|
///< Gets the current audio channel, which is stereo (0), mono left (1) or
|
|
|
|
///< mono right (2).
|
|
|
|
void SetAudioChannel(int AudioChannel);
|
|
|
|
///< Sets the audio channel to stereo (0), mono left (1) or mono right (2).
|
|
|
|
///< Any other values will be silently ignored.
|
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???
|
|
|
|
|
|
|
|
// Player facilities
|
|
|
|
|
|
|
|
private:
|
|
|
|
cPlayer *player;
|
2008-08-15 14:49:34 +02:00
|
|
|
cPatPmtParser patPmtParser;
|
|
|
|
cTsToPes tsToPesVideo;
|
|
|
|
cTsToPes tsToPesAudio;
|
|
|
|
cTsToPes tsToPesSubtitle;
|
2009-01-25 11:39:43 +01:00
|
|
|
bool isPlayingVideo;
|
2002-08-04 14:57:29 +02:00
|
|
|
protected:
|
2009-12-05 11:32:31 +01:00
|
|
|
const cPatPmtParser *PatPmtParser(void) const { return &patPmtParser; }
|
|
|
|
///< Returns a pointer to the patPmtParser, so that a derived device
|
|
|
|
///< can use the stream information from it.
|
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.
|
2013-02-16 15:26:45 +01:00
|
|
|
///< Returns true if the operation was successful.
|
2004-12-17 14:55:49 +01:00
|
|
|
virtual int PlayVideo(const uchar *Data, int Length);
|
|
|
|
///< Plays the given data block as video.
|
|
|
|
///< Data points to exactly one complete PES packet of the given Length.
|
|
|
|
///< PlayVideo() shall process the packet either as a whole (returning
|
2009-01-16 14:27:22 +01:00
|
|
|
///< Length) or not at all (returning 0 or -1 and setting 'errno' accordingly).
|
2013-02-16 15:26:45 +01:00
|
|
|
///< Returns the number of bytes actually taken from Data, or -1
|
2004-12-17 14:55:49 +01:00
|
|
|
///< in case of an error.
|
2006-02-04 10:24:43 +01:00
|
|
|
virtual int PlayAudio(const uchar *Data, int Length, uchar Id);
|
2004-12-17 14:55:49 +01:00
|
|
|
///< Plays the given data block as audio.
|
|
|
|
///< Data points to exactly one complete PES packet of the given Length.
|
2006-02-04 10:24:43 +01:00
|
|
|
///< Id indicates the type of audio data this packet holds.
|
2004-12-17 14:55:49 +01:00
|
|
|
///< PlayAudio() shall process the packet either as a whole (returning
|
2009-01-16 14:27:22 +01:00
|
|
|
///< Length) or not at all (returning 0 or -1 and setting 'errno' accordingly).
|
2013-02-16 15:26:45 +01:00
|
|
|
///< Returns the number of bytes actually taken from Data, or -1
|
2007-10-12 14:52:30 +02:00
|
|
|
///< in case of an error.
|
|
|
|
virtual int PlaySubtitle(const uchar *Data, int Length);
|
|
|
|
///< Plays the given data block as a subtitle.
|
|
|
|
///< Data points to exactly one complete PES packet of the given Length.
|
|
|
|
///< PlaySubtitle() shall process the packet either as a whole (returning
|
2009-01-16 14:27:22 +01:00
|
|
|
///< Length) or not at all (returning 0 or -1 and setting 'errno' accordingly).
|
2013-02-16 15:26:45 +01:00
|
|
|
///< Returns the number of bytes actually taken from Data, or -1
|
2004-12-17 14:55:49 +01:00
|
|
|
///< in case of an error.
|
|
|
|
virtual int PlayPesPacket(const uchar *Data, int Length, bool VideoOnly = false);
|
|
|
|
///< Plays the single PES packet in Data with the given Length.
|
|
|
|
///< If VideoOnly is true, only the video will be displayed,
|
|
|
|
///< which is necessary for trick modes like 'fast forward'.
|
|
|
|
///< Data must point to one single, complete PES packet.
|
2008-08-15 14:49:34 +02:00
|
|
|
virtual int PlayTsVideo(const uchar *Data, int Length);
|
|
|
|
///< Plays the given data block as video.
|
|
|
|
///< Data points to exactly one complete TS packet of the given Length
|
|
|
|
///< (which is always TS_SIZE).
|
|
|
|
///< PlayTsVideo() shall process the packet either as a whole (returning
|
2009-01-06 14:41:11 +01:00
|
|
|
///< Length) or not at all (returning 0 or -1 and setting 'errno' accordingly).
|
2008-08-15 14:49:34 +02:00
|
|
|
///< The default implementation collects all incoming TS payload belonging
|
|
|
|
///< to one PES packet and calls PlayVideo() with the resulting packet.
|
|
|
|
virtual int PlayTsAudio(const uchar *Data, int Length);
|
|
|
|
///< Plays the given data block as audio.
|
|
|
|
///< Data points to exactly one complete TS packet of the given Length
|
|
|
|
///< (which is always TS_SIZE).
|
|
|
|
///< PlayTsAudio() shall process the packet either as a whole (returning
|
2009-01-06 14:41:11 +01:00
|
|
|
///< Length) or not at all (returning 0 or -1 and setting 'errno' accordingly).
|
2008-08-15 14:49:34 +02:00
|
|
|
///< The default implementation collects all incoming TS payload belonging
|
|
|
|
///< to one PES packet and calls PlayAudio() with the resulting packet.
|
|
|
|
virtual int PlayTsSubtitle(const uchar *Data, int Length);
|
|
|
|
///< Plays the given data block as a subtitle.
|
|
|
|
///< Data points to exactly one complete TS packet of the given Length
|
|
|
|
///< (which is always TS_SIZE).
|
|
|
|
///< PlayTsSubtitle() shall process the packet either as a whole (returning
|
2009-01-06 14:41:11 +01:00
|
|
|
///< Length) or not at all (returning 0 or -1 and setting 'errno' accordingly).
|
2008-08-15 14:49:34 +02:00
|
|
|
///< The default implementation collects all incoming TS payload belonging
|
|
|
|
///< to one PES packet and displays the resulting subtitle via the OSD.
|
2002-06-16 12:57:31 +02:00
|
|
|
public:
|
2003-11-07 14:16:25 +01:00
|
|
|
virtual int64_t GetSTC(void);
|
|
|
|
///< Gets the current System Time Counter, which can be used to
|
2010-10-24 12:12:07 +02:00
|
|
|
///< synchronize audio, video and subtitles. If this device is able to
|
|
|
|
///< replay, it must provide an STC.
|
2009-03-13 14:45:12 +01:00
|
|
|
///< The value returned doesn't need to be an actual "clock" value,
|
|
|
|
///< it is sufficient if it holds the PTS (Presentation Time Stamp) of
|
|
|
|
///< the most recently presented frame. A proper value must be returned
|
|
|
|
///< in normal replay mode as well as in any trick modes (like slow motion,
|
|
|
|
///< fast forward/rewind).
|
|
|
|
///< Only the lower 32 bit of this value are actually used, since some
|
|
|
|
///< devices can't handle the msb correctly.
|
2009-01-25 11:39:43 +01:00
|
|
|
virtual bool IsPlayingVideo(void) const { return isPlayingVideo; }
|
2013-02-16 15:26:45 +01:00
|
|
|
///< Returns true if the currently attached player has delivered
|
2009-01-25 11:39:43 +01:00
|
|
|
///< any video packets.
|
2012-12-04 11:52:58 +01:00
|
|
|
virtual cRect CanScaleVideo(const cRect &Rect, int Alignment = taCenter) { return cRect::Null; }
|
|
|
|
///< Asks the output device whether it can scale the currently shown video in
|
|
|
|
///< such a way that it fits into the given Rect, while retaining its proper
|
|
|
|
///< aspect ratio. If the scaled video doesn't exactly fit into Rect, Alignment
|
|
|
|
///< is used to determine how to align the actual rectangle with the requested
|
|
|
|
///< one. The actual rectangle can be smaller, larger or the same size as the
|
|
|
|
///< given Rect, and its location may differ, depending on the capabilities of
|
|
|
|
///< the output device, which may not be able to display a scaled video at
|
|
|
|
///< arbitrary sizes and locations. The device shall, however, do its best to
|
|
|
|
///< match the requested Rect as closely as possible, preferring a size and
|
|
|
|
///< location that fits completely into the requested Rect if possible.
|
|
|
|
///< Returns the rectangle that can actually be used when scaling the video.
|
|
|
|
///< A skin plugin using this function should rearrange its content according
|
|
|
|
///< to the rectangle returned from calling this function, and should especially
|
|
|
|
///< be prepared for cases where the returned rectangle is way off the requested
|
|
|
|
///< Rect, or even Null. In such cases, the skin may want to fall back to
|
|
|
|
///< working with full screen video.
|
2013-01-03 08:55:37 +01:00
|
|
|
///< The coordinates of Rect are in the range of the width and height returned
|
|
|
|
///< by GetOsdSize().
|
2012-12-04 11:52:58 +01:00
|
|
|
///< If this device can't scale the video, a Null rectangle is returned (this
|
|
|
|
///< is also the default implementation).
|
|
|
|
virtual void ScaleVideo(const cRect &Rect = cRect::Null) {}
|
|
|
|
///< Scales the currently shown video in such a way that it fits into the given
|
|
|
|
///< Rect. Rect should be one retrieved through a previous call to
|
|
|
|
///< CanScaleVideo() (otherwise results may be undefined).
|
|
|
|
///< Even if video output is scaled, the functions GetVideoSize() and
|
|
|
|
///< GetOsdSize() must still return the same values as if in full screen mode!
|
|
|
|
///< If this device can't scale the video, nothing happens.
|
|
|
|
///< To restore full screen video, call this function with a Null rectangle.
|
2007-10-13 12:28:35 +02:00
|
|
|
virtual bool HasIBPTrickSpeed(void) { return false; }
|
|
|
|
///< Returns true if this device can handle all frames in 'fast forward'
|
|
|
|
///< trick speeds.
|
2013-12-25 13:36:51 +01:00
|
|
|
virtual void TrickSpeed(int Speed, bool Forward);
|
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
|
2013-12-25 13:36:51 +01:00
|
|
|
///< times. Forward is true if replay is done in the normal (forward)
|
|
|
|
///< direction, false if it is done reverse.
|
2007-07-22 11:29:37 +02:00
|
|
|
///< The cDvbPlayer uses the following values for the various speeds:
|
|
|
|
///< 1x 2x 3x
|
|
|
|
///< Fast Forward 6 3 1
|
|
|
|
///< Fast Reverse 6 3 1
|
|
|
|
///< Slow Forward 8 4 2
|
|
|
|
///< Slow Reverse 63 48 24
|
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.
|
2013-12-25 13:12:07 +01:00
|
|
|
///< Data points either to a series of TS (first byte is 0x47) or PES (first byte
|
2009-01-06 14:41:11 +01:00
|
|
|
///< is 0x00) data of the given Length. The default implementation
|
|
|
|
///< converts TS to PES and calls itself again, allowing a derived class
|
|
|
|
///< to display PES if it can't handle TS directly.
|
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
|
2011-12-04 13:40:52 +01:00
|
|
|
///< of milliseconds before returning in case it can't accept any data.
|
2004-06-19 08:58:14 +02:00
|
|
|
virtual bool Flush(int TimeoutMs = 0);
|
|
|
|
///< Returns true if the device's output buffers are empty, i. e. any
|
2011-12-04 13:40:52 +01:00
|
|
|
///< data which was buffered so far has been processed.
|
2004-06-19 08:58:14 +02:00
|
|
|
///< If TimeoutMs is not zero, the device will wait up to the given
|
|
|
|
///< number of milliseconds before returning in case there is still
|
2009-03-28 21:53:26 +01:00
|
|
|
///< data in the buffers.
|
2004-12-17 14:55:49 +01:00
|
|
|
virtual int PlayPes(const uchar *Data, int Length, bool VideoOnly = false);
|
|
|
|
///< Plays all valid PES packets in Data with the given Length.
|
|
|
|
///< If Data is NULL any leftover data from a previous call will be
|
|
|
|
///< discarded. If VideoOnly is true, only the video will be displayed,
|
|
|
|
///< which is necessary for trick modes like 'fast forward'.
|
|
|
|
///< Data should point to a sequence of complete PES packets. If the
|
|
|
|
///< last packet in Data is not complete, it will be copied and combined
|
|
|
|
///< to a complete packet with data from the next call to PlayPes().
|
|
|
|
///< That way any functions called from within PlayPes() will be
|
|
|
|
///< guaranteed to always receive complete PES packets.
|
2008-08-15 14:49:34 +02:00
|
|
|
virtual int PlayTs(const uchar *Data, int Length, bool VideoOnly = false);
|
|
|
|
///< Plays the given TS packet.
|
|
|
|
///< If VideoOnly is true, only the video will be displayed,
|
|
|
|
///< which is necessary for trick modes like 'fast forward'.
|
|
|
|
///< Data points to a single TS packet, Length is always TS_SIZE (the total
|
|
|
|
///< size of a single TS packet).
|
2009-01-06 14:41:11 +01:00
|
|
|
///< If Data is NULL any leftover data from a previous call will be
|
|
|
|
///< discarded.
|
2008-08-15 14:49:34 +02:00
|
|
|
///< A derived device can reimplement this function to handle the
|
|
|
|
///< TS packets itself. Any packets the derived function can't handle
|
|
|
|
///< must be sent to the base class function. This applies especially
|
|
|
|
///< to the PAT/PMT packets.
|
|
|
|
///< Returns -1 in case of error, otherwise the number of actually
|
2009-04-05 12:29:27 +02:00
|
|
|
///< processed bytes is returned.
|
|
|
|
///< PlayTs() shall process the TS packets either as a whole (returning
|
2013-01-22 17:01:16 +01:00
|
|
|
///< TS_SIZE) or not at all, returning 0 or -1 and setting 'errno' accordingly).
|
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.
|
2006-02-04 14:58:24 +01:00
|
|
|
bool Transferring(void) const;
|
|
|
|
///< Returns true if we are currently in Transfer Mode.
|
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-06-16 12:57:31 +02:00
|
|
|
|
|
|
|
// Receiver facilities
|
|
|
|
|
|
|
|
private:
|
2011-12-04 12:45:26 +01:00
|
|
|
mutable cMutex mutexReceiver;
|
2002-06-16 12:57:31 +02:00
|
|
|
cReceiver *receiver[MAXRECEIVERS];
|
2007-01-07 14:46:14 +01:00
|
|
|
public:
|
2002-09-29 13:40:45 +02:00
|
|
|
int Priority(void) const;
|
2012-02-25 14:44:43 +01:00
|
|
|
///< Returns the priority of the current receiving session (-MAXPRIORITY..MAXPRIORITY),
|
|
|
|
///< or IDLEPRIORITY if no receiver is currently active.
|
2007-01-07 14:46:14 +01:00
|
|
|
protected:
|
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:
|
2012-03-02 10:19:00 +01:00
|
|
|
bool Receiving(bool Dummy = false) const;
|
|
|
|
///< Returns true if we are currently receiving. The parameter has no meaning (for backwards compatibility only).
|
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.
|
2005-06-05 13:37:37 +02:00
|
|
|
void DetachAll(int Pid);
|
|
|
|
///< Detaches all receivers from this device for this pid.
|
2011-12-04 12:45:26 +01:00
|
|
|
virtual void DetachAllReceivers(void);
|
2006-01-06 13:55:57 +01:00
|
|
|
///< Detaches all receivers 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
|
2004-02-14 11:29:57 +01:00
|
|
|
/// re-synchronizes after broken packets.
|
2002-09-08 09:03:10 +02:00
|
|
|
|
2004-10-16 09:36:28 +02:00
|
|
|
class cTSBuffer : public cThread {
|
2002-09-08 09:03:10 +02:00
|
|
|
private:
|
|
|
|
int f;
|
|
|
|
int cardIndex;
|
2004-10-16 09:36:28 +02:00
|
|
|
bool delivered;
|
|
|
|
cRingBufferLinear *ringBuffer;
|
|
|
|
virtual void Action(void);
|
2002-09-08 09:03:10 +02:00
|
|
|
public:
|
|
|
|
cTSBuffer(int File, int Size, int CardIndex);
|
2013-12-28 13:29:54 +01:00
|
|
|
virtual ~cTSBuffer();
|
|
|
|
uchar *Get(int *Available = NULL);
|
|
|
|
///< Returns a pointer to the first TS packet in the buffer. If Available is given,
|
|
|
|
///< it will return the total number of consecutive bytes pointed to in the buffer.
|
|
|
|
///< It is guaranteed that the returned pointer points to a TS_SYNC_BYTE and that
|
|
|
|
///< there are at least TS_SIZE bytes in the buffer. Otherwise NULL will be
|
|
|
|
///< returned and the value in Available (if given) is undefined.
|
|
|
|
///< Each call to Get() returns a pointer to the next TS packet in the buffer.
|
2014-01-02 10:47:08 +01:00
|
|
|
void Skip(int Count);
|
|
|
|
///< If after a call to Get() more or less than TS_SIZE of the available data
|
|
|
|
///< has been processed, a call to Skip() with the number of processed bytes
|
|
|
|
///< will disable the automatic incrementing of the data pointer as described
|
|
|
|
///< in Get() and skip the given number of bytes instead. Count may be 0 if the
|
|
|
|
///< caller wants the previous TS packet to be delivered again in the next call
|
|
|
|
///< to Get().
|
2002-09-08 09:03:10 +02:00
|
|
|
};
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
#endif //__DEVICE_H
|