Commit 38db8779 authored by Alessio Treglia's avatar Alessio Treglia

Imported Upstream version 1.0

parents
# Contributors to biTStream
#
# The format of this file was inspired by the Linux kernel CREDITS file.
# Authors are listed alphabetically.
#
# The fields are: name (N), email (E), web-address (W), CVS account login (C),
# PGP key ID and fingerprint (P), description (D), and snail-mail address (S).
N: Christophe Massiot
E: massiot AT via DOT ecp DOT fr
C: massiot
D: All of the code
N: Georgi Chorbadzhiyski
E: gf AT unixsol DOT org
D: Additional MPEG/DVB PSI and descriptors support, examples/dvb_gen_si
Copyright (c) 2010-2011 VideoLAN
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Installing biTStream
====================
Make install copies all top-level directories (except dvb-examples) in
/usr/local/include/bitstream directory.
Install bitstream in its default location /usr/local/include/bitstream:
$> make install
Install bitstream in another location, eg: /usr/include/bitstream
$> make PREFIX=/usr install
PREFIX ?= /usr/local
INCLUDE = $(subst //,/,$(DESTDIR)/$(PREFIX)/include/bitstream)
VERSION = 1.0
all:
@echo "Run \"make install\" to install biTStream into $(INCLUDE)"
install:
@echo "INSTALL $(INCLUDE)"
@install -d $(INCLUDE)
@install -m 644 common.h $(INCLUDE)/
@install -d $(INCLUDE)/dvb
@install -m 644 dvb/*.h $(INCLUDE)/dvb
@install -d $(INCLUDE)/dvb/si
@install -m 644 dvb/si/*.h $(INCLUDE)/dvb/si
@install -d $(INCLUDE)/ietf
@install -m 644 ietf/* $(INCLUDE)/ietf
@install -d $(INCLUDE)/mpeg
@install -m 644 mpeg/*.h $(INCLUDE)/mpeg
@install -d $(INCLUDE)/mpeg/psi
@install -m 644 mpeg/psi/*.h $(INCLUDE)/mpeg/psi
uninstall:
@echo "REMOVE $(INCLUDE)"
@rm -rf $(INCLUDE)
distcheck:
git archive --format=tar --prefix=bitstream-$(VERSION)/ master | bzip2 -9 > bitstream-$(VERSION).tar.bz2
.PHONY: install uninstall distcheck
1.0 (15 Dec 2011)
=================
- Initial public release
Welcome to biTStream!
=====================
biTStream is a set of C headers allowing a simpler access to binary
structures such as specified by MPEG, DVB, IETF, etc.
biTStream vs. libdvbpsi
=======================
libdvbpsi converts binary structures to C structures. Lists are implemented
with chained lists of C structures.
biTStream is lower level, and more efficient: fewer memory allocations,
fewer memory copies. It also features a better separation between layers
and specifications.
Extending biTStream
===================
A lot of MPEG and DVB tables and descriptors are not implemented yet, or
are incomplete. Patches are very welcome.
Though biTStream is originally targeted at video applications in general
and MPEG-2 transport stream in particular, the same principle can be
followed with other binary data types, and patches are welcome here too.
Just try to follow a coherent directory naming.
My coding style is Linux kernel + Hungarian conventions. Really, I do not
care about the coding style of new files; do (WTF) you want. However, for
existing files, please try to follow the original conventions.
biTStream is released under the MIT license because since it is a
direct application of standards, there is no added value. The MIT license
doesn't require you to contribute back your changes, and you can use
biTStream in proprietary applications. However, if you add new structures,
or fix bugs in current structures, you'd be very nice to contribute them
(again, there is no point in concealing this). Thanks.
Supported SI tables
===================
* Program Allocation Table (PAT)
* Conditional Access Table (CAT)
* Transport Stream Descriptor Table (TSDT)
* Program Map Table (PMT)
* Network Information Table (NIT)
* Bouquet Association Table (BAT)
* Service Definition Table (SDT)
* Event Information Table (EIT)
* Time and Date Table (TDT)
* Time Offset Table (TOT)
* Running Status Table (RST)
* Stuffing Table (ST)
* Discontinuity Information Table (DIT)
* Selection Information Table (SIT)
Supported MPEG descriptors
==========================
* Descriptor 0x02: Video stream descriptor
* Descriptor 0x03: Audio stream descriptor
* Descriptor 0x04: Hierarchy descriptor
* Descriptor 0x05: Registration descriptor
* Descriptor 0x06: Data stream alignment descriptor
* Descriptor 0x07: Target Background Grid descriptor
* Descriptor 0x08: Video Window descriptor
* Descriptor 0x09: Conditional access descriptor
* Descriptor 0x0A: ISO-639 language descriptor
* Descriptor 0x0B: System clock descriptor
* Descriptor 0x0C: Multiplex buffer utilization descriptor
* Descriptor 0x0D: Copyright descriptor
* Descriptor 0x0E: Maximum bitrate descriptor
* Descriptor 0x0F: Private data indicator descriptor
* Descriptor 0x10: Smoothing buffer descriptor
* Descriptor 0x11: STD descriptor
* Descriptor 0x12: IBP descriptor
* Descriptor 0x1b: MPEG-4 video descriptor
* Descriptor 0x1c: MPEG-4 audio descriptor
* Descriptor 0x1d: IOD_descriptor
* Descriptor 0x1e: SL_descriptor
* Descriptor 0x1f: FMC_descriptor
* Descriptor 0x20: External ES_ID descriptor
* Descriptor 0x21: MuxCode descriptor
* Descriptor 0x22: FmxBufferSize descriptor
* Descriptor 0x23: MultiplexBuffer descriptor
* Descriptor 0x24: Content labeling descriptor
* Descriptor 0x25: Metadata pointer descriptor
* Descriptor 0x26: Metadata descriptor
* Descriptor 0x27: Metadata STD descriptor
* Descriptor 0x28: AVC video descriptor
* Descriptor 0x2a: AVC timing and HRD descriptor
* Descriptor 0x2b: MPEG-2 AAC audio descriptor
* Descriptor 0x2c: FlexMuxTiming_descriptor
Supported DVB descriptors
=========================
* Descriptor 0x40: Network name descriptor
* Descriptor 0x41: Service list descriptor
* Descriptor 0x42: Stuffing descriptor
* Descriptor 0x43: Satellite delivery system descriptor
* Descriptor 0x44: Cable delivery system descriptor
* Descriptor 0x45: VBI data descriptor
* Descriptor 0x46: VBI teletext descriptor
* Descriptor 0x47: Bouquet name descriptor
* Descriptor 0x48: Service descriptor
* Descriptor 0x49: Country availability descriptor
* Descriptor 0x4a: Linkage descriptor
* Descriptor 0x4b: NVOD reference descriptor
* Descriptor 0x4c: Time shifted service descriptor
* Descriptor 0x4d: Short event descriptor
* Descriptor 0x4e: Extended event descriptor
* Descriptor 0x4f: Time shifted event descriptor
* Descriptor 0x50: Component descriptor
* Descriptor 0x51: Mosaic descriptor
* Descriptor 0x52: Stream identifier descriptor
* Descriptor 0x53: CA identifier descriptor
* Descriptor 0x54: Content descriptor
* Descriptor 0x55: Parental rating descriptor
* Descriptor 0x56: Teletext descriptor
* Descriptor 0x57: Telephone descriptor
* Descriptor 0x58: Local time offset descriptor
* Descriptor 0x59: Subtitling descriptor
* Descriptor 0x5a: Terrestrial delivery system descriptor
* Descriptor 0x5b: Multilingual network name descriptor
* Descriptor 0x5c: Multilingual bouquet name descriptor
* Descriptor 0x5d: Multilingual service name descriptor
* Descriptor 0x5e: Multilingual component descriptor
* Descriptor 0x5f: Private data specifier descriptor
* Descriptor 0x60: Service move descriptor
* Descriptor 0x61: Short smoothing buffer descriptor
* Descriptor 0x62: Frequency list descriptor
* Descriptor 0x63: Partial transport stream descriptor
* Descriptor 0x64: Data broadcast descriptor
* Descriptor 0x65: Scrambling descriptor
* Descriptor 0x66: Data broadcast id descriptor
* Descriptor 0x67: Transport stream descriptor
* Descriptor 0x68: DSNG descriptor
* Descriptor 0x69: PDC descriptor
* Descriptor 0x6a: AC-3 descriptor
* Descriptor 0x6b: Ancillary data descriptor
* Descriptor 0x6c: Cell list descriptor
* Descriptor 0x6d: Cell frequency link descriptor
* Descriptor 0x6e: Announcement support descriptor
* Descriptor 0x7a: Enhanced AC-3 descriptor
* Descriptor 0x7b: DTS descriptor
* Descriptor 0x7c: AAC descriptor
To see what is unsupported look in the TODO file.
Example usage
=============
To see biTSream in action look in examples directory.
TODO items for biTStream. The items are not ordered by importance
so if you like something just do it and send a patch.
- Add support (parser, generator, example) for these MPEG descriptors:
- Descriptor 0x29 IPMP_descriptor (defined in ISO/IEC 13818-11, MPEG-2 IPMP)
- Add support (parser, generator, example) for these DVB descriptors:
- Descriptor 0x6f: application_signalling_descriptor
- Descriptor 0x70: adaptation_field_data_descriptor
- Descriptor 0x71: service_identifier_descriptor
- Descriptor 0x72: service_availability_descriptor
- Descriptor 0x73: default_authority_descriptor
- Descriptor 0x74: related_content_descriptor
- Descriptor 0x75: TVA_id_descriptor
- Descriptor 0x76: content_identifier_descriptor
- Descriptor 0x77: time_slice_fec_identifier_descriptor
- Descriptor 0x78: ECM_repetition_rate_descriptor
- Descriptor 0x79: S2_satellite_delivery_system_descriptor
- Descriptor 0x7d: XAIT location descriptor
- Descriptor 0x7e: FTA_content_management_descriptor
- Descriptor 0x7f: extension descriptor
- Add support for extension descriptors
/*****************************************************************************
* common.h: (Rare) common declarations for all submodules
*****************************************************************************
* Copyright (C) 2010 VideoLAN
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*****************************************************************************/
#ifndef __BITSTREAM_COMMON_H__
#define __BITSTREAM_COMMON_H__
#include <stdint.h> /* uint8_t, uint16_t, etc... */
#include <stdbool.h> /* bool */
#include <string.h> /* memset, memcpy */
#define BITSTREAM_VERSION_MAJOR 1
#define BITSTREAM_VERSION_MINOR 0
#define BITSTREAM_VERSION_REVISION 0
#ifdef __cplusplus
extern "C"
{
#endif
typedef enum print_type_t {
PRINT_TEXT,
PRINT_XML
} print_type_t;
typedef void (*f_print)(void *, const char *, ...) __attribute__ ((format(printf, 2, 3)));
typedef char * (*f_iconv)(void *, const char *, char *, size_t);
#ifdef __cplusplus
}
#endif
#endif
/*****************************************************************************
* ci.h: ETSI EN 50 221 Common Interface Specification
*****************************************************************************
* Copyright (C) 2010 VideoLAN
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*****************************************************************************/
/*
* Normative references:
* - ETSI EN 50 221 (1997) (Common Interface Specification)
*/
#ifndef __BITSTREAM_DVB_CI_H__
#define __BITSTREAM_DVB_CI_H__
#include <bitstream/mpeg/psi/psi.h>
#include <bitstream/mpeg/psi/descriptors.h>
#ifdef __cplusplus
extern "C"
{
#endif
/*****************************************************************************
* Conditional Access Program Map Table
*****************************************************************************
* Implementation note: the first field here is ca_pmt_list_management,
* since the previous length field is variable size and is generally put
* afterwards.
*****************************************************************************/
#define CAPMT_HEADER_SIZE 6
#define CAPMT_ES_SIZE 5
#define CAPMTI_HEADER_SIZE 3
/* Max theoritical size is PSI_MAX_SIZE + ~100 */
#define CAPMT_DECLARE PSI_PRIVATE_DECLARE
#define capmt_allocate psi_private_allocate
static inline void capmt_init(uint8_t *p_capmt)
{
p_capmt[3] = 0xc1;
p_capmt[4] = 0xf0;
}
static inline void capmt_set_listmanagement(uint8_t *p_capmt, uint8_t i_mgt)
{
p_capmt[0] = i_mgt;
}
static inline void capmt_set_program(uint8_t *p_capmt, uint16_t i_program)
{
p_capmt[1] = i_program >> 8;
p_capmt[2] = i_program & 0xff;
}
static inline void capmt_set_version(uint8_t *p_capmt, uint8_t i_version)
{
p_capmt[3] &= ~0x3e;
p_capmt[3] |= i_version << 1;
}
static inline uint8_t *capmt_get_infos(uint8_t *p_capmt)
{
return &p_capmt[4];
}
static inline uint16_t capmt_get_infoslength(const uint8_t *p_capmt)
{
return ((p_capmt[4] & 0xf) << 8) | p_capmt[5];
}
static inline void capmtn_init(uint8_t *p_capmt_n)
{
p_capmt_n[1] = 0xe0;
}
static inline void capmtn_set_streamtype(uint8_t *p_capmt_n,
uint8_t i_stream_type)
{
p_capmt_n[0] = i_stream_type;
}
static inline void capmtn_set_pid(uint8_t *p_capmt_n, uint16_t i_pid)
{
p_capmt_n[1] &= ~0x1f;
p_capmt_n[1] |= i_pid >> 8;
p_capmt_n[2] = i_pid & 0xff;
}
static inline uint16_t capmtn_get_infoslength(const uint8_t *p_capmt_n)
{
return ((p_capmt_n[3] & 0xf) << 8) | p_capmt_n[4];
}
static inline uint8_t *capmtn_get_infos(uint8_t *p_capmt_n)
{
return &p_capmt_n[3];
}
static inline uint8_t *capmt_get_es(uint8_t *p_capmt, uint8_t n)
{
uint8_t *p_capmt_n = p_capmt + CAPMT_HEADER_SIZE
+ capmt_get_infoslength(p_capmt);
while (n) {
p_capmt_n += CAPMT_ES_SIZE + capmtn_get_infoslength(p_capmt_n);
n--;
}
return p_capmt_n;
}
static inline void capmti_init(uint8_t *p_infos)
{
p_infos[0] = 0xf0;
}
static inline void capmti_set_length(uint8_t *p_infos, uint16_t i_length)
{
p_infos[0] &= ~0xf;
p_infos[0] |= i_length >> 8;
p_infos[1] = i_length & 0xff;
}
static inline uint16_t capmti_get_length(const uint8_t *p_infos)
{
return ((p_infos[0] & 0xf) << 8) | p_infos[1];
}
static inline void capmti_set_cmd(uint8_t *p_infos, uint8_t i_cmd)
{
p_infos[2] = i_cmd;
}
static inline uint8_t *capmti_get_info(uint8_t *p_infos, uint16_t n)
{
uint8_t *p_info = p_infos + CAPMTI_HEADER_SIZE;
uint16_t i_infos_size = capmti_get_length(p_infos) + DESCS_HEADER_SIZE;
while (n) {
if (p_info + DESC_HEADER_SIZE - p_infos > i_infos_size) return NULL;
p_info += DESC_HEADER_SIZE + desc_get_length(p_info);
n--;
}
if (p_info - p_infos >= i_infos_size) return NULL;
return p_info;
}
#ifdef __cplusplus
}
#endif
#endif
/*****************************************************************************
* si.h: ETSI EN 300 468 Service Information
*****************************************************************************
* Copyright (C) 2009-2010 VideoLAN
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*****************************************************************************/
/*
* Normative references:
* - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems)
* - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems)
*/
#ifndef __BITSTREAM_DVB_SI_H__
#define __BITSTREAM_DVB_SI_H__
#include <bitstream/common.h>
#include <bitstream/mpeg/psi/psi.h>
#include <bitstream/mpeg/psi/descriptors.h>
#include <bitstream/dvb/si/numbers.h>
#include <bitstream/dvb/si/datetime.h>
#include <bitstream/dvb/si/strings.h>
#include <bitstream/dvb/si/descs_list.h>
#include <bitstream/dvb/si/nit.h>
#include <bitstream/dvb/si/bat.h>
#include <bitstream/dvb/si/sdt.h>
#include <bitstream/dvb/si/eit.h>
#include <bitstream/dvb/si/tdt.h>
#include <bitstream/dvb/si/tot.h>
#include <bitstream/dvb/si/rst.h>
#include <bitstream/dvb/si/st.h>
#include <bitstream/dvb/si/dit.h>
#include <bitstream/dvb/si/sit.h>
#endif
/*****************************************************************************
* bat.h: ETSI EN 300 468 Bouquet Association Table (BAT)
*****************************************************************************
* Copyright (C) 2009-2010 VideoLAN
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Georgi Chorbadzhiyski <georgi@unixsol.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*****************************************************************************/
/*
* Normative references:
* - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems)
*/
#ifndef __BITSTREAM_DVB_BAT_H__
#define __BITSTREAM_DVB_BAT_H__
#include <bitstream/common.h>
#include <bitstream/mpeg/psi/psi.h>
#include <bitstream/mpeg/psi/descriptors.h>
#include <bitstream/dvb/si/nit.h>
#ifdef __cplusplus
extern "C"
{
#endif
/*****************************************************************************
* Bouquet Association Table
*****************************************************************************/
#define BAT_PID 0x11
#define BAT_TABLE_ID 0x4a
#define BAT_HEADER_SIZE (PSI_HEADER_SIZE_SYNTAX1 + 2)
#define BAT_HEADER2_SIZE 2
#define BAT_TS_SIZE 6
#define bat_set_bouquet_id psi_set_tableidext
#define bat_get_bouquet_id psi_get_tableidext
static inline void bat_init(uint8_t *p_bat)
{
psi_init(p_bat, true);
psi_set_tableid(p_bat, BAT_TABLE_ID);
p_bat[8] = 0xf0;
}
#define bat_set_length nit_set_length
#define bat_set_desclength nit_set_desclength
#define bat_get_desclength nit_get_desclength
#define bat_get_descs nit_get_descs
#define bath_init nith_init
#define bath_set_tslength nith_set_tslength
#define bath_get_tslength nith_get_tslength
#define bat_get_header2 nit_get_header2
#define batn_init nitn_init
#define batn_set_tsid nitn_set_tsid
#define batn_get_tsid nitn_get_tsid
#define batn_set_onid nitn_set_onid
#define batn_get_onid nitn_get_onid
#define batn_set_desclength nitn_set_desclength
#define batn_get_desclength nitn_get_desclength
#define batn_get_descs nitn_get_descs
#define bat_get_ts nit_get_ts
#define bat_validate_ts nit_validate_ts
#define bat_table_find_ts nit_table_find_ts
#define bat_table_validate nit_table_validate
static inline bool bat_validate(const uint8_t *p_bat)
{
uint16_t i_section_size = psi_get_length(p_bat) + PSI_HEADER_SIZE
- PSI_CRC_SIZE;
const uint8_t *p_bat_n;
if (!psi_get_syntax(p_bat) || psi_get_tableid(p_bat) != BAT_TABLE_ID)
return false;
if (i_section_size < BAT_HEADER_SIZE
|| i_section_size < BAT_HEADER_SIZE + bat_get_desclength(p_bat))
return false;
if (!descs_validate(p_bat + 8))
return false;
p_bat_n = p_bat + BAT_HEADER_SIZE + bat_get_desclength(p_bat);
if (bath_get_tslength(p_bat_n) != p_bat + i_section_size - p_bat_n
- BAT_HEADER2_SIZE)
return false;
p_bat_n += BAT_HEADER2_SIZE;
while (p_bat_n + BAT_TS_SIZE - p_bat <= i_section_size
&& p_bat_n + BAT_TS_SIZE + batn_get_desclength(p_bat_n) - p_bat
<= i_section_size) {
if (!descs_validate(p_bat_n + 4))
return false;
p_bat_n += BAT_TS_SIZE + batn_get_desclength(p_bat_n);
}
return (p_bat_n - p_bat == i_section_size);
}
#ifdef __cplusplus
}
#endif
#endif
/*****************************************************************************
* bat_print.h: ETSI EN 300 468 Bouquet Association Table (BAT) (printing)
*****************************************************************************
* Copyright (C) 2010 VideoLAN
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Georgi Chorbadzhiyski <georgi@unixsol.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.