aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libucsi/dvb/sit_section.h
diff options
context:
space:
mode:
authoretobi <git@e-tobi.net>2013-09-03 09:48:41 +0200
committeretobi <git@e-tobi.net>2013-09-03 09:48:41 +0200
commitab959d7b4194715870128e616b8e29d4a101e488 (patch)
tree61a746231d30817be73416a7d67763fd677a1042 /lib/libucsi/dvb/sit_section.h
parent6b350466c4902c5b137e0efaf1d189128a7f18f5 (diff)
downloadlinux-dvb-apps-ab959d7b4194715870128e616b8e29d4a101e488.tar.gz
Imported Upstream version 1.1.1+rev1207upstream/1.1.1+rev1207
Diffstat (limited to 'lib/libucsi/dvb/sit_section.h')
-rw-r--r--lib/libucsi/dvb/sit_section.h173
1 files changed, 173 insertions, 0 deletions
diff --git a/lib/libucsi/dvb/sit_section.h b/lib/libucsi/dvb/sit_section.h
new file mode 100644
index 0000000..e06d596
--- /dev/null
+++ b/lib/libucsi/dvb/sit_section.h
@@ -0,0 +1,173 @@
+/*
+ * section and descriptor parser
+ *
+ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org)
+ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef _UCSI_DVB_SIT_SECTION_H
+#define _UCSI_DVB_SIT_SECTION_H 1
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <libucsi/section.h>
+
+/**
+ * dvb_sit_section structure.
+ */
+struct dvb_sit_section {
+ struct section_ext head;
+
+ EBIT2(uint16_t reserved : 4; ,
+ uint16_t transmission_info_loop_length :12; );
+ /* struct descriptor descriptors[] */
+ /* struct dvb_sit_service services[] */
+};
+
+/**
+ * An entry in the services field of a dvb_sit_section.
+ */
+struct dvb_sit_service {
+ uint16_t service_id;
+ EBIT3(uint16_t reserved : 1; ,
+ uint16_t running_status : 3; ,
+ uint16_t service_loop_length :12; );
+ /* struct descriptor descriptors[] */
+};
+
+/**
+ * Process a dvb_sit_section.
+ *
+ * @param section Generic section_ext structure.
+ * @return dvb_sit_section pointer, or NULL on error.
+ */
+struct dvb_sit_section * dvb_sit_section_codec(struct section_ext *section);
+
+/**
+ * Iterator for descriptors field in a dvb_sit_section.
+ *
+ * @param sit dvb_sit_section Pointer.
+ * @param pos Variable holding pointer to current descriptor.
+ */
+#define dvb_sit_section_descriptors_for_each(sit, pos) \
+ for ((pos) = dvb_sit_section_descriptors_first(sit); \
+ (pos); \
+ (pos) = dvb_sit_section_descriptors_first(sit))
+
+/**
+ * Iterator for services field in a dvb_sit_section.
+ *
+ * @param sit dvb_sit_section Pointer.
+ * @param pos Variable holding pointer to current dvb_sit_service.
+ */
+#define dvb_sit_section_services_for_each(sit, pos) \
+ for ((pos) = dvb_sit_section_services_first(sit); \
+ (pos); \
+ (pos) = dvb_sit_section_services_next(sit, pos))
+
+/**
+ * Iterator for descriptors field in a dvb_sit_service.
+ *
+ * @param service dvb_sit_service Pointer.
+ * @param pos Variable holding pointer to current descriptor.
+ */
+#define dvb_sit_service_descriptors_for_each(service, pos) \
+ for ((pos) = dvb_sit_service_descriptors_first(service); \
+ (pos); \
+ (pos) = dvb_sit_service_descriptors_next(service, pos))
+
+
+
+
+
+
+
+
+
+
+/******************************** PRIVATE CODE ********************************/
+static inline struct descriptor *
+ dvb_sit_section_descriptors_first(struct dvb_sit_section *sit)
+{
+ if (sit->transmission_info_loop_length == 0)
+ return NULL;
+
+ return (struct descriptor *)
+ ((uint8_t *) sit + sizeof(struct dvb_sit_section));
+}
+
+static inline struct descriptor *
+ dvb_sit_section_descriptors_next(struct dvb_sit_section *sit,
+ struct descriptor* pos)
+{
+ return next_descriptor((uint8_t*) sit + sizeof(struct dvb_sit_section),
+ sit->transmission_info_loop_length,
+ pos);
+}
+
+static inline struct dvb_sit_service *
+ dvb_sit_section_services_first(struct dvb_sit_section *sit)
+{
+ size_t pos = sizeof(struct dvb_sit_section) + sit->transmission_info_loop_length;
+
+ if (pos >= section_ext_length(&sit->head))
+ return NULL;
+
+ return (struct dvb_sit_service*) ((uint8_t *) sit + pos);
+}
+
+static inline struct dvb_sit_service *
+ dvb_sit_section_services_next(struct dvb_sit_section *sit,
+ struct dvb_sit_service *pos)
+{
+ uint8_t *end = (uint8_t*) sit + section_ext_length(&sit->head);
+ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_sit_service) +
+ pos->service_loop_length;
+
+ if (next >= end)
+ return NULL;
+
+ return (struct dvb_sit_service *) next;
+}
+
+static inline struct descriptor *
+ dvb_sit_service_descriptors_first(struct dvb_sit_service * t)
+{
+ if (t->service_loop_length == 0)
+ return NULL;
+
+ return (struct descriptor *)
+ ((uint8_t *) t + sizeof(struct dvb_sit_service));
+}
+
+static inline struct descriptor *
+ dvb_sit_service_descriptors_next(struct dvb_sit_service *t,
+ struct descriptor* pos)
pre { line-height: 125%; margin: 0; } td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; } span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; } td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * section and descriptor parser
 *
 * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org)
 * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */

#ifndef _UCSI_ATSC_DCCT_SECTION_H
#define _UCSI_ATSC_DCCT_SECTION_H 1

#ifdef __cplusplus
extern "C"
{
#endif

#include <libucsi/atsc/section.h>
#include <libucsi/atsc/types.h>

enum atsc_dcc_context {
	ATSC_DCC_CONTEXT_TEMPORARY_RETUNE = 0,
	ATSC_DCC_CONTEXT_CHANNEL_REDIRECT = 1,
};

enum atsc_dcc_selection_type {
	ATSC_DCC_SELECTION_UNCONDITIONAL_CHANNEL_CHANGE = 0x00,
	ATSC_DCC_SELECTION_NUMERIC_POSTAL_CODE_INCLUSION = 0x01,
	ATSC_DCC_SELECTION_ALPHANUMERIC_POSTAL_CODE_INCLUSION = 0x02,
	ATSC_DCC_SELECTION_DEMOGRAPHIC_CATEGORY_ONE_OR_MORE = 0x05,
	ATSC_DCC_SELECTION_DEMOGRAPHIC_CATEGORY_ALL = 0x06,
	ATSC_DCC_SELECTION_GENRE_CATEGORY_ONE_OR_MORE = 0x07,
	ATSC_DCC_SELECTION_GENRE_CATEGORY_ALL = 0x08,
	ATSC_DCC_SELECTION_CANNOT_BE_AUTHORIZED = 0x09,
	ATSC_DCC_SELECTION_GEOGRAPHIC_LOCATION_INCLUSION = 0x0c,
	ATSC_DCC_SELECTION_RATING_BLOCKED = 0x0d,
	ATSC_DCC_SELECTION_RETURN_TO_ORIGINAL_CHANNEL = 0x0f,
	ATSC_DCC_SELECTION_NUMERIC_POSTAL_CODE_EXCLUSION = 0x11,
	ATSC_DCC_SELECTION_ALPHANUMERIC_POSTAL_CODE_EXCLUSION = 0x12,
	ATSC_DCC_SELECTION_DEMOGRAPHIC_CATEGORY_NOT_ONE_OR_MORE = 0x15,
	ATSC_DCC_SELECTION_DEMOGRAPHIC_CATEGORY_NOT_ALL = 0x16,
	ATSC_DCC_SELECTION_GENRE_CATEGORY_NOT_ONE_OR_MORE = 0x17,
	ATSC_DCC_SELECTION_GENRE_CATEGORY_NOT_ALL = 0x18,
	ATSC_DCC_SELECTION_GEOGRAPHIC_LOCATION_EXCLUSION = 0x1c,
	ATSC_DCC_SELECTION_VIEWER_DIRECT_SELECT_A = 0x20,
	ATSC_DCC_SELECTION_VIEWER_DIRECT_SELECT_B = 0x21,
	ATSC_DCC_SELECTION_VIEWER_DIRECT_SELECT_C = 0x22,
	ATSC_DCC_SELECTION_VIEWER_DIRECT_SELECT_D = 0x23,
};

/**
 * atsc_dcct_section structure.
 */
struct atsc_dcct_section {
	struct atsc_section_psip head;

	uint8_t dcc_test_count;
	/* struct atsc_dcct_test tests */
	/* struct atsc_dcct_section_part2 part2 */
} __ucsi_packed;

struct atsc_dcct_test {
  EBIT4(uint32_t dcc_context			: 1; ,
	uint32_t reserved			: 3; ,
	uint32_t dcc_from_major_channel_number	:10; ,
	uint32_t dcc_from_minor_channel_number	:10; );
  EBIT3(uint32_t reserved1			: 4; ,
	uint32_t dcc_to_major_channel_number	:10; ,
	uint32_t dcc_to_minor_channel_number	:10; );
	atsctime_t start_time;
	atsctime_t end_time;
	uint8_t dcc_term_count;
	/* struct atsc_dcct_term terms */
	/* struct atsc_dcct_test_part2 part2 */
} __ucsi_packed;

struct atsc_dcct_term {
	uint8_t dcc_selection_type;
	uint64_t dcc_selection_id;
  EBIT2(uint16_t reserved			: 6; ,
	uint16_t descriptors_length		:10; );
	/* struct descriptor descriptors[] */
} __ucsi_packed;

struct atsc_dcct_test_part2 {
  EBIT2(uint16_t reserved			: 6; ,
	uint16_t descriptors_length		:10; );
	/* struct descriptor descriptors[] */
} __ucsi_packed;

struct atsc_dcct_section_part2 {
  EBIT2(uint16_t reserved			: 6; ,
	uint16_t descriptors_length		:10; );
	/* struct descriptor descriptors[] */
} __ucsi_packed;

static inline struct atsc_dcct_test *
	atsc_dcct_section_tests_first(struct atsc_dcct_section *dcct);
static inline struct atsc_dcct_test *
	atsc_dcct_section_tests_next(struct atsc_dcct_section *dcct,
				     struct atsc_dcct_test *pos,
				     int idx);
static inline struct atsc_dcct_term *
	atsc_dcct_test_terms_first(struct atsc_dcct_test *test);
static inline struct atsc_dcct_term *
	atsc_dcct_test_terms_next(struct atsc_dcct_test *test,
				  struct atsc_dcct_term *pos,
				  int idx);


/**
 * Process an atsc_dcct_section.
 *
 * @param section Pointer to an atsc_section_psip structure.
 * @return atsc_dcct_section pointer, or NULL on error.
 */
struct atsc_dcct_section *atsc_dcct_section_codec(struct atsc_section_psip *section);

/**
 * Accessor for the dcc_subtype field of a dcct.
 *
 * @param dcct dcct pointer.
 * @return The dcc_subtype.
 */
static inline uint8_t atsc_dcct_section_dcc_subtype(struct atsc_dcct_section *dcct)
{
	return dcct->head.ext_head.table_id_ext >> 8;
}

/**
 * Accessor for the dcc_id field of a dcct.
 *
 * @param dcct dcct pointer.
 * @return The dcc_id.
 */
static inline uint8_t atsc_dcct_section_dcc_id(struct atsc_dcct_section *dcct)
{
	return dcct->head.ext_head.table_id_ext & 0xff;
}

/**
 * Iterator for the tests field in an atsc_dcct_section.
 *
 * @param dcct atsc_dcct_section pointer.
 * @param pos Variable containing a pointer to the current atsc_dcct_test.
 * @param idx Integer used to count which test we are in.
 */
#define atsc_dcct_section_tests_for_each(dcct, pos, idx) \
	for ((pos) = atsc_dcct_section_tests_first(dcct), idx=0; \
	     (pos); \
	     (pos) = atsc_dcct_section_tests_next(dcct, pos, ++idx))

/**
 * Iterator for the terms field in an atsc_dcct_test.
 *
 * @param test atsc_dcct_test pointer.
 * @param pos Variable containing a pointer to the current atsc_dcct_term.
 * @param idx Integer used to count which test we are in.
 */
#define atsc_dcct_test_terms_for_each(test, pos, idx) \
	for ((pos) = atsc_dcct_test_terms_first(test), idx=0; \
	     (pos); \
	     (pos) = atsc_dcct_test_terms_next(test, pos, ++idx))

/**
 * Iterator for the descriptors field in a atsc_dcct_term structure.
 *
 * @param term atsc_dcct_term pointer.
 * @param pos Variable containing a pointer to the current descriptor.
 */
#define atsc_dcct_term_descriptors_for_each(term, pos) \
	for ((pos) = atsc_dcct_term_descriptors_first(term); \
	     (pos); \
	     (pos) = atsc_dcct_term_descriptors_next(term, pos))

/**
 * Accessor for the part2 field of an atsc_dcct_test.
 *
 * @param test atsc_dcct_test pointer.
 * @return struct atsc_dcct_test_part2 pointer.
 */
static inline struct atsc_dcct_test_part2 *atsc_dcct_test_part2(struct atsc_dcct_test *test)
{
	int pos = sizeof(struct atsc_dcct_test);

	struct atsc_dcct_term *cur_term;
	int idx;
	atsc_dcct_test_terms_for_each(test, cur_term, idx) {
		pos += sizeof(struct atsc_dcct_term);
		pos += cur_term->descriptors_length;
	}

	return (struct atsc_dcct_test_part2 *) (((uint8_t*) test) + pos);
}

/**
 * Iterator for the descriptors field in a atsc_dcct_test_part2 structure.
 *
 * @param term atsc_dcct_test_part2 pointer.
 * @param pos Variable containing a pointer to the current descriptor.
 */
#define atsc_dcct_test_part2_descriptors_for_each(part2, pos) \
	for ((pos) = atsc_dcct_test_part2_descriptors_first(part2); \
	     (pos); \
	     (pos) = atsc_dcct_test_part2_descriptors_next(part2, pos))

/**
 * Accessor for the part2 field of an atsc_dcct_section.
 *
 * @param dcct atsc_dcct_section pointer.
 * @return struct atsc_dcct_section_part2 pointer.
 */
static inline struct atsc_dcct_section_part2 *atsc_dcct_section_part2(struct atsc_dcct_section *dcct)
{
	int pos = sizeof(struct atsc_dcct_section);

	struct atsc_dcct_test *cur_test;
	int testidx;
	atsc_dcct_section_tests_for_each(dcct, cur_test, testidx) {
		struct atsc_dcct_test_part2 *part2 = atsc_dcct_test_part2(cur_test);
		pos += ((uint8_t*) part2 - (uint8_t*) cur_test);

		pos += sizeof(struct atsc_dcct_test_part2);
		pos += part2->descriptors_length;
	}

	return (struct atsc_dcct_section_part2 *) (((uint8_t*) dcct) + pos);
}

/**
 * Iterator for the descriptors field in a atsc_dcct_section_part2 structure.
 *
 * @param part2 atsc_dcct_section_part2 pointer.
 * @param pos Variable containing a pointer to the current descriptor.
 */
#define atsc_dcct_section_part2_descriptors_for_each(part2, pos) \
	for ((pos) = atsc_dcct_section_part2_descriptors_first(part2); \
	     (pos); \
	     (pos) = atsc_dcct_section_part2_descriptors_next(part2, pos))











/******************************** PRIVATE CODE ********************************/
static inline struct atsc_dcct_test *
	atsc_dcct_section_tests_first(struct atsc_dcct_section *dcct)
{
	size_t pos = sizeof(struct atsc_dcct_section);

	if (dcct->dcc_test_count == 0)
		return NULL;

	return (struct atsc_dcct_test*) (((uint8_t *) dcct) + pos);
}

static inline struct atsc_dcct_test *
	atsc_dcct_section_tests_next(struct atsc_dcct_section *dcct,
				     struct atsc_dcct_test *pos,
				     int idx)
{
	if (idx >= dcct->dcc_test_count)
		return NULL;

	struct atsc_dcct_test_part2 *part2 = atsc_dcct_test_part2(pos);
	int len = sizeof(struct atsc_dcct_test_part2);
	len += part2->descriptors_length;

	return (struct atsc_dcct_test *) (((uint8_t*) part2) + len);
}

static inline struct atsc_dcct_term *
	atsc_dcct_test_terms_first(struct atsc_dcct_test *test)
{
	size_t pos = sizeof(struct atsc_dcct_test);

	if (test->dcc_term_count == 0)
		return NULL;

	return (struct atsc_dcct_term*) (((uint8_t *) test) + pos);
}

static inline struct atsc_dcct_term *
	atsc_dcct_test_terms_next(struct atsc_dcct_test *test,
				  struct atsc_dcct_term *pos,
				  int idx)
{
	if (idx >= test->dcc_term_count)
		return NULL;

	int len = sizeof(struct atsc_dcct_term);
	len += pos->descriptors_length;

	return (struct atsc_dcct_term *) (((uint8_t*) pos) + len);
}

static inline struct descriptor *
	atsc_dcct_term_descriptors_first(struct atsc_dcct_term *term)
{
	size_t pos = sizeof(struct atsc_dcct_term);

	if (term->descriptors_length == 0)
		return NULL;

	return (struct descriptor*) (((uint8_t *) term) + pos);
}

static inline struct descriptor *
	atsc_dcct_term_descriptors_next(struct atsc_dcct_term *term,
					struct descriptor *pos)
{
	return next_descriptor((uint8_t*) term + sizeof(struct atsc_dcct_term),
				term->descriptors_length,
				pos);
}

static inline struct descriptor *
	atsc_dcct_test_part2_descriptors_first(struct atsc_dcct_test_part2 *part2)
{
	size_t pos = sizeof(struct atsc_dcct_test_part2);

	if (part2->descriptors_length == 0)
		return NULL;

	return (struct descriptor*) (((uint8_t *) part2) + pos);
}

static inline struct descriptor *
	atsc_dcct_test_part2_descriptors_next(struct atsc_dcct_test_part2 *part2,
					      struct descriptor *pos)
{
	return next_descriptor((uint8_t*) part2 + sizeof(struct atsc_dcct_test_part2),
				part2->descriptors_length,
				pos);
}

static inline struct descriptor *
	atsc_dcct_section_part2_descriptors_first(struct atsc_dcct_section_part2 *part2)
{
	size_t pos = sizeof(struct atsc_dcct_section_part2);

	if (part2->descriptors_length == 0)
		return NULL;

	return (struct descriptor*) (((uint8_t *) part2) + pos);
}

static inline struct descriptor *
	atsc_dcct_section_part2_descriptors_next(struct atsc_dcct_section_part2 *part2,
						 struct descriptor *pos)
{
	return next_descriptor((uint8_t*) part2 + sizeof(struct atsc_dcct_section_part2),
				part2->descriptors_length,
				pos);
}


#ifdef __cplusplus
}
#endif

#endif