aboutsummaryrefslogtreecommitdiffstats
path: root/dvb-t/sk-Medzev
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2013-11-04 23:06:50 +0000
committerJonathan McCrohan <jmccrohan@gmail.com>2013-11-04 23:06:50 +0000
commit01e07222f7b63defc4ebb4aec3c485e25af017e9 (patch)
tree5a50f7cc5c7e785c4a0cc1d68a5f36da61514999 /dvb-t/sk-Medzev
parent4532828bb8ad8e0075195947944d2a284a2a7ab0 (diff)
downloaddtv-scan-tables-01e07222f7b63defc4ebb4aec3c485e25af017e9.tar.gz
Imported Upstream version 0+git20131101.75f3b39upstream/0+git20131101.75f3b39
Diffstat (limited to 'dvb-t/sk-Medzev')
0 files changed, 0 insertions, 0 deletions
id='n113' href='#n113'>113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
/*
 * 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_CVCT_SECTION_H
#define _UCSI_ATSC_CVCT_SECTION_H 1

#ifdef __cplusplus
extern "C"
{
#endif

#include <libucsi/atsc/section.h>

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

	uint8_t num_channels_in_section;
	/* struct atsc_cvct_channel channels[] */
 	/* struct atsc_cvct_channel_part2 part2 */
} __ucsi_packed;

struct atsc_cvct_channel {
	uint16_t short_name[7]; // UTF-16 network ordered
  EBIT4(uint32_t reserved			: 4; ,
	uint32_t major_channel_number		:10; ,
  	uint32_t minor_channel_number		:10; ,
	uint32_t modulation_mode		: 8; );
	uint32_t carrier_frequency;
	uint16_t channel_TSID;
	uint16_t program_number;
  EBIT8(uint16_t ETM_location			: 2; ,
	uint16_t access_controlled		: 1; ,
	uint16_t hidden				: 1; ,
	uint16_t path_select			: 1; ,
	uint16_t out_of_band			: 1; ,
	uint16_t hide_guide			: 1; ,
	uint16_t reserved2			: 3; ,
	uint16_t service_type			: 6; );
	uint16_t source_id;
  EBIT2(uint16_t reserved3			: 6; ,
	uint16_t descriptors_length		:10; );
	/* struct descriptor descriptors[] */
} __ucsi_packed;

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

static inline struct atsc_cvct_channel *atsc_cvct_section_channels_first(struct atsc_cvct_section *cvct);
static inline struct atsc_cvct_channel *
	atsc_cvct_section_channels_next(struct atsc_cvct_section *cvct, struct atsc_cvct_channel *pos, int idx);

/**
 * Process a atsc_cvct_section.
 *
 * @param section Pointer to anj atsc_section_psip structure.
 * @return atsc_cvct_section pointer, or NULL on error.
 */
struct atsc_cvct_section *atsc_cvct_section_codec(struct atsc_section_psip *section);

/**
 * Accessor for the transport_stream_id field of a CVCT.
 *
 * @param cvdt CVDT pointer.
 * @return The transport_stream_id.
 */
static inline uint16_t atsc_cvct_section_transport_stream_id(struct atsc_cvct_section *cvct)
{
	return cvct->head.ext_head.table_id_ext;
}

/**
 * Iterator for the tables field in an atsc_cvct_section.
 *
 * @param mgt atsc_cvct_section pointer.
 * @param pos Variable containing a pointer to the current atsc_cvct_channel.
 * @param idx Integer used to count which table we in.
 */
#define atsc_cvct_section_channels_for_each(mgt, pos, idx) \
	for ((pos) = atsc_cvct_section_channels_first(mgt), idx=0; \
	     (pos); \
	     (pos) = atsc_cvct_section_channels_next(mgt, pos, ++idx))

/**
 * Iterator for the descriptors field in a atsc_cvct_channel structure.
 *
 * @param table atsc_cvct_channel pointer.
 * @param pos Variable containing a pointer to the current descriptor.
 */
#define atsc_cvct_channel_descriptors_for_each(table, pos) \
	for ((pos) = atsc_cvct_channel_descriptors_first(table); \
	     (pos); \
	     (pos) = atsc_cvct_channel_descriptors_next(table, pos))

/**
 * Accessor for the second part of an atsc_cvct_section.
 *
 * @param mgt atsc_cvct_section pointer.
 * @return atsc_cvct_section_part2 pointer.
 */
static inline struct atsc_cvct_section_part2 *
	atsc_cvct_section_part2(struct atsc_cvct_section *mgt)
{
	int pos = sizeof(struct atsc_cvct_section);

	struct atsc_cvct_channel *cur_table;
	int idx;
	atsc_cvct_section_channels_for_each(mgt, cur_table, idx) {
		pos += sizeof(struct atsc_cvct_channel);
		pos += cur_table->descriptors_length;
	}

	return (struct atsc_cvct_section_part2 *) (((uint8_t*) mgt) + pos);
}

/**
 * Iterator for the descriptors field in a atsc_cvct_section structure.
 *
 * @param part2 atsc_cvct_section_part2 pointer.
 * @param pos Variable containing a pointer to the current descriptor.
 */
#define atsc_cvct_section_part2_descriptors_for_each(part2, pos) \
	for ((pos) = atsc_cvct_section_part2_descriptors_first(part2); \
	     (pos); \
	     (pos) = atsc_cvct_section_part2_descriptors_next(part2, pos))











/******************************** PRIVATE CODE ********************************/
static inline struct atsc_cvct_channel *
	atsc_cvct_section_channels_first(struct atsc_cvct_section *cvct)
{
	size_t pos = sizeof(struct atsc_cvct_section);

	if (cvct->num_channels_in_section == 0)
		return NULL;

	return (struct atsc_cvct_channel*) (((uint8_t *) cvct) + pos);
}

static inline struct atsc_cvct_channel *
	atsc_cvct_section_channels_next(struct atsc_cvct_section *cvct,
				     struct atsc_cvct_channel *pos,
				     int idx)
{
	if (idx >= cvct->num_channels_in_section)
		return NULL;

	return (struct atsc_cvct_channel *)
		(((uint8_t*) pos) + sizeof(struct atsc_cvct_channel) + pos->descriptors_length);
}

static inline struct descriptor *
	atsc_cvct_channel_descriptors_first(struct atsc_cvct_channel *table)
{
	size_t pos = sizeof(struct atsc_cvct_channel);

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

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

static inline struct descriptor *
	atsc_cvct_channel_descriptors_next(struct atsc_cvct_channel *table,
					struct descriptor *pos)
{
	return next_descriptor((uint8_t*) table + sizeof(struct atsc_cvct_channel),
				table->descriptors_length,
				pos);
}

static inline struct descriptor *
	atsc_cvct_section_part2_descriptors_first(struct atsc_cvct_section_part2 *part2)
{
	size_t pos = sizeof(struct atsc_cvct_section_part2);

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

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

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

#ifdef __cplusplus
}
#endif

#endif