Updating prebuilts and/or headers

60e29f95ea52df4407d771330897813cdb38340f - libv4lconvert/libv4lsyscall-priv.h
1f1d1e05443c4b824cd697c0ce5efa9ea1277964 - libv4lconvert/ov518-decomp.c
f4d73412805f12fa08dd79a43798a7f8d7acece9 - libv4lconvert/pac207.c
cc3f3e94a21795990610e63887c30528bde7b42e - libv4lconvert/bayer.c
3c49d99b9753208a9c1c2a9c738a1e7ad291ca22 - libv4lconvert/jpeg_memsrcdest.h
3271d74d02e2f33c16e3e50aeb1268eb9c440782 - libv4lconvert/rgbyuv.c
1949e23fe99ccd0a05dcd084848f6d38b0af7ab6 - libv4lconvert/hm12.c
4eff5c1a5e0b99ce4d6e9aa63645d9628467fdc3 - libv4lconvert/sn9c2028-decomp.c
b2c19c2eac71d39d3fb883cdc159a69c2afa8fd6 - libv4lconvert/ov511-decomp.c
84c9c3812d4b5f237c8cd616d37fc1161a212acc - libv4lconvert/se401.c
463725aa4dd3fecaf89c0b8bbf4747f8f7577935 - libv4lconvert/jpeg.c
fbbffd8182b4fe2e85289b6e784f70cba7ea7b1d - libv4lconvert/sq905c.c
db3c69c666e451c5d4ef6d1b5a3117f4b128baa4 - libv4lconvert/libv4lconvert-priv.h
8b7644ac3d5c4161cfb6dcc2a34013f4c379c665 - libv4lconvert/libv4lconvert.export
5c0ab7b5e7c5c2eac27f7e92a4c84acd61983658 - libv4lconvert/Makefile
72953a5a3a56b0188d35f49246356b9c8c35756c - libv4lconvert/helper.c
66dd7958319442bd52ba40ede28fbfe31bb4e074 - libv4lconvert/cpia1.c
1d9c446cd8a232da87bd79acebc93e018ec72499 - libv4lconvert/jidctflt.c
cc8982bb6f753249181c715fe6430ffefc78c23b - libv4lconvert/stv0680.c
25130d299463897a09e8b9adf72389dac2e89fa4 - libv4lconvert/tinyjpeg-internal.h
22a502c238e48f4b939c81de41feccfc7c366766 - libv4lconvert/Makefile.dGPU
fb3344cfa8df97688332ee4fd3b17968437e8ad5 - libv4lconvert/helper-funcs.h
5430e46abb1ac7039ed0309ca338237533ff29c9 - libv4lconvert/sn9c20x.c
d6c1aba89bbcb6fef46a6f22b7ea01025435c44d - libv4lconvert/Makefile.am
3e8e6c1fb85e3c4b58c4e9b2b0a223ddc793edcb - libv4lconvert/libv4lconvert.pc.in
6ad4947dca51a7e67e056561cdb445d6c354d23c - libv4lconvert/libv4lconvert.c
ff7444c48a8da88f8a466cfb138e30e585828cb3 - libv4lconvert/jl2005bcd.c
803c4d0b9364050eda163452b8792e62e221ab6d - libv4lconvert/tinyjpeg.h
f061a4e0e45ca8e0dbab630dd477e19a6c915fda - libv4lconvert/spca501.c
07f8e7c84abfbbe76d49d8bfd1f4eae6ea39a90b - libv4lconvert/jpgl.c
fa751ff0f78845f3b4591396710df3b165bc8d11 - libv4lconvert/mr97310a.c
be9e3bf3d7d1086b6eed0c1bf2f574c2b1737c00 - libv4lconvert/tinyjpeg.c
033894511bd7e8a374a52486889658faa17918c4 - libv4lconvert/flip.c
b694b6348e035b3da880824c2c2768145c9b5199 - libv4lconvert/jpeg_memsrcdest.c
725c9b8d0bfadba566cf200921e602961cb12705 - libv4lconvert/spca561-decompress.c
ddd39b2fe0e2a86a6c64031ccc0d36edfd9b0f1a - libv4lconvert/sn9c10x.c
f08c902ecd48c2739956606b502fc0b8e4007703 - libv4lconvert/crop.c
dae9c69b7f019d7d4494cd56e2cf757e8510824a - libv4lconvert/processing/whitebalance.c
0390d660eb130f0e580832bcf8ad5069010d2696 - libv4lconvert/processing/libv4lprocessing.h
a54c2cb0439e606af01d0b4f02704f411819d98c - libv4lconvert/processing/libv4lprocessing.c
ebf12bcf99f35fb9c400b04a1439e68598268249 - libv4lconvert/processing/gamma.c
33ab91b54108e8c24cbb80c5c335d96391d440b2 - libv4lconvert/processing/libv4lprocessing-priv.h
7da402829dbff238ca6ac829c037a85476185db6 - libv4lconvert/processing/autogain.c
1e08fb01a598d71e3fc69656c4f2291f7dc13105 - libv4lconvert/control/libv4lcontrol.h
19a7fd04cdeba61172f281806d030472dee79fcd - libv4lconvert/control/libv4lcontrol.c
70f4992835e964b2698473971904375333e3659b - libv4lconvert/control/libv4lcontrol-priv.h
9d456d1772885d900865a8958c0291e13d509de5 - libv4l2/v4l2convert.c
7fa618184ff89737d13164be0b79e227d81f398c - libv4l2/log.c
d1f2b6f016cfb90c616d848418feb915e3737fa7 - libv4l2/libv4l2.c
766aaca553b0166eb736557e44ad42b69464aa53 - libv4l2/libv4l2.export
e6516370c43e4869e05a540d2e4ef584ac64890a - libv4l2/v4l2-plugin.c
76ed189d56eb01e6b8bccb4490fad9a4b2af126d - libv4l2/Makefile
4ba98a607592ed0b8327b387af354544c65c9b67 - libv4l2/v4l2-plugin-android.c
2542aabb7fbff4b1a09faaadec6006c4410a6d10 - libv4l2/libv4l2-priv.h
ffecae84262f548deac1da0fa51f1aba6b6f96a0 - libv4l2/Makefile.dGPU
8e335567bf404eeb3d180dd384309f687f2ab944 - libv4l2/Makefile.am
cbcee4426c19c168c6f49d04af3a0b2e30c0b681 - libv4l2/libv4l2.pc.in
c84a9a115a21d1fd20da0f6ca3df7b46dd23cd2a - include/config.h
1edc439e6c0fc98513fa4a69557eb6221d043be0 - include/libv4l2.h
6feb5b2b8c99c99712dd1ea7fe9ab674d58bf86b - include/libv4l1.h
bc44111fd6b2f0374a9fc67b1b23666c5c498b2c - include/libv4l2rds.h
f751b481c4a9203345cdbb6459d0f2882f7cdbd9 - include/libv4lconvert.h
f2b73fa5ab10ea7038e58bd9a4461d8e16316249 - include/libv4l1-videodev.h
94434b9692371b7d5f54ddef2141d22d90079ce9 - include/libv4l-plugin.h
c8b4fc511833f0993fa740a529e1f61e0f5a216f - include/libdvbv5/mpeg_es.h
fb8d640da36b6a156cbe0ef12dc25468de89a2a1 - include/libdvbv5/dvb-sat.h
9a2b20076d6728b5799096e4149e33a73119e1ef - include/libdvbv5/desc_sat.h
ac87e3306569dae329809f27ef227c5d50f0b60e - include/libdvbv5/desc_event_short.h
efa3a711499f68ae370d49d98dc1963bf6bafcd8 - include/libdvbv5/desc_extension.h
ad13bfa0b1642fc72cca387e62bc193974c8d5ee - include/libdvbv5/atsc_header.h
b867a2e7941d718aa64b2f6a1402322b616cb2da - include/libdvbv5/pmt.h
bdf514383ca0afe981cf4fd6af86440db2dc6667 - include/libdvbv5/pat.h
96db22ef84892a36d5df3cffa0b30d5bad01939c - include/libdvbv5/desc_logical_channel.h
92d4c28148d0b537c8afc289e1a76de68435cba0 - include/libdvbv5/dvb-scan.h
7544b5fb8f621a9c637c40d8f7a2a71f6ab4bd63 - include/libdvbv5/desc_hierarchy.h
b72b6d1ffcdd81e3e631c7c20bb30e5c287dc7ff - include/libdvbv5/vct.h
9d523ee179af955a687662996050ee3cfaacf2ab - include/libdvbv5/crc32.h
6e6fd4c61c1f61006c63214cbe4868d49428ddb9 - include/libdvbv5/mpeg_pes.h
d7a096d51e3050c8f52e0e2111d88b71a5313da1 - include/libdvbv5/dvb-demux.h
5b4a5e7fb30a7f28118be012837e73a7151d2619 - include/libdvbv5/cat.h
30e9a7240938943de2725f2b335b19ad320179a5 - include/libdvbv5/header.h
4c412880f0c49cd00cb16e56eed082c4744211a5 - include/libdvbv5/countries.h
e81b7f75c11f175cf365fc7fb535e80828f10e24 - include/libdvbv5/dvb-file.h
2560f18846a535a2c02e1ae449511e731f11c011 - include/libdvbv5/desc_ca_identifier.h
c18291ff9009bfe71a2c7c6f0fce75331dc95e30 - include/libdvbv5/sdt.h
44ab16a8d4eae09690c71a6301927c1da55dda6d - include/libdvbv5/descriptors.h
188fc2cbec97288787a7f66554a4b6288224f980 - include/libdvbv5/desc_isdbt_delivery.h
c1212a9308d96730de547648d3cda2fc144d0e29 - include/libdvbv5/desc_atsc_service_location.h
7fb0966c6a1ccdf1a8844aed4a94d4ae1d02fcd7 - include/libdvbv5/dvb-fe.h
40a06b5375dbc0de88a15d26cc6c1e9a505119bc - include/libdvbv5/eit.h
22c83d133e5c1d2648efb3028e0d89c970d0aad4 - include/libdvbv5/desc_partial_reception.h
1ba874a7cad36ff31e4af3bfb37b98c05063d6b2 - include/libdvbv5/desc_event_extended.h
146f4f53fc49c66b59905249c0142efffd72fc54 - include/libdvbv5/desc_network_name.h
100c02ce3bc364ddff895c75f4fb1f928a748d2d - include/libdvbv5/desc_cable_delivery.h
7645dda247bcd45628afbb74ec2707a47050992e - include/libdvbv5/nit.h
73b7b0cf684de0e8a4eae49a8521f81b411d7b72 - include/libdvbv5/desc_ts_info.h
6bd2ed0beaf6aa4838e239198564fd8e1d20a3a1 - include/libdvbv5/desc_t2_delivery.h
d562371bb8a3b961c4d63a0f5618453bdff4bcd3 - include/libdvbv5/dvb-log.h
ef979f3276cc3cad6e947865a42643fbba860c69 - include/libdvbv5/mgt.h
2f55ba765c689500401111747bb381b5aca77b30 - include/libdvbv5/desc_ca.h
450fab787e61210c0c5f527df92c31c90b44a113 - include/libdvbv5/desc_service.h
cabecc6d7c9fdf1c437273bd6a746bf83c156f72 - include/libdvbv5/desc_frequency_list.h
5e2dfc1d9a71805389e9a7932812695d0309050c - include/libdvbv5/dvb-frontend.h
7a6093b13354d054cac78ea118a96e813cac3395 - include/libdvbv5/atsc_eit.h
9b5cfad4a5f41cbf886507da6e79b07314827b32 - include/libdvbv5/desc_language.h
98365b48442b9e3abb58101983b5da8c14f78289 - include/libdvbv5/dvb-v5-std.h
4fe7def34ff640fc5e327b3596298169fdfe2f1c - include/libdvbv5/mpeg_ts.h
02168c58e3c772f116f075085579ac4a8422e819 - include/libdvbv5/desc_terrestrial_delivery.h

