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

add support for the MPEG FMC descriptor

Signed-off-by: default avatarJean-Paul Saman <jpsaman@videolan.org>
parent d4167716
...@@ -140,6 +140,10 @@ ...@@ -140,6 +140,10 @@
<integer name="i_es_id" bitcount="16" default="0"/> <integer name="i_es_id" bitcount="16" default="0"/>
</descriptor> </descriptor>
<descriptor name="FMC" sname="mpeg_fmc" gen_args="1">
<array name="p_fmc" len_name="i_num_fmc" min_size="1" type="dvbpsi_fmc_t"/>
</descriptor>
<descriptor name="network name" sname="dvb_network_name"> <descriptor name="network name" sname="dvb_network_name">
<array name="i_name_byte" len_name="i_name_length" min_size="0" /> <array name="i_name_byte" len_name="i_name_length" min_size="0" />
</descriptor> </descriptor>
......
...@@ -899,6 +899,33 @@ static int main_mpeg_sl_0(void) ...@@ -899,6 +899,33 @@ static int main_mpeg_sl_0(void)
return i_err; return i_err;
} }
/* FMC */
static int main_mpeg_fmc_0(void)
{
BOZO_VARS(mpeg_fmc);
BOZO_START(FMC);
#define dvbpsi_gen_mpeg_fmc_dr(x,y) \
dvbpsi_gen_mpeg_fmc_dr(x)
/* check p_fmc */
BOZO_init_array(i_num_fmc);
BOZO_begin_array(p_fmc)
BOZO_loop_array_begin(p_fmc, i_num_fmc, 1)
BOZO_DOJOB(mpeg_fmc);
BOZO_check_array_begin(p_fmc, i_num_fmc)
BOZO_check_array_cmp(p_fmc, i_num_fmc, dvbpsi_fmc_t)
BOZO_CLEAN();
BOZO_loop_array_end(p_fmc, ARRAY_SIZE(s_decoded.p_fmc))
BOZO_end_array
BOZO_END(FMC);
return i_err;
}
/* network name */ /* network name */
static int main_dvb_network_name_0(void) static int main_dvb_network_name_0(void)
{ {
...@@ -2567,6 +2594,7 @@ int main(void) ...@@ -2567,6 +2594,7 @@ int main(void)
i_err |= main_mpeg_mpeg4_audio_0(); i_err |= main_mpeg_mpeg4_audio_0();
i_err |= main_mpeg_iod_0(); i_err |= main_mpeg_iod_0();
i_err |= main_mpeg_sl_0(); i_err |= main_mpeg_sl_0();
i_err |= main_mpeg_fmc_0();
i_err |= main_dvb_network_name_0(); i_err |= main_dvb_network_name_0();
i_err |= main_dvb_service_list_0(); i_err |= main_dvb_service_list_0();
i_err |= main_dvb_stuffing_0(); i_err |= main_dvb_stuffing_0();
......
...@@ -110,3 +110,13 @@ static int compare_dvbpsi_subtitle_t(const void *s1, const void *s2) ...@@ -110,3 +110,13 @@ static int compare_dvbpsi_subtitle_t(const void *s1, const void *s2)
a->i_ancillary_page_id > b->i_ancillary_page_id) return 1; a->i_ancillary_page_id > b->i_ancillary_page_id) return 1;
else return 0; else return 0;
} }
static int compare_dvbpsi_fmc_t(const void *s1, const void *s2)
{
const dvbpsi_fmc_t *a = s1, *b = s2;
if(a->i_es_id < b->i_es_id ||
a->i_flex_mux_channel < b->i_flex_mux_channel) return -1;
else if(a->i_es_id > b->i_es_id ||
a->i_flex_mux_channel > b->i_flex_mux_channel) return 1;
else return 0;
}
...@@ -48,6 +48,7 @@ mpegdrinclude_HEADERS = descriptors/mpeg/dr_02.h \ ...@@ -48,6 +48,7 @@ mpegdrinclude_HEADERS = descriptors/mpeg/dr_02.h \
descriptors/mpeg/dr_1c.h \ descriptors/mpeg/dr_1c.h \
descriptors/mpeg/dr_1d.h \ descriptors/mpeg/dr_1d.h \
descriptors/mpeg/dr_1e.h \ descriptors/mpeg/dr_1e.h \
descriptors/mpeg/dr_1f.h \
descriptors/mpeg/dr_24.h descriptors/mpeg/dr_24.h
dvbdrincludedir = $(pkgincludedir)/dvb dvbdrincludedir = $(pkgincludedir)/dvb
...@@ -122,6 +123,7 @@ descriptors_src = descriptors/mpeg/dr_02.c \ ...@@ -122,6 +123,7 @@ descriptors_src = descriptors/mpeg/dr_02.c \
descriptors/mpeg/dr_1c.c \ descriptors/mpeg/dr_1c.c \
descriptors/mpeg/dr_1d.c \ descriptors/mpeg/dr_1d.c \
descriptors/mpeg/dr_1e.c \ descriptors/mpeg/dr_1e.c \
descriptors/mpeg/dr_1f.c \
descriptors/mpeg/dr_24.c \ descriptors/mpeg/dr_24.c \
descriptors/dvb/dr_40.c \ descriptors/dvb/dr_40.c \
descriptors/dvb/dr_41.c \ descriptors/dvb/dr_41.c \
......
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
#include "mpeg/dr_1c.h" #include "mpeg/dr_1c.h"
#include "mpeg/dr_1d.h" #include "mpeg/dr_1d.h"
#include "mpeg/dr_1e.h" #include "mpeg/dr_1e.h"
#include "mpeg/dr_1f.h"
#include "mpeg/dr_24.h" #include "mpeg/dr_24.h"
#include "custom/dr_83_eacem.h" #include "custom/dr_83_eacem.h"
#include "custom/dr_8a_scte.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_1f.h"
#define FMC_PACKED_SIZE 3
dvbpsi_mpeg_fmc_dr_t* dvbpsi_decode_mpeg_fmc_dr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_mpeg_fmc_dr_t * p_decoded;
/* check the tag. */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x1f))
return NULL;
/* don't decode twice. */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* all descriptors of this type must carry an integral number of packed FMC
* structures inside. */
const uint8_t num_fmc = p_descriptor->i_length / FMC_PACKED_SIZE;
if (p_descriptor->i_length % FMC_PACKED_SIZE
|| num_fmc > ARRAY_SIZE(p_decoded->p_fmc))
return NULL;
p_decoded = malloc(sizeof(*p_decoded));
if (!p_decoded)
return NULL;
p_decoded->i_num_fmc = num_fmc;
for(uint8_t i = 0 ; i < num_fmc ; ++i)
{
dvbpsi_fmc_t * pair = p_decoded->p_fmc + i;
pair->i_es_id = ((p_descriptor->p_data[i*FMC_PACKED_SIZE] & 0xff) << 8)
| p_descriptor->p_data[i*FMC_PACKED_SIZE + 1];
pair->i_flex_mux_channel = p_descriptor->p_data[i*FMC_PACKED_SIZE + 2];
}
p_descriptor->p_decoded = p_decoded;
return p_decoded;
}
dvbpsi_descriptor_t * dvbpsi_gen_mpeg_fmc_dr(
dvbpsi_mpeg_fmc_dr_t * p_decoded)
{
if (p_decoded->i_num_fmc > ARRAY_SIZE(p_decoded->p_fmc))
return NULL;
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(
0x1f, p_decoded->i_num_fmc * FMC_PACKED_SIZE, NULL);
if (!p_descriptor)
return NULL;
/* encode the data. */
for (uint8_t i = 0 ; i < p_decoded->i_num_fmc ; ++i)
{
dvbpsi_fmc_t * pair = p_decoded->p_fmc + i;
p_descriptor->p_data[i*FMC_PACKED_SIZE] = pair->i_es_id >> 8;
p_descriptor->p_data[i*FMC_PACKED_SIZE + 1] = pair->i_es_id;
p_descriptor->p_data[i*FMC_PACKED_SIZE + 2] = pair->i_flex_mux_channel;
}
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_1f.h>
* \author Daniel Kamil Kozar <dkk089@gmail.com>
* \brief Application interface for the FMC descriptor decoder and generator.
*
* Application interface for the FMC descriptor decoder and generator. This
* descriptor's definition can be found in ISO/IEC 13818-1 revision 2014/10
* section 2.6.44.
*/
#ifndef _DVBPSI_DR_1F_H_
#define _DVBPSI_DR_1F_H_
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \struct dvbpsi_mpeg_fmc_dr_s
* \brief FMC descriptor structure.
*
* This structure is used to store a decoded FMC descriptor. (ISO/IEC 13818-1
* section 2.6.44).
*/
/*!
* \typedef struct dvbpsi_fmc_s dvbpsi_fmc_t
* \brief dvbpsi_fmc_t type definition.
*/
typedef struct dvbpsi_fmc_s {
uint16_t i_es_id; /*< ES_ID */
uint8_t i_flex_mux_channel; /*< FlexMuxChannel */
} dvbpsi_fmc_t;
/*!
* \typedef struct dvbpsi_mpeg_fmc_dr_s dvbpsi_mpeg_fmc_dr_t
* \brief dvbpsi_mpeg_fmc_dr_t type definition.
*/
typedef struct dvbpsi_mpeg_fmc_dr_s
{
uint8_t i_num_fmc;
dvbpsi_fmc_t p_fmc[84]; /* 253 (max payload) / 3 (sizeof(fmc)) = 84 */
} dvbpsi_mpeg_fmc_dr_t;
/*!
* \brief FMC descriptor decoder.
* \param p_descriptor pointer to the descriptor structure
* \return A pointer to a new FMC descriptor structure which contains the
* decoded data.
*/
dvbpsi_mpeg_fmc_dr_t* dvbpsi_decode_mpeg_fmc_dr(
dvbpsi_descriptor_t * p_descriptor);
/*!
* \brief FMC descriptor generator.
* \param p_decoded pointer to a decoded FMC descriptor structure.
* \return a pointer to a new descriptor structure which contains encoded data.
*/
dvbpsi_descriptor_t * dvbpsi_gen_mpeg_fmc_dr(
dvbpsi_mpeg_fmc_dr_t * p_decoded);
#ifdef __cplusplus
}
#endif
#else
#error "Multiple inclusions of dr_1f.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