~libv4l/libv4l/dev

« back to all changes in this revision

Viewing changes to lib/libdvbv5/descriptors/desc_service_location.c

  • Committer: Gregor Jasny
  • Date: 2014-10-01 08:14:20 UTC
  • Revision ID: git-v1:d852ba552c0ac76396298621843f5a537a33a7fc
libdvbv5: remove service_location descriptor

CC: Andre Roth <neolynx@gmail.com>
Acked-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Gregor Jasny <gjasny@googlemail.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or
5
 
 * modify it under the terms of the GNU General Public License
6
 
 * as published by the Free Software Foundation version 2
7
 
 * of the License.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
 
 * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18
 
 *
19
 
 */
20
 
 
21
 
#include <libdvbv5/desc_service_location.h>
22
 
#include <libdvbv5/descriptors.h>
23
 
#include <libdvbv5/dvb-fe.h>
24
 
 
25
 
int dvb_desc_service_location_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc)
26
 
{
27
 
        struct dvb_desc_service_location *service_location = (struct dvb_desc_service_location *) desc;
28
 
        const uint8_t *endbuf = buf + desc->length;
29
 
        ssize_t size = sizeof(struct dvb_desc_service_location) - sizeof(struct dvb_desc);
30
 
        struct dvb_desc_service_location_element *element;
31
 
        int i;
32
 
 
33
 
        if (buf + size > endbuf) {
34
 
                dvb_logerr("%s: short read %zd/%zd bytes", __FUNCTION__, endbuf - buf, size);
35
 
                return -1;
36
 
        }
37
 
 
38
 
        memcpy(desc->data, buf, size);
39
 
        bswap16(service_location->bitfield);
40
 
        buf += size;
41
 
 
42
 
        if (service_location->elements == 0)
43
 
                return 0;
44
 
 
45
 
        size = service_location->elements * sizeof(struct dvb_desc_service_location_element);
46
 
        if (buf + size > endbuf) {
47
 
                dvb_logerr("%s: short read %zd/%zd bytes", __FUNCTION__, endbuf - buf, size);
48
 
                return -2;
49
 
        }
50
 
        service_location->element = malloc(size);
51
 
        element = service_location->element;
52
 
        for (i = 0; i < service_location->elements; i++) {
53
 
                memcpy(element, buf, sizeof(struct dvb_desc_service_location_element) - 1); /* no \0 in lang */
54
 
                buf += sizeof(struct dvb_desc_service_location_element) - 1;
55
 
                element->language[3] = '\0';
56
 
                bswap16(element->bitfield);
57
 
                element++;
58
 
        }
59
 
        return 0;
60
 
}
61
 
 
62
 
void dvb_desc_service_location_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
63
 
{
64
 
        const struct dvb_desc_service_location *service_location = (const struct dvb_desc_service_location *) desc;
65
 
        struct dvb_desc_service_location_element *element = service_location->element;
66
 
        int i;
67
 
 
68
 
        dvb_loginfo("|    pcr pid      %d", service_location->pcr_pid);
69
 
        dvb_loginfo("|    streams:");
70
 
        for (i = 0; i < service_location->elements; i++)
71
 
                dvb_loginfo("|      pid %d, type %d: %s", element[i].elementary_pid, element[i].stream_type, element[i].language);
72
 
        dvb_loginfo("|  %d elements", service_location->elements);
73
 
}
74
 
 
75
 
void dvb_desc_service_location_free(struct dvb_desc *desc)
76
 
{
77
 
        const struct dvb_desc_service_location *service_location = (const struct dvb_desc_service_location *) desc;
78
 
 
79
 
        free(service_location->element);
80
 
}