Commit 074963a0 authored by Georgi Chorbadzhiyski's avatar Georgi Chorbadzhiyski

dvb/si: Complete support for descriptor 0x6a (AC-3 descriptor).

parent 9124fb3b
......@@ -139,10 +139,7 @@ Supported DVB descriptors
* Descriptor 0x67: Transport stream descriptor
* Descriptor 0x68: DSNG descriptor
* Descriptor 0x69: PDC descriptor
* Descriptor 0x6a: AC-3 descriptor [p]
Legend:
[p] - Partitial support, only parser is implemented.
* Descriptor 0x6a: AC-3 descriptor
To see what is unsupported look in the TODO file.
......
......@@ -11,7 +11,6 @@ so if you like something just do it and send a patch.
- Add generators and example usage for these DVB descriptors:
- Descriptor 0x4a: Linkage descriptor
- Descriptor 0x6a: AC-3 descriptor
- Add support (parser, generator, example) for these DVB descriptors:
- Descriptor 0x6b: ancillary_data_descriptor
......
......@@ -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,16 +50,77 @@ extern "C"
static inline void desc6a_init(uint8_t *p_desc)
{
desc_set_tag(p_desc, 0x6a);
desc_set_length(p_desc, (DESC6A_HEADER_SIZE - DESC_HEADER_SIZE));
p_desc[2] = 0x0f;
}
static inline void desc6a_clear_flags(uint8_t *p_desc)
{
p_desc[2] = 0;
p_desc[2] = 0x0f;
}
#define DEFINE_AC3_FLAG(FLAGNAME, bit) \
static inline bool desc6a_get_##FLAGNAME##_flag(const uint8_t *p_desc) \
{ \
return (p_desc[2] & bit) == bit; \
} \
\
static inline void desc6a_set_##FLAGNAME##_flag(uint8_t *p_desc, bool b_##FLAGNAME) \
{ \
p_desc[2] = b_##FLAGNAME ? (p_desc[2] | bit) : (p_desc[2] &~ bit); \
}
#define DEFINE_AC3_VALUE(VALUENAME, ofs) \
static inline uint8_t desc6a_get_##VALUENAME(const uint8_t *p_desc) \
{ \
if (!desc6a_get_##VALUENAME##_flag(p_desc)) return 0; \
return p_desc[ofs]; \
} \
\
static inline void desc6a_set_##VALUENAME(uint8_t *p_desc, uint8_t i_##VALUENAME) \
{ \
if (!desc6a_get_##VALUENAME##_flag(p_desc)) return; \
p_desc[ofs] = i_##VALUENAME; \
}
DEFINE_AC3_FLAG (component_type, 0x80)
DEFINE_AC3_VALUE(component_type, DESC6A_HEADER_SIZE)
DEFINE_AC3_FLAG (bsid, 0x40)
DEFINE_AC3_VALUE(bsid, DESC6A_HEADER_SIZE
+ desc6a_get_component_type_flag(p_desc))
DEFINE_AC3_FLAG (mainid, 0x20)
DEFINE_AC3_VALUE(mainid, DESC6A_HEADER_SIZE
+ desc6a_get_component_type_flag(p_desc)
+ desc6a_get_bsid_flag(p_desc))
DEFINE_AC3_FLAG (asvc, 0x10)
DEFINE_AC3_VALUE(asvc, DESC6A_HEADER_SIZE
+ desc6a_get_component_type_flag(p_desc)
+ desc6a_get_bsid_flag(p_desc)
+ desc6a_get_mainid_flag(p_desc))
#undef DEFINE_AC3_FLAG
#undef DEFINE_AC3_VALUE
static inline void desc6a_set_length(uint8_t *p_desc)
{
uint8_t i_size = (DESC6A_HEADER_SIZE - DESC_HEADER_SIZE)
+ desc6a_get_component_type_flag(p_desc)
+ desc6a_get_bsid_flag(p_desc)
+ desc6a_get_mainid_flag(p_desc)
+ desc6a_get_asvc_flag(p_desc);
return desc_set_length(p_desc, i_size);
}
static inline bool desc6a_validate(const uint8_t *p_desc)
{
return desc_get_length(p_desc) >= DESC6A_HEADER_SIZE - DESC_HEADER_SIZE;
uint8_t i_size = (DESC6A_HEADER_SIZE - DESC_HEADER_SIZE)
+ desc6a_get_component_type_flag(p_desc)
+ desc6a_get_bsid_flag(p_desc)
+ desc6a_get_mainid_flag(p_desc)
+ desc6a_get_asvc_flag(p_desc);
return desc_get_length(p_desc) >= i_size;
}
static inline void desc6a_print(const uint8_t *p_desc, f_print pf_print,
......@@ -66,10 +128,28 @@ static inline void desc6a_print(const uint8_t *p_desc, f_print pf_print,
{
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque, "<AC3_DESC />");
pf_print(opaque,
"<AC3_DESC component_type_flag=\"%u\" component_type=\"%u\""
" bsid_flag=\"%u\" bsid=\"%u\""
" mainid_flag=\"%u\" mainid=\"%u\""
" asvc_flag=\"%u\" asvc=\"%u\"/>",
desc6a_get_component_type_flag(p_desc), desc6a_get_component_type(p_desc),
desc6a_get_bsid_flag(p_desc), desc6a_get_bsid(p_desc),
desc6a_get_mainid_flag(p_desc), desc6a_get_mainid(p_desc),
desc6a_get_asvc_flag(p_desc), desc6a_get_asvc(p_desc)
);
break;
default:
pf_print(opaque, " - desc 6a ac3");
pf_print(opaque,
" - desc 6a ac3 component_type_flag=%u component_type=%u"
" bsid_flag=%u bsid=%u"
" mainid_flag=%u mainid=%u"
" asvc_flag=%u asvc=%u",
desc6a_get_component_type_flag(p_desc), desc6a_get_component_type(p_desc),
desc6a_get_bsid_flag(p_desc), desc6a_get_bsid(p_desc),
desc6a_get_mainid_flag(p_desc), desc6a_get_mainid(p_desc),
desc6a_get_asvc_flag(p_desc), desc6a_get_asvc(p_desc)
);
}
}
......
......@@ -1102,6 +1102,24 @@ static void build_desc69(uint8_t *desc) {
}
/* DVB Descriptor 0x6a: AC-3 descriptor */
static void build_desc6a(uint8_t *desc) {
desc6a_init(desc);
desc6a_set_component_type_flag (desc, true);
desc6a_set_component_type (desc, 10);
desc6a_set_bsid_flag (desc, true);
desc6a_set_bsid (desc, 20);
desc6a_set_mainid_flag (desc, true);
desc6a_set_mainid (desc, 30);
desc6a_set_asvc_flag (desc, true);
desc6a_set_asvc (desc, 40);
desc6a_set_length(desc);
}
/* --- Descriptor 0x6b: ancillary_data_descriptor */
/* --- Descriptor 0x6c: cell_list_descriptor */
/* --- Descriptor 0x6d: cell_frequency_link_descriptor */
......@@ -2143,6 +2161,9 @@ static void generate_pmt(void) {
desc = descs_get_desc(desc_loop, desc_counter++);
build_desc5e(desc);
desc = descs_get_desc(desc_loop, desc_counter++);
build_desc6a(desc);
// Finish descriptor generation
desc = descs_get_desc(desc_loop, desc_counter); // Get next descriptor pos
descs_set_length(desc_loop, desc - desc_loop - DESCS_HEADER_SIZE);
......
......@@ -213,6 +213,7 @@ new PMT program=20000 version=1 pcrpid=110
- desc 5e multilingual_component code="eng" component_tag=46 text="Stereo"
- desc 5e multilingual_component code="fre" component_tag=46 text="Stereo"
- desc 5e multilingual_component code="bul" component_tag=46 text="Stereo"
- desc 6a ac3 component_type_flag=1 component_type=10 bsid_flag=1 bsid=20 mainid_flag=1 mainid=30 asvc_flag=1 asvc=40
* ES pid=122 streamtype=0x06 streamtype_txt="13818-1 PES private data"
- desc 46 vbi_telx language=eng type=0x1 type_txt="Initial teletext page" mag=3 page=0x255x
- desc 46 vbi_telx language=bul type=0x2 type_txt="Teletext subtitle page" mag=2 page=0x127x
......
......@@ -378,6 +378,9 @@
<MULTILINGUAL_COMPONENT_DESC code="fre" component_tag="46" text="Stereo"/>
<MULTILINGUAL_COMPONENT_DESC code="bul" component_tag="46" text="Stereo"/>
</DESC>
<DESC id="0x6a" length="5" value="ff0a141e28">
<AC3_DESC component_type_flag="1" component_type="10" bsid_flag="1" bsid="20" mainid_flag="1" mainid="30" asvc_flag="1" asvc="40"/>
</DESC>
</ES>
<ES pid="122" streamtype="0x06" streamtype_txt="13818-1 PES private data">
<DESC id="0x46" length="15" value="656e670bff62756c127f6672651940">
......
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