From patchwork Thu Sep 18 18:59:27 2014 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: 4933301 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 0DB53BEEA5 for ; Thu, 18 Sep 2014 18:59:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0ADB620142 for ; Thu, 18 Sep 2014 18:59:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0696920121 for ; Thu, 18 Sep 2014 18:59:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753741AbaIRS7s (ORCPT ); Thu, 18 Sep 2014 14:59:48 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:49091 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751099AbaIRS7r (ORCPT ); Thu, 18 Sep 2014 14:59:47 -0400 Received: by mail-wi0-f170.google.com with SMTP id em10so7232197wid.1 for ; Thu, 18 Sep 2014 11:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=kBw7I7tOEwlN8FTMXU443gV+vBsHK/R08tZ++DnADAs=; b=zFVtv9z8RSXbgCuJvnOp/J3W+rZdc4pBZhSN0W4jbJt3I4mxH/ZMCjGp9AbBUnosbw I478dsNKB+pTWouOL+foNHBe/uG/5xvgUH0xvDiXQ7Y4OfUG+zJ/T3DlkCDxOMjTNFie sKJXY2y6HUq3KGk/BnLTN/FmTYGLxcDli0CO6jcsoWLvRCsP4wERLwGc5IXdHFS/Wryu /0Ya8y7QPmlOLoSEvau+FWU4z/oSBBrtM4Mb4LpgmzeTQIuBStmWyxkNbsipz+0ILba5 HKgG/N2r4wYhwEEQbL3VdNEl603VGjWooR1zQ6rMre9mp+3wV8Q6S3AdSj0c9oSZ8/Tn QR7w== X-Received: by 10.180.210.239 with SMTP id mx15mr50449326wic.29.1411066786284; Thu, 18 Sep 2014 11:59:46 -0700 (PDT) Received: from neutrino.exnihilo (162-27.194-178.cust.bluewin.ch. [178.194.27.162]) by mx.google.com with ESMTPSA id xm4sm114436wib.9.2014.09.18.11.59.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Sep 2014 11:59:45 -0700 (PDT) From: =?UTF-8?q?Andr=C3=A9=20Roth?= To: linux-media@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Roth?= Subject: [PATCH v3] libdvbv5: MPEG TS parser documentation Date: Thu, 18 Sep 2014 20:59:27 +0200 Message-Id: <1411066767-15653-1-git-send-email-neolynx@gmail.com> X-Mailer: git-send-email 1.9.1 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 --- doxygen_libdvbv5.cfg | 1 + lib/include/libdvbv5/mpeg_ts.h | 96 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 94 insertions(+), 3 deletions(-) diff --git a/doxygen_libdvbv5.cfg b/doxygen_libdvbv5.cfg index f1f9ab4..bbdaf9a 100644 --- a/doxygen_libdvbv5.cfg +++ b/doxygen_libdvbv5.cfg @@ -765,6 +765,7 @@ INPUT = $(SRCDIR)/doc/libdvbv5-index.doc \ $(SRCDIR)/lib/include/libdvbv5/vct.h \ $(SRCDIR)/lib/include/libdvbv5/crc32.h \ $(SRCDIR)/lib/include/libdvbv5/mpeg_es.h \ + $(SRCDIR)/lib/include/libdvbv5/mpeg_ts.h \ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/lib/include/libdvbv5/mpeg_ts.h b/lib/include/libdvbv5/mpeg_ts.h index 3eab029..cfb8831 100644 --- a/lib/include/libdvbv5/mpeg_ts.h +++ b/lib/include/libdvbv5/mpeg_ts.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 - Andre Roth + * Copyright (c) 2013-2014 - Andre Roth * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -21,12 +21,52 @@ #ifndef _MPEG_TS_H #define _MPEG_TS_H +/** + * @file mpeg_ts.h + * @ingroup dvb_table + * @brief Provides the table parser for the MPEG-PES Elementary Stream + * @copyright GNU General Public License version 2 (GPLv2) + * @author Andre Roth + * + * @par Relevant specs + * The table described herein is defined in ISO 13818-1 + * + * @see + * http://en.wikipedia.org/wiki/MPEG_transport_stream + * + * @par Bug Report + * Please submit bug reports and patches to linux-media@vger.kernel.org + */ #include #include /* ssize_t */ +/** + * @def DVB_MPEG_TS + * @brief MPEG Transport Stream magic + * @ingroup dvb_table + * @def DVB_MPEG_TS_PACKET_SIZE + * @brief Size of an MPEG packet + * @ingroup dvb_table + */ #define DVB_MPEG_TS 0x47 #define DVB_MPEG_TS_PACKET_SIZE 188 +/** + * @struct dvb_mpeg_ts_adaption + * @brief MPEG TS header adaption field + * + * @param type DVB_MPEG_ES_SEQ_START + * @param length 1 bit Adaptation Field Length + * @param discontinued 1 bit Discontinuity indicator + * @param random_access 1 bit Random Access indicator + * @param priority 1 bit Elementary stream priority indicator + * @param PCR 1 bit PCR flag + * @param OPCR 1 bit OPCR flag + * @param splicing_point 1 bit Splicing point flag + * @param private_data 1 bit Transport private data flag + * @param extension 1 bit Adaptation field extension flag + * @param data Pointer to data + */ struct dvb_mpeg_ts_adaption { uint8_t length; struct { @@ -42,8 +82,23 @@ struct dvb_mpeg_ts_adaption { uint8_t data[]; } __attribute__((packed)); +/** + * @struct dvb_mpeg_ts + * @brief MPEG TS header + * + * @param sync_byte DVB_MPEG_TS + * @param tei 1 bit Transport Error Indicator + * @param payload_start 1 bit Payload Unit Start Indicator + * @param priority 1 bit Transport Priority + * @param pid 13 bits Packet Identifier + * @param scrambling 2 bits Scrambling control + * @param adaptation_field 1 bit Adaptation field exist + * @param payload 1 bit Contains payload + * @param continuity_counter 4 bits Continuity counter + * @param adaption Pointer to optional adaption fiels (struct dvb_mpeg_ts_adaption) + */ struct dvb_mpeg_ts { - uint8_t sync_byte; // DVB_MPEG_TS + uint8_t sync_byte; union { uint16_t bitfield; struct { @@ -68,8 +123,43 @@ struct dvb_v5_fe_parms; extern "C" { #endif -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); +/** + * @brief Initialize a struct dvb_mpeg_ts from buffer + * + * @param parms struct dvb_v5_fe_parms for log functions + * @param buf Buffer + * @param buflen Length of buffer + * @param table Pointer to allocated struct dvb_mpeg_ts + * @param table_length Pointer to size_t where length will be written to + * + * @return Length of data in table + * + * This function copies the length of struct dvb_mpeg_ts + * to table and fixes endianness. table has to be allocated + * with malloc. + */ +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); + +/** + * @brief Deallocate memory associated with a struct dvb_mpeg_ts + * @ingroup file + * + * @param ts struct dvb_mpeg_ts to be deallocated + * + * This function assumes frees dynamically allocated memory by the + * dvb_mpeg_ts_init function. + */ void dvb_mpeg_ts_free(struct dvb_mpeg_ts *ts); + +/** + * @brief Print details of struct dvb_mpeg_ts + * + * @param parms struct dvb_v5_fe_parms for log functions + * @param ts Pointer to struct dvb_mpeg_ts to print + * + * This function prints the fields of struct dvb_mpeg_ts + */ void dvb_mpeg_ts_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_ts *ts); #ifdef __cplusplus