SASC-NG
DVBSoftCAM

cDvbDevice Class Reference

The cDvbDevice implements a DVB device which can be accessed through the Linux DVB driver API. More...

#include <dvbdevice.h>

Inheritance diagram for cDvbDevice:

List of all members.

Public Member Functions

 cDvbDevice (int n)
virtual ~cDvbDevice ()
virtual bool Ready (void)
virtual bool HasDecoder (void) const
 Tells whether this device has an MPEG decoder.
virtual cSpuDecoder * GetSpuDecoder (void)
virtual bool ProvidesSource (int Source) const
 Returns true if this device can provide the given source.
virtual bool ProvidesTransponder (const cChannel *Channel) const
virtual bool ProvidesChannel (const cChannel *Channel, int Priority=-1, bool *NeedsDetachReceivers=NULL) const
virtual bool IsTunedToTransponder (const cChannel *Channel)
virtual bool SetChannelDevice (const cChannel *Channel, bool LiveView)
 Sets the device to the given channel (actual physical setup).
virtual bool HasLock (int TimeoutMs=0)
virtual bool HasCi (void)
 Returns true if this device has a Common Interface.
virtual uchar * GrabImage (int &Size, bool Jpeg=true, int Quality=-1, int SizeX=-1, int SizeY=-1)
virtual void SetVideoDisplayFormat (eVideoDisplayFormat VideoDisplayFormat)
virtual void SetVideoFormat (bool VideoFormat16_9)
virtual eVideoSystem GetVideoSystem (void)
virtual int64_t GetSTC (void)
virtual void TrickSpeed (int Speed)
virtual void Clear (void)
virtual void Play (void)
virtual void Freeze (void)
 Puts the device into "freeze frame" mode.
virtual void Mute (void)
virtual void StillPicture (const uchar *Data, int Length)
 Displays the given I-frame as a still picture.
virtual bool Poll (cPoller &Poller, int TimeoutMs=0)
virtual bool Flush (int TimeoutMs=0)

Static Public Member Functions

static bool Initialize (void)
static void SetTransferModeForDolbyDigital (int Mode)

Protected Member Functions

virtual void MakePrimaryDevice (bool On)
virtual bool SetPid (cPidHandle *Handle, int Type, bool On)
virtual int OpenFilter (u_short Pid, u_char Tid, u_char Mask)
virtual void CloseFilter (int Handle)
virtual void SetAudioTrackDevice (eTrackType Type)
 Sets the current audio track to the given value.
virtual int GetAudioChannelDevice (void)
virtual void SetAudioChannelDevice (int AudioChannel)
 Sets the audio channel to stereo (0), mono left (1) or mono right (2).
virtual void SetVolumeDevice (int Volume)
 Sets the audio volume on this device (Volume = 0...255).
virtual void SetDigitalAudioDevice (bool On)
virtual bool CanReplay (void) const
 Returns true if this device can currently start a replay session.
virtual bool SetPlayMode (ePlayMode PlayMode)
virtual int PlayVideo (const uchar *Data, int Length)
virtual int PlayAudio (const uchar *Data, int Length, uchar Id)
virtual bool OpenDvr (void)
virtual void CloseDvr (void)
 Shuts down the DVR.
virtual bool GetTSPacket (uchar *&Data)

Protected Attributes

ePlayMode playMode

Detailed Description

The cDvbDevice implements a DVB device which can be accessed through the Linux DVB driver API.

Definition at line 28 of file dvbdevice.h.


Constructor & Destructor Documentation

cDvbDevice::cDvbDevice ( int  n)

Definition at line 50 of file dvbdevice.cpp.

References cDevice::cardIndex.

{
    //int camfd;
    fd_video = 0;
    cardIndex=n;
    //For sasc-ng, we never use the ca device here!
    //camfd=DvbOpen("ca",cardIndex,O_RDWR|O_NONBLOCK);
    //if (camfd > 0)
    //{
    //    fd_video = 1;
    //    close(camfd);
    //}
    //else
    //    fd_video = 0;
    //printf("HW Decoder: %s\n", fd_video ? "Yes" : "No");
}
cDvbDevice::~cDvbDevice ( ) [virtual]

Definition at line 67 of file dvbdevice.cpp.

{
}

Member Function Documentation

bool cDvbDevice::CanReplay ( void  ) const [protected, virtual]

Returns true if this device can currently start a replay session.

Reimplemented from cDevice.

Definition at line 175 of file dvbdevice.cpp.

{
  return false;
}
void cDvbDevice::Clear ( void  ) [virtual]

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.

Reimplemented from cDevice.

Definition at line 194 of file dvbdevice.cpp.

{
}
void cDvbDevice::CloseDvr ( void  ) [protected, virtual]

Shuts down the DVR.

Reimplemented from cDevice.

Definition at line 239 of file dvbdevice.cpp.

{
}
void cDvbDevice::CloseFilter ( int  Handle) [protected, virtual]

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.

Reimplemented from cDevice.

Definition at line 136 of file dvbdevice.cpp.

{
  close(Handle);
}
bool cDvbDevice::Flush ( int  TimeoutMs = 0) [virtual]

Returns true if the device's output buffers are empty, i. e. any data which was bufferd so far has been processed. If TimeoutMs is not zero, the device will wait up to the given number of milliseconds before returning in case there is still data in the buffers..

Reimplemented from cDevice.

Definition at line 219 of file dvbdevice.cpp.

{
  return true;
}
void cDvbDevice::Freeze ( void  ) [virtual]

Puts the device into "freeze frame" mode.

Reimplemented from cDevice.

Definition at line 202 of file dvbdevice.cpp.

{
}
int cDvbDevice::GetAudioChannelDevice ( void  ) [protected, virtual]

Gets the current audio channel, which is stereo (0), mono left (1) or mono right (2).

Reimplemented from cDevice.

Definition at line 272 of file dvbdevice.cpp.

{
  return 0;
}
cSpuDecoder * cDvbDevice::GetSpuDecoder ( void  ) [virtual]

Returns a pointer to the device's SPU decoder (or NULL, if this device doesn't have an SPU decoder).

Reimplemented from cDevice.

Definition at line 90 of file dvbdevice.cpp.

References NULL.

{
  return NULL;
}
int64_t cDvbDevice::GetSTC ( void  ) [virtual]

Gets the current System Time Counter, which can be used to synchronize audio and video. If this device is unable to provide the STC, -1 will be returned.

Reimplemented from cDevice.

Definition at line 185 of file dvbdevice.cpp.

{
  return -1;
}
bool cDvbDevice::GetTSPacket ( uchar *&  Data) [protected, virtual]

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.

Reimplemented from cDevice.

Definition at line 243 of file dvbdevice.cpp.

{
  return false;
}
eVideoSystem cDvbDevice::GetVideoSystem ( void  ) [virtual]

Returns the video system of the currently displayed material (default is PAL).

Reimplemented from cDevice.

Definition at line 99 of file dvbdevice.cpp.

References vsNTSC.

{
  return vsNTSC;
}
uchar * cDvbDevice::GrabImage ( int &  Size,
bool  Jpeg = true,
int  Quality = -1,
int  SizeX = -1,
int  SizeY = -1 
) [virtual]

Grabs the currently visible screen image.

Parameters:
SizeThe size of the returned data block.
JpegIf true will write a JPEG file. Otherwise a PNM file will be written.
QualityThe 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.
SizeXThe number of horizontal pixels in the frame (default is the current screen width).
SizeYThe 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. The caller takes ownership of the returned memory and must free() it once it isn't needed any more.

Reimplemented from cDevice.

Definition at line 263 of file dvbdevice.cpp.

References NULL.

{
  return NULL;
}
bool cDvbDevice::HasCi ( void  ) [virtual]

Returns true if this device has a Common Interface.

Reimplemented from cDevice.

Definition at line 258 of file dvbdevice.cpp.

{          
  return false;
}             
bool cDvbDevice::HasDecoder ( void  ) const [virtual]

Tells whether this device has an MPEG decoder.

Reimplemented from cDevice.

Definition at line 85 of file dvbdevice.cpp.

{
  return fd_video;
}
bool cDvbDevice::HasLock ( int  TimeoutMs = 0) [virtual]

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. If TimeoutMs is not zero, waits for the given number of milliseconds before returning false.

Reimplemented from cDevice.

Definition at line 162 of file dvbdevice.cpp.

{
  return true;
}
bool cDvbDevice::Initialize ( void  ) [static]