Change-Id: Ib659ea4ed46c3013e51d0ca3138ac89f5950388f
This commit is contained in:
svcmobrel-release
2022-08-15 08:54:20 -07:00
parent e003da6fcd
commit 455a031360
111 changed files with 30904 additions and 0 deletions

220
include/config.h Normal file
View File

@@ -0,0 +1,220 @@
/* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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) \
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,60 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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 */

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

@@ -0,0 +1,107 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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 General Public License,
* version 2, as published by the Free Software Foundation.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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

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

@@ -0,0 +1,59 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,141 @@
/*
* Copyright (c) 2013-2014 - Mauro Carvalho Chehab <m.chehab@samsung.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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));
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

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

@@ -0,0 +1,126 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,115 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,133 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,126 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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
* @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;
} __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,119 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,225 @@
/*
* Copyright (c) 2013-2014 - Mauro Carvalho Chehab <m.chehab@samsung.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,113 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,115 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,135 @@
/*
* Copyright (c) 2013-2014 - Mauro Carvalho Chehab <m.chehab@samsung.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,104 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,133 @@
/*
* Copyright (c) 2013 - Mauro Carvalho Chehab <m.chehab@samsung.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,113 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,126 @@
/*
* Copyright (c) 2013 - Mauro Carvalho Chehab <m.chehab@samsung.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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

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

@@ -0,0 +1,148 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,119 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,169 @@
/*
* Copyright (c) 2013-2014 - Mauro Carvalho Chehab <m.chehab@samsung.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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
* @ingroup descriptors
* @brief Structure to describe transponder subcell extension and frequencies
*
* @param cell_id_extension cell id extension
* @param transposer_frequency transposer frequency
*/
struct dvb_desc_t2_delivery_subcell {
uint8_t cell_id_extension;
uint16_t transposer_frequency;
} __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
* @param frequency_loop_length size of the dvb_desc_t2_delivery::centre_frequency
* vector
*
* @param subcel_info_loop_length size of the dvb_desc_t2_delivery::subcell
* vector
* @param subcell pointer to struct dvb_desc_t2_delivery_subcell
*/
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:3;
uint16_t SISO_MISO:2;
} __attribute__((packed));
} __attribute__((packed));
uint32_t *centre_frequency;
uint8_t frequency_loop_length;
uint8_t subcel_info_loop_length;
struct dvb_desc_t2_delivery_subcell *subcell;
} __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[];
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,161 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,145 @@
/*
* Copyright (c) 2013-2014 - Mauro Carvalho Chehab <m.chehab@samsung.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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,772 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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 ) \
for( struct dvb_desc *_desc = _tbl->descriptor; _desc; _desc = _desc->next ) \
#define dvb_desc_find(_struct, _desc, _tbl, _type) \
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_descriptior
* @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_descriptior = 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,
};
/* Please see desc_extension.h for extension_descriptor types */
#endif

