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
d1f318a2
Commit
d1f318a2
authored
Jun 13, 2012
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BAT: refactor dvbpsi_GatherBATSections
parent
546c4c45
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
124 additions
and
86 deletions
+124
-86
src/tables/bat.c
src/tables/bat.c
+124
-86
No files found.
src/tables/bat.c
View file @
d1f318a2
...
...
@@ -294,42 +294,40 @@ dvbpsi_descriptor_t *dvbpsi_BATTSAddDescriptor(
return
p_descriptor
;
}
/*****************************************************************************
* dvbpsi_GatherBATSections
*****************************************************************************
* Callback for the subtable demultiplexor.
*****************************************************************************/
void
dvbpsi_GatherBATSections
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_decoder_t
*
p_decoder
,
dvbpsi_psi_section_t
*
p_section
)
/* */
static
void
dvbpsi_ReInitBAT
(
dvbpsi_bat_decoder_t
*
p_decoder
,
const
bool
b_force
)
{
dvbpsi_demux_t
*
p_demux
=
(
dvbpsi_demux_t
*
)
p_dvbpsi
->
p_private
;
dvbpsi_bat_decoder_t
*
p_bat_decoder
=
(
dvbpsi_bat_decoder_t
*
)
p_decoder
;
assert
(
p_decoder
);
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
->
p_private
);
/* Force redecoding */
if
(
b_force
)
{
p_decoder
->
b_current_valid
=
false
;
if
(
!
dvbpsi_CheckPSISection
(
p_dvbpsi
,
p_section
,
0x4a
,
"BAT decoder"
))
/* Free structures */
if
(
p_decoder
->
p_building_bat
)
dvbpsi_DeleteBAT
(
p_decoder
->
p_building_bat
);
}
p_decoder
->
p_building_bat
=
NULL
;
/* Clear the section array */
for
(
unsigned
int
i
=
0
;
i
<=
255
;
i
++
)
{
dvbpsi_DeletePSISections
(
p_section
);
return
;
if
(
p_decoder
->
ap_sections
[
i
]
!=
NULL
)
{
dvbpsi_DeletePSISections
(
p_decoder
->
ap_sections
[
i
]);
p_decoder
->
ap_sections
[
i
]
=
NULL
;
}
}
}
/* */
static
bool
dvbpsi_CheckBAT
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_bat_decoder_t
*
p_bat_decoder
,
dvbpsi_psi_section_t
*
p_section
)
{
bool
b_reinit
=
false
;
assert
(
p_dvbpsi
);
assert
(
p_bat_decoder
);
/* We have a valid BAT section */
/* TS discontinuity check */
if
(
p_demux
->
b_discontinuity
)
{
b_reinit
=
true
;
p_demux
->
b_discontinuity
=
false
;
}
else
{
/* Perform a few sanity checks */
if
(
p_bat_decoder
->
p_building_bat
)
{
if
(
p_bat_decoder
->
p_building_bat
->
i_bouquet_id
!=
p_section
->
i_extension
)
{
/* bouquet_id */
...
...
@@ -353,6 +351,92 @@ void dvbpsi_GatherBATSections(dvbpsi_t *p_dvbpsi,
" whereas no discontinuity has occured"
);
b_reinit
=
true
;
}
return
b_reinit
;
}
static
bool
dvbpsi_IsCompleteBAT
(
dvbpsi_bat_decoder_t
*
p_bat_decoder
)
{
assert
(
p_bat_decoder
);
bool
b_complete
=
false
;
for
(
unsigned
int
i
=
0
;
i
<=
p_bat_decoder
->
i_last_section_number
;
i
++
)
{
if
(
!
p_bat_decoder
->
ap_sections
[
i
])
break
;
if
(
i
==
p_bat_decoder
->
i_last_section_number
)
b_complete
=
true
;
}
return
b_complete
;
}
static
bool
dvbpsi_AddSectionBAT
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_bat_decoder_t
*
p_bat_decoder
,
dvbpsi_psi_section_t
*
p_section
)
{
assert
(
p_dvbpsi
);
assert
(
p_bat_decoder
);
assert
(
p_section
);
/* Initialize the structures if it's the first section received */
if
(
!
p_bat_decoder
->
p_building_bat
)
{
p_bat_decoder
->
p_building_bat
=
dvbpsi_NewBAT
(
p_section
->
i_extension
,
p_section
->
i_version
,
p_section
->
b_current_next
);
if
(
p_bat_decoder
->
p_building_bat
)
return
false
;
p_bat_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
/* Fill the section array */
if
(
p_bat_decoder
->
ap_sections
[
p_section
->
i_number
]
!=
NULL
)
{
dvbpsi_debug
(
p_dvbpsi
,
"BAT decoder"
,
"overwrite section number %d"
,
p_section
->
i_number
);
dvbpsi_DeletePSISections
(
p_bat_decoder
->
ap_sections
[
p_section
->
i_number
]);
}
p_bat_decoder
->
ap_sections
[
p_section
->
i_number
]
=
p_section
;
return
true
;
}
/*****************************************************************************
* dvbpsi_GatherBATSections
*****************************************************************************
* Callback for the subtable demultiplexor.
*****************************************************************************/
void
dvbpsi_GatherBATSections
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_decoder_t
*
p_decoder
,
dvbpsi_psi_section_t
*
p_section
)
{
dvbpsi_demux_t
*
p_demux
=
(
dvbpsi_demux_t
*
)
p_dvbpsi
->
p_private
;
dvbpsi_bat_decoder_t
*
p_bat_decoder
=
(
dvbpsi_bat_decoder_t
*
)
p_decoder
;
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
->
p_private
);
if
(
!
dvbpsi_CheckPSISection
(
p_dvbpsi
,
p_section
,
0x4a
,
"BAT decoder"
))
{
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
/* We have a valid BAT section */
if
(
p_demux
->
b_discontinuity
)
{
dvbpsi_ReInitBAT
(
p_bat_decoder
,
true
);
p_bat_decoder
->
b_discontinuity
=
false
;
p_demux
->
b_discontinuity
=
false
;
}
else
{
/* Perform a few sanity checks */
if
(
p_bat_decoder
->
p_building_bat
)
{
if
(
dvbpsi_CheckBAT
(
p_dvbpsi
,
p_bat_decoder
,
p_section
))
dvbpsi_ReInitBAT
(
p_bat_decoder
,
true
);
}
else
{
...
...
@@ -365,7 +449,10 @@ void dvbpsi_GatherBATSections(dvbpsi_t *p_dvbpsi,
dvbpsi_debug
(
p_dvbpsi
,
"BAT decoder"
,
"ignoring already decoded section %d"
,
p_section
->
i_number
);
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
#if 0 /* FIXME: Is this really needed ? */
else if ( (!p_bat_decoder->current_bat.b_current_next)
&& (p_section->b_current_next))
{
...
...
@@ -382,75 +469,28 @@ void dvbpsi_GatherBATSections(dvbpsi_t *p_dvbpsi,
}
dvbpsi_DeletePSISections(p_section);
return;
#endif
}
}
/* Reinit the decoder if wanted */
if
(
b_reinit
)
{
/* Force redecoding */
p_bat_decoder
->
b_current_valid
=
false
;
/* Free structures */
if
(
p_bat_decoder
->
p_building_bat
)
{
dvbpsi_DeleteBAT
(
p_bat_decoder
->
p_building_bat
);
p_bat_decoder
->
p_building_bat
=
NULL
;
}
/* Clear the section array */
for
(
unsigned
int
i
=
0
;
i
<
256
;
i
++
)
{
if
(
p_bat_decoder
->
ap_sections
[
i
]
!=
NULL
)
{
dvbpsi_DeletePSISections
(
p_bat_decoder
->
ap_sections
[
i
]);
p_bat_decoder
->
ap_sections
[
i
]
=
NULL
;
}
}
}
/* Append the section to the list if wanted */
bool
b_complete
=
false
;
/* Initialize the structures if it's the first section received */
if
(
!
p_bat_decoder
->
p_building_bat
)
{
p_bat_decoder
->
p_building_bat
=
(
dvbpsi_bat_t
*
)
malloc
(
sizeof
(
dvbpsi_bat_t
));
if
(
p_bat_decoder
->
p_building_bat
)
dvbpsi_InitBAT
(
p_bat_decoder
->
p_building_bat
,
p_section
->
i_extension
,
p_section
->
i_version
,
p_section
->
b_current_next
);
else
dvbpsi_error
(
p_dvbpsi
,
"BAT decoder"
,
"failed decoding BAT section"
);
p_bat_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
/* Fill the section array */
if
(
p_bat_decoder
->
ap_sections
[
p_section
->
i_number
]
!=
NULL
)
/* Add section to BAT */
if
(
!
dvbpsi_AddSectionBAT
(
p_dvbpsi
,
p_bat_decoder
,
p_section
))
{
dvbpsi_
debug
(
p_dvbpsi
,
"BAT decoder"
,
"overwrite section number
%d"
,
dvbpsi_
error
(
p_dvbpsi
,
"BAT decoder"
,
"failed decoding section
%d"
,
p_section
->
i_number
);
dvbpsi_DeletePSISections
(
p_bat_decoder
->
ap_sections
[
p_section
->
i_number
]);
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
p_bat_decoder
->
ap_sections
[
p_section
->
i_number
]
=
p_section
;
/* Check if we have all the sections */
for
(
unsigned
int
i
=
0
;
i
<=
p_bat_decoder
->
i_last_section_number
;
i
++
)
if
(
dvbpsi_IsCompleteBAT
(
p_bat_decoder
)
)
{
if
(
!
p_bat_decoder
->
ap_sections
[
i
])
break
;
if
(
i
==
p_bat_decoder
->
i_last_section_number
)
b_complete
=
true
;
}
assert
(
p_bat_decoder
->
pf_bat_callback
);
if
(
b_complete
)
{
/* Save the current information */
p_bat_decoder
->
current_bat
=
*
p_bat_decoder
->
p_building_bat
;
p_bat_decoder
->
b_current_valid
=
true
;
/* Chain the sections */
assert
(
p_bat_decoder
->
i_last_section_number
>
256
);
if
(
p_bat_decoder
->
i_last_section_number
)
{
for
(
uint8_t
j
=
0
;
j
<=
p_bat_decoder
->
i_last_section_number
-
1
;
j
++
)
...
...
@@ -466,9 +506,7 @@ void dvbpsi_GatherBATSections(dvbpsi_t *p_dvbpsi,
p_bat_decoder
->
pf_bat_callback
(
p_bat_decoder
->
p_cb_data
,
p_bat_decoder
->
p_building_bat
);
/* Reinitialize the structures */
p_bat_decoder
->
p_building_bat
=
NULL
;
for
(
unsigned
int
i
=
0
;
i
<=
p_bat_decoder
->
i_last_section_number
;
i
++
)
p_bat_decoder
->
ap_sections
[
i
]
=
NULL
;
dvbpsi_ReInitBAT
(
p_bat_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