From patchwork Mon Dec 30 12:48:46 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: 3419211 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 0F32BC02DC for ; Mon, 30 Dec 2013 12:49:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF1D9200E6 for ; Mon, 30 Dec 2013 12:49:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3BDB020107 for ; Mon, 30 Dec 2013 12:49:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755860Ab3L3Mth (ORCPT ); Mon, 30 Dec 2013 07:49:37 -0500 Received: from mail-ee0-f45.google.com ([74.125.83.45]:38277 "EHLO mail-ee0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755736Ab3L3Mtf (ORCPT ); Mon, 30 Dec 2013 07:49:35 -0500 Received: by mail-ee0-f45.google.com with SMTP id d49so5056453eek.4 for ; Mon, 30 Dec 2013 04:49:34 -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=UFQ7h2NOJVrolJQ6nj0wmSYB2DzX7kZgZGIdbgN4SJk=; b=uQ7BRkcITkSrCYmc9vzwtbttaB3MTWUQBlrv67Xcl/NhwbQ8ERl+fxww0pUak+thU6 sFpIGisk0fLxTM0RfHUZ62AcGrBAOBaWAgHlEy5Zm8eQTAcjbzMwpbo0m6gQqEfXdFEe Edsr9zug2MgFWPJfMI0M1r6KDMv1XSDsLagy1O6cOlprvPY3aZCyjl4WDZnRgIw39mcS ifCJQ+ouTA9COciMrJgGNkxL0Di/YTk7OgZ3tgBAd3teKp1Reu/Z/ytKxi6RGDXOyz36 kkkvJmRrBTJNTEqTBCoJRZYO5wcP/U2RaxVCcS36JYmWywt3HycfPUuMf57/HIRA4/by bnnw== X-Received: by 10.14.224.197 with SMTP id x45mr1451590eep.103.1388407774091; Mon, 30 Dec 2013 04:49:34 -0800 (PST) Received: from neutrino.exnihilo (140-227.61-188.cust.bluewin.ch. [188.61.227.140]) by mx.google.com with ESMTPSA id z42sm108428856eeo.17.2013.12.30.04.49.32 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Dec 2013 04:49:33 -0800 (PST) From: =?UTF-8?q?Andr=C3=A9=20Roth?= To: linux-media@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Roth?= Subject: [PATCH 13/18] libdvbv5: improve TS parsing Date: Mon, 30 Dec 2013 13:48:46 +0100 Message-Id: <1388407731-24369-13-git-send-email-neolynx@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1388407731-24369-1-git-send-email-neolynx@gmail.com> References: <1388407731-24369-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=-6.9 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 54fee69..de4fc3f 100644 --- a/lib/include/descriptors/mpeg_ts.h +++ b/lib/include/descriptors/mpeg_ts.h @@ -38,7 +38,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 { @@ -67,7 +67,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 d7ec2c4..b06cdf7 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)