Commit 79b28353 authored by Jean-Paul Saman's avatar Jean-Paul Saman

doc/howto-new-api: add new API description.

Add a description on howto translate the old API into the new (update) API.
parent 1ac4cd61
## Process this file with automake to produce
EXTRA_DIST=index.doxygen structure.doxygen usage.doxygen newdec.doxygen \
howto-new-api.doxygen \ doxygen.cfg
......@@ -585,6 +585,7 @@ INPUT = index.doxygen \
structure.doxygen \
usage.doxygen \
newdec.doxygen \
howto-new-api.doxygen \
../src \
../src/tables \
/*! \page Howto port dvbpsi API (upto version 0.2.0) to version 1.0.0
<p>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:</p>
<li>explicit library handle allocation with <em>dvbpsi_NewHandle()</em> (delete with <em>dvbpsi_DeleteHandle()</em>)</li>
<li>consistent API for table and descriptor decoder/encoders</li>
<li>message callback function for easier intergrating libdvbpsi logging in applications</li>
<p>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 <em>dvbpsi_NewHandle()</em> and takes a callback function
for logging.
<code>dvbpsi_t *dvbpsi_NewHandle(dvbpsi_message_cb callback, enum dvbpsi_msg_level level);</code>
<p>The dvbpsi_t pointer must be released by calling <em>dvbpsi_DeleteHandle()</em></p>
<code>void dvbpsi_DeleteHandle(dvbpsi_t *handle);</code>
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.
<p>In many existing applications the following scheme is used to attaching a PAT decoder to a dvbpsi handle:</p>
dvbpsi_handle handle;
dvbpsi_AttachPAT(handle, handle_PAT, data);
<p>The same scheme is used for other PSI tables too, this translate to the following code sequence:</p>
dvbpsi_t *handle = dvbpsi_NewHandle(&dvbpsi_message, DVBPSI_MSG_DEBUG);
if (handle == NULL)
goto error;
if (!dvbpsi_AttachPAT(handle, handle_PAT, data))
handle = NULL;
goto error;
return 0;
if (dvbpsi_HasDecoder(handle))
if (handle)
return -1;
<p>The <em>message callback function</em> <b>dvbpsi_message</b> 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.
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);
......@@ -46,6 +46,7 @@ describes how to use it and the "C" API.</p>
<li>\ref structure</li>
<li>\ref usage</li>
<li>\ref newdec</li>
<li>\ref howto-new-api</li>
......@@ -29,4 +29,6 @@ tables.</p>
\ref usage
\ref howto-new-api
......@@ -41,4 +41,6 @@ file:</p>
\ref structure
\ref howto-new-api
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment