libdvbpsi  2.0.0-git
MPEG Transport Stream PSI table parser
Howto port dvbpsi API (upto version 0.2.0) to version 1.0.0

An update to libdvbpsi API was long overdue. In time the API grew to be inconsistent and needed some cleanup. The following issue are addressed in this version:

  • explicit library handle allocation with dvbpsi_new() (delete with dvbpsi_delete())
  • consistent API for table and descriptor decoder/encoders
  • message callback function for easier intergrating libdvbpsi logging in applications

The biggest change is the addition off an explicit dvbpsi_t pointer to ALL table decoder and encoder API's. This dvbpsi_t pointer is a dvbpsi handle which must be allocated using dvbpsi_new() and takes a callback function for logging. The handle must be deleted with dvbpsi_delete() if it is no longer needed.

dvbpsi_t *dvbpsi_new(dvbpsi_message_cb callback, enum dvbpsi_msg_level level);

The dvbpsi_t pointer must be released by calling dvbpsi_delete()

void dvbpsi_delete(dvbpsi_t *handle);


The following examples shows howto translate existing applications. In these examples only source code snippits are used and can thus not be compiled standalone. The examples are taken from existing applications using libdvbpsi. For a more elaborate example take a look in examples/ directory and especially to the file examples/dvbinfo/libdvbpsi.c from the dvbinfo application.

In many existing applications the following scheme is used to attaching a PAT decoder to a dvbpsi handle:

  dvbpsi_handle handle;
  dvbpsi_AttachPAT(handle, handle_PAT, data);

The same scheme is used for other PSI tables too, this translate to the following code sequence:

  dvbpsi_t *handle = dvbpsi_new(&dvbpsi_message, DVBPSI_MSG_DEBUG);
  if (handle == NULL)
   goto error;
  if (!dvbpsi_pat_attach(handle, handle_PAT, data))
    handle = NULL;
    goto error;
  return 0;
  if (dvbpsi_decoder_present(handle))
  if (handle)
  return -1;

The message callback function dvbpsi_message is defined as follows below. In this case the output goes directly to the console. Applications however can call into their messaging API and pass along libdvbpsi messages if wanted. See the following example:

static void dvbpsi_message(dvbpsi_t p_dvbpsi, const dvbpsi_msg_level_t level, const char msg)
  case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
  case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
  case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
  fprintf(stderr, "%s\n", msg);