Signed-off-by: André Roth <neolynx@xxxxxxxxx> --- lib/include/descriptors/mpeg_ts.h | 4 ++-- lib/libdvbv5/descriptors/mpeg_ts.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/include/descriptors/mpeg_ts.h b/lib/include/descriptors/mpeg_ts.h index 2bb570b..f332a58 100644 --- a/lib/include/descriptors/mpeg_ts.h +++ b/lib/include/descriptors/mpeg_ts.h @@ -39,7 +39,7 @@ struct dvb_mpeg_ts_adaption { uint8_t random_access:1; uint8_t discontinued:1; } __attribute__((packed)); - + uint8_t data[]; } __attribute__((packed)); struct dvb_mpeg_ts { @@ -68,7 +68,7 @@ struct dvb_v5_fe_parms; extern "C" { #endif -void dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length); +ssize_t dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length); void dvb_mpeg_ts_free(struct dvb_mpeg_ts *ts); void dvb_mpeg_ts_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_ts *ts); diff --git a/lib/libdvbv5/descriptors/mpeg_ts.c b/lib/libdvbv5/descriptors/mpeg_ts.c index c1d1293..e55f590 100644 --- a/lib/libdvbv5/descriptors/mpeg_ts.c +++ b/lib/libdvbv5/descriptors/mpeg_ts.c @@ -22,27 +22,32 @@ #include "descriptors.h" #include "dvb-fe.h" -void dvb_mpeg_ts_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length) +ssize_t dvb_mpeg_ts_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length) { if (buf[0] != DVB_MPEG_TS) { dvb_logerr("mpeg ts invalid marker %#02x, sould be %#02x", buf[0], DVB_MPEG_TS); *table_length = 0; - return; + return 0; } + ssize_t bytes_read = 0; struct dvb_mpeg_ts *ts = (struct dvb_mpeg_ts *) table; const uint8_t *p = buf; memcpy(table, p, sizeof(struct dvb_mpeg_ts)); p += sizeof(struct dvb_mpeg_ts); + bytes_read += sizeof(struct dvb_mpeg_ts); *table_length = sizeof(struct dvb_mpeg_ts); bswap16(ts->bitfield); if (ts->adaptation_field & 0x2) { memcpy(table + *table_length, p, sizeof(struct dvb_mpeg_ts_adaption)); - p += sizeof(struct dvb_mpeg_ts); + p += sizeof(struct dvb_mpeg_ts_adaption); + bytes_read += sizeof(struct dvb_mpeg_ts_adaption); *table_length += ts->adaption->length + 1; + // FIXME: copy adaption->lenght bytes } /*hexdump(parms, "TS: ", buf, buflen);*/ + return bytes_read; } void dvb_mpeg_ts_free(struct dvb_mpeg_ts *ts) -- 1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html