2
* Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
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
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.
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
21
#include <libdvbv5/desc_service_location.h>
22
#include <libdvbv5/descriptors.h>
23
#include <libdvbv5/dvb-fe.h>
25
int dvb_desc_service_location_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc)
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;
33
if (buf + size > endbuf) {
34
dvb_logerr("%s: short read %zd/%zd bytes", __FUNCTION__, endbuf - buf, size);
38
memcpy(desc->data, buf, size);
39
bswap16(service_location->bitfield);
42
if (service_location->elements == 0)
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);
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);
62
void dvb_desc_service_location_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
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;
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);
75
void dvb_desc_service_location_free(struct dvb_desc *desc)
77
const struct dvb_desc_service_location *service_location = (const struct dvb_desc_service_location *) desc;
79
free(service_location->element);