diff --git a/README b/README index c9b0002..cace38e 100644 --- a/README +++ b/README @@ -130,6 +130,7 @@ Supported DVB descriptors * Descriptor 0x5e: Multilingual component descriptor * Descriptor 0x5f: Private data specifier descriptor * Descriptor 0x60: Service move descriptor + * Descriptor 0x61: Short smoothing buffer descriptor * Descriptor 0x6a: AC-3 descriptor [p] Legend: diff --git a/TODO b/TODO index d017d63..d45777d 100644 --- a/TODO +++ b/TODO @@ -14,7 +14,6 @@ so if you like something just do it and send a patch. - Descriptor 0x6a: AC-3 descriptor - Add support (parser, generator, example) for these DVB descriptors: - - Descriptor 0x61: short_smoothing_buffer_descriptor - Descriptor 0x62: frequency_list_descriptor - Descriptor 0x63: partial_transport_stream_descriptor - Descriptor 0x64: data_broadcast_descriptor diff --git a/dvb/si/desc_61.h b/dvb/si/desc_61.h new file mode 100644 index 0000000..7cccf52 --- /dev/null +++ b/dvb/si/desc_61.h @@ -0,0 +1,102 @@ +/***************************************************************************** + * desc_61.h: ETSI EN 300 468 Descriptor 0x61: Short smoothing buffer + ***************************************************************************** + * Copyright (C) 2011 Unix Solutions Ltd. + * + * Authors: Georgi Chorbadzhiyski + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + *****************************************************************************/ + +/* + * Normative references: + * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems) + */ + +#ifndef __BITSTREAM_DVB_DESC_61_H__ +#define __BITSTREAM_DVB_DESC_61_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/***************************************************************************** + * Descriptor 0x61: Short smoothing buffer descriptor + *****************************************************************************/ +#define DESC61_HEADER_SIZE (DESC_HEADER_SIZE + 1) + +static inline void desc61_init(uint8_t *p_desc) +{ + desc_set_tag(p_desc, 0x61); + desc_set_length(p_desc, DESC61_HEADER_SIZE - DESC_HEADER_SIZE); +} + +static inline uint8_t desc61_get_sb_size(const uint8_t *p_desc) +{ + return p_desc[2] >> 6; +} + +static inline void desc61_set_sb_size(uint8_t *p_desc, uint8_t i_sb_size) +{ + p_desc[2] = (p_desc[2] & 0x3f) | (i_sb_size << 6); +} + +static inline uint8_t desc61_get_sb_leak_rate(const uint8_t *p_desc) +{ + return p_desc[2] & 0x3f; +} + +static inline void desc61_set_sb_leak_rate(uint8_t *p_desc, uint8_t i_sb_leak_rate) +{ + p_desc[2] = (p_desc[2] & 0xc0) | (i_sb_leak_rate & 0x3f); +} + +static inline bool desc61_validate(const uint8_t *p_desc) +{ + return desc_get_length(p_desc) >= DESC61_HEADER_SIZE - DESC_HEADER_SIZE; +} + +static inline void desc61_print(const uint8_t *p_desc, f_print pf_print, + void *opaque, print_type_t i_print_type) +{ + switch (i_print_type) { + case PRINT_XML: + pf_print(opaque, "", + desc61_get_sb_size(p_desc), + desc61_get_sb_leak_rate(p_desc) + ); + break; + default: + pf_print(opaque, " - desc 61 short_smoothing_buffer sb_size=%u sb_leak_rate=%u", + desc61_get_sb_size(p_desc), + desc61_get_sb_leak_rate(p_desc) + ); + } +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dvb/si/descs_list.h b/dvb/si/descs_list.h index 2ca45c5..2f95d31 100644 --- a/dvb/si/descs_list.h +++ b/dvb/si/descs_list.h @@ -67,6 +67,7 @@ #include #include #include +#include #include #include #include diff --git a/examples/dvb_gen_si.c b/examples/dvb_gen_si.c index 4c82f2e..936f61d 100644 --- a/examples/dvb_gen_si.c +++ b/examples/dvb_gen_si.c @@ -1008,7 +1008,13 @@ static void build_desc60(uint8_t *desc) { desc60_set_new_service_id(desc, 20000); } -/* --- Descriptor 0x61: short_smoothing_buffer_descriptor */ +/* DVB Descriptor 0x61: Short smoothing buffer descriptor */ +static void build_desc61(uint8_t *desc) { + desc61_init(desc); + desc61_set_sb_size(desc, 1); // 1536 bytes buffer size + desc61_set_sb_leak_rate(desc, 10); // 0.5 Mbit/s +} + /* --- Descriptor 0x62: frequency_list_descriptor */ /* --- Descriptor 0x63: partial_transport_stream_descriptor */ /* --- Descriptor 0x64: data_broadcast_descriptor */ @@ -1701,6 +1707,9 @@ static void generate_eit(void) { desc = descs_get_desc(desc_loop, desc_counter++); build_desc4d(desc); + desc = descs_get_desc(desc_loop, desc_counter++); + build_desc61(desc); + // Finish descriptor generation desc = descs_get_desc(desc_loop, desc_counter); // Get next descriptor pos descs_set_length(desc_loop, desc - desc_loop - DESCS_HEADER_SIZE); diff --git a/examples/dvb_print_si.output.txt b/examples/dvb_print_si.output.txt index e0952a9..b093e64 100644 --- a/examples/dvb_print_si.output.txt +++ b/examples/dvb_print_si.output.txt @@ -120,6 +120,7 @@ new EIT tableid=0x4e type=actual_pf version=1 tsid=10000 onid=40000 seg_last_sec - extended_event_item description="Year" text="2011" - extended_event_item description="Rating" text="***++" - desc 4d short_event lang=eng event_name="Major TV event" text="The event of the century!" + - desc 61 short_smoothing_buffer sb_size=1 sb_leak_rate=10 * EVENT id=30200 start_time=999999999 start_time_dec="2001-09-09 01:46:39 UTC" duration=7200 duration_dec=02:00:00 running_status=0 free_CA_mode=0 - desc 54 content content_l1=2 content_l2=4 user=78 - desc 54 content content_l1=6 content_l2=8 user=177 diff --git a/examples/dvb_print_si.output.xml b/examples/dvb_print_si.output.xml index e2f1987..2406c6a 100644 --- a/examples/dvb_print_si.output.xml +++ b/examples/dvb_print_si.output.xml @@ -206,6 +206,9 @@ + + + diff --git a/mpeg/psi/descs_print.h b/mpeg/psi/descs_print.h index a789ce5..5eb3c33 100644 --- a/mpeg/psi/descs_print.h +++ b/mpeg/psi/descs_print.h @@ -161,6 +161,7 @@ static inline void descl_print(uint8_t *p_descl, uint16_t i_length, CASE_DESC_ICONV(5d) CASE_DESC_ICONV(5e) CASE_DESC(60) + CASE_DESC(61) CASE_DESC(6a) #undef CASE_DESC