Commit f7c66da1 authored by Georgi Chorbadzhiyski's avatar Georgi Chorbadzhiyski

dvb/si: Complete support for descriptor 0x5a (Terrestrial delivery).

Add missing init and set functions and also fix printing.
parent e0f4129b
......@@ -4,6 +4,7 @@
* Copyright (C) 2009-2010 VideoLAN
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Georgi Chorbadzhiyski <georgi@unixsol.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
......@@ -49,69 +50,143 @@ extern "C"
*****************************************************************************/
#define DESC5A_HEADER_SIZE (DESC_HEADER_SIZE + 11)
static inline void desc5a_init(uint8_t *p_desc)
{
desc_set_tag(p_desc, 0x5a);
desc_set_length(p_desc, DESC5A_HEADER_SIZE - DESC_HEADER_SIZE);
p_desc[ 6] = 0x03;
p_desc[ 9] = 0xff;
p_desc[10] = 0xff;
p_desc[11] = 0xff;
p_desc[12] = 0xff;
}
static inline uint64_t desc5a_get_frequency(const uint8_t *p_desc)
{
return (((uint64_t)p_desc[2] << 24) | (p_desc[3] << 16) | (p_desc[4] << 8)
| p_desc[5]) * 10; /* Hz */
}
static inline void desc5a_set_frequency(uint8_t *p_desc, uint32_t i_freq)
{
p_desc[2] = (i_freq >> 24) & 0xff;
p_desc[3] = (i_freq >> 16) & 0xff;
p_desc[4] = (i_freq >> 8) & 0xff;
p_desc[5] = i_freq & 0xff;
}
static inline uint8_t desc5a_get_bandwidth(const uint8_t *p_desc)
{
return p_desc[6] >> 5;
}
static inline void desc5a_set_bandwidth(uint8_t *p_desc, uint8_t i_bandwidth)
{
p_desc[6] = (p_desc[6] &~ 0xe0) | (i_bandwidth << 5); // 111xxxxx
}
static inline bool desc5a_get_priority(const uint8_t *p_desc)
{
return !!((p_desc[6] >> 4) & 0x1);
}
static inline void desc5a_set_priority(uint8_t *p_desc, bool b_priority)
{
p_desc[6] = b_priority ? (p_desc[6] | 0x10) : (p_desc[6] &~ 0x10); // xxx1xxxx
}
/* ! inverted logic ! */
static inline bool desc5a_get_timeslicing(const uint8_t *p_desc)
{
return !((p_desc[6] >> 3) & 0x1);
}
static inline void desc5a_set_timeslicing(uint8_t *p_desc, bool b_timeslicing)
{
p_desc[6] = !b_timeslicing ? (p_desc[6] | 0x08) : (p_desc[6] &~ 0x08); // xxxx1xxx
}
/* ! inverted logic ! */
static inline bool desc5a_get_mpefec(const uint8_t *p_desc)
{
return !((p_desc[6] >> 2) & 0x1);
}
static inline void desc5a_set_mpefec(uint8_t *p_desc, bool b_mpefec)
{
p_desc[6] = !b_mpefec ? (p_desc[6] | 0x04) : (p_desc[6] &~ 0x04); // xxxxx1xx
}
static inline uint8_t desc5a_get_constellation(const uint8_t *p_desc)
{
return p_desc[7] >> 6;
}
static inline void desc5a_set_constellation(uint8_t *p_desc, uint8_t i_constellation)
{
p_desc[7] = (p_desc[7] &~ 0xc0) | (i_constellation << 6); // 11xxxxxx
}
static inline uint8_t desc5a_get_hierarchy(const uint8_t *p_desc)
{
return (p_desc[7] >> 3) & 0x7;
}
static inline void desc5a_set_hierarchy(uint8_t *p_desc, uint8_t i_hierarchy)
{
p_desc[7] = (p_desc[7] &~ 0x38) | ((i_hierarchy & 0x07) << 3); // xx111xxx
}
static inline uint8_t desc5a_get_coderatehp(const uint8_t *p_desc)
{
return p_desc[7] & 0x7;
}
static inline void desc5a_set_coderatehp(uint8_t *p_desc, uint8_t i_coderatehp)
{
p_desc[7] = (p_desc[7] &~ 0x07) | (i_coderatehp & 0x07); // xxxxx111
}
static inline uint8_t desc5a_get_coderatelp(const uint8_t *p_desc)
{
return p_desc[8] >> 5;
}
static inline void desc5a_set_coderatelp(uint8_t *p_desc, uint8_t i_coderatelp)
{
p_desc[8] = (p_desc[8] &~ 0xE0) | (i_coderatelp << 5); // 111xxxxx
}
static inline uint8_t desc5a_get_guard(const uint8_t *p_desc)
{
return (p_desc[8] >> 3) & 0x3;
}
static inline void desc5a_set_guard(uint8_t *p_desc, uint8_t i_guard)
{
p_desc[8] = (p_desc[8] &~ 0x18) | ((i_guard & 0x03) << 3); // xxx11xxx
}
static inline uint8_t desc5a_get_transmission(const uint8_t *p_desc)
{
return (p_desc[8] >> 1) & 0x3;
}
static inline void desc5a_set_transmission(uint8_t *p_desc, uint8_t i_transmission)
{
p_desc[8] = (p_desc[8] &~ 0x06) | ((i_transmission & 0x03) << 1); // xxxxx11x
}
static inline bool desc5a_get_otherfrequency(const uint8_t *p_desc)
{
return !!(p_desc[8] & 0x1);
}
static inline void desc5a_set_otherfrequency(uint8_t *p_desc, uint8_t b_otherfrequency)
{
p_desc[8] = b_otherfrequency ? (p_desc[8] | 0x01) : (p_desc[8] &~ 0x01); // xxxxxxx1
}
static inline bool desc5a_validate(const uint8_t *p_desc)
{
return desc_get_length(p_desc) >= DESC5A_HEADER_SIZE - DESC_HEADER_SIZE;
......@@ -178,24 +253,23 @@ static inline void desc5a_print(const uint8_t *p_desc, f_print pf_print,
desc5a_get_timeslicing(p_desc) ? 1 : 0,
desc5a_get_mpefec(p_desc) ? 1 : 0, psz_constellation,
psz_hierarchy,
dvb_delivery_get_fec(desc5a_get_coderatehp(p_desc)),
b_hierarchy ? dvb_delivery_get_fec(desc5a_get_coderatehp(p_desc)) : "not_applicable",
dvb_delivery_get_fec(desc5a_get_coderatehp(p_desc) + 1),
b_hierarchy ? dvb_delivery_get_fec(desc5a_get_coderatelp(p_desc) + 1) : "not_applicable",
psz_guard, psz_transmission,
desc5a_get_otherfrequency(p_desc) ? 1 : 0);
break;
default:
pf_print(opaque,
" - desc 5a dvb-t frequency=%"PRIu64" Hz bandwidth=%u MHz priority=%s%s%s constellation=%s hierarchy=%s coderatehp=%s%s%s guard=%s transmission=%s%s",
" - desc 5a dvb-t frequency=%"PRIu64" Hz bandwidth=%u MHz priority=%s timeslicing=%d mpefec=%d constellation=%s hierarchy=%s coderatehp=%s coderatelp=%s guard=%s transmission=%s otherfrequency=%d",
desc5a_get_frequency(p_desc), i_bandwidth,
desc5a_get_priority(p_desc) ? "HP" : "LP",
desc5a_get_timeslicing(p_desc) ? " timeslicing" : "",
desc5a_get_mpefec(p_desc) ? " mpefec" : "", psz_constellation,
desc5a_get_timeslicing(p_desc) ? 1 : 0,
desc5a_get_mpefec(p_desc) ? 1 : 0, psz_constellation,
psz_hierarchy,
dvb_delivery_get_fec(desc5a_get_coderatehp(p_desc)),
b_hierarchy ? "coderatelp=" : "",
b_hierarchy ? dvb_delivery_get_fec(desc5a_get_coderatehp(p_desc)) : "",
dvb_delivery_get_fec(desc5a_get_coderatehp(p_desc) + 1),
b_hierarchy ? dvb_delivery_get_fec(desc5a_get_coderatelp(p_desc) + 1) : "not_applicable",
psz_guard, psz_transmission,
desc5a_get_otherfrequency(p_desc) ? " otherfrequency" : "");
desc5a_get_otherfrequency(p_desc) ? 1 : 0);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment