├── .gitlab-ci.yml ├── AUTHORS ├── COPYING ├── INSTALL ├── Makefile ├── NEWS ├── README ├── TODO ├── atsc ├── a52.h ├── si.h └── si │ ├── desc_81.h │ ├── desc_cc.h │ └── descs_list.h ├── bitstream.pc.in ├── common.h ├── dvb ├── ci.h ├── si.h ├── si │ ├── bat.h │ ├── bat_print.h │ ├── datetime.h │ ├── desc_40.h │ ├── desc_41.h │ ├── desc_42.h │ ├── desc_43.h │ ├── desc_44.h │ ├── desc_45.h │ ├── desc_46.h │ ├── desc_47.h │ ├── desc_48.h │ ├── desc_49.h │ ├── desc_4a.h │ ├── desc_4b.h │ ├── desc_4c.h │ ├── desc_4d.h │ ├── desc_4e.h │ ├── desc_4f.h │ ├── desc_50.h │ ├── desc_51.h │ ├── desc_52.h │ ├── desc_53.h │ ├── desc_54.h │ ├── desc_55.h │ ├── desc_56.h │ ├── desc_57.h │ ├── desc_58.h │ ├── desc_59.h │ ├── desc_5a.h │ ├── desc_5b.h │ ├── desc_5c.h │ ├── desc_5d.h │ ├── desc_5e.h │ ├── desc_5f.h │ ├── desc_60.h │ ├── desc_61.h │ ├── desc_62.h │ ├── desc_63.h │ ├── desc_64.h │ ├── desc_65.h │ ├── desc_66.h │ ├── desc_67.h │ ├── desc_68.h │ ├── desc_69.h │ ├── desc_6a.h │ ├── desc_6b.h │ ├── desc_6c.h │ ├── desc_6d.h │ ├── desc_6e.h │ ├── desc_7a.h │ ├── desc_7b.h │ ├── desc_7c.h │ ├── desc_83p28.h │ ├── desc_88p28.h │ ├── descs_list.h │ ├── dit.h │ ├── dit_print.h │ ├── eit.h │ ├── eit_print.h │ ├── nit.h │ ├── nit_print.h │ ├── numbers.h │ ├── rst.h │ ├── rst_print.h │ ├── sdt.h │ ├── sdt_print.h │ ├── sit.h │ ├── sit_print.h │ ├── st.h │ ├── strings.h │ ├── tdt.h │ ├── tdt_print.h │ ├── tot.h │ └── tot_print.h ├── si_print.h ├── sim.h ├── sub.h ├── telx.h └── vbi.h ├── ebu └── biss.h ├── examples ├── Makefile ├── dvb_ecmg.c ├── dvb_ecmg_test.c ├── dvb_gen_si.c ├── dvb_gen_si.test.sh ├── dvb_print_si.c ├── dvb_print_si.output.txt ├── dvb_print_si.output.xml ├── mpeg_print_pcr.c ├── mpeg_restamp.c └── rtp_check_seqnum.c ├── ieee └── ethernet.h ├── ietf ├── ip.h ├── rfc4175.h ├── rtcp.h ├── rtcp3611.h ├── rtcp_fb.h ├── rtcp_rr.h ├── rtcp_sdes.h ├── rtcp_sr.h ├── rtp.h ├── rtp2250.h ├── rtp2435.h ├── rtp3551.h ├── rtp3640.h ├── rtp6184.h ├── rtp7587.h └── udp.h ├── itu └── h265.h ├── mpeg ├── aac.h ├── h264.h ├── mp2v.h ├── mpga.h ├── pes.h ├── psi.h ├── psi │ ├── cat.h │ ├── cat_print.h │ ├── desc_02.h │ ├── desc_03.h │ ├── desc_04.h │ ├── desc_05.h │ ├── desc_06.h │ ├── desc_07.h │ ├── desc_08.h │ ├── desc_09.h │ ├── desc_0a.h │ ├── desc_0b.h │ ├── desc_0c.h │ ├── desc_0d.h │ ├── desc_0e.h │ ├── desc_0f.h │ ├── desc_10.h │ ├── desc_11.h │ ├── desc_12.h │ ├── desc_1b.h │ ├── desc_1c.h │ ├── desc_1d.h │ ├── desc_1e.h │ ├── desc_1f.h │ ├── desc_20.h │ ├── desc_21.h │ ├── desc_22.h │ ├── desc_23.h │ ├── desc_24.h │ ├── desc_25.h │ ├── desc_26.h │ ├── desc_27.h │ ├── desc_28.h │ ├── desc_2a.h │ ├── desc_2b.h │ ├── desc_2c.h │ ├── descriptors.h │ ├── descs_list.h │ ├── descs_print.h │ ├── pat.h │ ├── pat_print.h │ ├── pmt.h │ ├── pmt_print.h │ ├── psi.h │ ├── tsdt.h │ └── tsdt_print.h ├── psi_print.h └── ts.h ├── scte ├── 104.h ├── 35.h └── 35_print.h └── smpte ├── 2010.h ├── 2022_1_fec.h ├── 2022_6_hbrmt.h ├── 291.h ├── 337.h ├── 352.h └── rdd08.h /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: registry.videolan.org/videolan-base-xenial 2 | 3 | test: 4 | stage: test 5 | script: 6 | - make check 7 | tags: 8 | - docker 9 | - amd64 10 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # Contributors to biTStream 2 | # 3 | # The format of this file was inspired by the Linux kernel CREDITS file. 4 | # Authors are listed alphabetically. 5 | # 6 | # The fields are: name (N), email (E), web-address (W), CVS account login (C), 7 | # PGP key ID and fingerprint (P), description (D), and snail-mail address (S). 8 | 9 | N: Christophe Massiot 10 | E: massiot AT via DOT ecp DOT fr 11 | C: massiot 12 | D: All of the code 13 | 14 | N: Georgi Chorbadzhiyski 15 | E: gf AT unixsol DOT org 16 | D: Additional MPEG/DVB PSI and descriptors support, examples/dvb_gen_si 17 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2011 VideoLAN 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject 9 | to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | 2 | Installing biTStream 3 | ==================== 4 | 5 | Make install copies all top-level directories (except dvb-examples) in 6 | /usr/local/include/bitstream directory. 7 | 8 | Install bitstream in its default location /usr/local/include/bitstream: 9 | 10 | $> make install 11 | 12 | Install bitstream in another location, eg: /usr/include/bitstream 13 | 14 | $> make PREFIX=/usr install 15 | 16 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PREFIX ?= /usr/local 2 | INCLUDEDIR = $(PREFIX)/include 3 | LIBDIR = $(PREFIX)/lib 4 | DATADIR = $(PREFIX)/share 5 | INCLUDE = $(DESTDIR)$(INCLUDEDIR)/bitstream 6 | PKGCONFIG = $(DESTDIR)$(DATADIR)/pkgconfig 7 | VERSION = 1.5 8 | 9 | all: 10 | ln -nsf .. examples/bitstream 11 | $(MAKE) -C examples 12 | 13 | bitstream.pc: bitstream.pc.in Makefile 14 | @echo "GEN $@" 15 | @sed -e 's|@PREFIX@|$(PREFIX)|' \ 16 | -e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \ 17 | -e 's|@VERSION@|$(VERSION)|' \ 18 | $< > $@ 19 | 20 | install: bitstream.pc 21 | @echo "INSTALL $(INCLUDE)" 22 | @install -d $(INCLUDE) 23 | @install -m 644 common.h $(INCLUDE)/ 24 | @install -d $(INCLUDE)/atsc 25 | @install -m 644 atsc/*.h $(INCLUDE)/atsc 26 | @install -d $(INCLUDE)/atsc/si 27 | @install -m 644 atsc/si/*.h $(INCLUDE)/atsc/si 28 | @install -d $(INCLUDE)/dvb 29 | @install -m 644 dvb/*.h $(INCLUDE)/dvb 30 | @install -d $(INCLUDE)/dvb/si 31 | @install -m 644 dvb/si/*.h $(INCLUDE)/dvb/si 32 | @install -d $(INCLUDE)/ebu 33 | @install -m 644 ebu/*.h $(INCLUDE)/ebu 34 | @install -d $(INCLUDE)/ietf 35 | @install -m 644 ietf/* $(INCLUDE)/ietf 36 | @install -d $(INCLUDE)/ieee 37 | @install -m 644 ieee/* $(INCLUDE)/ieee 38 | @install -d $(INCLUDE)/itu 39 | @install -m 644 itu/* $(INCLUDE)/itu 40 | @install -d $(INCLUDE)/mpeg 41 | @install -m 644 mpeg/*.h $(INCLUDE)/mpeg 42 | @install -d $(INCLUDE)/mpeg/psi 43 | @install -m 644 mpeg/psi/*.h $(INCLUDE)/mpeg/psi 44 | @install -d $(INCLUDE)/scte 45 | @install -m 644 scte/*.h $(INCLUDE)/scte 46 | @install -d $(INCLUDE)/smpte 47 | @install -m 644 smpte/*.h $(INCLUDE)/smpte 48 | @echo "INSTALL $(PKGCONFIG)/bitstream.pc" 49 | @install -d $(PKGCONFIG) 50 | @install -m 644 bitstream.pc $(PKGCONFIG) 51 | 52 | uninstall: 53 | @echo "REMOVE $(INCLUDE)" 54 | @$(RM) -r $(INCLUDE) 55 | @echo "REMOVE $(PKGCONFIG)/bitstream.pc" 56 | @$(RM) $(PKGCONFIG)/bitstream.pc 57 | 58 | dist: 59 | git archive --format=tar --prefix=bitstream-$(VERSION)/ master | \ 60 | bzip2 -9 > bitstream-$(VERSION).tar.bz2 61 | 62 | clean: 63 | $(RM) bitstream bitstream.pc 64 | $(MAKE) -C examples clean 65 | 66 | # if you want to check only particular headers, 67 | # use make check HEADER_LIST="dvb/sim.h ietf/rtp.h" 68 | 69 | HEADER_LIST = $$(find * -name '*.h') 70 | 71 | FLAGS = -I. -Werror -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wformat=2 72 | 73 | compiler_c = $(CC) $(FLAGS) $(CFLAGS) -std=gnu99 74 | compiler_c++ = $(CXX) $(FLAGS) $(CXXFLAGS) 75 | compile = $(compiler_$1) -include "$$header" -c -x $1 /dev/null -o /dev/null 76 | 77 | check: 78 | @ln -nsf . bitstream 79 | @for header in $(HEADER_LIST); do \ 80 | $(if $(V),set -x;) \ 81 | $(call compile,c) || exit 1; \ 82 | $(call compile,c++) || exit 1; \ 83 | echo "PASS: $$header"; \ 84 | done 85 | 86 | .PHONY: all install uninstall dist clean check 87 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | 1.6 (TODO) 2 | ================= 3 | - Add EBU BISS-CA 4 | 5 | 1.5 (6 November 2018) 6 | ================= 7 | - Add SDES 8 | - Fix hvcc header size 9 | - Add more ATSC A/52 support 10 | - Misc descriptors fixes 11 | 12 | 1.4 (1 July 2018) 13 | ================= 14 | - Add RTCP helpers 15 | - Add support for SMPTE 352 16 | - Misc descriptors fixes 17 | 18 | 1.3 (29 Jan 2018) 19 | ================= 20 | - Add support for avcC and hvcC structures 21 | - Add support for LOAS AAC 22 | - Improve support for RTP 23 | - Use ISO 6937 as default DVB charset 24 | - Ship pkg-config file 25 | 26 | 1.2 (31 Jan 2017) 27 | ================= 28 | - Add partial support for ITU-T H.265 29 | - Add support for DVB-VBI 30 | - Add support for SCTE 104 31 | - Add support for SMPTE 2010 32 | - Add support for SMPTE RDD 08 (OP-47 subtitles) 33 | - Add support for SMPTE 291 34 | - Add support for SMPTE 337 35 | - Add support for RFC 4175 video 36 | - Add support for hbrmt 2022-6 37 | - Add support for RTP RFC 2250 38 | - Improve support of RTCP 39 | - Fix character set for Chinese DVB strings 40 | - Fix A/52 bitrate table 41 | 42 | 1.1 (5 Oct 2015) 43 | ================ 44 | - Rename fields in BAT, RST and SIT to match those of SDT 45 | - Add support for private data specifier 0x233a for descriptor 0x83 46 | - Add support for elementary streams MPEG video and audio, AAC, A/52, Opus, 47 | H264 and DVB subtitles 48 | - Add support for SMPTE 2022-1 Forward Error Correction 49 | - Add support for encoder/decoder DVB Simulcrypt EMMG interface 50 | - Add support for IEEE 802.3 Ethernet frames 51 | - Add support for IP and UDP headers 52 | - Add support for IETF RTCP 53 | - Add support for SCTE-35 Splice Information Table 54 | - Fix parsing of PSI version_number 55 | - Fix bug in EIT 56 | - Fix bug in PCR writing 57 | - Fix retrieval of PES payload offset in case of optional header 58 | - Fix incorrect marker bit in PES PTS and DTS syntax 59 | 60 | 1.0 (15 Dec 2011) 61 | ================= 62 | - Initial public release 63 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | TODO items for biTStream. The items are not ordered by importance 2 | so if you like something just do it and send a patch. 3 | 4 | - Add support (parser, generator, example) for these MPEG descriptors: 5 | - Descriptor 0x29 IPMP_descriptor (defined in ISO/IEC 13818-11, MPEG-2 IPMP) 6 | 7 | - Add support (parser, generator, example) for these DVB descriptors: 8 | - Descriptor 0x6f: application_signalling_descriptor 9 | - Descriptor 0x70: adaptation_field_data_descriptor 10 | - Descriptor 0x71: service_identifier_descriptor 11 | - Descriptor 0x72: service_availability_descriptor 12 | - Descriptor 0x73: default_authority_descriptor 13 | - Descriptor 0x74: related_content_descriptor 14 | - Descriptor 0x75: TVA_id_descriptor 15 | - Descriptor 0x76: content_identifier_descriptor 16 | - Descriptor 0x77: time_slice_fec_identifier_descriptor 17 | - Descriptor 0x78: ECM_repetition_rate_descriptor 18 | - Descriptor 0x79: S2_satellite_delivery_system_descriptor 19 | - Descriptor 0x7d: XAIT location descriptor 20 | - Descriptor 0x7e: FTA_content_management_descriptor 21 | - Descriptor 0x7f: extension descriptor 22 | - Add support for extension descriptors 23 | -------------------------------------------------------------------------------- /atsc/si.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * si.h: ATSC Service Information 3 | ***************************************************************************** 4 | * Copyright (C) 2019 OpenHeadend 5 | * 6 | * Authors: Arnaud de Turckheim 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_ATSC_SI_H__ 29 | #define __BITSTREAM_ATSC_SI_H__ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /atsc/si/descs_list.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * descs_list.h: All supported ATSC descriptors 3 | ***************************************************************************** 4 | * Copyright (C) 2019 OpenHeadend 5 | * 6 | * Authors: Arnaud de Turckheim 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_ATSC_DESCS_LIST_H__ 29 | #define __BITSTREAM_ATSC_DESCS_LIST_H__ 30 | 31 | #include 32 | #include 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /bitstream.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@PREFIX@ 2 | includedir=@INCLUDEDIR@ 3 | 4 | Name: bitstream 5 | Description: Binary structures for MPEG, DVB, IETF, SMPTE, IEEE, SCTE, etc. 6 | Version: @VERSION@ 7 | Cflags: -I${includedir} 8 | -------------------------------------------------------------------------------- /common.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * common.h: (Rare) common declarations for all submodules 3 | ***************************************************************************** 4 | * Copyright (C) 2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_COMMON_H__ 29 | #define __BITSTREAM_COMMON_H__ 30 | 31 | #include /* uint8_t, uint16_t, etc... */ 32 | #include /* bool */ 33 | #include /* memset, memcpy */ 34 | 35 | #define BITSTREAM_VERSION_MAJOR 1 36 | #define BITSTREAM_VERSION_MINOR 0 37 | #define BITSTREAM_VERSION_REVISION 0 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | typedef enum print_type_t { 45 | PRINT_TEXT, 46 | PRINT_XML 47 | } print_type_t; 48 | 49 | typedef void (*f_print)(void *, const char *, ...) __attribute__ ((format(printf, 2, 3))); 50 | typedef char * (*f_iconv)(void *, const char *, char *, size_t); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /dvb/si.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * si.h: ETSI EN 300 468 Service Information 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 32 | */ 33 | 34 | #ifndef __BITSTREAM_DVB_SI_H__ 35 | #define __BITSTREAM_DVB_SI_H__ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /dvb/si/desc_41.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_41.h: ETSI EN 300 468 Descriptor 0x41: Service list descriptor 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * Georgi Chorbadzhiyski 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining 10 | * a copy of this software and associated documentation files (the 11 | * "Software"), to deal in the Software without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject 15 | * to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 24 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | *****************************************************************************/ 28 | 29 | /* 30 | * Normative references: 31 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 32 | */ 33 | 34 | #ifndef __BITSTREAM_DVB_DESC_41_H__ 35 | #define __BITSTREAM_DVB_DESC_41_H__ 36 | 37 | #include 38 | #include 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /***************************************************************************** 46 | * Descriptor 0x41: Service list descriptor 47 | *****************************************************************************/ 48 | #define DESC41_HEADER_SIZE DESC_HEADER_SIZE 49 | #define DESC41_SERVICE_SIZE 3 50 | 51 | static inline void desc41_init(uint8_t *p_desc) 52 | { 53 | desc_set_tag(p_desc, 0x41); 54 | } 55 | 56 | static inline uint8_t *desc41_get_service(uint8_t *p_desc, uint8_t n) 57 | { 58 | uint8_t *p_desc_n = p_desc + DESC41_HEADER_SIZE + n * DESC41_SERVICE_SIZE; 59 | if (p_desc_n + DESC41_SERVICE_SIZE - p_desc 60 | > desc_get_length(p_desc) + DESC41_HEADER_SIZE) 61 | return NULL; 62 | return p_desc_n; 63 | } 64 | 65 | static inline uint16_t desc41n_get_sid(const uint8_t *p_desc_n) 66 | { 67 | return (p_desc_n[0] << 8) | p_desc_n[1]; 68 | } 69 | 70 | static inline void desc41n_set_sid(uint8_t *p_desc_n, uint16_t i_sid) 71 | { 72 | p_desc_n[0] = i_sid >> 8; 73 | p_desc_n[1] = i_sid & 0xff; 74 | } 75 | 76 | static inline uint8_t desc41n_get_type(const uint8_t *p_desc_n) 77 | { 78 | return p_desc_n[2]; 79 | } 80 | 81 | static inline void desc41n_set_type(uint8_t *p_desc_n, uint8_t i_type) 82 | { 83 | p_desc_n[2] = i_type; 84 | } 85 | 86 | static inline bool desc41_validate(const uint8_t *p_desc) 87 | { 88 | return !(desc_get_length(p_desc) % DESC41_SERVICE_SIZE); 89 | } 90 | 91 | static inline void desc41_print(uint8_t *p_desc, f_print pf_print, 92 | void *opaque, print_type_t i_print_type) 93 | { 94 | uint8_t j = 0; 95 | uint8_t *p_desc_n; 96 | 97 | while ((p_desc_n = desc41_get_service(p_desc, j)) != NULL) { 98 | j++; 99 | switch (i_print_type) { 100 | case PRINT_XML: 101 | pf_print(opaque, 102 | "", 103 | desc41n_get_sid(p_desc_n), desc41n_get_type(p_desc_n)); 104 | break; 105 | default: 106 | pf_print(opaque, 107 | " - desc 41 service_list sid=%hu type=0x%02x", 108 | desc41n_get_sid(p_desc_n), desc41n_get_type(p_desc_n)); 109 | } 110 | } 111 | } 112 | 113 | #ifdef __cplusplus 114 | } 115 | #endif 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /dvb/si/desc_42.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_42.h: ETSI EN 300 468 Descriptor 0x42: Stuffing descriptor 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_DVB_DESC_42_H__ 34 | #define __BITSTREAM_DVB_DESC_42_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x42: Service list descriptor 46 | *****************************************************************************/ 47 | #define DESC42_HEADER_SIZE DESC_HEADER_SIZE 48 | 49 | static inline void desc42_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x42); 52 | } 53 | 54 | static inline bool desc42_validate(const uint8_t *p_desc) 55 | { 56 | (void) p_desc; 57 | 58 | return true; 59 | } 60 | 61 | static inline void desc42_print(uint8_t *p_desc, f_print pf_print, 62 | void *opaque, print_type_t i_print_type) 63 | { 64 | switch (i_print_type) { 65 | case PRINT_XML: 66 | pf_print(opaque, "", desc_get_length(p_desc)); 67 | break; 68 | default: 69 | pf_print(opaque, " - desc 42 stuffing length=%u", desc_get_length(p_desc)); 70 | } 71 | } 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /dvb/si/desc_47.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_47.h: ETSI EN 300 468 Descriptor 0x47: Bouquet name descriptor 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * Georgi Chorbadzhiyski 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining 10 | * a copy of this software and associated documentation files (the 11 | * "Software"), to deal in the Software without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject 15 | * to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 24 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | *****************************************************************************/ 28 | 29 | /* 30 | * Normative references: 31 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 32 | */ 33 | 34 | #ifndef __BITSTREAM_DVB_DESC_47_H__ 35 | #define __BITSTREAM_DVB_DESC_47_H__ 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | #ifdef __cplusplus 42 | extern "C" 43 | { 44 | #endif 45 | 46 | /***************************************************************************** 47 | * Descriptor 0x47: Bouquet name descriptor 48 | *****************************************************************************/ 49 | #define DESC47_HEADER_SIZE DESC_HEADER_SIZE 50 | 51 | static inline void desc47_init(uint8_t *p_desc) 52 | { 53 | desc_set_tag(p_desc, 0x47); 54 | } 55 | 56 | #define desc47_set_bouquetname desc40_set_networkname 57 | #define desc47_get_bouquetname desc40_get_networkname 58 | #define desc47_validate desc40_validate 59 | #define desc47_print desc40_print 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /dvb/si/desc_4c.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_4c.h: ETSI EN 300 468 Descriptor 0x4c: (Time shifted service descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_DVB_DESC_4C_H__ 34 | #define __BITSTREAM_DVB_DESC_4C_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x4c: Time shifted service descriptor 46 | *****************************************************************************/ 47 | #define DESC4C_HEADER_SIZE (DESC_HEADER_SIZE + 2) 48 | 49 | static inline void desc4c_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x4c); 52 | desc_set_length(p_desc, DESC4C_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline uint16_t desc4c_get_reference_sid(const uint8_t *p_desc) 56 | { 57 | return (p_desc[2] << 8) | p_desc[3]; 58 | } 59 | 60 | static inline void desc4c_set_reference_sid(uint8_t *p_desc, uint16_t i_reference_sid) 61 | { 62 | p_desc[2] = (i_reference_sid >> 8) & 0xff; 63 | p_desc[3] = i_reference_sid & 0xff; 64 | } 65 | 66 | static inline bool desc4c_validate(const uint8_t *p_desc) 67 | { 68 | return desc_get_length(p_desc) >= DESC4C_HEADER_SIZE - DESC_HEADER_SIZE; 69 | } 70 | 71 | static inline void desc4c_print(const uint8_t *p_desc, f_print pf_print, 72 | void *opaque, print_type_t i_print_type) 73 | { 74 | switch (i_print_type) { 75 | case PRINT_XML: 76 | pf_print(opaque, "", 77 | desc4c_get_reference_sid(p_desc)); 78 | break; 79 | default: 80 | pf_print(opaque, " - desc 4c time_shifted_service reference_sid=%u", 81 | desc4c_get_reference_sid(p_desc)); 82 | } 83 | } 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /dvb/si/desc_4f.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_4f.h: ETSI EN 300 468 Descriptor 0x4f: (Time shifted event descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_DVB_DESC_4F_H__ 34 | #define __BITSTREAM_DVB_DESC_4F_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x4f: Time shifted event descriptor 46 | *****************************************************************************/ 47 | #define DESC4F_HEADER_SIZE (DESC_HEADER_SIZE + 4) 48 | 49 | static inline void desc4f_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x4f); 52 | desc_set_length(p_desc, DESC4F_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline uint16_t desc4f_get_reference_sid(const uint8_t *p_desc) 56 | { 57 | return (p_desc[2] << 8) | p_desc[3]; 58 | } 59 | 60 | static inline void desc4f_set_reference_sid(uint8_t *p_desc, uint16_t i_reference_sid) 61 | { 62 | p_desc[2] = (i_reference_sid >> 8) & 0xff; 63 | p_desc[3] = i_reference_sid & 0xff; 64 | } 65 | 66 | static inline uint16_t desc4f_get_reference_event_id(const uint8_t *p_desc) 67 | { 68 | return (p_desc[4] << 8) | p_desc[5]; 69 | } 70 | 71 | static inline void desc4f_set_reference_event_id(uint8_t *p_desc, uint16_t i_reference_event_id) 72 | { 73 | p_desc[4] = (i_reference_event_id >> 8) & 0xff; 74 | p_desc[5] = i_reference_event_id & 0xff; 75 | } 76 | 77 | static inline bool desc4f_validate(const uint8_t *p_desc) 78 | { 79 | return desc_get_length(p_desc) >= DESC4F_HEADER_SIZE - DESC_HEADER_SIZE; 80 | } 81 | 82 | static inline void desc4f_print(const uint8_t *p_desc, f_print pf_print, 83 | void *opaque, print_type_t i_print_type) 84 | { 85 | switch (i_print_type) { 86 | case PRINT_XML: 87 | pf_print(opaque, "", 88 | desc4f_get_reference_sid(p_desc), 89 | desc4f_get_reference_event_id(p_desc) 90 | ); 91 | break; 92 | default: 93 | pf_print(opaque, " - desc 4f time_shifted_service reference_sid=%u reference_event_id=%u", 94 | desc4f_get_reference_sid(p_desc), 95 | desc4f_get_reference_event_id(p_desc) 96 | ); 97 | } 98 | } 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /dvb/si/desc_52.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_52.h: ETSI EN 300 468 Descriptor 0x52: Stream identifier descriptor 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_DVB_DESC_52_H__ 34 | #define __BITSTREAM_DVB_DESC_52_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x52: Stream identifier descriptor 46 | *****************************************************************************/ 47 | #define DESC52_HEADER_SIZE (DESC_HEADER_SIZE + 1) 48 | 49 | static inline void desc52_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x52); 52 | desc_set_length(p_desc, DESC52_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline void desc52_set_component_tag(uint8_t *p_desc, uint8_t component_tag) 56 | { 57 | p_desc[2] = component_tag; 58 | } 59 | 60 | static inline uint8_t desc52_get_component_tag(const uint8_t *p_desc) 61 | { 62 | return p_desc[2]; 63 | } 64 | 65 | static inline bool desc52_validate(const uint8_t *p_desc) 66 | { 67 | return desc_get_length(p_desc) >= DESC52_HEADER_SIZE - DESC_HEADER_SIZE; 68 | } 69 | 70 | static inline void desc52_print(const uint8_t *p_desc, f_print pf_print, 71 | void *opaque, print_type_t i_print_type) 72 | { 73 | switch (i_print_type) { 74 | case PRINT_XML: 75 | pf_print(opaque, "", 76 | desc52_get_component_tag(p_desc)); 77 | break; 78 | default: 79 | pf_print(opaque, " - desc 52 stream_identifier component_tag=%u", 80 | desc52_get_component_tag(p_desc)); 81 | } 82 | } 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /dvb/si/desc_53.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_53.h: ETSI EN 300 468 Descriptor 0x53: CA identifier descriptor 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * Georgi Chorbadzhiyski 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining 10 | * a copy of this software and associated documentation files (the 11 | * "Software"), to deal in the Software without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject 15 | * to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 24 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | *****************************************************************************/ 28 | 29 | /* 30 | * Normative references: 31 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 32 | */ 33 | 34 | #ifndef __BITSTREAM_DVB_DESC_53_H__ 35 | #define __BITSTREAM_DVB_DESC_53_H__ 36 | 37 | #include 38 | #include 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /***************************************************************************** 46 | * Descriptor 0x53: CA identifier descriptor 47 | *****************************************************************************/ 48 | #define DESC53_HEADER_SIZE DESC_HEADER_SIZE 49 | #define DESC53_CA_SIZE 2 50 | 51 | static inline void desc53_init(uint8_t *p_desc) 52 | { 53 | desc_set_tag(p_desc, 0x53); 54 | } 55 | 56 | static inline void desc53n_set_ca_sysid(uint8_t *p_desc_n, uint16_t i_ca_sysid) 57 | { 58 | p_desc_n[0] = i_ca_sysid >> 8; 59 | p_desc_n[1] = i_ca_sysid & 0xff; 60 | } 61 | 62 | static inline uint16_t desc53n_get_ca_sysid(const uint8_t *p_desc_n) 63 | { 64 | return (p_desc_n[0] << 8) | p_desc_n[1]; 65 | } 66 | 67 | static inline uint8_t *desc53_get_ca(uint8_t *p_desc, uint8_t n) 68 | { 69 | uint8_t *p_desc_n = p_desc + DESC53_HEADER_SIZE + n * DESC53_CA_SIZE; 70 | if (p_desc_n + DESC53_CA_SIZE - p_desc 71 | > desc_get_length(p_desc) + DESC53_HEADER_SIZE) 72 | return NULL; 73 | return p_desc_n; 74 | } 75 | 76 | static inline bool desc53_validate(const uint8_t *p_desc) 77 | { 78 | return (desc_get_length(p_desc) % DESC53_CA_SIZE) == 0; 79 | } 80 | 81 | static inline void desc53_print(uint8_t *p_desc, f_print pf_print, 82 | void *opaque, print_type_t i_print_type) 83 | { 84 | uint8_t j = 0; 85 | uint8_t *p_desc_n; 86 | 87 | while ((p_desc_n = desc53_get_ca(p_desc, j)) != NULL) { 88 | j++; 89 | switch (i_print_type) { 90 | case PRINT_XML: 91 | pf_print(opaque, "", 92 | desc53n_get_ca_sysid(p_desc_n)); 93 | break; 94 | default: 95 | pf_print(opaque," - desc 53 ca_identifier ca_sysid=0x%04x", 96 | desc53n_get_ca_sysid(p_desc_n)); 97 | } 98 | } 99 | } 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /dvb/si/desc_56.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_56.h: ETSI EN 300 468 Descriptor 0x56: Teletext descriptor 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_DVB_DESC_56_H__ 34 | #define __BITSTREAM_DVB_DESC_56_H__ 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /***************************************************************************** 46 | * Descriptor 0x56: Teletext descriptor 47 | *****************************************************************************/ 48 | #define DESC56_HEADER_SIZE DESC46_HEADER_SIZE 49 | #define DESC56_LANGUAGE_SIZE DESC46_LANGUAGE_SIZE 50 | 51 | #define DESC56_TELETEXTTYPE_INITIAL DESC46_TELETEXTTYPE_INITIAL 52 | #define DESC56_TELETEXTTYPE_SUBTITLE DESC46_TELETEXTTYPE_SUBTITLE 53 | #define DESC56_TELETEXTTYPE_INFORMATION DESC46_TELETEXTTYPE_INFORMATION 54 | #define DESC56_TELETEXTTYPE_SCHEDULE DESC46_TELETEXTTYPE_SCHEDULE 55 | #define DESC56_TELETEXTTYPE_SUBTITLE_H DESC46_TELETEXTTYPE_SUBTITLE_H 56 | 57 | static inline void desc56_init(uint8_t *p_desc) 58 | { 59 | desc_set_tag(p_desc, 0x56); 60 | } 61 | 62 | #define desc56_get_language desc46_get_language 63 | #define desc56n_set_code desc46n_set_code 64 | #define desc56n_get_code desc46n_get_code 65 | #define desc56n_set_teletexttype desc46n_set_teletexttype 66 | #define desc56n_get_teletexttype desc46n_get_teletexttype 67 | #define desc56n_set_teletextmagazine desc46n_set_teletextmagazine 68 | #define desc56n_get_teletextmagazine desc46n_get_teletextmagazine 69 | #define desc56n_set_teletextpage desc46n_set_teletextpage 70 | #define desc56n_get_teletextpage desc46n_get_teletextpage 71 | #define desc56_validate desc46_validate 72 | #define desc56_print desc46_print 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /dvb/si/desc_5c.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_5c.h: ETSI EN 300 468 Descriptor 0x5c: Multilingual bouquet name 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * Georgi Chorbadzhiyski 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining 10 | * a copy of this software and associated documentation files (the 11 | * "Software"), to deal in the Software without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject 15 | * to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 24 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | *****************************************************************************/ 28 | 29 | /* 30 | * Normative references: 31 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 32 | */ 33 | 34 | #ifndef __BITSTREAM_DVB_DESC_5C_H__ 35 | #define __BITSTREAM_DVB_DESC_5C_H__ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #ifdef __cplusplus 44 | extern "C" 45 | { 46 | #endif 47 | 48 | /***************************************************************************** 49 | * Descriptor 0x5c: Multilingual bouquet name 50 | *****************************************************************************/ 51 | #define DESC5C_HEADER_SIZE DESC_HEADER_SIZE 52 | #define DESC5C_DATA_SIZE 4 53 | 54 | static inline void desc5c_init(uint8_t *p_desc) 55 | { 56 | desc_set_tag(p_desc, 0x5c); 57 | } 58 | 59 | #define desc5cn_set_code desc0an_set_code 60 | #define desc5cn_get_code desc0an_get_code 61 | #define desc5cn_get bouquetname_length desc5bn_get_networkname_length 62 | #define desc5cn_get_bouquetname desc5bn_get_networkname 63 | #define desc5cn_set_bouquetname desc5bn_set_networkname 64 | #define desc5c_get_data desc5b_get_data 65 | #define desc5c_validate desc5b_validate 66 | #define desc5c_print desc5b_print 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /dvb/si/desc_5f.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_5f.h: ETSI EN 300 468 Descriptor 0x5f: Private data specifier 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * Georgi Chorbadzhiyski 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining 10 | * a copy of this software and associated documentation files (the 11 | * "Software"), to deal in the Software without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject 15 | * to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 24 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | *****************************************************************************/ 28 | 29 | /* 30 | * Normative references: 31 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 32 | */ 33 | 34 | #ifndef __BITSTREAM_DVB_DESC_5F_H__ 35 | #define __BITSTREAM_DVB_DESC_5F_H__ 36 | 37 | #include 38 | #include 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /***************************************************************************** 46 | * Descriptor 0x5f: Private data specifier descriptor 47 | *****************************************************************************/ 48 | #define DESC5F_HEADER_SIZE (DESC_HEADER_SIZE + 4) 49 | 50 | static inline void desc5f_init(uint8_t *p_desc) 51 | { 52 | desc_set_tag(p_desc, 0x5f); 53 | desc_set_length(p_desc, DESC5F_HEADER_SIZE - DESC_HEADER_SIZE); 54 | } 55 | 56 | static inline uint32_t desc5f_get_specifier(const uint8_t *p_desc) 57 | { 58 | return (p_desc[2] << 24) | (p_desc[3] << 16) | 59 | (p_desc[4] << 8) | p_desc[5]; 60 | } 61 | 62 | static inline void desc5f_set_specifier(uint8_t *p_desc, uint32_t i_specifier) 63 | { 64 | p_desc[2] = (i_specifier >> 24) & 0xff; 65 | p_desc[3] = (i_specifier >> 16) & 0xff; 66 | p_desc[4] = (i_specifier >> 8) & 0xff; 67 | p_desc[5] = i_specifier & 0xff; 68 | } 69 | 70 | static inline bool desc5f_validate(const uint8_t *p_desc) 71 | { 72 | return desc_get_length(p_desc) >= DESC5F_HEADER_SIZE - DESC_HEADER_SIZE; 73 | } 74 | 75 | static inline void desc5f_print(const uint8_t *p_desc, f_print pf_print, 76 | void *opaque, print_type_t i_print_type) 77 | { 78 | switch (i_print_type) { 79 | case PRINT_XML: 80 | pf_print(opaque, "", 81 | desc5f_get_specifier(p_desc)); 82 | break; 83 | default: 84 | pf_print(opaque, " - desc 5f private_data specifier=0x%08x", 85 | desc5f_get_specifier(p_desc)); 86 | } 87 | } 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /dvb/si/desc_61.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_61.h: ETSI EN 300 468 Descriptor 0x61: Short smoothing buffer 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_DVB_DESC_61_H__ 34 | #define __BITSTREAM_DVB_DESC_61_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x61: Short smoothing buffer descriptor 46 | *****************************************************************************/ 47 | #define DESC61_HEADER_SIZE (DESC_HEADER_SIZE + 1) 48 | 49 | static inline void desc61_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x61); 52 | desc_set_length(p_desc, DESC61_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline uint8_t desc61_get_sb_size(const uint8_t *p_desc) 56 | { 57 | return p_desc[2] >> 6; 58 | } 59 | 60 | static inline void desc61_set_sb_size(uint8_t *p_desc, uint8_t i_sb_size) 61 | { 62 | p_desc[2] = (p_desc[2] & 0x3f) | (i_sb_size << 6); 63 | } 64 | 65 | static inline uint8_t desc61_get_sb_leak_rate(const uint8_t *p_desc) 66 | { 67 | return p_desc[2] & 0x3f; 68 | } 69 | 70 | static inline void desc61_set_sb_leak_rate(uint8_t *p_desc, uint8_t i_sb_leak_rate) 71 | { 72 | p_desc[2] = (p_desc[2] & 0xc0) | (i_sb_leak_rate & 0x3f); 73 | } 74 | 75 | static inline bool desc61_validate(const uint8_t *p_desc) 76 | { 77 | return desc_get_length(p_desc) >= DESC61_HEADER_SIZE - DESC_HEADER_SIZE; 78 | } 79 | 80 | static inline void desc61_print(const uint8_t *p_desc, f_print pf_print, 81 | void *opaque, print_type_t i_print_type) 82 | { 83 | switch (i_print_type) { 84 | case PRINT_XML: 85 | pf_print(opaque, "", 86 | desc61_get_sb_size(p_desc), 87 | desc61_get_sb_leak_rate(p_desc) 88 | ); 89 | break; 90 | default: 91 | pf_print(opaque, " - desc 61 short_smoothing_buffer sb_size=%u sb_leak_rate=%u", 92 | desc61_get_sb_size(p_desc), 93 | desc61_get_sb_leak_rate(p_desc) 94 | ); 95 | } 96 | } 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /dvb/si/desc_68.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_68.h: ETSI EN 300 468 Descriptor 0x68: DSNG descriptor 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_DVB_DESC_68_H__ 34 | #define __BITSTREAM_DVB_DESC_68_H__ 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /***************************************************************************** 46 | * Descriptor 0x68: DSNG descriptor 47 | *****************************************************************************/ 48 | #define DESC68_HEADER_SIZE DESC_HEADER_SIZE 49 | 50 | static inline void desc68_init(uint8_t *p_desc) 51 | { 52 | desc_set_tag(p_desc, 0x68); 53 | desc_set_length(p_desc, 0); 54 | } 55 | 56 | #define desc68_get_bytes_length desc67_get_bytes_length 57 | #define desc68_get_bytes desc67_get_bytes 58 | #define desc68_set_bytes desc67_set_bytes 59 | #define desc68_validate desc67_validate 60 | #define desc68_print desc67_print 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /dvb/si/desc_88p28.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_88p28.h: ETSI EN 300 468 Descriptor 0x88: HD simulcast logical channel 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 31 | * - IEC/CENELEC 62 216 32 | */ 33 | 34 | #ifndef __BITSTREAM_DVB_DESC_88P28_H__ 35 | #define __BITSTREAM_DVB_DESC_88P28_H__ 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | #ifdef __cplusplus 42 | extern "C" 43 | { 44 | #endif 45 | 46 | /***************************************************************************** 47 | * Descriptor 0x88: HD simulcast logical channel descriptor (IEC/CENELEC 62 216) 48 | * Only valid if a private data specifier descriptor 28 is present before. 49 | *****************************************************************************/ 50 | #define DESC88P28_HEADER_SIZE DESC83P28_HEADER_SIZE 51 | #define DESC88P28_SERVICE_SIZE DESC83P28_SERVICE_SIZE 52 | 53 | static inline void desc88p28_init(uint8_t *p_desc) 54 | { 55 | desc_set_tag(p_desc, 0x88); 56 | } 57 | 58 | #define desc88p28_get_service desc83p28_get_service 59 | #define desc88p28_get_sid desc83p28_get_sid 60 | #define desc88p28_get_visible desc83p28_get_visible 61 | #define desc88p28_get_lcn desc83p28_get_lcn 62 | #define desc88p28_validate desc83p28_validate 63 | #define desc88p28_print desc83p28_print 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /dvb/si/descs_list.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * descs_list.h: All supported ETSI EN 300 468 descriptors 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_DVB_DESCS_LIST_H__ 29 | #define __BITSTREAM_DVB_DESCS_LIST_H__ 30 | 31 | /* 32 | * 1. Keep the list ordered. 33 | * 2. When you are adding new descriptor here, make sure you also add 34 | * the needed code in bitstream/mpeg/psi/descs_print.h 35 | */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | #include 73 | #include 74 | #include 75 | #include 76 | #include 77 | #include 78 | #include 79 | #include 80 | #include 81 | #include 82 | #include 83 | #include 84 | #include 85 | #include 86 | #include 87 | #include 88 | #include 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /dvb/si/dit.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dit.h: ETSI EN 300 468 Discontinuity Information Table (DIT) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_DVB_DIT_H__ 34 | #define __BITSTREAM_DVB_DIT_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Discontinuity Information Table 46 | *****************************************************************************/ 47 | #define DIT_PID 0x1E 48 | #define DIT_TABLE_ID 0x7E 49 | #define DIT_HEADER_SIZE PSI_HEADER_SIZE 50 | 51 | static inline void dit_init(uint8_t *p_dit) 52 | { 53 | psi_init(p_dit, false); 54 | psi_set_tableid(p_dit, DIT_TABLE_ID); 55 | psi_set_length(p_dit, 1); 56 | } 57 | 58 | static inline void dit_set_transition_flag(uint8_t *p_dit, bool b_transition_flag) 59 | { 60 | p_dit[3] = b_transition_flag ? 0xff : 0x7f; 61 | } 62 | 63 | static inline bool dit_get_transition_flag(const uint8_t *p_dit) 64 | { 65 | return p_dit[3] >> 7; 66 | } 67 | 68 | static inline bool dit_validate(const uint8_t *p_dit) 69 | { 70 | uint16_t i_section_size = psi_get_length(p_dit) + PSI_HEADER_SIZE; 71 | uint8_t i_tid = psi_get_tableid(p_dit); 72 | 73 | if (psi_get_syntax(p_dit) || i_tid != DIT_TABLE_ID 74 | || i_section_size < DIT_HEADER_SIZE) 75 | return false; 76 | 77 | return true; 78 | } 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /dvb/si/dit_print.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dit_print.h: ETSI EN 300 468 Discontinuity Information Table (DIT) (printing) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_DVB_DIT_PRINT_H__ 29 | #define __BITSTREAM_DVB_DIT_PRINT_H__ 30 | 31 | #include 32 | #include 33 | 34 | #ifdef __cplusplus 35 | extern "C" 36 | { 37 | #endif 38 | 39 | /***************************************************************************** 40 | * Discontinuity Information Table 41 | *****************************************************************************/ 42 | static inline void dit_print(uint8_t *p_dit, 43 | f_print pf_print, void *print_opaque, 44 | f_iconv pf_iconv, void *iconv_opaque, 45 | print_type_t i_print_type) 46 | { 47 | (void) pf_iconv; 48 | (void) iconv_opaque; 49 | 50 | switch (i_print_type) { 51 | case PRINT_XML: 52 | pf_print(print_opaque, "", 53 | dit_get_transition_flag(p_dit)); 54 | break; 55 | default: 56 | pf_print(print_opaque, "new DIT transition_flag=%u", 57 | dit_get_transition_flag(p_dit)); 58 | pf_print(print_opaque, "end DIT"); 59 | } 60 | } 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /dvb/si/numbers.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * numbers.h: BCD functions 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_DVB_BCD_H__ 29 | #define __BITSTREAM_DVB_BCD_H__ 30 | 31 | #include /* uint8_t, uint16_t, etc... */ 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif 37 | 38 | /***************************************************************************** 39 | * DVB numbers 40 | *****************************************************************************/ 41 | static inline unsigned int dvb_bcd_get(const uint8_t *p_bcd, uint8_t i_width) 42 | { 43 | unsigned int i_result = 0; 44 | 45 | while (i_width >= 8) { 46 | i_result *= 10; 47 | i_result += (*p_bcd) >> 4; 48 | i_result *= 10; 49 | i_result += (*p_bcd) & 0xf; 50 | i_width -= 8; 51 | p_bcd++; 52 | } 53 | 54 | if (i_width == 4) { 55 | i_result *= 10; 56 | i_result += (*p_bcd) >> 4; 57 | } 58 | 59 | return i_result; 60 | } 61 | 62 | static inline void dvb_bcd_set(uint8_t *p_bcd, unsigned int i_int, 63 | uint8_t i_width) 64 | { 65 | /* calculate 10^(i_width/4-1) */ 66 | unsigned int i_factor = 1, i_exp = i_width / 4 - 1, i_base = 10; 67 | while (i_exp) 68 | { 69 | if (i_exp & 1) 70 | i_factor *= i_base; 71 | i_exp >>= 1; 72 | i_base *= i_base; 73 | } 74 | 75 | while (i_factor >= 10) { 76 | *p_bcd = (i_int / i_factor) << 4; 77 | i_int %= i_factor; 78 | i_factor /= 10; 79 | *p_bcd |= (i_int / i_factor); 80 | i_int %= i_factor; 81 | i_factor /= 10; 82 | p_bcd++; 83 | } 84 | 85 | if (i_factor == 1) { 86 | *p_bcd &= 0xf; 87 | *p_bcd |= i_int << 4; 88 | } 89 | } 90 | 91 | static inline uint8_t dvb_bcd_set8(unsigned int i_int) 92 | { 93 | uint8_t i_result; 94 | dvb_bcd_set(&i_result, i_int, 8); 95 | return i_result; 96 | } 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /dvb/si/rst_print.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * rst_print.h: ETSI EN 300 468 Running Status Table (RST) (printing) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_DVB_RST_PRINT_H__ 29 | #define __BITSTREAM_DVB_RST_PRINT_H__ 30 | 31 | #include 32 | #include 33 | 34 | #ifdef __cplusplus 35 | extern "C" 36 | { 37 | #endif 38 | 39 | /***************************************************************************** 40 | * Running Status Table 41 | *****************************************************************************/ 42 | static inline void rst_print(uint8_t *p_rst, 43 | f_print pf_print, void *print_opaque, 44 | f_iconv pf_iconv, void *iconv_opaque, 45 | print_type_t i_print_type) 46 | { 47 | (void) pf_iconv; 48 | (void) iconv_opaque; 49 | 50 | uint8_t j = 0; 51 | uint8_t *p_rst_n; 52 | 53 | switch (i_print_type) { 54 | case PRINT_XML: 55 | pf_print(print_opaque, ""); 56 | break; 57 | default: 58 | pf_print(print_opaque, "new RST"); 59 | } 60 | 61 | while ((p_rst_n = rst_get_status(p_rst, j++)) != NULL) { 62 | switch (i_print_type) { 63 | case PRINT_XML: 64 | pf_print(print_opaque, 65 | "", 67 | rstn_get_tsid(p_rst_n), 68 | rstn_get_onid(p_rst_n), 69 | rstn_get_service_id(p_rst_n), 70 | rstn_get_event_id(p_rst_n), 71 | rstn_get_running(p_rst_n) 72 | ); 73 | break; 74 | default: 75 | pf_print(print_opaque, 76 | " * status tsid=\"%hu\" onid=\"%hu\" service_id=\"%hu\"" 77 | " event_id=\"%hu\" running=\"%hu\"", 78 | rstn_get_tsid(p_rst_n), 79 | rstn_get_onid(p_rst_n), 80 | rstn_get_service_id(p_rst_n), 81 | rstn_get_event_id(p_rst_n), 82 | rstn_get_running(p_rst_n) 83 | ); 84 | } 85 | } 86 | 87 | switch (i_print_type) { 88 | case PRINT_XML: 89 | pf_print(print_opaque, ""); 90 | break; 91 | default: 92 | pf_print(print_opaque, "end RST"); 93 | } 94 | } 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /dvb/si/sit_print.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * sit_print.h: ISO/IEC 13818-1 Selection Information Table (printing) 3 | ***************************************************************************** 4 | * Copyright (C) 2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * Georgi Chorbadzhiyski 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining 10 | * a copy of this software and associated documentation files (the 11 | * "Software"), to deal in the Software without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject 15 | * to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 24 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | *****************************************************************************/ 28 | 29 | #ifndef __BITSTREAM_DVB_SIT_PRINT_H__ 30 | #define __BITSTREAM_DVB_SIT_PRINT_H__ 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" 39 | { 40 | #endif 41 | 42 | static inline void sit_print(uint8_t *p_sit, 43 | f_print pf_print, void *print_opaque, 44 | f_iconv pf_iconv, void *iconv_opaque, 45 | print_type_t i_print_type) 46 | { 47 | uint8_t *p_service; 48 | uint8_t j = 0; 49 | 50 | switch (i_print_type) { 51 | case PRINT_XML: 52 | pf_print(print_opaque, "", 53 | psi_get_version(p_sit), 54 | !psi_get_current(p_sit) ? 0 : 1); 55 | break; 56 | default: 57 | pf_print(print_opaque, "new SIT version=%hhu%s", 58 | psi_get_version(p_sit), 59 | !psi_get_current(p_sit) ? " (next)" : ""); 60 | } 61 | 62 | descs_print(sit_get_descs(p_sit), pf_print, print_opaque, 63 | pf_iconv, iconv_opaque, i_print_type); 64 | 65 | while ((p_service = sit_get_service(p_sit, j)) != NULL) { 66 | j++; 67 | switch (i_print_type) { 68 | case PRINT_XML: 69 | pf_print(print_opaque, "", 70 | sitn_get_sid(p_service), 71 | sitn_get_running(p_service) 72 | ); 73 | break; 74 | default: 75 | pf_print(print_opaque, " * SERVICE sid=%hu running=%u", 76 | sitn_get_sid(p_service), 77 | sitn_get_running(p_service) 78 | ); 79 | } 80 | 81 | descs_print(sitn_get_descs(p_service), pf_print, print_opaque, 82 | pf_iconv, iconv_opaque, i_print_type); 83 | 84 | switch (i_print_type) { 85 | case PRINT_XML: 86 | pf_print(print_opaque, ""); 87 | break; 88 | default: 89 | break; 90 | } 91 | } 92 | 93 | switch (i_print_type) { 94 | case PRINT_XML: 95 | pf_print(print_opaque, ""); 96 | break; 97 | default: 98 | pf_print(print_opaque, "end SIT"); 99 | } 100 | } 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /dvb/si/st.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * st.h: ETSI EN 300 468 Stuffing Table (ST) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_DVB_ST_H__ 34 | #define __BITSTREAM_DVB_ST_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Stuffing Table 46 | *****************************************************************************/ 47 | #define ST_TABLE_ID 0x72 48 | #define ST_HEADER_SIZE PSI_HEADER_SIZE 49 | 50 | static inline void st_init(uint8_t *p_st) 51 | { 52 | psi_init(p_st, false); 53 | psi_set_tableid(p_st, ST_TABLE_ID); 54 | psi_set_length(p_st, 0); 55 | } 56 | 57 | static inline bool st_validate(const uint8_t *p_st) 58 | { 59 | if (psi_get_tableid(p_st) != ST_TABLE_ID) 60 | return false; 61 | 62 | return true; 63 | } 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /dvb/si/tdt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * tdt.h: ETSI EN 300 468 Time and Date Table (TDT) 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_DVB_TDT_H__ 34 | #define __BITSTREAM_DVB_TDT_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Time and Date Table 46 | *****************************************************************************/ 47 | #define TDT_PID 0x14 48 | #define TDT_TABLE_ID 0x70 49 | #define TDT_HEADER_SIZE (PSI_HEADER_SIZE + 5) 50 | 51 | static inline void tdt_init(uint8_t *p_tdt) 52 | { 53 | psi_init(p_tdt, false); 54 | psi_set_tableid(p_tdt, TDT_TABLE_ID); 55 | psi_set_length(p_tdt, TDT_HEADER_SIZE - PSI_HEADER_SIZE); 56 | } 57 | 58 | static inline void tdt_set_utc(uint8_t *p_tdt, uint64_t i_utc) 59 | { 60 | p_tdt[3] = (i_utc >> 32) & 0xff; 61 | p_tdt[4] = (i_utc >> 24) & 0xff; 62 | p_tdt[5] = (i_utc >> 16) & 0xff; 63 | p_tdt[6] = (i_utc >> 8) & 0xff; 64 | p_tdt[7] = i_utc & 0xff; 65 | } 66 | 67 | static inline uint64_t tdt_get_utc(const uint8_t *p_tdt) 68 | { 69 | return (uint64_t)(((uint64_t)p_tdt[3] << 32) | ((uint64_t)p_tdt[4] << 24) | 70 | ((uint64_t)p_tdt[5] << 16) | ((uint64_t)p_tdt[6] << 8) | p_tdt[7]); 71 | } 72 | 73 | static inline bool tdt_validate(const uint8_t *p_tdt) 74 | { 75 | uint16_t i_section_size = psi_get_length(p_tdt) + PSI_HEADER_SIZE; 76 | uint8_t i_tid = psi_get_tableid(p_tdt); 77 | 78 | if (psi_get_syntax(p_tdt) || i_tid != TDT_TABLE_ID 79 | || i_section_size < TDT_HEADER_SIZE) 80 | return false; 81 | 82 | return true; 83 | } 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /dvb/si/tdt_print.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * tdt_print.h: ETSI EN 300 468 Time and Date Table (TDT) (printing) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_DVB_TDT_PRINT_H__ 29 | #define __BITSTREAM_DVB_TDT_PRINT_H__ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #ifdef __cplusplus 36 | extern "C" 37 | { 38 | #endif 39 | 40 | /***************************************************************************** 41 | * Time and Date Table 42 | *****************************************************************************/ 43 | static inline void tdt_print(uint8_t *p_tdt, 44 | f_print pf_print, void *print_opaque, 45 | f_iconv pf_iconv, void *iconv_opaque, 46 | print_type_t i_print_type) 47 | { 48 | (void) pf_iconv; 49 | (void) iconv_opaque; 50 | 51 | time_t ts; 52 | char ts_str[24]; 53 | 54 | ts = dvb_time_format_UTC(tdt_get_utc(p_tdt), NULL, ts_str); 55 | 56 | switch (i_print_type) { 57 | case PRINT_XML: 58 | pf_print(print_opaque, "", 59 | ts, ts_str); 60 | break; 61 | default: 62 | pf_print(print_opaque, "new TDT time=%ld time_dec=\"%s\"", 63 | ts, ts_str); 64 | pf_print(print_opaque, "end TDT"); 65 | } 66 | } 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /dvb/si/tot.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * tot.h: ETSI EN 300 468 Time Offset Table (TOT) 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * Georgi Chorbadzhiyski 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining 10 | * a copy of this software and associated documentation files (the 11 | * "Software"), to deal in the Software without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject 15 | * to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 24 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | *****************************************************************************/ 28 | 29 | /* 30 | * Normative references: 31 | * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) 32 | */ 33 | 34 | #ifndef __BITSTREAM_DVB_TOT_H__ 35 | #define __BITSTREAM_DVB_TOT_H__ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #ifdef __cplusplus 43 | extern "C" 44 | { 45 | #endif 46 | 47 | /***************************************************************************** 48 | * Time Offset Table 49 | *****************************************************************************/ 50 | #define TOT_PID 0x14 51 | #define TOT_TABLE_ID 0x73 52 | #define TOT_HEADER_SIZE (PSI_HEADER_SIZE + 7) 53 | 54 | #define tot_set_utc tdt_set_utc 55 | #define tot_get_utc tdt_get_utc 56 | 57 | static inline void tot_init(uint8_t *p_tot) 58 | { 59 | psi_init(p_tot, false); 60 | psi_set_tableid(p_tot, TOT_TABLE_ID); 61 | p_tot[8] = 0xf0; 62 | } 63 | 64 | static inline void tot_set_length(uint8_t *p_tot, uint16_t i_tot_length) 65 | { 66 | psi_set_length(p_tot, TOT_HEADER_SIZE + PSI_CRC_SIZE - PSI_HEADER_SIZE 67 | + i_tot_length); 68 | } 69 | 70 | static inline void tot_set_desclength(uint8_t *p_tot, uint16_t i_length) 71 | { 72 | p_tot[8] &= ~0xf; 73 | p_tot[8] |= i_length >> 8; 74 | p_tot[9] = i_length & 0xff; 75 | } 76 | 77 | static inline uint16_t tot_get_desclength(const uint8_t *p_tot) 78 | { 79 | return ((p_tot[8] & 0xf) << 8) | p_tot[9]; 80 | } 81 | 82 | static inline uint8_t *tot_get_descs(uint8_t *p_tot) 83 | { 84 | return &p_tot[8]; 85 | } 86 | 87 | static inline bool tot_validate(const uint8_t *p_tot) 88 | { 89 | uint16_t i_section_size = psi_get_length(p_tot) + PSI_HEADER_SIZE; 90 | uint8_t i_tid = psi_get_tableid(p_tot); 91 | 92 | if (psi_get_syntax(p_tot) || i_tid != TOT_TABLE_ID 93 | || i_section_size < TOT_HEADER_SIZE + PSI_CRC_SIZE) 94 | return false; 95 | 96 | /* TOT is a syntax0 table with CRC */ 97 | if (!psi_check_crc(p_tot)) 98 | return false; 99 | 100 | if (i_section_size < TOT_HEADER_SIZE 101 | || i_section_size < TOT_HEADER_SIZE + tot_get_desclength(p_tot)) 102 | return false; 103 | 104 | if (!descs_validate(p_tot + 8)) 105 | return false; 106 | 107 | return true; 108 | } 109 | 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /dvb/si/tot_print.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * tot_print.h: ETSI EN 300 468 Time Offset Table (TOT) (printing) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_DVB_TOT_PRINT_H__ 29 | #define __BITSTREAM_DVB_TOT_PRINT_H__ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" 38 | { 39 | #endif 40 | 41 | /***************************************************************************** 42 | * Time Offset Table 43 | *****************************************************************************/ 44 | static inline void tot_print(uint8_t *p_tot, 45 | f_print pf_print, void *print_opaque, 46 | f_iconv pf_iconv, void *iconv_opaque, 47 | print_type_t i_print_type) 48 | { 49 | time_t ts; 50 | char ts_str[24]; 51 | 52 | ts = dvb_time_format_UTC(tot_get_utc(p_tot), NULL, ts_str); 53 | 54 | switch (i_print_type) { 55 | case PRINT_XML: 56 | pf_print(print_opaque, "", 57 | ts, ts_str); 58 | break; 59 | default: 60 | pf_print(print_opaque, "new TOT time=%ld time_dec=\"%s\"", 61 | ts, ts_str); 62 | } 63 | 64 | descs_print(tot_get_descs(p_tot), pf_print, print_opaque, 65 | pf_iconv, iconv_opaque, i_print_type); 66 | 67 | switch (i_print_type) { 68 | case PRINT_XML: 69 | pf_print(print_opaque, ""); 70 | break; 71 | default: 72 | pf_print(print_opaque, "end TOT"); 73 | } 74 | } 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /dvb/si_print.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * si_print.h: ETSI EN 300 468 Service Information (printing) 3 | ***************************************************************************** 4 | * Copyright (C) 2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_DVB_SI_PRINT_H__ 29 | #define __BITSTREAM_DVB_SI_PRINT_H__ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /dvb/sub.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * sub.h: ETSI EN 300 743 Subtitling Systems 3 | ***************************************************************************** 4 | * Copyright (C) 2014 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 743 V1.5.1 (2014-01) (Subtitling Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_DVB_SUB_H__ 34 | #define __BITSTREAM_DVB_SUB_H__ 35 | 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" 40 | { 41 | #endif 42 | 43 | /***************************************************************************** 44 | * PES data field 45 | *****************************************************************************/ 46 | #define DVBSUB_HEADER_SIZE 2 47 | #define DVBSUB_DATA_IDENTIFIER 0x20 48 | 49 | /***************************************************************************** 50 | * Subtitling segment 51 | *****************************************************************************/ 52 | #define DVBSUBS_HEADER_SIZE 6 53 | #define DVBSUBS_SYNC 0xf 54 | 55 | #define DVBSUBS_PAGE_COMPOSITION 0x10 56 | #define DVBSUBS_REGION_COMPOSITION 0x11 57 | #define DVBSUBS_CLUT_DEFINITION 0x12 58 | #define DVBSUBS_OBJECT_DATA 0x13 59 | #define DVBSUBS_DISPLAY_DEFINITION 0x14 60 | #define DVBSUBS_DISPARITY_SIGNALLING 0x15 61 | #define DVBSUBS_END_OF_DISPLAY_SET 0x80 62 | 63 | static inline uint8_t dvbsubs_get_type(const uint8_t *p_dvbsubs) 64 | { 65 | return p_dvbsubs[1]; 66 | } 67 | 68 | static inline uint16_t dvbsubs_get_page(const uint8_t *p_dvbsubs) 69 | { 70 | return (p_dvbsubs[2] << 8) | p_dvbsubs[3]; 71 | } 72 | 73 | static inline uint16_t dvbsubs_get_length(const uint8_t *p_dvbsubs) 74 | { 75 | return (p_dvbsubs[4] << 8) | p_dvbsubs[5]; 76 | } 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /dvb/telx.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * telx.h: ETSI EN 300 706 Enhanced Teletext 3 | ***************************************************************************** 4 | * Copyright (C) 2016 OpenHeadend 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 706 V1.2.1 (2003-04) (enhanced teletext) 31 | */ 32 | 33 | #ifndef __BITSTREAM_DVB_TELX_H__ 34 | #define __BITSTREAM_DVB_TELX_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Packet identification 46 | *****************************************************************************/ 47 | #define TELX_RUN_IN 0xaa 48 | #define TELX_FRAMING_CODE 0xe4 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /dvb/vbi.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * vbi.h: ETSI EN 301 775 Carriage of VBI in DVB 3 | ***************************************************************************** 4 | * Copyright (C) 2016 OpenHeadend 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ETSI EN 300 775 V1.2.1 (2003-05) (carriage of VBI in DVB) 31 | */ 32 | 33 | #ifndef __BITSTREAM_DVB_VBI_H__ 34 | #define __BITSTREAM_DVB_VBI_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * PES data field 46 | *****************************************************************************/ 47 | #define DVBVBI_HEADER_SIZE 1 48 | #define DVBVBI_UNIT_HEADER_SIZE 2 49 | #define DVBVBI_DATA_IDENTIFIER 0x10 50 | 51 | #define DVBVBI_ID_TTX_NONSUB 0x02 52 | #define DVBVBI_ID_TTX_SUB 0x03 53 | #define DVBVBI_ID_TTX_INVERTED 0xc0 54 | #define DVBVBI_ID_VPS 0xc3 55 | #define DVBVBI_ID_WSS 0xc4 56 | #define DVBVBI_ID_CEA608 0xc5 57 | #define DVBVBI_ID_RAWVBI 0xc6 58 | #define DVBVBI_ID_STUFFING 0xff 59 | 60 | #define DVBVBI_LENGTH 0x2c 61 | 62 | /***************************************************************************** 63 | * Teletext data field 64 | *****************************************************************************/ 65 | #define DVBVBITTX_FRAMING_CODE 0xe4 66 | 67 | static inline void dvbvbittx_set_field(uint8_t *p, bool field) 68 | { 69 | p[0] |= 0xc0; 70 | if (field) 71 | p[0] |= 0x20; 72 | else 73 | p[0] &= ~0x20; 74 | } 75 | 76 | static inline bool dvbvbittx_get_field(const uint8_t *p) 77 | { 78 | return p[0] & 0x20; 79 | } 80 | 81 | static inline void dvbvbittx_set_line(uint8_t *p, uint8_t line) 82 | { 83 | p[0] &= ~0x1f; 84 | p[0] |= 0xc0 | (line & 0x1f); 85 | } 86 | 87 | static inline uint8_t dvbvbittx_get_line(const uint8_t *p) 88 | { 89 | return p[0] & 0x1f; 90 | } 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /examples/Makefile: -------------------------------------------------------------------------------- 1 | PREFIX ?= /usr/local 2 | WARN = -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare 3 | CPPFLAGS = -I. -I.. -I../.. 4 | CFLAGS := $(WARN) -O2 -g -std=gnu99 $(CFLAGS) 5 | OBJ = dvb_print_si dvb_gen_si dvb_ecmg dvb_ecmg_test mpeg_print_pcr rtp_check_seqnum mpeg_restamp 6 | 7 | ifeq "$(shell uname -s)" "Linux" 8 | LDFLAGS += -lrt 9 | endif 10 | 11 | ifeq "$(shell uname -s)" "Darwin" 12 | LDFLAGS += -liconv 13 | endif 14 | 15 | all: $(OBJ) 16 | 17 | %: %.c 18 | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS) 19 | 20 | install: $(OBJ) 21 | install -d "$(DESTDIR)$(PREFIX)/bin" 22 | install -m 755 $(OBJ) "$(DESTDIR)$(PREFIX)/bin" 23 | 24 | clean: 25 | $(RM) -rf $(OBJ) *.dSYM 26 | -------------------------------------------------------------------------------- /examples/dvb_gen_si.test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to test PSI generation and parsing 3 | # Copyright (C) 2011 Unix Solutions Ltd. 4 | # 5 | # License: MIT 6 | # Authors: Georgi Chorbadzhiyski 7 | # 8 | 9 | rm dvb_gen_si dvb_print_si 10 | make local 11 | 12 | ./dvb_gen_si | ./dvb_print_si > dvb_print_si.output.txt 13 | ./dvb_gen_si | ./dvb_print_si -x xml > dvb_print_si.output.xml 14 | 15 | git diff dvb_print_si.output.txt dvb_print_si.output.xml 16 | -------------------------------------------------------------------------------- /examples/rtp_check_seqnum.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * rtp_check_seqnum.c: Prints RTP discontinuities 3 | ***************************************************************************** 4 | * Copyright (C) 2011 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | /***************************************************************************** 38 | * Local declarations 39 | *****************************************************************************/ 40 | #define DEFAULT_PACKET_SIZE 1328 41 | 42 | /***************************************************************************** 43 | * Main loop 44 | *****************************************************************************/ 45 | static void usage(const char *psz) 46 | { 47 | fprintf(stderr, "usage: multicat -u -m @: | %s []\n", psz); 48 | exit(EXIT_FAILURE); 49 | } 50 | 51 | int main(int i_argc, char **ppsz_argv) 52 | { 53 | int i_packet_size = DEFAULT_PACKET_SIZE; 54 | 55 | if (ppsz_argv[1] != NULL && 56 | (!strcmp(ppsz_argv[1], "-h") || !strcmp(ppsz_argv[1], "--help"))) 57 | usage(ppsz_argv[0]); 58 | 59 | if (ppsz_argv[1] != NULL) 60 | i_packet_size = atoi(ppsz_argv[1]); 61 | if (i_packet_size > 65535 || i_packet_size < RTP_HEADER_SIZE) 62 | usage(ppsz_argv[0]); 63 | 64 | uint8_t p_buffer[i_packet_size]; 65 | uint16_t i_seqnum = 0; 66 | 67 | for ( ; ; ) { 68 | ssize_t toto; 69 | if ((toto=read(STDIN_FILENO, p_buffer, i_packet_size)) != i_packet_size) { 70 | fprintf(stderr, "couldn't read %zd\n", toto); 71 | exit(EXIT_FAILURE); 72 | } 73 | 74 | if (!rtp_check_hdr(p_buffer)) { 75 | fprintf(stderr, "invalid RTP header\n"); 76 | continue; 77 | } 78 | 79 | uint16_t i_new_seqnum = rtp_get_seqnum(p_buffer); 80 | if (i_new_seqnum != i_seqnum) 81 | fprintf(stderr, "received packet %hu while expecting %hu\n", 82 | i_new_seqnum, i_seqnum); 83 | i_seqnum = (i_new_seqnum + 1) % 65536; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /ieee/ethernet.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * ethernet.h: Ethernet frames 3 | ***************************************************************************** 4 | * Copyright (C) 2015 VideoLAN 5 | * 6 | * Authors: Benjamin Cohen 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - IEEE Std 802.3-2012 (December 2012) 31 | * - IETF RFC 7042 IANA Considerations and IETF Protocol 32 | * and Documentation Usage for IEEE 802 Parameters (October 2013) 33 | */ 34 | 35 | #ifndef __BITSTREAM_IEEE_ETHERNET_H__ 36 | #define __BITSTREAM_IEEE_ETHERNET_H__ 37 | 38 | #include 39 | #include /* memcpy */ 40 | 41 | #ifdef __cplusplus 42 | extern "C" 43 | { 44 | #endif 45 | 46 | #define ETHERNET_ADDR_LEN 6 47 | #define ETHERNET_HEADER_LEN (2*ETHERNET_ADDR_LEN + 2) 48 | #define ETHERNET_VLAN_LEN 4 49 | 50 | #define ETHERNET_TYPE_IP 0x0800 51 | #define ETHERNET_TYPE_ARP 0x0806 52 | #define ETHERNET_TYPE_RARP 0x8035 53 | #define ETHERNET_TYPE_VLAN 0x8100 54 | #define ETHERNET_TYPE_IPV6 0x86DD 55 | #define ETHERNET_TYPE_PPP 0x880B 56 | #define ETHERNET_TYPE_MPLS 0x8847 57 | #define ETHERNET_TYPE_PPPOE_DISC 0x8863 58 | #define ETHERNET_TYPE_PPPOE_SESSION 0x8864 59 | #define ETHERNET_TYPE_LLDP 0x88CC 60 | 61 | static inline uint8_t *ethernet_dstaddr(uint8_t *p_ethernet) 62 | { 63 | return p_ethernet; 64 | } 65 | 66 | static inline void ethernet_get_dstaddr(const uint8_t *p_ethernet, uint8_t *p_addr) 67 | { 68 | memcpy(p_addr, p_ethernet, ETHERNET_ADDR_LEN); 69 | } 70 | 71 | static inline void ethernet_set_dstaddr(uint8_t *p_ethernet, const uint8_t *p_addr) 72 | { 73 | memcpy(ethernet_dstaddr(p_ethernet), p_addr, ETHERNET_ADDR_LEN); 74 | } 75 | 76 | static inline uint8_t *ethernet_srcaddr(uint8_t *p_ethernet) 77 | { 78 | return p_ethernet + ETHERNET_ADDR_LEN; 79 | } 80 | 81 | static inline void ethernet_get_srcaddr(const uint8_t *p_ethernet, uint8_t *p_addr) 82 | { 83 | memcpy(p_addr, p_ethernet + ETHERNET_ADDR_LEN, ETHERNET_ADDR_LEN); 84 | } 85 | 86 | static inline void ethernet_set_srcaddr(uint8_t *p_ethernet, const uint8_t *p_addr) 87 | { 88 | memcpy(ethernet_srcaddr(p_ethernet), p_addr, ETHERNET_ADDR_LEN); 89 | } 90 | 91 | static inline uint16_t ethernet_get_lentype(const uint8_t *p_ethernet) 92 | { 93 | return (p_ethernet[12] << 8) | p_ethernet[13]; 94 | } 95 | 96 | static inline void ethernet_set_lentype(uint8_t *p_ethernet, uint16_t lentype) 97 | { 98 | p_ethernet[12] = (lentype & 0xff00) >> 8; 99 | p_ethernet[13] = (lentype & 0xff); 100 | } 101 | 102 | static inline uint8_t *ethernet_payload(uint8_t *p_ethernet) 103 | { 104 | return p_ethernet + ETHERNET_HEADER_LEN; 105 | } 106 | 107 | #ifdef __cplusplus 108 | } 109 | #endif 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /ietf/rtcp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 OpenHeadend S.A.R.L. 3 | * 4 | * Authors: Arnaud de Turckheim 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject 12 | * to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef __BITSTREAM_IETF_RTCP_H__ 27 | # define __BITSTREAM_IETF_RTCP_H__ 28 | 29 | # include 30 | 31 | # define RTCP_RTP_VERSION 2 32 | # define RTCP_PT_APP 204 33 | 34 | static inline void rtcp_set_rtp_version(uint8_t *p_rtcp) 35 | { 36 | p_rtcp[0] = RTCP_RTP_VERSION << 6; 37 | } 38 | 39 | static inline uint8_t rtcp_get_rc(const uint8_t *p_rtcp) 40 | { 41 | return p_rtcp[0] & 0x1f; 42 | } 43 | 44 | static inline void rtcp_set_rc(uint8_t *p_rtcp, uint8_t rc) 45 | { 46 | p_rtcp[0] |= rc & 0x1f; 47 | } 48 | 49 | static inline uint8_t rtcp_get_pt(const uint8_t *p_rtcp) 50 | { 51 | return p_rtcp[1]; 52 | } 53 | 54 | static inline void rtcp_set_pt(uint8_t *p_rtcp, uint8_t pt) 55 | { 56 | p_rtcp[1] = pt; 57 | } 58 | 59 | static inline uint16_t rtcp_get_length(const uint8_t *p_rtcp) 60 | { 61 | return (p_rtcp[2] << 8) | p_rtcp[3]; 62 | } 63 | 64 | static inline void rtcp_set_length(uint8_t *p_rtcp, 65 | uint16_t length) 66 | { 67 | p_rtcp[2] = length >> 8; 68 | p_rtcp[3] = length & 0xff; 69 | } 70 | 71 | # include 72 | 73 | #endif /* !__BITSTREAM_IETF_RTCP_H__ */ 74 | -------------------------------------------------------------------------------- /ietf/rtcp_fb.h: -------------------------------------------------------------------------------- 1 | #ifndef __BITSTREAM_IETF_RTCP_FB_H__ 2 | # define __BITSTREAM_IETF_RTCP_FB_H__ 3 | 4 | # include 5 | 6 | # define RTCP_PT_RTPFB 205 7 | # define RTCP_PT_PSFB 206 8 | 9 | # define RTCP_PT_RTPFB_GENERIC_NACK 1 10 | 11 | # define RTCP_FB_HEADER_SIZE 12 12 | # define RTCP_FB_FCI_GENERIC_NACK_SIZE 4 13 | 14 | static inline void rtcp_fb_set_fmt(uint8_t *p_rtcp, uint8_t fmt) 15 | { 16 | p_rtcp[0] |= fmt & 0x1f; 17 | } 18 | 19 | static inline uint8_t rtcp_fb_get_fmt(const uint8_t *p_rtcp) 20 | { 21 | return p_rtcp[0] & 0x1f; 22 | } 23 | 24 | static inline void rtcp_fb_set_ssrc_pkt_sender(uint8_t *p_rtcp_fb, 25 | const uint8_t pi_ssrc[4]) 26 | { 27 | p_rtcp_fb[4] = pi_ssrc[0]; 28 | p_rtcp_fb[5] = pi_ssrc[1]; 29 | p_rtcp_fb[6] = pi_ssrc[2]; 30 | p_rtcp_fb[7] = pi_ssrc[3]; 31 | } 32 | 33 | static inline void rtcp_fb_set_int_ssrc_pkt_sender(uint8_t *p_rtcp_fb, uint32_t i_ssrc) 34 | { 35 | p_rtcp_fb[4] = (i_ssrc >> 24) & 0xff; 36 | p_rtcp_fb[5] = (i_ssrc >> 16) & 0xff; 37 | p_rtcp_fb[6] = (i_ssrc >> 8) & 0xff; 38 | p_rtcp_fb[7] = i_ssrc & 0xff; 39 | } 40 | 41 | static inline uint32_t rtcp_fb_get_int_ssrc_pkt_sender(const uint8_t *p_rtcp_fb) 42 | { 43 | return (p_rtcp_fb[4] << 24) | (p_rtcp_fb[5] << 16) | (p_rtcp_fb[6] << 8) | p_rtcp_fb[7]; 44 | } 45 | 46 | static inline void rtcp_fb_set_ssrc_media_src(uint8_t *p_rtcp_fb, 47 | const uint8_t pi_ssrc[4]) 48 | { 49 | p_rtcp_fb[8] = pi_ssrc[0]; 50 | p_rtcp_fb[9] = pi_ssrc[1]; 51 | p_rtcp_fb[10] = pi_ssrc[2]; 52 | p_rtcp_fb[11] = pi_ssrc[3]; 53 | } 54 | 55 | static inline void rtcp_fb_get_ssrc_pkt_sender(const uint8_t *p_rtcp_fb, 56 | uint8_t pi_ssrc[4]) 57 | { 58 | pi_ssrc[0] = p_rtcp_fb[4]; 59 | pi_ssrc[1] = p_rtcp_fb[5]; 60 | pi_ssrc[2] = p_rtcp_fb[6]; 61 | pi_ssrc[3] = p_rtcp_fb[7]; 62 | } 63 | 64 | static inline void rtcp_fb_get_ssrc_media_src(const uint8_t *p_rtcp_fb, 65 | uint8_t pi_ssrc[4]) 66 | { 67 | pi_ssrc[0] = p_rtcp_fb[8]; 68 | pi_ssrc[1] = p_rtcp_fb[9]; 69 | pi_ssrc[2] = p_rtcp_fb[10]; 70 | pi_ssrc[3] = p_rtcp_fb[11]; 71 | } 72 | 73 | static inline void rtcp_fb_nack_set_packet_id(uint8_t *p_rtcp_fb_nack, 74 | uint16_t packet_id) 75 | { 76 | p_rtcp_fb_nack[0] = (packet_id >> 8) & 0xff; 77 | p_rtcp_fb_nack[1] = packet_id & 0xff; 78 | } 79 | 80 | static inline uint16_t rtcp_fb_nack_get_packet_id(const uint8_t *p_rtcp_fb_nack) 81 | { 82 | return (p_rtcp_fb_nack[0] << 8) | p_rtcp_fb_nack[1]; 83 | } 84 | 85 | static inline uint16_t rtcp_fb_nack_get_bitmask_lost(const uint8_t *p_rtcp_fb_nack) 86 | { 87 | return (p_rtcp_fb_nack[2] << 8) | p_rtcp_fb_nack[3]; 88 | } 89 | 90 | static inline void rtcp_fb_nack_set_bitmask_lost(uint8_t *p_rtcp_fb_nack, 91 | uint16_t bitmask) 92 | { 93 | p_rtcp_fb_nack[2] = (bitmask >> 8) & 0xff; 94 | p_rtcp_fb_nack[3] = bitmask & 0xff; 95 | } 96 | 97 | #endif /* !__BITSTREAM_IETF_RTCP_FB_H__ */ 98 | -------------------------------------------------------------------------------- /ietf/rtcp_rr.h: -------------------------------------------------------------------------------- 1 | #ifndef __BITSTREAM_IETF_RTCP_RR_H__ 2 | # define __BITSTREAM_IETF_RTCP_RR_H__ 3 | 4 | # include 5 | # include 6 | 7 | # define RTCP_RR_SIZE 32 8 | 9 | # define RTCP_PT_RR 201 10 | 11 | static inline void rtcp_rr_set_pt(uint8_t *p_rtcp_rr) 12 | { 13 | rtcp_set_pt(p_rtcp_rr, RTCP_PT_RR); 14 | } 15 | 16 | static inline uint8_t rtcp_rr_get_fraction_lost(const uint8_t *p_rtcp_rr) 17 | { 18 | return p_rtcp_rr[12]; 19 | } 20 | 21 | static inline void rtcp_rr_set_fraction_lost(uint8_t *p_rtcp_rr, uint8_t fraction_lost) 22 | { 23 | p_rtcp_rr[12] = fraction_lost; 24 | } 25 | 26 | static inline int32_t rtcp_rr_get_cumulative_packets_lost(const uint8_t *p_rtcp_rr) 27 | { 28 | uint32_t u = (p_rtcp_rr[13] << 16) | (p_rtcp_rr[14] << 8) | p_rtcp_rr[15]; 29 | if (u & 0x800000) 30 | return -(u & 0x7fffff); 31 | else 32 | return u; 33 | } 34 | 35 | static inline void rtcp_rr_set_cumulative_packets_lost(uint8_t *p_rtcp_rr, 36 | int32_t packets_lost) 37 | { 38 | if (packets_lost > 0x7fffff) 39 | packets_lost = 0x7fffff; 40 | else if (packets_lost < -0x800000) 41 | packets_lost = -0x800000; 42 | 43 | int neg = packets_lost < 0; 44 | uint32_t u = neg ? -packets_lost : packets_lost; 45 | 46 | p_rtcp_rr[13] = (neg << 7) | ((u >> 16) & 0x7f); 47 | p_rtcp_rr[14] = (u >> 8) & 0xff; 48 | p_rtcp_rr[15] = u & 0xff; 49 | } 50 | 51 | static inline uint32_t rtcp_rr_get_highest_seqnum(const uint8_t *p_rtcp_rr) 52 | { 53 | return (p_rtcp_rr[16] << 24) | (p_rtcp_rr[17] << 16) | 54 | (p_rtcp_rr[18] << 8) | p_rtcp_rr[19]; 55 | } 56 | 57 | static inline void rtcp_rr_set_highest_seqnum(uint8_t *p_rtcp_rr, 58 | uint32_t highest_seqnum) 59 | { 60 | p_rtcp_rr[16] = (highest_seqnum >> 24) & 0xff; 61 | p_rtcp_rr[17] = (highest_seqnum >> 16) & 0xff; 62 | p_rtcp_rr[18] = (highest_seqnum >> 8) & 0xff; 63 | p_rtcp_rr[19] = highest_seqnum & 0xff; 64 | } 65 | 66 | static inline uint32_t rtcp_rr_get_inter_arrival_jitter(const uint8_t *p_rtcp_rr) 67 | { 68 | return (p_rtcp_rr[20] << 24) | (p_rtcp_rr[21] << 16) | 69 | (p_rtcp_rr[22] << 8) | p_rtcp_rr[23]; 70 | } 71 | 72 | static inline void rtcp_rr_set_inter_arrival_jitter(uint8_t *p_rtcp_rr, 73 | uint32_t inter_arrival_jitter) 74 | { 75 | p_rtcp_rr[20] = (inter_arrival_jitter >> 24) & 0xff; 76 | p_rtcp_rr[21] = (inter_arrival_jitter >> 16) & 0xff; 77 | p_rtcp_rr[22] = (inter_arrival_jitter >> 8) & 0xff; 78 | p_rtcp_rr[23] = inter_arrival_jitter & 0xff; 79 | } 80 | 81 | static inline uint32_t rtcp_rr_get_last_sr(const uint8_t *p_rtcp_rr) 82 | { 83 | return (p_rtcp_rr[24] << 24) | (p_rtcp_rr[25] << 16) | 84 | (p_rtcp_rr[26] << 8) | p_rtcp_rr[27]; 85 | } 86 | 87 | static inline void rtcp_rr_set_last_sr(uint8_t *p_rtcp_rr, 88 | uint32_t last_sr) 89 | { 90 | p_rtcp_rr[24] = (last_sr >> 24) & 0xff; 91 | p_rtcp_rr[25] = (last_sr >> 16) & 0xff; 92 | p_rtcp_rr[26] = (last_sr >> 8) & 0xff; 93 | p_rtcp_rr[27] = last_sr & 0xff; 94 | } 95 | 96 | static inline uint32_t rtcp_rr_get_delay_since_last_sr(const uint8_t *p_rtcp_rr) 97 | { 98 | return (p_rtcp_rr[28] << 24) | (p_rtcp_rr[29] << 16) | 99 | (p_rtcp_rr[30] << 8) | p_rtcp_rr[31]; 100 | } 101 | 102 | static inline void rtcp_rr_set_delay_since_last_sr(uint8_t *p_rtcp_rr, 103 | uint32_t delay_since_last_sr) 104 | { 105 | p_rtcp_rr[28] = (delay_since_last_sr >> 24) & 0xff; 106 | p_rtcp_rr[29] = (delay_since_last_sr >> 16) & 0xff; 107 | p_rtcp_rr[30] = (delay_since_last_sr >> 8) & 0xff; 108 | p_rtcp_rr[31] = delay_since_last_sr & 0xff; 109 | } 110 | #endif /* !__BITSTREAM_IETF_RTCP_RR_H__ */ 111 | -------------------------------------------------------------------------------- /ietf/rtcp_sdes.h: -------------------------------------------------------------------------------- 1 | #ifndef __BITSTREAM_IETF_RTCP_SDES_H__ 2 | # define __BITSTREAM_IETF_RTCP_SDES_H__ 3 | 4 | # include 5 | # include 6 | 7 | # define RTCP_SDES_SIZE 10 8 | 9 | # define RTCP_PT_SDES 202 10 | 11 | static inline void rtcp_sdes_set_pt(uint8_t *p_rtcp_rr) 12 | { 13 | rtcp_set_pt(p_rtcp_rr, RTCP_PT_SDES); 14 | } 15 | 16 | static inline uint8_t rtcp_sdes_get_cname(const uint8_t *p_rtcp_sdes) 17 | { 18 | return p_rtcp_sdes[8]; 19 | } 20 | 21 | static inline void rtcp_sdes_set_cname(uint8_t *p_rtcp_sdes, uint8_t cname) 22 | { 23 | p_rtcp_sdes[8] = cname; 24 | } 25 | 26 | static inline int8_t rtcp_sdes_get_name_length(const uint8_t *p_rtcp_sdes) 27 | { 28 | return p_rtcp_sdes[9]; 29 | } 30 | 31 | static inline void rtcp_sdes_set_name_length(uint8_t *p_rtcp_sdes, 32 | int8_t name_length) 33 | { 34 | p_rtcp_sdes[9] = name_length; 35 | } 36 | 37 | #endif /* !__BITSTREAM_IETF_RTCP_SDES_H__ */ 38 | -------------------------------------------------------------------------------- /ietf/rtcp_sr.h: -------------------------------------------------------------------------------- 1 | #ifndef __BITSTREAM_IETF_RTCP_SR_H__ 2 | # define __BITSTREAM_IETF_RTCP_SR_H__ 3 | 4 | # include 5 | # include 6 | 7 | # define RTCP_SR_SIZE 28 8 | 9 | # define RTCP_PT_SR 200 10 | 11 | static inline void rtcp_sr_set_rtp_version(uint8_t *p_rtcp) 12 | { 13 | rtcp_set_rtp_version(p_rtcp); 14 | } 15 | 16 | static inline void rtcp_sr_set_pt(uint8_t *p_rtcp_sr) 17 | { 18 | rtcp_set_pt(p_rtcp_sr, RTCP_PT_SR); 19 | } 20 | 21 | static inline void rtcp_sr_set_length(uint8_t *p_rtcp_sr, 22 | uint16_t length) 23 | { 24 | rtcp_set_length(p_rtcp_sr, length); 25 | } 26 | 27 | static inline uint32_t rtcp_sr_get_ntp_time_msw(const uint8_t *p_rtcp_sr) 28 | { 29 | return (p_rtcp_sr[8] << 24) | (p_rtcp_sr[9] << 16) | 30 | (p_rtcp_sr[10] << 8) | p_rtcp_sr[11]; 31 | } 32 | 33 | static inline void rtcp_sr_set_ntp_time_msw(uint8_t *p_rtcp_sr, 34 | uint32_t ntp_time_msw) 35 | { 36 | p_rtcp_sr[8] = (ntp_time_msw >> 24) & 0xff; 37 | p_rtcp_sr[9] = (ntp_time_msw >> 16) & 0xff; 38 | p_rtcp_sr[10] = (ntp_time_msw >> 8) & 0xff; 39 | p_rtcp_sr[11] = ntp_time_msw & 0xff; 40 | } 41 | 42 | static inline uint32_t rtcp_sr_get_ntp_time_lsw(const uint8_t *p_rtcp_sr) 43 | { 44 | return (p_rtcp_sr[12] << 24) | (p_rtcp_sr[13] << 16) | 45 | (p_rtcp_sr[14] << 8) | p_rtcp_sr[15]; 46 | } 47 | 48 | static inline void rtcp_sr_set_ntp_time_lsw(uint8_t *p_rtcp_sr, 49 | uint32_t ntp_time_lsw) 50 | { 51 | p_rtcp_sr[12] = (ntp_time_lsw >> 24) & 0xff; 52 | p_rtcp_sr[13] = (ntp_time_lsw >> 16) & 0xff; 53 | p_rtcp_sr[14] = (ntp_time_lsw >> 8) & 0xff; 54 | p_rtcp_sr[15] = ntp_time_lsw & 0xff; 55 | } 56 | 57 | static inline uint32_t rtcp_sr_get_rtp_time(const uint8_t *p_rtcp_sr) 58 | { 59 | return (p_rtcp_sr[16] << 24) | (p_rtcp_sr[17] << 16) | 60 | (p_rtcp_sr[18] << 8) | p_rtcp_sr[19]; 61 | } 62 | 63 | static inline void rtcp_sr_set_rtp_time(uint8_t *p_rtcp_sr, 64 | uint32_t rtp_time) 65 | { 66 | p_rtcp_sr[16] = (rtp_time >> 24) & 0xff; 67 | p_rtcp_sr[17] = (rtp_time >> 16) & 0xff; 68 | p_rtcp_sr[18] = (rtp_time >> 8) & 0xff; 69 | p_rtcp_sr[19] = rtp_time & 0xff; 70 | } 71 | 72 | static inline uint32_t rtcp_sr_get_packet_count(const uint8_t *p_rtcp_sr) 73 | { 74 | return (p_rtcp_sr[20] << 24) | (p_rtcp_sr[21] << 16) | 75 | (p_rtcp_sr[22] << 8) | p_rtcp_sr[23]; 76 | } 77 | 78 | static inline void rtcp_sr_set_packet_count(uint8_t *p_rtcp_sr, 79 | uint32_t packet_count) 80 | { 81 | p_rtcp_sr[20] = (packet_count >> 24) & 0xff; 82 | p_rtcp_sr[21] = (packet_count >> 16) & 0xff; 83 | p_rtcp_sr[22] = (packet_count >> 8) & 0xff; 84 | p_rtcp_sr[23] = packet_count & 0xff; 85 | } 86 | 87 | static inline uint32_t rtcp_sr_get_octet_count(const uint8_t *p_rtcp_sr) 88 | { 89 | return (p_rtcp_sr[24] << 24) | (p_rtcp_sr[25] << 16) | 90 | (p_rtcp_sr[26] << 8) | p_rtcp_sr[27]; 91 | } 92 | 93 | static inline void rtcp_sr_set_octet_count(uint8_t *p_rtcp_sr, 94 | uint32_t octet_count) 95 | { 96 | p_rtcp_sr[24] = (octet_count >> 24) & 0xff; 97 | p_rtcp_sr[25] = (octet_count >> 16) & 0xff; 98 | p_rtcp_sr[26] = (octet_count >> 8) & 0xff; 99 | p_rtcp_sr[27] = octet_count & 0xff; 100 | } 101 | 102 | #endif /* !__BITSTREAM_IETF_RTCP_SR_H__ */ 103 | -------------------------------------------------------------------------------- /ietf/rtp3640.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * rtp3640.h: RTP Payload Format for Transport of MPEG-4 Elementary Streams 3 | ***************************************************************************** 4 | * Copyright (C) 2017 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - IETF RFC 3640 RTP Payload Format for Transport of MPEG-4 ES 31 | */ 32 | 33 | #ifndef __BITSTREAM_IETF_RTP3640_H__ 34 | # define __BITSTREAM_IETF_RTP3640_H__ 35 | 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" 40 | { 41 | #endif 42 | 43 | #define RTP3640_AU_HEADERS_LENGTH_SIZE 2 44 | #define RTP3640_AU_HEADER_AAC_HBR_SIZE 2 45 | 46 | static inline void rtp3640_set_au_headers_length(uint8_t *header, uint16_t size) 47 | { 48 | header[0] = size >> 8; 49 | header[1] = size & 0xff; 50 | } 51 | 52 | static inline uint16_t rtp3640_get_au_headers_length(const uint8_t *header) 53 | { 54 | return (header[0] << 8) | header[1]; 55 | } 56 | 57 | static inline void rtp3640_set_aac_hbr_au_size(uint8_t *header, uint16_t size) 58 | { 59 | header[0] = (size >> 5) & 0xff; 60 | header[1] &= ~0xf8; 61 | header[1] |= (size << 3) & 0xf8; 62 | } 63 | 64 | static inline uint16_t rtp3640_get_aac_hbr_au_size(const uint8_t *header) 65 | { 66 | return (header[0] << 5) | (header[1] >> 3); 67 | } 68 | 69 | 70 | static inline void rtp3640_set_aac_hbr_au_index(uint8_t *header, uint8_t index) 71 | { 72 | header[1] &= ~0x7; 73 | header[1] |= index & 0x7; 74 | } 75 | 76 | static inline uint8_t rtp3640_get_aac_hbr_au_index(const uint8_t *header) 77 | { 78 | return (header[1] & 0x7); 79 | } 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /* !__BITSTREAM_IETF_RTP3640_H__ */ 86 | -------------------------------------------------------------------------------- /ietf/rtp6184.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * rtp6184.h: RTP Payload Format for H.264 Video 3 | ***************************************************************************** 4 | * Copyright (c) 2015 Arnaud de Turckheim 5 | * Copyright (C) 2017 VideoLAN 6 | * 7 | * Authors: Arnaud de Turckheim 8 | * Christophe Massiot 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining 11 | * a copy of this software and associated documentation files (the 12 | * "Software"), to deal in the Software without restriction, including 13 | * without limitation the rights to use, copy, modify, merge, publish, 14 | * distribute, sublicense, and/or sell copies of the Software, and to 15 | * permit persons to whom the Software is furnished to do so, subject 16 | * to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be 19 | * included in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 25 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 26 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 27 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | *****************************************************************************/ 29 | 30 | /* 31 | * Normative references: 32 | * - IETF RFC 6184 RTP Payload Format for H.264 Video (May 2011) 33 | */ 34 | 35 | #ifndef __BITSTREAM_IETF_RTP6184_H__ 36 | # define __BITSTREAM_IETF_RTP6184_H__ 37 | 38 | #include 39 | #include 40 | 41 | #ifdef __cplusplus 42 | extern "C" 43 | { 44 | #endif 45 | 46 | #define RTP_6184_CLOCKRATE 90000 47 | 48 | #define RTP_6184_STAP_A 24 49 | #define RTP_6184_STAP_B 25 50 | #define RTP_6184_MTAP16 26 51 | #define RTP_6184_MTAP24 27 52 | #define RTP_6184_FU_A 28 53 | #define RTP_6184_FU_B 29 54 | 55 | #define RTP_6184_STAP_HEADER_SIZE 2 56 | 57 | static inline void rtp_6184_stap_set_size(uint8_t *header, uint16_t size) 58 | { 59 | header[0] = size >> 8; 60 | header[1] = size & 0xff; 61 | } 62 | 63 | static inline uint16_t rtp_6184_stap_get_size(const uint8_t *header) 64 | { 65 | return (header[0] << 8) | header[1]; 66 | } 67 | 68 | static inline void rtp_6184_fu_set_start(uint8_t *header) 69 | { 70 | header[0] |= 0x80; 71 | } 72 | 73 | static inline bool rtp_6184_fu_check_start(uint8_t header) 74 | { 75 | return header & 0x80; 76 | } 77 | 78 | static inline void rtp_6184_fu_set_end(uint8_t *header) 79 | { 80 | header[0] |= 0x40; 81 | } 82 | 83 | static inline bool rtp_6184_fu_check_end(uint8_t header) 84 | { 85 | return header & 0x40; 86 | } 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif /* !__BITSTREAM_IETF_RTP6184_H__ */ 93 | -------------------------------------------------------------------------------- /ietf/rtp7587.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * rtp7587.h: RFC Profile for Opus 3 | ***************************************************************************** 4 | * Copyright (C) 2015 Open Broadcast Systems Ltd. 5 | * 6 | * Authors: Kieran Kunhya 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * RTP Payload Format for the Opus Speech and Audio Codec 30 | */ 31 | #ifndef __BITSTREAM_IETF_RTP7587_H__ 32 | # define __BITSTREAM_IETF_RTP7587_H__ 33 | 34 | #define RTP_7587_CLOCKRATE 48000 35 | 36 | #endif /* !__BITSTREAM_IETF_RTP7587_H__ */ 37 | -------------------------------------------------------------------------------- /ietf/udp.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * udp.h: User Datagram Protocol (UDP) 3 | ***************************************************************************** 4 | * Copyright (C) 2015 VideoLAN 5 | * 6 | * Authors: Benjamin Cohen 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - IETF RFC 768 User Datagram Protocol (August 1980) 31 | */ 32 | 33 | #ifndef __BITSTREAM_IETF_UDP_H__ 34 | #define __BITSTREAM_IETF_UDP_H__ 35 | 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" 40 | { 41 | #endif 42 | 43 | /* 44 | * Reminder: UDP header 45 | 0 7 8 15 16 23 24 31 46 | +--------+--------+--------+--------+ 47 | | Source | Destination | 48 | | Port | Port | 49 | +--------+--------+--------+--------+ 50 | | | | 51 | | Length | Checksum | 52 | +--------+--------+--------+--------+ 53 | */ 54 | 55 | #define UDP_HEADER_SIZE 8 56 | 57 | static inline void udp_set_srcport(uint8_t *p_udp, uint16_t port) 58 | { 59 | p_udp[0] = (port & 0xff00) >> 8; 60 | p_udp[1] = (port & 0xff); 61 | } 62 | 63 | static inline uint16_t udp_get_srcport(const uint8_t *p_udp) 64 | { 65 | return (p_udp[0] << 8) | p_udp[1]; 66 | } 67 | 68 | static inline void udp_set_dstport(uint8_t *p_udp, uint16_t port) 69 | { 70 | p_udp[2] = (port & 0xff00) >> 8; 71 | p_udp[3] = (port & 0xff); 72 | } 73 | 74 | static inline uint16_t udp_get_dstport(const uint8_t *p_udp) 75 | { 76 | return (p_udp[2] << 8) | p_udp[3]; 77 | } 78 | 79 | static inline void udp_set_len(uint8_t *p_udp, uint16_t len) 80 | { 81 | p_udp[4] = (len & 0xff00) >> 8; 82 | p_udp[5] = (len & 0xff); 83 | } 84 | 85 | static inline uint16_t udp_get_len(const uint8_t *p_udp) 86 | { 87 | return (p_udp[4] << 8) | p_udp[5]; 88 | } 89 | 90 | static inline void udp_set_cksum(uint8_t *p_udp, uint16_t cksum) 91 | { 92 | p_udp[6] = (cksum & 0xff00) >> 8; 93 | p_udp[7] = (cksum & 0xff); 94 | } 95 | 96 | static inline uint16_t udp_get_cksum(const uint8_t *p_udp) 97 | { 98 | return (p_udp[6] << 8) | p_udp[7]; 99 | } 100 | 101 | static inline uint8_t *udp_payload(uint8_t *p_udp) 102 | { 103 | return p_udp + UDP_HEADER_SIZE; 104 | } 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /mpeg/psi.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * psi.h: ISO/IEC 13818-1 Program Stream Information 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_PSI_H__ 34 | #define __BITSTREAM_MPEG_PSI_H__ 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /mpeg/psi/cat_print.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * cat_print.h: ISO/IEC 13818-1 Conditional Access Table (printing) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_MPEG_CAT_PRINT_H__ 29 | #define __BITSTREAM_MPEG_CAT_PRINT_H__ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" 40 | { 41 | #endif 42 | 43 | static inline void cat_table_print(uint8_t **pp_sections, f_print pf_print, 44 | void *opaque, print_type_t i_print_type) 45 | { 46 | uint8_t i_last_section = psi_table_get_lastsection(pp_sections); 47 | uint8_t i; 48 | const char *psz_table_name = "CAT"; 49 | 50 | if (psi_get_tableid(psi_table_get_section(pp_sections, 0)) == TSDT_TABLE_ID) 51 | psz_table_name = "TSDT"; 52 | 53 | switch (i_print_type) { 54 | case PRINT_XML: 55 | pf_print(opaque, "<%s version=\"%hhu\" current_next=\"%d\">", 56 | psz_table_name, 57 | psi_table_get_version(pp_sections), 58 | !psi_table_get_current(pp_sections) ? 0 : 1); 59 | break; 60 | default: 61 | pf_print(opaque, "new %s version=%hhu%s", 62 | psz_table_name, 63 | psi_table_get_version(pp_sections), 64 | !psi_table_get_current(pp_sections) ? " (next)" : ""); 65 | } 66 | 67 | for (i = 0; i <= i_last_section; i++) { 68 | uint8_t *p_section = psi_table_get_section(pp_sections, i); 69 | 70 | descl_print(cat_get_descl(p_section), cat_get_desclength(p_section), 71 | pf_print, opaque, NULL, NULL, i_print_type); 72 | } 73 | 74 | switch (i_print_type) { 75 | case PRINT_XML: 76 | pf_print(opaque, "", psz_table_name); 77 | break; 78 | default: 79 | pf_print(opaque, "end %s", psz_table_name); 80 | } 81 | } 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /mpeg/psi/desc_05.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_05.h: ISO/IEC 13818-1 Descriptor 0x05 (Registration descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_DESC_05_H__ 34 | #define __BITSTREAM_MPEG_DESC_05_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x05: Registration descriptor 46 | *****************************************************************************/ 47 | #define DESC05_HEADER_SIZE (DESC_HEADER_SIZE + 4) 48 | 49 | static inline void desc05_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x05); 52 | desc_set_length(p_desc, DESC05_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline void desc05_set_identifier(uint8_t *p_desc, const uint8_t p_id[4]) 56 | { 57 | p_desc[2] = p_id[0]; 58 | p_desc[3] = p_id[1]; 59 | p_desc[4] = p_id[2]; 60 | p_desc[5] = p_id[3]; 61 | } 62 | 63 | static inline const uint8_t *desc05_get_identifier(const uint8_t *p_desc) 64 | { 65 | return p_desc + 2; 66 | } 67 | 68 | static inline bool desc05_validate(const uint8_t *p_desc) 69 | { 70 | return desc_get_length(p_desc) >= DESC05_HEADER_SIZE - DESC_HEADER_SIZE; 71 | } 72 | 73 | static inline void desc05_print(const uint8_t *p_desc, f_print pf_print, 74 | void *opaque, print_type_t i_print_type) 75 | { 76 | switch (i_print_type) { 77 | case PRINT_XML: 78 | pf_print(opaque, "", 79 | desc05_get_identifier(p_desc)); 80 | break; 81 | default: 82 | pf_print(opaque, " - desc 05 registration identifier=%4.4s", 83 | desc05_get_identifier(p_desc)); 84 | } 85 | } 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /mpeg/psi/desc_06.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_06.h: ISO/IEC 13818-1 Descriptor 0x06 (Data stream alignment) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_DESC_06_H__ 34 | #define __BITSTREAM_MPEG_DESC_06_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x06: Data stream alignment descriptor 46 | *****************************************************************************/ 47 | #define DESC06_HEADER_SIZE (DESC_HEADER_SIZE + 1) 48 | 49 | static inline void desc06_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x06); 52 | desc_set_length(p_desc, DESC06_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline void desc06_set_alignment(uint8_t *p_desc, uint8_t alignment) 56 | { 57 | p_desc[2] = alignment; 58 | } 59 | 60 | static inline uint8_t desc06_get_alignment(const uint8_t *p_desc) 61 | { 62 | return p_desc[2]; 63 | } 64 | 65 | static inline const char *desc06_get_alignment_txt(uint8_t alignment) 66 | { 67 | return alignment == 0x00 ? "Reserved" : 68 | alignment == 0x01 ? "Slice, or video access unit or syncword" : 69 | alignment == 0x02 ? "Video access unit" : 70 | alignment == 0x03 ? "GOP, or SEQ" : 71 | alignment == 0x04 ? "SEQ" : "Reserved"; 72 | } 73 | 74 | static inline bool desc06_validate(const uint8_t *p_desc) 75 | { 76 | return desc_get_length(p_desc) >= DESC06_HEADER_SIZE - DESC_HEADER_SIZE; 77 | } 78 | 79 | static inline void desc06_print(const uint8_t *p_desc, f_print pf_print, 80 | void *opaque, print_type_t i_print_type) 81 | { 82 | switch (i_print_type) { 83 | case PRINT_XML: 84 | pf_print(opaque, "", 85 | desc06_get_alignment(p_desc), 86 | desc06_get_alignment_txt(desc06_get_alignment(p_desc))); 87 | break; 88 | default: 89 | pf_print(opaque, " - desc 06 data_stream_alignment alignment=%u alignment_txt=\"%s\"", 90 | desc06_get_alignment(p_desc), 91 | desc06_get_alignment_txt(desc06_get_alignment(p_desc))); 92 | } 93 | } 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /mpeg/psi/desc_08.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_08.h: ISO/IEC 13818-1 Descriptor 0x08 (Video Window descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_DESC_08_H__ 34 | #define __BITSTREAM_MPEG_DESC_08_H__ 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /***************************************************************************** 46 | * Descriptor 0x08: Video Window descriptor 47 | *****************************************************************************/ 48 | #define DESC08_HEADER_SIZE (DESC_HEADER_SIZE + 4) 49 | 50 | static inline void desc08_init(uint8_t *p_desc) 51 | { 52 | desc_set_tag(p_desc, 0x08); 53 | desc_set_length(p_desc, DESC08_HEADER_SIZE - DESC_HEADER_SIZE); 54 | } 55 | 56 | #define desc08_get_horizontal_offset desc07_get_horizontal_size 57 | #define desc08_set_horizontal_offset desc07_set_horizontal_size 58 | 59 | #define desc08_get_vertical_offset desc07_get_vertical_size 60 | #define desc08_set_vertical_offset desc07_set_vertical_size 61 | 62 | #define desc08_get_window_priority desc07_get_aspect_ratio_info 63 | #define desc08_set_window_priority desc07_set_aspect_ratio_info 64 | 65 | static inline bool desc08_validate(const uint8_t *p_desc) 66 | { 67 | return desc_get_length(p_desc) >= DESC08_HEADER_SIZE - DESC_HEADER_SIZE; 68 | } 69 | 70 | static inline void desc08_print(const uint8_t *p_desc, f_print pf_print, 71 | void *opaque, print_type_t i_print_type) 72 | { 73 | switch (i_print_type) { 74 | case PRINT_XML: 75 | pf_print(opaque, "", 76 | desc08_get_horizontal_offset(p_desc), 77 | desc08_get_vertical_offset(p_desc), 78 | desc08_get_window_priority(p_desc) 79 | ); 80 | break; 81 | default: 82 | pf_print(opaque, " - desc 08 video_window horizontal_offset=%u vertical_offset=%u window_priority=%u", 83 | desc08_get_horizontal_offset(p_desc), 84 | desc08_get_vertical_offset(p_desc), 85 | desc08_get_window_priority(p_desc) 86 | ); 87 | } 88 | } 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /mpeg/psi/desc_09.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_09.h: ISO/IEC 13818-1 Descriptor 0x09 (Conditional access descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * Georgi Chorbadzhiyski 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining 10 | * a copy of this software and associated documentation files (the 11 | * "Software"), to deal in the Software without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject 15 | * to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 24 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | *****************************************************************************/ 28 | 29 | /* 30 | * Normative references: 31 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 32 | */ 33 | 34 | #ifndef __BITSTREAM_MPEG_DESC_09_H__ 35 | #define __BITSTREAM_MPEG_DESC_09_H__ 36 | 37 | #include 38 | #include 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /***************************************************************************** 46 | * Descriptor 0x09: Conditional access descriptor 47 | *****************************************************************************/ 48 | #define DESC09_HEADER_SIZE (DESC_HEADER_SIZE + 4) 49 | 50 | static inline void desc09_init(uint8_t *p_desc) 51 | { 52 | desc_set_tag(p_desc, 0x09); 53 | desc_set_length(p_desc, DESC09_HEADER_SIZE - DESC_HEADER_SIZE); 54 | } 55 | 56 | static inline uint16_t desc09_get_sysid(const uint8_t *p_desc) 57 | { 58 | return (p_desc[2] << 8) | p_desc[3]; 59 | } 60 | 61 | static inline void desc09_set_sysid(uint8_t *p_desc, uint16_t i_sysid) 62 | { 63 | p_desc[2] = i_sysid >> 8; 64 | p_desc[3] = i_sysid & 0xff; 65 | } 66 | 67 | static inline uint16_t desc09_get_pid(const uint8_t *p_desc) 68 | { 69 | return ((p_desc[4] & 0x1f) << 8) | p_desc[5]; 70 | } 71 | 72 | static inline void desc09_set_pid(uint8_t *p_desc, uint16_t i_pid) 73 | { 74 | p_desc[4] = ((i_pid >> 8) & 0xff) | 0xE0; 75 | p_desc[5] = i_pid & 0xff; 76 | } 77 | 78 | static inline bool desc09_validate(const uint8_t *p_desc) 79 | { 80 | return desc_get_length(p_desc) >= DESC09_HEADER_SIZE - DESC_HEADER_SIZE; 81 | } 82 | 83 | static inline void desc09_print(const uint8_t *p_desc, f_print pf_print, 84 | void *opaque, print_type_t i_print_type) 85 | { 86 | switch (i_print_type) { 87 | case PRINT_XML: 88 | pf_print(opaque, "", 89 | desc09_get_sysid(p_desc), desc09_get_pid(p_desc)); 90 | break; 91 | default: 92 | pf_print(opaque, " - desc 09 ca sysid=0x%hx pid=%hu", 93 | desc09_get_sysid(p_desc), desc09_get_pid(p_desc)); 94 | } 95 | } 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /mpeg/psi/desc_0e.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_0e.h: ISO/IEC 13818-1 Descriptor 0x0e (Maximum bitrate descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_DESC_0E_H__ 34 | #define __BITSTREAM_MPEG_DESC_0E_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x0e: Maximum bitrate descriptor 46 | *****************************************************************************/ 47 | #define DESC0E_HEADER_SIZE (DESC_HEADER_SIZE + 3) 48 | 49 | static inline void desc0e_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x0E); 52 | desc_set_length(p_desc, DESC0E_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline uint32_t desc0e_get_max_bitrate(const uint8_t *p_desc) 56 | { 57 | return ((p_desc[2] &~ 0xc0) << 16) | (p_desc[3] << 8) | p_desc[4]; // 11xxxxxx xxxxxxxx xxxxxxxx 58 | } 59 | 60 | static inline void desc0e_set_max_bitrate(uint8_t *p_desc, uint32_t max_bitrate) 61 | { 62 | p_desc[2] = ((max_bitrate >> 16) & 0xff) | 0xc0; 63 | p_desc[3] = (max_bitrate >> 8) & 0xff; 64 | p_desc[4] = max_bitrate & 0xff; 65 | } 66 | 67 | static inline bool desc0e_validate(const uint8_t *p_desc) 68 | { 69 | return desc_get_length(p_desc) >= DESC0E_HEADER_SIZE - DESC_HEADER_SIZE; 70 | } 71 | 72 | static inline void desc0e_print(const uint8_t *p_desc, f_print pf_print, 73 | void *opaque, print_type_t i_print_type) 74 | { 75 | switch (i_print_type) { 76 | case PRINT_XML: 77 | pf_print(opaque, "", 78 | desc0e_get_max_bitrate(p_desc), desc0e_get_max_bitrate(p_desc) * 50); 79 | break; 80 | default: 81 | pf_print(opaque, " - desc 0e maximum_bitrate max_bitrate=%u max_bitrate_decoded=%u", 82 | desc0e_get_max_bitrate(p_desc), desc0e_get_max_bitrate(p_desc) * 50); 83 | } 84 | } 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /mpeg/psi/desc_0f.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_0f.h: ISO/IEC 13818-1 Descriptor 0x0f (Private data indicator) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_DESC_0F_H__ 34 | #define __BITSTREAM_MPEG_DESC_0F_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x0f: Private data indicator descriptor 46 | *****************************************************************************/ 47 | #define DESC0F_HEADER_SIZE (DESC_HEADER_SIZE + 4) 48 | 49 | static inline void desc0f_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x0F); 52 | desc_set_length(p_desc, DESC0F_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline uint32_t desc0f_get_private_indicator(const uint8_t *p_desc) 56 | { 57 | return (p_desc[2] << 24) | (p_desc[3] << 16) | (p_desc[4] << 8) | p_desc[5]; 58 | } 59 | 60 | static inline void desc0f_set_private_indicator(uint8_t *p_desc, uint32_t i_private_indicator) 61 | { 62 | p_desc[2] = (i_private_indicator >> 24) & 0xff; 63 | p_desc[3] = (i_private_indicator >> 16) & 0xff; 64 | p_desc[4] = (i_private_indicator >> 8) & 0xff; 65 | p_desc[5] = i_private_indicator & 0xff;; 66 | } 67 | 68 | static inline bool desc0f_validate(const uint8_t *p_desc) 69 | { 70 | return desc_get_length(p_desc) >= DESC0F_HEADER_SIZE - DESC_HEADER_SIZE; 71 | } 72 | 73 | static inline void desc0f_print(const uint8_t *p_desc, f_print pf_print, 74 | void *opaque, print_type_t i_print_type) 75 | { 76 | switch (i_print_type) { 77 | case PRINT_XML: 78 | pf_print(opaque, "", 79 | desc0f_get_private_indicator(p_desc)); 80 | break; 81 | default: 82 | pf_print(opaque, " - desc 0f private_data_indicator private_indicator=0x%08x", 83 | desc0f_get_private_indicator(p_desc)); 84 | } 85 | } 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /mpeg/psi/desc_10.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_10.h: ISO/IEC 13818-1 Descriptor 0x10 (Smoothing buffer descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_DESC_10_H__ 34 | #define __BITSTREAM_MPEG_DESC_10_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x10: Smoothing buffer descriptor 46 | *****************************************************************************/ 47 | #define DESC10_HEADER_SIZE (DESC_HEADER_SIZE + 6) 48 | 49 | static inline void desc10_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x10); 52 | desc_set_length(p_desc, DESC10_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline uint32_t desc10_get_sb_leak_rate(const uint8_t *p_desc) 56 | { 57 | return ((p_desc[2] &~ 0xc0) << 16) | (p_desc[3] << 8) | p_desc[4]; // 11xxxxxx xxxxxxxx xxxxxxxx; 58 | } 59 | 60 | static inline void desc10_set_sb_leak_rate(uint8_t *p_desc, uint32_t sb_leak_rate) 61 | { 62 | p_desc[2] = ((sb_leak_rate >> 16) & 0xff) | 0xc0; 63 | p_desc[3] = (sb_leak_rate >> 8) & 0xff; 64 | p_desc[4] = sb_leak_rate & 0xff; 65 | } 66 | 67 | static inline uint32_t desc10_get_sb_size(const uint8_t *p_desc) 68 | { 69 | return ((p_desc[5] &~ 0xc0) << 16) | (p_desc[6] << 8) | p_desc[7]; // 11xxxxxx xxxxxxxx xxxxxxxx; 70 | } 71 | 72 | static inline void desc10_set_sb_size(uint8_t *p_desc, uint32_t sb_size) 73 | { 74 | p_desc[5] = ((sb_size >> 16) & 0xff) | 0xc0; 75 | p_desc[6] = (sb_size >> 8) & 0xff; 76 | p_desc[7] = sb_size & 0xff; 77 | } 78 | 79 | static inline bool desc10_validate(const uint8_t *p_desc) 80 | { 81 | return desc_get_length(p_desc) >= DESC10_HEADER_SIZE - DESC_HEADER_SIZE; 82 | } 83 | 84 | static inline void desc10_print(const uint8_t *p_desc, f_print pf_print, 85 | void *opaque, print_type_t i_print_type) 86 | { 87 | switch (i_print_type) { 88 | case PRINT_XML: 89 | pf_print(opaque, "", 90 | desc10_get_sb_leak_rate(p_desc), desc10_get_sb_size(p_desc)); 91 | break; 92 | default: 93 | pf_print(opaque, " - desc 10 smoothing_buffer sb_leak_rate=%u sb_size=%u", 94 | desc10_get_sb_leak_rate(p_desc), desc10_get_sb_size(p_desc)); 95 | } 96 | } 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /mpeg/psi/desc_11.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_11.h: ISO/IEC 13818-1 Descriptor 0x11 (STD descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_DESC_11_H__ 34 | #define __BITSTREAM_MPEG_DESC_11_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x11: STD descriptor 46 | *****************************************************************************/ 47 | #define DESC11_HEADER_SIZE (DESC_HEADER_SIZE + 1) 48 | 49 | static inline void desc11_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x11); 52 | desc_set_length(p_desc, DESC11_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline void desc11_set_leak_valid_flag(uint8_t *p_desc, bool leak_valid_flag) 56 | { 57 | p_desc[2] = 0xfe | leak_valid_flag; 58 | } 59 | 60 | static inline bool desc11_get_leak_valid_flag(const uint8_t *p_desc) 61 | { 62 | return (p_desc[2] & 0x01) == 0x01; 63 | } 64 | 65 | static inline bool desc11_validate(const uint8_t *p_desc) 66 | { 67 | return desc_get_length(p_desc) >= DESC11_HEADER_SIZE - DESC_HEADER_SIZE; 68 | } 69 | 70 | static inline void desc11_print(const uint8_t *p_desc, f_print pf_print, 71 | void *opaque, print_type_t i_print_type) 72 | { 73 | switch (i_print_type) { 74 | case PRINT_XML: 75 | pf_print(opaque, "", 76 | desc11_get_leak_valid_flag(p_desc)); 77 | break; 78 | default: 79 | pf_print(opaque, " - desc 11 std leak_valid_flag=%u", 80 | desc11_get_leak_valid_flag(p_desc)); 81 | } 82 | } 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /mpeg/psi/desc_1b.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_1b.h: ISO/IEC 13818-1 Descriptor 0x1b (MPEG-4 video descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_DESC_1B_H__ 34 | #define __BITSTREAM_MPEG_DESC_1B_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x1b (MPEG-4 video descriptor) 46 | *****************************************************************************/ 47 | #define DESC1B_HEADER_SIZE (DESC_HEADER_SIZE + 1) 48 | 49 | static inline void desc1b_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x1b); 52 | desc_set_length(p_desc, DESC1B_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline bool desc1b_validate(const uint8_t *p_desc) 56 | { 57 | return desc_get_length(p_desc) >= DESC1B_HEADER_SIZE - DESC_HEADER_SIZE; 58 | } 59 | 60 | static inline uint8_t desc1b_get_mpeg4_visual_profile_and_level(const uint8_t *p_desc) { 61 | return p_desc[2]; 62 | } 63 | 64 | static inline void desc1b_set_mpeg4_visual_profile_and_level(uint8_t *p_desc, uint8_t i_mpeg4_visual_profile_and_level) { 65 | p_desc[2] = i_mpeg4_visual_profile_and_level; 66 | } 67 | 68 | static inline void desc1b_print(const uint8_t *p_desc, f_print pf_print, 69 | void *opaque, print_type_t i_print_type) 70 | { 71 | switch (i_print_type) { 72 | case PRINT_XML: 73 | pf_print(opaque, "", 74 | desc1b_get_mpeg4_visual_profile_and_level(p_desc)); 75 | break; 76 | default: 77 | pf_print(opaque," - desc 1b mpeg4_video visual_profile_and_level=0x%02x", 78 | desc1b_get_mpeg4_visual_profile_and_level(p_desc)); 79 | } 80 | } 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /mpeg/psi/desc_1c.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_1c.h: ISO/IEC 13818-1 Descriptor 0x1c (MPEG-4 audio descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_DESC_1C_H__ 34 | #define __BITSTREAM_MPEG_DESC_1C_H__ 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /***************************************************************************** 46 | * Descriptor 0x1c (MPEG-4 audio descriptor) 47 | *****************************************************************************/ 48 | #define DESC1C_HEADER_SIZE (DESC_HEADER_SIZE + 1) 49 | 50 | static inline void desc1c_init(uint8_t *p_desc) 51 | { 52 | desc_set_tag(p_desc, 0x1c); 53 | desc_set_length(p_desc, DESC1C_HEADER_SIZE - DESC_HEADER_SIZE); 54 | } 55 | 56 | #define desc1c_validate desc1b_validate 57 | #define desc1c_get_mpeg4_audio_profile_and_level desc1b_get_mpeg4_visual_profile_and_level 58 | #define desc1c_set_mpeg4_audio_profile_and_level desc1b_set_mpeg4_visual_profile_and_level 59 | 60 | static inline void desc1c_print(const uint8_t *p_desc, f_print pf_print, 61 | void *opaque, print_type_t i_print_type) 62 | { 63 | switch (i_print_type) { 64 | case PRINT_XML: 65 | pf_print(opaque, "", 66 | desc1c_get_mpeg4_audio_profile_and_level(p_desc)); 67 | break; 68 | default: 69 | pf_print(opaque," - desc 1c mpeg4_audio audio_profile_and_level=0x%02x", 70 | desc1c_get_mpeg4_audio_profile_and_level(p_desc)); 71 | } 72 | } 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /mpeg/psi/desc_1d.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_1d.h: ISO/IEC 13818-1 Descriptor 0x1d (IOD descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_DESC_1D_H__ 34 | #define __BITSTREAM_MPEG_DESC_1D_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x1d (IOD descriptor) 46 | *****************************************************************************/ 47 | #define DESC1D_HEADER_SIZE (DESC_HEADER_SIZE + 3) 48 | 49 | static inline void desc1d_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x1d); 52 | desc_set_length(p_desc, DESC1D_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline bool desc1d_validate(const uint8_t *p_desc) 56 | { 57 | return desc_get_length(p_desc) >= DESC1D_HEADER_SIZE - DESC_HEADER_SIZE; 58 | } 59 | 60 | static inline uint8_t desc1d_get_scope(const uint8_t *p_desc) { 61 | return p_desc[2]; 62 | } 63 | 64 | static inline void desc1d_set_scope(uint8_t *p_desc, uint8_t i_scope) { 65 | p_desc[2] = i_scope; 66 | } 67 | 68 | static inline uint8_t desc1d_get_iod_label(const uint8_t *p_desc) { 69 | return p_desc[3]; 70 | } 71 | 72 | static inline void desc1d_set_iod_label(uint8_t *p_desc, uint8_t i_iod_label) { 73 | p_desc[3] = i_iod_label; 74 | } 75 | 76 | static inline uint8_t desc1d_get_iod(const uint8_t *p_desc) { 77 | return p_desc[4]; 78 | } 79 | 80 | static inline void desc1d_set_iod(uint8_t *p_desc, uint8_t i_iod) { 81 | p_desc[4] = i_iod; 82 | } 83 | 84 | static inline void desc1d_print(const uint8_t *p_desc, f_print pf_print, 85 | void *opaque, print_type_t i_print_type) 86 | { 87 | switch (i_print_type) { 88 | case PRINT_XML: 89 | pf_print(opaque, "", 90 | desc1d_get_scope(p_desc), 91 | desc1d_get_iod_label(p_desc), 92 | desc1d_get_iod(p_desc)); 93 | break; 94 | default: 95 | pf_print(opaque," - desc 1d iod scope=0x%02x iod_label=0x%02x iod=0x%02x", 96 | desc1d_get_scope(p_desc), 97 | desc1d_get_iod_label(p_desc), 98 | desc1d_get_iod(p_desc)); 99 | } 100 | } 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /mpeg/psi/desc_1e.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_1e.h: ISO/IEC 13818-1 Descriptor 0x1e (SL descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_DESC_1e_H__ 34 | #define __BITSTREAM_MPEG_DESC_1e_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x1e (SL descriptor) 46 | *****************************************************************************/ 47 | #define DESC1E_HEADER_SIZE (DESC_HEADER_SIZE + 2) 48 | 49 | static inline void desc1e_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x1e); 52 | desc_set_length(p_desc, DESC1E_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline bool desc1e_validate(const uint8_t *p_desc) 56 | { 57 | return desc_get_length(p_desc) >= DESC1E_HEADER_SIZE - DESC_HEADER_SIZE; 58 | } 59 | 60 | static inline uint16_t desc1e_get_es_id(const uint8_t *p_desc) { 61 | return (p_desc[2] << 8) | p_desc[3]; 62 | } 63 | 64 | static inline void desc1e_set_es_id(uint8_t *p_desc, uint16_t i_es_id) { 65 | p_desc[2] = (i_es_id >> 8) & 0xff; 66 | p_desc[3] = i_es_id & 0xff; 67 | } 68 | 69 | static inline void desc1e_print(const uint8_t *p_desc, f_print pf_print, 70 | void *opaque, print_type_t i_print_type) 71 | { 72 | switch (i_print_type) { 73 | case PRINT_XML: 74 | pf_print(opaque, "", 75 | desc1e_get_es_id(p_desc)); 76 | break; 77 | default: 78 | pf_print(opaque," - desc 1e sl es_id=0x%04x", 79 | desc1e_get_es_id(p_desc)); 80 | } 81 | } 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /mpeg/psi/desc_20.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_20.h: ISO/IEC 13818-1 Descriptor 0x20 (External ES_ID descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_DESC_20_H__ 34 | #define __BITSTREAM_MPEG_DESC_20_H__ 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /***************************************************************************** 46 | * Descriptor 0x20 (External ES_ID descriptor) 47 | *****************************************************************************/ 48 | #define DESC20_HEADER_SIZE (DESC_HEADER_SIZE + 2) 49 | 50 | static inline void desc20_init(uint8_t *p_desc) 51 | { 52 | desc_set_tag(p_desc, 0x20); 53 | desc_set_length(p_desc, DESC20_HEADER_SIZE - DESC_HEADER_SIZE); 54 | } 55 | 56 | #define desc20_validate desc1e_validate 57 | #define desc20_get_external_es_id desc1e_get_es_id 58 | #define desc20_set_external_es_id desc1e_set_es_id 59 | 60 | static inline void desc20_print(const uint8_t *p_desc, f_print pf_print, 61 | void *opaque, print_type_t i_print_type) 62 | { 63 | switch (i_print_type) { 64 | case PRINT_XML: 65 | pf_print(opaque, "", 66 | desc20_get_external_es_id(p_desc)); 67 | break; 68 | default: 69 | pf_print(opaque," - desc 20 external_es_id external_es_id=0x%04x", 70 | desc20_get_external_es_id(p_desc)); 71 | } 72 | } 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /mpeg/psi/desc_23.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * desc_23.h: ISO/IEC 13818-1 Descriptor 0x23 (MultiplexBuffer descriptor) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_DESC_23_H__ 34 | #define __BITSTREAM_MPEG_DESC_23_H__ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * Descriptor 0x23 (MultiplexBuffer descriptor) 46 | *****************************************************************************/ 47 | #define DESC23_HEADER_SIZE (DESC_HEADER_SIZE + 6) 48 | 49 | static inline void desc23_init(uint8_t *p_desc) 50 | { 51 | desc_set_tag(p_desc, 0x23); 52 | desc_set_length(p_desc, DESC23_HEADER_SIZE - DESC_HEADER_SIZE); 53 | } 54 | 55 | static inline bool desc23_validate(const uint8_t *p_desc) 56 | { 57 | return desc_get_length(p_desc) >= DESC23_HEADER_SIZE - DESC_HEADER_SIZE; 58 | } 59 | 60 | static inline uint32_t desc23_get_mb_buffer_size(const uint8_t *p_desc) 61 | { 62 | return (p_desc[2] << 16) | (p_desc[3] << 8) | p_desc[4]; 63 | } 64 | 65 | static inline void desc23_set_mb_buffer_size(uint8_t *p_desc, uint32_t i_mb_buffer_size) 66 | { 67 | p_desc[2] = (i_mb_buffer_size >> 16) & 0xff; 68 | p_desc[3] = (i_mb_buffer_size >> 8) & 0xff; 69 | p_desc[4] = i_mb_buffer_size & 0xff; 70 | } 71 | 72 | static inline uint32_t desc23_get_tb_leak_rate(const uint8_t *p_desc) 73 | { 74 | return (p_desc[5] << 16) | (p_desc[6] << 8) | p_desc[7]; 75 | } 76 | 77 | static inline void desc23_set_tb_leak_rate(uint8_t *p_desc, uint32_t i_tb_leak_rate) 78 | { 79 | p_desc[5] = (i_tb_leak_rate >> 16) & 0xff; 80 | p_desc[6] = (i_tb_leak_rate >> 8) & 0xff; 81 | p_desc[7] = i_tb_leak_rate & 0xff; 82 | } 83 | 84 | static inline void desc23_print(const uint8_t *p_desc, f_print pf_print, 85 | void *opaque, print_type_t i_print_type) 86 | { 87 | switch (i_print_type) { 88 | case PRINT_XML: 89 | pf_print(opaque, "", 90 | desc23_get_mb_buffer_size(p_desc), 91 | desc23_get_tb_leak_rate(p_desc)); 92 | break; 93 | default: 94 | pf_print(opaque," - desc 23 multiplex_buffer mb_buffer_size=%u tb_leak_rate=%u", 95 | desc23_get_mb_buffer_size(p_desc), 96 | desc23_get_tb_leak_rate(p_desc)); 97 | } 98 | } 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /mpeg/psi/descs_list.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * descs_list.h: All supported ISO/IEC 13818-1 descriptors 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_MPEG_DESCS_LIST_H__ 29 | #define __BITSTREAM_MPEG_DESCS_LIST_H__ 30 | 31 | /* 32 | * 1. Keep the list ordered. 33 | * 2. When you are adding new descriptor here, make sure you also add 34 | * the needed code in bitstream/mpeg/psi/descs_print.h 35 | */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /mpeg/psi/pat_print.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * pat_print.h: ISO/IEC 13818-1 Program Allocation Table (PAT) (printing) 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_MPEG_PAT_PRINT_H__ 29 | #define __BITSTREAM_MPEG_PAT_PRINT_H__ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #ifdef __cplusplus 36 | extern "C" 37 | { 38 | #endif 39 | 40 | /***************************************************************************** 41 | * Program Association Table 42 | *****************************************************************************/ 43 | static inline void pat_table_print(uint8_t **pp_sections, f_print pf_print, 44 | void *opaque, print_type_t i_print_type) 45 | { 46 | uint8_t i_last_section = psi_table_get_lastsection(pp_sections); 47 | uint8_t i; 48 | 49 | switch (i_print_type) { 50 | case PRINT_XML: 51 | pf_print(opaque, "", 52 | psi_table_get_tableidext(pp_sections), 53 | psi_table_get_version(pp_sections), 54 | !psi_table_get_current(pp_sections) ? 0 : 1); 55 | break; 56 | default: 57 | pf_print(opaque, "new PAT tsid=%hu version=%hhu%s", 58 | psi_table_get_tableidext(pp_sections), 59 | psi_table_get_version(pp_sections), 60 | !psi_table_get_current(pp_sections) ? " (next)" : ""); 61 | } 62 | 63 | for (i = 0; i <= i_last_section; i++) { 64 | uint8_t *p_section = psi_table_get_section(pp_sections, i); 65 | const uint8_t *p_program; 66 | int j = 0; 67 | 68 | while ((p_program = pat_get_program(p_section, j)) != NULL) { 69 | uint16_t i_program = patn_get_program(p_program); 70 | uint16_t i_pid = patn_get_pid(p_program); 71 | j++; 72 | switch (i_print_type) { 73 | case PRINT_XML: 74 | pf_print(opaque, "", 75 | i_program, i_pid); 76 | break; 77 | default: 78 | if (i_program == 0) 79 | pf_print(opaque, " * NIT pid=%hu", i_pid); 80 | else 81 | pf_print(opaque, " * program number=%hu pid=%hu", 82 | i_program, i_pid); 83 | } 84 | } 85 | } 86 | 87 | switch (i_print_type) { 88 | case PRINT_XML: 89 | pf_print(opaque, ""); 90 | break; 91 | default: 92 | pf_print(opaque, "end PAT"); 93 | } 94 | } 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /mpeg/psi/tsdt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * tsdt.h: ISO/IEC 13818-1 Transport stream descriptor table (TSDT) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) 31 | */ 32 | 33 | #ifndef __BITSTREAM_MPEG_TSDT_H__ 34 | #define __BITSTREAM_MPEG_TSDT_H__ 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #ifdef __cplusplus 42 | extern "C" 43 | { 44 | #endif 45 | 46 | /***************************************************************************** 47 | * Transport stream descriptor table 48 | *****************************************************************************/ 49 | #define TSDT_PID 0x02 50 | #define TSDT_TABLE_ID 0x03 51 | #define TSDT_HEADER_SIZE PSI_HEADER_SIZE_SYNTAX1 52 | 53 | static inline void tsdt_init(uint8_t *p_tsdt) 54 | { 55 | psi_init(p_tsdt, true); 56 | psi_set_tableid(p_tsdt, TSDT_TABLE_ID); 57 | p_tsdt[1] &= ~0x40; 58 | psi_set_tableidext(p_tsdt, 0xffff); 59 | psi_set_section(p_tsdt, 0); 60 | psi_set_lastsection(p_tsdt, 0); 61 | } 62 | 63 | #define tsdt_set_length cat_set_length 64 | #define tsdt_get_desclength cat_get_desclength 65 | #define tsdt_set_desclength cat_set_desclength 66 | #define tsdt_get_descl cat_get_descl 67 | #define tsdt_get_descl_const cat_get_descl_const 68 | 69 | static inline bool tsdt_validate(const uint8_t *p_tsdt) 70 | { 71 | uint16_t i_section_size = psi_get_length(p_tsdt) + PSI_HEADER_SIZE 72 | - PSI_CRC_SIZE; 73 | 74 | if (!psi_get_syntax(p_tsdt) || psi_get_section(p_tsdt) 75 | || psi_get_lastsection(p_tsdt) 76 | || psi_get_tableid(p_tsdt) != TSDT_TABLE_ID) 77 | return false; 78 | 79 | if (i_section_size < TSDT_HEADER_SIZE 80 | || i_section_size < TSDT_HEADER_SIZE + tsdt_get_desclength(p_tsdt)) 81 | return false; 82 | 83 | if (!descl_validate(tsdt_get_descl_const(p_tsdt), tsdt_get_desclength(p_tsdt))) 84 | return false; 85 | 86 | return true; 87 | } 88 | 89 | #define tsdt_table_validate cat_table_validate 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /mpeg/psi/tsdt_print.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * tsdt_print.h: ISO/IEC 13818-1 Transport stream descriptor table (printing) 3 | ***************************************************************************** 4 | * Copyright (C) 2011 Unix Solutions Ltd. 5 | * 6 | * Authors: Georgi Chorbadzhiyski 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_MPEG_TSDT_PRINT_H__ 29 | #define __BITSTREAM_MPEG_TSDT_PRINT_H__ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" 39 | { 40 | #endif 41 | 42 | #define tsdt_table_print cat_table_print 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /mpeg/psi_print.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * psi_print.h: ISO/IEC 13818-1 Program Stream Information (printing) 3 | ***************************************************************************** 4 | * Copyright (C) 2010 VideoLAN 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | #ifndef __BITSTREAM_MPEG_PSI_PRINT_H__ 29 | #define __BITSTREAM_MPEG_PSI_PRINT_H__ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /smpte/2010.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 2010.h: SMPTE 2010 VANC mapping of SCTE 104 3 | ***************************************************************************** 4 | * Copyright (C) 2016 OpenHeadend 5 | * 6 | * Authors: Christophe Massiot 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - SMPTE 2010 31 | */ 32 | 33 | #ifndef __BITSTREAM_SMPTE_2010_H__ 34 | #define __BITSTREAM_SMPTE_2010_H__ 35 | 36 | #include /* uint8_t, uint16_t, etc... */ 37 | #include /* bool */ 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /***************************************************************************** 45 | * SMPTE 2010 ancillary data 46 | *****************************************************************************/ 47 | #define S2010_HEADER_SIZE 1 48 | 49 | #define S2010_VERSION 1 50 | 51 | static inline uint8_t s2010_get_version(const uint16_t *p_s2010) 52 | { 53 | return (p_s2010[0] & 0x18) >> 3; 54 | } 55 | 56 | static inline bool s2010_get_continued(const uint16_t *p_s2010) 57 | { 58 | return p_s2010[0] & 0x04; 59 | } 60 | 61 | static inline bool s2010_get_following(const uint16_t *p_s2010) 62 | { 63 | return p_s2010[0] & 0x02; 64 | } 65 | 66 | static inline bool s2010_get_duplicate(const uint16_t *p_s2010) 67 | { 68 | return p_s2010[0] & 0x01; 69 | } 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /smpte/352.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 352.h 3 | ***************************************************************************** 4 | * Copyright (C) 2018 Open Broadcast Systems Ltd 5 | * 6 | * Authors: Kieran Kunhya 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject 14 | * to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /* 29 | * Normative references: 30 | * - SMPTE 352 31 | */ 32 | 33 | #ifndef __BITSTREAM_SMPTE_352_H__ 34 | #define __BITSTREAM_SMPTE_352_H__ 35 | 36 | /* Payload and Digital Device Interface Identification */ 37 | #define S352_PAYLOAD_SD 0x81 38 | #define S352_PAYLOAD_720_INTERFACE_1_POINT_5_GBPS 0x84 39 | #define S352_PAYLOAD_1080_INTERFACE_1_POINT_5_GBPS 0x85 40 | #define S352_PAYLOAD_1080_INTERFACE_1_POINT_5_GBPS_DUAL_LINK 0x87 41 | #define S352_PAYLOAD_720_INTERFACE_3_GBPS_LEVEL_A 0x88 42 | #define S352_PAYLOAD_1080_INTERFACE_3_GBPS_LEVEL_A 0x89 43 | #define S352_PAYLOAD_1080_INTERFACE_3_GBPS_LEVEL_B 0x8a 44 | 45 | /* Scanning Method */ 46 | #define S352_TRANSPORT_INTERLACED 0 47 | #define S352_TRANSPORT_PROGRESSIVE 1 48 | 49 | #define S352_STRUCTURE_INTERLACED 0 50 | #define S352_STRUCTURE_PROGRESSIVE 1 51 | 52 | /* Picture Rate */ 53 | #define S352_PICTURE_RATE_UNDEFINED 0 54 | #define S352_PICTURE_RATE_24000_1001 2 55 | #define S352_PICTURE_RATE_24 3 56 | #define S352_PICTURE_RATE_48000_1001 4 57 | #define S352_PICTURE_RATE_25 5 58 | #define S352_PICTURE_RATE_30000_1001 6 59 | #define S352_PICTURE_RATE_30 7 60 | #define S352_PICTURE_RATE_48 8 61 | #define S352_PICTURE_RATE_50 9 62 | #define S352_PICTURE_RATE_60000_1001 10 63 | #define S352_PICTURE_RATE_60 11 64 | 65 | /* Sampling Structure Identification */ 66 | #define S352_ASPECT_RATIO_4_3 0 67 | #define S352_ASPECT_RATIO_16_9 1 68 | 69 | #define S352_SAMPLING_422_YCBCR 0 70 | #define S352_SAMPLING_444_YCBCR 1 71 | #define S352_SAMPLING_444_GBR 2 72 | #define S352_SAMPLING_420 3 73 | #define S352_SAMPLING_4224_YCBCRA 4 74 | #define S352_SAMPLING_4444_YCBCRA 5 75 | #define S352_SAMPLING_4444_GBRA 6 76 | #define S352_SAMPLING_2048_2_FS 7 77 | #define S352_SAMPLING_4224_YCBCRD 8 /* D = data channel */ 78 | #define S352_SAMPLING_4444_YCBCRD 9 79 | #define S352_SAMPLING_4444_GBRD 10 80 | #define S352_SAMPLING_444_XYZ 14 /* X'Y'Z' */ 81 | 82 | /* Bit Depth */ 83 | #define S352_BIT_DEPTH_8 0 84 | #define S352_BIT_DEPTH_10 1 85 | #define S352_BIT_DEPTH_12 2 /* mapped into 10-bit interface */ 86 | 87 | #endif 88 | --------------------------------------------------------------------------------