Updating prebuilts and/or headers

f07563fa1628a75c578152387638b1f217f730be - libv4lconvert/Makefile
6ac3c887c56c7d4345499cb5b7bfac9579a57d16 - libv4lconvert/cpia1.c
2d385802ec3690e78a961ce95431e98eb3f5fc6a - libv4lconvert/rgbyuv.c
43843cbdb81f3efee5873f5ed25ae1eb7745a9e5 - libv4lconvert/libv4lconvert-priv.h
002783c808dc565478c18bd27373792028264bb6 - libv4lconvert/ov518-decomp.c
4d49e6e897046e66e41c3563fec2eb2562abf813 - libv4lconvert/jpeg_memsrcdest.c
a38fdb4c79518e972678745c93cd62881d72972b - libv4lconvert/Makefile.dGPU
e9f783fb933606224252dfd3093afa36490f6f4c - libv4lconvert/Makefile.in
52900601a24ee9ffea87ca7fe6651e912e20235e - libv4lconvert/libv4lsyscall-priv.h
d37f854500cbd759ad93ae89c6aa75c00b000931 - libv4lconvert/bayer.c
2cd1b994bb7999d0c08c19b1a2efd11707250852 - libv4lconvert/helper.c
adac14b8826d05ddab33d595a803e92eaf84b797 - libv4lconvert/Makefile.am
6e806290f6e426c881322d362f189fa7b9e2f917 - libv4lconvert/sn9c10x.c
ba44b6ac00a643e6df484f3172022e1b2628c0cc - libv4lconvert/jpgl.c
fa06343de31dcf6d3d5862cc278396272fa838c4 - libv4lconvert/se401.c
4bd081bf25b63f5463d582ef36f77ba5e3711d0d - libv4lconvert/sq905c.c
940250beb5898bf254e7cd1ef9d7950a8db10af6 - libv4lconvert/mr97310a.c
5e177c3a7c157c25c4afcae031e79830237510f6 - libv4lconvert/libv4lconvert.c
1f362080c319355070cf409cfccf28d8c68d024e - libv4lconvert/sn9c2028-decomp.c
703ce22dc98d834490c7aa23ae73b9113e386221 - libv4lconvert/sn9c20x.c
018e503969b2e06a0ea639fc08f03a7476cc15b5 - libv4lconvert/jpeg_memsrcdest.h
fb3344cfa8df97688332ee4fd3b17968437e8ad5 - libv4lconvert/helper-funcs.h
d378cbdd377027e7528af47362a94ccb1ae15da3 - libv4lconvert/libv4lconvert.export
61710972d4e9bfcd00490c563d1bb5bde5480c9e - libv4lconvert/tinyjpeg.c
231571db9f8caa6fdc68138102029127a6b93812 - libv4lconvert/crop.c
d62448a06539ecf6e3daae7faa299b6da8878054 - libv4lconvert/pac207.c
72b65c9f0f3c87dcae86a2afbea65a76f2c6bafd - libv4lconvert/tinyjpeg-internal.h
a016f896e0e9f0cd8af7447b52651ed14c5a5b29 - libv4lconvert/jpeg.c
608a4c341a5df9daea647fbddc415cdaf27b0482 - libv4lconvert/spca561-decompress.c
b03b32eae024bf59b6ceaf6b6d342383cd0b0673 - libv4lconvert/jl2005bcd.c
803c4d0b9364050eda163452b8792e62e221ab6d - libv4lconvert/tinyjpeg.h
2df34af8f9d747fb0e5c7c71954c788aff1c483f - libv4lconvert/stv0680.c
3e8e6c1fb85e3c4b58c4e9b2b0a223ddc793edcb - libv4lconvert/libv4lconvert.pc.in
02aa2e7d12b72fe4ce79cdf4009da61f35091e94 - libv4lconvert/flip.c
05038ef9efab175322a12d3d6620dba6298aa2a9 - libv4lconvert/spca501.c
b2c19c2eac71d39d3fb883cdc159a69c2afa8fd6 - libv4lconvert/ov511-decomp.c
1d9c446cd8a232da87bd79acebc93e018ec72499 - libv4lconvert/jidctflt.c
ed215eca170d07a6838be3796aad933adf89ece2 - libv4lconvert/hm12.c
193e9d2c997e21ce8ca02f25050fb8d2d62b6bfd - libv4lconvert/processing/autogain.c
c894d4a9b9e0f95be9e7bade4f7f734ae0c6996c - libv4lconvert/processing/libv4lprocessing.c
4158e9c3d21cf0a064b99bdf8571df4f3ba6d5bb - libv4lconvert/processing/whitebalance.c
be34baf0d2ce1374c841494ba27ccc352c444e98 - libv4lconvert/processing/gamma.c
b48edcb4036ee5f4e77e9cb49dd1b52b1e7f2427 - libv4lconvert/processing/libv4lprocessing.h
967d27c0e09849338a69dc4b5647d1824f2cd2fb - libv4lconvert/processing/libv4lprocessing-priv.h
9f382ff1f2895b926f3596e0a8ae7637b5e6a2ac - libv4lconvert/control/libv4lcontrol.c
8c523bd3838004a4fa00430a38cbc6dbaa47286f - libv4lconvert/control/libv4lcontrol.h
4ce5e891af7857a3504d1350ef13015997dde62a - libv4lconvert/control/libv4lcontrol-priv.h
bda0c1296aad2b3b178a76f38e26c20ce3b81233 - include/libv4l1.h
a95818658d95c1602f2422e5f1fb54b9ca70536e - include/libv4l2rds.h
2d1932763a064ef1176450b1bb4dd242aa3c77bb - include/libv4lconvert.h
3517bc15e30852ad01ad9966ec7111a16a2263df - include/libv4l2.h
944cd9bc32420e73da3a7d3cb1d0ce707263c9f0 - include/libv4l1-videodev.h
7d9d199f4e6f4ba6f0d669ee5decd74355507137 - include/libv4l-plugin.h
cfeaf0c16571e0c64bce50bcb8a6cd8d8c976187 - include/config.h
d7d4fd219e36edadc17837bff78eb8323e2a115e - include/libdvbv5/libdvb-version.h
33071176eda60242f39927e572ac6b1c1bab32e2 - include/libdvbv5/desc_event_extended.h
29c2cd2554e4f4285ab8709e6eace38046d8ecdc - include/libdvbv5/desc_t2_delivery.h
b42819db457bc6a23324faf259c0db1104741d99 - include/libdvbv5/dvb-scan.h
bae10c2fa28bb522e9fc0bb5e4b0128ab6f90e65 - include/libdvbv5/desc_partial_reception.h
f797ddac8e1adc6b29750f076df0f3a23cf630eb - include/libdvbv5/dvb-v5-std.h
48079dcae511070a8eeb55b004bd8ac06735ecc7 - include/libdvbv5/desc_ca.h
f4eb8b615b7c5a245c76e3f448e6cd848d8cf765 - include/libdvbv5/desc_cable_delivery.h
170a50b570691975e0ff22faffeb0131fc47c7c8 - include/libdvbv5/desc_logical_channel.h
c8f11e89456fc078c607d424e887babe72cd3684 - include/libdvbv5/nit.h
d39a24d0d0a0fbe732881dd2734b10d842d88de9 - include/libdvbv5/header.h
badc03677ddbcfa1d1188ddaaa4c272fccfe4a21 - include/libdvbv5/desc_atsc_service_location.h
d3bad046037cad4a95778555021a1a1a6b3040d9 - include/libdvbv5/cat.h
a614739513f62affb1059df81c064203d9fe2fcd - include/libdvbv5/desc_ca_identifier.h
6d70f699eb912c974dc06a19f9bdcb7dd0c27932 - include/libdvbv5/desc_service.h
0eda1161b34ca39b8528bc53d05fb0fc7d457f80 - include/libdvbv5/desc_frequency_list.h
22f6b663d50de467539201ecfdb363e9252c88bd - include/libdvbv5/atsc_eit.h
1c1292f060664abf6c12273a41b2bf6f704dd19b - include/libdvbv5/desc_sat.h
22de6de5e65530aa1ab38a2373db128e81983a4c - include/libdvbv5/desc_network_name.h
91178a5945e63c81051b57b7b2842139947a3b39 - include/libdvbv5/desc_extension.h
9ca776ad159cf84b2f68101bf279472741829047 - include/libdvbv5/descriptors.h
fa7e8d5e996310e1dd47d5467780d533c8a93ad8 - include/libdvbv5/dvb-dev.h
fed6115825c5b23e1e31ff80aab997f0a7b6c3fc - include/libdvbv5/sdt.h
4b892acd2ce77c060b50cf67f5faf9dc9b76edbb - include/libdvbv5/dvb-frontend.h
8b9f9e00f7bcdce58aef1d8d7234567af82e49b8 - include/libdvbv5/dvb-file.h
b8a077b8e3c6e337223fc37685d217a81df112f1 - include/libdvbv5/dvb-demux.h
01a0afbe1a4f41cf58f9ce47d65b31e3df7c8680 - include/libdvbv5/pat.h
4a49c8b46947be16356d6355aa36d72d7baa946c - include/libdvbv5/vct.h
c83200debc98ff8fa82030d36371a2caa230281a - include/libdvbv5/desc_language.h
21cea15c5d4faff2726f18bdf5b83e2210d472c4 - include/libdvbv5/mpeg_pes.h
825f75350da9fb148acc7d36af513da977105169 - include/libdvbv5/desc_isdbt_delivery.h
8f60bf43907b1eac3c1c2f031cf68a9bdebb3662 - include/libdvbv5/desc_ts_info.h
89cbb75f3e0952e4dfb145fdea776b45e05b7e76 - include/libdvbv5/desc_hierarchy.h
5c80a7ee23d1da2c91f60e79f7292248694b4f65 - include/libdvbv5/crc32.h
93b7b27ccc89e1ad4279eb12560e1dfc3d2ff1eb - include/libdvbv5/dvb-fe.h
aeeb75989de4b2ecafa1b2fc5ed30787999eec1b - include/libdvbv5/mpeg_es.h
dc684983365ffef353993faad0b105bcb87f4218 - include/libdvbv5/desc_event_short.h
5e3be50d1292109d59c80f920ba1b7a4bcbbdf56 - include/libdvbv5/eit.h
f95a0206952db4cce561455accad66a37f9a4104 - include/libdvbv5/mgt.h
88f8c78bbaf22b345e2ccb68e9b787e649dac2c1 - include/libdvbv5/libdvb-version.h.in
74a66644980a66adeba21ecc40ebefa2b4480e25 - include/libdvbv5/pmt.h
7671f125c6f61eef85f55eb314097435b3772431 - include/libdvbv5/dvb-sat.h
26fd40a10548cdb9bd4aafdda4486f9d39fd5c9e - include/libdvbv5/countries.h
65db3beaf2ec19a43a870b2759e6aecb15a95c7b - include/libdvbv5/atsc_header.h
149f7eb3c71b8f65127d3c4f2143080b115697e5 - include/libdvbv5/desc_terrestrial_delivery.h
708af2b77b2c94ee9cf593b31e20471c80ea556b - include/libdvbv5/mpeg_ts.h
ba205468e43ca16edf1ebec59dce9822044c1064 - include/libdvbv5/desc_registration_id.h
e70b24d8d1f3a248735c2d724d3b92c49b7aaba5 - include/libdvbv5/dvb-log.h
2d0557eadd4cff02ab52e26778d35b6c34f09158 - libv4l2/libv4l2-priv.h
487af43db163be6d3604371b9a504c1df2a9bf6c - libv4l2/v4l2-plugin-android.c
0ac38b46fa1659db4c05660205f212389295e7ff - libv4l2/Makefile
8ac3789333a6cd18e7f35d3b66a8a4d0293feb78 - libv4l2/Makefile.dGPU
fdd6e5e27aa8b41d5da77cb3b9be3fc3b8a44763 - libv4l2/libv4l2.export
1d37e5ea9231e7e0eea7d1a02938c6d1ae8ba791 - libv4l2/Makefile.in
51892a60925c37c865fe6eb9c923a552df180ebf - libv4l2/v4l2-plugin.c
d4c7daee644a35244ac8a5e1009a3aeb1d4fd3da - libv4l2/Makefile.am
87856c7113d150dceb254b5d548f942e7fcaf8f1 - libv4l2/libv4l2.c
d11ec5b8ce8390a72fd61457d7b8667378311191 - libv4l2/log.c
cbcee4426c19c168c6f49d04af3a0b2e30c0b681 - libv4l2/libv4l2.pc.in
55bb16d05817a3ecf076174175b2ca5b56e729d8 - libv4l2/v4l2convert.c

Change-Id: I4dd528ac6ac1e89b1e1ebadc7fdaf45cea9dcc98
This commit is contained in:
svcmobrel-release
2025-08-25 10:24:17 -07:00
parent e003da6fcd
commit 1f9ef4be87
117 changed files with 35073 additions and 0 deletions

239
include/config.h Normal file
View File

@@ -0,0 +1,239 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#define ENABLE_NLS 1
/* alsa library is present */
#define HAVE_ALSA 1
/* glibc has functions to provide stack backtrace */
#define HAVE_BACKTRACE 1
/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the
CoreFoundation framework. */
/* #undef HAVE_CFLOCALECOPYCURRENT */
/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in
the CoreFoundation framework. */
/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */
/* Define if the GNU dcgettext() function is already present or preinstalled.
*/
#define HAVE_DCGETTEXT 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Usage of DVBv5 remote enabled */
#define HAVE_DVBV5_REMOTE 1
/* Define to 1 if you have the `fork' function. */
#define HAVE_FORK 1
/* Define if the GNU gettext() function is already present or preinstalled. */
#define HAVE_GETTEXT 1
/* Define if you have the iconv() function and it works. */
#define HAVE_ICONV 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* whether we use libjpeg */
//#define HAVE_JPEG 0
/* Define to 1 if you have the `klogctl' function. */
#define HAVE_KLOGCTL 1
/* Use libudev */
#define HAVE_LIBUDEV /**/
/* whether to use libv4lconvert helpers */
#define HAVE_LIBV4LCONVERT_HELPERS 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Have ioctl with POSIX signature */
/* #undef HAVE_POSIX_IOCTL */
/* Define if you have POSIX threads libraries and header files. */
#define HAVE_PTHREAD 1
/* Have PTHREAD_PRIO_INHERIT. */
#define HAVE_PTHREAD_PRIO_INHERIT 1
/* qt has opengl support */
#define HAVE_QTGL 1
/* Define to 1 if you have the `secure_getenv' function. */
#define HAVE_SECURE_GETENV 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/klog.h> header file. */
#define HAVE_SYS_KLOG_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* V4L plugin support enabled */
#define HAVE_V4L_PLUGINS 1
/* Define to 1 or 0, depending whether the compiler supports simple visibility
declarations. */
#define HAVE_VISIBILITY 1
/* Define to 1 if you have the `__secure_getenv' function. */
/* #undef HAVE___SECURE_GETENV */
/* Define as const if the declaration of iconv() needs const. */
#define ICONV_CONST
/* ir-keytable preinstalled tables directory */
#define IR_KEYTABLE_SYSTEM_DIR "/lib/udev/rc_keymaps"
/* ir-keytable user defined tables directory */
#define IR_KEYTABLE_USER_DIR "/usr/local/etc/rc_keymaps"
/* libdvbv5 domain */
#define LIBDVBV5_DOMAIN "libdvbv5"
/* libv4l1 private lib directory */
#define LIBV4L1_PRIV_DIR "/usr/local/lib/libv4l"
/* libv4l2 plugin directory */
#ifdef LIBV4L2_PLUGIN_DIR_PATH_X86
#define LIBV4L2_PLUGIN_DIR "/usr/lib/x86_64-linux-gnu/libv4l/plugins"
#else
#define LIBV4L2_PLUGIN_DIR "/usr/lib/aarch64-linux-gnu/libv4l/plugins/nv"
#endif
/* libv4l2 private lib directory */
#define LIBV4L2_PRIV_DIR "/usr/local/lib/libv4l"
/* libv4lconvert private lib directory */
#define LIBV4LCONVERT_PRIV_DIR "/usr/local/lib/libv4l"
/* locale directory */
#define LOCALEDIR "/usr/local/share/locale"
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"
/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
*/
/* #undef MAJOR_IN_MKDEV */
/* Define to 1 if `major', `minor', and `makedev' are declared in
<sysmacros.h>. */
/* #undef MAJOR_IN_SYSMACROS */
/* Name of package */
#define PACKAGE "v4l-utils"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME "v4l-utils"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "v4l-utils 1.14.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "v4l-utils"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.14.2"
/* Define to the type that is the result of default argument promotions of
type mode_t. */
#define PROMOTED_MODE_T mode_t
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
/* #undef PTHREAD_CREATE_JOINABLE */
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif
/* v4l-utils version string */
#define V4L_UTILS_VERSION "1.14.2"
/* Version number of package */
#define VERSION "1.14.2"
/* Define to 1 if on MINIX. */
/* #undef _MINIX */
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
/* #undef _POSIX_1_SOURCE */
/* Define to 1 if you need to in order for `stat' and other things to work. */
/* #undef _POSIX_SOURCE */
/* Define to `int' if <sys/types.h> does not define. */
/* #undef mode_t */

221
include/libdvbv5/atsc_eit.h Normal file
View File

@@ -0,0 +1,221 @@
/*
* Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file atsc_eit.h
* @ingroup dvb_table
* @brief Provides the table parser for the ATSC EIT (Event Information Table)
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The table described herein is defined at:
* - ATSC A/65:2009
*
* @see
* http://www.etherguidesystems.com/help/sdos/atsc/syntax/tablesections/eitks.aspx
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _ATSC_EIT_H
#define _ATSC_EIT_H
#include <stdint.h>
#include <unistd.h> /* ssize_t */
#include <time.h>
#include <libdvbv5/atsc_header.h>
/**
* @def ATSC_TABLE_EIT
* @brief ATSC EIT table ID
* @ingroup dvb_table
*/
#define ATSC_TABLE_EIT 0xCB
/**
* @struct atsc_table_eit_event
* @brief ATSC EIT event table
* @ingroup dvb_table
*
* @param event_id an uniquelly (inside a service ID) event ID
* @param title_length title length. Zero means no title
* @param duration duration in seconds
* @param etm Extended Text Message location
* @param descriptor pointer to struct dvb_desc
* @param next pointer to struct atsc_table_eit_event
* @param start event start (in struct tm format)
* @param source_id source id (obtained from ATSC header)
*
* This structure is used to store the original ATSC EIT event table,
* converting the integer fields to the CPU endianness, and converting the
* timestamps to a way that it is better handled on Linux.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*
* Everything after atsc_table_eit_event::descriptor (including it) won't
* be bit-mapped to the data parsed from the MPEG TS. So, metadata are added
* there.
*/
struct atsc_table_eit_event {
union {
uint16_t bitfield;
struct {
uint16_t event_id:14;
uint16_t one:2;
} __attribute__((packed));
} __attribute__((packed));
uint32_t start_time;
union {
uint32_t bitfield2;
struct {
uint32_t title_length:8;
uint32_t duration:20;
uint32_t etm:2;
uint32_t one2:2;
uint32_t :2;
} __attribute__((packed));
} __attribute__((packed));
struct dvb_desc *descriptor;
struct atsc_table_eit_event *next;
struct tm start;
uint16_t source_id;
} __attribute__((packed));
/**
* @union atsc_table_eit_desc_length
* @brief ATSC EIT descriptor length
* @ingroup dvb_table
*
* @param desc_length descriptor length
*
* This structure is used to store the original ATSC EIT event table,
* converting the integer fields to the CPU endianness, and converting the
* timestamps to a way that it is better handled on Linux.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*/
union atsc_table_eit_desc_length {
uint16_t bitfield;
struct {
uint16_t desc_length:12;
uint16_t reserved:4;
} __attribute__((packed));
} __attribute__((packed));
/**
* @struct atsc_table_eit
* @brief ATSC EIT table
* @ingroup dvb_table
*
* @param header struct dvb_table_header content
* @param protocol_version protocol version
* @param events events
* @param event pointer to struct atsc_table_eit_event
*
* This structure is used to store the original ATSC EIT table,
* converting the integer fields to the CPU endianness.
*
* Everything after atsc_table_eit::event (including it) won't
* be bit-mapped to the data parsed from the MPEG TS. So, metadata are added
* there.
*/
struct atsc_table_eit {
struct dvb_table_header header;
uint8_t protocol_version;
uint8_t events;
struct atsc_table_eit_event *event;
} __attribute__((packed));
/**
* @brief Macro used to find event on an ATSC EIT table
* @ingroup dvb_table
*
* @param _event event to seek
* @param _eit pointer to struct atsc_table_eit_event
*/
#define atsc_eit_event_foreach(_event, _eit) \
if (_eit && _eit->event) \
for( struct atsc_table_eit_event *_event = _eit->event; _event; _event = _event->next ) \
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses ATSC EIT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the EIT raw data
* @param buflen length of the buffer
* @param table pointer to struct atsc_table_eit to be allocated and filled
*
* This function allocates an ATSC EIT table and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
ssize_t atsc_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
ssize_t buflen, struct atsc_table_eit **table);
/**
* @brief Frees all data allocated by the ATSC EIT table parser
* @ingroup dvb_table
*
* @param table pointer to struct atsc_table_eit to be freed
*/
void atsc_table_eit_free(struct atsc_table_eit *table);
/**
* @brief Prints the content of the ATSC EIT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param table pointer to struct atsc_table_eit
*/
void atsc_table_eit_print(struct dvb_v5_fe_parms *parms,
struct atsc_table_eit *table);
/**
* @brief Converts an ATSC EIT formatted timestamp into struct tm
* @ingroup ancillary
*
* @param start_time event on ATSC EIT time format
* @param tm pointer to struct tm where the converted timestamp will
* be stored.
*/
void atsc_time(const uint32_t start_time, struct tm *tm);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#ifndef _ATSC_HEADER_H
#define _ATSC_HEADER_H
/**
* @file atsc_header.h
* @ingroup dvb_table
* @brief Provides some common ATSC stuff
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Andre Roth
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#include <stdint.h>
#include <unistd.h> /* ssize_t */
#include <libdvbv5/header.h>
/**
* @def ATSC_BASE_PID
* @brief ATSC PID for the Program and System Information Protocol
* @ingroup dvb_table
*/
#define ATSC_BASE_PID 0x1FFB
#ifndef _DOXYGEN
/* Deprecated, as it causes troubles with doxygen */
#define ATSC_HEADER() \
struct dvb_table_header header; \
uint8_t protocol_version; \
#define ATSC_TABLE_HEADER_PRINT(_parms, _table) \
dvb_table_header_print(_parms, &_table->header); \
dvb_loginfo("| protocol_version %d", _table->protocol_version); \
#endif /* _DOXYGEN */
#endif /* _ATSC_HEADER_H */

106
include/libdvbv5/cat.h Normal file
View File

@@ -0,0 +1,106 @@
/*
* Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file cat.h
* @ingroup dvb_table
* @brief Provides the table parser for the CAT (Conditional Access Table)
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Andre Roth
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _CAT_H
#define _CAT_H
#include <stdint.h>
#include <unistd.h> /* ssize_t */
#include <libdvbv5/header.h>
/**
* @def DVB_TABLE_CAT
* @brief ATSC CAT table ID
* @ingroup dvb_table
* @def DVB_TABLE_CAT_PID
* @brief ATSC PID table ID
* @ingroup dvb_table
*/
#define DVB_TABLE_CAT 0x01
#define DVB_TABLE_CAT_PID 0x0001
/**
* @struct dvb_table_cat
* @brief ATSC CAT table
*
* @param header struct dvb_table_header content
* @param descriptor pointer to struct dvb_desc
*/
struct dvb_table_cat {
struct dvb_table_header header;
struct dvb_desc *descriptor;
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses CAT table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the CAT raw data
* @param buflen length of the buffer
* @param table pointer to struct dvb_table_cat to be allocated and filled
*
* This function allocates an CAT table and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
ssize_t dvb_table_cat_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
ssize_t buflen, struct dvb_table_cat **table);
/**
* @brief Frees all data allocated by the CAT table parser
*
* @param table pointer to struct dvb_table_cat to be freed
*/
void dvb_table_cat_free(struct dvb_table_cat *table);
/**
* @brief Prints the content of the CAT table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param table pointer to struct dvb_table_cat
*/
void dvb_table_cat_print(struct dvb_v5_fe_parms *parms,
struct dvb_table_cat *table);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,869 @@
/*
* Copyright (C) 2006, 2007, 2008, 2009 Winfried Koehler
* Copyright (C) 2014 Akihiro Tsukada
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. if not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* @file countries.h
* @ingroup ancillary
* @brief Provides ancillary code to convert ISO 3166-1 country codes
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Winfried Koehler
* @author Akihiro Tsukada
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _COUNTRIES_H_
#define _COUNTRIES_H_
#ifdef __cplusplus
extern "C" {
#endif
/**
* @enum dvb_country_t
* @brief ISO-3166-1 alpha-2 country code
* @ingroup ancillary
*
* @var COUNTRY_UNKNOWN
* @brief (Unknown Country)
* @var AD
* @brief Andorra
* @var AE
* @brief United Arab Emirates
* @var AF
* @brief Afghanistan
* @var AG
* @brief Antigua and Barbuda
* @var AI
* @brief Anguilla
* @var AL
* @brief Albania
* @var AM
* @brief Armenia
* @var AO
* @brief Angola
* @var AQ
* @brief Antarctica
* @var AR
* @brief Argentina
* @var AS
* @brief American Samoa
* @var AT
* @brief Austria
* @var AU
* @brief Australia
* @var AW
* @brief Aruba
* @var AX
* @brief Aland Islands
* @var AZ
* @brief Azerbaijan
* @var BA
* @brief Bosnia and Herzegovina
* @var BB
* @brief Barbados
* @var BD
* @brief Bangladesh
* @var BE
* @brief Belgium
* @var BF
* @brief Burkina Faso
* @var BG
* @brief Bulgaria
* @var BH
* @brief Bahrain
* @var BI
* @brief Burundi
* @var BJ
* @brief Benin
* @var BL
* @brief Saint Barthelemy
* @var BM
* @brief Bermuda
* @var BN
* @brief Brunei Darussalam
* @var BO
* @brief Plurinational State of Bolivia
* @var BQ
* @brief Bonaire, Saint Eustatius and Saba
* @var BR
* @brief Brazil
* @var BS
* @brief Bahamas
* @var BT
* @brief Bhutan
* @var BV
* @brief Bouvet Island
* @var BW
* @brief Botswana
* @var BY
* @brief Belarus
* @var BZ
* @brief Belize
* @var CA
* @brief Canada
* @var CC
* @brief Cocos (Keeling) Islands
* @var CD
* @brief The Democratic Republic of the Congo
* @var CF
* @brief Central African Republic
* @var CG
* @brief Congo
* @var CH
* @brief Switzerland
* @var CI
* @brief Cote d'Ivoire
* @var CK
* @brief Cook Islands
* @var CL
* @brief Chile
* @var CM
* @brief Cameroon
* @var CN
* @brief China
* @var CO
* @brief Colombia
* @var CR
* @brief Costa Rica
* @var CU
* @brief Cuba
* @var CV
* @brief Cape Verde
* @var CW
* @brief Curacao
* @var CX
* @brief Christmas Island
* @var CY
* @brief Cyprus
* @var CZ
* @brief Czech Republic
* @var DE
* @brief Germany
* @var DJ
* @brief Djibouti
* @var DK
* @brief Denmark
* @var DM
* @brief Dominica
* @var DO
* @brief Dominican Republic
* @var DZ
* @brief Algeria
* @var EC
* @brief Ecuador
* @var EE
* @brief Estonia
* @var EG
* @brief Egypt
* @var EH
* @brief Western Sahara
* @var ER
* @brief Eritrea
* @var ES
* @brief Spain
* @var ET
* @brief Ethiopia
* @var FI
* @brief Finland
* @var FJ
* @brief Fiji
* @var FK
* @brief Falkland Islands (Malvinas)
* @var FM
* @brief Federated States of Micronesia
* @var FO
* @brief Faroe Islands
* @var FR
* @brief France
* @var GA
* @brief Gabon
* @var GB
* @brief United Kingdom
* @var GD
* @brief Grenada
* @var GE
* @brief Georgia
* @var GF
* @brief French Guiana
* @var GG
* @brief Guernsey
* @var GH
* @brief Ghana
* @var GI
* @brief Gibraltar
* @var GL
* @brief Greenland
* @var GM
* @brief Gambia
* @var GN
* @brief Guinea
* @var GP
* @brief Guadeloupe
* @var GQ
* @brief Equatorial Guinea
* @var GR
* @brief Greece
* @var GS
* @brief South Georgia and the South Sandwich Islands
* @var GT
* @brief Guatemala
* @var GU
* @brief Guam
* @var GW
* @brief Guinea-Bissau
* @var GY
* @brief Guyana
* @var HK
* @brief Hong Kong
* @var HM
* @brief Heard Island and McDonald Islands
* @var HN
* @brief Honduras
* @var HR
* @brief Croatia
* @var HT
* @brief Haiti
* @var HU
* @brief Hungary
* @var ID
* @brief Indonesia
* @var IE
* @brief Ireland
* @var IL
* @brief Israel
* @var IM
* @brief Isle of Man
* @var IN
* @brief India
* @var IO
* @brief British Indian Ocean Territory
* @var IQ
* @brief Iraq
* @var IR
* @brief Islamic Republic of Iran
* @var IS
* @brief Iceland
* @var IT
* @brief Italy
* @var JE
* @brief Jersey
* @var JM
* @brief Jamaica
* @var JO
* @brief Jordan
* @var JP
* @brief Japan
* @var KE
* @brief Kenya
* @var KG
* @brief Kyrgyzstan
* @var KH
* @brief Cambodia
* @var KI
* @brief Kiribati
* @var KM
* @brief Comoros
* @var KN
* @brief Saint Kitts and Nevis
* @var KP
* @brief Democratic People's Republic of Korea
* @var KR
* @brief Republic of Korea
* @var KW
* @brief Kuwait
* @var KY
* @brief Cayman Islands
* @var KZ
* @brief Kazakhstan
* @var LA
* @brief Lao People's Democratic Republic
* @var LB
* @brief Lebanon
* @var LC
* @brief Saint Lucia
* @var LI
* @brief Liechtenstein
* @var LK
* @brief Sri Lanka
* @var LR
* @brief Liberia
* @var LS
* @brief Lesotho
* @var LT
* @brief Lithuania
* @var LU
* @brief Luxembourg
* @var LV
* @brief Latvia
* @var LY
* @brief Libyan Arab Jamahiriya
* @var MA
* @brief Morocco
* @var MC
* @brief Monaco
* @var MD
* @brief Republic of Moldova
* @var ME
* @brief Montenegro
* @var MF
* @brief Saint Martin (French part)
* @var MG
* @brief Madagascar
* @var MH
* @brief Marshall Islands
* @var MK
* @brief The Former Yugoslav Republic of Macedonia
* @var ML
* @brief Mali
* @var MM
* @brief Myanmar
* @var MN
* @brief Mongolia
* @var MO
* @brief Macao
* @var MP
* @brief Northern Mariana Islands
* @var MQ
* @brief Martinique
* @var MR
* @brief Mauritania
* @var MS
* @brief Montserrat
* @var MT
* @brief Malta
* @var MU
* @brief Mauritius
* @var MV
* @brief Maldives
* @var MW
* @brief Malawi
* @var MX
* @brief Mexico
* @var MY
* @brief Malaysia
* @var MZ
* @brief Mozambique
* @var NA
* @brief Namibia
* @var NC
* @brief New Caledonia
* @var NE
* @brief Niger
* @var NF
* @brief Norfolk Island
* @var NG
* @brief Nigeria
* @var NI
* @brief Nicaragua
* @var NL
* @brief Netherlands
* @var NO
* @brief Norway
* @var NP
* @brief Nepal
* @var NR
* @brief Nauru
* @var NU
* @brief Niue
* @var NZ
* @brief New Zealand
* @var OM
* @brief Oman
* @var PA
* @brief Panama
* @var PE
* @brief Peru
* @var PF
* @brief French Polynesia
* @var PG
* @brief Papua New Guinea
* @var PH
* @brief Philippines
* @var PK
* @brief Pakistan
* @var PL
* @brief Poland
* @var PM
* @brief Saint Pierre and Miquelon
* @var PN
* @brief Pitcairn
* @var PR
* @brief Puerto Rico
* @var PS
* @brief Occupied Palestinian Territory
* @var PT
* @brief Portugal
* @var PW
* @brief Palau
* @var PY
* @brief Paraguay
* @var QA
* @brief Qatar
* @var RE
* @brief Reunion
* @var RO
* @brief Romania
* @var RS
* @brief Serbia
* @var RU
* @brief Russian Federation
* @var RW
* @brief Rwanda
* @var SA
* @brief Saudi Arabia
* @var SB
* @brief Solomon Islands
* @var SC
* @brief Seychelles
* @var SD
* @brief Sudan
* @var SE
* @brief Sweden
* @var SG
* @brief Singapore
* @var SH
* @brief Saint Helena, Ascension and Tristan da Cunha
* @var SI
* @brief Slovenia
* @var SJ
* @brief Svalbard and Jan Mayen
* @var SK
* @brief Slovakia
* @var SL
* @brief Sierra Leone
* @var SM
* @brief San Marino
* @var SN
* @brief Senegal
* @var SO
* @brief Somalia
* @var SR
* @brief Suriname
* @var SS
* @brief South Sudan
* @var ST
* @brief Sao Tome and Principe
* @var SV
* @brief El Salvador
* @var SX
* @brief Sint Maarten (Dutch part)
* @var SY
* @brief Syrian Arab Republic
* @var SZ
* @brief Swaziland
* @var TC
* @brief Turks and Caicos Islands
* @var TD
* @brief Chad
* @var TF
* @brief French Southern Territories
* @var TG
* @brief Togo
* @var TH
* @brief Thailand
* @var TJ
* @brief Tajikistan
* @var TK
* @brief Tokelau
* @var TL
* @brief Timor-Leste
* @var TM
* @brief Turkmenistan
* @var TN
* @brief Tunisia
* @var TO
* @brief Tonga
* @var TR
* @brief Turkey
* @var TT
* @brief Trinidad and Tobago
* @var TV
* @brief Tuvalu
* @var TW
* @brief Taiwan, Province of China
* @var TZ
* @brief United Republic of Tanzania
* @var UA
* @brief Ukraine
* @var UG
* @brief Uganda
* @var UM
* @brief United States Minor Outlying Islands
* @var US
* @brief United States
* @var UY
* @brief Uruguay
* @var UZ
* @brief Uzbekistan
* @var VA
* @brief Holy See (Vatican City State)
* @var VC
* @brief Saint Vincent and The Grenadines
* @var VE
* @brief Bolivarian Republic of Venezuela
* @var VG
* @brief British Virgin Islands
* @var VI
* @brief U.S. Virgin Islands
* @var VN
* @brief Viet Nam
* @var VU
* @brief Vanuatu
* @var WF
* @brief Wallis and Futuna
* @var WS
* @brief Samoa
* @var YE
* @brief Yemen
* @var YT
* @brief Mayotte
* @var ZA
* @brief South Africa
* @var ZM
* @brief Zambia
* @var ZW
* @brief Zimbabwe
*/
enum dvb_country_t {
COUNTRY_UNKNOWN,
AD,
AE,
AF,
AG,
AI,
AL,
AM,
AO,
AQ,
AR,
AS,
AT,
AU,
AW,
AX,
AZ,
BA,
BB,
BD,
BE,
BF,
BG,
BH,
BI,
BJ,
BL,
BM,
BN,
BO,
BQ,
BR,
BS,
BT,
BV,
BW,
BY,
BZ,
CA,
CC,
CD,
CF,
CG,
CH,
CI,
CK,
CL,
CM,
CN,
CO,
CR,
CU,
CV,
CW,
CX,
CY,
CZ,
DE,
DJ,
DK,
DM,
DO,
DZ,
EC,
EE,
EG,
EH,
ER,
ES,
ET,
FI,
FJ,
FK,
FM,
FO,
FR,
GA,
GB,
GD,
GE,
GF,
GG,
GH,
GI,
GL,
GM,
GN,
GP,
GQ,
GR,
GS,
GT,
GU,
GW,
GY,
HK,
HM,
HN,
HR,
HT,
HU,
ID,
IE,
IL,
IM,
IN,
IO,
IQ,
IR,
IS,
IT,
JE,
JM,
JO,
JP,
KE,
KG,
KH,
KI,
KM,
KN,
KP,
KR,
KW,
KY,
KZ,
LA,
LB,
LC,
LI,
LK,
LR,
LS,
LT,
LU,
LV,
LY,
MA,
MC,
MD,
ME,
MF,
MG,
MH,
MK,
ML,
MM,
MN,
MO,
MP,
MQ,
MR,
MS,
MT,
MU,
MV,
MW,
MX,
MY,
MZ,
NA,
NC,
NE,
NF,
NG,
NI,
NL,
NO,
NP,
NR,
NU,
NZ,
OM,
PA,
PE,
PF,
PG,
PH,
PK,
PL,
PM,
PN,
PR,
PS,
PT,
PW,
PY,
QA,
RE,
RO,
RS,
RU,
RW,
SA,
SB,
SC,
SD,
SE,
SG,
SH,
SI,
SJ,
SK,
SL,
SM,
SN,
SO,
SR,
SS,
ST,
SV,
SX,
SY,
SZ,
TC,
TD,
TF,
TG,
TH,
TJ,
TK,
TL,
TM,
TN,
TO,
TR,
TT,
TV,
TW,
TZ,
UA,
UG,
UM,
US,
UY,
UZ,
VA,
VC,
VE,
VG,
VI,
VN,
VU,
WF,
WS,
YE,
YT,
ZA,
ZM,
ZW,
};
/**
* @brief Converts an Unix-like 2-letter Country code into enum dvb_country_t
* @ingroup ancillary
*
* @param name two-letter Country code.
*
* @return It returns the corresponding enum dvb_country_t ID. If not found,
* returns COUNTRY_UNKNOWN.
*/
enum dvb_country_t dvb_country_a2_to_id(const char *name);
/**
* @brief Converts a 3-letter Country code as used by MPEG-TS tables into
* enum dvb_country_t
* @ingroup ancillary
*
* @param name three-letter Country code.
*
* @return It returns the corresponding enum dvb_country_t ID. If not found,
* returns COUNTRY_UNKNOWN.
*/
enum dvb_country_t dvb_country_a3_to_id(const char *name);
/**
* @brief Converts an enum dvb_country_t into Unix-like 2-letter Country code
* @ingroup ancillary
*
* @param id enum dvb_country_t ID.
*
* @return It returns the 2-letter country code string that corresponts to the
* Country. If not found, returns NULL.
*/
const char *dvb_country_to_2letters(int id);
/**
* @brief Converts an enum dvb_country_t into a 3-letter Country code
* as used by MPEG-TS tables
* @ingroup ancillary
*
* @param id enum dvb_country_t ID.
*
* @return It returns the 3-letter country code string that corresponts to the
* Country. If not found, returns NULL.
*/
const char *dvb_country_to_3letters(int id);
/**
* @brief Converts an enum dvb_country_t into a Country name
* as used by MPEG-TS tables
* @ingroup ancillary
*
* @param id enum dvb_country_t ID.
*
* @return It returns a string with the Country name that corresponts to the
* country. If not found, returns NULL.
*/
const char *dvb_country_to_name(int id);
/**
* @brief Guess the country code from the Unix environment variables
* @ingroup ancillary
*
* @return It returns the corresponding enum dvb_country_t ID. If not found,
* returns COUNTRY_UNKNOWN.
*/
enum dvb_country_t dvb_guess_user_country(void);
#ifdef __cplusplus
}
#endif
#endif

