Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libdvbpsi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
libdvbpsi
Commits
9982ebce
Commit
9982ebce
authored
Dec 04, 2015
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doxygen: write documentation for migrating to libdvbpsi version 2.0.0 from previous versions.
parent
93f02c8d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
226 additions
and
0 deletions
+226
-0
doc/index.doxygen
doc/index.doxygen
+1
-0
doc/migrate-v1-to-v2.doxygen
doc/migrate-v1-to-v2.doxygen
+225
-0
No files found.
doc/index.doxygen
View file @
9982ebce
...
@@ -53,6 +53,7 @@ describes how to use it and the "C" API.</p>
...
@@ -53,6 +53,7 @@ describes how to use it and the "C" API.</p>
<li>\ref usage</li>
<li>\ref usage</li>
<li>\ref newdec</li>
<li>\ref newdec</li>
<li>\ref howto-new-api</li>
<li>\ref howto-new-api</li>
<li>\ref migrate-v1-to-v2</li>
</ul>
</ul>
*/
*/
doc/migrate-v1-to-v2.doxygen
0 → 100644
View file @
9982ebce
/*! \page migrate-v1-to-v2 Migrate from dvbpsi API version 1.0.0 to version 2.0.0
<p>In libdvbpsi version 2 the API has changed considerably in the area of subtable decoders.
Upto version 1.x.x this was handled by demux functions (dvbpsi/demux.h). It required for
each PSI subtable that a new dvbpsi_subsdec_t struct was used to wrap other subtable decoders.
Not all PSI tables implemented that, such as PAT, PMT and CAT. The version 2 removes all
demux_XXX functions and replaces it with a simple linked list implemented by dvbpsi_decoder_chain_XXX()
functions. As a result all PSI Tables can be chained now and handled by only one demuxing
function operating on a dvbpsi_t handle. It is still possible to allocate a dvbpsi_t handle
per PSI table, which is compatible with the old way of working in writing libdvbpsi table decoders.</p>
<h2>Example: PAT table</h2>
<p>
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.
</p>
<p>In many existing applications the following scheme is used to attach a PAT decoder to a dvbpsi handle
(This code is still supported by libdvbpsi version 2.0.0):</p>
<code>
dvbpsi_t *handle = dvbpsi_new(&dvbpsi_message, DVBPSI_MSG_DEBUG); <br />
if (handle == NULL) <br />
goto error; <br />
if (!dvbpsi_pat_attach(handle, handle_PAT, data)) <br />
{ <br />
dvbpsi_delete(handle); <br />
handle = NULL; <br />
goto error; <br />
} <br />
... other code ...
<br />
return 0; <br />
<br />
error: <br />
if (dvbpsi_decoder_present(handle)) <br />
dvbpsi_pat_detach(handle); <br />
if (handle) <br />
dvbpsi_delete(handle); <br />
return -1; <br />
</code>
<p>The same snippit of code using the dvbpsi_decoder_chain_XX() functions looks like this:</p>
<code>
/***************************************************************************** <br />
* AttachPAT <br />
*****************************************************************************/ <br />
static void AttachPAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension, <br />
void *p_zero) <br />
{ <br />
if (!dvbpsi_pat_attach(p_dvbpsi, i_table_id, i_extension, DumpPAT, NULL)) <br />
fprintf(stderr, "Failed to attach PAT decoder\n"); <br />
} <br />
<br />
static void DetachPAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension) <br />
{ <br />
dvbpsi_pat_detach(p_dvbpsi, i_table_id, i_extension); <br />
} <br />
<br />
void main(int argc, char** argv) <br />
{ <br />
dvbpsi_t *handle = dvbpsi_new(&dvbpsi_message, DVBPSI_MSG_DEBUG); <br />
if (handle == NULL) <br />
goto error; <br />
if (!dvbpsi_decoder_chain_new(p_dvbpsi, AttachPAT, DetachPAT, NULL)) <br />
goto error; <br />
<br />
.. other code .. <br />
return 0; <br />
<br />
error: <br />
if (!dvbpsi_decoder_chain_delete(p_dvbpsi)) <br />
goto error; <br />
if (handle) <br />
dvbpsi_delete(handle); <br />
return -1; <br />
} <br />
</code>
<h2>Example: Demuxing SDT table</h2>
<p>The scheme used for demuxing PSI tables and subtables is very similar, but requires different APIs. With the
new API (version 2 and up), the code looks the same as with the example above. The first code segment shows the
old way of doing things. The second shows you how to write it with dvbpsi_decoder_chain_XXX() functions.</p>
<code>
/***************************************************************************** <br />
* NewSubtable <br />
*****************************************************************************/ <br />
static void NewSubtable(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension, <br />
void * p_zero) <br />
{ <br />
if (i_table_id == 0x42) <br />
{ <br />
if (!dvbpsi_sdt_attach(p_dvbpsi, i_table_id, i_extension, DumpSDT, NULL)) <br />
fprintf(stderr, "Failed to attach SDT subdecoder\n"); <br />
} <br />
} <br />
<br />
/***************************************************************************** <br />
* main <br />
*****************************************************************************/ <br />
int main(int i_argc, char* pa_argv[]) <br />
{ <br />
int i_fd; <br />
int ret = 1; <br />
uint8_t data[188]; <br />
dvbpsi_t *p_dvbpsi; <br />
bool b_ok; <br />
<br />
if(i_argc != 2) <br />
return 1; <br />
<br />
i_fd = open(pa_argv[1], 0); <br />
if (i_fd < 0) <br />
return 1; <br />
<br />
p_dvbpsi = dvbpsi_new(&message, DVBPSI_MSG_DEBUG); <br />
if (p_dvbpsi == NULL) <br />
goto out; <br />
<br />
if (!dvbpsi_AttachDemux(p_dvbpsi, NewSubtable, NULL)) <br />
goto out; <br />
<br />
b_ok = ReadPacket(i_fd, data); <br />
<br />
while(b_ok) <br />
{ <br />
uint16_t i_pid = ((uint16_t)(data[1] & 0x1f) << 8) + data[2]; <br />
if(i_pid == 0x11) <br />
dvbpsi_packet_push(p_dvbpsi, data); <br />
b_ok = ReadPacket(i_fd, data); <br />
} <br />
<br />
ret = 0; <br />
<br />
out: <br />
if (p_dvbpsi) <br />
{ <br />
dvbpsi_DetachDemux(p_dvbpsi); <br />
dvbpsi_delete(p_dvbpsi); <br />
} <br />
close(i_fd); <br />
return ret; <br />
} <br />
<code>
<code>
/***************************************************************************** <br />
* NewSubtable <br />
*****************************************************************************/ <br />
static void NewSubtable(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension, <br />
void * p_zero) <br />
{ <br />
if(i_table_id == 0x42) <br />
{ <br />
if (!dvbpsi_sdt_attach(p_dvbpsi, i_table_id, i_extension, DumpSDT, NULL)) <br />
fprintf(stderr, "Failed to attach SDT subdecoder\n"); <br />
} <br />
} <br />
<br />
/***************************************************************************** <br />
* DelSubtable <br />
*****************************************************************************/ <br />
static void DelSubtable(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension) <br />
{ <br />
if(i_table_id == 0x42) <br />
{ <br />
dvbpsi_sdt_detach(p_dvbpsi, i_table_id, i_extension); <br />
} <br />
} <br />
<br />
/***************************************************************************** <br />
* main <br />
*****************************************************************************/ <br />
int main(int i_argc, char* pa_argv[]) <br />
{ <br />
int i_fd; <br />
int ret = 1; <br />
uint8_t data[188]; <br />
dvbpsi_t *p_dvbpsi; <br />
bool b_ok; <br />
<br />
if(i_argc != 2) <br />
return 1; <br />
<br />
i_fd = open(pa_argv[1], 0); <br />
if (i_fd < 0) <br />
return 1; <br />
<br />
p_dvbpsi = dvbpsi_new(&message, DVBPSI_MSG_DEBUG); <br />
if (p_dvbpsi == NULL) <br />
goto out; <br />
<br />
if (!dvbpsi_decoder_chain_new(p_dvbpsi, NewSubtable, DelSubtable, NULL)) <br />
goto out; <br />
<br />
b_ok = ReadPacket(i_fd, data); <br />
<br />
while(b_ok) <br />
{ <br />
uint16_t i_pid = ((uint16_t)(data[1] & 0x1f) << 8) + data[2]; <br />
if(i_pid == 0x11) <br />
dvbpsi_packet_push(p_dvbpsi, data); <br />
b_ok = ReadPacket(i_fd, data); <br />
} <br />
<br />
ret = 0; <br />
<br />
out: <br />
if (p_dvbpsi) <br />
{ <br />
if (!dvbpsi_decoder_chain_delete(p_dvbpsi)) <br />
ret = 1; <br />
dvbpsi_delete(p_dvbpsi); <br />
} <br />
close(i_fd); <br />
return ret; <br />
} <br />
</code>
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment