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

« back to all changes in this revision

Viewing changes to src/libucsi/dvb/data_broadcast_id_descriptor.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_DATA_BROADCAST_ID_DESCRIPTOR
23
 
#define _UCSI_DVB_DATA_BROADCAST_ID_DESCRIPTOR 1
24
 
 
25
 
#ifdef __cplusplus
26
 
extern "C"
27
 
{
28
 
#endif
29
 
 
30
 
#include <libucsi/descriptor.h>
31
 
#include <libucsi/endianops.h>
32
 
 
33
 
/**
34
 
 * Possible values for data_broadcast_id.
35
 
 */
36
 
enum {
37
 
        DVB_BROADCAST_ID_DATA_PIPE                      = 0X0001,
38
 
        DVB_BROADCAST_ID_ASYNCHRONOUS_DATA_STREAM       = 0X0002,
39
 
        DVB_BROADCAST_ID_SYNCHRONOUS_DATA_STREAM        = 0X0003,
40
 
        DVB_BROADCAST_ID_SYNCHRONISED_DATA_STREAM       = 0X0004,
41
 
        DVB_BROADCAST_ID_MULTI_PROTOCOL_ENCAPSULATION   = 0X0005,
42
 
        DVB_BROADCAST_ID_DATA_CAROUSEL                  = 0X0006,
43
 
        DVB_BROADCAST_ID_OBJECT_CAROUSEL                = 0X0007,
44
 
        DVB_BROADCAST_ID_DVB_ATM_STREAMS                = 0X0008,
45
 
        DVB_BROADCAST_ID_HIGHER_PROTOCOLS               = 0X0009,
46
 
        DVB_BROADCAST_ID_SOFTWARE_UPDATE                = 0x000A,
47
 
        DVB_BROADCAST_ID_IP_MAC_NOTIFICATION_TABLE      = 0x000B,
48
 
};
49
 
 
50
 
/**
51
 
 * dvb_data_broadcast_id_descriptor structure.
52
 
 */
53
 
struct dvb_data_broadcast_id_descriptor {
54
 
        struct descriptor d;
55
 
 
56
 
        uint16_t data_broadcast_id;
57
 
        /* uint8_t id_selector_byte[] */
58
 
} __ucsi_packed;
59
 
 
60
 
/**
61
 
 * id_selector_byte for 0x000b data_broadcast_id (IP/MAC Notification Table).
62
 
 */
63
 
struct dvb_id_selector_byte_000b {
64
 
        uint8_t platform_id_data_length;
65
 
        /* struct dvb_ip_mac_notification_info infos[] */
66
 
        /* uint8_t private_data[] */
67
 
} __ucsi_packed;
68
 
 
69
 
/**
70
 
 * Entries in the infos field of a dvb_id_selector_byte_0b.
71
 
 */
72
 
struct dvb_ip_mac_notification_info {
73
 
  EBIT2(uint32_t platform_id            : 24; ,
74
 
        uint8_t action_type             : 8;  );
75
 
  EBIT3(uint8_t reserved                : 2;  ,
76
 
        uint8_t INT_versioning_flag     : 1;  ,
77
 
        uint8_t INT_version             : 5;  );
78
 
} __ucsi_packed;
79
 
 
80
 
/**
81
 
 * Process a dvb_data_broadcast_id_descriptor.
82
 
 *
83
 
 * @param d Generic descriptor structure.
84
 
 * @return dvb_data_broadcast_id_descriptor pointer, or NULL on error.
85
 
 */
86
 
static inline struct dvb_data_broadcast_id_descriptor*
87
 
        dvb_data_broadcast_id_descriptor_codec(struct descriptor* d)
88
 
{
89
 
        if (d->len < (sizeof(struct dvb_data_broadcast_id_descriptor) - 2))
90
 
                return NULL;
91
 
 
92
 
        bswap16((uint8_t*) d + 2);
93
 
 
94
 
        return (struct dvb_data_broadcast_id_descriptor*) d;
95
 
}
96
 
 
97
 
/**
98
 
 * Accessor for the selector_byte field of a dvb_data_broadcast_id_descriptor.
99
 
 *
100
 
 * @param d dvb_data_broadcast_id_descriptor pointer.
101
 
 * @return Pointer to the field.
102
 
 */
103
 
static inline uint8_t *
104
 
        dvb_data_broadcast_id_descriptor_id_selector_byte(struct dvb_data_broadcast_id_descriptor *d)
105
 
{
106
 
        return (uint8_t *) d + sizeof(struct dvb_data_broadcast_id_descriptor);
107
 
}
108
 
 
109
 
/**
110
 
 * Determine the length of the selector_byte field of a dvb_data_broadcast_id_descriptor.
111
 
 *
112
 
 * @param d dvb_data_broadcast_id_descriptor pointer.
113
 
 * @return Length of the field in bytes.
114
 
 */
115
 
static inline int
116
 
        dvb_data_broadcast_id_descriptor_id_selector_byte_length(struct dvb_data_broadcast_id_descriptor *d)
117
 
{
118
 
        return d->d.len - 2;
119
 
}
120
 
 
121
 
/**
122
 
 * Accessor for a dvb_id_selector_byte_000b pointer.
123
 
 *
124
 
 * @param d dvb_data_broadcast_id_descriptor pointer.
125
 
 * @return Pointer to the data field.
126
 
 */
127
 
static inline struct dvb_id_selector_byte_000b *
128
 
        dvb_id_selector_byte_000b(struct dvb_data_broadcast_id_descriptor *d)
129
 
{
130
 
        if (d->data_broadcast_id != DVB_BROADCAST_ID_IP_MAC_NOTIFICATION_TABLE)
131
 
                return NULL;
132
 
        return (struct dvb_id_selector_byte_000b *) dvb_data_broadcast_id_descriptor_id_selector_byte(d);
133
 
}
134
 
 
135
 
/**
136
 
 * Iterator for the dvb_ip_mac_notification_info field of a dvb_id_selector_byte_000b.
137
 
 *
138
 
 * @param id_selector_byte dvb_id_selector_byte_000b pointer.
139
 
 * @param pos Variable containing a pointer to the current dvb_ip_mac_notification_info.
140
 
 */
141
 
#define dvb_id_selector_byte_000b_ip_mac_notification_info_for_each(id_selector_byte, pos) \
142
 
        for ((pos) = dvb_ip_mac_notification_info_first(id_selector_byte); \
143
 
             (pos); \
144
 
             (pos) = dvb_ip_mac_notification_info_next(id_selector_byte, pos))
145
 
 
146
 
/**
147
 
 * Length of the private_data field of a dvb_id_selector_byte_000b.
148
 
 *
149
 
 * @param d descriptor pointer.
150
 
 * @param i dvb_id_selector_byte_000b pointer.
151
 
 * @return Length of the field.
152
 
 */
153
 
static inline uint8_t
154
 
        dvb_id_selector_byte_000b_private_data_length(struct descriptor *d,
155
 
                            struct dvb_id_selector_byte_000b *i)
156
 
{
157
 
        return (uint8_t) (d->len -
158
 
             sizeof(struct descriptor) -
159
 
             i->platform_id_data_length -
160
 
             sizeof(struct dvb_id_selector_byte_000b));
161
 
}
162
 
 
163
 
/**
164
 
 * Accessor for the private_data field of a dvb_id_selector_byte_000b.
165
 
 *
166
 
 * @param d descriptor pointer.
167
 
 * @param i dvb_id_selector_byte_000b pointer.
168
 
 * @return Pointer to the field.
169
 
 */
170
 
static inline uint8_t *
171
 
        dvb_id_selector_byte_000b_private_data(struct descriptor *d,
172
 
                            struct dvb_id_selector_byte_000b *i)
173
 
{
174
 
        if (dvb_id_selector_byte_000b_private_data_length(d, i) <= 0)
175
 
                return NULL;
176
 
 
177
 
        return (uint8_t *) i + i->platform_id_data_length + sizeof(struct dvb_id_selector_byte_000b);
178
 
}
179
 
 
180
 
 
181
 
 
182
 
 
183
 
 
184
 
 
185
 
 
186
 
/******************************** PRIVATE CODE ********************************/
187
 
static inline struct dvb_ip_mac_notification_info *
188
 
        dvb_ip_mac_notification_info_first(struct dvb_id_selector_byte_000b *d)
189
 
{
190
 
        if (d->platform_id_data_length == 0)
191
 
                return NULL;
192
 
 
193
 
        bswap32((uint8_t *) d + sizeof(struct dvb_id_selector_byte_000b));
194
 
 
195
 
        return (struct dvb_ip_mac_notification_info *) ((uint8_t *) d + sizeof(struct dvb_id_selector_byte_000b));
196
 
}
197
 
 
198
 
static inline struct dvb_ip_mac_notification_info *
199
 
        dvb_ip_mac_notification_info_next(struct dvb_id_selector_byte_000b *d,
200
 
                                    struct dvb_ip_mac_notification_info *pos)
201
 
{
202
 
        uint8_t *end = (uint8_t *) d + d->platform_id_data_length;
203
 
        uint8_t *next = (uint8_t *) pos +
204
 
                        sizeof(struct dvb_id_selector_byte_000b) +
205
 
                        sizeof(struct dvb_ip_mac_notification_info);
206
 
 
207
 
        if (next >= end)
208
 
                return NULL;
209
 
 
210
 
        bswap32(next);
211
 
 
212
 
        return (struct dvb_ip_mac_notification_info *) next;
213
 
}
214
 
 
215
 
#ifdef __cplusplus
216
 
}
217
 
#endif
218
 
 
219
 
#endif
220
 
 
221
 
#include <libucsi/dvb/mhp_data_broadcast_id_descriptor.h>