58
include/libdvbv5/crc32.h Normal file
View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 2011-2012 - Mauro Carvalho Chehab
* Copyright (c) 2012-2014 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file crc32.h
* @ingroup ancillary
* @brief Provides ancillary code to calculate DVB crc32 checksum
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _CRC32_H
#define _CRC32_H
#include <stdint.h>
#include <unistd.h> /* size_t */
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Calculates the crc-32 as defined at the MPEG-TS specs
* @ingroup ancillary
*
* @param data Pointer to the buffer to be checked
* @param datalen Length of the buffer
* @param crc Initial value for the crc checksum. To calculate the
* checksum of the entire packet at once, use 0xFFFFFFFF
*/
uint32_t dvb_crc32(uint8_t *data, size_t datalen, uint32_t crc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,140 @@
/*
* Copyright (c) 2013-2014 - Mauro Carvalho Chehab <mchehab@kernel.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#ifndef _ATSC_SERVICE_LOCATION_H
#define _ATSC_SERVICE_LOCATION_H
#include <libdvbv5/descriptors.h>
/**
* @file desc_atsc_service_location.h
* @ingroup descriptors
* @brief Provides the descriptors for ATSC service location
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ATSC A/53
*
* @see http://www.etherguidesystems.com/help/sdos/atsc/semantics/descriptors/ServiceLocation.aspx
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
/**
* @struct atsc_desc_service_location_elementary
* @ingroup descriptors
* @brief service location elementary descriptors
*
* @param stream_type stream type
* @param elementary_pid elementary pid
* @param ISO_639_language_code ISO 639 language code
*/
struct atsc_desc_service_location_elementary {
uint8_t stream_type;
union {
uint16_t bitfield;
struct {
uint16_t elementary_pid:13;
uint16_t reserved:3;
} __attribute__((packed));
} __attribute__((packed));
unsigned char ISO_639_language_code[3];
} __attribute__((packed));
/**
* @struct atsc_desc_service_location
* @ingroup descriptors
* @brief Describes the elementary streams inside a PAT table for ATSC
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param elementary pointer to struct atsc_desc_service_location_elementary
* @param pcr_pid PCR pid
* @param number_elements number elements
*/
struct atsc_desc_service_location {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
struct atsc_desc_service_location_elementary *elementary;
union {
uint16_t bitfield;
struct {
uint16_t pcr_pid:13;
uint16_t reserved:3;
} __attribute__((packed));
} __attribute__((packed));
uint8_t number_elements;
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the service location descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function allocates a the descriptor and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int atsc_desc_service_location_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf,
struct dvb_desc *desc);
/**
* @brief Prints the content of the service location descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void atsc_desc_service_location_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Frees all data allocated by the service location descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void atsc_desc_service_location_free(struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

125
include/libdvbv5/desc_ca.h Normal file
View File

@@ -0,0 +1,125 @@
/*
* Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Described at ETSI EN 300 468 V1.11.1 (2010-04)
*/
/**
* @file desc_ca.h
* @ingroup descriptors
* @brief Provides the descriptors for Conditional Access
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Andre Roth
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ETSI EN 300 468 V1.11.1 (2010-04)
*
* @see http://www.etherguidesystems.com/help/sdos/mpeg/semantics/mpeg-2/descriptors/CA_descriptor.aspx
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _CA_H
#define _CA_H
#include <libdvbv5/descriptors.h>
/**
* @struct dvb_desc_ca
* @ingroup descriptors
* @brief Contains the private data for Conditional Access
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param ca_id Conditional Access ID
* @param ca_pid Conditional Access ID
* @param privdata pointer to private data buffer
* @param privdata_len length of the private data
*/
struct dvb_desc_ca {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
uint16_t ca_id;
union {
uint16_t bitfield1;
struct {
uint16_t ca_pid:13;
uint16_t reserved:3;
} __attribute__((packed));
} __attribute__((packed));
uint8_t *privdata;
uint8_t privdata_len;
} __attribute__((packed));
struct dvb_v5_fe_parms;
/** @brief initial descriptor field at dvb_desc_ca struct */
#define dvb_desc_ca_field_first ca_id
/** @brief last descriptor field at dvb_desc_ca struct */
#define dvb_desc_ca_field_last privdata
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the CA descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function allocates a the descriptor and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_ca_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
struct dvb_desc *desc);
/**
* @brief Prints the content of the CA descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_ca_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Frees all data allocated by the CA descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void dvb_desc_ca_free(struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,114 @@
/*
* Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Described at ETSI EN 300 468 V1.11.1 (2010-04)
*/
/**
* @file desc_ca_identifier.h
* @ingroup descriptors
* @brief Provides the descriptors for the Conditional Access identifier
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Andre Roth
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ETSI EN 300 468 V1.11.1 (2010-04)
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _CA_IDENTIFIER_H
#define _CA_IDENTIFIER_H
#include <libdvbv5/descriptors.h>
/**
* @struct dvb_desc_ca_identifier
* @ingroup descriptors
* @brief Indicates if a particular bouquet, service or event is associated
* with a CA system
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param caid_count Number of CA IDs
* @param caids CA Identifier IDs
*/
struct dvb_desc_ca_identifier {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
uint8_t caid_count;
uint16_t *caids;
} __attribute__((packed));
struct dvb_v5_fe_parms;
/** @brief initial descriptor field at dvb_desc_ca_identifier struct */
#define dvb_desc_ca_identifier_field_first ca_id
/** @brief last descriptor field at dvb_desc_ca_identifier struct */
#define dvb_desc_ca_identifier_field_last privdata
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the CA identifier descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function allocates a the descriptor and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_ca_identifier_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the CA identifier descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_ca_identifier_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Frees all data allocated by the CA identifier descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void dvb_desc_ca_identifier_free(struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,132 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Described at ETSI EN 300 468 V1.11.1 (2010-04)
*/
/**
* @file desc_cable_delivery.h
* @ingroup descriptors
* @brief Provides the descriptors for the cable delivery system descriptor
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ETSI EN 300 468 V1.11.1 (2010-04)
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _CABLE_DELIVERY_H
#define _CABLE_DELIVERY_H
#include <libdvbv5/descriptors.h>
/**
* @struct dvb_desc_cable_delivery
* @ingroup descriptors
* @brief Structure containing the cable delivery system descriptor
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param frequency frequency, converted to Hz.
* @param fec_outer FEC outer (typically, Viterbi)
* @param modulation modulation
* @param fec_inner FEC inner (convolutional code)
* @param symbol_rate symbol rate, converted to symbols/sec (bauds)
*/
struct dvb_desc_cable_delivery {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
uint32_t frequency;
union {
uint16_t bitfield1;
struct {
uint16_t fec_outer:4;
uint16_t reserved_future_use:12;
} __attribute__((packed));
} __attribute__((packed));
uint8_t modulation;
union {
uint32_t bitfield2;
struct {
uint32_t fec_inner:4;
uint32_t symbol_rate:28;
} __attribute__((packed));
} __attribute__((packed));
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the service location descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function initializes and makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* Currently, no memory is allocated internally.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_cable_delivery_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the service location descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_cable_delivery_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief converts from the descriptor's modulation into enum fe_modulation,
* as defined by DVBv5 API.
*/
extern const unsigned dvbc_modulation_table[];
/**
* @brief converts from the descriptor's FEC into enum fe_code_rate,
* as defined by DVBv5 API.
*/
extern const unsigned dvbc_fec_table[];
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,134 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file desc_event_extended.h
* @ingroup descriptors
* @brief Provides the descriptors for the extended event descriptor
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ETSI EN 300 468 V1.11.1
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _DESC_EVENT_EXTENDED_H
#define _DESC_EVENT_EXTENDED_H
#include <libdvbv5/descriptors.h>
struct dvb_desc_event_extended_item {
char *description;
char *description_emph;
char *item;
char *item_emph;
};
/**
* @struct dvb_desc_event_extended
* @ingroup descriptors
* @brief Structure containing the extended event descriptor
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param id descriptor number
* @param last_id last descriptor number
* @param language ISO 639 language code
* @param text text string
* @param text_emph text emphasis string
*
* @details
* The emphasis text is the one that uses asterisks. For example, in the text:
* "the quick *fox* jumps over the lazy table" the emphasis would be "fox".
*/
struct dvb_desc_event_extended {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
union {
struct {
uint8_t last_id:4;
uint8_t id:4;
} __attribute__((packed));
uint8_t ids;
} __attribute__((packed));
unsigned char language[4];
char *text;
char *text_emph;
struct dvb_desc_event_extended_item *items;
int num_items;
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the extended event descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function allocates a the descriptor and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_event_extended_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the extended event descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_event_extended_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Frees all data allocated by the extended event descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void dvb_desc_event_extended_free(struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,118 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file desc_event_short.h
* @ingroup descriptors
* @brief Provides the descriptors for the short event descriptor
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ETSI EN 300 468 V1.11.1
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _DESC_EVENT_SHORT_H
#define _DESC_EVENT_SHORT_H
#include <libdvbv5/descriptors.h>
/**
* @struct dvb_desc_event_short
* @ingroup descriptors
* @brief Structure containing the short event descriptor
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param language ISO 639 language code
* @param name event name string
* @param name_emph event name emphasis string
* @param text event text string
* @param text_emph event text emphasis string
*
* @details
* The emphasis text is the one that uses asterisks. For example, in the text:
* "the quick *fox* jumps over the lazy table" the emphasis would be "fox".
*/
struct dvb_desc_event_short {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
unsigned char language[4];
char *name;
char *name_emph;
char *text;
char *text_emph;
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the short event descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function allocates a the descriptor and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_event_short_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the short event descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_event_short_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Frees all data allocated by the short event descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void dvb_desc_event_short_free(struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,224 @@
/*
* Copyright (c) 2013-2014 - Mauro Carvalho Chehab <mchehab@kernel.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file desc_extension.h
* @ingroup descriptors
* @brief Provides the descriptors for the extension descriptor.
* The extension descriptor is used to extend the 8-bit namespace
* of the descriptor_tag field.
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* @par Relevant specs
* The descriptor described herein is defined at:
*
* @see
* - ETSI EN 300 468 V1.11.1
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _EXTENSION_DESC_H
#define _EXTENSION_DESC_H
#include <libdvbv5/descriptors.h>
struct dvb_v5_fe_parms;
/**
* @enum extension_descriptors
* @brief List containing all extended descriptors used by Digital TV MPEG-TS
* as defined at ETSI EN 300 468 V1.11.1
* @ingroup descriptors
*
* @var image_icon_descriptor
* @brief image icon descriptor
*
* @var cpcm_delivery_signalling_descriptor
* @brief Content Protection/Copy Management (CPCM) delivery signalling
* descriptor
*
* @var CP_descriptor
* @brief Content Protection descriptor
*
* @var CP_identifier_descriptor
* @brief Content Protection identifier descriptor
*
* @var T2_delivery_system_descriptor
* @brief DVB-T2 delivery system descriptor
*
* @var SH_delivery_system_descriptor
* @brief DVB-SH delivery system descriptor
*
* @var supplementary_audio_descriptor
* @brief supplementary audio descriptor
*
* @var network_change_notify_descriptor
* @brief network change notify descriptor
*
* @var message_descriptor
* @brief message descriptor
*
* @var target_region_descriptor
* @brief target region descriptor
*
* @var target_region_name_descriptor
* @brief target region name descriptor
*
* @var service_relocated_descriptor
* @brief service relocated descriptor
*/
enum extension_descriptors {
image_icon_descriptor = 0x00,
cpcm_delivery_signalling_descriptor = 0x01,
CP_descriptor = 0x02,
CP_identifier_descriptor = 0x03,
T2_delivery_system_descriptor = 0x04,
SH_delivery_system_descriptor = 0x05,
supplementary_audio_descriptor = 0x06,
network_change_notify_descriptor = 0x07,
message_descriptor = 0x08,
target_region_descriptor = 0x09,
target_region_name_descriptor = 0x0a,
service_relocated_descriptor = 0x0b,
};
/**
* @struct dvb_extension_descriptor
* @ingroup descriptors
* @brief Structure containing the extended descriptors
*
* @param type Descriptor type
* @param length Length of the descriptor
* @param next pointer to the dvb_desc descriptor
* @param extension_code extension code
* @param descriptor pointer to struct dvb_desc
*/
struct dvb_extension_descriptor {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
uint8_t extension_code;
struct dvb_desc *descriptor;
} __attribute__((packed));
/**
* @brief Function prototype for the extended descriptors parsing init code
* @ingroup dvb_table
*
* @param parms Struct dvb_v5_fe_parms pointer
* @param buf buffer with the content of the descriptor
* @param ext struct dvb_extension_descriptor pointer
* @param desc struct dvb_desc pointer
*/
typedef int (*dvb_desc_ext_init_func) (struct dvb_v5_fe_parms *parms,
const uint8_t *buf,
struct dvb_extension_descriptor *ext,
void *desc);
/**
* @brief Function prototype for the extended descriptors parsing print code
* @ingroup dvb_table
*
* @param parms Struct dvb_v5_fe_parms pointer
* @param buf buffer with the content of the descriptor
* @param ext struct dvb_extension_descriptor pointer
* @param desc struct dvb_desc pointer
*/
typedef void (*dvb_desc_ext_print_func)(struct dvb_v5_fe_parms *parms,
const struct dvb_extension_descriptor *ext,
const void *desc);
/**
* @brief Function prototype for the extended descriptors parsing free code
* @ingroup dvb_table
*
* @param desc struct dvb_desc pointer
*/
typedef void (*dvb_desc_ext_free_func) (const void *desc);
/**
* @struct dvb_ext_descriptor
* @ingroup descriptors
* @brief Structure that describes the parser functions for the extended
* descriptors. Works on a similar way as struct dvb_descriptor.
*
* @param name name of the descriptor
* @param init init dvb_desc_ext_init_func pointer
* @param print print dvb_desc_ext_print_func pointer
* @param free free dvb_desc_ext_free_func pointer
* @param size size of the descriptor
*/
struct dvb_ext_descriptor {
const char *name;
dvb_desc_ext_init_func init;
dvb_desc_ext_print_func print;
dvb_desc_ext_free_func free;
ssize_t size;
};
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the extended descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function allocates a the descriptor and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_extension_descriptor_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the extended descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_extension_descriptor_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Frees all data allocated by the extended descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void dvb_extension_descriptor_free(struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,112 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#ifndef _DESC_FREQUENCY_LIST_H
#define _DESC_FREQUENCY_LIST_H
#include <libdvbv5/descriptors.h>
/**
* @file desc_frequency_list.h
* @ingroup descriptors
* @brief Provides the descriptors for the frequency list descriptor.
* This descriptor lists the additional frequencies used in transmission
* of a multiplex on other frequencies.
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ETSI EN 300 468 V1.11.1
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
/**
* @struct dvb_desc_frequency_list
* @ingroup descriptors
* @brief Struct containing the frequency list descriptor
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param frequencies number of frequencies in the frequency vector
* @param frequency vector with the centre frequency
* @param freq_type freq type, being: 0 = undefined,
* 1 = satelite, 2 = cable or 3 = terrestrial.
*/
struct dvb_desc_frequency_list {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
uint8_t frequencies;
uint32_t *frequency;
union {
uint8_t bitfield;
struct {
uint8_t freq_type:2;
uint8_t reserved:6;
} __attribute__((packed));
} __attribute__((packed));
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the frequency list descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function initializes and makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* Currently, no memory is allocated internally.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_frequency_list_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the frequency list descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_frequency_list_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,114 @@
/*
* Copyright (c) 2011-2012 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file desc_hierarchy.h
* @ingroup descriptors
* @brief Provides the descriptors for the hierarchy descriptor
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ISO/IEC 13818-1
*
* @see
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _HIERARCHY_H
#define _HIERARCHY_H
#include <libdvbv5/descriptors.h>
/**
* @struct dvb_desc_hierarchy
* @ingroup descriptors
* @brief Structure containing the hierarchy descriptor
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param hierarchy_type hierarchy type
* @param layer hierarchy layer index
* @param embedded_layer hierarchy embedded layer index
* @param channel hierarchy channel
*/
struct dvb_desc_hierarchy {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
uint8_t hierarchy_type:4;
uint8_t reserved:4;
uint8_t layer:6;
uint8_t reserved2:2;
uint8_t embedded_layer:6;
uint8_t reserved3:2;
uint8_t channel:6;
uint8_t reserved4:2;
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the hierarchy descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function initializes and makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* Currently, no memory is allocated internally.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_hierarchy_init (struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the hierarchy descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_hierarchy_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,134 @@
/*
* Copyright (c) 2013-2014 - Mauro Carvalho Chehab <mchehab@kernel.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Described on ARIB STD-B10 as Terrestrial delivery system descriptor
*/
/**
* @file desc_isdbt_delivery.h
* @ingroup descriptors
* @brief Provides the descriptors for the ISDB-T terrestrial delivery system
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ARIB STD-B10
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _ISDBT_DELIVERY_H
#define _ISDBT_DELIVERY_H
#include <libdvbv5/descriptors.h>
/**
* @struct isdbt_desc_terrestrial_delivery_system
* @ingroup descriptors
* @brief Struct containing the ISDB-T terrestrial delivery system
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param area_code area code. The area code definition varies from
* Country to Country.
* @param guard_interval guard interval
* @param transmission_mode transmission mode
* @param frequency vector with center frequencies
* @param num_freqs number of frequencies at the
* isdbt_desc_terrestrial_delivery_system::frequency vector
*/
struct isdbt_desc_terrestrial_delivery_system {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
uint32_t *frequency;
unsigned num_freqs;
union {
uint16_t bitfield;
struct {
uint16_t transmission_mode:2;
uint16_t guard_interval:2;
uint16_t area_code:12;
} __attribute__((packed));
} __attribute__((packed));
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the ISDB-T terrestrial delivery system
* descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function allocates a the descriptor and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int isdbt_desc_delivery_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the ISDB-T terrestrial delivery system
* descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void isdbt_desc_delivery_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Frees all data allocated by the ISDB-T terrestrial delivery system
* descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void isdbt_desc_delivery_free(struct dvb_desc *desc);
/**
* Converts an ISDB-T Interval code into a string
*/
extern const uint32_t isdbt_interval[];
/**
* Converts an ISDB-T mode into a string
*/
extern const uint32_t isdbt_mode[];
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,103 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file desc_language.h
* @ingroup descriptors
* @brief Provides the descriptors for the ISO639 language descriptor
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ISO/IEC 13818-1
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _DESC_LANGUAGE_H
#define _DESC_LANGUAGE_H
#include <libdvbv5/descriptors.h>
/**
* @struct dvb_desc_language
* @ingroup descriptors
* @brief Structure containing the ISO639 language descriptor
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param language ISO639 language string
* @param audio_type audio type: 0 = undefined, 1 = clean effects,
* 2 = hearing impaired, 3 = visual impired
* comentary, other values are reserved.
*/
struct dvb_desc_language {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
unsigned char language[4];
uint8_t audio_type;
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the language descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function initializes and makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* Currently, no memory is allocated internally.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_language_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
struct dvb_desc *desc);
/**
* @brief Prints the content of the language descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_language_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,132 @@
/*
* Copyright (c) 2013 - Mauro Carvalho Chehab <mchehab@kernel.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Described on IEC/CENELEC DS/EN 62216-1:2011
*
* I couldn't find the original version, so I used what's there at:
* http://tdt.telecom.pt/recursos/apresentacoes/Signalling Specifications for DTT deployment in Portugal.pdf
*/
/**
* @file desc_logical_channel.h
* @ingroup descriptors
* @brief Provides the descriptors for the LCN - Logican Channel Number
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - IEC/CENELEC DS/EN 62216-1:2011
*
* @see http://tdt.telecom.pt/recursos/apresentacoes/Signalling Specifications for DTT deployment in Portugal.pdf
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _LCN_DESC_H
#define _LCN_DESC_H
#include <libdvbv5/descriptors.h>
/**
* @struct dvb_desc_logical_channel_number
* @ingroup descriptors
* @brief Structure containing the logical channel number entires
*
* @param service_id service id
* @param visible_service_flag visible service flag
* @param logical_channel_number logical channel number
*/
struct dvb_desc_logical_channel_number {
uint16_t service_id;
union {
uint16_t bitfield;
struct {
uint16_t logical_channel_number:10;
uint16_t reserved:5;
uint16_t visible_service_flag:1;
} __attribute__((packed));
} __attribute__((packed));
} __attribute__((packed));
/**
* @struct dvb_desc_logical_channel
* @ingroup descriptors
* @brief Structure containing the logical channel number descriptor
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param lcn pointer to struct dvb_desc_logical_channel_number
*/
struct dvb_desc_logical_channel {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
struct dvb_desc_logical_channel_number *lcn;
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the logical channel number descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function allocates a the descriptor and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_logical_channel_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the logical channel number descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_logical_channel_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Frees all data allocated by the logical channel number descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void dvb_desc_logical_channel_free(struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,112 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file desc_network_name.h
* @ingroup descriptors
* @brief Provides the descriptors for the network name descriptor
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ETSI EN 300 468 V1.11.1 (2010-04)
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _DESC_NETWORK_NAME_H
#define _DESC_NETWORK_NAME_H
#include <libdvbv5/descriptors.h>
/**
* @struct dvb_desc_network_name
* @ingroup descriptors
* @brief Struct containing the network name descriptor
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param network_name network name string
* @param network_name_emph network name emphasis string
*
* @details
* The emphasis text is the one that uses asterisks. For example, in the text:
* "the quick *fox* jumps over the lazy table" the emphasis would be "fox".
*/
struct dvb_desc_network_name {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
char *network_name;
char *network_name_emph;
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the network name descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function allocates a the descriptor and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_network_name_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the network name descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_network_name_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Frees all data allocated by the network name descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void dvb_desc_network_name_free(struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,125 @@
/*
* Copyright (c) 2013 - Mauro Carvalho Chehab <mchehab@kernel.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Described on IEC/CENELEC DS/EN 62216-1:2011
*
* I couldn't find the original version, so I used what's there at:
* http://tdt.telecom.pt/recursos/apresentacoes/Signalling Specifications for DTT deployment in Portugal.pdf
*/
/**
* @file desc_partial_reception.h
* @ingroup descriptors
* @brief Provides the descriptors for the ISDB partial reception descriptor
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - IEC/CENELEC DS/EN 62216-1:2011
*
* @see http://tdt.telecom.pt/recursos/apresentacoes/Signalling Specifications for DTT deployment in Portugal.pdf
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _PARTIAL_RECEPTION_H
#define _PARTIAL_RECEPTION_H
#include <libdvbv5/descriptors.h>
/**
* @struct isdb_partial_reception_service_id
* @ingroup descriptors
* @brief Service ID that uses partial reception
*
* @param service_id service id
*/
struct isdb_partial_reception_service_id {
uint16_t service_id;
} __attribute__((packed));
/**
* @struct isdb_desc_partial_reception
* @ingroup descriptors
* @brief Structure containing the partial reception descriptor
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param partial_reception vector of struct isdb_partial_reception_service_id.
* The length of the vector is given by:
* length / sizeof(struct isdb_partial_reception_service_id).
*/
struct isdb_desc_partial_reception {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
struct isdb_partial_reception_service_id *partial_reception;
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the ISDB-T partial reception descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function allocates a the descriptor and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int isdb_desc_partial_reception_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the ISDB-T partial reception descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void isdb_desc_partial_reception_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Frees all data allocated by the ISDB-T partial reception descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void isdb_desc_partial_reception_free(struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,109 @@
/*
* Copyright (c) 2020 - Mauro Carvalho Chehab
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#ifndef _DESC_REGISTRATION_ID_H
#define _DESC_REGISTRATION_ID_H
#include <libdvbv5/descriptors.h>
/**
* @file desc_registration_id.h
* @ingroup descriptors
* @brief Provides the descriptors for the registration descriptor.
* This descriptor provides the format information for an
* Elementary Stream.
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ISO/IEC 13818-1
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
/**
* @struct dvb_desc_registration
* @ingroup descriptors
* @brief Struct containing the frequency list descriptor
*
* @param type descriptor tag
* @param length descriptor length
* @param format_identifier 32-bit value obtained from ISO/IEC JTC 1/SC 29
* which describes the format of the ES
* The length of the vector is given by:
* length - 4.
*/
struct dvb_desc_registration {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
uint8_t format_identifier[4];
uint8_t *additional_identification_info;
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the registration descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function initializes and makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* Currently, no memory is allocated internally.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_registration_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the registration descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_registration_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Frees all data allocated by the registration descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void dvb_desc_registration_free(struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

147
include/libdvbv5/desc_sat.h Normal file
View File

@@ -0,0 +1,147 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file desc_sat.h
* @ingroup descriptors
* @brief Provides the descriptors for the satellite delivery system descriptor
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ETSI EN 300 468 V1.11.1
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _SAT_H
#define _SAT_H
#include <libdvbv5/descriptors.h>
/**
* @struct dvb_desc_sat
* @ingroup descriptors
* @brief Structure containing the satellite delivery system descriptor
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param frequency frequency in kHz
* @param orbit orbital position in degrees (multiplied by 10)
* @param west_east west east flag. 0 = west, 1 = east
* @param polarization polarization. 0 = horizontal, 1 = vertical,
* 2 = left, 3 = right.
* @param roll_off roll off alpha factor. 0 = 0.35, 1 = 0.25,
* 2 = 0.20, 3 = reserved.
* @param modulation_system modulation system. 0 = DVB-S, 1 = DVB-S2.
* @param modulation_type modulation type. 0 = auto, 1 = QPSK, 2 = 8PSK,
* 3 = 16-QAM (only for DVB-S2).
* @param symbol_rate symbol rate in Kbauds.
* @param fec inner FEC (convolutional code)
*/
struct dvb_desc_sat {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
uint32_t frequency;
uint16_t orbit;
uint8_t modulation_type:2;
uint8_t modulation_system:1;
uint8_t roll_off:2;
uint8_t polarization:2;
uint8_t west_east:1;
union {
uint32_t bitfield;
struct {
uint32_t fec:4;
uint32_t symbol_rate:28;
} __attribute__((packed));
} __attribute__((packed));
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the satellite delivery system descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function initializes and makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* Currently, no memory is allocated internally.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_sat_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the satellite delivery system descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_sat_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief converts from the descriptor's FEC into enum fe_code_rate,
* as defined by DVBv5 API.
*/
extern const unsigned dvbs_dvbc_dvbs_freq_inner[];
/**
* @brief converts from the descriptor's polarization into
* enum dvb_sat_polarization, as defined at dvb-v5-std.h.
*/
extern const unsigned dvbs_polarization[];
/**
* @brief converts from the descriptor's rolloff into enum fe_rolloff,
* as defined by DVBv5 API.
*/
extern const unsigned dvbs_rolloff[];
/**
* @brief converts from the descriptor's modulation into enum fe_modulation,
* as defined by DVBv5 API.
*/
extern const unsigned dvbs_modulation[];
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,118 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file desc_service.h
* @ingroup descriptors
* @brief Provides the descriptors for the service descriptor
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ETSI EN 300 468 V1.11.1
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _DESC_SERVICE_H
#define _DESC_SERVICE_H
#include <libdvbv5/descriptors.h>
/**
* @struct dvb_desc_service
* @ingroup descriptors
* @brief Structure containing the service descriptor
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param service_type service type
* @param name name string
* @param name_emph name emphasis string
* @param provider provider string
* @param provider_emph provider emphasis string
*
* @details
* The emphasis text is the one that uses asterisks. For example, in the text:
* "the quick *fox* jumps over the lazy table" the emphasis would be "fox".
*/
struct dvb_desc_service {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
uint8_t service_type;
char *name;
char *name_emph;
char *provider;
char *provider_emph;
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the service descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function allocates a the descriptor and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_service_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the service descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_service_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Frees all data allocated by the service descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void dvb_desc_service_free(struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,224 @@
/*
* Copyright (c) 2013-2014 - Mauro Carvalho Chehab <mchehab@kernel.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Based on ETSI EN 300 468 V1.11.1 (2010-04)
*/
/**
* @file desc_t2_delivery.h
* @ingroup descriptors
* @brief Provides the descriptors for the DVB-T2 delivery system descriptor
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ETSI EN 300 468 V1.11.1
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _T2_DELIVERY_H
#define _T2_DELIVERY_H
#include <libdvbv5/descriptors.h>
/**
* @struct dvb_desc_t2_delivery_subcell_old
* @ingroup descriptors
* @brief Structure to describe transponder subcell extension and frequencies
*
* @param cell_id_extension cell id extension
* @param transposer_frequency transposer frequency
*
* NOTE: This struct is deprecated and will never be filled.
* It is kept here just to avoid breaking ABI.
*
* All subcell transposer frequencies will be added to
* dvb_desc_t2_delivery::centre_frequency array.
*/
struct dvb_desc_t2_delivery_subcell_old {
uint8_t cell_id_extension;
uint16_t transposer_frequency; // Should be 32 bits, instead
} __attribute__((packed));
/**
* @struct dvb_desc_t2_delivery_subcell
* @ingroup descriptors
* @brief Structure to describe transponder subcell extension and frequencies
*
* @param cell_id_extension cell id extension
* @param transposer_frequency pointer to transposer frequency
*/
struct dvb_desc_t2_delivery_subcell {
uint8_t cell_id_extension;
uint32_t transposer_frequency;
} __attribute__((packed));
/**
* @struct dvb_desc_t2_delivery_cell
* @ingroup descriptors
* @brief Structure to describe transponder cells
*
* @param cell_id cell id extension
* @param num_freqs number of cell frequencies
* @param centre_frequency pointer to centre frequencies
* @param subcel_length number of subcells. May be zero
* @param subcell pointer to subcell array. May be NULL
*/
struct dvb_desc_t2_delivery_cell {
uint16_t cell_id;
int num_freqs;
uint32_t *centre_frequency;
uint8_t subcel_length;
struct dvb_desc_t2_delivery_subcell *subcel;
} __attribute__((packed));
/**
* @struct dvb_desc_t2_delivery
* @ingroup descriptors
* @brief Structure containing the T2 delivery system descriptor
*
* @param plp_id data PLP id
* @param system_id T2 system id
* @param SISO_MISO SISO MISO
* @param bandwidth bandwidth
* @param guard_interval guard interval
* @param transmission_mode transmission mode
* @param other_frequency_flag other frequency flag
* @param tfs_flag tfs flag
*
* @param centre_frequency centre frequency vector. It contains the full
* frequencies for all cells and subcells.
* @param frequency_loop_length size of the dvb_desc_t2_delivery::centre_frequency
* vector
*
* @param subcel_info_loop_length unused. Always 0
* @param subcell unused. Always NULL
* @param num_cell number of cells
* @param cell cell array. Contains per-cell and per-subcell
* pointers to the frequencies parsed.
*/
struct dvb_desc_t2_delivery {
/* extended descriptor */
uint8_t plp_id;
uint16_t system_id;
union {
uint16_t bitfield;
struct {
uint16_t tfs_flag:1;
uint16_t other_frequency_flag:1;
uint16_t transmission_mode:3;
uint16_t guard_interval:3;
uint16_t reserved:2;
uint16_t bandwidth:4;
uint16_t SISO_MISO:2;
} __attribute__((packed));
} __attribute__((packed));
uint32_t *centre_frequency;
uint8_t frequency_loop_length;
/* Unused, as the definitions here are incomplete. */
uint8_t subcel_info_loop_length;
struct dvb_desc_t2_delivery_subcell_old *subcell;
/* Since version 1.13 */
unsigned int num_cell;
struct dvb_desc_t2_delivery_cell *cell;
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the T2 delivery system descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param ext struct dvb_extension_descriptor pointer
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function allocates a the descriptor and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_t2_delivery_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf,
struct dvb_extension_descriptor *ext,
void *desc);
/**
* @brief Prints the content of the T2 delivery system descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param ext struct dvb_extension_descriptor pointer
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_t2_delivery_print(struct dvb_v5_fe_parms *parms,
const struct dvb_extension_descriptor *ext,
const void *desc);
/**
* @brief Frees all data allocated by the T2 delivery system descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void dvb_desc_t2_delivery_free(const void *desc);
/**
* @brief converts from internal representation into bandwidth in Hz
*/
extern const unsigned dvbt2_bw[];
/**
* @brief converts from internal representation into enum fe_guard_interval,
* as defined at DVBv5 API.
*/
extern const uint32_t dvbt2_interval[];
/**
* @brief converts from the descriptor's transmission mode into
* enum fe_transmit_mode, as defined by DVBv5 API.
*/
extern const unsigned dvbt2_transmission_mode[];
/**
* @brief converts from internal representation to string the SISO_MISO
* field of dvb_desc_t2_delivery:SISO_MISO field.
*/
extern const char *siso_miso[4];
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,160 @@
/*
* Copyright (c) 2011-2012 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Based on ETSI EN 300 468 V1.11.1 (2010-04)
*
*/
/**
* @file desc_terrestrial_delivery.h
* @ingroup descriptors
* @brief Provides the descriptors for the DVB-T terrestrial delivery system descriptor
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ETSI EN 300 468 V1.11.1
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _TERRESTRIAL_DELIVERY_H
#define _TERRESTRIAL_DELIVERY_H
#include <libdvbv5/descriptors.h>
/**
* @struct dvb_desc_terrestrial_delivery
* @ingroup descriptors
* @brief Structure containing the DVB-T terrestrial delivery system descriptor
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param centre_frequency centre frequency, multiplied by 10 Hz
* @param bandwidth bandwidth
* @param priority priority (0 = LP, 1 = HP)
* @param time_slice_indicator time slicing indicator
* @param mpe_fec_indicator mpe fec indicator. If 1, MPE-FEC is not used.
* @param constellation constellation
* @param hierarchy_information hierarchy information
* @param code_rate_hp_stream code rate hp stream
* @param code_rate_lp_stream code rate lp stream
* @param guard_interval guard interval
* @param transmission_mode transmission mode
* @param other_frequency_flag other frequency flag
*/
struct dvb_desc_terrestrial_delivery {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
uint32_t centre_frequency;
uint8_t reserved_future_use1:2;
uint8_t mpe_fec_indicator:1;
uint8_t time_slice_indicator:1;
uint8_t priority:1;
uint8_t bandwidth:3;
uint8_t code_rate_hp_stream:3;
uint8_t hierarchy_information:3;
uint8_t constellation:2;
uint8_t other_frequency_flag:1;
uint8_t transmission_mode:2;
uint8_t guard_interval:2;
uint8_t code_rate_lp_stream:3;
uint32_t reserved_future_use2;
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the DVB-T terrestrial delivery system descriptor
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function initializes and makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* Currently, no memory is allocated internally.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_terrestrial_delivery_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf,
struct dvb_desc *desc);
/**
* @brief Prints the content of the DVB-T terrestrial delivery system descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_terrestrial_delivery_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief converts from internal representation into bandwidth in Hz
*/
extern const unsigned dvbt_bw[];
/**
* @brief converts from the descriptor's modulation into enum fe_modulation,
* as defined by DVBv5 API.
*/
extern const unsigned dvbt_modulation[];
/**
* @brief converts from the descriptor's hierarchy into enum fe_hierarchy,
* as defined by DVBv5 API.
*/
extern const unsigned dvbt_hierarchy[];
/**
* @brief converts from the descriptor's FEC into enum fe_code_rate,
* as defined by DVBv5 API.
*/
extern const unsigned dvbt_code_rate[];
/**
* @brief converts from internal representation into enum fe_guard_interval,
* as defined at DVBv5 API.
*/
extern const uint32_t dvbt_interval[];
/**
* @brief converts from the descriptor's transmission mode into
* enum fe_transmit_mode, as defined by DVBv5 API.
*/
extern const unsigned dvbt_transmission_mode[];
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,144 @@
/*
* Copyright (c) 2013-2014 - Mauro Carvalho Chehab <mchehab@kernel.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Described on ARIB STD-B10 as TS information descriptor
*/
/**
* @file desc_ts_info.h
* @ingroup descriptors
* @brief Provides the descriptors for the ISDB TS information descriptor.
* The TS information descriptor specifies the remote control key
* identifier assigned to the applicable TS and indicates the relationship
* between the service identifier and the transmission layer during
* hierarchical transmission.
*
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* @par Relevant specs
* The descriptor described herein is defined at:
* - ARIB STD-B10
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _TS_INFO_H
#define _TS_INFO_H
#include <libdvbv5/descriptors.h>
/**
* @struct dvb_desc_ts_info_transmission_type
* @ingroup descriptors
* @brief ISDB TS information transmission type
*
* @param transmission_type_info transmission type info
* @param num_of_service num of service
*/
struct dvb_desc_ts_info_transmission_type {
uint8_t transmission_type_info;
uint8_t num_of_service;
} __attribute__((packed));
/**
* @struct dvb_desc_ts_info
* @ingroup descriptors
* @brief Structure describing the ISDB TS information descriptor.
*
* @param type descriptor tag
* @param length descriptor length
* @param next pointer to struct dvb_desc
* @param remote_control_key_id remote control key id
* @param length_of_ts_name length of ts name
* @param transmission_type_count transmission type count
*
* @param ts_name ts name string
* @param ts_name_emph ts name emphasis string
* @param transmission_type struct dvb_desc_ts_info_transmission_type content
* @param service_id service id vector
*/
struct dvb_desc_ts_info {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
char *ts_name, *ts_name_emph;
struct dvb_desc_ts_info_transmission_type transmission_type;
uint16_t *service_id;
union {
uint16_t bitfield;
struct {
uint8_t transmission_type_count:2;
uint8_t length_of_ts_name:6;
uint8_t remote_control_key_id:8;
} __attribute__((packed));
};
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses the ISDB TS information descriptor.
* descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the descriptor's raw data
* @param desc pointer to struct dvb_desc to be allocated and filled
*
* This function allocates a the descriptor and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
int dvb_desc_ts_info_init(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Prints the content of the ISDB TS information descriptor.
* descriptor
* @ingroup descriptors
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param desc pointer to struct dvb_desc
*/
void dvb_desc_ts_info_print(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Frees all data allocated by the ISDB TS information descriptor.
* descriptor
* @ingroup descriptors
*
* @param desc pointer to struct dvb_desc to be freed
*/
void dvb_desc_ts_info_free(struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,780 @@
/*
* Copyright (c) 2011-2012 - Mauro Carvalho Chehab
* Copyright (c) 2012-2014 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* @file descriptors.h
* @ingroup dvb_table
* @brief Provides a way to handle MPEG-TS descriptors found on Digital TV
* streams.
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The descriptors herein are defined on the following specs:
* - ISO/IEC 13818-1
* - ETSI EN 300 468 V1.11.1 (2010-04)
* - SCTE 35 2004
* - http://www.etherguidesystems.com/Help/SDOs/ATSC/Semantics/Descriptors/Default.aspx
* - http://www.coolstf.com/tsreader/descriptors.html
* - ABNT NBR 15603-1 2007
* - ATSC A/65:2009 spec
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _DESCRIPTORS_H
#define _DESCRIPTORS_H
#include <unistd.h>
#include <stdint.h>
#include <arpa/inet.h>
/**
* @brief Maximum size of a table session to be parsed
* @ingroup dvb_table
*/
#define DVB_MAX_PAYLOAD_PACKET_SIZE 4096
/**
* @brief number of bytes for the descriptor's CRC check
* @ingroup dvb_table
*/
#define DVB_CRC_SIZE 4
#ifndef _DOXYGEN
struct dvb_v5_fe_parms;
#endif
/**
* @brief Function prototype for a function that initializes the
* descriptors parsing on a table
* @ingroup dvb_table
*
* @param parms Struct dvb_v5_fe_parms pointer
* @param buf Buffer with data to be parsed
* @param buflen Size of the buffer to be parsed
* @param table pointer to a place where the allocated memory with the
* table structure will be stored.
*/
typedef void (*dvb_table_init_func)(struct dvb_v5_fe_parms *parms,
const uint8_t *buf, ssize_t buflen,
void **table);
/**
* @brief Table with all possible descriptors
* @ingroup dvb_table
*/
extern const dvb_table_init_func dvb_table_initializers[256];
#ifndef _DOXYGEN
#define bswap16(b) do {\
b = ntohs(b); \
} while (0)
#define bswap32(b) do {\
b = ntohl(b); \
} while (0)
/* Deprecated */
#define DVB_DESC_HEADER() \
uint8_t type; \
uint8_t length; \
struct dvb_desc *next
#endif /* _DOXYGEN */
/**
* @struct dvb_desc
* @brief Linked list containing the several descriptors found on a
* MPEG-TS table
* @ingroup dvb_table
*
* @param type Descriptor type
* @param length Length of the descriptor
* @param next pointer to the dvb_desc descriptor
* @param data Descriptor data
*/
struct dvb_desc {
uint8_t type;
uint8_t length;
struct dvb_desc *next;
uint8_t data[];
} __attribute__((packed));
#ifndef _DOXYGEN
#define dvb_desc_foreach( _desc, _tbl ) \
if (_tbl && _tbl->descriptor) \
for( struct dvb_desc *_desc = _tbl->descriptor; _desc; _desc = _desc->next ) \
#define dvb_desc_find(_struct, _desc, _tbl, _type) \
if (_tbl && _tbl->descriptor) \
for( _struct *_desc = (_struct *) _tbl->descriptor; _desc; _desc = (_struct *) _desc->next ) \
if(_desc->type == _type) \
#endif /* _DOXYGEN */
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Converts from BCD to CPU integer internal representation
* @ingroup dvb_table
*
* @param bcd value in BCD encoding
*/
uint32_t dvb_bcd(uint32_t bcd);
/**
* @brief dumps data into the logs in hexadecimal format
* @ingroup dvb_table
*
* @param parms Struct dvb_v5_fe_parms pointer
* @param prefix String to be printed before the dvb_hexdump
* @param buf Buffer to hex dump
* @param len Number of bytes to show
*/
void dvb_hexdump(struct dvb_v5_fe_parms *parms, const char *prefix,
const unsigned char *buf, int len);
/**
* @brief parse MPEG-TS descriptors
* @ingroup dvb_table
*
* @param parms Struct dvb_v5_fe_parms pointer
* @param buf Buffer with data to be parsed
* @param buflen Size of the buffer to be parsed
* @param head_desc pointer to the place to store the parsed data
*
* This function takes a buf as argument and parses it to find the
* MPEG-TS descriptors inside it, creating a linked list.
*
* On success, head_desc will be allocated and filled with a linked list
* with the descriptors found inside the buffer.
*
* This function is used by the several MPEG-TS table handlers to parse
* the entire table that got read by dvb_read_sessions and other similar
* functions.
*
* @return Returns 0 on success, a negative value otherwise.
*/
int dvb_desc_parse(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
uint16_t buflen, struct dvb_desc **head_desc);
/**
* @brief frees a dvb_desc linked list
* @ingroup dvb_table
*
* @param list struct dvb_desc pointer.
*/
void dvb_desc_free (struct dvb_desc **list);
/**
* @brief prints the contents of a struct dvb_desc linked list
* @ingroup dvb_table
*
* @param parms Struct dvb_v5_fe_parms pointer
* @param desc struct dvb_desc pointer.
*/
void dvb_desc_print(struct dvb_v5_fe_parms *parms, struct dvb_desc *desc);
#ifdef __cplusplus
}
#endif
/**
* @brief Function prototype for the descriptors parsing init code
* @ingroup dvb_table
*
* @param parms Struct dvb_v5_fe_parms pointer
* @param buf buffer with the content of the descriptor
* @param desc struct dvb_desc pointer
*/
typedef int (*dvb_desc_init_func) (struct dvb_v5_fe_parms *parms,
const uint8_t *buf, struct dvb_desc *desc);
/**
* @brief Function prototype for the descriptors parsing print code
* @ingroup dvb_table
*
* @param parms Struct dvb_v5_fe_parms pointer
* @param desc struct dvb_desc pointer
*/
typedef void (*dvb_desc_print_func)(struct dvb_v5_fe_parms *parms,
const struct dvb_desc *desc);
/**
* @brief Function prototype for the descriptors memory free code
* @ingroup dvb_table
*
* @param desc pointer to struct dvb_desc pointer to be freed
*/
typedef void (*dvb_desc_free_func) (struct dvb_desc *desc);
/**
* @struct dvb_descriptor
* @brief Contains the parser information for the MPEG-TS parser code
* @ingroup dvb_table
*
* @param name String containing the name of the descriptor
* @param init Pointer to a function to initialize the descriptor
* parser. This function fills the descriptor-specific
* internal structures
* @param print Prints the content of the descriptor
* @param free Frees all memory blocks allocated by the init function
* @param size Descriptor's size, in bytes.
*/
struct dvb_descriptor {
const char *name;
dvb_desc_init_func init;
dvb_desc_print_func print;
dvb_desc_free_func free;
ssize_t size;
};
/**
* @brief Contains the parsers for the several descriptors
* @ingroup dvb_table
*/
extern const struct dvb_descriptor dvb_descriptors[];
/**
* @enum descriptors
* @brief List containing all descriptors used by Digital TV MPEG-TS
* @ingroup dvb_table
*
* @var video_stream_descriptor
* @brief video_stream descriptor - ISO/IEC 13818-1
* @var audio_stream_descriptor
* @brief audio_stream descriptor - ISO/IEC 13818-1
* @var hierarchy_descriptor
* @brief hierarchy descriptor - ISO/IEC 13818-1
* @var registration_descriptor
* @brief registration descriptor - ISO/IEC 13818-1
* @var ds_alignment_descriptor
* @brief ds_alignment descriptor - ISO/IEC 13818-1
* @var target_background_grid_descriptor
* @brief target_background_grid descriptor - ISO/IEC 13818-1
* @var video_window_descriptor
* @brief video_window descriptor - ISO/IEC 13818-1
* @var conditional_access_descriptor
* @brief conditional_access descriptor - ISO/IEC 13818-1
* @var iso639_language_descriptor
* @brief iso639_language descriptor - ISO/IEC 13818-1
* @var system_clock_descriptor
* @brief system_clock descriptor - ISO/IEC 13818-1
* @var multiplex_buffer_utilization_descriptor
* @brief multiplex_buffer_utilization descriptor - ISO/IEC 13818-1
* @var copyright_descriptor
* @brief copyright descriptor - ISO/IEC 13818-1
* @var maximum_bitrate_descriptor
* @brief maximum_bitrate descriptor - ISO/IEC 13818-1
* @var private_data_indicator_descriptor
* @brief private_data_indicator descriptor - ISO/IEC 13818-1
* @var smoothing_buffer_descriptor
* @brief smoothing_buffer descriptor - ISO/IEC 13818-1
* @var std_descriptor
* @brief std descriptor - ISO/IEC 13818-1
* @var ibp_descriptor
* @brief ibp descriptor - ISO/IEC 13818-1
* @var mpeg4_video_descriptor
* @brief mpeg4_video descriptor - ISO/IEC 13818-1
* @var mpeg4_audio_descriptor
* @brief mpeg4_audio descriptor - ISO/IEC 13818-1
* @var iod_descriptor
* @brief iod descriptor - ISO/IEC 13818-1
* @var sl_descriptor
* @brief sl descriptor - ISO/IEC 13818-1
* @var fmc_descriptor
* @brief fmc descriptor - ISO/IEC 13818-1
* @var external_es_id_descriptor
* @brief external_es_id descriptor - ISO/IEC 13818-1
* @var muxcode_descriptor
* @brief muxcode descriptor - ISO/IEC 13818-1
* @var fmxbuffersize_descriptor
* @brief fmxbuffersize descriptor - ISO/IEC 13818-1
* @var multiplexbuffer_descriptor
* @brief multiplexbuffer descriptor - ISO/IEC 13818-1
* @var content_labeling_descriptor
* @brief content_labeling descriptor - ISO/IEC 13818-1
* @var metadata_pointer_descriptor
* @brief metadata_pointer descriptor - ISO/IEC 13818-1
* @var metadata_descriptor
* @brief metadata descriptor - ISO/IEC 13818-1
* @var metadata_std_descriptor
* @brief metadata_std descriptor - ISO/IEC 13818-1
* @var AVC_video_descriptor
* @brief AVC_video descriptor - ISO/IEC 13818-1
* @var ipmp_descriptor
* @brief ipmp descriptor - ISO/IEC 13818-1
* @var AVC_timing_and_HRD_descriptor
* @brief AVC_timing_and_HRD descriptor - ISO/IEC 13818-1
* @var mpeg2_aac_audio_descriptor
* @brief mpeg2_aac_audio descriptor - ISO/IEC 13818-1
* @var flexmux_timing_descriptor
* @brief flexmux_timing descriptor - ISO/IEC 13818-1
* @var network_name_descriptor
* @brief network_name descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var service_list_descriptor
* @brief service_list descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var stuffing_descriptor
* @brief stuffing descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var satellite_delivery_system_descriptor
* @brief satellite_delivery_system descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var cable_delivery_system_descriptor
* @brief cable_delivery_system descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var VBI_data_descriptor
* @brief VBI_data descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var VBI_teletext_descriptor
* @brief VBI_teletext descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var bouquet_name_descriptor
* @brief bouquet_name descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var service_descriptor
* @brief service descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var country_availability_descriptor
* @brief country_availability descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var linkage_descriptor
* @brief linkage descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var NVOD_reference_descriptor
* @brief NVOD_reference descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var time_shifted_service_descriptor
* @brief time_shifted_service descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var short_event_descriptor
* @brief short_event descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var extended_event_descriptor
* @brief extended_event descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var time_shifted_event_descriptor
* @brief time_shifted_event descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var component_descriptor
* @brief component descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var mosaic_descriptor
* @brief mosaic descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var stream_identifier_descriptor
* @brief stream_identifier descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var CA_identifier_descriptor
* @brief CA_identifier descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var content_descriptor
* @brief content descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var parental_rating_descriptor
* @brief parental_rating descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var teletext_descriptor
* @brief teletext descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var telephone_descriptor
* @brief telephone descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var local_time_offset_descriptor
* @brief local_time_offset descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var subtitling_descriptor
* @brief subtitling descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var terrestrial_delivery_system_descriptor
* @brief terrestrial_delivery_system descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var multilingual_network_name_descriptor
* @brief multilingual_network_name descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var multilingual_bouquet_name_descriptor
* @brief multilingual_bouquet_name descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var multilingual_service_name_descriptor
* @brief multilingual_service_name descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var multilingual_component_descriptor
* @brief multilingual_component descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var private_data_specifier_descriptor
* @brief private_data_specifier descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var service_move_descriptor
* @brief service_move descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var short_smoothing_buffer_descriptor
* @brief short_smoothing_buffer descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var frequency_list_descriptor
* @brief frequency_list descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var partial_transport_stream_descriptor
* @brief partial_transport_stream descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var data_broadcast_descriptor
* @brief data_broadcast descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var scrambling_descriptor
* @brief scrambling descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var data_broadcast_id_descriptor
* @brief data_broadcast_id descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var transport_stream_descriptor
* @brief transport_stream descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var DSNG_descriptor
* @brief DSNG descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var PDC_descriptor
* @brief PDC descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var AC_3_descriptor
* @brief AC_3 descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var ancillary_data_descriptor
* @brief ancillary_data descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var cell_list_descriptor
* @brief cell_list descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var cell_frequency_link_descriptor
* @brief cell_frequency_link descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var announcement_support_descriptor
* @brief announcement_support descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var application_signalling_descriptor
* @brief application_signalling descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var adaptation_field_data_descriptor
* @brief adaptation_field_data descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var service_identifier_descriptor
* @brief service_identifier descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var service_availability_descriptor
* @brief service_availability descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var default_authority_descriptor
* @brief default_authority descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var related_content_descriptor
* @brief related_content descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var TVA_id_descriptor
* @brief TVA_id descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var content_identifier_descriptor
* @brief content_identifier descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var time_slice_fec_identifier_descriptor
* @brief time_slice_fec_identifier descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var ECM_repetition_rate_descriptor
* @brief ECM_repetition_rate descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var S2_satellite_delivery_system_descriptor
* @brief S2_satellite_delivery_system descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var enhanced_AC_3_descriptor
* @brief enhanced_AC_3 descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var DTS_descriptor
* @brief DTS descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var AAC_descriptor
* @brief AAC descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var XAIT_location_descriptor
* @brief XAIT_location descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var FTA_content_management_descriptor
* @brief FTA_content_management descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var extension_descriptor
* @brief extension descriptor - ETSI EN 300 468 V1.11.1 (2010-04)
* @var CUE_identifier_descriptor
* @brief CUE_identifier descriptor - SCTE 35 2004
* @var extended_channel_name
* @brief extended_channel_name descriptor - SCTE 35 2004
* @var service_location
* @brief service_location descriptor - SCTE 35 2004
* @var component_name_descriptor
* @brief component_name descriptor - SCTE 35 2004
* @see http://www.etherguidesystems.com/Help/SDOs/ATSC/Semantics/Descriptors/Default.aspx
* @var logical_channel_number_descriptor
* @brief logical_channel_number descriptor - SCTE 35 2004
* @see http://www.coolstf.com/tsreader/descriptors.html
*
* @var carousel_id_descriptor
* @brief carousel_id descriptor - ABNT NBR 15603-1 2007
* @var association_tag_descriptor
* @brief association_tag descriptor - ABNT NBR 15603-1 2007
* @var deferred_association_tags_descriptor
* @brief deferred_association_tags descriptor - ABNT NBR 15603-1 2007
* @var hierarchical_transmission_descriptor
* @brief hierarchical_transmission descriptor - ABNT NBR 15603-1 2007
* @var digital_copy_control_descriptor
* @brief digital_copy_control descriptor - ABNT NBR 15603-1 2007
* @var network_identifier_descriptor
* @brief network_identifier descriptor - ABNT NBR 15603-1 2007
* @var partial_transport_stream_time_descriptor
* @brief partial_transport_stream_time descriptor - ABNT NBR 15603-1 2007
* @var audio_component_descriptor
* @brief audio_component descriptor - ABNT NBR 15603-1 2007
* @var hyperlink_descriptor
* @brief hyperlink descriptor - ABNT NBR 15603-1 2007
* @var target_area_descriptor
* @brief target_area descriptor - ABNT NBR 15603-1 2007
* @var data_contents_descriptor
* @brief data_contents descriptor - ABNT NBR 15603-1 2007
* @var video_decode_control_descriptor
* @brief video_decode_control descriptor - ABNT NBR 15603-1 2007
* @var download_content_descriptor
* @brief download_content descriptor - ABNT NBR 15603-1 2007
* @var CA_EMM_TS_descriptor
* @brief CA_EMM_TS descriptor - ABNT NBR 15603-1 2007
* @var CA_contract_information_descriptor
* @brief CA_contract_information descriptor - ABNT NBR 15603-1 2007
* @var CA_service_descriptor
* @brief CA_service descriptor - ABNT NBR 15603-1 2007
* @var TS_Information_descriptor
* @brief transport_stream_information descriptor - ABNT NBR 15603-1 2007
* @var extended_broadcaster_descriptor
* @brief extended_broadcaster descriptor - ABNT NBR 15603-1 2007
* @var logo_transmission_descriptor
* @brief logo_transmission descriptor - ABNT NBR 15603-1 2007
* @var basic_local_event_descriptor
* @brief basic_local_event descriptor - ABNT NBR 15603-1 2007
* @var reference_descriptor
* @brief reference descriptor - ABNT NBR 15603-1 2007
* @var node_relation_descriptor
* @brief node_relation descriptor - ABNT NBR 15603-1 2007
* @var short_node_information_descriptor
* @brief short_node_information descriptor - ABNT NBR 15603-1 2007
* @var STC_reference_descriptor
* @brief STC_reference descriptor - ABNT NBR 15603-1 2007
* @var series_descriptor
* @brief series descriptor - ABNT NBR 15603-1 2007
* @var event_group_descriptor
* @brief event_group descriptor - ABNT NBR 15603-1 2007
* @var SI_parameter_descriptor
* @brief SI_parameter descriptor - ABNT NBR 15603-1 2007
* @var broadcaster_Name_Descriptor
* @brief broadcaster_Name descriptor - ABNT NBR 15603-1 2007
* @var component_group_descriptor
* @brief component_group descriptor - ABNT NBR 15603-1 2007
* @var SI_prime_TS_descriptor
* @brief SI_prime_transport_stream descriptor - ABNT NBR 15603-1 2007
* @var board_information_descriptor
* @brief board_information descriptor - ABNT NBR 15603-1 2007
* @var LDT_linkage_descriptor
* @brief LDT_linkage descriptor - ABNT NBR 15603-1 2007
* @var connected_transmission_descriptor
* @brief connected_transmission descriptor - ABNT NBR 15603-1 2007
* @var content_availability_descriptor
* @brief content_availability descriptor - ABNT NBR 15603-1 2007
* @var service_group_descriptor
* @brief service_group descriptor - ABNT NBR 15603-1 2007
* @var carousel_compatible_composite_descriptor
* @brief carousel_compatible_composite descriptor - ABNT NBR 15603-1 2007
* @var conditional_playback_descriptor
* @brief conditional_playback descriptor - ABNT NBR 15603-1 2007
* @var ISDBT_delivery_system_descriptor
* @brief ISDBT terrestrial_delivery_system descriptor - ABNT NBR 15603-1 2007
* @var partial_reception_descriptor
* @brief partial_reception descriptor - ABNT NBR 15603-1 2007
* @var emergency_information_descriptor
* @brief emergency_information descriptor - ABNT NBR 15603-1 2007
* @var data_component_descriptor
* @brief data_component descriptor - ABNT NBR 15603-1 2007
* @var system_management_descriptor
* @brief system_management descriptor - ABNT NBR 15603-1 2007
*
* @var atsc_stuffing_descriptor
* @brief atsc_stuffing descriptor - ATSC A/65:2009
* @var atsc_ac3_audio_descriptor
* @brief atsc_ac3_audio descriptor - ATSC A/65:2009
* @var atsc_caption_service_descriptor
* @brief atsc_caption_service descriptor - ATSC A/65:2009
* @var atsc_content_advisory_descriptor
* @brief atsc_content_advisory descriptor - ATSC A/65:2009
* @var atsc_extended_channel_descriptor
* @brief atsc_extended_channel descriptor - ATSC A/65:2009
* @var atsc_service_location_descriptor
* @brief atsc_service_location descriptor - ATSC A/65:2009
* @var atsc_time_shifted_service_descriptor
* @brief atsc_time_shifted_service descriptor - ATSC A/65:2009
* @var atsc_component_name_descriptor
* @brief atsc_component_name descriptor - ATSC A/65:2009
* @var atsc_DCC_departing_request_descriptor
* @brief atsc_DCC_departing_request descriptor - ATSC A/65:2009
* @var atsc_DCC_arriving_request_descriptor
* @brief atsc_DCC_arriving_request descriptor - ATSC A/65:2009
* @var atsc_redistribution_control_descriptor
* @brief atsc_redistribution_control descriptor - ATSC A/65:2009
* @var atsc_ATSC_private_information_descriptor
* @brief atsc_ATSC_private_information descriptor - ATSC A/65:2009
* @var atsc_genre_descriptor
* @brief atsc_genre descriptor - ATSC A/65:2009
*/
enum descriptors {
/* ISO/IEC 13818-1 */
video_stream_descriptor = 0x02,
audio_stream_descriptor = 0x03,
hierarchy_descriptor = 0x04,
registration_descriptor = 0x05,
ds_alignment_descriptor = 0x06,
target_background_grid_descriptor = 0x07,
video_window_descriptor = 0x08,
conditional_access_descriptor = 0x09,
iso639_language_descriptor = 0x0a,
system_clock_descriptor = 0x0b,
multiplex_buffer_utilization_descriptor = 0x0c,
copyright_descriptor = 0x0d,
maximum_bitrate_descriptor = 0x0e,
private_data_indicator_descriptor = 0x0f,
smoothing_buffer_descriptor = 0x10,
std_descriptor = 0x11,
ibp_descriptor = 0x12,
mpeg4_video_descriptor = 0x1b,
mpeg4_audio_descriptor = 0x1c,
iod_descriptor = 0x1d,
sl_descriptor = 0x1e,
fmc_descriptor = 0x1f,
external_es_id_descriptor = 0x20,
muxcode_descriptor = 0x21,
fmxbuffersize_descriptor = 0x22,
multiplexbuffer_descriptor = 0x23,
content_labeling_descriptor = 0x24,
metadata_pointer_descriptor = 0x25,
metadata_descriptor = 0x26,
metadata_std_descriptor = 0x27,
AVC_video_descriptor = 0x28,
ipmp_descriptor = 0x29,
AVC_timing_and_HRD_descriptor = 0x2a,
mpeg2_aac_audio_descriptor = 0x2b,
flexmux_timing_descriptor = 0x2c,
/* ETSI EN 300 468 V1.11.1 (2010-04) */
network_name_descriptor = 0x40,
service_list_descriptor = 0x41,
stuffing_descriptor = 0x42,
satellite_delivery_system_descriptor = 0x43,
cable_delivery_system_descriptor = 0x44,
VBI_data_descriptor = 0x45,
VBI_teletext_descriptor = 0x46,
bouquet_name_descriptor = 0x47,
service_descriptor = 0x48,
country_availability_descriptor = 0x49,
linkage_descriptor = 0x4a,
NVOD_reference_descriptor = 0x4b,
time_shifted_service_descriptor = 0x4c,
short_event_descriptor = 0x4d,
extended_event_descriptor = 0x4e,
time_shifted_event_descriptor = 0x4f,
component_descriptor = 0x50,
mosaic_descriptor = 0x51,
stream_identifier_descriptor = 0x52,
CA_identifier_descriptor = 0x53,
content_descriptor = 0x54,
parental_rating_descriptor = 0x55,
teletext_descriptor = 0x56,
telephone_descriptor = 0x57,
local_time_offset_descriptor = 0x58,
subtitling_descriptor = 0x59,
terrestrial_delivery_system_descriptor = 0x5a,
multilingual_network_name_descriptor = 0x5b,
multilingual_bouquet_name_descriptor = 0x5c,
multilingual_service_name_descriptor = 0x5d,
multilingual_component_descriptor = 0x5e,
private_data_specifier_descriptor = 0x5f,
service_move_descriptor = 0x60,
short_smoothing_buffer_descriptor = 0x61,
frequency_list_descriptor = 0x62,
partial_transport_stream_descriptor = 0x63,
data_broadcast_descriptor = 0x64,
scrambling_descriptor = 0x65,
data_broadcast_id_descriptor = 0x66,
transport_stream_descriptor = 0x67,
DSNG_descriptor = 0x68,
PDC_descriptor = 0x69,
AC_3_descriptor = 0x6a,
ancillary_data_descriptor = 0x6b,
cell_list_descriptor = 0x6c,
cell_frequency_link_descriptor = 0x6d,
announcement_support_descriptor = 0x6e,
application_signalling_descriptor = 0x6f,
adaptation_field_data_descriptor = 0x70,
service_identifier_descriptor = 0x71,
service_availability_descriptor = 0x72,
default_authority_descriptor = 0x73,
related_content_descriptor = 0x74,
TVA_id_descriptor = 0x75,
content_identifier_descriptor = 0x76,
time_slice_fec_identifier_descriptor = 0x77,
ECM_repetition_rate_descriptor = 0x78,
S2_satellite_delivery_system_descriptor = 0x79,
enhanced_AC_3_descriptor = 0x7a,
DTS_descriptor = 0x7b,
AAC_descriptor = 0x7c,
XAIT_location_descriptor = 0x7d,
FTA_content_management_descriptor = 0x7e,
extension_descriptor = 0x7f,
/* SCTE 35 2004 */
CUE_identifier_descriptor = 0x8a,
extended_channel_name = 0xa0,
service_location = 0xa1,
/* From http://www.etherguidesystems.com/Help/SDOs/ATSC/Semantics/Descriptors/Default.aspx */
component_name_descriptor = 0xa3,
/* From http://www.coolstf.com/tsreader/descriptors.html */
logical_channel_number_descriptor = 0x83,
/* ISDB Descriptors, as defined on ABNT NBR 15603-1 2007 */
carousel_id_descriptor = 0x13,
association_tag_descriptor = 0x14,
deferred_association_tags_descriptor = 0x15,
hierarchical_transmission_descriptor = 0xc0,
digital_copy_control_descriptor = 0xc1,
network_identifier_descriptor = 0xc2,
partial_transport_stream_time_descriptor = 0xc3,
audio_component_descriptor = 0xc4,
hyperlink_descriptor = 0xc5,
target_area_descriptor = 0xc6,
data_contents_descriptor = 0xc7,
video_decode_control_descriptor = 0xc8,
download_content_descriptor = 0xc9,
CA_EMM_TS_descriptor = 0xca,
CA_contract_information_descriptor = 0xcb,
CA_service_descriptor = 0xcc,
TS_Information_descriptor = 0xcd,
extended_broadcaster_descriptor = 0xce,
logo_transmission_descriptor = 0xcf,
basic_local_event_descriptor = 0xd0,
reference_descriptor = 0xd1,
node_relation_descriptor = 0xd2,
short_node_information_descriptor = 0xd3,
STC_reference_descriptor = 0xd4,
series_descriptor = 0xd5,
event_group_descriptor = 0xd6,
SI_parameter_descriptor = 0xd7,
broadcaster_Name_Descriptor = 0xd8,
component_group_descriptor = 0xd9,
SI_prime_TS_descriptor = 0xda,
board_information_descriptor = 0xdb,
LDT_linkage_descriptor = 0xdc,
connected_transmission_descriptor = 0xdd,
content_availability_descriptor = 0xde,
service_group_descriptor = 0xe0,
carousel_compatible_composite_descriptor = 0xf7,
conditional_playback_descriptor = 0xf8,
ISDBT_delivery_system_descriptor = 0xfa,
partial_reception_descriptor = 0xfb,
emergency_information_descriptor = 0xfc,
data_component_descriptor = 0xfd,
system_management_descriptor = 0xfe,
/* ATSC descriptors - ATSC A/65:2009 spec */
atsc_stuffing_descriptor = 0x80,
atsc_ac3_audio_descriptor = 0x81,
atsc_caption_service_descriptor = 0x86,
atsc_content_advisory_descriptor = 0x87,
atsc_extended_channel_descriptor = 0xa0,
atsc_service_location_descriptor = 0xa1,
atsc_time_shifted_service_descriptor = 0xa2,
atsc_component_name_descriptor = 0xa3,
atsc_DCC_departing_request_descriptor = 0xa8,
atsc_DCC_arriving_request_descriptor = 0xa9,
atsc_redistribution_control_descriptor = 0xaa,
atsc_ATSC_private_information_descriptor = 0xad,
atsc_genre_descriptor = 0xab,
};
/*
* NOTE: this is here just to avoid API break. There was a typo
* on the name of this descriptor
*/
#define TS_Information_descriptior TS_Information_descriptor
/* Please see desc_extension.h for extension_descriptor types */
#endif

View File

@@ -0,0 +1,157 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* These routines were originally written as part of the dvb-apps, as:
* util functions for various ?zap implementations
*
* Copyright (C) 2001 Johannes Stezenbach (js@convergence.de)
* for convergence integrated media
*
* Originally licensed as GPLv2 or upper
*/
/**
* @file dvb-demux.h
* @ingroup demux
* @brief Provides interfaces to deal with DVB demux.
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _DVB_DEMUX_H
#define _DVB_DEMUX_H
#include <linux/dvb/dmx.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Opens a DVB demux in read/write mode
* @ingroup demux
*
* @param adapter DVB adapter number to open
* @param demux DVB demux number to open
*
* @details This is a wrapper function to open(). File is always opened in
* blocking mode.
*
* @return Returns a file descriptor on success, -1 otherwise.
*
* @warning Deprecated. Please use dvb_dev_open() instead.
*/
int dvb_dmx_open(int adapter, int demux);
/**
* @brief Stops the DMX filter for the file descriptor and closes
* @ingroup demux
*
* @param dmx_fd File descriptor to close
*
* This is a wrapper function to close().
*
* @warning Deprecated. Please use dvb_dev_close() instead.
*/
void dvb_dmx_close(int dmx_fd);
/**
* @brief Stops the DMX filter for a given file descriptor
* @ingroup demux
*
* @param dmx_fd File descriptor to close
*
* This is a wrapper function to DMX_STOP ioctl.
* See http://linuxtv.org/downloads/v4l-dvb-apis/dvb_demux.html
* for more details.
*
* @warning Deprecated. Please use dvb_dev_dmx_stop() instead.
*/
void dvb_dmx_stop(int dmx_fd);
/**
* @brief Start a filter for a MPEG-TS Packetized Elementary
* Stream (PES)
* @ingroup demux
*
* @param dmxfd File descriptor for the demux device
* @param pid Program ID to filter. Use 0x2000 to select all PIDs
* @param type type of the PID (DMX_PES_VIDEO, DMX_PES_AUDIO,
* DMX_PES_OTHER, etc).
* @param output Where the data will be output (DMX_OUT_TS_TAP,
* DMX_OUT_DECODER, etc).
* @param buffersize Size of the buffer to be allocated to store the filtered data.
*
* This is a wrapper function for DMX_SET_PES_FILTER ioctl.
* See http://linuxtv.org/downloads/v4l-dvb-apis/dvb_demux.html
* for more details.
*
* @return Retuns zero on success, -1 otherwise.
*
* @warning Deprecated. Please use dvb_dev_dmx_set_pesfilter() instead.
*/
int dvb_set_pesfilter(int dmxfd, int pid, dmx_pes_type_t type,
dmx_output_t output, int buffersize);
/**
* @brief Sets a MPEG-TS section filter
* @ingroup demux
*
* @param dmxfd File descriptor for the demux device
* @param pid Program ID to filter. Use 0x2000 to select all PIDs
* @param filtsize Size of the filter (up to 18 btyes)
* @param filter data to filter. Can be NULL or should have filtsize length
* @param mask filter mask. Can be NULL or should have filtsize length
* @param mode mode mask. Can be NULL or should have filtsize length
* @param flags flags for set filter (DMX_CHECK_CRC,DMX_ONESHOT,
* DMX_IMMEDIATE_START).
*
* This is a wrapper function for DMX_SET_FILTER ioctl.
* See http://linuxtv.org/downloads/v4l-dvb-apis/dvb_demux.html
* for more details.
*
* @warning Deprecated. Please use dvb_dev_dmx_set_pesfilter() instead.
*
* @return Retuns zero on success, -1 otherwise.
*
*/
int dvb_set_section_filter(int dmxfd, int pid, unsigned filtsize,
unsigned char *filter,
unsigned char *mask,
unsigned char *mode,
unsigned int flags);
/**
* @brief read the contents of the MPEG-TS PAT table, seeking for
* an specific service ID
* @ingroup demux
*
* @param dmxfd File descriptor for the demux device
* @param sid Session ID to seeking
*
* @warning Deprecated. Please use dvb_get_pmt_pid() instead.
*
* @return At return, it returns a negative value if error or the PID associated with
* the desired Session ID.
*
* @warning This function currently assumes that the PAT fits into one session.
*/
int dvb_get_pmt_pid(int dmxfd, int sid);
#ifdef __cplusplus
}
#endif
#endif

510
include/libdvbv5/dvb-dev.h Normal file
View File

@@ -0,0 +1,510 @@
/*
* Copyright (c) 2016 - Mauro Carvalho Chehab
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
#ifndef _DVB_DEV_H
#define _DVB_DEV_H
#include "dvb-fe.h"
#include "dvb-scan.h"
#include <linux/dvb/dmx.h>
/**
* @file dvb-dev.h
* @ingroup dvb_device
* @brief Provides interfaces to handle Digital TV devices.
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* Digital TV device node file names depend on udev configuration. For
* example, while frontends are typically found at/dev/dvb/adapter?/frontend?,
* the actual file name can vary from system to system, depending on the
* udev ruleset.
*
* The libdvbv5 provides a set of functions to allow detecting and getting
* the device paths in a sane way, via libudev.
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
/**
* @enum dvb_dev_type
* @brief Type of a device entry to search
* @ingroup dvb_device
*
* @param DVB_DEVICE_FRONTEND Digital TV frontend
* @param DVB_DEVICE_DEMUX Digital TV demux
* @param DVB_DEVICE_DVR Digital TV Digital Video Record
* @param DVB_DEVICE_NET Digital TV network interface control
* @param DVB_DEVICE_CA Digital TV Conditional Access
* @param DVB_DEVICE_CA_SEC Digital TV Conditional Access serial
*/
enum dvb_dev_type {
DVB_DEVICE_FRONTEND,
DVB_DEVICE_DEMUX,
DVB_DEVICE_DVR,
DVB_DEVICE_NET,
DVB_DEVICE_CA,
DVB_DEVICE_CA_SEC,
DVB_DEVICE_VIDEO,
DVB_DEVICE_AUDIO,
};
/**
* @struct dvb_dev_list
* @brief Digital TV device node properties
* @ingroup dvb_device
*
* @param path path for the /dev file handler
* @param sysname Kernel's system name for the device (dvb?.frontend?,
* for example)
* @param dvb_type type of the DVB device, as defined by enum dvb_dev_type
* @param bus_addr address of the device at the bus. For USB devices,
* it will be like: usb:3-1.1.4; for PCI devices:
* pci:0000:01:00.0)
* @param bus_id Id of the device at the bus (optional, PCI ID or USB ID)
* @param manufacturer Device's manufacturer name (optional, only on USB)
* @param product Device's product name (optional, only on USB)
* @param serial Device's serial name (optional, only on USB)
*/
struct dvb_dev_list {
char *syspath;
char *path;
char *sysname;
enum dvb_dev_type dvb_type;
char *bus_addr;
char *bus_id;
char *manufacturer;
char *product;
char *serial;
};
/**
* @enum dvb_dev_change_type
* @brief Describes the type of change to be notifier_delay
*
* @param DVB_DEV_ADD New device detected
* @param DVB_DEV_CHANGE Device has changed something
* @param DVB_DEV_REMOVE A hot-pluggable device was removed
*/
enum dvb_dev_change_type {
DVB_DEV_ADD,
DVB_DEV_CHANGE,
DVB_DEV_REMOVE,
};
/**
* @brief Describes a callback for dvb_dev_find()
*
* sysname: Kernel's system name for the device (dvb?.frontend?,
* for example)
* @type: type of change, as defined by enum dvb_dev_change_type
*
* @note: the returned string should be freed with free().
*/
typedef int (*dvb_dev_change_t)(char *sysname,
enum dvb_dev_change_type type, void *priv);
/**
* @struct dvb_open_descriptor
*
* Opaque struct with a DVB open file descriptor
*/
struct dvb_open_descriptor;
/**
* @struct dvb_device
* @brief Digital TV list of devices
* @ingroup dvb_device
*
* @param devices Array with a dvb_dev_list of devices. Each device
* node is a different entry at the list.
* @param num_devices number of elements at the devices array.
*/
struct dvb_device {
/* Digital TV device lists */
struct dvb_dev_list *devices;
int num_devices;
/* Digital TV frontend access */
struct dvb_v5_fe_parms *fe_parms;
};
/**
* @brief Allocate a struct dvb_device
* @ingroup dvb_device
*
* @note Before using the dvb device function calls, the struct dvb_device should
* be allocated via this function call.
*
* @return on success, returns a pointer to the allocated struct dvb_device or
* NULL if not enough memory to allocate the struct.
*/
struct dvb_device *dvb_dev_alloc(void);
/**
* @brief free a struct dvb_device
* @ingroup dvb_device
*
* @param dvb pointer to struct dvb_device to be freed
*/
void dvb_dev_free(struct dvb_device *dvb);
/**
* @brief finds all DVB devices on the local machine
* @ingroup dvb_device
*
* @param dvb pointer to struct dvb_device to be filled
* @param enable_monitor if different than zero put the routine into
* monitor mode
* @param user_priv pointer to user private data
*
* This routine can be called on two modes: normal or monitor mode
*
* In normal mode, it will seek for the local Digital TV devices, store them
* at the struct dvb_device and return.
*
* In monitor mode, it will not only enumerate all devices, but it will also
* keep waiting for device changes. The device seek loop will only be
* interrupted after calling dvb_dev_stop_monitor().
*
* Please notice that, in such mode, the function will wait forever. So, it
* is up to the application to put start a separate thread to handle it in
* monitor mode, and add the needed mutexes to make it thread safe.
*
* @return returns 0 on success, a negative value otherwise.
*/
int dvb_dev_find(struct dvb_device *dvb, dvb_dev_change_t handler,
void *user_priv);
/**
* @brief Find a device that matches the search criteria given by this
* functions's parameters.
*
* @param dvb pointer to struct dvb_device to be used
* @param adapter Adapter number, as defined internally at the Kernel.
* Always start with 0;
* @param num Digital TV device number (e. g. frontend0, net0, etc);
* @param type Type of the device, as given by enum dvb_dev_type;
*
* @return returns a pointer to a struct dvb_dev_list object or NULL if the
* desired device was not found.
*/
struct dvb_dev_list *dvb_dev_seek_by_adapter(struct dvb_device *dvb,
unsigned int adapter,
unsigned int num,
enum dvb_dev_type type);
/**
* @brief Return data about a device from its sysname
*
* @param dvb pointer to struct dvb_device to be used
* @param sysname Kernel's name of the device to be opened, as obtained
* via dvb_dev_seek_by_adapter() or via dvb_dev_find().
*
* @return returns a pointer to a struct dvb_dev_list object or NULL if the
* desired device was not found.
*/
struct dvb_dev_list *dvb_get_dev_info(struct dvb_device *dvb,
const char *sysname);
/**
* @brief Stop the dvb_dev_find loop
* @ingroup dvb_device
*
* @param dvb pointer to struct dvb_device to be used
*
* This function stops dvb_dev_find() if it is running in monitor
* mode. It does nothing on other modes. Can be called even if the
* monitor mode was already stopped.
*/
void dvb_dev_stop_monitor(struct dvb_device *dvb);
/**
* @brief Sets the DVB verbosity and log function with context private data
* @ingroup dvb_device
*
* @param dvb pointer to struct dvb_device to be used
* @param verbose Verbosity level of the messages that will be printed
* @param logfunc Callback function to be called when a log event
* happens. Can either store the event into a file or
* to print it at the TUI/GUI. Can be null.
* @param logpriv Private data for log function
*
* @details Sets the function to report log errors and to set the verbosity
* level of debug report messages. If not called, or if logfunc is
* NULL, the libdvbv5 will report error and debug messages via stderr,
* and will use colors for the debug messages.
*
*/
void dvb_dev_set_logpriv(struct dvb_device *dvb,
unsigned verbose,
dvb_logfunc_priv logfunc, void *logpriv);
/**
* @brief Sets the DVB verbosity and log function
* @ingroup dvb_device
*
* @param dvb pointer to struct dvb_device to be used
* @param verbose Verbosity level of the messages that will be printed
* @param logfunc Callback function to be called when a log event
* happens. Can either store the event into a file or
* to print it at the TUI/GUI. Can be null.
*
* @details Sets the function to report log errors and to set the verbosity
* level of debug report messages. If not called, or if logfunc is
* NULL, the libdvbv5 will report error and debug messages via stderr,
* and will use colors for the debug messages.
*
*/
void dvb_dev_set_log(struct dvb_device *dvb,
unsigned verbose,
dvb_logfunc logfunc);
/**
* @brief Opens a dvb device
* @ingroup dvb_device
*
* @param dvb pointer to struct dvb_device to be used
* @param sysname Kernel's name of the device to be opened, as obtained
* via dvb_dev_seek_by_adapter() or via dvb_dev_find().
* @param flags Flags to be passed to open: O_RDONLY, O_RDWR and/or
* O_NONBLOCK
*
*
* @note Please notice that O_NONBLOCK is not supported for frontend devices,
* and will be silently ignored.
*
* @note the sysname will only work if a previous call to dvb_dev_find()
* is issued.
*
* @details This function is equivalent to open(2) system call: it opens a
* Digital TV given by the dev parameter, using the flags.
*
* @return returns a pointer to the dvb_open_descriptor that should be used
* on further calls if sucess. NULL otherwise.
*/
struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *dvb,
const char *sysname, int flags);
/**
* @brief Closes a dvb device
* @ingroup dvb_device
*
* @param open_dev Points to the struct dvb_open_descriptor to be
* closed.
*/
void dvb_dev_close(struct dvb_open_descriptor *open_dev);
/**
* @brief returns fd from a local device
* This will not work for remote devices.
* @ingroup dvb_device
*
* @param open_dev Points to the struct dvb_open_descriptor
*
* @return On success, returns the fd.
* Returns -1 on error.
*/
int dvb_dev_get_fd(struct dvb_open_descriptor *open_dev);
/**
* @brief read from a dvb demux or dvr file
* @ingroup dvb_device
*
* @param open_dev Points to the struct dvb_open_descriptor to be
* closed.
* @param buf Buffer to store the data
* @param count number of bytes to read
*
* @return On success, returns the number of bytes read. Returns -1 on
* error.
*/
ssize_t dvb_dev_read(struct dvb_open_descriptor *open_dev,
void *buf, size_t count);
/**
* @brief Stops the demux filter for a given file descriptor
* @ingroup dvb_device
*
* @param open_dev Points to the struct dvb_open_descriptor
*
* This is a wrapper function for DMX_STOP ioctl.
*
* See http://linuxtv.org/downloads/v4l-dvb-apis/dvb_demux.html
* for more details.
*
* @note valid only for DVB_DEVICE_DEMUX.
*/
void dvb_dev_dmx_stop(struct dvb_open_descriptor *open_dev);
/**
* @brief Start a demux or dvr buffer size
* @ingroup dvb_device
*
* @param open_dev Points to the struct dvb_open_descriptor
* @param buffersize Size of the buffer to be allocated to store the filtered data.
*
* This is a wrapper function for DMX_SET_BUFFER_SIZE ioctl.
*
* See http://linuxtv.org/downloads/v4l-dvb-apis/dvb_demux.html
* for more details.
*
* @return Retuns zero on success, -1 otherwise.
*
* @note valid only for DVB_DEVICE_DEMUX or DVB_DEVICE_DVR.
*/
int dvb_dev_set_bufsize(struct dvb_open_descriptor *open_dev,
int buffersize);
/**
* @brief Start a filter for a MPEG-TS Packetized Elementary
* Stream (PES)
* @ingroup dvb_device
*
* @param open_dev Points to the struct dvb_open_descriptor
* @param pid Program ID to filter. Use 0x2000 to select all PIDs
* @param type type of the PID (DMX_PES_VIDEO, DMX_PES_AUDIO,
* DMX_PES_OTHER, etc).
* @param output Where the data will be output (DMX_OUT_TS_TAP,
* DMX_OUT_DECODER, etc).
* @param buffersize Size of the buffer to be allocated to store the filtered data.
*
* This is a wrapper function for DMX_SET_PES_FILTER and DMX_SET_BUFFER_SIZE
* ioctls.
*
* See http://linuxtv.org/downloads/v4l-dvb-apis/dvb_demux.html
* for more details.
*
* @return Retuns zero on success, -1 otherwise.
*
* @note valid only for DVB_DEVICE_DEMUX.
*/
int dvb_dev_dmx_set_pesfilter(struct dvb_open_descriptor *open_dev,
int pid, dmx_pes_type_t type,
dmx_output_t output, int buffersize);
/**
* @brief Sets a MPEG-TS section filter
* @ingroup dvb_device
*
* @param open_dev Points to the struct dvb_open_descriptor
* @param pid Program ID to filter. Use 0x2000 to select all PIDs
* @param filtsize Size of the filter (up to 18 btyes)
* @param filter data to filter. Can be NULL or should have filtsize length
* @param mask filter mask. Can be NULL or should have filtsize length
* @param mode mode mask. Can be NULL or should have filtsize length
* @param flags flags for set filter (DMX_CHECK_CRC,DMX_ONESHOT,
* DMX_IMMEDIATE_START).
*
* This is a wrapper function for DMX_SET_FILTER ioctl.
*
* See http://linuxtv.org/downloads/v4l-dvb-apis/dvb_demux.html
* for more details.
*
* @return Retuns zero on success, -1 otherwise.
*
* @note valid only for DVB_DEVICE_DEMUX.
*/
int dvb_dev_dmx_set_section_filter(struct dvb_open_descriptor *open_dev,
int pid, unsigned filtsize,
unsigned char *filter,
unsigned char *mask,
unsigned char *mode,
unsigned int flags);
/**
* @brief read the contents of the MPEG-TS PAT table, seeking for
* an specific service ID
* @ingroup dvb_device
*
* @param open_dev Points to the struct dvb_open_descriptor
* @param sid Session ID to seeking
*
* @return At return, it returns a negative value if error or the PID
* associated with the desired Session ID.
*
* @warning This function currently assumes that the PAT fits into one session.
*
* @note valid only for DVB_DEVICE_DEMUX.
*/
int dvb_dev_dmx_get_pmt_pid(struct dvb_open_descriptor *open_dev, int sid);
/**
* @brief Scans a DVB dvb_add_scaned_transponder
* @ingroup frontend_scan
*
* @param entry DVB file entry that corresponds to a transponder to be
* tuned
* @param open_dev Points to the struct dvb_open_descriptor
* @param check_frontend a pointer to a function that will show the frontend
* status while tuning into a transponder
* @param args a pointer, opaque to libdvbv5, that will be used when
* calling check_frontend. It should contain any parameters
* that could be needed by check_frontend.
* @param other_nit Use alternate table IDs for NIT and other tables
* @param timeout_multiply Improves the timeout for each table reception, by
*
* This is the function that applications should use when doing a transponders
* scan. It does everything needed to fill the entries with DVB programs
* (virtual channels) and detect the PIDs associated with them.
*
* This is the dvb_device variant of dvb_scan_transponder().
*/
struct dvb_v5_descriptors *dvb_dev_scan(struct dvb_open_descriptor *open_dev,
struct dvb_entry *entry,
check_frontend_t *check_frontend,
void *args,
unsigned other_nit,
unsigned timeout_multiply);
/* From dvb-dev-remote.c */
#ifdef HAVE_DVBV5_REMOTE
#define REMOTE_BUF_SIZE (87 * 188) /* 16356 bytes */
/**
* @brief initialize the dvb-dev to use a remote device running the
* dvbv5-daemon.
*
* @param dvb pointer to struct dvb_device to be used
* @param server server hostname or address
* @param port server port
*
* @note The protocol between the dvbv5-daemon and the dvb_dev library is
* highly experimental and is subject to changes in a near future. So,
* while this is not stable enough, you will only work if both the client
* and the server are running the same version of the v4l-utils library.
*/
int dvb_dev_remote_init(struct dvb_device *d, char *server, int port);
#else
static inline int dvb_dev_remote_init(struct dvb_device *d, char *server,
int port)
{
return -1;
};
#endif
#endif

770
include/libdvbv5/dvb-fe.h Normal file
View File

@@ -0,0 +1,770 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#ifndef _DVB_FE_H
#define _DVB_FE_H
#include <stdio.h>
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <string.h>
#include "dvb-frontend.h"
#include "dvb-sat.h"
#include "dvb-log.h"
/**
* @file dvb-fe.h
* @ingroup frontend
* @brief Provides interfaces to deal with DVB frontend.
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* The libdvbv5 API works with a set of key/value properties.
* There are two types of properties:
*
* - The ones defined at the Kernel's frontent API, that are found at
* /usr/include/linux/dvb/frontend.h (actually, it uses a local copy
* of that file, stored at ./include/linux/dvb/frontend.h)
*
* - Some extra properties used by libdvbv5. Those can be found at
* lib/include/libdvbv5/dvb-v5-std.h and start at DTV_USER_COMMAND_START.
*
* Just like the DTV properties, the stats are cached. That warrants that
* all stats are got at the same time, when dvb_fe_get_stats() is called.
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
/**
* @def ARRAY_SIZE(array)
* @brief Calculates the number of elements of an array
* @ingroup ancillary
*/
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
/**
* @def MAX_DELIVERY_SYSTEMS
* @brief Max number of delivery systems for a given frontend.
* @ingroup frontend
*/
#define MAX_DELIVERY_SYSTEMS 20
#ifndef _DOXYGEN
/*
* There are a few aliases for other properties. Those are needed just
* to avoid breaking apps that depend on the library but shoudn't be used
* anymore on newer apps.
*/
#define DTV_MAX_STATS DTV_NUM_STATS_PROPS
#define DTV_SIGNAL_STRENGTH DTV_STAT_SIGNAL_STRENGTH
#define DTV_SNR DTV_STAT_CNR
#define DTV_UNCORRECTED_BLOCKS DTV_STAT_ERROR_BLOCK_COUNT
#endif
/**
* @struct dvb_v5_fe_parms
* @ingroup frontend
* @brief Keeps data needed to handle the DVB frontend
*
* @param info Contains the DVB info properties (RO)
* @param version Version of the Linux DVB API (RO)
* @param has_v5_stats A value different than 0 indicates that the
* frontend supports DVBv5 stats (RO)
* @param current_sys Currently selected delivery system (RO)
* @param num_systems Number of delivery systems (RO)
* @param systems Delivery systems supported by the hardware (RO)
* @param legacy_fe A value different than 0 indicates a legacy
* Kernel driver using DVBv3 API only, or that
* DVBv3 only mode was forced by the client (RO)
* @param abort Client should set it to abort a pending
* operation like DTV scan (RW)
* @param lna: Sets the LNA mode 0 disables; 1 enables, -1 uses
* auto mode (RW)
* @param lnb LNBf description (RW)
* @param sat_number Number of the satellite (used by DISEqC setup) (RW)
* @param freq_bpf SCR/Unicable band-pass filter frequency to use, in kHz
* @param verbose Verbosity level of the library (RW)
* @param dvb_logfunc Function used to write log messages (RO)
* @param default_charset Name of the charset used by the DVB standard (RW)
* @param output_charset Name of the charset to output (system specific) (RW)
*
* @details The fields marked as RO should not be changed by the client, as otherwise
* undesired effects may happen. The ones marked as RW are ok to either read
* or write by the client.
*/
struct dvb_v5_fe_parms {
/* Information visible to the client - don't override those values */
struct dvb_frontend_info info;
uint32_t version;
int has_v5_stats;
fe_delivery_system_t current_sys;
int num_systems;
fe_delivery_system_t systems[MAX_DELIVERY_SYSTEMS];
int legacy_fe;
/* The values below are specified by the library client */
/* Flags from the client to the library */
int abort;
/* Linear Amplifier settings */
int lna;
/* Satellite settings */
const struct dvb_sat_lnb *lnb;
int sat_number;
unsigned freq_bpf;
unsigned diseqc_wait;
/* Function to write DVB logs */
unsigned verbose;
dvb_logfunc logfunc;
/* Charsets to be used by the conversion utilities */
char *default_charset;
char *output_charset;
};
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Allocates a dummy frontend structure
* @ingroup frontend
*
* @details This is useful for some applications that may want to just use the
* frontend structure internally, without associating it with a real hardware
*
* @return Returns a pointer to a dummy struct, or NULL if no memory.
*/
struct dvb_v5_fe_parms *dvb_fe_dummy(void);
/**
* @brief Opens a frontend and allocates a structure to work with
* @ingroup frontend
*
* @param adapter Number of the adapter to open
* @param frontend Number of the frontend to open
* @param verbose Verbosity level of the messages that will be
* printed
* @param use_legacy_call Force to use the DVBv3 calls, instead of using
* the DVBv5 API
* @param logfunc Callback function to be called when a log event
* happens. Can either store the event into a file
* or to print it at the TUI/GUI. If NULL, the
* library will use its internal handler.
* @param flags Flags to be passed to open. Currently only two
* flags are supported: O_RDONLY or O_RDWR.
* Using O_NONBLOCK may hit unexpected issues.
*
* @todo Add/check support for O_NONBLOCK at the scan routines.
*
* @details This function should be called before using any other function at
* the frontend library (or the other alternatives: dvb_fe_open() or
* dvb_fe_dummy().
*
* In general, this is called using O_RDWR, except if all that it is wanted
* is to check the DVB frontend statistics.
*
* @return Returns a pointer to an allocated data pointer or NULL on error.
*/
struct dvb_v5_fe_parms *dvb_fe_open_flags(int adapter, int frontend,
unsigned verbose,
unsigned use_legacy_call,
dvb_logfunc logfunc,
int flags);
/**
* @brief Opens a frontend and allocates a structure to work with
* @ingroup frontend
*
* @param adapter Number of the adapter to open
* @param frontend Number of the frontend to open
* @param verbose Verbosity level of the messages that will be
* printed
* @param use_legacy_call Force to use the DVBv3 calls, instead of using
* the DVBv5 API
*
* @details This function should be called before using any other function at
* the frontend library (or the other alternatives: dvb_fe_open2() or
* dvb_fe_dummy().
*
* @return Returns a pointer to an allocated data pointer or NULL on error.
*/
struct dvb_v5_fe_parms *dvb_fe_open(int adapter, int frontend,
unsigned verbose,
unsigned use_legacy_call);
/**
* @brief Opens a frontend and allocates a structure to work with
* @ingroup frontend
*
* @param adapter Number of the adapter to open
* @param frontend Number of the frontend to open
* @param verbose Verbosity level of the messages that will be
* printed
* @param use_legacy_call Force to use the DVBv3 calls, instead of using
* the DVBv5 API
* @param logfunc Callback function to be called when a log event
* happens. Can either store the event into a file
* or to print it at the TUI/GUI.
*
* @details This function should be called before using any other function at
* the frontend library (or the other alternatives: dvb_fe_open() or
* dvb_fe_dummy().
*
* @return Returns a pointer to an allocated data pointer or NULL on error.
*/
struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend,
unsigned verbose, unsigned use_legacy_call,
dvb_logfunc logfunc);
/**
* @brief Closes the frontend and frees allocated resources
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
*/
void dvb_fe_close(struct dvb_v5_fe_parms *parms);
/**
* @brief Returns the string name associated with a DVBv5 command
* @ingroup frontend
*
* @param cmd DVBv5 or libdvbv5 property
*
* @details This function gets an integer argument (cmd) and returns a string
* that corresponds to the name of that property.
*
* @return it returns a string that corresponds to the property name.
* For example:
* dvb_cmd_name(DTV_GUARD_INTERVAL) would return "GUARD_INTERVAL"
* It also returns names for the properties used internally by libdvbv5.
*/
const char *dvb_cmd_name(int cmd);
/**
* @brief Returns an string array with the valid string values associated with a DVBv5 command
* @ingroup frontend
*
* @param cmd DVBv5 or libdvbv5 property
*
* @return it returns a string array that corresponds to the names associated
* with the possible values for that property, when available.
* For example:
* dvb_cmd_name(DTV_CODE_RATE_HP) would return an array with the
* possible values for the code rates:
* { "1/2", "2/3", ... NULL }
* @note The array always ends with NULL.
*/
const char *const *dvb_attr_names(int cmd);
/* Get/set delivery system parameters */
/**
* @brief Retrieves the value of a DVBv5/libdvbv5 property
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param cmd DVBv5 or libdvbv5 property
* @param value Pointer to an uint32_t where the value will be stored.
*
* This reads the value of a property stored at the cache. Before using it,
* a dvb_fe_get_parms() is likely required.
*
* @return Return 0 if success, EINVAL otherwise.
*/
int dvb_fe_retrieve_parm(const struct dvb_v5_fe_parms *parms,
unsigned cmd, uint32_t *value);
/**
* @brief Stores the value of a DVBv5/libdvbv5 property
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param cmd DVBv5 or libdvbv5 property
* @param value Pointer to an uint32_t where the value will be stored.
*
* This stores the value of a property at the cache. The value will only
* be send to the hardware after calling dvb_fe_set_parms().
*
* @return Return 0 if success, EINVAL otherwise.
*/
int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms,
unsigned cmd, uint32_t value);
/**
* @brief Sets the delivery system
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param sys delivery system to be selected
*
* This function changes the delivery system of the frontend. By default,
* the libdvbv5 will use the first available delivery system. If another
* delivery system is desirable, this function should be called before being
* able to store the properties for the new delivery system via
* dvb_fe_store_parm().
*
* @return Return 0 if success, EINVAL otherwise.
*/
int dvb_set_sys(struct dvb_v5_fe_parms *parms,
fe_delivery_system_t sys);
/**
* @brief Make dvb properties reflect the current standard
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param sys delivery system to be selected
*
* This function prepares the properties cache for a given delivery system.
*
* It is automatically called by dvb_set_sys(), and should not be normally
* called, except when dvb_fe_dummy() is used.
*
* @return Return 0 if success, EINVAL otherwise.
*/
int dvb_add_parms_for_sys(struct dvb_v5_fe_parms *parms,
fe_delivery_system_t sys);
/**
* @brief Sets the delivery system
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened
* device
* @param desired_system delivery system to be selected
*
* This function changes the delivery system of the frontend. By default,
* the libdvbv5 will use the first available delivery system. If another
* delivery system is desirable, this function should be called before being
* able to store the properties for the new delivery system via
* dvb_fe_store_parm().
*
* This function is an enhanced version of dvb_set_sys(). It has an special
* logic inside to work with Kernels that supports only DVBv3.
*
* @return Return 0 if success, EINVAL otherwise.
*/
int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms,
uint32_t desired_system);
/**
* @brief Prints all the properties at the cache
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
*
* Used mostly for debugging issues.
*/
void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms);
/**
* @brief Prints all the properties at the cache
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
*
* Writes the properties stored at the DVB cache at the DVB hardware. At
* return, some properties could have a different value, as the frontend
* may not support the values set.
*
* @return Return 0 if success, EINVAL otherwise.
*/
int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms);
/**
* @brief Prints all the properties at the cache
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
*
* Gets the properties from the DVB hardware. The values will only reflect
* what's set at the hardware if the frontend is locked.
*
* @return Return 0 if success, EINVAL otherwise.
*/
int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms);
/*
* statistics functions
*/
/**
* @brief Retrieve the stats for a DTV layer from cache
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param cmd DVBv5 or libdvbv5 property
* @param layer DTV layer
*
* Gets the value for one stats cache, on a given layer. Layer 0 is
* always present. On DTV standards that doesn't have layers, it returns
* the same value as dvb_fe_retrieve_stats() for layer = 0.
*
* For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A',
* layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all
* frontends support per-layer stats. Also, the layer value is only valid if
* the layer exists at the original stream.
* Also, on such standards, layer 0 is typically a mean value of the layers,
* or a sum of events (if FE_SCALE_COUNTER).
*
* For it to be valid, dvb_fe_get_stats() should be called first.
*
* @return It returns a struct dtv_stats if succeed or NULL otherwise.
*/
struct dtv_stats *dvb_fe_retrieve_stats_layer(struct dvb_v5_fe_parms *parms,
unsigned cmd, unsigned layer);
/**
* @brief Retrieve the stats for a DTV layer from cache
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param cmd DVBv5 or libdvbv5 property
* @param value DTV value pointer
*
* Gets the value for one stats property for layer = 0.
*
* For it to be valid, dvb_fe_get_stats() should be called first.
*
* @return The returned value is 0 if success, EINVAL otherwise.
*/
int dvb_fe_retrieve_stats(struct dvb_v5_fe_parms *parms,
unsigned cmd, uint32_t *value);
/**
* @brief Retrieve the stats from the Kernel
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
*
* Updates the stats cache from the available stats at the Kernel.
*
* @return The returned value is 0 if success, EINVAL otherwise.
*/
int dvb_fe_get_stats(struct dvb_v5_fe_parms *parms);
/**
* @brief Retrieve the BER stats from cache
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param layer DTV layer
* @param scale retrieves the scale
*
* Gets the value for BER stats from stats cache, on a given layer. Layer 0 is
* always present. On DTV standards that doesn't have layers, it returns
* the same value as dvb_fe_retrieve_stats() for layer = 0.
*
* For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A',
* layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all
* frontends support per-layer stats. Also, the layer value is only valid if
* the layer exists at the original stream.
* Also, on such standards, layer 0 is typically a mean value of the layers,
* or a sum of events (if FE_SCALE_COUNTER).
*
* For it to be valid, dvb_fe_get_stats() should be called first.
*
* @return It returns a float number for the BER value.
* If the statistics is not available for any reason, scale will be equal to
* FE_SCALE_NOT_AVAILABLE.
*/
float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer,
enum fecap_scale_params *scale);
/**
* @brief Retrieve the PER stats from cache
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param layer DTV layer
*
* Gets the value for BER stats from stats cache, on a given layer. Layer 0 is
* always present. On DTV standards that doesn't have layers, it returns
* the same value as dvb_fe_retrieve_stats() for layer = 0.
*
* For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A',
* layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all
* frontends support per-layer stats. Also, the layer value is only valid if
* the layer exists at the original stream.
* Also, on such standards, layer 0 is typically a mean value of the layers,
* or a sum of events (if FE_SCALE_COUNTER).
*
* For it to be valid, dvb_fe_get_stats() should be called first.
*
* @return A negative value indicates error.
*/
float dvb_fe_retrieve_per(struct dvb_v5_fe_parms *parms, unsigned layer);
/**
* @brief Retrieve the quality stats from cache
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param layer DTV layer
*
* Gets a quality measure for a given layer. Layer 0 is
* always present. On DTV standards that doesn't have layers, it returns
* the same value as dvb_fe_retrieve_stats() for layer = 0.
*
* For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A',
* layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all
* frontends support per-layer stats. Also, the layer value is only valid if
* the layer exists at the original stream.
* Also, on such standards, layer 0 is typically a mean value of the layers,
* or a sum of events (if FE_SCALE_COUNTER).
*
* For it to be valid, dvb_fe_get_stats() should be called first.
*
* @return returns an enum dvb_quantity, where DVB_QUAL_UNKNOWN means that
* the stat isnot available.
*/
enum dvb_quality dvb_fe_retrieve_quality(struct dvb_v5_fe_parms *parms,
unsigned layer);
/**
* @brief Ancillary function to sprintf on ENG format
* @ingroup frontend
*
* @param buf buffer to store the value
* @param len buffer length
* @param val value to be printed
*
* On ENG notation, the exponential value should be multiple of 3. This is
* good to display some values, like BER.
*
* @return At return, it shows the actual size of the print. A negative value
* indicates an error.
*/
int dvb_fe_snprintf_eng(char *buf, int len, float val);
/**
* @brief Ancillary function to sprintf on ENG format
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param cmd DVBv5 or libdvbv5 property
* @param display_name String with the name of the property to be shown
* @param layer DTV Layer
* @param buf buffer to store the value
* @param len buffer length
* @param show_layer_name a value different than zero shows the layer name, if
* the layer is bigger than zero.
*
* This function calls internally dvb_fe_retrieve_stats_layer(). It allows to
* print a DVBv5 statistics value into a string. An extra property is available
* (DTV_QUALITY) with prints either one of the values: Poor, Ok or Good,
* depending on the overall measures.
*
* @return: It returns the length of the printed data. A negative value
* indicates an error.
*/
int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *parms, uint32_t cmd,
char *display_name, int layer,
char **buf, int *len, int *show_layer_name);
/**
* @brief Get both status statistics and dvb parameters
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
*
* That's similar of calling both dvb_fe_get_parms() and dvb_fe_get_stats().
*
* @return It returns 0 if success or an errorno otherwise.
*/
int dvb_fe_get_event(struct dvb_v5_fe_parms *parms);
/*
* Other functions, associated to SEC/LNB/DISEqC
*
* The functions below are just wrappers for the Kernel calls, in order to
* manually control satellite systems.
*
* Instead of using most them, the best is to set the LNBf parameters, and let
* the libdvbv5 to automatically handle the calls.
*
* NOTE: It currently lacks support for two ioctl's:
* FE_DISEQC_RESET_OVERLOAD used only on av7110.
* Spec says:
* If the bus has been automatically powered off due to power overload,
* this ioctl call restores the power to the bus. The call requires read/write
* access to the device. This call has no effect if the device is manually
* powered off. Not all DVB adapters support this ioctl.
*
* FE_DISHNETWORK_SEND_LEGACY_CMD is used on av7110, budget, gp8psk and stv0299
* Spec says:
* WARNING: This is a very obscure legacy command, used only at stv0299
* driver. Should not be used on newer drivers.
* It provides a non-standard method for selecting Diseqc voltage on the
* frontend, for Dish Network legacy switches.
* As support for this ioctl were added in 2004, this means that such dishes
* were already legacy in 2004.
*
* So, it doesn't make much sense on implementing support for them.
*/
/**
* @brief DVB ioctl wrapper for setting SEC voltage
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param on a value different than zero indicates to enable
* voltage on a Satellite Equipment Control (SEC)
* @param v18 if on != 0, a value different than zero means 18 Volts;
* zero means 13 Volts.
*
* If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
*/
int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18);
/**
* @brief DVB ioctl wrapper for setting SEC tone
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param tone tone setting, as defined by DVB fe_sec_tone_mode_t type
*
* If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
*/
int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone);
/**
* @brief DVB ioctl wrapper for setting LNBf high voltage
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param on a value different than zero indicates to produce
* lightly higher voltages instead of 13/18V, in order
* to compensate for long cables.
*/
int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on);
/**
* @brief DVB ioctl wrapper for setting SEC DiSeqC tone burst to select between
* satellite A or B
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param mini_b if different than zero, sends a 22 KHz tone burst to
* select satellite B. Otherwise, sends tone to select
* satellite A.
*
* Valid only on certain DISEqC arrangements.
*
* If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
*/
int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *parms, int mini_b);
/**
* @brief DVB ioctl wrapper for setting SEC DiSeqC command
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param len size of the DiSEqC command
* @param buf DiSEqC command to be sent
*
* If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
*/
int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *parms, const unsigned len,
const unsigned char *buf);
/**
* @brief DVB ioctl wrapper for getting SEC DiSEqC reply
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param len size of the DiSEqC command
* @param buf DiSEqC command to be sent
* @param timeout maximum time to receive the command, in ms.
*
* If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
*/
int dvb_fe_diseqc_reply(struct dvb_v5_fe_parms *parms, unsigned *len, char *buf,
int timeout);
/**
* @brief DVB Ancillary routine to check if a given Delivery system is satellite
* @ingroup frontend
*
* @param delivery_system delivery system to be selected
*/
int dvb_fe_is_satellite(uint32_t delivery_system);
/**
* @brief Set default country variant of delivery systems like ISDB-T
* @ingroup frontend
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param country default country, in ISO 3166-1 two letter code. If
* NULL, default charset is guessed from locale environment
* variables.
*
* @return 0 if success or an errorno otherwise.
*
* "COUNTRY" property in dvb_fe_set_parm() overrides the setting.
*/
int dvb_fe_set_default_country(struct dvb_v5_fe_parms *parms,
const char *country);
#ifdef __cplusplus
}
#endif
/*
* Arrays from dvb-v5.h
*
* Those arrays can be used to translate from a DVB property into a name.
*
* No need to directly access them from userspace, as dvb_attr_names()
* already handles them into a more standard way.
*/
#ifndef _DOXYGEN
extern const unsigned fe_bandwidth_name[8];
extern const char *dvb_v5_name[72];
extern const void *dvb_v5_attr_names[];
extern const char *delivery_system_name[20];
extern const char *fe_code_rate_name[14];
extern const char *fe_modulation_name[15];
extern const char *fe_transmission_mode_name[10];
extern const unsigned fe_bandwidth_name[8];
extern const char *fe_guard_interval_name[12];
extern const char *fe_hierarchy_name[6];
extern const char *fe_voltage_name[4];
extern const char *fe_tone_name[3];
extern const char *fe_inversion_name[4];
extern const char *fe_pilot_name[4];
extern const char *fe_rolloff_name[5];
#endif
#endif

520
include/libdvbv5/dvb-file.h Normal file
View File

@@ -0,0 +1,520 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
*/
#ifndef _DVB_FILE_H
#define _DVB_FILE_H
#include "dvb-fe.h"
/**
* @file dvb-file.h
* @ingroup file
* @brief Provides interfaces to deal with DVB channel and program files.
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* There are basically two types of files used for DVB:
* - files that describe the physical channels (also called as transponders);
* - files that describe the several programs found on a MPEG-TS (also called
* as zap files).
*
* The libdvbv5 library defines an unified type for both types. Other
* applications generally use different formats.
*
* The purpose of the functions and structures defined herein is to provide
* support to read and write to those different formats.
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
/*
* DVB structures used to represent all files opened by the libdvbv5 library.
*
* Those structs represents each individual entry on a file, and the file
* as a whole.
*/
/**
* @struct dvb_elementary_pid
* @brief associates an elementary stream type with its PID
* @ingroup file
*
* @param type Elementary stream type
* @param pid Elementary stream Program ID
*/
struct dvb_elementary_pid {
uint8_t type;
uint16_t pid;
};
/**
* @struct dvb_entry
* @brief Represents one entry on a DTV file
* @ingroup file
*
* @param props A property key/value pair. The keys are the ones
* specified at the DVB API, plus the ones defined
* internally by libdvbv5, at the dvb-v5-std.h
* header file.
* @param next a pointer to the next entry. NULL if this is
* the last one.
* @param service_id Service ID associated with a program inside a
* transponder. Please note that pure "channel"
* files will have this field filled with 0.
* @param video_pid Array with the video program IDs inside a service
* @param audio_pid Array with the audio program IDs inside a service
* @param other_el_pid Array with all non-audio/video program IDs
* inside a service
* @param video_pid_len Size of the video_pid array
* @param audio_pid_len Size of the audio_pid array
* @param other_el_pid_len Size of the other_el_pid array
* @param channel String containing the name of the channel
* @param vchannel String representing the Number of the channel
* @param location String representing the location of the channel
* @param sat_number For satellite streams, this represents the
* number of the satellite dish on a DiSeqC
* arrangement. Should be zero on arrangements
* without DiSeqC.
* @param freq_bpf SCR/Unicable band-pass filter frequency to
* use, in kHz.
* For non SRC/Unicable arrangements, it should
* be zero.
* @param diseqc_wait Extra time to wait for DiSeqC commands to
* complete, in ms. The library will use 15 ms
* as the minimal time,
* plus the time specified on this field.
* @param lnb String with the name of the LNBf to be used for
* satellite tuning. The names should match the
* names provided by dvb_sat_get_lnb() call
* (see dvb-sat.h).
*/
struct dvb_entry {
struct dtv_property props[DTV_MAX_COMMAND];
unsigned int n_props;
struct dvb_entry *next;
uint16_t service_id;
uint16_t *video_pid, *audio_pid;
struct dvb_elementary_pid *other_el_pid;
unsigned video_pid_len, audio_pid_len, other_el_pid_len;
char *channel;
char *vchannel;
char *location;
int sat_number;
unsigned freq_bpf;
unsigned diseqc_wait;
char *lnb;
uint16_t network_id;
uint16_t transport_id;
};
/**
* @struct dvb_file
* @brief Describes an entire DVB file opened
*
* @param fname name of the file
* @param n_entries number of the entries read
* @param first_entry entry for the first entry. NULL if the file is empty.
*/
struct dvb_file {
char *fname;
int n_entries;
struct dvb_entry *first_entry;
};
/*
* DVB file format tables
*
* The structs below are used to represent oneline formats like the ones
* commonly found on DVB legacy applications.
*/
/**
* @struct dvb_parse_table
* @brief Describes the fields to parse on a file
* @ingroup file
*
* @param prop Name of the DVBv5 or libdvbv5 property field
* @param table Name of a translation table for string to
* int conversion
* @param size Size of the translation table
* @param mult_factor Multiply factor - Used, for example, to
* multiply the symbol rate read from a DVB-S
* table by 1000.
* @param has_default_value It is different than zero when the property
* can be optional. In this case, the next field
* should be present
* @param default_value Default value for the optional field
*/
struct dvb_parse_table {
unsigned int prop;
const char **table;
unsigned int size;
int mult_factor;
int has_default_value;
int default_value;
};
/**
* @struct dvb_parse_struct
* @brief Describes the format to parse an specific delivery system
* @ingroup file
*
* @param id String that identifies the delivery system on the
* file to be parsed
* @param delsys Delivery system
* @param table the struct dvb_parse_table used to parse for this
* specific delivery system
* @param size Size of the table
*/
struct dvb_parse_struct {
char *id;
uint32_t delsys;
const struct dvb_parse_table *table;
unsigned int size;
};
/**
* @struct dvb_parse_file
* @brief Describes an entire file format
*
* @param has_delsys_id A non-zero value indicates that the id field
* at the formats vector should be used
* @param delimiter Delimiters to split entries on the format
* @param formats A struct dvb_parse_struct vector with the
* per delivery system parsers. This table should
* terminate with an empty entry.
*/
struct dvb_parse_file {
int has_delsys_id;
char *delimiter;
struct dvb_parse_struct formats[];
};
/**
* @enum dvb_file_formats
* @brief Known file formats
* @ingroup file
*
* @details
* Please notice that the channel format defined here has a few optional
* fields that aren't part of the dvb-apps format, for DVB-S2 and for DVB-T2.
* They're there to match the formats found at dtv-scan-tables package up to
* September, 5 2014.
*
* @var FILE_UNKNOWN
* @brief File format is unknown
* @var FILE_ZAP
* @brief File is at the dvb-apps "dvbzap" format
* @var FILE_CHANNEL
* @brief File is at the dvb-apps output format for dvb-zap
* @var FILE_DVBV5
* @brief File is at libdvbv5 format
* @var FILE_VDR
* @brief File is at DVR format (as supported on version 2.1.6).
* Note: this is only supported as an output format.
*/
enum dvb_file_formats {
FILE_UNKNOWN,
FILE_ZAP,
FILE_CHANNEL,
FILE_DVBV5,
FILE_VDR,
};
struct dvb_v5_descriptors;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Deallocates memory associated with a struct dvb_file
* @ingroup file
*
* @param dvb_file dvb_file struct to be deallocated
*
* This function assumes that several functions were dynamically allocated
* by the library file functions.
*/
static inline void dvb_file_free(struct dvb_file *dvb_file)
{
struct dvb_entry *entry = dvb_file->first_entry, *next;
while (entry) {
next = entry->next;
if (entry->channel)
free(entry->channel);
if (entry->vchannel)
free(entry->vchannel);
if (entry->location)
free(entry->location);
if (entry->video_pid)
free(entry->video_pid);
if (entry->audio_pid)
free(entry->audio_pid);
if (entry->other_el_pid)
free(entry->other_el_pid);
if (entry->lnb)
free(entry->lnb);
free(entry);
entry = next;
}
free(dvb_file);
}
/*
* File format description structures defined for the several formats that
* the library can read natively.
*/
/**
* @brief File format definitions for dvb-apps channel format
* @ingroup file
*/
extern const struct dvb_parse_file channel_file_format;
/**
* @brief File format definitions for dvb-apps zap format
* @ingroup file
*/
extern const struct dvb_parse_file channel_file_zap_format;
/*
* Prototypes for the several functions defined at dvb-file.c
*/
/**
* @brief Read a file at libdvbv5 format
* @ingroup file
*
* @param fname file name
*
* @return It returns a pointer to struct dvb_file describing the entries that
* were read from the file. If it fails, NULL is returned.
*/
struct dvb_file *dvb_read_file(const char *fname);
/**
* @brief Write a file at libdvbv5 format
* @ingroup file
*
* @param fname file name
* @param dvb_file contents of the file to be written
*
* @return It returns zero if success, or a positive error number if it fails.
*/
int dvb_write_file(const char *fname, struct dvb_file *dvb_file);
/**
* @brief Read a file on any format natively supported by
* the library
* @ingroup file
*
* @param fname file name
* @param delsys Delivery system, as specified by enum fe_delivery_system
* @param format Name of the format to be read
*
* @return It returns a pointer to struct dvb_file describing the entries that
* were read from the file. If it fails, NULL is returned.
*/
struct dvb_file *dvb_read_file_format(const char *fname,
uint32_t delsys,
enum dvb_file_formats format);
/**
* @brief Write a file on any format natively supported by
* the library
* @ingroup file
*
* @param fname file name
* @param dvb_file contents of the file to be written
* @param delsys Delivery system, as specified by enum fe_delivery_system
* @param format Name of the format to be read
*
* @return It a pointer to struct dvb_file on success, NULL otherwise.
*/
int dvb_write_file_format(const char *fname,
struct dvb_file *dvb_file,
uint32_t delsys,
enum dvb_file_formats format);
/**
* @brief Stores a key/value pair on a DVB file entry
* @ingroup file
*
* @param entry entry to be filled
* @param cmd key for the property to be used. It be one of the DVBv5
* properties, plus the libdvbv5 ones, as defined at dvb-v5-std.h
* @param value value for the property.
*
* This function seeks for a property with the name specified by cmd and
* fills it with value. If the entry doesn't exist, it creates a new key.
*
* @return Returns 0 if success, or, if the entry has already DTV_MAX_COMMAND
* properties, it returns -1.
*/
int dvb_store_entry_prop(struct dvb_entry *entry,
uint32_t cmd, uint32_t value);
/**
* @brief Retrieves the value associated witha key on a DVB file entry
* @ingroup file
*
* @param entry entry to be used
* @param cmd key for the property to be found. It be one of the DVBv5
* properties, plus the libdvbv5 ones, as defined at dvb-v5-std.h
* @param value pointer to store the value associated with the property.
*
* This function seeks for a property with the name specified by cmd and
* fills value with its contents.
*
* @return Returns 0 if success, or, -1 if the entry doesn't exist.
*/
int dvb_retrieve_entry_prop(struct dvb_entry *entry,
uint32_t cmd, uint32_t *value);
/**
* @brief stored a new scanned channel into a dvb_file struct
* @ingroup file
*
* @param dvb_file file struct to be filled
* @param parms struct dvb_v5_fe_parms used by libdvbv5 frontend
* @param dvb_desc struct dvb_desc as described at descriptors.h, filled
* with the descriptors associated with a DVB channel.
* those descriptors can be filled by calling one of the
* scan functions defined at dvb-sat.h.
* @param get_detected if different than zero, uses the frontend parameters
* obtained from the device driver (such as modulation,
* FEC, etc)
* @param get_nit if true, uses the parameters obtained from the MPEG-TS
* NIT table to add newly detected transponders.
*
* This function should be used to store the services found on a scanned
* transponder. Initially, it copies the same parameters used to set the
* frontend, that came from a file where the Service ID and Elementary Stream
* PIDs are unknown. At tuning time, it is common to set the device to tune
* on auto-detection mode (e. g. using QAM/AUTO, for example, to autodetect
* the QAM modulation). The libdvbv5's logic will be to check the detected
* values. So, the modulation might, for example, have changed to QAM/256.
* In such case, if get_detected is 0, it will store QAM/AUTO at the struct.
* If get_detected is different than zero, it will store QAM/256.
* If get_nit is different than zero, and if the MPEG-TS has info about other
* physical channels/transponders, this function will add newer entries to
* dvb_file, for it to seek for new transponders. This is very useful especially
* for DVB-C, where all transponders belong to the same operator. Knowing one
* frequency is generally enough to get all DVB-C transponders.
*
* @return Returns 0 if success, or, -1 if error.
*/
int dvb_store_channel(struct dvb_file **dvb_file,
struct dvb_v5_fe_parms *parms,
struct dvb_v5_descriptors *dvb_desc,
int get_detected, int get_nit);
/**
* @brief Ancillary function that seeks for a delivery system
* @ingroup file
*
* @param name string containing the name of the Delivery System to seek
*
* If the name is found, this function returns the DVBv5 property that
* corresponds to the string given. The function is case-insensitive, and
* it can check for alternate ways to write the name of a Delivery System.
* Currently, it supports: DVB-C, DVB-H, DVB-S, DVB-S2, DVB-T, DVB-T2,
* ISDB-C, ISDB-S, ISDB-T, ATSC-MH, DVBC/ANNEX_A, DVBC/ANNEX_B, DVBT, DSS,
* DVBS, DVBS2, DVBH, ISDBT, ISDBS, ISDBC, ATSC, ATSCMH, DTMB, CMMB, DAB,
* DVBT2, TURBO, DVBC/ANNEX_C.
* Please notice that this doesn't mean that all those standards are properly
* supported by the library.
*
* @return Returns the Delivery System property number if success, -1 if error.
*/
int dvb_parse_delsys(const char *name);
/**
* @brief Ancillary function that parses the name of a file format
* @ingroup file
*
* @param name string containing the name of the format
* Current valid names are: ZAP, CHANNEL, VDR and DVBV5.
* The name is case-insensitive.
*
* @return It returns FILE_ZAP, FILE_CHANNEL, FILE_VDR or FILE_DVBV5
* if the name was translated. FILE_UNKNOWN otherwise.
*/
enum dvb_file_formats dvb_parse_format(const char *name);
/*
* Routines to read a non-libdvbv5 format. They're called by
* dvb_read_file_format() or dvb_write_file_format()
*/
/**
* @brief Read and parses a one line file format
* @ingroup file
*
* @param fname file name
* @param delsys delivery system
* @param parse_file pointer struct dvb_parse_file
*
* @return It a pointer to struct dvb_file on success, NULL otherwise.
*
* This function is called internally by dvb_read_file_format.
*/
struct dvb_file *dvb_parse_format_oneline(const char *fname,
uint32_t delsys,
const struct dvb_parse_file *parse_file);
/**
* @brief Writes a file into an one line file format
* @ingroup file
*
* @param fname file name
* @param dvb_file contents of the file to be written
* @param delsys delivery system
* @param parse_file pointer struct dvb_parse_file
*
* @return It returns zero if success, or a positive error number if it fails.
*
* This function is called internally by dvb_write_file_format.
*/
int dvb_write_format_oneline(const char *fname,
struct dvb_file *dvb_file,
uint32_t delsys,
const struct dvb_parse_file *parse_file);
/**
* @brief Writes a file into vdr format (compatible up to version 2.1)
* @ingroup file
*
* @param fname file name
* @param dvb_file contents of the file to be written
*
* @return It returns zero if success, or a positive error number if it fails.
*
* This function is called internally by dvb_write_file_format.
*/
int dvb_write_format_vdr(const char *fname,
struct dvb_file *dvb_file);
#ifdef __cplusplus
}
#endif
#endif // _DVB_FILE_H

View File

File diff suppressed because it is too large Load Diff

110
include/libdvbv5/dvb-log.h Normal file
View File

@@ -0,0 +1,110 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#ifndef _LOG_H
#define _LOG_H
#include <syslog.h>
/**
* @file dvb-log.h
* @ingroup ancillary
* @brief Provides interfaces to handle libdvbv5 log messages.
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
/**
* @typedef void (*dvb_logfunc)(int level, const char *fmt, ...)
* @brief typedef used by dvb_fe_open2 for the log function
* @ingroup ancillary
*/
typedef void (*dvb_logfunc)(int level, const char *fmt, ...) __attribute__ (( format( printf, 2, 3 )));
/**
* @typedef void (*dvb_logfunc)(void *logpriv, int level, const char *fmt, ...)
* @brief typedef used by dvb_fe_open2 for the log function with private context
* @ingroup ancillary
*/
typedef void (*dvb_logfunc_priv)(void *logpriv, int level, const char *fmt, ...);
/*
* Macros used internally inside libdvbv5 frontend part, to output logs
*/
#ifndef _DOXYGEN
struct dvb_v5_fe_parms;
/**
* @brief retrieve the logging function with private data from the private fe params.
*/
dvb_logfunc_priv dvb_get_log_priv(struct dvb_v5_fe_parms *, void **);
#ifndef __DVB_FE_PRIV_H
#define dvb_loglevel(level, fmt, arg...) do {\
void *priv;\
dvb_logfunc_priv f = dvb_get_log_priv(parms, &priv);\
if (f) {\
f(priv, level, fmt, ##arg);\
} else {\
parms->logfunc(level, fmt, ##arg); \
}\
} while (0)
#else
#define dvb_loglevel(level, fmt, arg...) do {\
if (parms->logfunc_priv) {\
parms->logfunc_priv(parms->logpriv, level, fmt, ##arg);\
} else {\
parms->p.logfunc(level, fmt, ##arg); \
}\
} while (0)
#endif
#define dvb_log(fmt, arg...) dvb_loglevel(LOG_INFO, fmt, ##arg)
#define dvb_logerr(fmt, arg...) dvb_loglevel(LOG_ERR, fmt, ##arg)
#define dvb_logdbg(fmt, arg...) dvb_loglevel(LOG_DEBUG, fmt, ##arg)
#define dvb_logwarn(fmt, arg...) dvb_loglevel(LOG_WARNING, fmt, ##arg)
#define dvb_loginfo(fmt, arg...) dvb_loglevel(LOG_NOTICE, fmt, ##arg)
#define dvb_perror(msg) dvb_logerr("%s: %s", msg, strerror(errno))
#endif /* _DOXYGEN */
/**
* @brief This is the prototype of the internal log function that it is used,
* if the library client doesn't desire to override with something else.
* @ingroup ancillary
*
* @param level level of the message, as defined at syslog.h
* @param fmt format string (same as format string on sprintf)
*/
void dvb_default_log(int level, const char *fmt, ...) __attribute__ (( format( printf, 2, 3 )));
#endif

163
include/libdvbv5/dvb-sat.h Normal file
View File

@@ -0,0 +1,163 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
#ifndef _LIBSAT_H
#define _LIBSAT_H
#include "dvb-v5-std.h"
/**
* @file dvb-sat.h
* @ingroup satellite
* @brief Provides interfaces to deal with DVB Satellite systems.
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
/*
* Satellite handling functions
*/
/**
* @struct dvb_sat_lnb
* @brief Stores the information of a LNBf
* @ingroup satellite
*
* @param name long name of the LNBf type
* @param alias short name for the LNBf type
*
* The LNBf (low-noise block downconverter) is a type of amplifier that is
* installed inside the parabolic dishes. It converts the antenna signal to
* an Intermediate Frequency. Several Ku-band LNBf have more than one IF.
* The lower IF is stored at lowfreq, the higher IF at highfreq.
* The exact setup for those structs actually depend on the model of the LNBf,
* and its usage.
*/
struct dvb_sat_lnb {
const char *name;
const char *alias;
/*
* Legacy fields, kept just to avoid ABI breakages
* Should not be used by new applications
*/
unsigned lowfreq, highfreq;
unsigned rangeswitch;
struct dvbsat_freqrange {
unsigned low, high;
} freqrange[2];
};
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/* From libsat.c */
/**
* @brief search for a LNBf entry
* @ingroup satellite
*
* @param name name of the LNBf entry to seek.
*
* On sucess, it returns a non-negative number with corresponds to the LNBf
* entry inside the LNBf structure at dvb-sat.c.
*
* @return A -1 return code indicates that the LNBf was not found.
*/
int dvb_sat_search_lnb(const char *name);
/**
* @brief prints the contents of a LNBf entry at STDOUT.
* @ingroup satellite
*
* @param index index for the entry
*
* @return returns -1 if the index is out of range, zero otherwise.
*/
int dvb_print_lnb(int index);
/**
* @brief Prints all LNBf entries at STDOUT.
* @ingroup satellite
*
* This function doesn't return anything. Internally, it calls dvb_print_lnb()
* for all entries inside its LNBf database.
*/
void dvb_print_all_lnb(void);
/**
* @brief gets a LNBf entry at its internal database
* @ingroup satellite
*
* @param index index for the entry.
*
* @return returns NULL if not found, of a struct dvb_sat_lnb pointer otherwise.
*
* NOTE: none of the strings are i18n translated. In order to get the
* translated name, you should use dvb_sat_get_lnb_name()
*/
const struct dvb_sat_lnb *dvb_sat_get_lnb(int index);
/**
* @brief gets a LNBf entry at its internal database
* @ingroup satellite
*
* @param index index for the entry.
*
* @return returns NULL if not found, of the name of a LNBf,
* translated to the user language, if translation is available.
*/
const char *dvb_sat_get_lnb_name(int index);
/**
* @brief sets the satellite parameters
* @ingroup satellite
*
* @param parms struct dvb_v5_fe_parms pointer.
*
* This function is called internally by the library to set the LNBf
* parameters, if the dvb_v5_fe_parms::lnb field is filled.
*
* @return 0 on success.
*/
int dvb_sat_set_parms(struct dvb_v5_fe_parms *parms);
/**
* @brief return the real satellite frequency
* @ingroup satellite
*
* @param parms struct dvb_v5_fe_parms pointer.
*
* This function is called internally by the library to get the satellite
* frequency, considering the LO frequency.
*
* @return frequency.
*/
int dvb_sat_real_freq(struct dvb_v5_fe_parms *p, int freq);
#ifdef __cplusplus
}
#endif
#endif // _LIBSAT_H

434
include/libdvbv5/dvb-scan.h Normal file
View File

@@ -0,0 +1,434 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
#ifndef _LIBSCAN_H
#define _LIBSCAN_H
#include <stdint.h>
#include <linux/dvb/dmx.h>
#include <libdvbv5/descriptors.h>
#include <libdvbv5/dvb-sat.h>
/**
* @file dvb-scan.h
* @ingroup frontend_scan
* @brief Provides interfaces to scan programs inside MPEG-TS digital TV streams.
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
/* According with ISO/IEC 13818-1:2007 */
#define MAX_TABLE_SIZE 1024 * 1024
#ifdef __cplusplus
extern "C" {
#endif
struct dvb_entry;
/**
* @struct dvb_v5_descriptors_program
* @brief Associates PMT with PAT tables
* @ingroup frontend_scan
*
* @param pat_pgm pointer for PAT descriptor
* @param pmt pointer for PMT descriptor
*/
struct dvb_v5_descriptors_program {
struct dvb_table_pat_program *pat_pgm;
struct dvb_table_pmt *pmt;
};
/**
* @struct dvb_v5_descriptors
* @brief Contains the descriptors needed to scan the Service ID and other relevant info at a MPEG-TS Digital TV stream
* @ingroup frontend_scan
*
* @param delivery_system Delivery system of the parsed MPEG-TS
* @param entry struct dvb_entry pointer (see dvb-file.h)
* @param pat PAT table descriptor pointer (table ID 0x00).
* @param vct VCT table descriptor pointer (either table ID 0xc8,
* for TVCT or table ID 0xc9, for CVCT)
* @param program PAT/PMT array associated programs found at MPEG-TS
* @param num_program Number of program entries at @ref program array.
* @param nit NIT table descriptor pointer for table ID 0x40.
* @param sdt SDT table descriptor pointer for table ID 0x42.
* @param other_nits Contains an array of pointers to the other NIT
* extension tables identified by table ID 0x41.
* @param num_other_nits Number of NIT tables at @ref other_nits array.
* @param other_sdts Contains an array of pointers to the other NIT
* extension tables identified by table ID 0x46.
* @param num_other_sdts Number of NIT tables at @ref other_sdts array.
*
* Those descriptors are filled by the scan routines when the tables are
* found. Otherwise, they're NULL.
*
* @note: Never alloc this struct yourself. This is meant to always be
* allocated via dvb_scan_alloc_handler_table() or via dvb_get_ts_tables().
*/
struct dvb_v5_descriptors {
uint32_t delivery_system;
struct dvb_entry *entry;
unsigned num_entry;
struct dvb_table_pat *pat;
struct atsc_table_vct *vct;
struct dvb_v5_descriptors_program *program;
struct dvb_table_nit *nit;
struct dvb_table_sdt *sdt;
unsigned num_program;
struct dvb_table_nit **other_nits;
unsigned num_other_nits;
struct dvb_table_sdt **other_sdts;
unsigned num_other_sdts;
};
/**
* @struct dvb_table_filter
* @brief Describes the PES filters used by DVB scan
* @ingroup frontend_scan
*
* @param tid Table ID
* @param pid Program ID
* @param ts_id Table section ID (for multisession filtering). If no
* specific table section is needed, -1 should be used
* @param table pointer to a pointer for the table struct to be filled
* @param allow_section_gaps Allow non-continuous section numbering
* @param priv Internal structure used inside the DVB core. shouldn't
* be touched externally.
*/
struct dvb_table_filter {
/* Input data */
unsigned char tid;
uint16_t pid;
int ts_id;
void **table;
int allow_section_gaps;
/*
* Private temp data used by dvb_read_sections().
* Should not be filled outside dvb-scan.c, as they'll be
* overrided
*/
void *priv;
};
/**
* @brief deallocates all data associated with a table filter
* @ingroup frontend_scan
*
* @param sect table filter pointer
*/
void dvb_table_filter_free(struct dvb_table_filter *sect);
/**
* @brief read MPEG-TS tables that comes from a DTV card
* @ingroup frontend_scan
*
* @param parms pointer to struct dvb_v5_fe_parms created when the
* frontend is opened
* @param dmx_fd an opened demux file descriptor
* @param tid Table ID
* @param pid Program ID
* @param table pointer to a pointer for the table struct to be filled
* @param timeout Limit, in seconds, to read a MPEG-TS table
*
* This function is used to read the DVB tables by specifying a table ID and
* a program ID. The libdvbv5 should have a parser for the descriptors of the
* table type that should be parsed.
* The table will be automatically allocated on success.
* The function will read on the specified demux and return when reading is
* done or an error has occurred. If table is not NULL after the call, it has
* to be freed with the apropriate free table function (even if an error has
* occurred).
*
* If the application wants to abort the read operation, it can change the
* value of parms->p.abort to 1.
*
* Returns 0 on success or a negative error code.
*
* Example usage:
* @code
* struct dvb_table_pat *pat;
* int r = dvb_read_section( parms, dmx_fd, DVB_TABLE_PAT, DVB_TABLE_PAT_PID,
* (void **) &pat, 5 );
* if (r < 0)
* dvb_logerr("error reading PAT table");
* else {
* // do something with pat
* }
* if (pat)
* dvb_table_pat_free( pat );
* @endcode
*/
int dvb_read_section(struct dvb_v5_fe_parms *parms, int dmx_fd,
unsigned char tid, uint16_t pid, void **table,
unsigned timeout);
/**
* @brief read MPEG-TS tables that comes from a DTV card
* with an specific table section ID
* @ingroup frontend_scan
*
* @param parms pointer to struct dvb_v5_fe_parms created when the
* frontend is opened
* @param dmx_fd an opened demux file descriptor
* @param tid Table ID
* @param pid Program ID
* @param ts_id Table section ID (for multisession filtering). If no
* specific table section is needed, -1 should be used
* @param table pointer to a pointer for the table struct to be filled
* @param timeout limit, in seconds, to read a MPEG-TS table
*
* This is a variant of dvb_read_section() that also seeks for an specific
* table section ID given by ts_id.
*/
int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
unsigned char tid, uint16_t pid, int ts_id,
void **table, unsigned timeout);
/**
* @brief read MPEG-TS tables that comes from a DTV card
* @ingroup frontend_scan
*
* @param parms pointer to struct dvb_v5_fe_parms created when the
* frontend is opened
* @param dmx_fd an opened demux file descriptor
* @param sect section filter pointer
* @param timeout limit, in seconds, to read a MPEG-TS table
*
* This is a variant of dvb_read_section() that uses a struct dvb_table_filter
* to specify the filter to use.
*/
int dvb_read_sections(struct dvb_v5_fe_parms *parms, int dmx_fd,
struct dvb_table_filter *sect,
unsigned timeout);
/**
* @brief allocates a struct dvb_v5_descriptors
* @ingroup frontend_scan
*
* @param delivery_system Delivery system to be used on the table
*
* At success, returns a pointer. NULL otherwise.
*/
struct dvb_v5_descriptors *dvb_scan_alloc_handler_table(uint32_t delivery_system);
/**
* @brief frees a struct dvb_v5_descriptors
* @ingroup frontend_scan
*
* @param dvb_scan_handler pointer to the struct to be freed.
*/
void dvb_scan_free_handler_table(struct dvb_v5_descriptors *dvb_scan_handler);
/**
* @brief Scans a DVB stream, looking for the tables needed to
* identify the programs inside a MPEG-TS
* @ingroup frontend_scan
*
* @param parms pointer to struct dvb_v5_fe_parms created when
* the frontend is opened
* @param dmx_fd an opened demux file descriptor
* @param delivery_system delivery system to be scanned
* @param other_nit use alternate table IDs for NIT and other tables
* @param timeout_multiply improves the timeout for each table reception
* by using a value that will multiply the wait
* time.
*
* Given an opened frontend and demux, this function seeks for all programs
* available at the transport stream, and parses the following tables:
* PAT, PMT, NIT, SDT (and VCT, if the delivery system is ATSC).
*
* On sucess, it returns a pointer to a struct dvb_v5_descriptors, that can
* either be used to tune into a service or to be stored inside a file.
*/
struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms, int dmx_fd,
uint32_t delivery_system,
unsigned other_nit,
unsigned timeout_multiply);
/**
* @brief frees a struct dvb_v5_descriptors
* @ingroup frontend_scan
*
* @param dvb_desc pointed to the structure to be freed.
*
* This function recursively frees everything that is allocated by
* dvb_get_ts_tables() and stored at dvb_desc, including dvb_desc itself.
*/
void dvb_free_ts_tables(struct dvb_v5_descriptors *dvb_desc);
/**
* @brief Callback for the application to show the frontend status
* @ingroup frontend_scan
*
* @param args a pointer, opaque to libdvbv5, to be used by the
* application if needed.
* @param parms pointer to struct dvb_v5_fe_parms created when the
* frontend is opened
*/
typedef int (check_frontend_t)(void *args, struct dvb_v5_fe_parms *parms);
/**
* @brief Scans a DVB dvb_add_scaned_transponder
* @ingroup frontend_scan
*
* @param parms pointer to struct dvb_v5_fe_parms created when the
* frontend is opened
* @param entry DVB file entry that corresponds to a transponder to be
* tuned
* @param dmx_fd an opened demux file descriptor
* @param check_frontend a pointer to a function that will show the frontend
* status while tuning into a transponder
* @param args a pointer, opaque to libdvbv5, that will be used when
* calling check_frontend. It should contain any parameters
* that could be needed by check_frontend.
* @param other_nit Use alternate table IDs for NIT and other tables
* @param timeout_multiply Improves the timeout for each table reception, by
*
* This is the function that applications should use when doing a transponders
* scan. It does everything needed to fill the entries with DVB programs
* (virtual channels) and detect the PIDs associated with them.
*
* A typical usage is to after open a channel file, open a dmx_fd and open
* a frontend. Then, seek for the MPEG tables on all the transponder
* frequencies with:
*
* @code
* for (entry = dvb_file->first_entry; entry != NULL; entry = entry->next) {
* struct dvb_v5_descriptors *dvb_scan_handler = NULL;
*
* dvb_scan_handler = dvb_scan_transponder(parms, entry, dmx_fd,
* &check_frontend, args,
* args->other_nit,
* args->timeout_multiply);
* if (parms->abort) {
* dvb_scan_free_handler_table(dvb_scan_handler);
* break;
* }
* if (dvb_scan_handler) {
* dvb_store_channel(&dvb_file_new, parms, dvb_scan_handler,
* args->get_detected, args->get_nit);
* dvb_scan_free_handler_table(dvb_scan_handler);
* }
* }
* @endcode
*/
struct dvb_v5_descriptors *dvb_scan_transponder(struct dvb_v5_fe_parms *parms,
struct dvb_entry *entry,
int dmx_fd,
check_frontend_t *check_frontend,
void *args,
unsigned other_nit,
unsigned timeout_multiply);
/**
* @brief Add new transponders to a dvb_file
* @ingroup frontend_scan
*
* @param parms pointer to struct dvb_v5_fe_parms created when the
* frontend is opened
* @param dvb_scan_handler pointer to a struct dvb_v5_descriptors containing
* scaned MPEG-TS
* @param first_entry first entry of a DVB file struct
* @param entry current entry on a DVB file struct
*
* When the NIT table is parsed, some new transponders could be described
* inside. This function adds new entries to a dvb_file struct, pointing
* to those new transponders. It is used inside the scan loop, as shown at
* the dvb_scan_transponder(), to add new channels.
*
* Example:
* @code
* for (entry = dvb_file->first_entry; entry != NULL; entry = entry->next) {
* struct dvb_v5_descriptors *dvb_scan_handler = NULL;
*
* dvb_scan_handler = dvb_scan_transponder(parms, entry, dmx_fd,
* &check_frontend, args,
* args->other_nit,
* args->timeout_multiply);
* if (parms->abort) {
* dvb_scan_free_handler_table(dvb_scan_handler);
* break;
* }
* if (dvb_scan_handler) {
* dvb_store_channel(&dvb_file_new, parms, dvb_scan_handler,
* args->get_detected, args->get_nit);
* dvb_scan_free_handler_table(dvb_scan_handler);
*
* dvb_add_scaned_transponders(parms, dvb_scan_handler,
* dvb_file->first_entry, entry);
*
* dvb_scan_free_handler_table(dvb_scan_handler);
* }
* }
* @endcode
*/
void dvb_add_scaned_transponders(struct dvb_v5_fe_parms *parms,
struct dvb_v5_descriptors *dvb_scan_handler,
struct dvb_entry *first_entry,
struct dvb_entry *entry);
#ifndef _DOXYGEN
/*
* Some ancillary functions used internally inside the library, used to
* identify duplicated transport streams and add new found transponder entries
*/
int dvb_estimate_freq_shift(struct dvb_v5_fe_parms *parms);
int dvb_new_freq_is_needed(struct dvb_entry *entry, struct dvb_entry *last_entry,
uint32_t freq, enum dvb_sat_polarization pol, int shift);
struct dvb_entry *dvb_scan_add_entry(struct dvb_v5_fe_parms *parms,
struct dvb_entry *first_entry,
struct dvb_entry *entry,
uint32_t freq, uint32_t shift,
enum dvb_sat_polarization pol);
int dvb_new_entry_is_needed(struct dvb_entry *entry,
struct dvb_entry *last_entry,
uint32_t freq, int shift,
enum dvb_sat_polarization pol, uint32_t stream_id);
struct dvb_entry *dvb_scan_add_entry_ex(struct dvb_v5_fe_parms *parms,
struct dvb_entry *first_entry,
struct dvb_entry *entry,
uint32_t freq, uint32_t shift,
enum dvb_sat_polarization pol,
uint32_t stream_id);
void dvb_update_transponders(struct dvb_v5_fe_parms *parms,
struct dvb_v5_descriptors *dvb_scan_handler,
struct dvb_entry *first_entry,
struct dvb_entry *entry);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,267 @@
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Per-delivery system properties defined at libdvbv5 scope, following
* the same model as defined at the Linux DVB media specs:
* http://linuxtv.org/downloads/v4l-dvb-apis/FE_GET_SET_PROPERTY.html
*/
#ifndef _DVB_V5_STD_H
#define _DVB_V5_STD_H
#include <stddef.h>
#include "dvb-frontend.h"
/**
* @file dvb-v5-std.h
* @ingroup frontend
* @brief Provides libdvbv5 defined properties for the frontend.
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
/*
* User DTV codes, for internal usage. There are two sets of
* properties. One for DTV properties and another one for statistics
*/
/*
* First set: DTV properties that don't belong to Kernelspace
*
* Those properties contain data that comes from the MPEG-TS
* tables, like audio/video/other PIDs, and satellite config
*/
/**
* @def DTV_USER_COMMAND_START
* @brief Start number for libdvbv5 user commands
* @ingroup frontend
* @def DTV_POLARIZATION
* @brief Satellite polarization (for Satellite delivery systems)
* @ingroup frontend
* @def DTV_AUDIO_PID
* @brief Audio PID
* @ingroup frontend
* @def DTV_VIDEO_PID
* @brief Video PID
* @ingroup frontend
* @def DTV_SERVICE_ID
* @brief MPEG TS service ID
* @ingroup frontend
* @def DTV_CH_NAME
* @brief Digital TV service name
* @ingroup frontend
* @def DTV_VCHANNEL
* @brief Digital TV channel number. May contain symbols
* @ingroup frontend
* @def DTV_SAT_NUMBER
* @brief Number of the satellite (used on multi-dish Satellite systems)
* @ingroup frontend
* @def DTV_DISEQC_WAIT
* @brief Extra time needed to wait for DiSeqC to complete, in ms.
* The minimal wait time is 15 ms. The time here will be
* added to the minimal time.
* @ingroup frontend
* @def DTV_DISEQC_LNB
* @brief LNBf name
* @ingroup frontend
* @def DTV_FREQ_BPF
* @brief SCR/Unicable band-pass filter frequency in kHz
* @ingroup frontend
* @def DTV_PLS_CODE
* @brief DVB-T2 PLS code. Not used internally. It is needed
* only for file conversion.
* @ingroup frontend
* @def DTV_PLS_MODE
* @brief DVB-T2 PLS mode. Not used internally. It is needed
* only for file conversion.
* @ingroup frontend
* @def DTV_COUNTRY_CODE
* @brief Country variant of international delivery system standard.
in ISO 3166-1 two letter code.
* @ingroup frontend
* @def DTV_MAX_USER_COMMAND
* @brief Last user command
* @ingroup frontend
* @def DTV_USER_NAME_SIZE
* @brief Number of user commands
* @ingroup frontend
*/
#define DTV_USER_COMMAND_START 256
#define DTV_POLARIZATION (DTV_USER_COMMAND_START + 0)
#define DTV_VIDEO_PID (DTV_USER_COMMAND_START + 1)
#define DTV_AUDIO_PID (DTV_USER_COMMAND_START + 2)
#define DTV_SERVICE_ID (DTV_USER_COMMAND_START + 3)
#define DTV_CH_NAME (DTV_USER_COMMAND_START + 4)
#define DTV_VCHANNEL (DTV_USER_COMMAND_START + 5)
#define DTV_SAT_NUMBER (DTV_USER_COMMAND_START + 6)
#define DTV_DISEQC_WAIT (DTV_USER_COMMAND_START + 7)
#define DTV_DISEQC_LNB (DTV_USER_COMMAND_START + 8)
#define DTV_FREQ_BPF (DTV_USER_COMMAND_START + 9)
#define DTV_PLS_CODE (DTV_USER_COMMAND_START + 10)
#define DTV_PLS_MODE (DTV_USER_COMMAND_START + 11)
#define DTV_COUNTRY_CODE (DTV_USER_COMMAND_START + 12)
#define DTV_MAX_USER_COMMAND DTV_COUNTRY_CODE
#define DTV_USER_NAME_SIZE (1 + DTV_MAX_USER_COMMAND - DTV_USER_COMMAND_START)
/**
* @enum dvb_sat_polarization
* @brief Polarization types for Satellite systems
* @ingroup satellite
*
* @param POLARIZATION_OFF Polarization disabled/unused.
* @param POLARIZATION_H Horizontal polarization
* @param POLARIZATION_V Vertical polarization
* @param POLARIZATION_L Left circular polarization (C-band)
* @param POLARIZATION_R Right circular polarization (C-band)
*/
enum dvb_sat_polarization {
POLARIZATION_OFF = 0,
POLARIZATION_H = 1,
POLARIZATION_V = 2,
POLARIZATION_L = 3,
POLARIZATION_R = 4,
};
/*
* Second set: DTV statistics
*
* Those properties contain statistics measurements that aren't
* either provided by the Kernel via property cmd/value pair,
* like status (with has its own ioctl), or that are derivated
* measures from two or more Kernel reported stats.
*/
/**
* @def DTV_STAT_COMMAND_START
* @brief Start number for libdvbv5 statistics commands
* @ingroup frontend
* @def DTV_STATUS
* @brief Lock status of a DTV frontend. This actually comes from
* the Kernel, but it uses a separate ioctl.
* @ingroup frontend
* @def DTV_BER
* @brief Bit Error Rate. This is a parameter that it is
* derivated from two counters at the Kernel side
* @ingroup frontend
* @def DTV_PER
* @brief Packet Error Rate. This is a parameter that it is
* derivated from two counters at the Kernel side
* @ingroup frontend
* @def DTV_QUALITY
* @brief A quality indicator that represents if a locked
* channel provides a good, OK or poor signal. This is
* estimated considering the error rates, signal strengh
* and/or S/N ratio of the carrier.
* @ingroup frontend
* @def DTV_PRE_BER
* @brief Bit Error Rate before Viterbi. This is the error rate
* before applying the Forward Error Correction. This is
* a parameter that it is derivated from two counters
* at the Kernel side.
* @ingroup frontend
* @def DTV_MAX_STAT_COMMAND
* @brief Last statistics command
* @ingroup frontend
* @def DTV_STAT_NAME_SIZE
* @brief Number of statistics commands
* @ingroup frontend
* @def DTV_NUM_KERNEL_STATS
* @brief Number of statistics commands provided by the Kernel
* @ingroup frontend
* @def DTV_NUM_STATS_PROPS
* @brief Total number of statistics commands
* @ingroup frontend
*/
#define DTV_STAT_COMMAND_START 512
#define DTV_STATUS (DTV_STAT_COMMAND_START + 0)
#define DTV_BER (DTV_STAT_COMMAND_START + 1)
#define DTV_PER (DTV_STAT_COMMAND_START + 2)
#define DTV_QUALITY (DTV_STAT_COMMAND_START + 3)
#define DTV_PRE_BER (DTV_STAT_COMMAND_START + 4)
#define DTV_MAX_STAT_COMMAND DTV_PRE_BER
#define DTV_STAT_NAME_SIZE (1 + DTV_MAX_STAT_COMMAND - DTV_STAT_COMMAND_START)
/* There are currently 8 stats provided on Kernelspace */
#define DTV_NUM_KERNEL_STATS 8
#define DTV_NUM_STATS_PROPS (DTV_NUM_KERNEL_STATS + DTV_STAT_NAME_SIZE)
/**
* @enum dvb_quality
* @brief Provides an estimation about the user's experience
* while watching to a given MPEG stream
* @ingroup frontend
*
* @param DVB_QUAL_UNKNOWN Quality could not be estimated, as the Kernel driver
* doesn't provide enough statistics
*
* @param DVB_QUAL_POOR The signal reception is poor. Signal loss or packets
* can be lost too frequently.
* @param DVB_QUAL_OK The signal reception is ok. Eventual artifacts could
* be expected, but it should work.
* @param DVB_QUAL_GOOD The signal is good, and not many errors are happening.
* The user should have a good experience watching the
* stream.
*/
enum dvb_quality {
DVB_QUAL_UNKNOWN = 0,
DVB_QUAL_POOR,
DVB_QUAL_OK,
DVB_QUAL_GOOD,
};
#ifndef _DOXYGEN
/*
* Some tables to translate from value to string
*
* These tables are raw ways to translate from some DTV values into strings.
* Please use the API-provided function dvb_cmd_name() and dvb_dvb_attr_names(),
* instead of using the tables directly.
*/
extern const unsigned int sys_dvbt_props[];
extern const unsigned int sys_dvbt2_props[];
extern const unsigned int sys_isdbt_props[];
extern const unsigned int sys_atsc_props[];
extern const unsigned int sys_atscmh_props[];
extern const unsigned int sys_dvbc_annex_ac_props[];
extern const unsigned int sys_dvbc_annex_b_props[];
extern const unsigned int sys_dvbs_props[];
extern const unsigned int sys_dvbs2_props[];
extern const unsigned int sys_turbo_props[];
extern const unsigned int sys_isdbs_props[];
extern const unsigned int *dvb_v5_delivery_system[];
extern const char *dvb_sat_pol_name[6];
extern const char *dvb_user_name[DTV_USER_NAME_SIZE + 1];
extern const char *dvb_stat_name[DTV_STAT_NAME_SIZE + 1];
extern const void *dvb_user_attr_names[];
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
#endif

226
include/libdvbv5/eit.h Normal file
View File

@@ -0,0 +1,226 @@
/*
* Copyright (c) 2011-2012 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file eit.h
* @ingroup dvb_table
* @brief Provides the table parser for the DVB EIT (Event Information Table)
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The table described herein is defined at:
* - ETSI EN 300 468
*
* @see
* http://www.etherguidesystems.com/Help/SDOs/dvb/syntax/tablesections/EIT.aspx
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _EIT_H
#define _EIT_H
#include <stdint.h>
#include <unistd.h> /* ssize_t */
#include <time.h>
#include <libdvbv5/header.h>
/**
* @def DVB_TABLE_EIT
* @brief DVB EIT table ID for the actual TS
* @ingroup dvb_table
* @def DVB_TABLE_EIT_OTHER
* @brief DVB EIT table ID for other TS
* @ingroup dvb_table
* @def DVB_TABLE_EIT_PID
* @brief DVB EIT Program ID
* @ingroup dvb_table
* @def DVB_TABLE_EIT_SCHEDULE
* @brief Start table ID for the DVB EIT schedule data on the actual TS
* The range has 0x0f elements (0x50 to 0x5F).
* @ingroup dvb_table
* @def DVB_TABLE_EIT_SCHEDULE_OTHER
* @brief Start table ID for the DVB EIT schedule data on other TS
* The range has 0x0f elements (0x60 to 0x6F).
* @ingroup dvb_table
*/
#define DVB_TABLE_EIT 0x4E
#define DVB_TABLE_EIT_OTHER 0x4F
#define DVB_TABLE_EIT_PID 0x12
#define DVB_TABLE_EIT_SCHEDULE 0x50
#define DVB_TABLE_EIT_SCHEDULE_OTHER 0x60
/**
* @struct dvb_table_eit_event
* @brief DVB EIT event table
* @ingroup dvb_table
*
* @param event_id an uniquelly (inside a service ID) event ID
* @param desc_length descriptor's length
* @param free_CA_mode free CA mode. 0 indicates that the event
* is not scrambled
* @param running_status running status of the event. The status can
* be translated to string via
* dvb_eit_running_status_name string table.
* @param descriptor pointer to struct dvb_desc
* @param next pointer to struct dvb_table_eit_event
* @param tm_start event start (in struct tm format)
* @param duration duration in seconds
* @param service_id service ID
*
* This structure is used to store the original EIT event table,
* converting the integer fields to the CPU endianness, and converting the
* timestamps to a way that it is better handled on Linux.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*
* Everything after dvb_table_eit_event::descriptor (including it) won't
* be bit-mapped to the data parsed from the MPEG TS. So, metadata are added
* there.
*/
struct dvb_table_eit_event {
uint16_t event_id;
union {
uint16_t bitfield1; /* first 2 bytes are MJD, they need to be bswapped */
uint8_t dvbstart[5];
} __attribute__((packed));
uint8_t dvbduration[3];
union {
uint16_t bitfield2;
struct {
uint16_t desc_length:12;
uint16_t free_CA_mode:1;
uint16_t running_status:3;
} __attribute__((packed));
} __attribute__((packed));
struct dvb_desc *descriptor;
struct dvb_table_eit_event *next;
struct tm start;
uint32_t duration;
uint16_t service_id;
} __attribute__((packed));
/**
* @struct dvb_table_eit
* @brief DVB EIT table
* @ingroup dvb_table
*
* @param header struct dvb_table_header content
* @param transport_id transport id
* @param network_id network id
* @param last_segment last segment
* @param last_table_id last table id
* @param event pointer to struct dvb_table_eit_event
*
* This structure is used to store the original EIT table,
* converting the integer fields to the CPU endianness.
*
* Everything after dvb_table_eit::event (including it) won't
* be bit-mapped to the data parsed from the MPEG TS. So, metadata are added
* there.
*/
struct dvb_table_eit {
struct dvb_table_header header;
uint16_t transport_id;
uint16_t network_id;
uint8_t last_segment;
uint8_t last_table_id;
struct dvb_table_eit_event *event;
} __attribute__((packed));
/**
* @brief Macro used to find event on a DVB EIT table
* @ingroup dvb_table
*
* @param _event event to seek
* @param _eit pointer to struct dvb_table_eit_event
*/
#define dvb_eit_event_foreach(_event, _eit) \
if (_eit && _eit->event) \
for( struct dvb_table_eit_event *_event = _eit->event; _event; _event = _event->next ) \
struct dvb_v5_fe_parms;
/** @brief Converts a running_status field into string */
extern const char *dvb_eit_running_status_name[8];
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses EIT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the EIT raw data
* @param buflen length of the buffer
* @param table pointer to struct dvb_table_eit to be allocated and filled
*
* This function allocates an EIT table and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
ssize_t dvb_table_eit_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf,
ssize_t buflen, struct dvb_table_eit **table);
/**
* @brief Frees all data allocated by the DVB EIT table parser
* @ingroup dvb_table
*
* @param table pointer to struct dvb_table_eit to be freed
*/
void dvb_table_eit_free(struct dvb_table_eit *table);
/**
* @brief Prints the content of the DVB EIT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param table pointer to struct dvb_table_eit
*/
void dvb_table_eit_print(struct dvb_v5_fe_parms *parms,
struct dvb_table_eit *table);
/**
* @brief Converts a DVB EIT formatted timestamp into struct tm
* @ingroup dvb_table
*
* @param data event on DVB EIT time format
* @param tm pointer to struct tm where the converted timestamp will
* be stored.
*/
void dvb_time(const uint8_t data[5], struct tm *tm);
#ifdef __cplusplus
}
#endif
#endif

150
include/libdvbv5/header.h Normal file
View File

@@ -0,0 +1,150 @@
/*
* Copyright (c) 2011-2012 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Described at ISO/IEC 13818-1
*/
#ifndef _HEADER_H
#define _HEADER_H
#include <stdint.h>
#include <unistd.h> /* ssize_t */
/**
* @file header.h
* @ingroup dvb_table
* @brief Provides the MPEG TS table headers
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
/**
* @struct dvb_ts_packet_header
* @brief Header of a MPEG-TS transport packet
* @ingroup dvb_table
*
* @param sync_byte sync byte
* @param pid Program ID
* @param transport_priority transport priority
* @param payload_unit_start_indicator payload unit start indicator
* @param transport_error_indicator transport error indicator
* @param continuity_counter continuity counter
* @param adaptation_field_control adaptation field control
* @param transport_scrambling_control transport scrambling control
* @param adaptation_field_length adaptation field length
*
* @see http://www.etherguidesystems.com/Help/SDOs/MPEG/Semantics/MPEG-2/transport_packet.aspx
*/
struct dvb_ts_packet_header {
uint8_t sync_byte;
union {
uint16_t bitfield;
struct {
uint16_t pid:13;
uint16_t transport_priority:1;
uint16_t payload_unit_start_indicator:1;
uint16_t transport_error_indicator:1;
} __attribute__((packed));
} __attribute__((packed));
uint8_t continuity_counter:4;
uint8_t adaptation_field_control:2;
uint8_t transport_scrambling_control:2;
/* Only if adaptation_field_control > 1 */
uint8_t adaptation_field_length;
/* Only if adaptation_field_length >= 1 */
struct {
uint8_t extension:1;
uint8_t private_data:1;
uint8_t splicing_point:1;
uint8_t OPCR:1;
uint8_t PCR:1;
uint8_t priority:1;
uint8_t random_access:1;
uint8_t discontinued:1;
} __attribute__((packed));
} __attribute__((packed));
/**
* @struct dvb_table_header
* @brief Header of a MPEG-TS table
* @ingroup dvb_table
*
* @param table_id table id
* @param section_length section length
* @param syntax syntax
* @param id Table ID extension
* @param current_next current next
* @param version version
* @param section_id section number
* @param last_section last section number
*
* All MPEG-TS tables start with this header.
*/
struct dvb_table_header {
uint8_t table_id;
union {
uint16_t bitfield;
struct {
uint16_t section_length:12;
uint8_t one:2;
uint8_t zero:1;
uint8_t syntax:1;
} __attribute__((packed));
} __attribute__((packed));
uint16_t id; /* TS ID */
uint8_t current_next:1;
uint8_t version:5;
uint8_t one2:2;
uint8_t section_id; /* section_number */
uint8_t last_section; /* last_section_number */
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses MPEG-TS table header
* @ingroup dvb_table
*
* @param header pointer to struct dvb_table_header to be parsed
*/
void dvb_table_header_init (struct dvb_table_header *header);
/**
* @brief Prints the content of the MPEG-TS table header
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param header pointer to struct dvb_table_header to be printed
*/
void dvb_table_header_print(struct dvb_v5_fe_parms *parms,
const struct dvb_table_header *header);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,4 @@
#define LIBDVBV5_VERSION_MAJOR 1
#define LIBDVBV5_VERSION_MINOR 22
#define LIBDVBV5_VERSION_PATCH 1
#define LIBDVBV5_VERSION "1.22.1"

View File

@@ -0,0 +1,4 @@
#define LIBDVBV5_VERSION_MAJOR @MAJOR@
#define LIBDVBV5_VERSION_MINOR @MINOR@
#define LIBDVBV5_VERSION_PATCH @PATCH@
#define LIBDVBV5_VERSION "@PACKAGE_VERSION@"

187
include/libdvbv5/mgt.h Normal file
View File

@@ -0,0 +1,187 @@
/*
* Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file mgt.h
* @ingroup dvb_table
* @brief Provides the table parser for the ATSC MGT (Master Guide Table)
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Andre Roth
*
* @par Relevant specs
* The table described herein is defined at:
* - ATSC A/65:2009
*
* @see
* http://www.etherguidesystems.com/help/sdos/atsc/syntax/tablesections/MGT.aspx
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _MGT_H
#define _MGT_H
#include <stdint.h>
#include <unistd.h> /* ssize_t */
#include <libdvbv5/atsc_header.h>
/**
* @def ATSC_TABLE_MGT
* @brief ATSC MGT table ID
* @ingroup dvb_table
*/
#define ATSC_TABLE_MGT 0xC7
/**
* @struct atsc_table_mgt_table
* @brief ATSC tables descrition at MGT table
* @ingroup dvb_table
*
* @param type table type
* @param pid table type pid
* @param type_version type type version number
* @param size number of bytes for the table entry
* @param desc_length table type descriptors length
* @param descriptor pointer to struct dvb_desc
* @param next pointer to struct atsc_table_mgt_table
*
* This structure is used to store the original VCT channel table,
* converting the integer fields to the CPU endianness.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*
* Everything after atsc_table_mgt_table::descriptor (including it) won't
* be bit-mapped * to the data parsed from the MPEG TS. So, metadata are
* added there.
*/
struct atsc_table_mgt_table {
uint16_t type;
union {
uint16_t bitfield;
struct {
uint16_t pid:13;
uint16_t one:3;
} __attribute__((packed));
} __attribute__((packed));
uint8_t type_version:5;
uint8_t one2:3;
uint32_t size;
union {
uint16_t bitfield2;
struct {
uint16_t desc_length:12;
uint16_t one3:4;
} __attribute__((packed));
} __attribute__((packed));
struct dvb_desc *descriptor;
struct atsc_table_mgt_table *next;
} __attribute__((packed));
/**
* @struct atsc_table_mgt
* @brief ATSC MGT table
* @ingroup dvb_table
*
* @param header struct dvb_table_header content
* @param protocol_version protocol version
* @param tables tables_defined Number of tables defined
* @param table pointer to struct atsc_table_mgt_table
* @param descriptor pointer to struct dvb_desc
*
* This structure is used to store the original MGT channel table,
* converting the integer fields to the CPU endianness.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*
* Everything after atsc_table_mgt::table (including it) won't
* be bit-mapped * to the data parsed from the MPEG TS. So, metadata are
* added there.
*/
struct atsc_table_mgt {
struct dvb_table_header header;
uint8_t protocol_version;
uint16_t tables;
struct atsc_table_mgt_table *table;
struct dvb_desc *descriptor;
} __attribute__((packed));
/**
* @brief Macro used to find a table inside a MGT table
*
* @param _table channel to seek
* @param _mgt pointer to struct atsc_table_mgt_table
*/
#define atsc_mgt_table_foreach( _table, _mgt ) \
if (_mgt && _mgt->_table) \
for( struct atsc_table_mgt_table *_table = _mgt->table; _table; _table = _table->next ) \
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses MGT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the MGT raw data
* @param buflen length of the buffer
* @param table pointer to struct atsc_table_mgt to be allocated and filled
*
* This function allocates an ATSC MGT table and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
ssize_t atsc_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
ssize_t buflen, struct atsc_table_mgt **table);
/**
* @brief Frees all data allocated by the MGT table parser
* @ingroup dvb_table
*
* @param table pointer to struct atsc_table_mgt to be freed
*/
void atsc_table_mgt_free(struct atsc_table_mgt *table);
/**
* @brief Prints the content of the MGT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param table pointer to struct atsc_table_mgt
*/
void atsc_table_mgt_print(struct dvb_v5_fe_parms *parms,
struct atsc_table_mgt *table);
#ifdef __cplusplus
}
#endif
#endif

248
include/libdvbv5/mpeg_es.h Normal file
View File

@@ -0,0 +1,248 @@
/*
* Copyright (c) 2013-2014 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#ifndef _MPEG_ES_H
#define _MPEG_ES_H
/**
* @file mpeg_es.h
* @ingroup dvb_table
* @brief Provides the table parser for the MPEG-TS Elementary Stream
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Andre Roth
*
* @par Relevant specs
* The table described herein is defined in ISO 13818-2
*
* @see
* http://dvd.sourceforge.net/dvdinfo/mpeghdrs.html
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#include <stdint.h>
#include <unistd.h> /* ssize_t */
/**
* @def DVB_MPEG_ES_PIC_START
* @brief Picture Start
* @ingroup dvb_table
* @def DVB_MPEG_ES_USER_DATA
* @brief User Data
* @ingroup dvb_table
* @def DVB_MPEG_ES_SEQ_START
* @brief Sequence Start
* @ingroup dvb_table
* @def DVB_MPEG_ES_SEQ_EXT
* @brief Extension
* @ingroup dvb_table
* @def DVB_MPEG_ES_GOP
* @brief Group Of Pictures
* @ingroup dvb_table
* @def DVB_MPEG_ES_SLICES
* @brief Slices
* @ingroup dvb_table
*/
#define DVB_MPEG_ES_PIC_START 0x00
#define DVB_MPEG_ES_USER_DATA 0xb2
#define DVB_MPEG_ES_SEQ_START 0xb3
#define DVB_MPEG_ES_SEQ_EXT 0xb5
#define DVB_MPEG_ES_GOP 0xb8
#define DVB_MPEG_ES_SLICES 0x01 ... 0xaf
/**
* @struct dvb_mpeg_es_seq_start
* @brief MPEG ES Sequence header
* @ingroup dvb_table
*
* @param type DVB_MPEG_ES_SEQ_START
* @param sync Sync bytes
* @param framerate Framerate
* @param aspect Aspect ratio
* @param height Height
* @param width Width
* @param qm_nonintra Load non-intra quantizer matrix
* @param qm_intra Load intra quantizer matrix
* @param constrained Constrained parameters flag
* @param vbv VBV buffer size
* @param one Should be 1
* @param bitrate Bitrate
*/
struct dvb_mpeg_es_seq_start {
union {
uint32_t bitfield;
struct {
uint32_t type:8;
uint32_t sync:24;
} __attribute__((packed));
} __attribute__((packed));
union {
uint32_t bitfield2;
struct {
uint32_t framerate:4;
uint32_t aspect:4;
uint32_t height:12;
uint32_t width:12;
} __attribute__((packed));
} __attribute__((packed));
union {
uint32_t bitfield3;
struct {
uint32_t qm_nonintra:1;
uint32_t qm_intra:1;
uint32_t constrained:1;
uint32_t vbv:10; // Size of video buffer verifier = 16*1024*vbv buf size
uint32_t one:1;
uint32_t bitrate:18;
} __attribute__((packed));
} __attribute__((packed));
} __attribute__((packed));
/**
* @struct dvb_mpeg_es_pic_start
* @brief MPEG ES Picture start header
* @ingroup dvb_table
*
* @param type DVB_MPEG_ES_PIC_START
* @param sync Sync bytes
* @param dummy Unused
* @param vbv_delay VBV delay
* @param coding_type Frame type (enum dvb_mpeg_es_frame_t)
* @param temporal_ref Temporal sequence number
*/
struct dvb_mpeg_es_pic_start {
union {
uint32_t bitfield;
struct {
uint32_t type:8;
uint32_t sync:24;
} __attribute__((packed));
} __attribute__((packed));
union {
uint32_t bitfield2;
struct {
uint32_t dummy:3;
uint32_t vbv_delay:16;
uint32_t coding_type:3;
uint32_t temporal_ref:10;
} __attribute__((packed));
} __attribute__((packed));
} __attribute__((packed));
/**
* @enum dvb_mpeg_es_frame_t
* @brief MPEG frame types
* @ingroup dvb_table
*
* @var DVB_MPEG_ES_FRAME_UNKNOWN
* @brief Unknown frame
* @var DVB_MPEG_ES_FRAME_I
* @brief I frame
* @var DVB_MPEG_ES_FRAME_P
* @brief P frame
* @var DVB_MPEG_ES_FRAME_B
* @brief B frame
* @var DVB_MPEG_ES_FRAME_D
* @brief D frame
*/
enum dvb_mpeg_es_frame_t
{
DVB_MPEG_ES_FRAME_UNKNOWN,
DVB_MPEG_ES_FRAME_I,
DVB_MPEG_ES_FRAME_P,
DVB_MPEG_ES_FRAME_B,
DVB_MPEG_ES_FRAME_D
};
/**
* @brief Vector that translates from enum dvb_mpeg_es_frame_t to string.
* @ingroup dvb_table
*/
extern const char *dvb_mpeg_es_frame_names[5];
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize a struct dvb_mpeg_es_seq_start from buffer
* @ingroup dvb_table
*
* @param buf Buffer
* @param buflen Length of buffer
* @param seq_start Pointer to allocated struct dvb_mpeg_es_seq_start
*
* @return If buflen too small, return -1, 0 otherwise.
*
* This function copies the length of struct dvb_mpeg_es_seq_start
* to seq_start and fixes endianness. seq_start has to be allocated
* with malloc.
*/
int dvb_mpeg_es_seq_start_init (const uint8_t *buf, ssize_t buflen,
struct dvb_mpeg_es_seq_start *seq_start);
/**
* @brief Print details of struct dvb_mpeg_es_seq_start
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms for log functions
* @param seq_start Pointer to struct dvb_mpeg_es_seq_start to print
*
* This function prints the fields of struct dvb_mpeg_es_seq_start
*/
void dvb_mpeg_es_seq_start_print(struct dvb_v5_fe_parms *parms,
struct dvb_mpeg_es_seq_start *seq_start);
/**
* @brief Initialize a struct dvb_mpeg_es_pic_start from buffer
* @ingroup dvb_table
*
* @param buf Buffer
* @param buflen Length of buffer
* @param pic_start Pointer to allocated structdvb_mpeg_es_pic_start
*
* @return If buflen too small, return -1, 0 otherwise.
*
* This function copies the length of struct dvb_mpeg_es_pic_start
* to pic_start and fixes endianness. seq_start has to be allocated
* with malloc.
*/
int dvb_mpeg_es_pic_start_init (const uint8_t *buf, ssize_t buflen,
struct dvb_mpeg_es_pic_start *pic_start);
/**
* @brief Print details of struct dvb_mpeg_es_pic_start
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms for log functions
* @param pic_start Pointer to struct dvb_mpeg_es_pic_start to print
*
* This function prints the fields of struct dvb_mpeg_es_pic_start
*/
void dvb_mpeg_es_pic_start_print(struct dvb_v5_fe_parms *parms,
struct dvb_mpeg_es_pic_start *pic_start);
#ifdef __cplusplus
}
#endif
#endif

248
include/libdvbv5/mpeg_pes.h Normal file
View File

@@ -0,0 +1,248 @@
/*
* Copyright (c) 2013-2014 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#ifndef _MPEG_PES_H
#define _MPEG_PES_H
/**
* @file mpeg_pes.h
* @ingroup dvb_table
* @brief Provides the table parser for the MPEG-PES Elementary Stream
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Andre Roth
*
* @par Relevant specs
* The table described herein is defined in ISO 13818-1
*
* @see
* http://dvd.sourceforge.net/dvdinfo/pes-hdr.html
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#include <stdint.h>
#include <unistd.h> /* ssize_t */
/**
* @def DVB_MPEG_PES
* @brief MPEG Packetized Elementary Stream magic
* @ingroup dvb_table
* @def DVB_MPEG_PES_AUDIO
* @brief PES Audio
* @ingroup dvb_table
* @def DVB_MPEG_PES_VIDEO
* @brief PES Video
* @ingroup dvb_table
* @def DVB_MPEG_STREAM_MAP
* @brief PES Stream map
* @ingroup dvb_table
* @def DVB_MPEG_STREAM_PADDING
* @brief PES padding
* @ingroup dvb_table
* @def DVB_MPEG_STREAM_PRIVATE_2
* @brief PES private
* @ingroup dvb_table
* @def DVB_MPEG_STREAM_ECM
* @brief PES ECM Stream
* @ingroup dvb_table
* @def DVB_MPEG_STREAM_EMM
* @brief PES EMM Stream
* @ingroup dvb_table
* @def DVB_MPEG_STREAM_DIRECTORY
* @brief PES Stream directory
* @ingroup dvb_table
* @def DVB_MPEG_STREAM_DSMCC
* @brief PES DSMCC
* @ingroup dvb_table
* @def DVB_MPEG_STREAM_H222E
* @brief PES H.222.1 type E
* @ingroup dvb_table
*/
#define DVB_MPEG_PES 0x00001
#define DVB_MPEG_PES_AUDIO 0xc0 ... 0xcf
#define DVB_MPEG_PES_VIDEO 0xe0 ... 0xef
#define DVB_MPEG_STREAM_MAP 0xBC
#define DVB_MPEG_STREAM_PADDING 0xBE
#define DVB_MPEG_STREAM_PRIVATE_2 0x5F
#define DVB_MPEG_STREAM_ECM 0x70
#define DVB_MPEG_STREAM_EMM 0x71
#define DVB_MPEG_STREAM_DIRECTORY 0xFF
#define DVB_MPEG_STREAM_DSMCC 0x7A
#define DVB_MPEG_STREAM_H222E 0xF8
/**
* @struct ts_t
* @brief MPEG PES timestamp structure, used for dts and pts
* @ingroup dvb_table
*
* @param tag 4 bits Should be 0010 for PTS and 0011 for DTS
* @param bits30 3 bits Timestamp bits 30-32
* @param one 1 bit Sould be 1
* @param bits15 15 bits Timestamp bits 15-29
* @param one1 1 bit Should be 1
* @param bits00 15 Bits Timestamp bits 0-14
* @param one2 1 bit Should be 1
*/
struct ts_t {
uint8_t one:1;
uint8_t bits30:3;
uint8_t tag:4;
union {
uint16_t bitfield;
struct {
uint16_t one1:1;
uint16_t bits15:15;
} __attribute__((packed));
} __attribute__((packed));
union {
uint16_t bitfield2;
struct {
uint16_t one2:1;
uint16_t bits00:15;
} __attribute__((packed));
} __attribute__((packed));
} __attribute__((packed));
/**
* @struct dvb_mpeg_pes_optional
* @brief MPEG PES optional header
* @ingroup dvb_table
*
* @param two 2 bits Should be 10
* @param PES_scrambling_control 2 bits PES Scrambling Control (Not Scrambled=00, otherwise scrambled)
* @param PES_priority 1 bit PES Priority
* @param data_alignment_indicator 1 bit PES data alignment
* @param copyright 1 bit PES content protected by copyright
* @param original_or_copy 1 bit PES content is original (=1) or copied (=0)
* @param PTS_DTS 2 bit PES header contains PTS (=10, =11) and/or DTS (=01, =11)
* @param ESCR 1 bit PES header contains ESCR fields
* @param ES_rate 1 bit PES header contains ES_rate field
* @param DSM_trick_mode 1 bit PES header contains DSM_trick_mode field
* @param additional_copy_info 1 bit PES header contains additional_copy_info field
* @param PES_CRC 1 bit PES header contains CRC field
* @param PES_extension 1 bit PES header contains extension field
* @param length 8 bit PES header data length
* @param pts 64 bit PES PTS timestamp
* @param dts 64 bit PES DTS timestamp
*/
struct dvb_mpeg_pes_optional {
union {
uint16_t bitfield;
struct {
uint16_t PES_extension:1;
uint16_t PES_CRC:1;
uint16_t additional_copy_info:1;
uint16_t DSM_trick_mode:1;
uint16_t ES_rate:1;
uint16_t ESCR:1;
uint16_t PTS_DTS:2;
uint16_t original_or_copy:1;
uint16_t copyright:1;
uint16_t data_alignment_indicator:1;
uint16_t PES_priority:1;
uint16_t PES_scrambling_control:2;
uint16_t two:2;
} __attribute__((packed));
} __attribute__((packed));
uint8_t length;
uint64_t pts;
uint64_t dts;
} __attribute__((packed));
/**
* @struct dvb_mpeg_pes
* @brief MPEG PES data structure
* @ingroup dvb_table
*
* @param sync 24 bits DVB_MPEG_PES
* @param stream_id 8 bits PES Stream ID
* @param length 16 bits PES packet length
* @param optional Pointer to optional PES header
*/
struct dvb_mpeg_pes {
union {
uint32_t bitfield;
struct {
uint32_t stream_id:8;
uint32_t sync:24;
} __attribute__((packed));
} __attribute__((packed));
uint16_t length;
struct dvb_mpeg_pes_optional optional[];
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize a struct dvb_mpeg_pes from buffer
* @ingroup dvb_table
*
* @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_pes
*
* @return Length of data in table
*
* This function copies the length of struct dvb_mpeg_pes
* to table and fixes endianness. The pointer table has to be
* allocated on stack or dynamically.
*/
ssize_t dvb_mpeg_pes_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen,
uint8_t *table);
/**
* @brief Deallocate memory associated with a struct dvb_mpeg_pes
* @ingroup dvb_table
*
* @param pes struct dvb_mpeg_pes to be deallocated
*
* If the pointer pes was allocated dynamically, this function
* can be used to free the memory.
*/
void dvb_mpeg_pes_free(struct dvb_mpeg_pes *pes);
/**
* @brief Print details of struct dvb_mpeg_pes
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms for log functions
* @param pes Pointer to struct dvb_mpeg_pes to print
*
* This function prints the fields of struct dvb_mpeg_pes
*/
void dvb_mpeg_pes_print (struct dvb_v5_fe_parms *parms, struct dvb_mpeg_pes *pes);
#ifdef __cplusplus
}
#endif
#endif

172
include/libdvbv5/mpeg_ts.h Normal file
View File

@@ -0,0 +1,172 @@
/*
* Copyright (c) 2013-2014 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#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 Lesser General Public License version 2.1 (LGPLv2.1)
* @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 <stdint.h>
#include <unistd.h> /* 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
* @ingroup dvb_table
*
* @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 {
uint8_t extension:1;
uint8_t private_data:1;
uint8_t splicing_point:1;
uint8_t OPCR:1;
uint8_t PCR:1;
uint8_t priority:1;
uint8_t random_access:1;
uint8_t discontinued:1;
} __attribute__((packed));
uint8_t data[];
} __attribute__((packed));
/**
* @struct dvb_mpeg_ts
* @brief MPEG TS header
* @ingroup dvb_table
*
* @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;
union {
uint16_t bitfield;
struct {
uint16_t pid:13;
uint16_t priority:1;
uint16_t payload_start:1;
uint16_t tei:1;
} __attribute__((packed));
} __attribute__((packed));
struct {
uint8_t continuity_counter:4;
uint8_t payload:1;
uint8_t adaptation_field:1;
uint8_t scrambling:2;
} __attribute__((packed));
struct dvb_mpeg_ts_adaption adaption[];
} __attribute__((packed));
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize a struct dvb_mpeg_ts from buffer
* @ingroup dvb_table
*
* @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. The pointer table has to be allocated
* on stack or dynamically.
*/
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 dvb_table
*
* @param ts struct dvb_mpeg_ts to be deallocated
*
* If ts was allocated dynamically, this function
* can be used to free the memory.
*/
void dvb_mpeg_ts_free(struct dvb_mpeg_ts *ts);
/**
* @brief Print details of struct dvb_mpeg_ts
* @ingroup dvb_table
*
* @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
}
#endif
#endif

276
include/libdvbv5/nit.h Normal file
View File

@@ -0,0 +1,276 @@
/*
* Copyright (c) 2011-2012 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#ifndef _NIT_H
#define _NIT_H
#include <stdint.h>
#include <unistd.h> /* ssize_t */
#include <libdvbv5/header.h>
#include <libdvbv5/descriptors.h>
/**
* @file nit.h
* @ingroup dvb_table
* @brief Provides the descriptors for NIT MPEG-TS table
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Bug Report
* Please submit bug report and patches to linux-media@vger.kernel.org
*
* @par Relevant specs
* The table described herein is defined at:
* - ISO/IEC 13818-1
* - ETSI EN 300 468
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
/**
* @def DVB_TABLE_NIT
* @brief NIT table ID
* @ingroup dvb_table
* @def DVB_TABLE_NIT2
* @brief NIT table ID (alternative table ID)
* @ingroup dvb_table
* @def DVB_TABLE_NIT_PID
* @brief NIT Program ID
* @ingroup dvb_table
*/
#define DVB_TABLE_NIT 0x40
#define DVB_TABLE_NIT2 0x41
#define DVB_TABLE_NIT_PID 0x10
/**
* @union dvb_table_nit_transport_header
* @brief MPEG-TS NIT transport header
* @ingroup dvb_table
*
* @param transport_length transport length
*
* This structure is used to store the original NIT transport header,
* converting the integer fields to the CPU endianness.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*/
union dvb_table_nit_transport_header {
uint16_t bitfield;
struct {
uint16_t transport_length:12;
uint16_t reserved:4;
} __attribute__((packed));
} __attribute__((packed));
/**
* @struct dvb_table_nit_transport
* @brief MPEG-TS NIT transport table
* @ingroup dvb_table
*
* @param transport_id transport id
* @param network_id network id
* @param desc_length desc length
* @param descriptor pointer to struct dvb_desc
* @param next pointer to struct dvb_table_nit_transport
*
* This structure is used to store the original NIT transport table,
* converting the integer fields to the CPU endianness.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*
* Everything after dvb_table_nit_transport::descriptor (including it) won't
* be bit-mapped to the data parsed from the MPEG TS. So, metadata are added
* there.
*/
struct dvb_table_nit_transport {
uint16_t transport_id;
uint16_t network_id;
union {
uint16_t bitfield;
struct {
uint16_t desc_length:12;
uint16_t reserved:4;
} __attribute__((packed));
} __attribute__((packed));
struct dvb_desc *descriptor;
struct dvb_table_nit_transport *next;
} __attribute__((packed));
/**
* @struct dvb_table_nit
* @brief MPEG-TS NIT table
* @ingroup dvb_table
*
* @param header struct dvb_table_header content
* @param desc_length descriptor length
* @param descriptor pointer to struct dvb_desc
* @param transport pointer to struct dvb_table_nit_transport
*
* This structure is used to store the original NIT table,
* converting the integer fields to the CPU endianness.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*
* Everything after dvb_table_nit::descriptor (including it) won't be bit-mapped
* to the data parsed from the MPEG TS. So, metadata are added there.
*/
struct dvb_table_nit {
struct dvb_table_header header;
union {
uint16_t bitfield;
struct {
uint16_t desc_length:12;
uint16_t reserved:4;
} __attribute__((packed));
} __attribute__((packed));
struct dvb_desc *descriptor;
struct dvb_table_nit_transport *transport;
} __attribute__((packed));
/**
* @brief typedef for a callback used when a NIT table entry is found
* @ingroup dvb_table
*
* @param nit a struct dvb_table_nit pointer
* @param desc a struct dvb_desc pointer
* @param priv an opaque optional pointer
*/
typedef void nit_handler_callback_t(struct dvb_table_nit *nit,
struct dvb_desc *desc,
void *priv);
/**
* @brief typedef for a callback used when a NIT transport table entry is found
* @ingroup dvb_table
*
* @param nit a struct dvb_table_nit pointer
* @param tran a struct dvb_table_nit_transport pointer
* @param desc a struct dvb_desc pointer
* @param priv an opaque optional pointer
*/
typedef void nit_tran_handler_callback_t(struct dvb_table_nit *nit,
struct dvb_table_nit_transport *tran,
struct dvb_desc *desc,
void *priv);
/**
* @brief Macro used to find a transport inside a NIT table
* @ingroup dvb_table
*
* @param _tran transport to seek
* @param _nit pointer to struct dvb_table_nit_transport
*/
#define dvb_nit_transport_foreach( _tran, _nit ) \
if (_nit && _nit->transport) \
for (struct dvb_table_nit_transport *_tran = _nit->transport; _tran; _tran = _tran->next) \
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses NIT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the NIT raw data
* @param buflen length of the buffer
* @param table pointer to struct dvb_table_nit to be allocated and filled
*
* This function allocates a NIT table and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
ssize_t dvb_table_nit_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf,
ssize_t buflen, struct dvb_table_nit **table);
/**
* @brief Frees all data allocated by the NIT table parser
* @ingroup dvb_table
*
* @param table pointer to struct dvb_table_nit to be freed
*/
void dvb_table_nit_free(struct dvb_table_nit *table);
/**
* @brief Prints the content of the NIT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param table pointer to struct dvb_table_nit
*/
void dvb_table_nit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_nit *table);
/**
* @brief For each entry at NIT and NIT transport tables, call a callback
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param table pointer to struct dvb_table_nit
* @param descriptor indicates the NIT table descriptor to seek
* @param call_nit a nit_handler_callback_t function to be called when a
* new entry at the NIT table is found (or NULL).
* @param call_tran a nit_tran_handler_callback_t function to be called
* when a new entry at the NIT transport table is found
* (or NULL).
* @param priv an opaque pointer to be optionally used by the
* callbacks. The function won't touch on it, just use
* as an argument for the callback functions.
*
* When parsing a NIT entry, we need to call some code to properly handle
* when a given descriptor in the table is found. This is used, for example,
* to create newer transponders to seek during scan.
*
* For example, to seek for the CATV delivery system descriptor and call a
* function that would add a new transponder to a scan procedure:
* @code
* dvb_table_nit_descriptor_handler(
* &parms->p, dvb_scan_handler->nit,
* cable_delivery_system_descriptor,
* NULL, add_update_nit_dvbc, &tr);
* @endcode
*/
void dvb_table_nit_descriptor_handler(
struct dvb_v5_fe_parms *parms,
struct dvb_table_nit *table,
enum descriptors descriptor,
nit_handler_callback_t *call_nit,
nit_tran_handler_callback_t *call_tran,
void *priv);
#ifdef __cplusplus
}
#endif
#endif

172
include/libdvbv5/pat.h Normal file
View File

@@ -0,0 +1,172 @@
/*
* Copyright (c) 2011-2012 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file pat.h
* @ingroup dvb_table
* @brief Provides the descriptors for PAT MPEG-TS table
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The table described herein is defined at:
* - ISO/IEC 13818-1
*
* @see http://www.etherguidesystems.com/help/sdos/mpeg/syntax/tablesections/pat.aspx
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _PAT_H
#define _PAT_H
#include <stdint.h>
#include <unistd.h> /* ssize_t */
#include <libdvbv5/header.h>
/**
* @def DVB_TABLE_PAT
* @brief PAT table ID
* @ingroup dvb_table
* @def DVB_TABLE_PAT_PID
* @brief PAT Program ID
* @ingroup dvb_table
*/
#define DVB_TABLE_PAT 0x00
#define DVB_TABLE_PAT_PID 0x0000
/**
* @struct dvb_table_pat_program
* @brief MPEG-TS PAT program table
* @ingroup dvb_table
*
* @param service_id service id
* @param pid pid
* @param next pointer to struct dvb_table_pat_program
*
* This structure is used to store the original PAT program table,
* converting the integer fields to the CPU endianness.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*
* Everything after dvb_table_pat_program::next (including it) won't be bit-mapped
* to the data parsed from the MPEG TS. So, metadata are added there.
*/
struct dvb_table_pat_program {
uint16_t service_id;
union {
uint16_t bitfield;
struct {
uint16_t pid:13;
uint8_t reserved:3;
} __attribute__((packed));
} __attribute__((packed));
struct dvb_table_pat_program *next;
} __attribute__((packed));
/**
* @struct dvb_table_pat
* @brief MPEG-TS PAT table
* @ingroup dvb_table
*
* @param header struct dvb_table_header content
* @param programs number of programs
* @param program pointer to struct dvb_table_pat_program
* This structure is used to store the original PAT table,
* converting the integer fields to the CPU endianness.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*
* Everything after dvb_table_pat_program::program (including it) won't be bit-mapped
* to the data parsed from the MPEG TS. So, metadata are added there.
*/
struct dvb_table_pat {
struct dvb_table_header header;
uint16_t programs;
struct dvb_table_pat_program *program;
} __attribute__((packed));
/**
* @brief Macro used to find programs on a PAT table
* @ingroup dvb_table
*
* @param _pgm program to seek
* @param _pat pointer to struct dvb_table_pat_program
*/
#define dvb_pat_program_foreach(_pgm, _pat) \
if (_pat && _pat->program) \
for (struct dvb_table_pat_program *_pgm = _pat->program; _pgm; _pgm = _pgm->next) \
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses PAT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the PAT raw data
* @param buflen length of the buffer
* @param table pointer to struct dvb_table_pat to be allocated and filled
*
* This function allocates a PAT table and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
ssize_t dvb_table_pat_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf,
ssize_t buflen, struct dvb_table_pat **table);
/**
* @brief Frees all data allocated by the PAT table parser
* @ingroup dvb_table
*
* @param table pointer to struct dvb_table_pat to be freed
*/
void dvb_table_pat_free(struct dvb_table_pat *table);
/**
* @brief Prints the content of the PAT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param table pointer to struct dvb_table_pat
*/
void dvb_table_pat_print(struct dvb_v5_fe_parms *parms,
struct dvb_table_pat *table);
#ifdef __cplusplus
}
#endif
#endif

