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_VBI_DATA_DESCRIPTOR
23
#define _UCSI_DVB_VBI_DATA_DESCRIPTOR 1
30
#include <libucsi/descriptor.h>
31
#include <libucsi/endianops.h>
34
* Possible values for the data_service_id field.
37
DVB_VBI_DATA_SERVICE_ID_EBU = 0x01,
38
DVB_VBI_DATA_SERVICE_ID_INVERTED = 0x02,
39
DVB_VBI_DATA_SERVICE_ID_VPS = 0x04,
40
DVB_VBI_DATA_SERVICE_ID_WSS = 0x05,
41
DVB_VBI_DATA_SERVICE_ID_CC = 0x06,
42
DVB_VBI_DATA_SERVICE_ID_MONO_422 = 0x07,
46
* dvb_vbi_data_descriptor structure
48
struct dvb_vbi_data_descriptor {
51
/* struct dvb_vbi_data_entry entries[] */
55
* An entry in the dvb_vbi_data_descriptor entries field.
57
struct dvb_vbi_data_entry {
58
uint8_t data_service_id;
64
* Format of the dvb_vbi_data_entry data field, if data_service_id == 1,2,4,5,6,7.
66
struct dvb_vbi_data_x {
67
EBIT3(uint8_t reserved : 2; ,
68
uint8_t field_parity : 1; ,
69
uint8_t line_offset : 5; );
73
* Process a dvb_vbi_data_descriptor.
75
* @param d Generic descriptor structure.
76
* @return dvb_vbi_data_descriptor pointer, or NULL on error.
78
static inline struct dvb_vbi_data_descriptor*
79
dvb_vbi_data_descriptor_codec(struct descriptor* d)
81
uint8_t* p = (uint8_t*) d + 2;
83
uint32_t len = d->len;
86
struct dvb_vbi_data_entry *e =
87
(struct dvb_vbi_data_entry*) (p+pos);
89
pos += sizeof(struct dvb_vbi_data_entry);
94
pos += e->data_length;
100
return (struct dvb_vbi_data_descriptor*) d;
104
* Iterator for entries field in a dvb_vbi_data_descriptor structure.
106
* @param d Pointer to dvb_vbi_data_descriptor structure.
107
* @param pos Variable holding pointer to the current dvb_vbi_data_entry structure.
109
#define dvb_vbi_data_descriptor_entries_for_each(d, pos) \
110
for ((pos) = dvb_vbi_data_descriptor_entries_first(d); \
112
(pos) = dvb_vbi_data_descriptor_entries_next(d, pos))
115
* Get a pointer to the data field of a dvb_vbi_data_entry.
117
* @param d dvb_vbi_data_entry structure.
118
* @return Pointer to the data field.
120
static inline uint8_t *
121
dvb_vbi_data_entry_data(struct dvb_vbi_data_entry *d)
123
return (uint8_t *) d + sizeof(struct dvb_vbi_data_entry);
127
* Get a pointer to the data field of a dvb_vbi_data_x for id 1,2,4,5,6,7.
129
* @param d dvb_vbi_data_entry structure.
130
* @return Pointer to the data field, or NULL if invalid
132
static inline struct dvb_vbi_data_x*
133
dvb_vbi_data_entry_data_x(struct dvb_vbi_data_entry *d)
135
switch(d->data_service_id) {
142
return (struct dvb_vbi_data_x*) ((uint8_t *) d + sizeof(struct dvb_vbi_data_entry));
157
/******************************** PRIVATE CODE ********************************/
158
static inline struct dvb_vbi_data_entry*
159
dvb_vbi_data_descriptor_entries_first(struct dvb_vbi_data_descriptor *d)
164
return (struct dvb_vbi_data_entry *)
165
((uint8_t*) d + sizeof(struct dvb_vbi_data_descriptor));
168
static inline struct dvb_vbi_data_entry*
169
dvb_vbi_data_descriptor_entries_next(struct dvb_vbi_data_descriptor *d,
170
struct dvb_vbi_data_entry *pos)
172
uint8_t *end = (uint8_t*) d + 2 + d->d.len;
173
uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_vbi_data_entry) +
179
return (struct dvb_vbi_data_entry *) next;