| 1 |
/* |
| 2 |
* Copyright (c) 2013 - Mauro Carvalho Chehab <[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 on ARIB STD-B10 as Partial reception descriptor |
| 19 |
*/ |
| 20 |
|
| 21 |
#include <libdvbv5/desc_partial_reception.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 isdb_desc_partial_reception_init(struct dvb_v5_fe_parms *parms, |
| 29 |
const uint8_t *buf, struct dvb_desc *desc) |
| 30 |
{ |
| 31 |
struct isdb_desc_partial_reception *d = (void *)desc; |
| 32 |
unsigned char *p = (unsigned char *)buf; |
| 33 |
size_t len; |
| 34 |
int i; |
| 35 |
|
| 36 |
d->partial_reception = malloc(d->length); |
| 37 |
if (!d->partial_reception) { |
| 38 |
dvb_logerr("%s: out of memory", __func__); |
| 39 |
return -1; |
| 40 |
} |
| 41 |
|
| 42 |
memcpy(d->partial_reception, p, d->length); |
| 43 |
|
| 44 |
len = d->length / sizeof(*d->partial_reception); |
| 45 |
|
| 46 |
for (i = 0; i < len; i++) |
| 47 |
bswap16(d->partial_reception[i].service_id); |
| 48 |
return 0; |
| 49 |
} |
| 50 |
|
| 51 |
void isdb_desc_partial_reception_free(struct dvb_desc *desc) |
| 52 |
{ |
| 53 |
struct isdb_desc_partial_reception *d = (void *)desc; |
| 54 |
if (d->partial_reception) |
| 55 |
free(d->partial_reception); |
| 56 |
} |
| 57 |
|
| 58 |
void isdb_desc_partial_reception_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc) |
| 59 |
{ |
| 60 |
struct isdb_desc_partial_reception *d = (void *)desc; |
| 61 |
int i; |
| 62 |
size_t len; |
| 63 |
|
| 64 |
len = d->length / sizeof(*d->partial_reception); |
| 65 |
|
| 66 |
for (i = 0; i < len; i++) { |
| 67 |
dvb_loginfo("| service ID[%d] %d", i, d->partial_reception[i].service_id); |
| 68 |
} |
| 69 |
} |