300
include/libdvbv5/pmt.h Normal file
View File

@@ -0,0 +1,300 @@
/*
* Copyright (c) 2011-2012 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file pmt.h
* @ingroup dvb_table
* @brief Provides the descriptors for PMT MPEG-TS table
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The table described herein is defined at:
* - ISO/IEC 13818-1
*
* @see http://www.etherguidesystems.com/help/sdos/mpeg/syntax/tablesections/pmts.aspx
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _PMT_H
#define _PMT_H
#include <stdint.h>
#include <unistd.h> /* ssize_t */
#include <libdvbv5/header.h>
/**
* @def DVB_TABLE_PMT
* @brief PMT table ID
* @ingroup dvb_table
*/
#define DVB_TABLE_PMT 0x02
/**
* @enum dvb_streams
* @brief Add support for MPEG-TS Stream types
* @ingroup dvb_table
*
* @var stream_reserved0
* @brief ITU-T | ISO/IEC Reserved
* @var stream_video
* @brief ISO/IEC 11172 Video
* @var stream_video_h262
* @brief ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream
* @var stream_audio
* @brief ISO/IEC 11172 Audio
* @var stream_audio_13818_3
* @brief ISO/IEC 13818-3 Audio
* @var stream_private_sections
* @brief ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections
* @var stream_private_data
* @brief ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data
* @var stream_mheg
* @brief ISO/IEC 13522 MHEG
* @var stream_h222
* @brief ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM-CC
* @var stream_h222_1
* @brief ITU-T Rec. H.222.1
* @var stream_13818_6_A
* @brief ISO/IEC 13818-6 type A
* @var stream_13818_6_B
* @brief ISO/IEC 13818-6 type B
* @var stream_13818_6_C
* @brief ISO/IEC 13818-6 type C
* @var stream_13818_6_D
* @brief ISO/IEC 13818-6 type D
* @var stream_h222_aux
* @brief ITU-T Rec. H.222.0 | ISO/IEC 13818-1 auxiliary
* @var stream_audio_adts
* @brief ISO/IEC 13818-7 Audio with ADTS transport syntax
* @var stream_video_14496_2
* @brief ISO/IEC 14496-2 Visual
* @var stream_audio_latm
* @brief ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3 / AMD 1
* @var stream_14496_1_pes
* @brief ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in PES packets
* @var stream_14496_1_iso
* @brief ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in ISO/IEC14496_sections.
* @var stream_download
* @brief ISO/IEC 13818-6 Synchronized Download Protocol
* @var stream_reserved
* @brief ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved (from 0x15 to 0x7f)
* @var stream_private
* @brief User Private (from 0x80 to 0xff)
*/
enum dvb_streams {
stream_video = 0x01,
stream_video_h262 = 0x02,
stream_audio = 0x03,
stream_audio_13818_3 = 0x04,
stream_private_sections = 0x05,
stream_private_data = 0x06,
stream_mheg = 0x07,
stream_h222 = 0x08,
stream_h222_1 = 0x09,
stream_13818_6_A = 0x0A,
stream_13818_6_B = 0x0B,
stream_13818_6_C = 0x0C,
stream_13818_6_D = 0x0D,
stream_h222_aux = 0x0E,
stream_audio_adts = 0x0F,
stream_video_14496_2 = 0x10,
stream_audio_latm = 0x11,
stream_14496_1_pes = 0x12,
stream_14496_1_iso = 0x13,
stream_download = 0x14,
stream_video_h264 = 0x1b,
stream_audio_14496_3 = 0x1c,
stream_video_hevc = 0x24,
stream_video_cavs = 0x42,
stream_video_moto = 0x80,
stream_audio_a52 = 0x81,
stream_scte_27 = 0x82,
stream_audio_sdds = 0x84,
stream_audio_dts_hdmv = 0x85,
stream_audio_e_ac3 = 0x87,
stream_audio_dts = 0x8a,
stream_audio_a52_vls = 0x91,
stream_spu_vls = 0x92,
stream_audio_sdds2 = 0x94,
};
/**
* @brief Converts from enum dvb_streams into a string
* @ingroup dvb_table
*/
extern const char *pmt_stream_name[];
/**
* @struct dvb_table_pmt_stream
* @brief MPEG-TS PMT stream table
* @ingroup dvb_table
*
* @param type stream type
* @param elementary_pid elementary pid
* @param desc_length descriptor length
* @param zero zero
* @param descriptor pointer to struct dvb_desc
* @param next pointer to struct dvb_table_pmt_stream
*
* This structure is used to store the original PMT stream table,
* converting the integer fields to the CPU endianness.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*
* Everything after dvb_table_pmt_stream::descriptor (including it) won't be
* bit-mapped to the data parsed from the MPEG TS. So, metadata are added there.
*/
struct dvb_table_pmt_stream {
uint8_t type;
union {
uint16_t bitfield;
struct {
uint16_t elementary_pid:13;
uint16_t reserved:3;
} __attribute__((packed));
} __attribute__((packed));
union {
uint16_t bitfield2;
struct {
uint16_t desc_length:10;
uint16_t zero:2;
uint16_t reserved2:4;
} __attribute__((packed));
} __attribute__((packed));
struct dvb_desc *descriptor;
struct dvb_table_pmt_stream *next;
} __attribute__((packed));
/**
* @struct dvb_table_pmt
* @brief MPEG-TS PMT table
* @ingroup dvb_table
*
* @param header struct dvb_table_header content
* @param pcr_pid PCR PID
* @param desc_length descriptor length
* @param descriptor pointer to struct dvb_desc
* @param stream pointer to struct dvb_table_pmt_stream
*
* This structure is used to store the original PMT stream table,
* converting the integer fields to the CPU endianness.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*
* Everything after dvb_table_pmt::descriptor (including it) won't be
* bit-mapped to the data parsed from the MPEG TS. So, metadata are added there.
*/
struct dvb_table_pmt {
struct dvb_table_header header;
union {
uint16_t bitfield;
struct {
uint16_t pcr_pid:13;
uint16_t reserved2:3;
} __attribute__((packed));
} __attribute__((packed));
union {
uint16_t bitfield2;
struct {
uint16_t desc_length:10;
uint16_t zero3:2;
uint16_t reserved3:4;
} __attribute__((packed));
} __attribute__((packed));
struct dvb_desc *descriptor;
struct dvb_table_pmt_stream *stream;
} __attribute__((packed));
/** @brief First field at the struct */
#define dvb_pmt_field_first header
/** @brief First field that are not part of the received data */
#define dvb_pmt_field_last descriptor
/**
* @brief Macro used to find streams on a PMT table
* @ingroup dvb_table
*
* @param _stream stream to seek
* @param _pmt pointer to struct dvb_table_pmt_stream
*/
#define dvb_pmt_stream_foreach(_stream, _pmt) \
if (_pmt && _pmt->stream) \
for (struct dvb_table_pmt_stream *_stream = _pmt->stream; _stream; _stream = _stream->next) \
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses PMT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the PMT raw data
* @param buflen length of the buffer
* @param table pointer to struct dvb_table_pmt to be allocated and filled
*
* This function allocates a PMT table and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
ssize_t dvb_table_pmt_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf,
ssize_t buflen, struct dvb_table_pmt **table);
/**
* @brief Frees all data allocated by the PMT table parser
* @ingroup dvb_table
*
* @param table pointer to struct dvb_table_pmt to be freed
*/
void dvb_table_pmt_free(struct dvb_table_pmt *table);
/**
* @brief Prints the content of the PAT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param table pointer to struct dvb_table_pmt
*/
void dvb_table_pmt_print(struct dvb_v5_fe_parms *parms,
const struct dvb_table_pmt *table);
#ifdef __cplusplus
}
#endif
#endif

