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
Show 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,42 +271,41 @@ dvbpsi_descriptor_t *dvbpsi_SDTServiceAddDescriptor(
return
p_descriptor
;
}
/*****************************************************************************
* dvbpsi_GatherSDTSections
*****************************************************************************
* Callback for the subtable demultiplexor.
*****************************************************************************/
void
dvbpsi_GatherSDTSections
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_decoder_t
*
p_private_decoder
,
dvbpsi_psi_section_t
*
p_section
)
/* */
static
void
dvbpsi_ReInitSDT
(
dvbpsi_sdt_decoder_t
*
p_decoder
,
const
bool
b_force
)
{
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
->
p_private
);
assert
(
p_decoder
);
if
(
!
dvbpsi_CheckPSISection
(
p_dvbpsi
,
p_section
,
0x42
,
"SDT decoder"
))
/* Force redecoding */
if
(
b_force
)
{
dvbpsi_DeletePSISections
(
p_section
);
return
;
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
;
/* */
dvbpsi_demux_t
*
p_demux
=
(
dvbpsi_demux_t
*
)
p_dvbpsi
->
p_private
;
dvbpsi_sdt_decoder_t
*
p_sdt_decoder
=
(
dvbpsi_sdt_decoder_t
*
)
p_private_decoder
;
/* 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
;
/* TS discontinuity check */
if
(
p_demux
->
b_discontinuity
)
{
b_reinit
=
true
;
p_demux
->
b_discontinuity
=
false
;
}
else
{
/* Perform a few sanity checks */
if
(
p_sdt_decoder
->
p_building_sdt
)
{
if
(
p_sdt_decoder
->
p_building_sdt
->
i_ts_id
!=
p_section
->
i_extension
)
{
/* transport_stream_id */
...
...
@@ -331,59 +330,44 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
" whereas no discontinuity has occured"
);
b_reinit
=
true
;
}
}
else
{
if
(
(
p_sdt_decoder
->
b_current_valid
)
&&
(
p_sdt_decoder
->
current_sdt
.
i_version
==
p_section
->
i_version
)
&&
(
p_sdt_decoder
->
current_sdt
.
b_current_next
==
p_section
->
b_current_next
))
{
/* Don't decode since this version is already decoded */
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
}
}
/* Reinit the decoder if wanted */
if
(
b_reinit
)
{
/* Force redecoding */
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
)
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
++
)
{
dvbpsi_DeletePSISections
(
p_sdt_decoder
->
ap_sections
[
i
]);
p_sdt_decoder
->
ap_sections
[
i
]
=
NULL
;
}
}
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_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
,
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
;
}
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
)
...
...
@@ -394,19 +378,74 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
}
p_sdt_decoder
->
ap_sections
[
p_section
->
i_number
]
=
p_section
;
/* Check if we have all the sections */
bool
b_complete
=
false
;
for
(
unsigned
int
i
=
0
;
i
<=
p_sdt_decoder
->
i_last_section_number
;
i
++
)
return
true
;
}
/*****************************************************************************
* dvbpsi_GatherSDTSections
*****************************************************************************
* Callback for the subtable demultiplexor.
*****************************************************************************/
void
dvbpsi_GatherSDTSections
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_decoder_t
*
p_private_decoder
,
dvbpsi_psi_section_t
*
p_section
)
{
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
->
p_private
);
if
(
!
dvbpsi_CheckPSISection
(
p_dvbpsi
,
p_section
,
0x42
,
"SDT decoder"
))
{
if
(
!
p_sdt_decoder
->
ap_sections
[
i
])
break
;
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
if
(
i
==
p_sdt_decoder
->
i_last_section_number
)
b_complete
=
true
;
/* We have a valid SDT section */
dvbpsi_demux_t
*
p_demux
=
(
dvbpsi_demux_t
*
)
p_dvbpsi
->
p_private
;
dvbpsi_sdt_decoder_t
*
p_sdt_decoder
=
(
dvbpsi_sdt_decoder_t
*
)
p_private_decoder
;
/* TS discontinuity check */
if
(
p_demux
->
b_discontinuity
)
{
dvbpsi_ReInitSDT
(
p_sdt_decoder
,
true
);
p_sdt_decoder
->
b_discontinuity
=
false
;
p_demux
->
b_discontinuity
=
false
;
}
else
{
/* Perform a few sanity checks */
if
(
p_sdt_decoder
->
p_building_sdt
)
{
if
(
dvbpsi_CheckSDT
(
p_dvbpsi
,
p_section
))
dvbpsi_ReInitSDT
(
p_sdt_decoder
,
true
);
}
else
{
if
(
(
p_sdt_decoder
->
b_current_valid
)
&&
(
p_sdt_decoder
->
current_sdt
.
i_version
==
p_section
->
i_version
)
&&
(
p_sdt_decoder
->
current_sdt
.
b_current_next
==
p_section
->
b_current_next
))
{
/* Don't decode since this version is already decoded */
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
}
}
if
(
b_complete
)
/* Add section to SDT */
if
(
!
dvbpsi_AddSectionSDT
(
p_dvbpsi
,
p_sdt_decoder
,
p_section
))
{
dvbpsi_error
(
p_dvbpsi
,
"SDT decoder"
,
"failed decoding section %d"
,
p_section
->
i_number
);
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
/* Check if we have all the sections */
if
(
dvbpsi_IsCompleteSDT
(
p_sdt_decoder
))
{
assert
(
p_sdt_decoder
->
pf_sdt_callback
);
/* Save the current information */
p_sdt_decoder
->
current_sdt
=
*
p_sdt_decoder
->
p_building_sdt
;
p_sdt_decoder
->
b_current_valid
=
true
;
...
...
@@ -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
->
p_building_sdt
);
/* Reinitialize the structures */
p_sdt_decoder
->
p_building_sdt
=
NULL
;
for
(
unsigned
int
i
=
0
;
i
<=
p_sdt_decoder
->
i_last_section_number
;
i
++
)
p_sdt_decoder
->
ap_sections
[
i
]
=
NULL
;
dvbpsi_ReInitSDT
(
p_sdt_decoder
,
false
);
}
}
...
...
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