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_EIT_SECTION_H
23
#define _UCSI_DVB_EIT_SECTION_H 1
30
#include <libucsi/section.h>
31
#include <libucsi/dvb/types.h>
35
* dvb_eit_section structure.
37
struct dvb_eit_section {
38
struct section_ext head;
40
uint16_t transport_stream_id;
41
uint16_t original_network_id;
42
uint8_t segment_last_section_number;
43
uint8_t last_table_id;
44
/* struct eit_event events[] */
48
* An entry in the events field of a dvb_eit_section.
50
struct dvb_eit_event {
53
dvbduration_t duration;
54
EBIT3(uint16_t running_status : 3; ,
55
uint16_t free_ca_mode : 1; ,
56
uint16_t descriptors_loop_length:12; );
57
/* struct descriptor descriptors[] */
61
* Process a dvb_eit_section.
63
* @param section Pointer to a generic section_ext structure.
64
* @return Pointer to a dvb_eit_section, or NULL on error.
66
struct dvb_eit_section *dvb_eit_section_codec(struct section_ext *section);
69
* Accessor for the service_id field of an EIT.
71
* @param eit EIT pointer.
72
* @return The service_id.
74
static inline uint16_t dvb_eit_section_service_id(struct dvb_eit_section *eit)
76
return eit->head.table_id_ext;
80
* Iterator for the events field of a dvb_eit_section.
82
* @param eit dvb_eit_section pointer.
83
* @param pos Variable containing a pointer to the current dvb_eit_event.
85
#define dvb_eit_section_events_for_each(eit, pos) \
86
for ((pos) = dvb_eit_section_events_first(eit); \
88
(pos) = dvb_eit_section_events_next(eit, pos))
91
* Iterator for the descriptors field of a dvb_eit_event.
93
* @param eit dvb_eit_event pointer.
94
* @param pos Variable containing a pointer to the current descriptor.
96
#define dvb_eit_event_descriptors_for_each(event, pos) \
97
for ((pos) = dvb_eit_event_descriptors_first(event); \
99
(pos) = dvb_eit_event_descriptors_next(event, pos))
110
/******************************** PRIVATE CODE ********************************/
111
static inline struct dvb_eit_event *
112
dvb_eit_section_events_first(struct dvb_eit_section *eit)
114
size_t pos = sizeof(struct dvb_eit_section);
116
if (pos >= section_ext_length(&eit->head))
119
return (struct dvb_eit_event*) ((uint8_t *) eit + pos);
122
static inline struct dvb_eit_event *
123
dvb_eit_section_events_next(struct dvb_eit_section *eit,
124
struct dvb_eit_event *pos)
126
uint8_t *end = (uint8_t*) eit + section_ext_length(&eit->head);
127
uint8_t *next = (uint8_t *) pos +
128
sizeof(struct dvb_eit_event) +
129
pos->descriptors_loop_length;
134
return (struct dvb_eit_event *) next;
137
static inline struct descriptor *
138
dvb_eit_event_descriptors_first(struct dvb_eit_event * t)
140
if (t->descriptors_loop_length == 0)
143
return (struct descriptor *)
144
((uint8_t *) t + sizeof(struct dvb_eit_event));
147
static inline struct descriptor *
148
dvb_eit_event_descriptors_next(struct dvb_eit_event * t,
149
struct descriptor* pos)
151
return next_descriptor((uint8_t*) t + sizeof(struct dvb_eit_event),
152
t->descriptors_loop_length,