~ubuntu-branches/ubuntu/precise/me-tv/precise-proposed

« back to all changes in this revision

Viewing changes to src/libucsi/dvb/eit_section.h

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Kern
  • Date: 2008-07-23 14:03:56 UTC
  • mfrom: (1.1.3 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080723140356-m6ze7fbkydes42c7
Tags: 0.5.33-3
Fix xine-lib ffmpeg dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * section and descriptor parser
3
 
 *
4
 
 * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org)
5
 
 * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net)
6
 
 *
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.
11
 
 *
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.
16
 
 *
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
20
 
 */
21
 
 
22
 
#ifndef _UCSI_DVB_EIT_SECTION_H
23
 
#define _UCSI_DVB_EIT_SECTION_H 1
24
 
 
25
 
#ifdef __cplusplus
26
 
extern "C"
27
 
{
28
 
#endif
29
 
 
30
 
#include <libucsi/section.h>
31
 
#include <libucsi/dvb/types.h>
32
 
 
33
 
 
34
 
/**
35
 
 * dvb_eit_section structure.
36
 
 */
37
 
struct dvb_eit_section {
38
 
        struct section_ext head;
39
 
 
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[] */
45
 
} __ucsi_packed;
46
 
 
47
 
/**
48
 
 * An entry in the events field of a dvb_eit_section.
49
 
 */
50
 
struct dvb_eit_event {
51
 
        uint16_t event_id;
52
 
        dvbdate_t start_time;
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[] */
58
 
} __ucsi_packed;
59
 
 
60
 
/**
61
 
 * Process a dvb_eit_section.
62
 
 *
63
 
 * @param section Pointer to a generic section_ext structure.
64
 
 * @return Pointer to a dvb_eit_section, or NULL on error.
65
 
 */
66
 
struct dvb_eit_section *dvb_eit_section_codec(struct section_ext *section);
67
 
 
68
 
/**
69
 
 * Accessor for the service_id field of an EIT.
70
 
 *
71
 
 * @param eit EIT pointer.
72
 
 * @return The service_id.
73
 
 */
74
 
static inline uint16_t dvb_eit_section_service_id(struct dvb_eit_section *eit)
75
 
{
76
 
        return eit->head.table_id_ext;
77
 
}
78
 
 
79
 
/**
80
 
 * Iterator for the events field of a dvb_eit_section.
81
 
 *
82
 
 * @param eit dvb_eit_section pointer.
83
 
 * @param pos Variable containing a pointer to the current dvb_eit_event.
84
 
 */
85
 
#define dvb_eit_section_events_for_each(eit, pos) \
86
 
        for ((pos) = dvb_eit_section_events_first(eit); \
87
 
             (pos); \
88
 
             (pos) = dvb_eit_section_events_next(eit, pos))
89
 
 
90
 
/**
91
 
 * Iterator for the descriptors field of a dvb_eit_event.
92
 
 *
93
 
 * @param eit dvb_eit_event pointer.
94
 
 * @param pos Variable containing a pointer to the current descriptor.
95
 
 */
96
 
#define dvb_eit_event_descriptors_for_each(event, pos) \
97
 
        for ((pos) = dvb_eit_event_descriptors_first(event); \
98
 
             (pos); \
99
 
             (pos) = dvb_eit_event_descriptors_next(event, pos))
100
 
 
101
 
 
102
 
 
103
 
 
104
 
 
105
 
 
106
 
 
107
 
 
108
 
 
109
 
 
110
 
/******************************** PRIVATE CODE ********************************/
111
 
static inline struct dvb_eit_event *
112
 
        dvb_eit_section_events_first(struct dvb_eit_section *eit)
113
 
{
114
 
        size_t pos = sizeof(struct dvb_eit_section);
115
 
 
116
 
        if (pos >= section_ext_length(&eit->head))
117
 
                return NULL;
118
 
 
119
 
        return (struct dvb_eit_event*) ((uint8_t *) eit + pos);
120
 
}
121
 
 
122
 
static inline struct dvb_eit_event *
123
 
        dvb_eit_section_events_next(struct dvb_eit_section *eit,
124
 
                                    struct dvb_eit_event *pos)
125
 
{
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;
130
 
 
131
 
        if (next >= end)
132
 
                return NULL;
133
 
 
134
 
        return (struct dvb_eit_event *) next;
135
 
}
136
 
 
137
 
static inline struct descriptor *
138
 
        dvb_eit_event_descriptors_first(struct dvb_eit_event * t)
139
 
{
140
 
        if (t->descriptors_loop_length == 0)
141
 
                return NULL;
142
 
 
143
 
        return (struct descriptor *)
144
 
                ((uint8_t *) t + sizeof(struct dvb_eit_event));
145
 
}
146
 
 
147
 
static inline struct descriptor *
148
 
        dvb_eit_event_descriptors_next(struct dvb_eit_event * t,
149
 
                                       struct descriptor* pos)
150
 
{
151
 
        return next_descriptor((uint8_t*) t + sizeof(struct dvb_eit_event),
152
 
                               t->descriptors_loop_length,
153
 
                               pos);
154
 
}
155
 
 
156
 
#ifdef __cplusplus
157
 
}
158
 
#endif
159
 
 
160
 
#endif