From patchwork Sat Dec 28 15:46:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Roth?= X-Patchwork-Id: 3414091 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8F89DC02DC for ; Sat, 28 Dec 2013 15:46:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B4A6D20107 for ; Sat, 28 Dec 2013 15:46:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DD9F520103 for ; Sat, 28 Dec 2013 15:46:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755381Ab3L1Pqs (ORCPT ); Sat, 28 Dec 2013 10:46:48 -0500 Received: from mail-ee0-f42.google.com ([74.125.83.42]:46954 "EHLO mail-ee0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755292Ab3L1Pqb (ORCPT ); Sat, 28 Dec 2013 10:46:31 -0500 Received: by mail-ee0-f42.google.com with SMTP id e53so4405766eek.15 for ; Sat, 28 Dec 2013 07:46:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=OVd6shmg6md8jHAFkKEOHLg0l5dlqgtf75fwC36Mc+M=; b=bah5HvvyoL540paTEbBwnzeK9ADFlzFVs2iicA6Y+KxoxI/GAbyQsbNZLgFfn0jZGj VOxsMqmTPln430GK79y9lsYxvR7w0qRIh0vavezySA51vMlOMEqfECc472Bb5R8by7GL J/klGtJ/6ockDzVWPrhdL1b+LRBHRjSHH88kGV1cG8bVFy6AIC5xqkmi8VLX846DsZL6 mxj5tsnZDfl9tEnMrQBR4uNQ+x38wBPHN9FHL8fYp4ZMRkijZb95HIaZADErP/wtWrei 5ZoxCvUOdnckgj2KoutqEuStkzBqiTHQkoDZKZ4BgRvgZH+GF9oEXv8PxbU2EKZcUc5l oSOw== X-Received: by 10.15.91.3 with SMTP id r3mr47913619eez.18.1388245590058; Sat, 28 Dec 2013 07:46:30 -0800 (PST) Received: from neutrino.exnihilo (140-227.61-188.cust.bluewin.ch. [188.61.227.140]) by mx.google.com with ESMTPSA id n1sm91594131eep.20.2013.12.28.07.46.28 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 28 Dec 2013 07:46:29 -0800 (PST) From: =?UTF-8?q?Andr=C3=A9=20Roth?= To: Linux Media Mailing List Cc: =?UTF-8?q?Andr=C3=A9=20Roth?= Subject: [PATCH 13/13] libdvbv5: improve TS parsing Date: Sat, 28 Dec 2013 16:46:01 +0100 Message-Id: <1388245561-8751-13-git-send-email-neolynx@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1388245561-8751-1-git-send-email-neolynx@gmail.com> References: <1388245561-8751-1-git-send-email-neolynx@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: André Roth --- 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)