Commit 627b462b authored by Georgi Chorbadzhiyski's avatar Georgi Chorbadzhiyski

mpeg/psi: Add support for descriptor 0x22 (FmxBufferSize descriptor).

parent bba83369
...@@ -86,6 +86,7 @@ Supported MPEG descriptors ...@@ -86,6 +86,7 @@ Supported MPEG descriptors
* Descriptor 0x1f: FMC_descriptor * Descriptor 0x1f: FMC_descriptor
* Descriptor 0x20: External ES_ID descriptor * Descriptor 0x20: External ES_ID descriptor
* Descriptor 0x21: MuxCode descriptor * Descriptor 0x21: MuxCode descriptor
* Descriptor 0x22: FmxBufferSize descriptor
* Descriptor 0x23: MultiplexBuffer descriptor * Descriptor 0x23: MultiplexBuffer descriptor
* Descriptor 0x27: Metadata STD descriptor * Descriptor 0x27: Metadata STD descriptor
* Descriptor 0x28: AVC video descriptor * Descriptor 0x28: AVC video descriptor
......
...@@ -2,7 +2,6 @@ TODO items for biTStream. The items are not ordered by importance ...@@ -2,7 +2,6 @@ TODO items for biTStream. The items are not ordered by importance
so if you like something just do it and send a patch. so if you like something just do it and send a patch.
- Add support (parser, generator, example) for these MPEG descriptors: - Add support (parser, generator, example) for these MPEG descriptors:
- Descriptor 0x22 FmxBufferSize_descriptor
- Descriptor 0x24 content_labeling_descriptor - Descriptor 0x24 content_labeling_descriptor
- Descriptor 0x25 metadata_pointer_descriptor - Descriptor 0x25 metadata_pointer_descriptor
- Descriptor 0x26 metadata_descriptor - Descriptor 0x26 metadata_descriptor
......
...@@ -365,6 +365,31 @@ static void build_desc21(uint8_t *desc) { ...@@ -365,6 +365,31 @@ static void build_desc21(uint8_t *desc) {
desc_set_length(desc, entry_n - desc - DESC_HEADER_SIZE); desc_set_length(desc, entry_n - desc - DESC_HEADER_SIZE);
} }
/* MPEG Descriptor 0x22: FmxBufferSize descriptor */
static void build_desc22(uint8_t *desc) {
uint8_t k = 0;
uint8_t *entry_n;
desc22_init(desc);
desc22_set_default_buffer_size(desc, 0x112233);
desc_set_length(desc, 255);
entry_n = desc22_get_entry(desc, k++);
desc22n_set_flexmux_channel(entry_n, 0x11);
desc22n_set_flexmux_buffer_size(entry_n, 0x223344);
entry_n = desc22_get_entry(desc, k++);
desc22n_set_flexmux_channel(entry_n, 0x55);
desc22n_set_flexmux_buffer_size(entry_n, 0x667788);
entry_n = desc22_get_entry(desc, k++);
desc22n_set_flexmux_channel(entry_n, 0x99);
desc22n_set_flexmux_buffer_size(entry_n, 0xaabbcc);
entry_n = desc22_get_entry(desc, k);
desc_set_length(desc, entry_n - desc - DESC_HEADER_SIZE);
}
/* MPEG Descriptor 0x23: MultiplexBuffer descriptor */ /* MPEG Descriptor 0x23: MultiplexBuffer descriptor */
static void build_desc23(uint8_t *desc) { static void build_desc23(uint8_t *desc) {
desc23_init(desc); desc23_init(desc);
...@@ -2514,6 +2539,9 @@ static void generate_pmt(void) { ...@@ -2514,6 +2539,9 @@ static void generate_pmt(void) {
desc = descs_get_desc(desc_loop, desc_counter++); desc = descs_get_desc(desc_loop, desc_counter++);
build_desc21(desc); build_desc21(desc);
desc = descs_get_desc(desc_loop, desc_counter++);
build_desc22(desc);
desc = descs_get_desc(desc_loop, desc_counter++); desc = descs_get_desc(desc_loop, desc_counter++);
build_desc23(desc); build_desc23(desc);
......
...@@ -291,6 +291,10 @@ new PMT program=20000 version=1 pcrpid=110 ...@@ -291,6 +291,10 @@ new PMT program=20000 version=1 pcrpid=110
- muxcode_substruct_entry slot=1 flex_mux_channel=71 number_of_bytes=81 - muxcode_substruct_entry slot=1 flex_mux_channel=71 number_of_bytes=81
- muxcode_substruct_entry slot=2 flex_mux_channel=72 number_of_bytes=82 - muxcode_substruct_entry slot=2 flex_mux_channel=72 number_of_bytes=82
- muxcode_substruct_entry slot=3 flex_mux_channel=73 number_of_bytes=83 - muxcode_substruct_entry slot=3 flex_mux_channel=73 number_of_bytes=83
- desc 22 fmx_buffer_size default_buffer_size=1122867
- flexmux_channel=0x11 buffer_size=2241348
- flexmux_channel=0x55 buffer_size=6715272
- flexmux_channel=0x99 buffer_size=11189196
- desc 23 multiplex_buffer mb_buffer_size=112233 tb_leak_rate=445566 - desc 23 multiplex_buffer mb_buffer_size=112233 tb_leak_rate=445566
- desc 27 metadata_std input_leak_rate=12345 buffer_size=23456 output_leak_rate=34567 - desc 27 metadata_std input_leak_rate=12345 buffer_size=23456 output_leak_rate=34567
- desc 2c flexmux_timing fcr_es_id=0x1234 fcr_resolution=123456789 fcr_length=55 fmx_rate_length=66 - desc 2c flexmux_timing fcr_es_id=0x1234 fcr_resolution=123456789 fcr_length=55 fmx_rate_length=66
......
...@@ -517,6 +517,13 @@ ...@@ -517,6 +517,13 @@
</MUXCODE_ENTRY> </MUXCODE_ENTRY>
</MUXCODE_DESC> </MUXCODE_DESC>
</DESC> </DESC>
<DESC id="0x22" length="15" value="112233112233445566778899aabbcc">
<FMX_BUFFER_SIZE_DESC default_buffer_size="1122867">
<FLEXMUX_BUFFER_DESC flexmux_channel="0x11" buffer_size="2241348"/>
<FLEXMUX_BUFFER_DESC flexmux_channel="0x55" buffer_size="6715272"/>
<FLEXMUX_BUFFER_DESC flexmux_channel="0x99" buffer_size="11189196"/>
</FMX_BUFFER_SIZE_DESC>
</DESC>
<DESC id="0x23" length="6" value="01b66906cc7e"> <DESC id="0x23" length="6" value="01b66906cc7e">
<MULTIPLEX_BUFFER_DESC mb_buffer_size="112233" tb_leak_rate="445566"/> <MULTIPLEX_BUFFER_DESC mb_buffer_size="112233" tb_leak_rate="445566"/>
</DESC> </DESC>
......
/*****************************************************************************
* desc_22.h: ISO/IEC 13818-1 Descriptor 0x22 (FmxBufferSize descriptor)
*****************************************************************************
* Copyright (C) 2011 Unix Solutions Ltd.
*
* Authors: 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
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*****************************************************************************/
/*
* Normative references:
* - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems)
* - ISO/IEC 14496-1:2001(E) (MPEG-4 Systems)
*/
#ifndef __BITSTREAM_MPEG_DESC_22_H__
#define __BITSTREAM_MPEG_DESC_22_H__
#include <bitstream/common.h>
#include <bitstream/mpeg/psi/descriptors.h>
#ifdef __cplusplus
extern "C"
{
#endif
/*****************************************************************************
* Descriptor 0x22: FmxBufferSize descriptor
*****************************************************************************/
#define DESC22_HEADER_SIZE (DESC_HEADER_SIZE + 3)
#define DESC22_ENTRY_SIZE 4
static inline void desc22_init(uint8_t *p_desc)
{
desc_set_tag(p_desc, 0x22);
desc_set_length(p_desc, DESC22_HEADER_SIZE - DESC_HEADER_SIZE);
}
static inline uint32_t desc22_get_default_buffer_size(const uint8_t *p_desc)
{
return (p_desc[2] << 16) | (p_desc[3] << 8) | p_desc[4];
}
static inline void desc22_set_default_buffer_size(uint8_t *p_desc, uint32_t i_default_buffer_size)
{
p_desc[2] = (i_default_buffer_size >> 16) & 0xff;
p_desc[3] = (i_default_buffer_size >> 8) & 0xff;
p_desc[4] = i_default_buffer_size & 0xff;
}
static inline uint8_t *desc22_get_entry(uint8_t *p_desc, uint8_t n)
{
uint8_t *p_desc_n = p_desc + DESC22_HEADER_SIZE + n * DESC22_ENTRY_SIZE;
if (p_desc_n + DESC22_ENTRY_SIZE - p_desc
> desc_get_length(p_desc) + DESC22_HEADER_SIZE)
return NULL;
return p_desc_n;
}
static inline uint8_t desc22n_get_flexmux_channel(const uint8_t *p_desc_n)
{
return p_desc_n[0];
}
static inline void desc22n_set_flexmux_channel(uint8_t *p_desc_n, uint8_t i_flexmux_channel)
{
p_desc_n[0] = i_flexmux_channel;
}
static inline uint32_t desc22n_get_flexmux_buffer_size(const uint8_t *p_desc_n)
{
return (p_desc_n[1] << 16) | (p_desc_n[2] << 8) | p_desc_n[3];
}
static inline void desc22n_set_flexmux_buffer_size(uint8_t *p_desc_n, uint32_t i_buffer_size)
{
p_desc_n[1] = (i_buffer_size >> 16) & 0xff;
p_desc_n[2] = (i_buffer_size >> 8) & 0xff;
p_desc_n[3] = i_buffer_size & 0xff;
}
static inline bool desc22_validate(const uint8_t *p_desc)
{
return ((desc_get_length(p_desc) - (DESC22_HEADER_SIZE - DESC_HEADER_SIZE))
% DESC22_ENTRY_SIZE) == 0;
}
static inline void desc22_print(uint8_t *p_desc, f_print pf_print,
void *opaque, print_type_t i_print_type)
{
uint8_t n = 0;
uint8_t *p_desc_n;
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque, "<FMX_BUFFER_SIZE_DESC default_buffer_size=\"%u\">",
desc22_get_default_buffer_size(p_desc));
break;
default:
pf_print(opaque, " - desc 22 fmx_buffer_size default_buffer_size=%u",
desc22_get_default_buffer_size(p_desc));
}
while ((p_desc_n = desc22_get_entry(p_desc, n++)) != NULL) {
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque, "<FLEXMUX_BUFFER_DESC flexmux_channel=\"0x%02x\" buffer_size=\"%u\"/>",
desc22n_get_flexmux_channel(p_desc_n),
desc22n_get_flexmux_buffer_size(p_desc_n));
break;
default:
pf_print(opaque, " - flexmux_channel=0x%02x buffer_size=%u",
desc22n_get_flexmux_channel(p_desc_n),
desc22n_get_flexmux_buffer_size(p_desc_n));
}
}
if (i_print_type == PRINT_XML)
pf_print(opaque, "</FMX_BUFFER_SIZE_DESC>");
}
#ifdef __cplusplus
}
#endif
#endif
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include <bitstream/mpeg/psi/desc_1f.h> #include <bitstream/mpeg/psi/desc_1f.h>
#include <bitstream/mpeg/psi/desc_20.h> #include <bitstream/mpeg/psi/desc_20.h>
#include <bitstream/mpeg/psi/desc_21.h> #include <bitstream/mpeg/psi/desc_21.h>
#include <bitstream/mpeg/psi/desc_22.h>
#include <bitstream/mpeg/psi/desc_23.h> #include <bitstream/mpeg/psi/desc_23.h>
#include <bitstream/mpeg/psi/desc_27.h> #include <bitstream/mpeg/psi/desc_27.h>
#include <bitstream/mpeg/psi/desc_28.h> #include <bitstream/mpeg/psi/desc_28.h>
......
...@@ -124,6 +124,7 @@ static inline void descl_print(uint8_t *p_descl, uint16_t i_length, ...@@ -124,6 +124,7 @@ static inline void descl_print(uint8_t *p_descl, uint16_t i_length,
CASE_DESC(1f) CASE_DESC(1f)
CASE_DESC(20) CASE_DESC(20)
CASE_DESC(21) CASE_DESC(21)
CASE_DESC(22)
CASE_DESC(23) CASE_DESC(23)
CASE_DESC(27) CASE_DESC(27)
CASE_DESC(28) CASE_DESC(28)
......
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