From 846b3b5ba1b61592bf50cbc1959c56fd41eec675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Sat, 15 Aug 2009 08:16:47 +0000 Subject: [PATCH] Add psi_rawts_table_parser() for parsing tables just based on TS packets --- src/psi.c | 28 +++++++++++++++++++++++++++- src/psi.h | 4 ++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/psi.c b/src/psi.c index eddf758c..b084a0bc 100644 --- a/src/psi.c +++ b/src/psi.c @@ -62,14 +62,40 @@ psi_section_reassemble(psi_section_t *ps, uint8_t *data, int len, } +/** + * TS table parser + */ +void +psi_rawts_table_parser(psi_section_t *section, uint8_t *tsb, + void (*gotsection)(const uint8_t *data, int len, + void *opauqe), void *opaque) +{ + int off = tsb[3] & 0x20 ? tsb[4] + 5 : 4; + int pusi = tsb[1] & 0x40; + int len; + if(off >= 188) + return; + if(pusi) { + len = tsb[off++]; + if(len > 0) { + if(len > 188 - off) + return; + if(!psi_section_reassemble(section, tsb + off, len, 0, 1)) + gotsection(section->ps_data, section->ps_offset, opaque); + off += len; + } + } + + if(!psi_section_reassemble(section, tsb + off, 188 - off, pusi, 1)) + gotsection(section->ps_data, section->ps_offset, opaque); +} /** * PAT parser, from ISO 13818-1 */ - int psi_parse_pat(th_transport_t *t, uint8_t *ptr, int len, pid_section_callback_t *pmt_callback) diff --git a/src/psi.h b/src/psi.h index f0e48aa0..e3ace6d3 100644 --- a/src/psi.h +++ b/src/psi.h @@ -49,4 +49,8 @@ const char *psi_caid2name(uint16_t caid); void psi_load_transport_settings(htsmsg_t *m, th_transport_t *t); void psi_save_transport_settings(htsmsg_t *m, th_transport_t *t); +void psi_rawts_table_parser(psi_section_t *section, uint8_t *tsb, + void (*gotsection)(const uint8_t *data, int len, + void *opauqe), void *opaque); + #endif /* PSI_H_ */