| 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 IEC/CENELEC DS/EN 62216-1:2011 |
| 19 |
* |
| 20 |
* I couldn't find the original version, so I used what's there at: |
| 21 |
* http://tdt.telecom.pt/recursos/apresentacoes/Signalling Specifications for DTT deployment in Portugal.pdf |
| 22 |
*/ |
| 23 |
|
| 24 |
#include <libdvbv5/desc_logical_channel.h> |
| 25 |
#include <libdvbv5/dvb-fe.h> |
| 26 |
|
| 27 |
#if __GNUC__ >= 9 |
| 28 |
#pragma GCC diagnostic ignored "-Waddress-of-packed-member" |
| 29 |
#endif |
| 30 |
|
| 31 |
int dvb_desc_logical_channel_init(struct dvb_v5_fe_parms *parms, |
| 32 |
const uint8_t *buf, struct dvb_desc *desc) |
| 33 |
{ |
| 34 |
struct dvb_desc_logical_channel *d = (void *)desc; |
| 35 |
unsigned char *p = (unsigned char *)buf; |
| 36 |
size_t len; |
| 37 |
int i; |
| 38 |
|
| 39 |
d->lcn = malloc(d->length); |
| 40 |
if (!d->lcn) { |
| 41 |
dvb_logerr("%s: out of memory", __func__); |
| 42 |
return -1; |
| 43 |
} |
| 44 |
|
| 45 |
memcpy(d->lcn, p, d->length); |
| 46 |
|
| 47 |
len = d->length / 4; |
| 48 |
|
| 49 |
for (i = 0; i < len; i++) { |
| 50 |
bswap16(d->lcn[i].service_id); |
| 51 |
bswap16(d->lcn[i].bitfield); |
| 52 |
} |
| 53 |
return 0; |
| 54 |
} |
| 55 |
|
| 56 |
void dvb_desc_logical_channel_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc) |
| 57 |
{ |
| 58 |
struct dvb_desc_logical_channel *d = (void *)desc; |
| 59 |
int i; |
| 60 |
size_t len; |
| 61 |
|
| 62 |
len = d->length / 4; |
| 63 |
|
| 64 |
for (i = 0; i < len; i++) { |
| 65 |
dvb_loginfo("| service ID[%d] %d", i, d->lcn[i].service_id); |
| 66 |
dvb_loginfo("| LCN %d", d->lcn[i].logical_channel_number); |
| 67 |
dvb_loginfo("| visible service %d", d->lcn[i].visible_service_flag); |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
void dvb_desc_logical_channel_free(struct dvb_desc *desc) |
| 72 |
{ |
| 73 |
struct dvb_desc_logical_channel *d = (void *)desc; |
| 74 |
|
| 75 |
free(d->lcn); |
| 76 |
} |
| 77 |
|