View File

@@ -0,0 +1,142 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 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 General Public License version 2 (GPLv2)
* @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.
*/
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 open.
*/
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 open.
*/
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.
*/
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.
*
* @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 This function currently assumes that the PAT fits into one session.
*
* @return At return, it returns a negative value if error or the PID associated with
* the desired Session ID.
*/
int dvb_get_pmt_pid(int dmxfd, int sid);
#ifdef __cplusplus
}
#endif
#endif

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

@@ -0,0 +1,771 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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[71];
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

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

@@ -0,0 +1,514 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*/
#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 General Public License version 2 (GPLv2)
* @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;
};
/**
* @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

@@ -0,0 +1,592 @@
/*
* frontend.h
*
* Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
* Ralph Metzler <ralph@convergence.de>
* Holger Waechtler <holger@convergence.de>
* Andre Draszik <ad@convergence.de>
* for convergence integrated media GmbH
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License,
* version 2.1, as published by the Free Software Foundation.
*
* 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 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 _DVBFRONTEND_H_
#define _DVBFRONTEND_H_
#include <linux/types.h>
typedef enum fe_type {
FE_QPSK,
FE_QAM,
FE_OFDM,
FE_ATSC
} fe_type_t;
typedef enum fe_caps {
FE_IS_STUPID = 0,
FE_CAN_INVERSION_AUTO = 0x1,
FE_CAN_FEC_1_2 = 0x2,
FE_CAN_FEC_2_3 = 0x4,
FE_CAN_FEC_3_4 = 0x8,
FE_CAN_FEC_4_5 = 0x10,
FE_CAN_FEC_5_6 = 0x20,
FE_CAN_FEC_6_7 = 0x40,
FE_CAN_FEC_7_8 = 0x80,
FE_CAN_FEC_8_9 = 0x100,
FE_CAN_FEC_AUTO = 0x200,
FE_CAN_QPSK = 0x400,
FE_CAN_QAM_16 = 0x800,
FE_CAN_QAM_32 = 0x1000,
FE_CAN_QAM_64 = 0x2000,
FE_CAN_QAM_128 = 0x4000,
FE_CAN_QAM_256 = 0x8000,
FE_CAN_QAM_AUTO = 0x10000,
FE_CAN_TRANSMISSION_MODE_AUTO = 0x20000,
FE_CAN_BANDWIDTH_AUTO = 0x40000,
FE_CAN_GUARD_INTERVAL_AUTO = 0x80000,
FE_CAN_HIERARCHY_AUTO = 0x100000,
FE_CAN_8VSB = 0x200000,
FE_CAN_16VSB = 0x400000,
FE_HAS_EXTENDED_CAPS = 0x800000, /* We need more bitspace for newer APIs, indicate this. */
FE_CAN_MULTISTREAM = 0x4000000, /* frontend supports multistream filtering */
FE_CAN_TURBO_FEC = 0x8000000, /* frontend supports "turbo fec modulation" */
FE_CAN_2G_MODULATION = 0x10000000, /* frontend supports "2nd generation modulation" (DVB-S2) */
FE_NEEDS_BENDING = 0x20000000, /* not supported anymore, don't use (frontend requires frequency bending) */
FE_CAN_RECOVER = 0x40000000, /* frontend can recover from a cable unplug automatically */
FE_CAN_MUTE_TS = 0x80000000 /* frontend can stop spurious TS data output */
} fe_caps_t;
struct dvb_frontend_info {
char name[128];
fe_type_t type; /* DEPRECATED. Use DTV_ENUM_DELSYS instead */
__u32 frequency_min;
__u32 frequency_max;
__u32 frequency_stepsize;
__u32 frequency_tolerance;
__u32 symbol_rate_min;
__u32 symbol_rate_max;
__u32 symbol_rate_tolerance; /* ppm */
__u32 notifier_delay; /* DEPRECATED */
fe_caps_t caps;
};
/**
* Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
* the meaning of this struct...
*/
struct dvb_diseqc_master_cmd {
__u8 msg [6]; /* { framing, address, command, data [3] } */
__u8 msg_len; /* valid values are 3...6 */
};
struct dvb_diseqc_slave_reply {
__u8 msg [4]; /* { framing, data [3] } */
__u8 msg_len; /* valid values are 0...4, 0 means no msg */
int timeout; /* return from ioctl after timeout ms with */
}; /* errorcode when no message was received */
typedef enum fe_sec_voltage {
SEC_VOLTAGE_13,
SEC_VOLTAGE_18,
SEC_VOLTAGE_OFF
} fe_sec_voltage_t;
typedef enum fe_sec_tone_mode {
SEC_TONE_ON,
SEC_TONE_OFF
} fe_sec_tone_mode_t;
typedef enum fe_sec_mini_cmd {
SEC_MINI_A,
SEC_MINI_B
} fe_sec_mini_cmd_t;
/**
* enum fe_status - enumerates the possible frontend status
* @FE_HAS_SIGNAL: found something above the noise level
* @FE_HAS_CARRIER: found a DVB signal
* @FE_HAS_VITERBI: FEC is stable
* @FE_HAS_SYNC: found sync bytes
* @FE_HAS_LOCK: everything's working
* @FE_TIMEDOUT: no lock within the last ~2 seconds
* @FE_REINIT: frontend was reinitialized, application is recommended
* to reset DiSEqC, tone and parameters
*/
typedef enum fe_status {
FE_HAS_SIGNAL = 0x01,
FE_HAS_CARRIER = 0x02,
FE_HAS_VITERBI = 0x04,
FE_HAS_SYNC = 0x08,
FE_HAS_LOCK = 0x10,
FE_TIMEDOUT = 0x20,
FE_REINIT = 0x40,
} fe_status_t;
typedef enum fe_spectral_inversion {
INVERSION_OFF,
INVERSION_ON,
INVERSION_AUTO
} fe_spectral_inversion_t;
typedef enum fe_code_rate {
FEC_NONE = 0,
FEC_1_2,
FEC_2_3,
FEC_3_4,
FEC_4_5,
FEC_5_6,
FEC_6_7,
FEC_7_8,
FEC_8_9,
FEC_AUTO,
FEC_3_5,
FEC_9_10,
FEC_2_5,
} fe_code_rate_t;
typedef enum fe_modulation {
QPSK,
QAM_16,
QAM_32,
QAM_64,
QAM_128,
QAM_256,
QAM_AUTO,
VSB_8,
VSB_16,
PSK_8,
APSK_16,
APSK_32,
DQPSK,
QAM_4_NR,
} fe_modulation_t;
typedef enum fe_transmit_mode {
TRANSMISSION_MODE_2K,
TRANSMISSION_MODE_8K,
TRANSMISSION_MODE_AUTO,
TRANSMISSION_MODE_4K,
TRANSMISSION_MODE_1K,
TRANSMISSION_MODE_16K,
TRANSMISSION_MODE_32K,
TRANSMISSION_MODE_C1,
TRANSMISSION_MODE_C3780,
} fe_transmit_mode_t;
#if defined(__DVB_CORE__) || !defined (__KERNEL__)
typedef enum fe_bandwidth {
BANDWIDTH_8_MHZ,
BANDWIDTH_7_MHZ,
BANDWIDTH_6_MHZ,
BANDWIDTH_AUTO,
BANDWIDTH_5_MHZ,
BANDWIDTH_10_MHZ,
BANDWIDTH_1_712_MHZ,
} fe_bandwidth_t;
#endif
typedef enum fe_guard_interval {
GUARD_INTERVAL_1_32,
GUARD_INTERVAL_1_16,
GUARD_INTERVAL_1_8,
GUARD_INTERVAL_1_4,
GUARD_INTERVAL_AUTO,
GUARD_INTERVAL_1_128,
GUARD_INTERVAL_19_128,
GUARD_INTERVAL_19_256,
GUARD_INTERVAL_PN420,
GUARD_INTERVAL_PN595,
GUARD_INTERVAL_PN945,
} fe_guard_interval_t;
typedef enum fe_hierarchy {
HIERARCHY_NONE,
HIERARCHY_1,
HIERARCHY_2,
HIERARCHY_4,
HIERARCHY_AUTO
} fe_hierarchy_t;
enum fe_interleaving {
INTERLEAVING_NONE,
INTERLEAVING_AUTO,
INTERLEAVING_240,
INTERLEAVING_720,
};
#if defined(__DVB_CORE__) || !defined (__KERNEL__)
struct dvb_qpsk_parameters {
__u32 symbol_rate; /* symbol rate in Symbols per second */
fe_code_rate_t fec_inner; /* forward error correction (see above) */
};
struct dvb_qam_parameters {
__u32 symbol_rate; /* symbol rate in Symbols per second */
fe_code_rate_t fec_inner; /* forward error correction (see above) */
fe_modulation_t modulation; /* modulation type (see above) */
};
struct dvb_vsb_parameters {
fe_modulation_t modulation; /* modulation type (see above) */
};
struct dvb_ofdm_parameters {
fe_bandwidth_t bandwidth;
fe_code_rate_t code_rate_HP; /* high priority stream code rate */
fe_code_rate_t code_rate_LP; /* low priority stream code rate */
fe_modulation_t constellation; /* modulation type (see above) */
fe_transmit_mode_t transmission_mode;
fe_guard_interval_t guard_interval;
fe_hierarchy_t hierarchy_information;
};
struct dvb_frontend_parameters {
__u32 frequency; /* (absolute) frequency in Hz for QAM/OFDM/ATSC */
/* intermediate frequency in kHz for QPSK */
fe_spectral_inversion_t inversion;
union {
struct dvb_qpsk_parameters qpsk;
struct dvb_qam_parameters qam;
struct dvb_ofdm_parameters ofdm;
struct dvb_vsb_parameters vsb;
} u;
};
struct dvb_frontend_event {
fe_status_t status;
struct dvb_frontend_parameters parameters;
};
#endif
/* S2API Commands */
#define DTV_UNDEFINED 0
#define DTV_TUNE 1
#define DTV_CLEAR 2
#define DTV_FREQUENCY 3
#define DTV_MODULATION 4
#define DTV_BANDWIDTH_HZ 5
#define DTV_INVERSION 6
#define DTV_DISEQC_MASTER 7
#define DTV_SYMBOL_RATE 8
#define DTV_INNER_FEC 9
#define DTV_VOLTAGE 10
#define DTV_TONE 11
#define DTV_PILOT 12
#define DTV_ROLLOFF 13
#define DTV_DISEQC_SLAVE_REPLY 14
/* Basic enumeration set for querying unlimited capabilities */
#define DTV_FE_CAPABILITY_COUNT 15
#define DTV_FE_CAPABILITY 16
#define DTV_DELIVERY_SYSTEM 17
/* ISDB-T and ISDB-Tsb */
#define DTV_ISDBT_PARTIAL_RECEPTION 18
#define DTV_ISDBT_SOUND_BROADCASTING 19
#define DTV_ISDBT_SB_SUBCHANNEL_ID 20
#define DTV_ISDBT_SB_SEGMENT_IDX 21
#define DTV_ISDBT_SB_SEGMENT_COUNT 22
#define DTV_ISDBT_LAYERA_FEC 23
#define DTV_ISDBT_LAYERA_MODULATION 24
#define DTV_ISDBT_LAYERA_SEGMENT_COUNT 25
#define DTV_ISDBT_LAYERA_TIME_INTERLEAVING 26
#define DTV_ISDBT_LAYERB_FEC 27
#define DTV_ISDBT_LAYERB_MODULATION 28
#define DTV_ISDBT_LAYERB_SEGMENT_COUNT 29
#define DTV_ISDBT_LAYERB_TIME_INTERLEAVING 30
#define DTV_ISDBT_LAYERC_FEC 31
#define DTV_ISDBT_LAYERC_MODULATION 32
#define DTV_ISDBT_LAYERC_SEGMENT_COUNT 33
#define DTV_ISDBT_LAYERC_TIME_INTERLEAVING 34
#define DTV_API_VERSION 35
#define DTV_CODE_RATE_HP 36
#define DTV_CODE_RATE_LP 37
#define DTV_GUARD_INTERVAL 38
#define DTV_TRANSMISSION_MODE 39
#define DTV_HIERARCHY 40
#define DTV_ISDBT_LAYER_ENABLED 41
#define DTV_STREAM_ID 42
#define DTV_ISDBS_TS_ID_LEGACY DTV_STREAM_ID
#define DTV_DVBT2_PLP_ID_LEGACY 43
#define DTV_ENUM_DELSYS 44
/* ATSC-MH */
#define DTV_ATSCMH_FIC_VER 45
#define DTV_ATSCMH_PARADE_ID 46
#define DTV_ATSCMH_NOG 47
#define DTV_ATSCMH_TNOG 48
#define DTV_ATSCMH_SGN 49
#define DTV_ATSCMH_PRC 50
#define DTV_ATSCMH_RS_FRAME_MODE 51
#define DTV_ATSCMH_RS_FRAME_ENSEMBLE 52
#define DTV_ATSCMH_RS_CODE_MODE_PRI 53
#define DTV_ATSCMH_RS_CODE_MODE_SEC 54
#define DTV_ATSCMH_SCCC_BLOCK_MODE 55
#define DTV_ATSCMH_SCCC_CODE_MODE_A 56
#define DTV_ATSCMH_SCCC_CODE_MODE_B 57
#define DTV_ATSCMH_SCCC_CODE_MODE_C 58
#define DTV_ATSCMH_SCCC_CODE_MODE_D 59
#define DTV_INTERLEAVING 60
#define DTV_LNA 61
/* Quality parameters */
#define DTV_STAT_SIGNAL_STRENGTH 62
#define DTV_STAT_CNR 63
#define DTV_STAT_PRE_ERROR_BIT_COUNT 64
#define DTV_STAT_PRE_TOTAL_BIT_COUNT 65
#define DTV_STAT_POST_ERROR_BIT_COUNT 66
#define DTV_STAT_POST_TOTAL_BIT_COUNT 67
#define DTV_STAT_ERROR_BLOCK_COUNT 68
#define DTV_STAT_TOTAL_BLOCK_COUNT 69
#define DTV_MAX_COMMAND DTV_STAT_TOTAL_BLOCK_COUNT
typedef enum fe_pilot {
PILOT_ON,
PILOT_OFF,
PILOT_AUTO,
} fe_pilot_t;
typedef enum fe_rolloff {
ROLLOFF_35, /* Implied value in DVB-S, default for DVB-S2 */
ROLLOFF_20,
ROLLOFF_25,
ROLLOFF_AUTO,
} fe_rolloff_t;
typedef enum fe_delivery_system {
SYS_UNDEFINED,
SYS_DVBC_ANNEX_A,
SYS_DVBC_ANNEX_B,
SYS_DVBT,
SYS_DSS,
SYS_DVBS,
SYS_DVBS2,
SYS_DVBH,
SYS_ISDBT,
SYS_ISDBS,
SYS_ISDBC,
SYS_ATSC,
SYS_ATSCMH,
SYS_DTMB,
SYS_CMMB,
SYS_DAB,
SYS_DVBT2,
SYS_TURBO,
SYS_DVBC_ANNEX_C,
} fe_delivery_system_t;
/* backward compatibility */
#define SYS_DVBC_ANNEX_AC SYS_DVBC_ANNEX_A
#define SYS_DMBTH SYS_DTMB /* DMB-TH is legacy name, use DTMB instead */
/* ATSC-MH */
enum atscmh_sccc_block_mode {
ATSCMH_SCCC_BLK_SEP = 0,
ATSCMH_SCCC_BLK_COMB = 1,
ATSCMH_SCCC_BLK_RES = 2,
};
enum atscmh_sccc_code_mode {
ATSCMH_SCCC_CODE_HLF = 0,
ATSCMH_SCCC_CODE_QTR = 1,
ATSCMH_SCCC_CODE_RES = 2,
};
enum atscmh_rs_frame_ensemble {
ATSCMH_RSFRAME_ENS_PRI = 0,
ATSCMH_RSFRAME_ENS_SEC = 1,
};
enum atscmh_rs_frame_mode {
ATSCMH_RSFRAME_PRI_ONLY = 0,
ATSCMH_RSFRAME_PRI_SEC = 1,
ATSCMH_RSFRAME_RES = 2,
};
enum atscmh_rs_code_mode {
ATSCMH_RSCODE_211_187 = 0,
ATSCMH_RSCODE_223_187 = 1,
ATSCMH_RSCODE_235_187 = 2,
ATSCMH_RSCODE_RES = 3,
};
#define NO_STREAM_ID_FILTER (~0U)
#define LNA_AUTO (~0U)
struct dtv_cmds_h {
char *name; /* A display name for debugging purposes */
__u32 cmd; /* A unique ID */
/* Flags */
__u32 set:1; /* Either a set or get property */
__u32 buffer:1; /* Does this property use the buffer? */
__u32 reserved:30; /* Align */
};
/**
* Scale types for the quality parameters.
* @FE_SCALE_NOT_AVAILABLE: That QoS measure is not available. That
* could indicate a temporary or a permanent
* condition.
* @FE_SCALE_DECIBEL: The scale is measured in 0.0001 dB steps, typically
* used on signal measures.
* @FE_SCALE_RELATIVE: The scale is a relative percentual measure,
* ranging from 0 (0%) to 0xffff (100%).
* @FE_SCALE_COUNTER: The scale counts the occurrence of an event, like
* bit error, block error, lapsed time.
*/
enum fecap_scale_params {
FE_SCALE_NOT_AVAILABLE = 0,
FE_SCALE_DECIBEL,
FE_SCALE_RELATIVE,
FE_SCALE_COUNTER
};
/**
* struct dtv_stats - Used for reading a DTV status property
*
* @value: value of the measure. Should range from 0 to 0xffff;
* @scale: Filled with enum fecap_scale_params - the scale
* in usage for that parameter
*
* For most delivery systems, this will return a single value for each
* parameter.
* It should be noticed, however, that new OFDM delivery systems like
* ISDB can use different modulation types for each group of carriers.
* On such standards, up to 8 groups of statistics can be provided, one
* for each carrier group (called "layer" on ISDB).
* In order to be consistent with other delivery systems, the first
* value refers to the entire set of carriers ("global").
* dtv_status:scale should use the value FE_SCALE_NOT_AVAILABLE when
* the value for the entire group of carriers or from one specific layer
* is not provided by the hardware.
* st.len should be filled with the latest filled status + 1.
*
* In other words, for ISDB, those values should be filled like:
* u.st.stat.svalue[0] = global statistics;
* u.st.stat.scale[0] = FE_SCALE_DECIBELS;
* u.st.stat.value[1] = layer A statistics;
* u.st.stat.scale[1] = FE_SCALE_NOT_AVAILABLE (if not available);
* u.st.stat.svalue[2] = layer B statistics;
* u.st.stat.scale[2] = FE_SCALE_DECIBELS;
* u.st.stat.svalue[3] = layer C statistics;
* u.st.stat.scale[3] = FE_SCALE_DECIBELS;
* u.st.len = 4;
*/
struct dtv_stats {
__u8 scale; /* enum fecap_scale_params type */
union {
__u64 uvalue; /* for counters and relative scales */
__s64 svalue; /* for 0.0001 dB measures */
};
} __attribute__ ((packed));
#define MAX_DTV_STATS 4
struct dtv_fe_stats {
__u8 len;
struct dtv_stats stat[MAX_DTV_STATS];
} __attribute__ ((packed));
struct dtv_property {
__u32 cmd;
__u32 reserved[3];
union {
__u32 data;
struct dtv_fe_stats st;
struct {
__u8 data[32];
__u32 len;
__u32 reserved1[3];
void *reserved2;
} buffer;
} u;
int result;
} __attribute__ ((packed));
/* num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl */
#define DTV_IOCTL_MAX_MSGS 64
struct dtv_properties {
__u32 num;
struct dtv_property *props;
};
#define FE_SET_PROPERTY _IOW('o', 82, struct dtv_properties)
#define FE_GET_PROPERTY _IOR('o', 83, struct dtv_properties)
/**
* When set, this flag will disable any zigzagging or other "normal" tuning
* behaviour. Additionally, there will be no automatic monitoring of the lock
* status, and hence no frontend events will be generated. If a frontend device
* is closed, this flag will be automatically turned off when the device is
* reopened read-write.
*/
#define FE_TUNE_MODE_ONESHOT 0x01
#define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info)
#define FE_DISEQC_RESET_OVERLOAD _IO('o', 62)
#define FE_DISEQC_SEND_MASTER_CMD _IOW('o', 63, struct dvb_diseqc_master_cmd)
#define FE_DISEQC_RECV_SLAVE_REPLY _IOR('o', 64, struct dvb_diseqc_slave_reply)
#define FE_DISEQC_SEND_BURST _IO('o', 65) /* fe_sec_mini_cmd_t */
#define FE_SET_TONE _IO('o', 66) /* fe_sec_tone_mode_t */
#define FE_SET_VOLTAGE _IO('o', 67) /* fe_sec_voltage_t */
#define FE_ENABLE_HIGH_LNB_VOLTAGE _IO('o', 68) /* int */
#define FE_READ_STATUS _IOR('o', 69, fe_status_t)
#define FE_READ_BER _IOR('o', 70, __u32)
#define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, __u16)
#define FE_READ_SNR _IOR('o', 72, __u16)
#define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32)
#define FE_SET_FRONTEND _IOW('o', 76, struct dvb_frontend_parameters)
#define FE_GET_FRONTEND _IOR('o', 77, struct dvb_frontend_parameters)
#define FE_SET_FRONTEND_TUNE_MODE _IO('o', 81) /* unsigned int */
#define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event)
#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
#endif /*_DVBFRONTEND_H_*/

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

