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
58e54473
Commit
58e54473
authored
Jun 13, 2012
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SDT: rework dvbpsi_GatherSDTSections
parent
fa575f15
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
123 additions
and
86 deletions
+123
-86
src/tables/sdt.c
src/tables/sdt.c
+123
-86
No files found.
src/tables/sdt.c
View file @
58e54473
...
@@ -271,6 +271,116 @@ dvbpsi_descriptor_t *dvbpsi_SDTServiceAddDescriptor(
...
@@ -271,6 +271,116 @@ dvbpsi_descriptor_t *dvbpsi_SDTServiceAddDescriptor(
return
p_descriptor
;
return
p_descriptor
;
}
}
/* */
static
void
dvbpsi_ReInitSDT
(
dvbpsi_sdt_decoder_t
*
p_decoder
,
const
bool
b_force
)
{
assert
(
p_decoder
);
/* Force redecoding */
if
(
b_force
)
{
p_decoder
->
b_current_valid
=
false
;
/* Free structures */
if
(
p_decoder
->
p_building_sdt
)
free
(
p_decoder
->
p_building_sdt
);
}
p_decoder
->
p_building_sdt
=
NULL
;
/* Clear the section array */
for
(
unsigned
int
i
=
0
;
i
<=
255
;
i
++
)
{
if
(
p_decoder
->
ap_sections
[
i
]
!=
NULL
)
{
dvbpsi_DeletePSISections
(
p_decoder
->
ap_sections
[
i
]);
p_decoder
->
ap_sections
[
i
]
=
NULL
;
}
}
}
static
bool
dvbpsi_CheckSDT
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_psi_section_t
*
p_section
)
{
bool
b_reinit
=
false
;
assert
(
p_dvbpsi
->
p_private
);
dvbpsi_sdt_decoder_t
*
p_sdt_decoder
;
p_sdt_decoder
=
(
dvbpsi_sdt_decoder_t
*
)
p_dvbpsi
->
p_private
;
if
(
p_sdt_decoder
->
p_building_sdt
->
i_ts_id
!=
p_section
->
i_extension
)
{
/* transport_stream_id */
dvbpsi_error
(
p_dvbpsi
,
"SDT decoder"
,
"'transport_stream_id' differs"
" whereas no TS discontinuity has occured"
);
b_reinit
=
true
;
}
else
if
(
p_sdt_decoder
->
p_building_sdt
->
i_version
!=
p_section
->
i_version
)
{
/* version_number */
dvbpsi_error
(
p_dvbpsi
,
"SDT decoder"
,
"'version_number' differs"
" whereas no discontinuity has occured"
);
b_reinit
=
true
;
}
else
if
(
p_sdt_decoder
->
i_last_section_number
!=
p_section
->
i_last_number
)
{
/* last_section_number */
dvbpsi_error
(
p_dvbpsi
,
"SDT decoder"
,
"'last_section_number' differs"
" whereas no discontinuity has occured"
);
b_reinit
=
true
;
}
return
b_reinit
;
}
static
bool
dvbpsi_IsCompleteSDT
(
dvbpsi_sdt_decoder_t
*
p_sdt_decoder
)
{
assert
(
p_sdt_decoder
);
bool
b_complete
=
false
;
for
(
unsigned
int
i
=
0
;
i
<=
p_sdt_decoder
->
i_last_section_number
;
i
++
)
{
if
(
!
p_sdt_decoder
->
ap_sections
[
i
])
break
;
if
(
i
==
p_sdt_decoder
->
i_last_section_number
)
b_complete
=
true
;
}
return
b_complete
;
}
static
bool
dvbpsi_AddSectionSDT
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_sdt_decoder_t
*
p_sdt_decoder
,
dvbpsi_psi_section_t
*
p_section
)
{
assert
(
p_dvbpsi
);
assert
(
p_sdt_decoder
);
assert
(
p_section
);
/* Initialize the structures if it's the first section received */
if
(
!
p_sdt_decoder
->
p_building_sdt
)
{
p_sdt_decoder
->
p_building_sdt
=
dvbpsi_NewSDT
(
p_section
->
i_extension
,
p_section
->
i_version
,
p_section
->
b_current_next
,
((
uint16_t
)(
p_section
->
p_payload_start
[
0
])
<<
8
)
|
p_section
->
p_payload_start
[
1
]);
if
(
p_sdt_decoder
->
p_building_sdt
==
NULL
)
return
false
;
p_sdt_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
/* Fill the section array */
if
(
p_sdt_decoder
->
ap_sections
[
p_section
->
i_number
]
!=
NULL
)
{
dvbpsi_debug
(
p_dvbpsi
,
"SDT decoder"
,
"overwrite section number %d"
,
p_section
->
i_number
);
dvbpsi_DeletePSISections
(
p_sdt_decoder
->
ap_sections
[
p_section
->
i_number
]);
}
p_sdt_decoder
->
ap_sections
[
p_section
->
i_number
]
=
p_section
;
return
true
;
}
/*****************************************************************************
/*****************************************************************************
* dvbpsi_GatherSDTSections
* dvbpsi_GatherSDTSections
*****************************************************************************
*****************************************************************************
...
@@ -289,17 +399,16 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
...
@@ -289,17 +399,16 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
return
;
return
;
}
}
/* */
/*
We have a valid SDT section
*/
dvbpsi_demux_t
*
p_demux
=
(
dvbpsi_demux_t
*
)
p_dvbpsi
->
p_private
;
dvbpsi_demux_t
*
p_demux
=
(
dvbpsi_demux_t
*
)
p_dvbpsi
->
p_private
;
dvbpsi_sdt_decoder_t
*
p_sdt_decoder
dvbpsi_sdt_decoder_t
*
p_sdt_decoder
=
(
dvbpsi_sdt_decoder_t
*
)
p_private_decoder
;
=
(
dvbpsi_sdt_decoder_t
*
)
p_private_decoder
;
bool
b_reinit
=
false
;
/* TS discontinuity check */
/* TS discontinuity check */
if
(
p_demux
->
b_discontinuity
)
if
(
p_demux
->
b_discontinuity
)
{
{
b_reinit
=
true
;
dvbpsi_ReInitSDT
(
p_sdt_decoder
,
true
);
p_sdt_decoder
->
b_discontinuity
=
false
;
p_demux
->
b_discontinuity
=
false
;
p_demux
->
b_discontinuity
=
false
;
}
}
else
else
...
@@ -307,30 +416,8 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
...
@@ -307,30 +416,8 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
/* Perform a few sanity checks */
/* Perform a few sanity checks */
if
(
p_sdt_decoder
->
p_building_sdt
)
if
(
p_sdt_decoder
->
p_building_sdt
)
{
{
if
(
p_sdt_decoder
->
p_building_sdt
->
i_ts_id
!=
p_section
->
i_extension
)
if
(
dvbpsi_CheckSDT
(
p_dvbpsi
,
p_section
))
{
dvbpsi_ReInitSDT
(
p_sdt_decoder
,
true
);
/* transport_stream_id */
dvbpsi_error
(
p_dvbpsi
,
"SDT decoder"
,
"'transport_stream_id' differs"
" whereas no TS discontinuity has occured"
);
b_reinit
=
true
;
}
else
if
(
p_sdt_decoder
->
p_building_sdt
->
i_version
!=
p_section
->
i_version
)
{
/* version_number */
dvbpsi_error
(
p_dvbpsi
,
"SDT decoder"
,
"'version_number' differs"
" whereas no discontinuity has occured"
);
b_reinit
=
true
;
}
else
if
(
p_sdt_decoder
->
i_last_section_number
!=
p_section
->
i_last_number
)
{
/* last_section_number */
dvbpsi_error
(
p_dvbpsi
,
"SDT decoder"
,
"'last_section_number' differs"
" whereas no discontinuity has occured"
);
b_reinit
=
true
;
}
}
}
else
else
{
{
...
@@ -345,68 +432,20 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
...
@@ -345,68 +432,20 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
}
}
}
}
/*
Reinit the decoder if wanted
*/
/*
Add section to SDT
*/
if
(
b_reinit
)
if
(
!
dvbpsi_AddSectionSDT
(
p_dvbpsi
,
p_sdt_decoder
,
p_section
)
)
{
{
/* Force redecoding */
dvbpsi_error
(
p_dvbpsi
,
"SDT decoder"
,
"failed decoding section %d"
,
p_sdt_decoder
->
b_current_valid
=
false
;
/* Free structures */
if
(
p_sdt_decoder
->
p_building_sdt
)
{
free
(
p_sdt_decoder
->
p_building_sdt
);
p_sdt_decoder
->
p_building_sdt
=
NULL
;
}
/* Clear the section array */
for
(
unsigned
int
i
=
0
;
i
<=
255
;
i
++
)
{
if
(
p_sdt_decoder
->
ap_sections
[
i
]
!=
NULL
)
{
dvbpsi_DeletePSISections
(
p_sdt_decoder
->
ap_sections
[
i
]);
p_sdt_decoder
->
ap_sections
[
i
]
=
NULL
;
}
}
}
/* Initialize the structures if it's the first section received */
if
(
!
p_sdt_decoder
->
p_building_sdt
)
{
p_sdt_decoder
->
p_building_sdt
=
(
dvbpsi_sdt_t
*
)
calloc
(
1
,
sizeof
(
dvbpsi_sdt_t
));
if
(
p_sdt_decoder
->
p_building_sdt
)
{
dvbpsi_InitSDT
(
p_sdt_decoder
->
p_building_sdt
,
p_section
->
i_extension
,
p_section
->
i_version
,
p_section
->
b_current_next
,
((
uint16_t
)(
p_section
->
p_payload_start
[
0
])
<<
8
)
|
p_section
->
p_payload_start
[
1
]);
p_sdt_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
else
dvbpsi_debug
(
p_dvbpsi
,
"SDT decoder"
,
"failed decoding section"
);
}
/* Fill the section array */
if
(
p_sdt_decoder
->
ap_sections
[
p_section
->
i_number
]
!=
NULL
)
{
dvbpsi_debug
(
p_dvbpsi
,
"SDT decoder"
,
"overwrite section number %d"
,
p_section
->
i_number
);
p_section
->
i_number
);
dvbpsi_DeletePSISections
(
p_sdt_decoder
->
ap_sections
[
p_section
->
i_number
]);
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
}
p_sdt_decoder
->
ap_sections
[
p_section
->
i_number
]
=
p_section
;
/* Check if we have all the sections */
/* Check if we have all the sections */
bool
b_complete
=
false
;
if
(
dvbpsi_IsCompleteSDT
(
p_sdt_decoder
))
for
(
unsigned
int
i
=
0
;
i
<=
p_sdt_decoder
->
i_last_section_number
;
i
++
)
{
{
if
(
!
p_sdt_decoder
->
ap_sections
[
i
])
assert
(
p_sdt_decoder
->
pf_sdt_callback
);
break
;
if
(
i
==
p_sdt_decoder
->
i_last_section_number
)
b_complete
=
true
;
}
if
(
b_complete
)
{
/* Save the current information */
/* Save the current information */
p_sdt_decoder
->
current_sdt
=
*
p_sdt_decoder
->
p_building_sdt
;
p_sdt_decoder
->
current_sdt
=
*
p_sdt_decoder
->
p_building_sdt
;
p_sdt_decoder
->
b_current_valid
=
true
;
p_sdt_decoder
->
b_current_valid
=
true
;
...
@@ -426,9 +465,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
...
@@ -426,9 +465,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
p_sdt_decoder
->
pf_sdt_callback
(
p_sdt_decoder
->
p_cb_data
,
p_sdt_decoder
->
pf_sdt_callback
(
p_sdt_decoder
->
p_cb_data
,
p_sdt_decoder
->
p_building_sdt
);
p_sdt_decoder
->
p_building_sdt
);
/* Reinitialize the structures */
/* Reinitialize the structures */
p_sdt_decoder
->
p_building_sdt
=
NULL
;
dvbpsi_ReInitSDT
(
p_sdt_decoder
,
false
);
for
(
unsigned
int
i
=
0
;
i
<=
p_sdt_decoder
->
i_last_section_number
;
i
++
)
p_sdt_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