187
include/libdvbv5/sdt.h Normal file
View File

@@ -0,0 +1,187 @@
/*
* Copyright (c) 2011-2012 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#ifndef _SDT_H
#define _SDT_H
/**
* @file sdt.h
* @ingroup dvb_table
* @brief Provides the descriptors for SDT MPEG-TS table
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The table described herein is defined at:
* - ISO/IEC 13818-1
*
* @see http://www.etherguidesystems.com/Help/SDOs/dvb/syntax/tablesections/SDT.aspx
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#include <stdint.h>
#include <unistd.h> /* ssize_t */
#include <libdvbv5/header.h>
/**
* @def DVB_TABLE_SDT
* @brief SDT table ID
* @ingroup dvb_table
* @def DVB_TABLE_SDT2
* @brief SDT table ID (alternative table ID)
* @ingroup dvb_table
* @def DVB_TABLE_SDT_PID
* @brief SDT Program ID
* @ingroup dvb_table
*/
#define DVB_TABLE_SDT 0x42
#define DVB_TABLE_SDT2 0x46
#define DVB_TABLE_SDT_PID 0x0011
/**
* @struct dvb_table_sdt_service
* @brief MPEG-TS SDT service table
* @ingroup dvb_table
*
* @param service_id service id
* @param EIT_present_following EIT present following
* @param EIT_schedule EIT schedule
* @param desc_length desc length
* @param free_CA_mode free CA mode
* @param running_status running status
* @param descriptor pointer to struct dvb_desc
* @param next pointer to struct dvb_table_sdt_service
*
* This structure is used to store the original SDT service table,
* converting the integer fields to the CPU endianness.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*
* Everything after dvb_table_sdt_service::descriptor (including it) won't
* be bit-mapped to the data parsed from the MPEG TS. So, metadata are added
* there.
*/
struct dvb_table_sdt_service {
uint16_t service_id;
uint8_t EIT_present_following:1;
uint8_t EIT_schedule:1;
uint8_t reserved:6;
union {
uint16_t bitfield;
struct {
uint16_t desc_length:12;
uint16_t free_CA_mode:1;
uint16_t running_status:3;
} __attribute__((packed));
} __attribute__((packed));
struct dvb_desc *descriptor;
struct dvb_table_sdt_service *next;
} __attribute__((packed));
/**
* @struct dvb_table_sdt
* @brief MPEG-TS SDT table
* @ingroup dvb_table
*
* @param header struct dvb_table_header content
* @param network_id network id
* @param service pointer to struct dvb_table_sdt_service
*
* This structure is used to store the original SDT table,
* converting the integer fields to the CPU endianness.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*
* Everything after dvb_table_sdt::service (including it) won't be bit-mapped
* to the data parsed from the MPEG TS. So, metadata are added there.
*/
struct dvb_table_sdt {
struct dvb_table_header header;
uint16_t network_id;
uint8_t reserved;
struct dvb_table_sdt_service *service;
} __attribute__((packed));
/**
* @brief Macro used to find services on a SDT table
* @ingroup dvb_table
*
* @param _service service to seek
* @param _sdt pointer to struct dvb_table_sdt_service
*/
#define dvb_sdt_service_foreach(_service, _sdt) \
if (_sdt && _sdt->service) \
for (struct dvb_table_sdt_service *_service = _sdt->service; _service; _service = _service->next ) \
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses SDT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the SDT raw data
* @param buflen length of the buffer
* @param table pointer to struct dvb_table_sdt to be allocated and filled
*
* This function allocates a SDT table and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
ssize_t dvb_table_sdt_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf,
ssize_t buflen, struct dvb_table_sdt **table);
/**
* @brief Frees all data allocated by the SDT table parser
* @ingroup dvb_table
*
* @param table pointer to struct dvb_table_sdt to be freed
*/
void dvb_table_sdt_free(struct dvb_table_sdt *table);
/**
* @brief Prints the content of the SDT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param table pointer to struct dvb_table_sdt
*/
void dvb_table_sdt_print(struct dvb_v5_fe_parms *parms, struct dvb_table_sdt *table);
#ifdef __cplusplus
}
#endif
#endif

251
include/libdvbv5/vct.h Normal file
View File

@@ -0,0 +1,251 @@
/*
* Copyright (c) 2013 - Mauro Carvalho Chehab <mchehab@kernel.org>
* Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
/**
* @file vct.h
* @ingroup dvb_table
* @brief Provides the descriptors for TVCT and CVCT tables
* @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* @par Relevant specs
* The table described herein is defined at:
* - ATSC A/65:2009
*
* @see http://www.etherguidesystems.com/help/sdos/atsc/syntax/tablesections/TVCT.aspx
* @see http://www.etherguidesystems.com/help/sdos/atsc/syntax/tablesections/CVCT.aspx
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#ifndef _VCT_H
#define _VCT_H
#include <stdint.h>
#include <unistd.h> /* ssize_t */
#include <libdvbv5/atsc_header.h>
/**
* @def ATSC_TABLE_TVCT
* @brief TVCT table ID
* @ingroup dvb_table
* @def ATSC_TABLE_CVCT
* @brief CVCT table ID
* @ingroup dvb_table
* @def ATSC_TABLE_VCT_PID
* @brief Program ID with the VCT tables on it
* @ingroup dvb_table
*/
#define ATSC_TABLE_TVCT 0xc8
#define ATSC_TABLE_CVCT 0xc9
#define ATSC_TABLE_VCT_PID 0x1ffb
/**
* @struct atsc_table_vct_channel
* @brief ATSC VCT channel table (covers both CVCT and TVCT)
* @ingroup dvb_table
*
* @param modulation_mode modulation mode
* @param minor_channel_number minor channel number
* @param major_channel_number major channel number
* @param carrier_frequency carrier frequency
* @param channel_tsid channel tsid
* @param program_number program number
* @param service_type service type
* @param hide_guide hide guide
* @param out_of_band out of band (CVCT only)
* @param path_select path select (CVCT only)
* @param hidden hidden
* @param access_controlled access controlled
* @param ETM_location ETM location
* @param source_id source ID
* @param descriptors_length length of the descriptors
*
* @param descriptor pointer to struct dvb_desc
* @param next pointer to another struct atsc_table_vct_channel
* @param descriptors_length length of the descriptors
* @param short_name short name. The __short_name is converted
* from UTF-16 to locale charset when parsed
*
* This structure is used to store the original VCT channel table,
* converting the integer fields to the CPU endianness.
*
* The undocumented parameters are used only internally by the API and/or
* are fields that are reserved. They shouldn't be used, as they may change
* on future API releases.
*
* Everything after atsc_table_vct_channel::descriptor (including it) won't
* be bit-mapped * to the data parsed from the MPEG TS. So, metadata are
* added there.
*/
struct atsc_table_vct_channel {
uint16_t __short_name[7];
union {
uint32_t bitfield1;
struct {
uint32_t modulation_mode:8;
uint32_t minor_channel_number:10;
uint32_t major_channel_number:10;
uint32_t reserved1:4;
} __attribute__((packed));
} __attribute__((packed));
uint32_t carrier_frequency;
uint16_t channel_tsid;
uint16_t program_number;
union {
uint16_t bitfield2;
struct {
uint16_t service_type:6;
uint16_t reserved2:3;
uint16_t hide_guide:1;
uint16_t out_of_band:1; /* CVCT only */
uint16_t path_select:1; /* CVCT only */
uint16_t hidden:1;
uint16_t access_controlled:1;
uint16_t ETM_location:2;
} __attribute__((packed));
} __attribute__((packed));
uint16_t source_id;
union {
uint16_t bitfield3;
struct {
uint16_t descriptors_length:10;
uint16_t reserved3:6;
} __attribute__((packed));
} __attribute__((packed));
/*
* Everything after atsc_table_vct_channel::descriptor (including it)
* won't be bit-mapped to the data parsed from the MPEG TS. So,
* metadata are added there
*/
struct dvb_desc *descriptor;
struct atsc_table_vct_channel *next;
/* The channel_short_name is converted to locale charset by vct.c */
char short_name[32];
} __attribute__((packed));
/**
* @struct atsc_table_vct
* @brief ATSC VCT table (covers both CVCT and TVCT)
* @ingroup dvb_table
*
* @param header struct dvb_table_header content
* @param protocol_version protocol version
* @param num_channels_in_section num channels in section
* @param channel pointer to struct channel
* @param descriptor pointer to struct descriptor
*
* Everything after atsc_table_vct::channel (including it) won't be bit-mapped
* to the data parsed from the MPEG TS. So, metadata are added there
*/
struct atsc_table_vct {
struct dvb_table_header header;
uint8_t protocol_version;
uint8_t num_channels_in_section;
struct atsc_table_vct_channel *channel;
struct dvb_desc *descriptor;
} __attribute__((packed));
/**
* @union atsc_table_vct_descriptor_length
* @brief ATSC VCT descriptor length
* @ingroup dvb_table
*
* @param descriptor_length descriptor length
*
* Used internally by the library to parse the descriptor length endianness.
*/
union atsc_table_vct_descriptor_length {
uint16_t bitfield;
struct {
uint16_t descriptor_length:10;
uint16_t reserved:6;
} __attribute__((packed));
} __attribute__((packed));
/**
* @brief Macro used to find channels on a VCT table
* @ingroup dvb_table
*
* @param _channel channel to seek
* @param _vct pointer to struct atsc_table_vct_channel
*/
#define atsc_vct_channel_foreach(_channel, _vct) \
if (_vct && _vct->channel) \
for (struct atsc_table_vct_channel *_channel = _vct->channel; _channel; _channel = _channel->next) \
struct dvb_v5_fe_parms;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes and parses VCT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param buf buffer containing the VCT raw data
* @param buflen length of the buffer
* @param table pointer to struct atsc_table_vct to be allocated and filled
*
* This function allocates an ATSC VCT table and fills the fields inside
* the struct. It also makes sure that all fields will follow the CPU
* endianness. Due to that, the content of the buffer may change.
*
* @return On success, it returns the size of the allocated struct.
* A negative value indicates an error.
*/
ssize_t atsc_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
ssize_t buflen, struct atsc_table_vct **table);
/**
* @brief Frees all data allocated by the VCT table parser
* @ingroup dvb_table
*
* @param table pointer to struct atsc_table_vct to be freed
*/
void atsc_table_vct_free(struct atsc_table_vct *table);
/**
* @brief Prints the content of the VCT table
* @ingroup dvb_table
*
* @param parms struct dvb_v5_fe_parms pointer to the opened device
* @param table pointer to struct atsc_table_vct
*/
void atsc_table_vct_print(struct dvb_v5_fe_parms *parms,
struct atsc_table_vct *table);
#ifdef __cplusplus
}
#endif
#endif