@@ -0,0 +1,111 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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 )));
/*
* Macros used internally inside libdvbv5 frontend part, to output logs
*/
#ifndef _DOXYGEN
#ifndef __DVB_FE_PRIV_H
#define dvb_log(fmt, arg...) do {\
parms->logfunc(LOG_INFO, fmt, ##arg); \
} while (0)
#define dvb_logerr(fmt, arg...) do {\
parms->logfunc(LOG_ERR, fmt, ##arg); \
} while (0)
#define dvb_logdbg(fmt, arg...) do {\
parms->logfunc(LOG_DEBUG, fmt, ##arg); \
} while (0)
#define dvb_logwarn(fmt, arg...) do {\
parms->logfunc(LOG_WARNING, fmt, ##arg); \
} while (0)
#define dvb_loginfo(fmt, arg...) do {\
parms->logfunc(LOG_NOTICE, fmt, ##arg); \
} while (0)
#define dvb_perror(msg) do {\
parms->logfunc(LOG_ERR, "%s: %s", msg, strerror(errno)); \
} while (0)
#else
#define dvb_log(fmt, arg...) do {\
parms->p.logfunc(LOG_INFO, fmt, ##arg); \
} while (0)
#define dvb_logerr(fmt, arg...) do {\
parms->p.logfunc(LOG_ERR, fmt, ##arg); \
} while (0)
#define dvb_logdbg(fmt, arg...) do {\
parms->p.logfunc(LOG_DEBUG, fmt, ##arg); \
} while (0)
#define dvb_logwarn(fmt, arg...) do {\
parms->p.logfunc(LOG_WARNING, fmt, ##arg); \
} while (0)
#define dvb_loginfo(fmt, arg...) do {\
parms->p.logfunc(LOG_NOTICE, fmt, ##arg); \
} while (0)
#define dvb_perror(msg) do {\
parms->p.logfunc(LOG_ERR, "%s: %s", msg, strerror(errno)); \
} while (0)
#endif
#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

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

