libdvbv5: Digital TV device enumeration

libdvbv5 1.28.1 Library to work with Digital TV devices on Linux

Files | Data Structures | Enumerations | Functions
Digital TV device enumeration

## Files
file | dvb-dev.h
| Provides interfaces to handle Digital TV devices.

## Data Structures
struct | dvb_dev_list
| Digital TV device node properties. More...
struct | dvb_device
| Digital TV list of devices. More...

## Enumerations
enum | dvb_dev_type { DVB_DEVICE_FRONTEND , DVB_DEVICE_DEMUX , DVB_DEVICE_DVR , DVB_DEVICE_NET , DVB_DEVICE_CA , DVB_DEVICE_CA_SEC , DVB_DEVICE_VIDEO , DVB_DEVICE_AUDIO }
| Type of a device entry to search. More...

## Functions
struct dvb_device * | dvb_dev_alloc (void)
| Allocate a struct dvb_device.
void | dvb_dev_free (struct dvb_device *dvb)
| free a struct dvb_device
int | dvb_dev_find (struct dvb_device *dvb, dvb_dev_change_t handler, void *user_priv)
| finds all DVB devices on the local machine
void | dvb_dev_stop_monitor (struct dvb_device *dvb)
| Stop the dvb_dev_find loop.
void | dvb_dev_set_logpriv (struct dvb_device *dvb, unsigned verbose, dvb_logfunc_priv logfunc, void *logpriv)
| Sets the DVB verbosity and log function with context private data.
void | dvb_dev_set_log (struct dvb_device *dvb, unsigned verbose, dvb_logfunc logfunc)
| Sets the DVB verbosity and log function.
struct dvb_open_descriptor * | dvb_dev_open (struct dvb_device *dvb, const char *sysname, int flags)
| Opens a dvb device.
void | dvb_dev_close (struct dvb_open_descriptor *open_dev)
| Closes a dvb device.
int | dvb_dev_get_fd (struct dvb_open_descriptor *open_dev)
| returns fd from a local device This will not work for remote devices.
ssize_t | dvb_dev_read (struct dvb_open_descriptor *open_dev, void *buf, size_t count)
| read from a dvb demux or dvr file
void | dvb_dev_dmx_stop (struct dvb_open_descriptor *open_dev)
| Stops the demux filter for a given file descriptor.
int | dvb_dev_set_bufsize (struct dvb_open_descriptor *open_dev, int buffersize)
| Start a demux or dvr buffer size.
int | dvb_dev_dmx_set_pesfilter (struct dvb_open_descriptor *open_dev, int pid, dmx_pes_type_t type, dmx_output_t output, int buffersize)
| Start a filter for a MPEG-TS Packetized Elementary Stream (PES)
int | dvb_dev_dmx_set_section_filter (struct dvb_open_descriptor *open_dev, int pid, unsigned filtsize, unsigned char *filter, unsigned char *mask, unsigned char *mode, unsigned int flags)
| Sets a MPEG-TS section filter.
int | dvb_dev_dmx_get_pmt_pid (struct dvb_open_descriptor *open_dev, int sid)
| read the contents of the MPEG-TS PAT table, seeking for an specific service ID

## Detailed Description

## Enumeration Type Documentation

## ◆ dvb_dev_type

enum dvb_dev_type

Type of a device entry to search.

Parameters

  DVB_DEVICE_FRONTEND | Digital TV frontend
  DVB_DEVICE_DEMUX | Digital TV demux
  DVB_DEVICE_DVR | Digital TV Digital Video Record
  DVB_DEVICE_NET | Digital TV network interface control
  DVB_DEVICE_CA | Digital TV Conditional Access
  DVB_DEVICE_CA_SEC | Digital TV Conditional Access serial

Enumerator
DVB_DEVICE_FRONTEND |
DVB_DEVICE_DEMUX |
DVB_DEVICE_DVR |
DVB_DEVICE_NET |
DVB_DEVICE_CA |
DVB_DEVICE_CA_SEC |
DVB_DEVICE_VIDEO |
DVB_DEVICE_AUDIO |

Definition at line 58 of file dvb-dev.h.

## Function Documentation

## ◆ dvb_dev_alloc()

struct dvb_device * dvb_dev_alloc | ( | void |  | ) |

Allocate a struct dvb_device.

Note
  Before using the dvb device function calls, the struct dvb_device should be allocated via this function call.

Returns
  on success, returns a pointer to the allocated struct dvb_device or NULL if not enough memory to allocate the struct.

Examples
  dvb-fe-tool.c, dvbv5-scan.c, and dvbv5-zap.c.

## ◆ dvb_dev_close()

