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
546c4c45
Commit
546c4c45
authored
Jun 13, 2012
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CAT: refactor dvbpsi_GatherCATSections.
parent
d48aceeb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
129 additions
and
73 deletions
+129
-73
src/tables/cat.c
src/tables/cat.c
+129
-73
No files found.
src/tables/cat.c
View file @
546c4c45
...
@@ -184,6 +184,121 @@ dvbpsi_descriptor_t* dvbpsi_CATAddDescriptor(dvbpsi_cat_t* p_cat,
...
@@ -184,6 +184,121 @@ dvbpsi_descriptor_t* dvbpsi_CATAddDescriptor(dvbpsi_cat_t* p_cat,
return
p_descriptor
;
return
p_descriptor
;
}
}
/* */
static
void
dvbpsi_ReInitCAT
(
dvbpsi_cat_decoder_t
*
p_cat_decoder
,
const
bool
b_force
)
{
assert
(
p_cat_decoder
);
/* Force redecoding */
if
(
b_force
)
{
p_cat_decoder
->
b_current_valid
=
false
;
/* Free structures */
if
(
p_cat_decoder
->
p_building_cat
)
dvbpsi_DeleteCAT
(
p_cat_decoder
->
p_building_cat
);
}
p_cat_decoder
->
p_building_cat
=
NULL
;
/* Clear the section array */
for
(
unsigned
int
i
=
0
;
i
<=
255
;
i
++
)
{
if
(
p_cat_decoder
->
ap_sections
[
i
]
!=
NULL
)
{
dvbpsi_DeletePSISections
(
p_cat_decoder
->
ap_sections
[
i
]);
p_cat_decoder
->
ap_sections
[
i
]
=
NULL
;
}
}
}
static
bool
dvbpsi_CheckCAT
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_psi_section_t
*
p_section
)
{
bool
b_reinit
=
false
;
assert
(
p_dvbpsi
->
p_private
);
dvbpsi_cat_decoder_t
*
p_cat_decoder
;
p_cat_decoder
=
(
dvbpsi_cat_decoder_t
*
)
p_dvbpsi
->
p_private
;
/* Perform a few sanity checks */
#if 0
if (p_pat_decoder->p_building_pat->i_ts_id != p_section->i_extension)
{
/* transport_stream_id */
dvbpsi_error(p_dvbpsi, "PAT decoder",
"'transport_stream_id' differs"
" whereas no TS discontinuity has occured");
b_reinit = true;
}
else
#endif
if
(
p_cat_decoder
->
p_building_cat
->
i_version
!=
p_section
->
i_version
)
{
/* version_number */
dvbpsi_error
(
p_dvbpsi
,
"CAT decoder"
,
"'version_number' differs"
" whereas no discontinuity has occured"
);
b_reinit
=
true
;
}
else
if
(
p_cat_decoder
->
i_last_section_number
!=
p_section
->
i_last_number
)
{
/* last_section_number */
dvbpsi_error
(
p_dvbpsi
,
"CAT decoder"
,
"'last_section_number' differs"
" whereas no discontinuity has occured"
);
b_reinit
=
true
;
}
return
b_reinit
;
}
static
bool
dvbpsi_IsCompleteCAT
(
dvbpsi_cat_decoder_t
*
p_cat_decoder
)
{
assert
(
p_cat_decoder
);
bool
b_complete
=
false
;
for
(
unsigned
int
i
=
0
;
i
<=
p_cat_decoder
->
i_last_section_number
;
i
++
)
{
if
(
!
p_cat_decoder
->
ap_sections
[
i
])
break
;
if
(
i
==
p_cat_decoder
->
i_last_section_number
)
b_complete
=
true
;
}
return
b_complete
;
}
static
bool
dvbpsi_AddSectionCAT
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_cat_decoder_t
*
p_decoder
,
dvbpsi_psi_section_t
*
p_section
)
{
assert
(
p_dvbpsi
);
assert
(
p_decoder
);
assert
(
p_section
);
/* Initialize the structures if it's the first section received */
if
(
p_decoder
->
p_building_cat
==
NULL
)
{
p_decoder
->
p_building_cat
=
dvbpsi_NewCAT
(
p_section
->
i_version
,
p_section
->
b_current_next
);
if
(
p_decoder
->
p_building_cat
==
NULL
)
return
false
;
p_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
/* Fill the section array */
if
(
p_decoder
->
ap_sections
[
p_section
->
i_number
]
!=
NULL
)
{
dvbpsi_debug
(
p_dvbpsi
,
"CAT decoder"
,
"overwrite section number %d"
,
p_section
->
i_number
);
dvbpsi_DeletePSISections
(
p_decoder
->
ap_sections
[
p_section
->
i_number
]);
}
p_decoder
->
ap_sections
[
p_section
->
i_number
]
=
p_section
;
return
true
;
}
/*****************************************************************************
/*****************************************************************************
* dvbpsi_GatherCATSections
* dvbpsi_GatherCATSections
*****************************************************************************
*****************************************************************************
...
@@ -205,12 +320,10 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
...
@@ -205,12 +320,10 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
dvbpsi_cat_decoder_t
*
p_cat_decoder
dvbpsi_cat_decoder_t
*
p_cat_decoder
=
(
dvbpsi_cat_decoder_t
*
)
p_dvbpsi
->
p_private
;
=
(
dvbpsi_cat_decoder_t
*
)
p_dvbpsi
->
p_private
;
bool
b_reinit
=
false
;
/* TS discontinuity check */
/* TS discontinuity check */
if
(
p_cat_decoder
->
b_discontinuity
)
if
(
p_cat_decoder
->
b_discontinuity
)
{
{
b_reinit
=
true
;
dvbpsi_ReInitCAT
(
p_cat_decoder
,
true
)
;
p_cat_decoder
->
b_discontinuity
=
false
;
p_cat_decoder
->
b_discontinuity
=
false
;
}
}
else
else
...
@@ -218,22 +331,8 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
...
@@ -218,22 +331,8 @@ void dvbpsi_GatherCATSections(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
(
p_cat_decoder
->
p_building_cat
->
i_version
!=
p_section
->
i_version
)
if
(
dvbpsi_CheckCAT
(
p_dvbpsi
,
p_section
))
{
dvbpsi_ReInitCAT
(
p_cat_decoder
,
true
);
/* version_number */
dvbpsi_error
(
p_dvbpsi
,
"CAT decoder"
,
"'version_number' differs"
" whereas no discontinuity has occured"
);
b_reinit
=
true
;
}
else
if
(
p_cat_decoder
->
i_last_section_number
!=
p_section
->
i_last_number
)
{
/* last_section_number */
dvbpsi_error
(
p_dvbpsi
,
"CAT decoder"
,
"'last_section_number' differs"
" whereas no discontinuity has occured"
);
b_reinit
=
true
;
}
}
}
else
else
{
{
...
@@ -243,70 +342,29 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
...
@@ -243,70 +342,29 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
p_section
->
b_current_next
))
p_section
->
b_current_next
))
{
{
/* Don't decode since this version is already decoded */
/* Don't decode since this version is already decoded */
dvbpsi_debug
(
p_dvbpsi
,
"CAT decoder"
,
"ignoring already decoded section %d"
,
p_section
->
i_number
);
dvbpsi_DeletePSISections
(
p_section
);
dvbpsi_DeletePSISections
(
p_section
);
return
;
return
;
}
}
}
}
}
}
/* Reinit the decoder if wanted */
/* Add section to CAT */
if
(
b_reinit
)
if
(
!
dvbpsi_AddSectionCAT
(
p_dvbpsi
,
p_cat_decoder
,
p_section
))
{
/* Force redecoding */
p_cat_decoder
->
b_current_valid
=
false
;
/* Free structures */
if
(
p_cat_decoder
->
p_building_cat
)
{
dvbpsi_DeleteCAT
(
p_cat_decoder
->
p_building_cat
);
p_cat_decoder
->
p_building_cat
=
NULL
;
}
/* Clear the section array */
for
(
unsigned
int
i
=
0
;
i
<=
255
;
i
++
)
{
if
(
p_cat_decoder
->
ap_sections
[
i
]
!=
NULL
)
{
dvbpsi_DeletePSISections
(
p_cat_decoder
->
ap_sections
[
i
]);
p_cat_decoder
->
ap_sections
[
i
]
=
NULL
;
}
}
}
int
b_complete
=
false
;
/* Initialize the structures if it's the first section received */
if
(
!
p_cat_decoder
->
p_building_cat
)
{
p_cat_decoder
->
p_building_cat
=
(
dvbpsi_cat_t
*
)
malloc
(
sizeof
(
dvbpsi_cat_t
));
if
(
p_cat_decoder
->
p_building_cat
)
dvbpsi_InitCAT
(
p_cat_decoder
->
p_building_cat
,
p_section
->
i_version
,
p_section
->
b_current_next
);
else
dvbpsi_error
(
p_dvbpsi
,
"CAT decoder"
,
"failed decoding section"
);
p_cat_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
/* Fill the section array */
if
(
p_cat_decoder
->
ap_sections
[
p_section
->
i_number
]
!=
NULL
)
{
{
dvbpsi_
debug
(
p_dvbpsi
,
"CAT decoder"
,
"overwrite section number
%d"
,
dvbpsi_
error
(
p_dvbpsi
,
"CAT decoder"
,
"failed decoding section
%d"
,
p_section
->
i_number
);
p_section
->
i_number
);
dvbpsi_DeletePSISections
(
p_cat_decoder
->
ap_sections
[
p_section
->
i_number
]);
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
}
p_cat_decoder
->
ap_sections
[
p_section
->
i_number
]
=
p_section
;
/* Check if we have all the sections */
/* Check if we have all the sections */
for
(
unsigned
int
i
=
0
;
i
<=
p_cat_decoder
->
i_last_section_number
;
i
++
)
if
(
dvbpsi_IsCompleteCAT
(
p_cat_decoder
)
)
{
{
if
(
!
p_cat_decoder
->
ap_sections
[
i
])
assert
(
p_cat_decoder
->
pf_cat_callback
);
break
;
if
(
i
==
p_cat_decoder
->
i_last_section_number
)
b_complete
=
true
;
}
if
(
b_complete
)
{
/* Save the current information */
/* Save the current information */
p_cat_decoder
->
current_cat
=
*
p_cat_decoder
->
p_building_cat
;
p_cat_decoder
->
current_cat
=
*
p_cat_decoder
->
p_building_cat
;
p_cat_decoder
->
b_current_valid
=
true
;
p_cat_decoder
->
b_current_valid
=
true
;
...
@@ -326,9 +384,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
...
@@ -326,9 +384,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
p_cat_decoder
->
pf_cat_callback
(
p_cat_decoder
->
p_cb_data
,
p_cat_decoder
->
pf_cat_callback
(
p_cat_decoder
->
p_cb_data
,
p_cat_decoder
->
p_building_cat
);
p_cat_decoder
->
p_building_cat
);
/* Reinitialize the structures */
/* Reinitialize the structures */
p_cat_decoder
->
p_building_cat
=
NULL
;
dvbpsi_ReInitCAT
(
p_cat_decoder
,
false
);
for
(
unsigned
int
i
=
0
;
i
<=
p_cat_decoder
->
i_last_section_number
;
i
++
)
p_cat_decoder
->
ap_sections
[
i
]
=
NULL
;
}
}
}
}
...
...
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