@@ -0,0 +1,151 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @author Mauro Carvalho Chehab
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
/*
* Satellite handling functions
*/
/**
* @struct dvbsat_freqrange
* @brief Defines a frequency range used by Satellite
* @ingroup satellite
*
* @param low low frequency, in kHz
* @param high high frequency, in kHz
*/
struct dvbsat_freqrange {
unsigned low, high;
};
/**
* @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
* @param lowfreq Low frequency Intermediate Frequency of the LNBf, in kHz
* @param highfreq High frequency Intermediate frequency of the LNBf,
* in kHz
* @param rangeswitch For LNBf that has multiple frequency ranges controlled
* by a voltage change, specify the start frequency where
* the second range will be applied.
* @param freqrange Contains the range(s) of frequencies supported by a
* given LNBf.
*
* 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;
unsigned lowfreq, highfreq;
unsigned rangeswitch;
struct dvbsat_freqrange 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.
*/
const struct dvb_sat_lnb *dvb_sat_get_lnb(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);
#ifdef __cplusplus
}
#endif
#endif // _LIBSAT_H

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

@@ -0,0 +1,419 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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
* @param vct VCT table descriptor pointer
* @param program PAT/PMT array associated programs found at MPEG-TS
* @param nit NIT table descriptor pointer
* @param sdt SDT table descriptor pointer
* @param num_program Number of program entries at program array.
*
* Those descriptors are filled by the scan routines when the tables are
* found. Otherwise, they're NULL.
*/
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_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,268 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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

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