void dvb_dev_close | ( | struct dvb_open_descriptor * | open_dev | ) |

Closes a dvb device.

Parameters

  open_dev | Points to the struct dvb_open_descriptor to be closed.

Examples
  dvbv5-scan.c, and dvbv5-zap.c.

## ◆ dvb_dev_dmx_get_pmt_pid()

int dvb_dev_dmx_get_pmt_pid | ( | struct dvb_open_descriptor * | open_dev,
|  | int | sid )

read the contents of the MPEG-TS PAT table, seeking for an specific service ID

Parameters

  open_dev | Points to the struct dvb_open_descriptor
  sid | Session ID to seeking

Returns
  At return, it returns a negative value if error or the PID associated with the desired Session ID.

Warning
  This function currently assumes that the PAT fits into one session.

Note
  valid only for DVB_DEVICE_DEMUX.

Examples
  dvbv5-zap.c.

## ◆ dvb_dev_dmx_set_pesfilter()

int dvb_dev_dmx_set_pesfilter | ( | struct dvb_open_descriptor * | open_dev,
|  | int | pid,
|  | dmx_pes_type_t | type,
|  | dmx_output_t | output,
|  | int | buffersize )

Start a filter for a MPEG-TS Packetized Elementary Stream (PES)

Parameters

  open_dev | Points to the struct dvb_open_descriptor
  pid | Program ID to filter. Use 0x2000 to select all PIDs
  type | type of the PID (DMX_PES_VIDEO, DMX_PES_AUDIO, DMX_PES_OTHER, etc).
  output | Where the data will be output (DMX_OUT_TS_TAP, DMX_OUT_DECODER, etc).
  buffersize | Size of the buffer to be allocated to store the filtered data.

This is a wrapper function for DMX_SET_PES_FILTER and DMX_SET_BUFFER_SIZE ioctls.

See http://linuxtv.org/downloads/v4l-dvb-apis/dvb_demux.html for more details.

Returns
  Retuns zero on success, -1 otherwise.

Note
  valid only for DVB_DEVICE_DEMUX.

Examples
  dvbv5-zap.c.

## ◆ dvb_dev_dmx_set_section_filter()

int dvb_dev_dmx_set_section_filter | ( | struct dvb_open_descriptor * | open_dev,
|  | int | pid,
|  | unsigned | filtsize,
|  | unsigned char * | filter,
|  | unsigned char * | mask,
|  | unsigned char * | mode,
|  | unsigned int | flags )

Sets a MPEG-TS section filter.

Parameters

  open_dev | Points to the struct dvb_open_descriptor
  pid | Program ID to filter. Use 0x2000 to select all PIDs
  filtsize | Size of the filter (up to 18 btyes)
  filter | data to filter. Can be NULL or should have filtsize length
  mask | filter mask. Can be NULL or should have filtsize length
  mode | mode mask. Can be NULL or should have filtsize length
  flags | flags for set filter (DMX_CHECK_CRC,DMX_ONESHOT, DMX_IMMEDIATE_START).

This is a wrapper function for DMX_SET_FILTER ioctl.

See http://linuxtv.org/downloads/v4l-dvb-apis/dvb_demux.html for more details.

Returns
  Retuns zero on success, -1 otherwise.

Note
  valid only for DVB_DEVICE_DEMUX.

## ◆ dvb_dev_dmx_stop()

void dvb_dev_dmx_stop | ( | struct dvb_open_descriptor * | open_dev | ) |

Stops the demux filter for a given file descriptor.

Parameters

  open_dev | Points to the struct dvb_open_descriptor

This is a wrapper function for DMX_STOP ioctl.

See http://linuxtv.org/downloads/v4l-dvb-apis/dvb_demux.html for more details.

Note
  valid only for DVB_DEVICE_DEMUX.

## ◆ dvb_dev_find()

int dvb_dev_find | ( | struct dvb_device * | dvb,
|  | dvb_dev_change_t | handler,
|  | void * | user_priv )

finds all DVB devices on the local machine

Parameters

  dvb | pointer to struct dvb_device to be filled
  handler | if not NULL, then this is called whenever something changed monitor mode
  user_priv | pointer to user private data

This routine can be called on two modes: normal or monitor mode

In normal mode, it will seek for the local Digital TV devices, store them at the struct dvb_device and return.

In monitor mode, it will not only enumerate all devices, but it will also keep waiting for device changes. The handler callback is called for the changed device.

Returns
  returns 0 on success, a negative value otherwise.

Examples
  dvb-fe-tool.c, dvbv5-scan.c, and dvbv5-zap.c.

## ◆ dvb_dev_free()

void dvb_dev_free | ( | struct dvb_device * | dvb | ) |

free a struct dvb_device

Parameters

  dvb | pointer to struct dvb_device to be freed

Examples
  dvb-fe-tool.c, dvbv5-scan.c, and dvbv5-zap.c.

## ◆ dvb_dev_get_fd()

int dvb_dev_get_fd | ( | struct dvb_open_descriptor * | open_dev | ) |

returns fd from a local device This will not work for remote devices.

Parameters

  open_dev | Points to the struct dvb_open_descriptor

Returns
  On success, returns the fd. Returns -1 on error.

## ◆ dvb_dev_open()

struct dvb_open_descriptor * dvb_dev_open | ( | struct dvb_device * | dvb,
|  | const char * | sysname,
|  | int | flags )

Opens a dvb device.

Parameters

  dvb | pointer to struct dvb_device to be used
  sysname | Kernel's name of the device to be opened, as obtained via dvb_dev_seek_by_adapter() or via dvb_dev_find().
  flags | Flags to be passed to open: O_RDONLY, O_RDWR and/or O_NONBLOCK

Note
  Please notice that O_NONBLOCK is not supported for frontend devices, and will be silently ignored.
  the sysname will only work if a previous call to dvb_dev_find() is issued.

This function is equivalent to open(2) system call: it opens a Digital TV given by the dev parameter, using the flags.

Returns
  returns a pointer to the dvb_open_descriptor that should be used on further calls if sucess. NULL otherwise.

Examples
  dvb-fe-tool.c, dvbv5-scan.c, and dvbv5-zap.c.

## ◆ dvb_dev_read()

ssize_t dvb_dev_read | ( | struct dvb_open_descriptor * | open_dev,
|  | void * | buf,
|  | size_t | count )

read from a dvb demux or dvr file

Parameters

  open_dev | Points to the struct dvb_open_descriptor to be closed.
  buf | Buffer to store the data
  count | number of bytes to read

Returns
  On success, returns the number of bytes read. Returns -1 on error.

Examples
  dvbv5-zap.c.

## ◆ dvb_dev_set_bufsize()

int dvb_dev_set_bufsize | ( | struct dvb_open_descriptor * | open_dev,
|  | int | buffersize )

Start a demux or dvr buffer size.

Parameters

  open_dev | Points to the struct dvb_open_descriptor
  buffersize | Size of the buffer to be allocated to store the filtered data.

This is a wrapper function for DMX_SET_BUFFER_SIZE ioctl.

See http://linuxtv.org/downloads/v4l-dvb-apis/dvb_demux.html for more details.

Returns
  Retuns zero on success, -1 otherwise.

Note
  valid only for DVB_DEVICE_DEMUX or DVB_DEVICE_DVR.

Examples
  dvbv5-zap.c.

## ◆ dvb_dev_set_log()

void dvb_dev_set_log | ( | struct dvb_device * | dvb,
|  | unsigned | verbose,
|  | dvb_logfunc | logfunc )

Sets the DVB verbosity and log function.

Parameters

  dvb | pointer to struct dvb_device to be used
  verbose | Verbosity level of the messages that will be printed
  logfunc | Callback function to be called when a log event happens. Can either store the event into a file or to print it at the TUI/GUI. Can be null.

Sets the function to report log errors and to set the verbosity level of debug report messages. If not called, or if logfunc is NULL, the libdvbv5 will report error and debug messages via stderr, and will use colors for the debug messages.

Examples
  dvb-fe-tool.c, dvbv5-scan.c, and dvbv5-zap.c.

## ◆ dvb_dev_set_logpriv()

void dvb_dev_set_logpriv | ( | struct dvb_device * | dvb,
|  | unsigned | verbose,
|  | dvb_logfunc_priv | logfunc,
|  | void * | logpriv )

Sets the DVB verbosity and log function with context private data.

Parameters

  dvb | pointer to struct dvb_device to be used
  verbose | Verbosity level of the messages that will be printed
  logfunc | Callback function to be called when a log event happens. Can either store the event into a file or to print it at the TUI/GUI. Can be null.
  logpriv | Private data for log function

Sets the function to report log errors and to set the verbosity level of debug report messages. If not called, or if logfunc is NULL, the libdvbv5 will report error and debug messages via stderr, and will use colors for the debug messages.

## ◆ dvb_dev_stop_monitor()

void dvb_dev_stop_monitor | ( | struct dvb_device * | dvb | ) |

Stop the dvb_dev_find loop.

Parameters

  dvb | pointer to struct dvb_device to be used

This function stops dvb_dev_find() if it is running in monitor mode. It does nothing on other modes. Can be called even if the monitor mode was already stopped.