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
a856c423
Commit
a856c423
authored
Nov 26, 2015
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CAT: implement as chained decoder
parent
5f2425ad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
30 deletions
+69
-30
src/tables/cat.c
src/tables/cat.c
+60
-24
src/tables/cat.h
src/tables/cat.h
+9
-6
No files found.
src/tables/cat.c
View file @
a856c423
...
@@ -46,6 +46,7 @@
...
@@ -46,6 +46,7 @@
#include "../dvbpsi_private.h"
#include "../dvbpsi_private.h"
#include "../psi.h"
#include "../psi.h"
#include "../descriptor.h"
#include "../descriptor.h"
#include "../chain.h"
#include "cat.h"
#include "cat.h"
#include "cat_private.h"
#include "cat_private.h"
...
@@ -54,11 +55,20 @@
...
@@ -54,11 +55,20 @@
*****************************************************************************
*****************************************************************************
* Initialize a CAT decoder and return a handle on it.
* Initialize a CAT decoder and return a handle on it.
*****************************************************************************/
*****************************************************************************/
bool
dvbpsi_cat_attach
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_cat_callback
pf_callback
,
bool
dvbpsi_cat_attach
(
dvbpsi_t
*
p_dvbpsi
,
uint8_t
i_table_id
,
uint16_t
i_extension
,
void
*
p_cb_data
)
dvbpsi_cat_callback
pf_callback
,
void
*
p_cb_data
)
{
{
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
->
p_decoder
==
NULL
);
dvbpsi_decoder_t
*
p_dec
=
dvbpsi_decoder_chain_get
(
p_dvbpsi
,
i_table_id
,
i_extension
);
if
(
p_dec
!=
NULL
)
{
dvbpsi_error
(
p_dvbpsi
,
"CAT decoder"
,
"Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)"
,
i_table_id
,
i_extension
);
return
false
;
}
dvbpsi_cat_decoder_t
*
p_cat_decoder
;
dvbpsi_cat_decoder_t
*
p_cat_decoder
;
p_cat_decoder
=
(
dvbpsi_cat_decoder_t
*
)
dvbpsi_decoder_new
(
&
dvbpsi_cat_sections_gather
,
p_cat_decoder
=
(
dvbpsi_cat_decoder_t
*
)
dvbpsi_decoder_new
(
&
dvbpsi_cat_sections_gather
,
...
@@ -71,7 +81,16 @@ bool dvbpsi_cat_attach(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback,
...
@@ -71,7 +81,16 @@ bool dvbpsi_cat_attach(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback,
p_cat_decoder
->
p_cb_data
=
p_cb_data
;
p_cat_decoder
->
p_cb_data
=
p_cb_data
;
p_cat_decoder
->
p_building_cat
=
NULL
;
p_cat_decoder
->
p_building_cat
=
NULL
;
p_dvbpsi
->
p_decoder
=
DVBPSI_DECODER
(
p_cat_decoder
);
p_cat_decoder
->
i_table_id
=
i_table_id
;
p_cat_decoder
->
i_extension
=
i_extension
;
/* Add decoder to decoder chain */
if
(
!
dvbpsi_decoder_chain_add
(
p_dvbpsi
,
DVBPSI_DECODER
(
p_cat_decoder
)))
{
dvbpsi_decoder_delete
(
DVBPSI_DECODER
(
p_cat_decoder
));
return
false
;
}
return
true
;
return
true
;
}
}
...
@@ -80,19 +99,36 @@ bool dvbpsi_cat_attach(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback,
...
@@ -80,19 +99,36 @@ bool dvbpsi_cat_attach(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback,
*****************************************************************************
*****************************************************************************
* Close a CAT decoder. The handle isn't valid any more.
* Close a CAT decoder. The handle isn't valid any more.
*****************************************************************************/
*****************************************************************************/
void
dvbpsi_cat_detach
(
dvbpsi_t
*
p_dvbpsi
)
void
dvbpsi_cat_detach
(
dvbpsi_t
*
p_dvbpsi
,
uint8_t
i_table_id
,
uint16_t
i_extension
)
{
{
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
->
p_decoder
);
dvbpsi_cat_decoder_t
*
p_cat_decoder
dvbpsi_cat_decoder_t
*
p_cat_decoder
=
=
(
dvbpsi_cat_decoder_t
*
)
p_dvbpsi
->
p_decoder
;
(
dvbpsi_cat_decoder_t
*
)
dvbpsi_decoder_chain_get
(
p_dvbpsi
,
i_table_id
,
i_extension
);
if
(
!
p_cat_decoder
)
{
dvbpsi_error
(
p_dvbpsi
,
"CAT Decoder"
,
"No such CAT decoder (table_id == 0x%02x,"
"extension == 0x%02x)"
,
i_table_id
,
i_extension
);
return
;
}
/* Remove table decoder from chain */
if
(
!
dvbpsi_decoder_chain_remove
(
p_dvbpsi
,
DVBPSI_DECODER
(
p_cat_decoder
)))
{
dvbpsi_error
(
p_dvbpsi
,
"CAT Decoder"
,
"Failed to remove"
"extension == 0x%02x)"
,
i_table_id
,
i_extension
);
return
;
}
if
(
p_cat_decoder
->
p_building_cat
)
if
(
p_cat_decoder
->
p_building_cat
)
dvbpsi_cat_delete
(
p_cat_decoder
->
p_building_cat
);
dvbpsi_cat_delete
(
p_cat_decoder
->
p_building_cat
);
p_cat_decoder
->
p_building_cat
=
NULL
;
p_cat_decoder
->
p_building_cat
=
NULL
;
dvbpsi_decoder_delete
(
DVBPSI_DECODER
(
p_cat_decoder
));
dvbpsi_decoder_delete
(
p_dvbpsi
->
p_decoder
);
p_cat_decoder
=
NULL
;
p_dvbpsi
->
p_decoder
=
NULL
;
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -185,20 +221,17 @@ static void dvbpsi_ReInitCAT(dvbpsi_cat_decoder_t* p_decoder, const bool b_force
...
@@ -185,20 +221,17 @@ static void dvbpsi_ReInitCAT(dvbpsi_cat_decoder_t* p_decoder, const bool b_force
p_decoder
->
p_building_cat
=
NULL
;
p_decoder
->
p_building_cat
=
NULL
;
}
}
static
bool
dvbpsi_CheckCAT
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_psi_section_t
*
p_section
)
static
bool
dvbpsi_CheckCAT
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_cat_decoder_t
*
p_cat_decoder
,
dvbpsi_psi_section_t
*
p_section
)
{
{
bool
b_reinit
=
false
;
bool
b_reinit
=
false
;
assert
(
p_dvbpsi
->
p_decoder
);
dvbpsi_cat_decoder_t
*
p_cat_decoder
;
p_cat_decoder
=
(
dvbpsi_cat_decoder_t
*
)
p_dvbpsi
->
p_decoder
;
/* Perform a few sanity checks */
/* Perform a few sanity checks */
#if 0
#if 0
if (p_
p
at_decoder->p_building_pat->i_ts_id != p_section->i_extension)
if (p_
c
at_decoder->p_building_pat->i_ts_id != p_section->i_extension)
{
{
/* transport_stream_id */
/* transport_stream_id */
dvbpsi_error(p_dvbpsi, "
P
AT decoder",
dvbpsi_error(p_dvbpsi, "
C
AT decoder",
"'transport_stream_id' differs"
"'transport_stream_id' differs"
" whereas no TS discontinuity has occurred");
" whereas no TS discontinuity has occurred");
b_reinit = true;
b_reinit = true;
...
@@ -256,11 +289,9 @@ static bool dvbpsi_AddSectionCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_decoder_t *p_dec
...
@@ -256,11 +289,9 @@ static bool dvbpsi_AddSectionCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_decoder_t *p_dec
*****************************************************************************
*****************************************************************************
* Callback for the PSI decoder.
* Callback for the PSI decoder.
*****************************************************************************/
*****************************************************************************/
void
dvbpsi_cat_sections_gather
(
dvbpsi_t
*
p_dvbpsi
,
void
dvbpsi_cat_sections_gather
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_psi_section_t
*
p_section
)
dvbpsi_psi_section_t
*
p_section
)
{
{
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
->
p_decoder
);
if
(
!
dvbpsi_CheckPSISection
(
p_dvbpsi
,
p_section
,
0x01
,
"CAT decoder"
))
if
(
!
dvbpsi_CheckPSISection
(
p_dvbpsi
,
p_section
,
0x01
,
"CAT decoder"
))
{
{
...
@@ -269,10 +300,15 @@ void dvbpsi_cat_sections_gather(dvbpsi_t *p_dvbpsi,
...
@@ -269,10 +300,15 @@ void dvbpsi_cat_sections_gather(dvbpsi_t *p_dvbpsi,
}
}
/* */
/* */
dvbpsi_cat_decoder_t
*
p_cat_decoder
dvbpsi_decoder_t
*
p_dec
=
dvbpsi_decoder_chain_get
(
p_dvbpsi
,
p_section
->
i_table_id
,
p_section
->
i_extension
);
=
(
dvbpsi_cat_decoder_t
*
)
p_dvbpsi
->
p_decoder
;
if
(
!
p_dec
)
{
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
/* TS discontinuity check */
/* TS discontinuity check */
dvbpsi_cat_decoder_t
*
p_cat_decoder
=
(
dvbpsi_cat_decoder_t
*
)
p_dec
;
if
(
p_cat_decoder
->
b_discontinuity
)
if
(
p_cat_decoder
->
b_discontinuity
)
{
{
dvbpsi_ReInitCAT
(
p_cat_decoder
,
true
);
dvbpsi_ReInitCAT
(
p_cat_decoder
,
true
);
...
@@ -283,7 +319,7 @@ void dvbpsi_cat_sections_gather(dvbpsi_t *p_dvbpsi,
...
@@ -283,7 +319,7 @@ void dvbpsi_cat_sections_gather(dvbpsi_t *p_dvbpsi,
/* Perform some few sanity checks */
/* Perform some few sanity checks */
if
(
p_cat_decoder
->
p_building_cat
)
if
(
p_cat_decoder
->
p_building_cat
)
{
{
if
(
dvbpsi_CheckCAT
(
p_dvbpsi
,
p_section
))
if
(
dvbpsi_CheckCAT
(
p_dvbpsi
,
p_
cat_decoder
,
p_
section
))
dvbpsi_ReInitCAT
(
p_cat_decoder
,
true
);
dvbpsi_ReInitCAT
(
p_cat_decoder
,
true
);
}
}
else
else
...
...
src/tables/cat.h
View file @
a856c423
...
@@ -77,30 +77,33 @@ typedef void (* dvbpsi_cat_callback)(void* p_cb_data, dvbpsi_cat_t* p_new_cat);
...
@@ -77,30 +77,33 @@ typedef void (* dvbpsi_cat_callback)(void* p_cb_data, dvbpsi_cat_t* p_new_cat);
* dvbpsi_cat_attach
* dvbpsi_cat_attach
*****************************************************************************/
*****************************************************************************/
/*!
/*!
* \fn bool dvbpsi_cat_attach(dvbpsi_t *p_dvbpsi,
* \fn bool dvbpsi_cat_attach(dvbpsi_t *p_dvbpsi,
uint8_t i_table_id, uint16_t i_extension,
dvbpsi_cat_callback pf_callback, void* p_cb_data)
dvbpsi_cat_callback pf_callback, void* p_cb_data)
* \brief Creation and initialization of a CAT decoder. It will be attached to p_dvbpsi
* \brief Creation and initialization of a CAT decoder. It will be attached to p_dvbpsi
* \param p_dvbpsi is a pointer to dvbpsi_t which holds a pointer to the decoder
* \param p_dvbpsi is a pointer to dvbpsi_t which holds a pointer to the decoder
* \param i_table_id Table ID, here 0x01
* \param i_extension Table ID extension.
* \param pf_callback function to call back on new CAT
* \param pf_callback function to call back on new CAT
* \param p_cb_data private data given in argument to the callback
* \param p_cb_data private data given in argument to the callback
* \return true on success, false on failure
* \return true on success, false on failure
*/
*/
bool
dvbpsi_cat_attach
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_cat_callback
pf_callback
,
bool
dvbpsi_cat_attach
(
dvbpsi_t
*
p_dvbpsi
,
uint8_t
i_table_id
,
uint16_t
i_extension
,
void
*
p_cb_data
);
dvbpsi_cat_callback
pf_callback
,
void
*
p_cb_data
);
/*****************************************************************************
/*****************************************************************************
* dvbpsi_cat_detach
* dvbpsi_cat_detach
*****************************************************************************/
*****************************************************************************/
/*!
/*!
* \fn void dvbpsi_cat_detach(dvbpsi_t *p_dvbpsi)
* \fn void dvbpsi_cat_detach(dvbpsi_t *p_dvbpsi
, uint8_t i_table_id, uint16_t i_extension
)
* \brief Destroy a CAT decoder.
* \brief Destroy a CAT decoder.
* \param p_dvbpsi handle to dvbpsi with attached decoder
* \param p_dvbpsi handle to dvbpsi with attached decoder
* \param p_dvbpsi handle holds the decoder pointer
* \param i_table_id Table ID, here 0x01
* \param i_extension Table ID extension.
* \return nothing.
* \return nothing.
*
*
* The handle isn't valid any more.
* The handle isn't valid any more.
*/
*/
void
dvbpsi_cat_detach
(
dvbpsi_t
*
p_dvbpsi
);
void
dvbpsi_cat_detach
(
dvbpsi_t
*
p_dvbpsi
,
uint8_t
i_table_id
,
uint16_t
i_extension
);
/*****************************************************************************
/*****************************************************************************
* dvbpsi_cat_init/dvbpsi_cat_new
* dvbpsi_cat_init/dvbpsi_cat_new
...
...
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