Initializes the DVB devices. Must be called before accessing any DVB functions.

Returns:
True if any devices are available.

Reimplemented in cScDevices.

Definition at line 76 of file dvbdevice.cpp.

{
  return true;
}
bool cDvbDevice::IsTunedToTransponder ( const cChannel *  Channel) [virtual]

Returns true if this device is currently tuned to the given Channel's transponder.

Reimplemented from cDevice.

Definition at line 253 of file dvbdevice.cpp.

{
  return true;
}
void cDvbDevice::MakePrimaryDevice ( bool  On) [protected, virtual]

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.

Reimplemented from cDevice.

Definition at line 81 of file dvbdevice.cpp.

{
}
void cDvbDevice::Mute ( void  ) [virtual]

Turns off audio while replaying. A derived class must call the base class function to make sure all registered cAudio objects are notified.

Reimplemented from cDevice.

Definition at line 206 of file dvbdevice.cpp.

{
}
bool cDvbDevice::OpenDvr ( void  ) [protected, virtual]

Opens the DVR of this device and prepares it to deliver a Transport Stream for use in a cReceiver.

Reimplemented from cDevice.

Definition at line 234 of file dvbdevice.cpp.

{
  return false;
}
int cDvbDevice::OpenFilter ( u_short  Pid,
u_char  Tid,
u_char  Mask 
) [protected, virtual]

Opens a file handle for the given filter data. A derived device that provides section data must implement this function.

Reimplemented from cDevice.

Definition at line 112 of file dvbdevice.cpp.

References cDevice::CardIndex(), DEV_DVB_DEMUX, esyslog, and open().

{
  const char *FileName = *cDvbName(DEV_DVB_DEMUX, CardIndex());
  int f = open(FileName, O_RDWR | O_NONBLOCK);
  if (f >= 0) {
     dmx_sct_filter_params sctFilterParams;
     memset(&sctFilterParams, 0, sizeof(sctFilterParams));
     sctFilterParams.pid = Pid;
     sctFilterParams.timeout = 0;
     sctFilterParams.flags = DMX_IMMEDIATE_START;
     sctFilterParams.filter.filter[0] = Tid;
     sctFilterParams.filter.mask[0] = Mask;
     if (ioctl(f, DMX_SET_FILTER, &sctFilterParams) >= 0)
        return f;
     else {
        esyslog("ERROR: can't set filter (pid=%d, tid=%02X, mask=%02X): %m", Pid, Tid, Mask);
        close(f);
        }
     }
  else
     esyslog("ERROR: can't open filter handle on '%s'", FileName);
  return -1;
}
void cDvbDevice::Play ( void  ) [virtual]

Sets the device into play mode (after a previous trick mode).

Reimplemented from cDevice.

Definition at line 198 of file dvbdevice.cpp.

{
}
int cDvbDevice::PlayAudio ( const uchar *  Data,
int  Length,
uchar  Id 
) [protected, virtual]

Plays the given data block as audio. Data points to exactly one complete PES packet of the given Length. Id indicates the type of audio data this packet holds. PlayAudio() shall process the packet either as a whole (returning Length) or not at all (returning 0 or -1 and setting 'errno' to EAGAIN).

Returns:
Returns the number of bytes actually taken from Data, or -1 in case of an error.

Reimplemented from cDevice.

Definition at line 229 of file dvbdevice.cpp.

{
  return -1;
}
int cDvbDevice::PlayVideo ( const uchar *  Data,
int  Length 
) [protected, virtual]

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 Length) or not at all (returning 0 or -1 and setting 'errno' to EAGAIN).

Returns:
Returns the number of bytes actually taken from Data, or -1 in case of an error.

Reimplemented from cDevice.

Definition at line 224 of file dvbdevice.cpp.

{
  return -1;
}
bool cDvbDevice::Poll ( cPoller &  Poller,
int  TimeoutMs = 0 
) [virtual]

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 it can't accept any data.

Reimplemented from cDevice.

Definition at line 214 of file dvbdevice.cpp.

{
  return false;
}
bool cDvbDevice::ProvidesChannel ( const cChannel *  Channel,
int  Priority = -1,
bool *  NeedsDetachReceivers = NULL 
) const [virtual]

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.

Reimplemented from cDevice.

Definition at line 151 of file dvbdevice.cpp.

{
  bool result = false;
  return result;
}
bool cDvbDevice::ProvidesSource ( int  Source) const [virtual]

Returns true if this device can provide the given source.

Reimplemented from cDevice.

Definition at line 141 of file dvbdevice.cpp.

{
  return true;
}
bool cDvbDevice::ProvidesTransponder ( const cChannel *  Channel) const [virtual]

Returns true if this device can provide the transponder of the given Channel (which implies that it can provide the Channel's source).

Reimplemented from cDevice.

Definition at line 146 of file dvbdevice.cpp.

{
  return false;
}
bool cDvbDevice::Ready ( void  ) [virtual]

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()).

Reimplemented from cDevice.

Definition at line 248 of file dvbdevice.cpp.

{
  return true;
}
void cDvbDevice::SetAudioChannelDevice ( int  AudioChannel) [protected, virtual]

Sets the audio channel to stereo (0), mono left (1) or mono right (2).

Reimplemented from cDevice.

Definition at line 277 of file dvbdevice.cpp.

{
}
void cDvbDevice::SetAudioTrackDevice ( eTrackType  Type) [protected, virtual]

Sets the current audio track to the given value.

Reimplemented from cDevice.

Definition at line 171 of file dvbdevice.cpp.

{
}
bool cDvbDevice::SetChannelDevice ( const cChannel *  Channel,
bool  LiveView 
) [virtual]

Sets the device to the given channel (actual physical setup).

Reimplemented from cDevice.

Definition at line 157 of file dvbdevice.cpp.

{
  return true;
}
void cDvbDevice::SetDigitalAudioDevice ( bool  On) [protected, virtual]

Tells the actual device that digital audio output shall be switched on or off.

Reimplemented from cDevice.

Definition at line 281 of file dvbdevice.cpp.

{
}
bool cDvbDevice::SetPid ( cPidHandle *  Handle,
int  Type,
bool  On 
) [protected, virtual]

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 indicates 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.

Reimplemented from cDevice.

Definition at line 107 of file dvbdevice.cpp.

{
  return true;
}
bool cDvbDevice::SetPlayMode ( ePlayMode  PlayMode) [protected, virtual]

Sets the device into the given play mode.

Returns:
true if the operation was successful.

Reimplemented from cDevice.

Definition at line 180 of file dvbdevice.cpp.

{
  return true;
}
void cDvbDevice::SetTransferModeForDolbyDigital ( int  Mode) [static]

Controls how the DVB device handles Transfer Mode when replaying Dolby Digital audio. 0 = don't set "audio bypass" in driver/firmware, don't force Transfer Mode 1 = set "audio bypass" in driver/firmware, force Transfer Mode (default) 2 = don't set "audio bypass" in driver/firmware, force Transfer Mode

Definition at line 285 of file dvbdevice.cpp.

Referenced by cScDevices::Startup().

{
}
void cDvbDevice::SetVideoDisplayFormat ( eVideoDisplayFormat  VideoDisplayFormat) [virtual]

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!

Reimplemented from cDevice.

Definition at line 268 of file dvbdevice.cpp.

{
}
void cDvbDevice::SetVideoFormat ( bool  VideoFormat16_9) [virtual]

Sets the output video format to either 16:9 or 4:3 (only useful if this device has an MPEG decoder).

Reimplemented from cDevice.

Definition at line 95 of file dvbdevice.cpp.

{
}
void cDvbDevice::SetVolumeDevice ( int  Volume) [protected, virtual]

Sets the audio volume on this device (Volume = 0...255).

Reimplemented from cDevice.

Definition at line 167 of file dvbdevice.cpp.

{
}
void cDvbDevice::StillPicture ( const uchar *  Data,
int  Length 
) [virtual]

Displays the given I-frame as a still picture.

Reimplemented from cDevice.

Definition at line 210 of file dvbdevice.cpp.

{
}
void cDvbDevice::TrickSpeed ( int  Speed) [virtual]

Sets the device into a mode where replay is done slower. Every single frame shall then be displayed the given number of times.

Reimplemented from cDevice.

Definition at line 190 of file dvbdevice.cpp.

{
}

Member Data Documentation

Definition at line 134 of file dvbdevice.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines