Commit 7258f595 authored by Johan Bilien's avatar Johan Bilien

* src/descriptors/*: added a few DVB descriptors decoder and generator

    (Stuffing, Bouquet Name, Service Name)
parent e3cc31b3
......@@ -28,6 +28,9 @@ pkginclude_HEADERS = dvbpsi.h psi.h descriptor.h tables/pat.h tables/pmt.h table
descriptors/dr_0d.h \
descriptors/dr_0e.h \
descriptors/dr_0f.h \
descriptors/dr_42.h \
descriptors/dr_47.h \
descriptors/dr_48.h \
descriptors/dr.h
descriptors_src = descriptors/dr_02.c \
......@@ -43,7 +46,10 @@ descriptors_src = descriptors/dr_02.c \
descriptors/dr_0c.c \
descriptors/dr_0d.c \
descriptors/dr_0e.c \
descriptors/dr_0f.c
descriptors/dr_0f.c \
descriptors/dr_42.c \
descriptors/dr_47.c \
descriptors/dr_48.c
tables_src = tables/pat.c tables/pat_private.h \
tables/pmt.c tables/pmt_private.h \
......
/*****************************************************************************
* dr_42.c
* (c)2001-2002 VideoLAN
* $Id: dr_42.c,v 1.1 2002/12/11 13:14:42 jobi Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* Johan Bilien <jobi@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.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_42.h"
/*****************************************************************************
* dvbpsi_DecodeStuffingDr
*****************************************************************************/
dvbpsi_stuffing_dr_t * dvbpsi_DecodeStuffingDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_stuffing_dr_t * p_decoded;
/* Check the tag */
if(p_descriptor->i_tag != 0x42)
{
DVBPSI_ERROR_ARG("dr_42 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
/* Don't decode twice */
if(p_descriptor->p_decoded)
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded =
(dvbpsi_stuffing_dr_t*)malloc(sizeof(dvbpsi_stuffing_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_42 decoder", "out of memory");
return NULL;
}
/* Decode data */
p_decoded->i_stuffing_length = p_descriptor->i_length;
if(p_decoded->i_stuffing_length)
memcpy(p_decoded->i_stuffing_byte,
p_descriptor->p_data,
p_decoded->i_stuffing_length);
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenStuffingDr
*****************************************************************************/
dvbpsi_descriptor_t * dvbpsi_GenStuffingDr(
dvbpsi_stuffing_dr_t * p_decoded,
int b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x42, p_decoded->i_stuffing_length, NULL);
if(p_descriptor)
{
/* Encode data */
if(p_decoded->i_stuffing_length)
memcpy(p_descriptor->p_data,
p_decoded->i_stuffing_byte,
p_decoded->i_stuffing_length);
if(b_duplicate)
{
/* Duplicate decoded data */
dvbpsi_stuffing_dr_t * p_dup_decoded =
(dvbpsi_stuffing_dr_t*)malloc(sizeof(dvbpsi_stuffing_dr_t));
if(p_dup_decoded)
memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_stuffing_dr_t));
p_descriptor->p_decoded = (void*)p_dup_decoded;
}
}
return p_descriptor;
}
/*****************************************************************************
* dr_42.h
* (c)2001-2002 VideoLAN
* $Id: dr_42.h,v 1.1 2002/12/11 13:14:42 jobi Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* Johan Bilien <jobi@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*****************************************************************************/
/*!
* \file <dr_42.h>
* \author Johan Bilien <jobi@via.ecp.fr>
* \brief Application interface for the DVB "stuffing"
* descriptor decoder and generator.
*
* Application interface for the DVB "stuffing" descriptor
* decoder and generator. This descriptor's definition can be found in
* ETSI EN 300 468 section 6.2.35.
*/
#ifndef _DVBPSI_DR_0F_H_
#define _DVBPSI_DR_0F_H_
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
* dvbpsi_stuffing_dr_t
*****************************************************************************/
/*!
* \struct dvbpsi_stuffing_dr_s
* \brief "stuffing" descriptor structure.
*
* This structure is used to store a decoded "stuffing"
* descriptor. (ETSI EN 300 468 section 6.2.35).
*/
/*!
* \typedef struct dvbpsi_stuffing_dr_s dvbpsi_stuffing_dr_t
* \brief dvbpsi_stuffing_dr_t type definition.
*/
typedef struct dvbpsi_stuffing_dr_s
{
uint8_t i_stuffing_length; /*!< length of the i_stuffing_byte
array */
uint8_t i_stuffing_byte[255]; /*!< stuffing_bytes */
} dvbpsi_stuffing_dr_t;
/*****************************************************************************
* dvbpsi_DecodeStuffingDataDr
*****************************************************************************/
/*!
* \fn dvbpsi_stuffing_dr_t * dvbpsi_DecodeStuffingDr(
dvbpsi_descriptor_t * p_descriptor)
* \brief "stuffing" descriptor decoder.
* \param p_descriptor pointer to the descriptor structure
* \return a pointer to a new "stuffing" descriptor structure
* which contains the decoded data.
*/
dvbpsi_stuffing_dr_t* dvbpsi_DecodeStuffingDr(
dvbpsi_descriptor_t * p_descriptor);
/*****************************************************************************
* dvbpsi_GenStuffingDataDr
*****************************************************************************/
/*!
* \fn dvbpsi_descriptor_t * dvbpsi_GenStuffingDr(
dvbpsi_stuffing_data_dr_t * p_decoded, int b_duplicate)
* \brief "stuffing" descriptor generator.
* \param p_decoded pointer to a decoded "stuffing" descriptor
* structure
* \param b_duplicate if non zero then duplicate the p_decoded structure into
* the descriptor
* \return a pointer to a new descriptor structure which contains encoded data.
*/
dvbpsi_descriptor_t * dvbpsi_GenStuffingDataDr(
dvbpsi_stuffing_dr_t * p_decoded,
int b_duplicate);
#ifdef __cplusplus
};
#endif
#else
#error "Multiple inclusions of dr_42.h"
#endif
/*****************************************************************************
* dr_47.c
* (c)2001-2002 VideoLAN
* $Id: dr_47.c,v 1.1 2002/12/11 13:14:42 jobi Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* Johan Bilien <jobi@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.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_47.h"
/*****************************************************************************
* dvbpsi_DecodeBouquetNameDr
*****************************************************************************/
dvbpsi_bouquet_name_dr_t * dvbpsi_DecodeBouquetNameDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_bouquet_name_dr_t * p_decoded;
/* Check the tag */
if(p_descriptor->i_tag != 0x47)
{
DVBPSI_ERROR_ARG("dr_47 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
/* Don't decode twice */
if(p_descriptor->p_decoded)
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded =
(dvbpsi_bouquet_name_dr_t*)malloc(sizeof(dvbpsi_bouquet_name_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_47 decoder", "out of memory");
return NULL;
}
/* Decode data */
p_decoded->i_name_length = p_descriptor->i_length;
if(p_decoded->i_name_length)
memcpy(p_decoded->i_char,
p_descriptor->p_data,
p_decoded->i_name_length);
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenBouquetNameDr
*****************************************************************************/
dvbpsi_descriptor_t * dvbpsi_GenBouquetNameDr(
dvbpsi_bouquet_name_dr_t * p_decoded,
int b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x47, p_decoded->i_name_length, NULL);
if(p_descriptor)
{
/* Encode data */
if(p_decoded->i_name_length)
memcpy(p_descriptor->p_data,
p_decoded->i_char,
p_decoded->i_name_length);
if(b_duplicate)
{
/* Duplicate decoded data */
dvbpsi_bouquet_name_dr_t * p_dup_decoded =
(dvbpsi_bouquet_name_dr_t*)malloc(sizeof(dvbpsi_bouquet_name_dr_t));
if(p_dup_decoded)
memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_bouquet_name_dr_t));
p_descriptor->p_decoded = (void*)p_dup_decoded;
}
}
return p_descriptor;
}
/*****************************************************************************
* dr_47.h
* (c)2001-2002 VideoLAN
* $Id: dr_47.h,v 1.1 2002/12/11 13:14:42 jobi Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* Johan Bilien <jobi@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*****************************************************************************/
/*!
* \file <dr_47.h>
* \author Johan Bilien <jobi@via.ecp.fr>
* \brief Application interface for the DVB "bouquet name"
* descriptor decoder and generator.
*
* Application interface for the MPEG 2 "bouquet name" descriptor
* decoder and generator. This descriptor's definition can be found in
* ETSI EN 300 468 section 6.2.3.
*/
#ifndef _DVBPSI_DR_0F_H_
#define _DVBPSI_DR_0F_H_
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
* dvbpsi_bouquet_name_dr_t
*****************************************************************************/
/*!
* \struct dvbpsi_bouquet_name_dr_s
* \brief "bouquet name" descriptor structure.
*
* This structure is used to store a decoded "bouquet name"
* descriptor. (ETSI EN 300 468 section 6.2.3).
*/
/*!
* \typedef struct dvbpsi_bouquet_name_dr_s dvbpsi_bouquet_name_dr_t
* \brief dvbpsi_bouquet_name_dr_t type definition.
*/
typedef struct dvbpsi_bouquet_name_dr_s
{
uint8_t i_name_length; /*!< length of thr i_char array */
uint8_t i_char[255]; /*!< char */
} dvbpsi_bouquet_name_dr_t;
/*****************************************************************************
* dvbpsi_DecodeBouquetNameDr
*****************************************************************************/
/*!
* \fn dvbpsi_bouquet_name_dr_t * dvbpsi_DecodeBouquetNameDr(
dvbpsi_descriptor_t * p_descriptor)
* \brief "bouquet name" descriptor decoder.
* \param p_descriptor pointer to the descriptor structure
* \return a pointer to a new "bouquet name" descriptor structure
* which contains the decoded data.
*/
dvbpsi_bouquet_name_dr_t* dvbpsi_DecodeBouquetNameDr(
dvbpsi_descriptor_t * p_descriptor);
/*****************************************************************************
* dvbpsi_GenBouquetNameDr
*****************************************************************************/
/*!
* \fn dvbpsi_descriptor_t * dvbpsi_GenStuffingDr(
dvbpsi_bouquet_name_dr_t * p_decoded, int b_duplicate)
* \brief "bouquet name" descriptor generator.
* \param p_decoded pointer to a decoded "bouquet name" descriptor
* structure
* \param b_duplicate if non zero then duplicate the p_decoded structure into
* the descriptor
* \return a pointer to a new descriptor structure which contains encoded data.
*/
dvbpsi_descriptor_t * dvbpsi_GenBouquetNameDr(
dvbpsi_bouquet_name_dr_t * p_decoded,
int b_duplicate);
#ifdef __cplusplus
};
#endif
#else
#error "Multiple inclusions of dr_47.h"
#endif
/*****************************************************************************
* dr_48.c
* (c)2001-2002 VideoLAN
* $Id: dr_48.c,v 1.1 2002/12/11 13:14:42 jobi Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* Johan Bilien <jobi@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.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_48.h"
/*****************************************************************************
* dvbpsi_DecodeServiceDr
*****************************************************************************/
dvbpsi_service_dr_t * dvbpsi_DecodeServiceDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_service_dr_t * p_decoded;
/* Check the tag */
if(p_descriptor->i_tag != 0x48)
{
DVBPSI_ERROR_ARG("dr_48 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
/* Don't decode twice */
if(p_descriptor->p_decoded)
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded =
(dvbpsi_service_dr_t*)malloc(sizeof(dvbpsi_service_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_48 decoder", "out of memory");
return NULL;
}
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
{
DVBPSI_ERROR_ARG("dr_07 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
}
p_decoded->i_service_type = p_descriptor->p_data[0];
p_decoded->i_service_provider_name_length = p_descriptor->p_data[1];
if(p_decoded->i_service_provider_name_length)
memcpy(p_decoded->i_service_provider_name,
p_descriptor->p_data + 2,
p_decoded->i_service_provider_name_length);
p_decoded->i_service_name_length =
p_descriptor->p_data[2+p_decoded->i_service_provider_name_length];
if(p_decoded->i_service_name_length)
memcpy(p_decoded->i_service_name,
p_descriptor->p_data + 3 + p_decoded->i_service_provider_name_length,
p_decoded->i_service_name_length);
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenServiceDr
*****************************************************************************/
dvbpsi_descriptor_t * dvbpsi_GenServiceDr(
dvbpsi_service_dr_t * p_decoded,
int b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x48, 3 + p_decoded->i_service_name_length +
p_decoded->i_service_provider_name_length , NULL);
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = p_decoded->i_service_type;
p_descriptor->p_data[1] = p_decoded->i_service_provider_name_length;
if(p_decoded->i_service_provider_name_length)
memcpy(p_descriptor->p_data + 2,
p_decoded->i_service_provider_name,
p_decoded->i_service_provider_name_length);
p_descriptor->p_data[2+p_decoded->i_service_provider_name_length] =
p_decoded->i_service_name_length;
if(p_decoded->i_service_name_length)
memcpy(p_descriptor->p_data + 3 + p_decoded->i_service_provider_name_length,
p_decoded->i_service_name,
p_decoded->i_service_name_length);
if(b_duplicate)
{
/* Duplicate decoded data */
dvbpsi_service_dr_t * p_dup_decoded =
(dvbpsi_service_dr_t*)malloc(sizeof(dvbpsi_service_dr_t));
if(p_dup_decoded)
memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_service_dr_t));
p_descriptor->p_decoded = (void*)p_dup_decoded;
}
}
return p_descriptor;
}
/*****************************************************************************
* dr_48.h
* (c)2001-2002 VideoLAN
* $Id: dr_48.h,v 1.1 2002/12/11 13:14:42 jobi Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* Johan Bilien <jobi@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*****************************************************************************/
/*!
* \file <dr_48.h>
* \author Johan Bilien <jobi@via.ecp.fr>
* \brief Application interface for the DVB "service"
* descriptor decoder and generator.
*
* Application interface for the DVB "service" descriptor
* decoder and generator. This descriptor's definition can be found in
* ETSI EN 300 468 section 6.2.30.
*/
#ifndef _DVBPSI_DR_0F_H_
#define _DVBPSI_DR_0F_H_
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
* dvbpsi_service_dr_t
*****************************************************************************/
/*!
* \struct dvbpsi_service_dr_s
* \brief "service" descriptor structure.
*
* This structure is used to store a decoded "service"
* descriptor. (ETSI EN 300 468 section 6.2.30).
*/
/*!
* \typedef struct dvbpsi_service_dr_s dvbpsi_service_dr_t
* \brief dvbpsi_service_dr_t type definition.
*/
typedef struct dvbpsi_service_dr_s
{
uint8_t i_service_type; /*!< service_type*/
uint8_t i_service_provider_name_length; /*!< length of the
i_service_provider_name array*/
uint8_t i_service_provider_name[252];/*!< name of the service provider */
uint8_t i_service_name_length; /*!< length of the
i_service_name array*/
uint8_t i_service_name[252]; /*!< name of the service */
} dvbpsi_service_dr_t;
/*****************************************************************************
* dvbpsi_DecodeServiceDataDr
*****************************************************************************/
/*!
* \fn dvbpsi_service_dr_t * dvbpsi_DecodeServiceDr(
dvbpsi_descriptor_t * p_descriptor)
* \brief "service" descriptor decoder.
* \param p_descriptor pointer to the descriptor structure
* \return a pointer to a new "service" descriptor structure
* which contains the decoded data.
*/
dvbpsi_service_dr_t* dvbpsi_DecodeServiceDr(
dvbpsi_descriptor_t * p_descriptor);
/*****************************************************************************
* dvbpsi_GenServiceDataDr
*****************************************************************************/
/*!
* \fn dvbpsi_descriptor_t * dvbpsi_GenServiceDr(
dvbpsi_service_dr_t * p_decoded, int b_duplicate)
* \brief "service" descriptor generator.
* \param p_decoded pointer to a decoded "service" descriptor
* structure
* \param b_duplicate if non zero then duplicate the p_decoded structure into
* the descriptor
* \return a pointer to a new descriptor structure which contains encoded data.
*/
dvbpsi_descriptor_t * dvbpsi_GenServiceDataDr(
dvbpsi_service_dr_t * p_decoded,
int b_duplicate);
#ifdef __cplusplus
};
#endif
#else
#error "Multiple inclusions of dr_48.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