46
include/libv4l-plugin.h Normal file
View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2010 Nokia Corporation <multimedia@maemo.org>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __LIBV4L_PLUGIN_H
#define __LIBV4L_PLUGIN_H
#include <sys/types.h>
/* Structure libv4l_dev_ops holds the calls from libv4ls to video nodes.
They can be normal open/close/ioctl etc. or any of them may be replaced
with a callback by a loaded plugin.
*/
struct libv4l_dev_ops {
void * (*init)(int fd);
void (*close)(void *dev_ops_priv);
int (*ioctl)(void *dev_ops_priv, int fd, unsigned long int request, void *arg);
ssize_t (*read)(void *dev_ops_priv, int fd, void *buffer, size_t n);
ssize_t (*write)(void *dev_ops_priv, int fd, const void *buffer, size_t n);
/* For future plugin API extension, plugins implementing the current API
must set these all to NULL, as future versions may check for these */
void (*reserved1)(void);
void (*reserved2)(void);
void (*reserved3)(void);
void (*reserved4)(void);
void (*reserved5)(void);
void (*reserved6)(void);
void (*reserved7)(void);
};
#endif

207
include/libv4l1-videodev.h Normal file
View File

@@ -0,0 +1,207 @@
/* libv4l1 linux/videodev.h replacement file */
#ifndef __LINUX_VIDEODEV_H
#define __LINUX_VIDEODEV_H
#ifdef linux
#include <linux/ioctl.h>
#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
#include <sys/ioctl.h>
#endif
#include <stdint.h>
#define VID_TYPE_CAPTURE 1 /* Can capture */
#define VID_TYPE_TUNER 2 /* Can tune */
#define VID_TYPE_TELETEXT 4 /* Does teletext */
#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */
#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */
#define VID_TYPE_CLIPPING 32 /* Can clip */
#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */
#define VID_TYPE_SCALES 128 /* Scalable */
#define VID_TYPE_MONOCHROME 256 /* Monochrome only */
#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */
#define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */
#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */
#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */
#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */
struct video_capability
{
char name[32];
int type;
int channels; /* Num channels */
int audios; /* Num audio devices */
int maxwidth; /* Supported width */
int maxheight; /* And height */
int minwidth; /* Supported width */
int minheight; /* And height */
};
struct video_channel
{
int channel;
char name[32];
int tuners;
uint32_t flags;
#define VIDEO_VC_TUNER 1 /* Channel has a tuner */
#define VIDEO_VC_AUDIO 2 /* Channel has audio */
uint16_t type;
#define VIDEO_TYPE_TV 1
#define VIDEO_TYPE_CAMERA 2
uint16_t norm; /* Norm set by channel */
};
struct video_tuner
{
int tuner;
char name[32];
unsigned long rangelow, rangehigh; /* Tuner range */
uint32_t flags;
#define VIDEO_TUNER_PAL 1
#define VIDEO_TUNER_NTSC 2
#define VIDEO_TUNER_SECAM 4
#define VIDEO_TUNER_LOW 8 /* Uses KHz not MHz */
#define VIDEO_TUNER_NORM 16 /* Tuner can set norm */
#define VIDEO_TUNER_STEREO_ON 128 /* Tuner is seeing stereo */
#define VIDEO_TUNER_RDS_ON 256 /* Tuner is seeing an RDS datastream */
#define VIDEO_TUNER_MBS_ON 512 /* Tuner is seeing an MBS datastream */
uint16_t mode; /* PAL/NTSC/SECAM/OTHER */
#define VIDEO_MODE_PAL 0
#define VIDEO_MODE_NTSC 1
#define VIDEO_MODE_SECAM 2
#define VIDEO_MODE_AUTO 3
uint16_t signal; /* Signal strength 16bit scale */
};
struct video_picture
{
uint16_t brightness;
uint16_t hue;
uint16_t colour;
uint16_t contrast;
uint16_t whiteness; /* Black and white only */
uint16_t depth; /* Capture depth */
uint16_t palette; /* Palette in use */
#define VIDEO_PALETTE_GREY 1 /* Linear greyscale */
#define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */
#define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */
#define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */
#define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */
#define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */
#define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */
#define VIDEO_PALETTE_YUYV 8
#define VIDEO_PALETTE_UYVY 9 /* The great thing about standards is ... */
#define VIDEO_PALETTE_YUV420 10
#define VIDEO_PALETTE_YUV411 11 /* YUV411 capture */
#define VIDEO_PALETTE_RAW 12 /* RAW capture (BT848) */
#define VIDEO_PALETTE_YUV422P 13 /* YUV 4:2:2 Planar */
#define VIDEO_PALETTE_YUV411P 14 /* YUV 4:1:1 Planar */
#define VIDEO_PALETTE_YUV420P 15 /* YUV 4:2:0 Planar */
#define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */
#define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */
#define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */
};
struct video_audio
{
int audio; /* Audio channel */
uint16_t volume; /* If settable */
uint16_t bass, treble;
uint32_t flags;
#define VIDEO_AUDIO_MUTE 1
#define VIDEO_AUDIO_MUTABLE 2
#define VIDEO_AUDIO_VOLUME 4
#define VIDEO_AUDIO_BASS 8
#define VIDEO_AUDIO_TREBLE 16
#define VIDEO_AUDIO_BALANCE 32
char name[16];
#define VIDEO_SOUND_MONO 1
#define VIDEO_SOUND_STEREO 2
#define VIDEO_SOUND_LANG1 4
#define VIDEO_SOUND_LANG2 8
uint16_t mode;
uint16_t balance; /* Stereo balance */
uint16_t step; /* Step actual volume uses */
};
struct video_clip
{
int32_t x,y;
int32_t width, height;
struct video_clip *next; /* For user use/driver use only */
};
struct video_window
{
uint32_t x,y; /* Position of window */
uint32_t width,height; /* Its size */
uint32_t chromakey;
uint32_t flags;
struct video_clip *clips; /* Set only */
int clipcount;
#define VIDEO_WINDOW_INTERLACE 1
#define VIDEO_WINDOW_CHROMAKEY 16 /* Overlay by chromakey */
#define VIDEO_CLIP_BITMAP -1
/* bitmap is 1024x625, a '1' bit represents a clipped pixel */
#define VIDEO_CLIPMAP_SIZE (128 * 625)
};
struct video_buffer
{
void *base;
int height,width;
int depth;
int bytesperline;
};
struct video_mmap
{
unsigned int frame; /* Frame (0 - n) for double buffer */
int height,width;
unsigned int format; /* should be VIDEO_PALETTE_* */
};
struct video_mbuf
{
int size; /* Total memory to map */
int frames; /* Frames */
int offsets[32];
};
struct vbi_format {
uint32_t sampling_rate; /* in Hz */
uint32_t samples_per_line;
uint32_t sample_format; /* VIDEO_PALETTE_RAW only (1 byte) */
int32_t start[2]; /* starting line for each frame */
uint32_t count[2]; /* count of lines for each frame */
uint32_t flags;
#define VBI_UNSYNC 1 /* can distingues between top/bottom field */
#define VBI_INTERLACED 2 /* lines are interlaced */
};
#define VIDIOCGCAP _IOR('v',1,struct video_capability) /* Get capabilities */
#define VIDIOCGCHAN _IOWR('v',2,struct video_channel) /* Get channel info (sources) */
#define VIDIOCSCHAN _IOW('v',3,struct video_channel) /* Set channel */
#define VIDIOCGTUNER _IOWR('v',4,struct video_tuner) /* Get tuner abilities */
#define VIDIOCSTUNER _IOW('v',5,struct video_tuner) /* Tune the tuner for the current channel */
#define VIDIOCGPICT _IOR('v',6,struct video_picture) /* Get picture properties */
#define VIDIOCSPICT _IOW('v',7,struct video_picture) /* Set picture properties */
#define VIDIOCCAPTURE _IOW('v',8,int) /* Start, end capture */
#define VIDIOCGWIN _IOR('v',9, struct video_window) /* Get the video overlay window */
#define VIDIOCSWIN _IOW('v',10, struct video_window) /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */
#define VIDIOCGFBUF _IOR('v',11, struct video_buffer) /* Get frame buffer */
#define VIDIOCSFBUF _IOW('v',12, struct video_buffer) /* Set frame buffer - root only */
#define VIDIOCGFREQ _IOR('v',14, unsigned long) /* Set tuner */
#define VIDIOCSFREQ _IOW('v',15, unsigned long) /* Set tuner */
#define VIDIOCGAUDIO _IOR('v',16, struct video_audio) /* Get audio info */
#define VIDIOCSAUDIO _IOW('v',17, struct video_audio) /* Audio source, mute etc */
#define VIDIOCSYNC _IOW('v',18, int) /* Sync with mmap grabbing */
#define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap) /* Grab frames */
#define VIDIOCGMBUF _IOR('v',20, struct video_mbuf) /* Memory map buffer info */
#define VIDIOCGVBIFMT _IOR('v',28, struct vbi_format) /* Get VBI information */
#define VIDIOCSVBIFMT _IOW('v',29, struct vbi_format) /* Set VBI information */
#endif