@@ -0,0 +1,224 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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
* @ingroup dvb_table
* @def DVB_TABLE_EIT_SCHEDULE_OTHER
* @brief Start table ID for the DVB EIT schedule data on other TS
* @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 /* - 0x5F */
#define DVB_TABLE_EIT_SCHEDULE_OTHER 0x60 /* - 0x6F */
/**
* @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) \
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

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

@@ -0,0 +1,140 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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;
} __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 TS ID
* @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

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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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 ) \
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

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

@@ -0,0 +1,249 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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

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

@@ -0,0 +1,249 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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

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

@@ -0,0 +1,173 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @author Andre Roth
*
* @par Relevant specs
* The table described herein is defined in ISO 13818-1
*
* @see
* http://en.wikipedia.org/wiki/MPEG_transport_stream
*
* @par Bug Report
* Please submit bug reports and patches to linux-media@vger.kernel.org
*/
#include <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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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 ) \
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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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) \
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

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

@@ -0,0 +1,289 @@
/*
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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_reserved0 = 0x00,
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_reserved = 0x15,
stream_private = 0x80
};
/**
* @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) \
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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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) \
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 <m.chehab@samsung.com>
* 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 General Public License
* as published by the Free Software Foundation version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 General Public License version 2 (GPLv2)
* @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) \
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

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

@@ -0,0 +1,45 @@
/*
* 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, version 2.1,
* as published by the Free Software Foundation.
*
* 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__)
#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

74
include/libv4l1.h Normal file
View File

@@ -0,0 +1,74 @@
/*
# (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, version 2.1,
# as published by the Free Software Foundation.
#
# 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

115
include/libv4l2.h Normal file
View File

@@ -0,0 +1,115 @@
/*
# (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, version 2.1,
# as published by the Free Software Foundation.
#
# 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 occured. */
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

351
include/libv4l2rds.h Normal file
View File

@@ -0,0 +1,351 @@
/*
* Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
* Author: Konke Radlow <koradlow@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, version 2.1,
* as published by the Free Software Foundation.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 __LIBV4L2RDS
#define __LIBV4L2RDS
#include <stdbool.h>
#include <stdint.h>
#include <linux/videodev2.h>
#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

156
include/libv4lconvert.h Normal file
View File

@@ -0,0 +1,156 @@
/*
# (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, version 2.1,
# as published by the Free Software Foundation.
#
# 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__)
#include <sys/time.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#endif
/* end broken header workaround includes */
#include <linux/videodev2.h>
#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