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
882a4a3a
Commit
882a4a3a
authored
Nov 25, 2015
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SDT: implement as chained decoder
parent
925cbbc6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
49 deletions
+60
-49
examples/decode_sdt.c
examples/decode_sdt.c
+20
-6
src/tables/sdt.c
src/tables/sdt.c
+40
-42
src/tables/sdt_private.h
src/tables/sdt_private.h
+0
-1
No files found.
examples/decode_sdt.c
View file @
882a4a3a
...
...
@@ -43,13 +43,13 @@
#ifdef DVBPSI_DIST
#include "../src/dvbpsi.h"
#include "../src/psi.h"
#include "../src/
demux
.h"
#include "../src/
chain
.h"
#include "../src/descriptor.h"
#include "../src/tables/sdt.h"
#else
#include <dvbpsi/dvbpsi.h>
#include <dvbpsi/psi.h>
#include <dvbpsi/
demux
.h>
#include <dvbpsi/
chain
.h>
#include <dvbpsi/descriptor.h>
#include <dvbpsi/sdt.h>
#endif
...
...
@@ -151,12 +151,24 @@ static void NewSubtable(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_exten
}
}
/*****************************************************************************
* DelSubtable
*****************************************************************************/
static
void
DelSubtable
(
dvbpsi_t
*
p_dvbpsi
,
uint8_t
i_table_id
,
uint16_t
i_extension
)
{
if
(
i_table_id
==
0x42
)
{
dvbpsi_sdt_detach
(
p_dvbpsi
,
i_table_id
,
i_extension
);
}
}
/*****************************************************************************
* main
*****************************************************************************/
int
main
(
int
i_argc
,
char
*
pa_argv
[])
{
int
i_fd
;
int
ret
=
1
;
uint8_t
data
[
188
];
dvbpsi_t
*
p_dvbpsi
;
bool
b_ok
;
...
...
@@ -172,7 +184,7 @@ int main(int i_argc, char* pa_argv[])
if
(
p_dvbpsi
==
NULL
)
goto
out
;
if
(
!
dvbpsi_
AttachDemux
(
p_dvbpsi
,
New
Subtable
,
NULL
))
if
(
!
dvbpsi_
decoder_chain_new
(
p_dvbpsi
,
NewSubtable
,
Del
Subtable
,
NULL
))
goto
out
;
b_ok
=
ReadPacket
(
i_fd
,
data
);
...
...
@@ -185,13 +197,15 @@ int main(int i_argc, char* pa_argv[])
b_ok
=
ReadPacket
(
i_fd
,
data
);
}
ret
=
0
;
out:
if
(
p_dvbpsi
)
{
dvbpsi_DetachDemux
(
p_dvbpsi
);
if
(
!
dvbpsi_decoder_chain_delete
(
p_dvbpsi
))
ret
=
1
;
dvbpsi_delete
(
p_dvbpsi
);
}
close
(
i_fd
);
return
0
;
return
ret
;
}
src/tables/sdt.c
View file @
882a4a3a
...
...
@@ -44,7 +44,7 @@
#include "../dvbpsi_private.h"
#include "../psi.h"
#include "../descriptor.h"
#include "../
demux
.h"
#include "../
chain
.h"
#include "sdt.h"
#include "sdt_private.h"
...
...
@@ -57,11 +57,9 @@ bool dvbpsi_sdt_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extens
dvbpsi_sdt_callback
pf_callback
,
void
*
p_cb_data
)
{
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
->
p_decoder
);
dvbpsi_demux_t
*
p_demux
=
(
dvbpsi_demux_t
*
)
p_dvbpsi
->
p_decoder
;
if
(
dvbpsi_demuxGetSubDec
(
p_demux
,
i_table_id
,
i_extension
))
dvbpsi_decoder_t
*
p_dec
=
dvbpsi_decoder_chain_get
(
p_dvbpsi
,
i_table_id
,
i_extension
);
if
(
p_dec
!=
NULL
)
{
dvbpsi_error
(
p_dvbpsi
,
"SDT decoder"
,
"Already a decoder for (table_id == 0x%02x,"
...
...
@@ -71,29 +69,26 @@ bool dvbpsi_sdt_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extens
}
dvbpsi_sdt_decoder_t
*
p_sdt_decoder
;
p_sdt_decoder
=
(
dvbpsi_sdt_decoder_t
*
)
dvbpsi_decoder_new
(
NULL
,
0
,
true
,
sizeof
(
dvbpsi_sdt_decoder_t
));
p_sdt_decoder
=
(
dvbpsi_sdt_decoder_t
*
)
dvbpsi_decoder_new
(
dvbpsi_sdt_sections_gather
,
4096
,
true
,
sizeof
(
dvbpsi_sdt_decoder_t
));
if
(
p_sdt_decoder
==
NULL
)
return
false
;
/* subtable decoder configuration */
dvbpsi_demux_subdec_t
*
p_subdec
;
p_subdec
=
dvbpsi_NewDemuxSubDecoder
(
i_table_id
,
i_extension
,
dvbpsi_sdt_detach
,
dvbpsi_sdt_sections_gather
,
DVBPSI_DECODER
(
p_sdt_decoder
));
if
(
p_subdec
==
NULL
)
{
dvbpsi_decoder_delete
(
DVBPSI_DECODER
(
p_sdt_decoder
));
return
false
;
}
/* Attach the subtable decoder to the demux */
dvbpsi_AttachDemuxSubDecoder
(
p_demux
,
p_subdec
);
/* SDT decoder information */
p_sdt_decoder
->
pf_sdt_callback
=
pf_callback
;
p_sdt_decoder
->
p_cb_data
=
p_cb_data
;
p_sdt_decoder
->
p_building_sdt
=
NULL
;
p_sdt_decoder
->
i_table_id
=
i_table_id
;
p_sdt_decoder
->
i_extension
=
i_extension
;
/* add sdt decoder to decoder chain */
if
(
!
dvbpsi_decoder_chain_add
(
p_dvbpsi
,
DVBPSI_DECODER
(
p_sdt_decoder
)))
{
dvbpsi_decoder_delete
(
DVBPSI_DECODER
(
p_sdt_decoder
));
return
false
;
}
return
true
;
}
...
...
@@ -105,13 +100,9 @@ bool dvbpsi_sdt_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extens
void
dvbpsi_sdt_detach
(
dvbpsi_t
*
p_dvbpsi
,
uint8_t
i_table_id
,
uint16_t
i_extension
)
{
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
->
p_decoder
);
dvbpsi_demux_t
*
p_demux
=
(
dvbpsi_demux_t
*
)
p_dvbpsi
->
p_decoder
;
dvbpsi_demux_subdec_t
*
p_subdec
;
p_subdec
=
dvbpsi_demuxGetSubDec
(
p_demux
,
i_table_id
,
i_extension
);
if
(
p_subdec
==
NULL
)
dvbpsi_decoder_t
*
p_dec
=
dvbpsi_decoder_chain_get
(
p_dvbpsi
,
i_table_id
,
i_extension
);
if
(
p_dec
==
NULL
)
{
dvbpsi_error
(
p_dvbpsi
,
"SDT Decoder"
,
"No such SDT decoder (table_id == 0x%02x,"
...
...
@@ -120,17 +111,23 @@ void dvbpsi_sdt_detach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extens
return
;
}
assert
(
p_subdec
->
p_decoder
);
/* Remove table decoder from decoder chain */
if
(
!
dvbpsi_decoder_chain_remove
(
p_dvbpsi
,
p_dec
))
{
dvbpsi_error
(
p_dvbpsi
,
"SDT Decoder"
,
"Failed to remove"
"extension == 0x%02x)"
,
i_table_id
,
i_extension
);
return
;
}
dvbpsi_sdt_decoder_t
*
p_sdt_decoder
;
p_sdt_decoder
=
(
dvbpsi_sdt_decoder_t
*
)
p_subdec
->
p_decoder
;
/* Free associated memory */
dvbpsi_sdt_decoder_t
*
p_sdt_decoder
=
(
dvbpsi_sdt_decoder_t
*
)
p_dec
;
if
(
p_sdt_decoder
->
p_building_sdt
)
dvbpsi_sdt_delete
(
p_sdt_decoder
->
p_building_sdt
);
p_sdt_decoder
->
p_building_sdt
=
NULL
;
/* Free sub table decoder */
dvbpsi_DetachDemuxSubDecoder
(
p_demux
,
p_subdec
);
dvbpsi_DeleteDemuxSubDecoder
(
p_subdec
);
dvbpsi_decoder_delete
(
p_dec
);
p_dec
=
NULL
;
}
/*****************************************************************************
...
...
@@ -346,12 +343,9 @@ static bool dvbpsi_AddSectionSDT(dvbpsi_t *p_dvbpsi, dvbpsi_sdt_decoder_t *p_sdt
*****************************************************************************
* Callback for the subtable demultiplexor.
*****************************************************************************/
void
dvbpsi_sdt_sections_gather
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_decoder_t
*
p_private_decoder
,
dvbpsi_psi_section_t
*
p_section
)
void
dvbpsi_sdt_sections_gather
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_psi_section_t
*
p_section
)
{
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
->
p_decoder
);
const
uint8_t
i_table_id
=
(
p_section
->
i_table_id
==
0x42
||
p_section
->
i_table_id
==
0x46
)
?
...
...
@@ -363,17 +357,21 @@ void dvbpsi_sdt_sections_gather(dvbpsi_t *p_dvbpsi,
return
;
}
dvbpsi_decoder_t
*
p_dec
=
dvbpsi_decoder_chain_get
(
p_dvbpsi
,
p_section
->
i_table_id
,
p_section
->
i_extension
);
if
(
!
p_dec
)
{
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
/* We have a valid SDT section */
dvbpsi_demux_t
*
p_demux
=
(
dvbpsi_demux_t
*
)
p_dvbpsi
->
p_decoder
;
dvbpsi_sdt_decoder_t
*
p_sdt_decoder
=
(
dvbpsi_sdt_decoder_t
*
)
p_private_decoder
;
dvbpsi_sdt_decoder_t
*
p_sdt_decoder
=
(
dvbpsi_sdt_decoder_t
*
)
p_dec
;
/* TS discontinuity check */
if
(
p_
demux
->
b_discontinuity
)
if
(
p_
sdt_decoder
->
b_discontinuity
)
{
dvbpsi_ReInitSDT
(
p_sdt_decoder
,
true
);
p_sdt_decoder
->
b_discontinuity
=
false
;
p_demux
->
b_discontinuity
=
false
;
}
else
{
...
...
src/tables/sdt_private.h
View file @
882a4a3a
...
...
@@ -51,7 +51,6 @@ typedef struct dvbpsi_sdt_decoder_s
* Callback for the PSI decoder.
*****************************************************************************/
void
dvbpsi_sdt_sections_gather
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_decoder_t
*
p_private_decoder
,
dvbpsi_psi_section_t
*
p_section
);
/*****************************************************************************
...
...
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