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
85be9dd9
Commit
85be9dd9
authored
Jun 13, 2012
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PAT: rework dvbpsi_GatherPATSections()
parent
6a65c6c9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
46 deletions
+63
-46
src/tables/pat.c
src/tables/pat.c
+63
-46
No files found.
src/tables/pat.c
View file @
85be9dd9
...
...
@@ -193,19 +193,20 @@ dvbpsi_pat_program_t* dvbpsi_PATAddProgram(dvbpsi_pat_t* p_pat,
}
/* */
static
void
dvbpsi_ReInitPAT
(
dvbpsi_pat_decoder_t
*
p_pat_decoder
)
static
void
dvbpsi_ReInitPAT
(
dvbpsi_pat_decoder_t
*
p_pat_decoder
,
const
bool
b_force
)
{
assert
(
p_pat_decoder
);
/* Force redecoding */
if
(
b_force
)
{
p_pat_decoder
->
b_current_valid
=
false
;
/* Free structures */
if
(
p_pat_decoder
->
p_building_pat
)
{
free
(
p_pat_decoder
->
p_building_pat
);
p_pat_decoder
->
p_building_pat
=
NULL
;
}
p_pat_decoder
->
p_building_pat
=
NULL
;
/* Clear the section array */
for
(
unsigned
int
i
=
0
;
i
<=
255
;
i
++
)
...
...
@@ -255,6 +256,52 @@ static bool dvbpsi_CheckPAT(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
return
b_reinit
;
}
static
bool
dvbpsi_IsCompletePAT
(
dvbpsi_pat_decoder_t
*
p_pat_decoder
)
{
assert
(
p_pat_decoder
);
bool
b_complete
=
false
;
for
(
unsigned
int
i
=
0
;
i
<=
p_pat_decoder
->
i_last_section_number
;
i
++
)
{
if
(
!
p_pat_decoder
->
ap_sections
[
i
])
break
;
if
(
i
==
p_pat_decoder
->
i_last_section_number
)
b_complete
=
true
;
}
return
b_complete
;
}
static
bool
dvbpsi_AddSectionPAT
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_pat_decoder_t
*
p_pat_decoder
,
dvbpsi_psi_section_t
*
p_section
)
{
assert
(
p_dvbpsi
);
assert
(
p_pat_decoder
);
assert
(
p_section
);
/* Initialize the structures if it's the first section received */
if
(
p_pat_decoder
->
p_building_pat
==
NULL
)
{
p_pat_decoder
->
p_building_pat
=
dvbpsi_NewPAT
(
p_section
->
i_extension
,
p_section
->
i_version
,
p_section
->
b_current_next
);
if
(
p_pat_decoder
->
p_building_pat
==
NULL
)
return
false
;
p_pat_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
/* Fill the section array */
if
(
p_pat_decoder
->
ap_sections
[
p_section
->
i_number
]
!=
NULL
)
{
dvbpsi_debug
(
p_dvbpsi
,
"PAT decoder"
,
"overwrite section number %d"
,
p_section
->
i_number
);
dvbpsi_DeletePSISections
(
p_pat_decoder
->
ap_sections
[
p_section
->
i_number
]);
}
p_pat_decoder
->
ap_sections
[
p_section
->
i_number
]
=
p_section
;
return
true
;
}
/*****************************************************************************
* dvbpsi_GatherPATSections
*****************************************************************************
...
...
@@ -279,7 +326,7 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
/* TS discontinuity check */
if
(
p_pat_decoder
->
b_discontinuity
)
{
dvbpsi_ReInitPAT
(
p_pat_decoder
);
dvbpsi_ReInitPAT
(
p_pat_decoder
,
true
);
p_pat_decoder
->
b_discontinuity
=
false
;
}
else
...
...
@@ -287,7 +334,7 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
if
(
p_pat_decoder
->
p_building_pat
)
{
if
(
dvbpsi_CheckPAT
(
p_dvbpsi
,
p_section
))
dvbpsi_ReInitPAT
(
p_pat_decoder
);
dvbpsi_ReInitPAT
(
p_pat_decoder
,
true
);
}
else
{
...
...
@@ -306,12 +353,8 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
}
}
/* Initialize the structures if it's the first section received */
if
(
!
p_pat_decoder
->
p_building_pat
)
{
p_pat_decoder
->
p_building_pat
=
(
dvbpsi_pat_t
*
)
calloc
(
1
,
sizeof
(
dvbpsi_pat_t
));
if
(
p_pat_decoder
->
p_building_pat
==
NULL
)
/* Add section to PAT */
if
(
!
dvbpsi_AddSectionPAT
(
p_dvbpsi
,
p_pat_decoder
,
p_section
))
{
dvbpsi_error
(
p_dvbpsi
,
"PAT decoder"
,
"failed decoding section %d"
,
p_section
->
i_number
);
...
...
@@ -319,32 +362,8 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
return
;
}
dvbpsi_InitPAT
(
p_pat_decoder
->
p_building_pat
,
p_section
->
i_extension
,
p_section
->
i_version
,
p_section
->
b_current_next
);
p_pat_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
/* Fill the section array */
if
(
p_pat_decoder
->
ap_sections
[
p_section
->
i_number
]
!=
NULL
)
{
dvbpsi_debug
(
p_dvbpsi
,
"PAT decoder"
,
"overwrite section number %d"
,
p_section
->
i_number
);
dvbpsi_DeletePSISections
(
p_pat_decoder
->
ap_sections
[
p_section
->
i_number
]);
}
p_pat_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_pat_decoder
->
i_last_section_number
;
i
++
)
{
if
(
!
p_pat_decoder
->
ap_sections
[
i
])
break
;
if
(
i
==
p_pat_decoder
->
i_last_section_number
)
b_complete
=
true
;
}
if
(
b_complete
)
if
(
dvbpsi_IsCompletePAT
(
p_pat_decoder
))
{
assert
(
p_pat_decoder
->
pf_pat_callback
);
...
...
@@ -373,9 +392,7 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
p_pat_decoder
->
p_building_pat
);
/* Reinitialize the structures */
p_pat_decoder
->
p_building_pat
=
NULL
;
for
(
unsigned
int
i
=
0
;
i
<=
p_pat_decoder
->
i_last_section_number
;
i
++
)
p_pat_decoder
->
ap_sections
[
i
]
=
NULL
;
dvbpsi_ReInitPAT
(
p_pat_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