Commit 2fac91b7 authored by Jiri Pinkava's avatar Jiri Pinkava Committed by Jean-Paul Saman

New descriptor 0x69 (Program Delivery Control PDC). Programme Delivery Control...

New descriptor 0x69 (Program Delivery Control PDC). Programme Delivery Control (PDC) is a standard (ETS 300 231) to control video recorders using hidden codes in the teletext service. The PDC data indicates to the recorder when a show or program starts. PDC is often used together with StarText, enabling the user to select a programme to record using specially coded teletext programme listings. The combination of features is often called PDC/StarText. More information on: http://en.wikipedia.org/wiki/Programme_Delivery_Control.
parent 5ae3fe47
...@@ -39,6 +39,7 @@ pkginclude_HEADERS = dvbpsi.h psi.h descriptor.h demux.h \ ...@@ -39,6 +39,7 @@ pkginclude_HEADERS = dvbpsi.h psi.h descriptor.h demux.h \
descriptors/dr_55.h \ descriptors/dr_55.h \
descriptors/dr_56.h \ descriptors/dr_56.h \
descriptors/dr_59.h \ descriptors/dr_59.h \
descriptors/dr_69.h \
descriptors/dr.h descriptors/dr.h
descriptors_src = descriptors/dr_02.c \ descriptors_src = descriptors/dr_02.c \
...@@ -63,7 +64,8 @@ descriptors_src = descriptors/dr_02.c \ ...@@ -63,7 +64,8 @@ descriptors_src = descriptors/dr_02.c \
descriptors/dr_52.c \ descriptors/dr_52.c \
descriptors/dr_55.c \ descriptors/dr_55.c \
descriptors/dr_56.c \ descriptors/dr_56.c \
descriptors/dr_59.c descriptors/dr_59.c \
descriptors/dr_69.c
tables_src = tables/pat.c tables/pat_private.h \ tables_src = tables/pat.c tables/pat_private.h \
tables/pmt.c tables/pmt_private.h \ tables/pmt.c tables/pmt_private.h \
......
/*****************************************************************************
* dr_69.c
* (c)2007 VideoLAN
* $Id$
*
* Authors: Jiri Pinkava <master_up@post.cz>
*
* 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_69.h"
/*****************************************************************************
* dvbpsi_DecodePDCDr
*****************************************************************************/
dvbpsi_PDC_dr_t * dvbpsi_DecodePDCDr(dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_PDC_dr_t * p_decoded;
/* Check the tag */
if(p_descriptor->i_tag != 0x69)
{
DVBPSI_ERROR_ARG("dr_69 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;
/* Decode data and check the length */
if( p_descriptor->i_length != 3)
{
DVBPSI_ERROR_ARG("dr_69 decoder", "bad length (%d)",
p_descriptor->i_length);
return NULL;
}
/* Allocate memory */
p_decoded = (dvbpsi_PDC_dr_t*)malloc(sizeof(dvbpsi_PDC_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_69 decoder", "out of memory");
return NULL;
}
p_decoded->i_PDC[0] = ((p_descriptor->p_data[0] & 0x0f) << 1) |
(p_descriptor->p_data[1] >> 7);
p_decoded->i_PDC[1] = ((p_descriptor->p_data[1] >> 3) & 0x0f);
p_decoded->i_PDC[2] = ((p_descriptor->p_data[1] << 2) & 0x1c) |
(p_descriptor->p_data[2] >> 6);
p_decoded->i_PDC[3] = p_descriptor->p_data[2] & 0x3f;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenPDCDr
*****************************************************************************/
dvbpsi_descriptor_t * dvbpsi_GenPDCDr(dvbpsi_PDC_dr_t * p_decoded,
int b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x69, 3, NULL);
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = 0xf0 | (p_decoded->i_PDC[0] >> 1);
p_descriptor->p_data[1] = (p_decoded->i_PDC[0] << 7) |
(p_decoded->i_PDC[1] << 3) | (p_decoded->i_PDC[2] >> 2);
p_descriptor->p_data[2] = (p_decoded->i_PDC[2] << 6 ) |
p_decoded->i_PDC[3];
if(b_duplicate)
{
/* Duplicate decoded data */
dvbpsi_PDC_dr_t * p_dup_decoded =
(dvbpsi_PDC_dr_t*)malloc(sizeof(dvbpsi_PDC_dr_t));
if(p_dup_decoded)
memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_PDC_dr_t));
p_descriptor->p_decoded = (void*)p_dup_decoded;
}
}
return p_descriptor;
}
/*****************************************************************************
* dr_69.h
* (c)2007 VideoLAN
* $Id$
*
* Authors: Pinkava Jiri <master_up@post.cz>
*
* 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_69.h>
* \author Jiri Pinkava <master_up@post.cz>
* \brief Application interface for the PDC (Programme Delivery Control)
* descriptor decoder and generator.
*
* Application interface for the MPEG 2 TS PDC descriptor decoder and generator
* This descriptor's definition can be found in ETSC EN 300 231
*/
#ifndef _DVBPSI_DR_69_H_
#define _DVBPSI_DR_69_H_
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
* dvbpsi_PDC_dr_t
*****************************************************************************/
/*!
* \struct dvbpsi_PDC_dr_s
* \brief PDC descriptor structure.
*
* This structure is used to store a decoded PDC descriptor.
* (ETSI EN 300 231).
*/
/*!
* \typedef struct dvbpsi_PDC_dr_s dvbpsi_PDC_dr_t
* \brief dvbpsi_PDC_dr_t type definition.
*/
typedef struct dvbpsi_PDC_dr_s
{
/* pdc[0] ~= day; PDC[1] ~= month; PDC[2] ~= hour; PDC[3] ~= min; */
uint8_t i_PDC[4]; /*!< PDC */
} dvbpsi_PDC_dr_t;
/*****************************************************************************
* dvbpsi_DecodePDCDr
*****************************************************************************/
/*!
* \fn dvbpsi_PDC_dr_t * dvbpsi_DecodePDCDr(
dvbpsi_descriptor_t * p_descriptor)
* \brief PDC descriptor decoder.
* \param p_descriptor pointer to the descriptor structure
* \return a pointer to a new "video stream" descriptor structure which
* contains the decoded data.
*/
dvbpsi_PDC_dr_t* dvbpsi_DecodePDCDr(dvbpsi_descriptor_t * p_descriptor);
/*****************************************************************************
* dvbpsi_GenPDCDr
*****************************************************************************/
/*!
* \fn dvbpsi_descriptor_t * dvbpsi_GenVStreamDr(
dvbpsi_PDC_dr_t * p_decoded, int b_duplicate)
* \brief PDC descriptor generator.
* \param p_decoded pointer to a decoded PDC 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_GenPDCDr(dvbpsi_PDC_dr_t * p_decoded,
int b_duplicate);
#ifdef __cplusplus
};
#endif
#else
#error "Multiple inclusions of dr_69.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