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

« back to all changes in this revision

Viewing changes to src/libucsi/dvb/sdt_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_SDT_SECTION_H
23
 
#define _UCSI_DVB_SDT_SECTION_H 1
24
 
 
25
 
#ifdef __cplusplus
26
 
extern "C"
27
 
{
28
 
#endif
29
 
 
30
 
#include <libucsi/section.h>
31
 
 
32
 
/**
33
 
 * dvb_sdt_section structure.
34
 
 */
35
 
struct dvb_sdt_section {
36
 
        struct section_ext head;
37
 
 
38
 
        uint16_t original_network_id;
39
 
        uint8_t reserved;
40
 
        /* struct dvb_sdt_service services[] */
41
 
} __ucsi_packed;
42
 
 
43
 
/**
44
 
 * An entry in the services field of a dvb_sdt_section.
45
 
 */
46
 
struct dvb_sdt_service {
47
 
        uint16_t service_id;
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[] */
55
 
} __ucsi_packed;
56
 
 
57
 
/**
58
 
 * Process a dvb_sdt_section.
59
 
 *
60
 
 * @param section Pointer to a generic section_ext structure.
61
 
 * @return dvb_sdt_section pointer, or NULL on error.
62
 
 */
63
 
struct dvb_sdt_section * dvb_sdt_section_codec(struct section_ext *section);
64
 
 
65
 
/**
66
 
 * Accessor for the transport_stream_id field of an SDT.
67
 
 *
68
 
 * @param sdt SDT pointer.
69
 
 * @return The transport_stream_id.
70
 
 */
71
 
static inline uint16_t dvb_sdt_section_transport_stream_id(struct dvb_sdt_section *sdt)
72
 
{
73
 
        return sdt->head.table_id_ext;
74
 
}
75
 
 
76
 
/**
77
 
 * Iterator for the services field in a dvb_sdt_section.
78
 
 *
79
 
 * @param sdt dvb_sdt_section pointer.
80
 
 * @param pos Variable containing a pointer to the current dvb_sdt_service.
81
 
 */
82
 
#define dvb_sdt_section_services_for_each(sdt, pos) \
83
 
        for ((pos) = dvb_sdt_section_services_first(sdt); \
84
 
             (pos); \
85
 
             (pos) = dvb_sdt_section_services_next(sdt, pos))
86
 
 
87
 
/**
88
 
 * Iterator for the descriptors field in a dvb_sdt_service.
89
 
 *
90
 
 * @param service dvb_sdt_service pointer.
91
 
 * @param pos Variable containing a pointer to the current descriptor.
92
 
 */
93
 
#define dvb_sdt_service_descriptors_for_each(service, pos) \
94
 
        for ((pos) = dvb_sdt_service_descriptors_first(service); \
95
 
             (pos); \
96
 
             (pos) = dvb_sdt_service_descriptors_next(service, pos))
97
 
 
98
 
 
99
 
 
100
 
 
101
 
 
102
 
 
103
 
 
104
 
 
105
 
 
106
 
 
107
 
 
108
 
/******************************** PRIVATE CODE ********************************/
109
 
static inline struct dvb_sdt_service *
110
 
        dvb_sdt_section_services_first(struct dvb_sdt_section * sdt)
111
 
{
112
 
        size_t pos = sizeof(struct dvb_sdt_section);
113
 
 
114
 
        if (pos >= section_ext_length(&sdt->head))
115
 
                return NULL;
116
 
 
117
 
        return (struct dvb_sdt_service*) ((uint8_t *) sdt + pos);
118
 
}
119
 
 
120
 
static inline struct dvb_sdt_service *
121
 
        dvb_sdt_section_services_next(struct dvb_sdt_section * sdt,
122
 
                                      struct dvb_sdt_service * pos)
123
 
{
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;
127
 
 
128
 
        if (next >= end)
129
 
                return NULL;
130
 
 
131
 
        return (struct dvb_sdt_service *) next;
132
 
}
133
 
 
134
 
static inline struct descriptor *
135
 
        dvb_sdt_service_descriptors_first(struct dvb_sdt_service *svc)
136
 
{
137
 
        if (svc->descriptors_loop_length == 0)
138
 
                return NULL;
139
 
 
140
 
        return (struct descriptor *)
141
 
                ((uint8_t*) svc + sizeof(struct dvb_sdt_service));
142
 
}
143
 
 
144
 
static inline struct descriptor *
145
 
        dvb_sdt_service_descriptors_next(struct dvb_sdt_service *svc,
146
 
                                         struct descriptor* pos)
147
 
{
148
 
        return next_descriptor((uint8_t*) svc + sizeof(struct dvb_sdt_service),
149
 
                               svc->descriptors_loop_length,
150
 
                               pos);
151
 
}
152
 
 
153
 
#ifdef __cplusplus
154
 
}
155
 
#endif
156
 
 
157
 
#endif