| 1 |
/* |
| 2 |
* Copyright (c) 2013 - Andre Roth <[email protected]> |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation version 2.1 of the License. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program; if not, write to the Free Software |
| 15 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 16 |
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
| 17 |
* |
| 18 |
* Described at ETSI EN 300 468 V1.11.1 (2010-04) |
| 19 |
*/ |
| 20 |
|
| 21 |
#include <libdvbv5/desc_ca_identifier.h> |
| 22 |
#include <libdvbv5/dvb-fe.h> |
| 23 |
|
| 24 |
#if __GNUC__ >= 9 |
| 25 |
#pragma GCC diagnostic ignored "-Waddress-of-packed-member" |
| 26 |
#endif |
| 27 |
|
| 28 |
int dvb_desc_ca_identifier_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc) |
| 29 |
{ |
| 30 |
struct dvb_desc_ca_identifier *d = (struct dvb_desc_ca_identifier *) desc; |
| 31 |
int i; |
| 32 |
|
| 33 |
d->caid_count = d->length >> 1; /* FIXME: warn if odd */ |
| 34 |
d->caids = malloc(d->length); |
| 35 |
if (!d->caids) { |
| 36 |
dvb_logerr("dvb_desc_ca_identifier_init: out of memory"); |
| 37 |
return -1; |
| 38 |
} |
| 39 |
for (i = 0; i < d->caid_count; i++) { |
| 40 |
d->caids[i] = ((uint16_t *) buf)[i]; |
| 41 |
bswap16(d->caids[i]); |
| 42 |
} |
| 43 |
return 0; |
| 44 |
} |
| 45 |
|
| 46 |
void dvb_desc_ca_identifier_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc) |
| 47 |
{ |
| 48 |
const struct dvb_desc_ca_identifier *d = (const struct dvb_desc_ca_identifier *) desc; |
| 49 |
int i; |
| 50 |
|
| 51 |
for (i = 0; i < d->caid_count; i++) |
| 52 |
dvb_loginfo("| caid %d 0x%04x", i, d->caids[i]); |
| 53 |
} |
| 54 |
|
| 55 |
void dvb_desc_ca_identifier_free(struct dvb_desc *desc) |
| 56 |
{ |
| 57 |
struct dvb_desc_ca_identifier *d = (struct dvb_desc_ca_identifier *) desc; |
| 58 |
if (d->caids) |
| 59 |
free(d->caids); |
| 60 |
} |
| 61 |
|