2
* section and descriptor parser
4
* Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org)
5
* Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net)
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22
#ifndef _UCSI_DVB_SDT_SECTION_H
23
#define _UCSI_DVB_SDT_SECTION_H 1
30
#include <libucsi/section.h>
33
* dvb_sdt_section structure.
35
struct dvb_sdt_section {
36
struct section_ext head;
38
uint16_t original_network_id;
40
/* struct dvb_sdt_service services[] */
44
* An entry in the services field of a dvb_sdt_section.
46
struct dvb_sdt_service {
48
EBIT3(uint8_t reserved : 6; ,
49
uint8_t eit_schedule_flag : 1; ,
50
uint8_t eit_present_following_flag : 1; );
51
EBIT3(uint16_t running_status : 3; ,
52
uint16_t free_ca_mode : 1; ,
53
uint16_t descriptors_loop_length :12; );
54
/* struct descriptor descriptors[] */
58
* Process a dvb_sdt_section.
60
* @param section Pointer to a generic section_ext structure.
61
* @return dvb_sdt_section pointer, or NULL on error.
63
struct dvb_sdt_section * dvb_sdt_section_codec(struct section_ext *section);
66
* Accessor for the transport_stream_id field of an SDT.
68
* @param sdt SDT pointer.
69
* @return The transport_stream_id.
71
static inline uint16_t dvb_sdt_section_transport_stream_id(struct dvb_sdt_section *sdt)
73
return sdt->head.table_id_ext;
77
* Iterator for the services field in a dvb_sdt_section.
79
* @param sdt dvb_sdt_section pointer.
80
* @param pos Variable containing a pointer to the current dvb_sdt_service.
82
#define dvb_sdt_section_services_for_each(sdt, pos) \
83
for ((pos) = dvb_sdt_section_services_first(sdt); \
85
(pos) = dvb_sdt_section_services_next(sdt, pos))
88
* Iterator for the descriptors field in a dvb_sdt_service.
90
* @param service dvb_sdt_service pointer.
91
* @param pos Variable containing a pointer to the current descriptor.
93
#define dvb_sdt_service_descriptors_for_each(service, pos) \
94
for ((pos) = dvb_sdt_service_descriptors_first(service); \
96
(pos) = dvb_sdt_service_descriptors_next(service, pos))
108
/******************************** PRIVATE CODE ********************************/
109
static inline struct dvb_sdt_service *
110
dvb_sdt_section_services_first(struct dvb_sdt_section * sdt)
112
size_t pos = sizeof(struct dvb_sdt_section);
114
if (pos >= section_ext_length(&sdt->head))
117
return (struct dvb_sdt_service*) ((uint8_t *) sdt + pos);
120
static inline struct dvb_sdt_service *
121
dvb_sdt_section_services_next(struct dvb_sdt_section * sdt,
122
struct dvb_sdt_service * pos)
124
uint8_t *end = (uint8_t*) sdt + section_ext_length(&sdt->head);
125
uint8_t *next = (uint8_t*) pos + sizeof(struct dvb_sdt_service) +
126
pos->descriptors_loop_length;
131
return (struct dvb_sdt_service *) next;
134
static inline struct descriptor *
135
dvb_sdt_service_descriptors_first(struct dvb_sdt_service *svc)
137
if (svc->descriptors_loop_length == 0)
140
return (struct descriptor *)
141
((uint8_t*) svc + sizeof(struct dvb_sdt_service));
144
static inline struct descriptor *
145
dvb_sdt_service_descriptors_next(struct dvb_sdt_service *svc,
146
struct descriptor* pos)
148
return next_descriptor((uint8_t*) svc + sizeof(struct dvb_sdt_service),
149
svc->descriptors_loop_length,