Commit 8efa5a12 authored by Daniel Kamil Kozar's avatar Daniel Kamil Kozar Committed by Jean-Paul Saman

add support for the MPEG MultiplexBuffer descriptor

Signed-off-by: default avatarJean-Paul Saman <jpsaman@videolan.org>
parent 9bc70c3e
......@@ -148,6 +148,11 @@
<integer name="i_ext_es_id" bitcount="16" default="0"/>
</descriptor>
<descriptor name="MultiplexBuffer" sname="mpeg_mux_buf" gen_args="1">
<integer name="i_mb_buf_size" bitcount="24" default="0"/>
<integer name="i_tb_leak_rate" bitcount="24" default="0"/>
</descriptor>
<descriptor name="network name" sname="dvb_network_name">
<array name="i_name_byte" len_name="i_name_length" min_size="0" />
</descriptor>
......
......@@ -950,6 +950,40 @@ static int main_mpeg_ext_es_id_0(void)
return i_err;
}
/* MultiplexBuffer */
static int main_mpeg_mux_buf_0(void)
{
BOZO_VARS(mpeg_mux_buf);
BOZO_START(MultiplexBuffer);
#define dvbpsi_gen_mpeg_mux_buf_dr(x,y) \
dvbpsi_gen_mpeg_mux_buf_dr(x)
/* check i_mb_buf_size */
BOZO_init_integer(i_mb_buf_size, 0);
BOZO_init_integer(i_tb_leak_rate, 0);
BOZO_begin_integer(i_mb_buf_size, 24)
BOZO_DOJOB(mpeg_mux_buf);
BOZO_check_integer(i_mb_buf_size, 24)
BOZO_CLEAN();
BOZO_end_integer(i_mb_buf_size, 24)
/* check i_tb_leak_rate */
BOZO_init_integer(i_mb_buf_size, 0);
BOZO_init_integer(i_tb_leak_rate, 0);
BOZO_begin_integer(i_tb_leak_rate, 24)
BOZO_DOJOB(mpeg_mux_buf);
BOZO_check_integer(i_tb_leak_rate, 24)
BOZO_CLEAN();
BOZO_end_integer(i_tb_leak_rate, 24)
BOZO_END(MultiplexBuffer);
return i_err;
}
/* network name */
static int main_dvb_network_name_0(void)
{
......@@ -2620,6 +2654,7 @@ int main(void)
i_err |= main_mpeg_sl_0();
i_err |= main_mpeg_fmc_0();
i_err |= main_mpeg_ext_es_id_0();
i_err |= main_mpeg_mux_buf_0();
i_err |= main_dvb_network_name_0();
i_err |= main_dvb_service_list_0();
i_err |= main_dvb_stuffing_0();
......
......@@ -50,6 +50,7 @@ mpegdrinclude_HEADERS = descriptors/mpeg/dr_02.h \
descriptors/mpeg/dr_1e.h \
descriptors/mpeg/dr_1f.h \
descriptors/mpeg/dr_20.h \
descriptors/mpeg/dr_23.h \
descriptors/mpeg/dr_24.h
dvbdrincludedir = $(pkgincludedir)/dvb
......@@ -126,6 +127,7 @@ descriptors_src = descriptors/mpeg/dr_02.c \
descriptors/mpeg/dr_1e.c \
descriptors/mpeg/dr_1f.c \
descriptors/mpeg/dr_20.c \
descriptors/mpeg/dr_23.c \
descriptors/mpeg/dr_24.c \
descriptors/dvb/dr_40.c \
descriptors/dvb/dr_41.c \
......
......@@ -92,6 +92,7 @@
#include "mpeg/dr_1e.h"
#include "mpeg/dr_1f.h"
#include "mpeg/dr_20.h"
#include "mpeg/dr_23.h"
#include "mpeg/dr_24.h"
#include "custom/dr_83_eacem.h"
#include "custom/dr_8a_scte.h"
......
/*
Copyright (C) 2016 Daniel Kamil Kozar
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <stdlib.h>
#include <stdbool.h>
#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
#elif defined(HAVE_STDINT_H)
#include <stdint.h>
#endif
#include "../../dvbpsi.h"
#include "../../dvbpsi_private.h"
#include "../../descriptor.h"
#include "dr_23.h"
dvbpsi_mpeg_mux_buf_dr_t* dvbpsi_decode_mpeg_mux_buf_dr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_mpeg_mux_buf_dr_t * p_decoded;
/* check the tag. */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x23))
return NULL;
/* don't decode twice. */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* all descriptors of this type must have 6 bytes of payload. */
if (p_descriptor->i_length != 6)
return NULL;
p_decoded = malloc(sizeof(*p_decoded));
if (!p_decoded)
return NULL;
p_decoded->i_mb_buf_size = ((p_descriptor->p_data[0] & 0xff) << 16)
| ((p_descriptor->p_data[1] & 0xff) << 8)
| p_descriptor->p_data[2];
p_decoded->i_tb_leak_rate = ((p_descriptor->p_data[3] & 0xff) << 16)
| ((p_descriptor->p_data[4] & 0xff) << 8)
| p_descriptor->p_data[5];
p_descriptor->p_decoded = p_decoded;
return p_decoded;
}
dvbpsi_descriptor_t * dvbpsi_gen_mpeg_mux_buf_dr(
dvbpsi_mpeg_mux_buf_dr_t * p_decoded)
{
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x23, 6, NULL);
if (!p_descriptor)
return NULL;
/* encode the data. */
p_descriptor->p_data[0] = p_decoded->i_mb_buf_size >> 16;
p_descriptor->p_data[1] = p_decoded->i_mb_buf_size >> 8;
p_descriptor->p_data[2] = p_decoded->i_mb_buf_size;
p_descriptor->p_data[3] = p_decoded->i_tb_leak_rate >> 16;
p_descriptor->p_data[4] = p_decoded->i_tb_leak_rate >> 8;
p_descriptor->p_data[5] = p_decoded->i_tb_leak_rate;
return p_descriptor;
}
/*
Copyright (C) 2016 Daniel Kamil Kozar
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!
* \file <dr_23.h>
* \author Daniel Kamil Kozar <dkk089@gmail.com>
* \brief Application interface for the MultiplexBuffer descriptor decoder and
* generator.
*
* Application interface for the MultiplexBuffer descriptor decoder and
* generator. This descriptor's definition can be found in ISO/IEC 13818-1
* revision 2014/10 section 2.6.52.
*/
#ifndef _DVBPSI_DR_23_H_
#define _DVBPSI_DR_23_H_
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \struct dvbpsi_mpeg_mux_buf_dr_s
* \brief MultiplexBuffer descriptor structure.
*
* This structure is used to store a decoded MultiplexBuffer descriptor.
* (ISO/IEC 13818-1 section 2.6.52).
*/
/*!
* \typedef struct dvbpsi_mpeg_mux_buf_dr_s dvbpsi_mpeg_mux_buf_dr_t
* \brief dvbpsi_mpeg_mux_buf_dr_t type definition.
*/
typedef struct dvbpsi_mpeg_mux_buf_dr_s {
uint32_t i_mb_buf_size; /*< MB_buffer_size */
uint32_t i_tb_leak_rate; /*< TB_leak_rate */
} dvbpsi_mpeg_mux_buf_dr_t;
/*!
* \brief MultiplexBuffer descriptor decoder.
* \param p_descriptor pointer to the descriptor structure
* \return A pointer to a new MultiplexBuffer descriptor structure which contains
* the decoded data.
*/
dvbpsi_mpeg_mux_buf_dr_t* dvbpsi_decode_mpeg_mux_buf_dr(
dvbpsi_descriptor_t * p_descriptor);
/*!
* \brief MultiplexBuffer descriptor generator.
* \param p_decoded pointer to a decoded MultiplexBuffer descriptor structure.
* \return a pointer to a new descriptor structure which contains encoded data.
*/
dvbpsi_descriptor_t * dvbpsi_gen_mpeg_mux_buf_dr(
dvbpsi_mpeg_mux_buf_dr_t * p_decoded);
#ifdef __cplusplus
}
#endif
#else
#error "Multiple inclusions of dr_23.h"
#endif
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