75
include/libv4l1.h Normal file
View File

@@ -0,0 +1,75 @@
/*
# (C) 2008 Hans de Goede <hdegoede@redhat.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*/
#ifndef __LIBV4L1_H
#define __LIBV4L1_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <libv4l1-videodev.h>
#if HAVE_VISIBILITY
#define LIBV4L_PUBLIC __attribute__ ((visibility("default")))
#else
#define LIBV4L_PUBLIC
#endif
/* Point this to a FILE opened for writing when you want to log error and
status messages to a file, when NULL errors will get send to stderr */
LIBV4L_PUBLIC extern FILE *v4l1_log_file;
/* Just like your regular open/close/etc, except that when opening a v4l2
capture only device, full v4l1 emulation is done including emulating the
often not implemented in v4l2 drivers CGMBUF ioctl and v4l1 style mmap call
in userspace.
Format conversion is done if necessary when capturing. That is if you
(try to) set a capture format which is not supported by the cam, but is
supported by libv4lconvert then SPICT will succeed and on SYNC / read the
data will be converted for you and returned in the request format.
Note that currently libv4l1 depends on the kernel v4l1 compatibility layer
for: 1) Devices which are not capture only, 2) Emulation of many basic
v4l1 ioctl's which require no driver specific handling.
Note that no functionality is added to v4l1 devices, so if for example an
obscure v4l1 device is opened which only supports some weird capture format
then libv4l1 will not be of any help (in this case it would be best to get
the driver converted to v4l2, as v4l2 has been designed to include weird
capture formats, like hw specific bayer compression methods).
*/
LIBV4L_PUBLIC int v4l1_open(const char *file, int oflag, ...);
LIBV4L_PUBLIC int v4l1_close(int fd);
LIBV4L_PUBLIC int v4l1_dup(int fd);
LIBV4L_PUBLIC int v4l1_ioctl(int fd, unsigned long int request, ...);
LIBV4L_PUBLIC ssize_t v4l1_read(int fd, void *buffer, size_t n);
LIBV4L_PUBLIC void *v4l1_mmap(void *start, size_t length, int prot, int flags,
int fd, int64_t offset);
LIBV4L_PUBLIC int v4l1_munmap(void *_start, size_t length);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

116
include/libv4l2.h Normal file
View File

@@ -0,0 +1,116 @@
/*
# (C) 2008 Hans de Goede <hdegoede@redhat.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*/
#ifndef __LIBV4L2_H
#define __LIBV4L2_H
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#if HAVE_VISIBILITY
#define LIBV4L_PUBLIC __attribute__ ((visibility("default")))
#else
#define LIBV4L_PUBLIC
#endif
/* Point this to a FILE opened for writing when you want to log error and
status messages to a file, when NULL errors will get send to stderr */
LIBV4L_PUBLIC extern FILE *v4l2_log_file;
/* Just like your regular open/close/etc, except that format conversion is
done if necessary when capturing. That is if you (try to) set a capture
format which is not supported by the cam, but is supported by libv4lconvert,
then the try_fmt / set_fmt will succeed as if the cam supports the format
and on dqbuf / read the data will be converted for you and returned in
the request format. enum_fmt will also report support for the formats to
which conversion is possible.
Another difference is that you can make v4l2_read() calls even on devices
which do not support the regular read() method.
Note the device name passed to v4l2_open must be of a video4linux2 device,
if it is anything else (including a video4linux1 device), v4l2_open will
fail.
Note that the argument to v4l2_ioctl after the request must be a valid
memory address of structure of the appropriate type for the request (for
v4l2 requests which expect a structure address). Passing in NULL or an
invalid memory address will not lead to failure with errno being EFAULT,
as it would with a real ioctl, but will cause libv4l2 to break, and you
get to keep both pieces.
*/
LIBV4L_PUBLIC int v4l2_open(const char *file, int oflag, ...);
LIBV4L_PUBLIC int v4l2_close(int fd);
LIBV4L_PUBLIC int v4l2_dup(int fd);
LIBV4L_PUBLIC int v4l2_ioctl(int fd, unsigned long int request, ...);
LIBV4L_PUBLIC ssize_t v4l2_read(int fd, void *buffer, size_t n);
LIBV4L_PUBLIC ssize_t v4l2_write(int fd, const void *buffer, size_t n);
LIBV4L_PUBLIC void *v4l2_mmap(void *start, size_t length, int prot, int flags,
int fd, int64_t offset);
LIBV4L_PUBLIC int v4l2_munmap(void *_start, size_t length);
/* Misc utility functions */
/* This function takes a value of 0 - 65535, and then scales that range to
the actual range of the given v4l control id, and then if the cid exists
and is not locked sets the cid to the scaled value.
Normally returns 0, even if the cid did not exist or was locked, returns
non 0 when an other error occurred. */
LIBV4L_PUBLIC int v4l2_set_control(int fd, int cid, int value);
/* This function returns a value of 0 - 65535, scaled to from the actual range
of the given v4l control id. When the cid does not exist, or could not be
accessed -1 is returned. */
LIBV4L_PUBLIC int v4l2_get_control(int fd, int cid);
/* "low level" access functions, these functions allow somewhat lower level
access to libv4l2 (currently there only is v4l2_fd_open here) */
/* Flags for v4l2_fd_open's v4l2_flags argument */
/* Disable all format conversion done by libv4l2, this includes the software
whitebalance, gamma correction, flipping, etc. libv4lconvert does. Use this
if you want raw frame data, but still want the additional error checks and
the read() emulation libv4l2 offers. */
#define V4L2_DISABLE_CONVERSION 0x01
/* This flag is *OBSOLETE*, since version 0.5.98 libv4l *always* reports
emulated formats to ENUM_FMT, except when conversion is disabled. */
#define V4L2_ENABLE_ENUM_FMT_EMULATION 0x02
/* v4l2_fd_open: open an already opened fd for further use through
v4l2lib and possibly modify libv4l2's default behavior through the
v4l2_flags argument.
Returns fd on success, -1 if the fd is not suitable for use through libv4l2
(note the fd is left open in this case). */
LIBV4L_PUBLIC int v4l2_fd_open(int fd, int v4l2_flags);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

343
include/libv4l2rds.h Normal file
View File

@@ -0,0 +1,343 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
* Author: Konke Radlow <koradlow@gmail.com>
*/
#ifndef __LIBV4L2RDS
#define __LIBV4L2RDS
#include <stdbool.h>
#include <stdint.h>
#if defined(__OpenBSD__)
#include <sys/videoio.h>
#else
#include <linux/videodev2.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#if HAVE_VISIBILITY
#define LIBV4L_PUBLIC __attribute__ ((visibility("default")))
#else
#define LIBV4L_PUBLIC
#endif
/* used to define the current version (version field) of the v4l2_rds struct */
#define V4L2_RDS_VERSION (2)
/* Constants used to define the size of arrays used to store RDS information */
#define MAX_ODA_CNT 18 /* there are 16 groups each with type a or b. Of these
* 32 distinct groups, 18 can be used for ODA purposes */
#define MAX_AF_CNT 25 /* AF Method A allows a maximum of 25 AFs to be defined
* AF Method B does not impose a limit on the number of AFs
* but it is not fully supported at the moment and will
* not receive more than 25 AFs */
#define MAX_TMC_ADDITIONAL 28 /* 28 is the maximal possible number of fields.
* Additional data is limited to 112 bit, and the smallest
* optional tuple has a size of 4 bit (4 bit identifier +
* 0 bits of data) */
#define MAX_TMC_ALT_STATIONS 32 /* defined by ISO 14819-1:2003, 7.5.3.3 */
#define MAX_TMC_AF_CNT 4 /* limit for the numbers of AFs stored per alternative TMC
* station. This value is not defined by the standard, but based on observation
* of real-world RDS-TMC streams. The maximum encountered number of AFs per
* station during testing was 2 */
#define MAX_EON_CNT 20 /* Maximal number of entries in the EON table (for storing
* information about other radio stations, broadcasted by the current station).
* This value is not defined by the standard, but based on observation
* of real-world RDS-TMC streams. EON doesn't seem to be a widely used feature
* and the maximum number of EON encountered during testing was 8 */
/* Define Constants for the possible types of RDS information
* used to address the relevant bit in the valid_fields bitmask */
#define V4L2_RDS_PI 0x01 /* Program Identification */
#define V4L2_RDS_PTY 0x02 /* Program Type */
#define V4L2_RDS_TP 0x04 /* Traffic Program */
#define V4L2_RDS_PS 0x08 /* Program Service Name */
#define V4L2_RDS_TA 0x10 /* Traffic Announcement */
#define V4L2_RDS_DI 0x20 /* Decoder Information */
#define V4L2_RDS_MS 0x40 /* Music / Speech flag */
#define V4L2_RDS_PTYN 0x80 /* Program Type Name */
#define V4L2_RDS_RT 0x100 /* Radio-Text */
#define V4L2_RDS_TIME 0x200 /* Date and Time information */
#define V4L2_RDS_TMC 0x400 /* TMC availability */
#define V4L2_RDS_AF 0x800 /* AF (alternative freq) available */
#define V4L2_RDS_ECC 0x1000 /* Extended County Code */
#define V4L2_RDS_LC 0x2000 /* Language Code */
#define V4L2_RDS_TMC_SG 0x4000 /* RDS-TMC single group */
#define V4L2_RDS_TMC_MG 0x8000 /* RDS-TMC multi group */
#define V4L2_RDS_TMC_SYS 0x10000 /* RDS-TMC system information */
#define V4L2_RDS_EON 0x20000 /* Enhanced Other Network Info */
#define V4L2_RDS_LSF 0x40000 /* Linkage information */
#define V4L2_RDS_TMC_TUNING 0x80000 /* RDS-TMC tuning information */
/* Define Constants for the state of the RDS decoding process
* used to address the relevant bit in the decode_information bitmask */
#define V4L2_RDS_GROUP_NEW 0x01 /* New group received */
#define V4L2_RDS_ODA 0x02 /* Open Data Group announced */
/* Decoder Information (DI) codes
* used to decode the DI information according to the RDS standard */
#define V4L2_RDS_FLAG_STEREO 0x01
#define V4L2_RDS_FLAG_ARTIFICIAL_HEAD 0x02
#define V4L2_RDS_FLAG_COMPRESSED 0x04
#define V4L2_RDS_FLAG_DYNAMIC_PTY 0x08
/* TMC related codes
* used to extract TMC fields from RDS-TMC groups
* see ISO 14819-1:2003, Figure 2 - RDS-TMC single-grp full message structure */
#define V4L2_TMC_TUNING_INFO 0x10 /* Bit 4 indicates Tuning Info / User msg */
#define V4L2_TMC_SINGLE_GROUP 0x08 /* Bit 3 indicates Single / Multi-group msg */
/* struct to encapsulate one complete RDS group */
/* This structure is used internally to store data until a complete RDS
* group was received and group id dependent decoding can be done.
* It is also used to provide external access to uninterpreted RDS groups
* when manual decoding is required (e.g. special ODA types) */
struct v4l2_rds_group {
uint16_t pi; /* Program Identification */
char group_version; /* group version ('A' / 'B') */
uint8_t group_id; /* group number (0..16) */
/* uninterpreted data blocks for decoding (e.g. ODA) */
uint8_t data_b_lsb;
uint8_t data_c_msb;
uint8_t data_c_lsb;
uint8_t data_d_msb;
uint8_t data_d_lsb;
};
/* struct to encapsulate some statistical information about the decoding process */
struct v4l2_rds_statistics {
uint32_t block_cnt; /* total amount of received blocks */
uint32_t group_cnt; /* total amount of successfully
* decoded groups */
uint32_t block_error_cnt; /* blocks that were marked as erroneous
* and had to be dropped */
uint32_t group_error_cnt; /* group decoding processes that had to be
* aborted because of erroneous blocks
* or wrong order of blocks */
uint32_t block_corrected_cnt; /* blocks that contained 1-bit errors
* which were corrected */
uint32_t group_type_cnt[16]; /* number of occurrence for each
* defined RDS group */
};
/* struct to encapsulate the definition of one ODA (Open Data Application) type */
struct v4l2_rds_oda {
uint8_t group_id; /* RDS group used to broadcast this ODA */
char group_version; /* group version (A / B) for this ODA */
uint16_t aid; /* Application Identification for this ODA,
* AIDs are centrally administered by the
* RDS Registration Office (rds.org.uk) */
};
/* struct to encapsulate an array of all defined ODA types for a channel */
/* This structure will grow with ODA announcements broadcasted in type 3A
* groups, that were verified not to be no duplicates or redefinitions */
struct v4l2_rds_oda_set {
uint8_t size; /* number of ODAs defined by this channel */
struct v4l2_rds_oda oda[MAX_ODA_CNT];
};
/* struct to encapsulate an array of Alternative Frequencies for a channel */
/* Every channel can send out AFs for his program. The number of AFs that
* will be broadcasted is announced by the channel */
struct v4l2_rds_af_set {
uint8_t size; /* size of the set (might be smaller
* than the announced size) */
uint8_t announced_af; /* number of announced AF */
uint32_t af[MAX_AF_CNT]; /* AFs defined in Hz */
};
/* struct to encapsulate one entry in the EON table (Enhanced Other Network) */
struct v4l2_rds_eon {
uint32_t valid_fields;
uint16_t pi;
uint8_t ps[9];
uint8_t pty;
bool ta;
bool tp;
uint16_t lsf; /* Linkage Set Number */
struct v4l2_rds_af_set af;
};
/* struct to encapsulate a table of EON information */
struct v4l2_rds_eon_set {
uint8_t size; /* size of the table */
uint8_t index; /* current position in the table */
struct v4l2_rds_eon eon[MAX_EON_CNT]; /* Information about other
* radio channels */
};
/* struct to encapsulate alternative frequencies (AFs) for RDS-TMC stations.
* AFs listed in af[] can be used unconditionally.
* AFs listed in mapped_af[n] should only be used if the current
* tuner frequency matches the value in mapped_af_tuning[n] */
struct v4l2_tmc_alt_freq {
uint8_t af_size; /* number of known AFs */
uint8_t af_index;
uint8_t mapped_af_size; /* number of mapped AFs */
uint8_t mapped_af_index;
uint32_t af[MAX_TMC_AF_CNT]; /* AFs defined in Hz */
uint32_t mapped_af[MAX_TMC_AF_CNT]; /* mapped AFs defined in Hz */
uint32_t mapped_af_tuning[MAX_TMC_AF_CNT]; /* mapped AFs defined in Hz */
};
/* struct to encapsulate information about stations carrying RDS-TMC services */
struct v4l2_tmc_station {
uint16_t pi;
uint8_t ltn; /* database-ID of ON */
uint8_t msg; /* msg parameters of ON */
uint8_t sid; /* service-ID of ON */
struct v4l2_tmc_alt_freq afi;
};
/* struct to encapsulate tuning information for TMC */
struct v4l2_tmc_tuning {
uint8_t station_cnt; /* number of announced alternative stations */
uint8_t index;
struct v4l2_tmc_station station[MAX_TMC_ALT_STATIONS]; /* information
* about other stations carrying the same RDS-TMC service */
};
/* struct to encapsulate an additional data field in a TMC message */
struct v4l2_tmc_additional {
uint8_t label;
uint16_t data;
};
/* struct to encapsulate an arbitrary number of additional data fields
* belonging to one TMC message */
struct v4l2_tmc_additional_set {
uint8_t size;
struct v4l2_tmc_additional fields[MAX_TMC_ADDITIONAL];
};
/* struct to encapsulate a decoded TMC message with optional additional
* data field (in case of a multi-group TMC message) */
struct v4l2_rds_tmc_msg {
uint8_t length; /* length of multi-group message (0..4) */
uint8_t sid; /* service identifier at time of reception */
uint8_t extent;
uint8_t dp; /* duration and persistence */
uint16_t event; /* TMC event code */
uint16_t location; /* TMC event location */
bool follow_diversion; /* indicates if the driver is adviced to
* follow the diversion */
bool neg_direction; /* indicates negative / positive direction */
/* decoded additional information (only available in multi-group
* messages) */
struct v4l2_tmc_additional_set additional;
};
/* struct to encapsulate all TMC related information, including TMC System
* Information, TMC Tuning information and a buffer for the last decoded
* TMC messages */
struct v4l2_rds_tmc {
uint8_t ltn; /* location_table_number */
bool afi; /* alternative frequency indicator */
bool enhanced_mode; /* mode of transmission,
* if false -> basic => gaps between tmc groups
* gap defines timing behavior
* if true -> enhanced => t_a, t_w and t_d
* define timing behavior of tmc groups */
uint8_t mgs; /* message geographical scope */
uint8_t sid; /* service identifier (unique ID on national level) */
uint8_t gap; /* Gap parameters */
uint8_t t_a; /* activity time (only if mode = enhanced) */
uint8_t t_w; /* window time (only if mode = enhanced */
uint8_t t_d; /* delay time (only if mode = enhanced */
uint8_t spn[9]; /* service provider name */
struct v4l2_rds_tmc_msg tmc_msg;
/* tuning information for alternative service providers */
struct v4l2_tmc_tuning tuning;
};
/* struct to encapsulate state and RDS information for current decoding process */
/* This is the structure that will be used by external applications, to
* communicate with the library and get access to RDS data */
struct v4l2_rds {
/** state information **/
uint32_t decode_information; /* state of decoding process */
uint32_t valid_fields; /* currently valid info fields
* of this structure */
/** RDS info fields **/
bool is_rbds; /* use RBDS standard version of LUTs */
uint16_t pi; /* Program Identification */
uint8_t ps[9]; /* Program Service Name, UTF-8 encoding,
* '\0' terminated */
uint8_t pty; /* Program Type */
uint8_t ptyn[9]; /* Program Type Name, UTF-8 encoding,
* '\0' terminated */
bool ptyn_ab_flag; /* PTYN A/B flag (toggled), to signal
* change of PTYN */
uint8_t rt_length; /* length of RT string */
uint8_t rt[65]; /* Radio-Text string, UTF-8 encoding,
* '\0' terminated */
bool rt_ab_flag; /* RT A/B flag (toggled), to signal
* transmission of new RT */
bool ta; /* Traffic Announcement */
bool tp; /* Traffic Program */
bool ms; /* Music / Speech flag */
uint8_t di; /* Decoder Information */
uint8_t ecc; /* Extended Country Code */
uint8_t lc; /* Language Code */
time_t time; /* local time and date of transmission */
struct v4l2_rds_statistics rds_statistics;
struct v4l2_rds_oda_set rds_oda; /* Open Data Services */
struct v4l2_rds_af_set rds_af; /* Alternative Frequencies */
struct v4l2_rds_eon_set rds_eon; /* EON information */
struct v4l2_rds_tmc tmc; /* TMC information */
};
/* v4l2_rds_init() - initializes a new decoding process
* @is_rbds: defines which standard is used: true=RBDS, false=RDS
*
* initialize a new instance of the RDS-decoding struct and return
* a handle containing state and RDS information, used to interact
* with the library functions */
LIBV4L_PUBLIC struct v4l2_rds *v4l2_rds_create(bool is_rbds);
/* frees all memory allocated for the RDS-decoding struct */
LIBV4L_PUBLIC void v4l2_rds_destroy(struct v4l2_rds *handle);
/* resets the RDS information in the handle to initial values
* e.g. can be used when radio channel is changed
* @reset_statistics: true = set all statistic values to 0, false = keep them untouched */
LIBV4L_PUBLIC void v4l2_rds_reset(struct v4l2_rds *handle, bool reset_statistics);
/* adds a raw RDS block to decode it into RDS groups
* @return: bitmask with with updated fields set to 1
* @rds_data: 3 bytes of raw RDS data, obtained by calling read()
* on RDS capable V4L2 devices */
LIBV4L_PUBLIC uint32_t v4l2_rds_add(struct v4l2_rds *handle, struct v4l2_rds_data *rds_data);
/*
* group of functions to translate numerical RDS data into strings
*
* return program description string defined in the RDS/RBDS Standard
* ! return value depends on selected Standard !*/
LIBV4L_PUBLIC const char *v4l2_rds_get_pty_str(const struct v4l2_rds *handle);
LIBV4L_PUBLIC const char *v4l2_rds_get_language_str(const struct v4l2_rds *handle);
LIBV4L_PUBLIC const char *v4l2_rds_get_country_str(const struct v4l2_rds *handle);
LIBV4L_PUBLIC const char *v4l2_rds_get_coverage_str(const struct v4l2_rds *handle);
/* returns a pointer to the last decoded RDS group, in order to give raw
* access to RDS data if it is required (e.g. ODA decoding) */
LIBV4L_PUBLIC const struct v4l2_rds_group *v4l2_rds_get_group
(const struct v4l2_rds *handle);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

164
include/libv4lconvert.h Normal file
View File

@@ -0,0 +1,164 @@
/*
# (C) 2008 Hans de Goede <hdegoede@redhat.com>
#
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*/
#ifndef __LIBV4LCONVERT_H
#define __LIBV4LCONVERT_H
/* These headers are not needed by us, but by linux/videodev2.h,
which is broken on some systems and doesn't include them itself :( */
#ifdef linux
#include <sys/time.h>
#include <linux/types.h>
#include <linux/ioctl.h>
#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
#include <sys/time.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#endif
/* end broken header workaround includes */
#if defined(__OpenBSD__)
#include <sys/videoio.h>
#else
#include <linux/videodev2.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#if HAVE_VISIBILITY
#define LIBV4L_PUBLIC __attribute__ ((visibility("default")))
#else
#define LIBV4L_PUBLIC
#endif
struct libv4l_dev_ops;
struct v4lconvert_data;
LIBV4L_PUBLIC const struct libv4l_dev_ops *v4lconvert_get_default_dev_ops(void);
LIBV4L_PUBLIC struct v4lconvert_data *v4lconvert_create(int fd);
LIBV4L_PUBLIC struct v4lconvert_data *v4lconvert_create_with_dev_ops(int fd,
void *dev_ops_priv, const struct libv4l_dev_ops *dev_ops);
LIBV4L_PUBLIC void v4lconvert_destroy(struct v4lconvert_data *data);
/* When doing flipping / rotating / video-processing, only supported
destination formats can be used (as flipping / rotating / video-processing
is not supported on other formats). This function can be used to query
if that is the case. */
LIBV4L_PUBLIC int v4lconvert_supported_dst_fmt_only(
struct v4lconvert_data *data);
/* With regards to dest_fmt just like VIDIOC_TRY_FMT, except that the try
format will succeed and return the requested V4L2_PIX_FMT_foo in dest_fmt if
the cam has a format from which v4lconvert can convert to dest_fmt.
The real format to which the cam should be set is returned through src_fmt
when not NULL.
Note that just like the real VIDIOC_TRY_FMT this function will change the
dest_fmt when not supported. This includes changing it to a supported
destination format when trying a native format of the camera and
v4lconvert_supported_dst_fmt_only() returns true. */
LIBV4L_PUBLIC int v4lconvert_try_format(struct v4lconvert_data *data,
struct v4l2_format *dest_fmt, /* in / out */
struct v4l2_format *src_fmt); /* out */
/* Like VIDIOC_ENUM_FMT, but the emulated formats are added at the end of the
list, except if flipping / processing is active for the device, then only
supported destination formats are listed */
LIBV4L_PUBLIC int v4lconvert_enum_fmt(struct v4lconvert_data *data,
struct v4l2_fmtdesc *fmt);
/* Is conversion necessary or can the app use the data directly? */
LIBV4L_PUBLIC int v4lconvert_needs_conversion(struct v4lconvert_data *data,
const struct v4l2_format *src_fmt, /* in */
const struct v4l2_format *dest_fmt); /* in */
/* This function does the following conversions:
- format conversion
- cropping
if enabled:
- processing (auto whitebalance, auto gain, gamma correction)
- horizontal/vertical flipping
- 90 degree (clockwise) rotation
NOTE: the last 3 steps are enabled/disabled depending on
- the internal device list
- the state of the (software emulated) image controls
Therefore this function should
- not be used when getting the frames from libv4l
- be called only once per frame
Otherwise this may result in unintended double conversions !
Returns the amount of bytes written to dest and -1 on error */
LIBV4L_PUBLIC int v4lconvert_convert(struct v4lconvert_data *data,
const struct v4l2_format *src_fmt, /* in */
const struct v4l2_format *dest_fmt, /* in */
unsigned char *src, int src_size, unsigned char *dest, int dest_size);
/* get a string describing the last error */
LIBV4L_PUBLIC const char *v4lconvert_get_error_message(struct v4lconvert_data *data);
/* Just like VIDIOC_ENUM_FRAMESIZE, except that the framesizes of emulated
formats can be enumerated as well. */
LIBV4L_PUBLIC int v4lconvert_enum_framesizes(struct v4lconvert_data *data,
struct v4l2_frmsizeenum *frmsize);
/* Just like VIDIOC_ENUM_FRAMEINTERVALS, except that the intervals of emulated
formats can be enumerated as well. */
LIBV4L_PUBLIC int v4lconvert_enum_frameintervals(struct v4lconvert_data *data,
struct v4l2_frmivalenum *frmival);
/* Pass calls to query, get and set video controls to the libv4lcontrol class */
LIBV4L_PUBLIC int v4lconvert_vidioc_queryctrl(struct v4lconvert_data *data,
void *arg);
LIBV4L_PUBLIC int v4lconvert_vidioc_g_ctrl(struct v4lconvert_data *data,
void *arg);
LIBV4L_PUBLIC int v4lconvert_vidioc_s_ctrl(struct v4lconvert_data *data,
void *arg);
LIBV4L_PUBLIC int v4lconvert_vidioc_g_ext_ctrls(struct v4lconvert_data *data,
void *arg);
LIBV4L_PUBLIC int v4lconvert_vidioc_try_ext_ctrls(struct v4lconvert_data *data,
void *arg);
LIBV4L_PUBLIC int v4lconvert_vidioc_s_ext_ctrls(struct v4lconvert_data *data,
void *arg);
/* Is the passed in pixelformat supported as destination format? */
LIBV4L_PUBLIC int v4lconvert_supported_dst_format(unsigned int pixelformat);
/* Get/set the no fps libv4lconvert uses to decide if a compressed format
must be used as src fmt to stay within the bus bandwidth */
LIBV4L_PUBLIC int v4lconvert_get_fps(struct v4lconvert_data *data);
LIBV4L_PUBLIC void v4lconvert_set_fps(struct v4lconvert_data *data, int fps);
/* Fixup bytesperline and sizeimage for supported destination formats */
LIBV4L_PUBLIC void v4lconvert_fixup_fmt(struct v4l2_format *fmt);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif