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
bfecad98
Commit
bfecad98
authored
Nov 25, 2015
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BAT: implement as chained decoder
parent
882a4a3a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
50 deletions
+66
-50
examples/decode_bat.c
examples/decode_bat.c
+23
-8
src/tables/bat.c
src/tables/bat.c
+40
-39
src/tables/bat_private.h
src/tables/bat_private.h
+3
-3
No files found.
examples/decode_bat.c
View file @
bfecad98
...
@@ -42,13 +42,13 @@
...
@@ -42,13 +42,13 @@
#ifdef DVBPSI_DIST
#ifdef DVBPSI_DIST
#include "../src/dvbpsi.h"
#include "../src/dvbpsi.h"
#include "../src/psi.h"
#include "../src/psi.h"
#include "../src/
demux
.h"
#include "../src/
chain
.h"
#include "../src/descriptor.h"
#include "../src/descriptor.h"
#include "../src/tables/bat.h"
#include "../src/tables/bat.h"
#else
#else
#include <dvbpsi/dvbpsi.h>
#include <dvbpsi/dvbpsi.h>
#include <dvbpsi/psi.h>
#include <dvbpsi/psi.h>
#include <dvbpsi/
demux
.h>
#include <dvbpsi/
chain
.h>
#include <dvbpsi/descriptor.h>
#include <dvbpsi/descriptor.h>
#include <dvbpsi/bat.h>
#include <dvbpsi/bat.h>
#endif
#endif
...
@@ -194,7 +194,6 @@ static void DumpBAT(void* p_zero, dvbpsi_bat_t* p_bat)
...
@@ -194,7 +194,6 @@ static void DumpBAT(void* p_zero, dvbpsi_bat_t* p_bat)
dvbpsi_bat_delete
(
p_bat
);
dvbpsi_bat_delete
(
p_bat
);
}
}
/*****************************************************************************
/*****************************************************************************
* NewSubtable
* NewSubtable
*****************************************************************************/
*****************************************************************************/
...
@@ -208,6 +207,18 @@ static void NewSubtableBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
...
@@ -208,6 +207,18 @@ static void NewSubtableBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
}
}
}
}
/*****************************************************************************
* DelSubtable
*****************************************************************************/
static
void
DelSubtableBAT
(
dvbpsi_t
*
p_dvbpsi
,
uint8_t
i_table_id
,
uint16_t
i_extension
)
{
if
(
i_table_id
==
0x4a
)
{
dvbpsi_bat_detach
(
p_dvbpsi
,
i_table_id
,
i_extension
);
}
}
static
void
message
(
dvbpsi_t
*
handle
,
const
dvbpsi_msg_level_t
level
,
const
char
*
msg
)
static
void
message
(
dvbpsi_t
*
handle
,
const
dvbpsi_msg_level_t
level
,
const
char
*
msg
)
{
{
switch
(
level
)
switch
(
level
)
...
@@ -227,21 +238,22 @@ static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char
...
@@ -227,21 +238,22 @@ static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char
int
main
(
int
i_argc
,
char
*
pa_argv
[])
int
main
(
int
i_argc
,
char
*
pa_argv
[])
{
{
int
i_fd
;
int
i_fd
;
int
ret
=
1
;
uint8_t
data
[
188
];
uint8_t
data
[
188
];
dvbpsi_t
*
p_dvbpsi
;
dvbpsi_t
*
p_dvbpsi
;
bool
b_ok
;
bool
b_ok
;
if
(
i_argc
!=
2
)
if
(
i_argc
!=
2
)
return
1
;
return
ret
;
i_fd
=
open
(
pa_argv
[
1
],
0
);
i_fd
=
open
(
pa_argv
[
1
],
0
);
if
(
i_fd
<
0
)
if
(
i_fd
<
0
)
return
1
;
return
ret
;
p_dvbpsi
=
dvbpsi_new
(
&
message
,
DVBPSI_MSG_DEBUG
);
p_dvbpsi
=
dvbpsi_new
(
&
message
,
DVBPSI_MSG_DEBUG
);
if
(
p_dvbpsi
==
NULL
)
if
(
p_dvbpsi
==
NULL
)
goto
out
;
goto
out
;
if
(
!
dvbpsi_
AttachDemux
(
p_dvbpsi
,
New
SubtableBAT
,
NULL
))
if
(
!
dvbpsi_
decoder_chain_new
(
p_dvbpsi
,
NewSubtableBAT
,
Del
SubtableBAT
,
NULL
))
goto
out
;
goto
out
;
b_ok
=
ReadPacket
(
i_fd
,
data
);
b_ok
=
ReadPacket
(
i_fd
,
data
);
...
@@ -254,12 +266,15 @@ int main(int i_argc, char* pa_argv[])
...
@@ -254,12 +266,15 @@ int main(int i_argc, char* pa_argv[])
b_ok
=
ReadPacket
(
i_fd
,
data
);
b_ok
=
ReadPacket
(
i_fd
,
data
);
}
}
ret
=
0
;
out:
out:
if
(
p_dvbpsi
)
if
(
p_dvbpsi
)
{
{
dvbpsi_DetachDemux
(
p_dvbpsi
);
if
(
!
dvbpsi_decoder_chain_delete
(
p_dvbpsi
))
ret
=
1
;
dvbpsi_delete
(
p_dvbpsi
);
dvbpsi_delete
(
p_dvbpsi
);
}
}
close
(
i_fd
);
close
(
i_fd
);
return
0
;
return
ret
;
}
}
src/tables/bat.c
View file @
bfecad98
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
#include "../dvbpsi_private.h"
#include "../dvbpsi_private.h"
#include "../psi.h"
#include "../psi.h"
#include "../descriptor.h"
#include "../descriptor.h"
#include "../
demux
.h"
#include "../
chain
.h"
#include "bat.h"
#include "bat.h"
#include "bat_private.h"
#include "bat_private.h"
...
@@ -59,10 +59,9 @@ bool dvbpsi_bat_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
...
@@ -59,10 +59,9 @@ bool dvbpsi_bat_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
uint16_t
i_extension
,
dvbpsi_bat_callback
pf_callback
,
void
*
p_cb_data
)
uint16_t
i_extension
,
dvbpsi_bat_callback
pf_callback
,
void
*
p_cb_data
)
{
{
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
->
p_decoder
);
dvbpsi_de
mux_t
*
p_demux
=
(
dvbpsi_demux_t
*
)
p_dvbpsi
->
p_decoder
;
dvbpsi_de
coder_t
*
p_dec
=
dvbpsi_decoder_chain_get
(
p_dvbpsi
,
i_table_id
,
i_extension
)
;
if
(
dvbpsi_demuxGetSubDec
(
p_demux
,
i_table_id
,
i_extension
)
)
if
(
p_dec
!=
NULL
)
{
{
dvbpsi_error
(
p_dvbpsi
,
"BAT decoder"
,
dvbpsi_error
(
p_dvbpsi
,
"BAT decoder"
,
"Already a decoder for (table_id == 0x%02x,"
"Already a decoder for (table_id == 0x%02x,"
...
@@ -71,30 +70,26 @@ bool dvbpsi_bat_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
...
@@ -71,30 +70,26 @@ bool dvbpsi_bat_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
return
false
;
return
false
;
}
}
dvbpsi_bat_decoder_t
*
p_bat_decoder
;
dvbpsi_bat_decoder_t
*
p_bat_decoder
;
p_bat_decoder
=
(
dvbpsi_bat_decoder_t
*
)
dvbpsi_decoder_new
(
NULL
,
p_bat_decoder
=
(
dvbpsi_bat_decoder_t
*
)
dvbpsi_decoder_new
(
dvbpsi_bat_sections_gather
,
0
,
true
,
sizeof
(
dvbpsi_bat_decoder_t
));
4096
,
true
,
sizeof
(
dvbpsi_bat_decoder_t
));
if
(
p_bat_decoder
==
NULL
)
if
(
p_bat_decoder
==
NULL
)
return
false
;
return
false
;
/* subtable decoder configuration */
dvbpsi_demux_subdec_t
*
p_subdec
;
p_subdec
=
dvbpsi_NewDemuxSubDecoder
(
i_table_id
,
i_extension
,
dvbpsi_bat_detach
,
dvbpsi_bat_sections_gather
,
DVBPSI_DECODER
(
p_bat_decoder
));
if
(
p_subdec
==
NULL
)
{
dvbpsi_decoder_delete
(
DVBPSI_DECODER
(
p_bat_decoder
));
return
false
;
}
/* Attach the subtable decoder to the demux */
dvbpsi_AttachDemuxSubDecoder
(
p_demux
,
p_subdec
);
/* BAT decoder information */
/* BAT decoder information */
p_bat_decoder
->
pf_bat_callback
=
pf_callback
;
p_bat_decoder
->
pf_bat_callback
=
pf_callback
;
p_bat_decoder
->
p_cb_data
=
p_cb_data
;
p_bat_decoder
->
p_cb_data
=
p_cb_data
;
p_bat_decoder
->
p_building_bat
=
NULL
;
p_bat_decoder
->
p_building_bat
=
NULL
;
p_bat_decoder
->
i_table_id
=
i_table_id
;
p_bat_decoder
->
i_extension
=
i_extension
;
/* Add bat decoder to decoder chain */
if
(
!
dvbpsi_decoder_chain_add
(
p_dvbpsi
,
DVBPSI_DECODER
(
p_bat_decoder
)))
{
dvbpsi_decoder_delete
(
DVBPSI_DECODER
(
p_bat_decoder
));
return
false
;
}
return
true
;
return
true
;
}
}
...
@@ -106,13 +101,9 @@ bool dvbpsi_bat_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
...
@@ -106,13 +101,9 @@ bool dvbpsi_bat_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
void
dvbpsi_bat_detach
(
dvbpsi_t
*
p_dvbpsi
,
uint8_t
i_table_id
,
uint16_t
i_extension
)
void
dvbpsi_bat_detach
(
dvbpsi_t
*
p_dvbpsi
,
uint8_t
i_table_id
,
uint16_t
i_extension
)
{
{
assert
(
p_dvbpsi
);
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
;
dvbpsi_decoder_t
*
p_dec
=
dvbpsi_decoder_chain_get
(
p_dvbpsi
,
i_table_id
,
i_extension
);
p_subdec
=
dvbpsi_demuxGetSubDec
(
p_demux
,
i_table_id
,
i_extension
);
if
(
p_dec
==
NULL
)
if
(
p_subdec
==
NULL
)
{
{
dvbpsi_error
(
p_dvbpsi
,
"BAT Decoder"
,
dvbpsi_error
(
p_dvbpsi
,
"BAT Decoder"
,
"No such BAT decoder (table_id == 0x%02x,"
"No such BAT decoder (table_id == 0x%02x,"
...
@@ -121,14 +112,22 @@ void dvbpsi_bat_detach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extens
...
@@ -121,14 +112,22 @@ void dvbpsi_bat_detach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extens
return
;
return
;
}
}
dvbpsi_bat_decoder_t
*
p_bat_decoder
;
/* Remove table decoder from chain */
p_bat_decoder
=
(
dvbpsi_bat_decoder_t
*
)
p_subdec
->
p_decoder
;
if
(
!
dvbpsi_decoder_chain_remove
(
p_dvbpsi
,
p_dec
))
{
dvbpsi_error
(
p_dvbpsi
,
"BAT Decoder"
,
"Failed to remove"
"extension == 0x%02x)"
,
i_table_id
,
i_extension
);
return
;
}
dvbpsi_bat_decoder_t
*
p_bat_decoder
=
(
dvbpsi_bat_decoder_t
*
)
p_dec
;
if
(
p_bat_decoder
->
p_building_bat
)
if
(
p_bat_decoder
->
p_building_bat
)
dvbpsi_bat_delete
(
p_bat_decoder
->
p_building_bat
);
dvbpsi_bat_delete
(
p_bat_decoder
->
p_building_bat
);
p_bat_decoder
->
p_building_bat
=
NULL
;
p_bat_decoder
->
p_building_bat
=
NULL
;
dvbpsi_decoder_delete
(
p_dec
);
dvbpsi_DetachDemuxSubDecoder
(
p_demux
,
p_subdec
);
p_dec
=
NULL
;
dvbpsi_DeleteDemuxSubDecoder
(
p_subdec
);
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -362,14 +361,9 @@ static bool dvbpsi_AddSectionBAT(dvbpsi_t *p_dvbpsi, dvbpsi_bat_decoder_t *p_bat
...
@@ -362,14 +361,9 @@ static bool dvbpsi_AddSectionBAT(dvbpsi_t *p_dvbpsi, dvbpsi_bat_decoder_t *p_bat
* Callback for the subtable demultiplexor.
* Callback for the subtable demultiplexor.
*****************************************************************************/
*****************************************************************************/
void
dvbpsi_bat_sections_gather
(
dvbpsi_t
*
p_dvbpsi
,
void
dvbpsi_bat_sections_gather
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_decoder_t
*
p_decoder
,
dvbpsi_psi_section_t
*
p_section
)
dvbpsi_psi_section_t
*
p_section
)
{
{
dvbpsi_demux_t
*
p_demux
=
(
dvbpsi_demux_t
*
)
p_dvbpsi
->
p_decoder
;
dvbpsi_bat_decoder_t
*
p_bat_decoder
=
(
dvbpsi_bat_decoder_t
*
)
p_decoder
;
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
->
p_decoder
);
if
(
!
dvbpsi_CheckPSISection
(
p_dvbpsi
,
p_section
,
0x4a
,
"BAT decoder"
))
if
(
!
dvbpsi_CheckPSISection
(
p_dvbpsi
,
p_section
,
0x4a
,
"BAT decoder"
))
{
{
...
@@ -378,11 +372,18 @@ void dvbpsi_bat_sections_gather(dvbpsi_t *p_dvbpsi,
...
@@ -378,11 +372,18 @@ void dvbpsi_bat_sections_gather(dvbpsi_t *p_dvbpsi,
}
}
/* We have a valid BAT section */
/* We have a valid BAT section */
if
(
p_demux
->
b_discontinuity
)
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
;
}
dvbpsi_bat_decoder_t
*
p_bat_decoder
=
(
dvbpsi_bat_decoder_t
*
)
p_dec
;
if
(
p_bat_decoder
->
b_discontinuity
)
{
{
dvbpsi_ReInitBAT
(
p_bat_decoder
,
true
);
dvbpsi_ReInitBAT
(
p_bat_decoder
,
true
);
p_bat_decoder
->
b_discontinuity
=
false
;
p_bat_decoder
->
b_discontinuity
=
false
;
p_demux
->
b_discontinuity
=
false
;
}
}
else
else
{
{
...
...
src/tables/bat_private.h
View file @
bfecad98
...
@@ -51,8 +51,8 @@ typedef struct dvbpsi_bat_decoder_s
...
@@ -51,8 +51,8 @@ typedef struct dvbpsi_bat_decoder_s
*****************************************************************************
*****************************************************************************
* Callback for the PSI decoder.
* Callback for the PSI decoder.
*****************************************************************************/
*****************************************************************************/
void
dvbpsi_bat_sections_gather
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_decoder_t
*
p_decoder
,
void
dvbpsi_bat_sections_gather
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_psi_section_t
*
p_section
);
dvbpsi_psi_section_t
*
p_section
);
/*****************************************************************************
/*****************************************************************************
* dvbpsi_bat_sections_decode
* dvbpsi_bat_sections_decode
...
@@ -60,7 +60,7 @@ void dvbpsi_bat_sections_gather(dvbpsi_t* p_dvbpsi, dvbpsi_decoder_t* p_decoder,
...
@@ -60,7 +60,7 @@ void dvbpsi_bat_sections_gather(dvbpsi_t* p_dvbpsi, dvbpsi_decoder_t* p_decoder,
* BAT decoder.
* BAT decoder.
*****************************************************************************/
*****************************************************************************/
void
dvbpsi_bat_sections_decode
(
dvbpsi_bat_t
*
p_bat
,
void
dvbpsi_bat_sections_decode
(
dvbpsi_bat_t
*
p_bat
,
dvbpsi_psi_section_t
*
p_section
);
dvbpsi_psi_section_t
*
p_section
);
#else
#else
#error "Multiple inclusions of bat_private.h"
#error "Multiple inclusions of bat_private.h"
...
...
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