Commit 19a31474 authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/tables/*: Privatize dvbpsi_decoder_t in dvbpsi_t

All dvbpsi decoders now use dvbpsi_t as handle instead of
dvbpsi_decoder_t *. The pointer to dvbpsi_decoder_t is privatized
and accessible through (dvbpsi_t *)->p_private member. The user
must make sure to cast it to the correct dvbpsi_*_decoder_t type
before accessing structure members.

Dvbpsi decoder developers should use the define DVBPSI_DECODER_COMMON
at the start of a new dvbpsi_*_decoder_t.

WARNING: THIS COMMIT BREAKS THE EXISTING API IN A MAJOR WAY !!!

- most public APIs requires a pointer to existing dvbpsi_t
- new functions to obtain and delete a pointer to dvbpsi_t structure:
  dvbpsi_NewHandle() and dvbpsi_DeleteHandle()
- subtable descriptors fixes
- indentations
parent f6de3f79
......@@ -5,6 +5,7 @@
* $Id$
*
* Authors: Johan Bilien <jobi@via.ecp.fr>
* Jean-Paul Saman <jpsaman@videolan.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -24,7 +25,6 @@
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
......@@ -36,6 +36,8 @@
#include <stdint.h>
#endif
#include <assert.h>
#include "dvbpsi.h"
#include "dvbpsi_private.h"
#include "psi.h"
......@@ -46,39 +48,33 @@
*****************************************************************************
* Creation of the demux structure
*****************************************************************************/
dvbpsi_handle dvbpsi_AttachDemux(dvbpsi_demux_new_cb_t pf_new_cb,
void * p_new_cb_data)
dvbpsi_t *dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi,
dvbpsi_demux_new_cb_t pf_new_cb,
void * p_new_cb_data)
{
dvbpsi_handle h_dvbpsi = (dvbpsi_decoder_t*)malloc(sizeof(dvbpsi_decoder_t));
dvbpsi_demux_t * p_demux;
if(h_dvbpsi == NULL)
return NULL;
p_demux = (dvbpsi_demux_t*)malloc(sizeof(dvbpsi_demux_t));
if(p_demux == NULL)
{
free(h_dvbpsi);
return NULL;
}
/* PSI decoder configuration */
h_dvbpsi->pf_callback = &dvbpsi_Demux;
h_dvbpsi->p_private_decoder = p_demux;
h_dvbpsi->i_section_max_size = 4096;
/* PSI decoder initial state */
h_dvbpsi->i_continuity_counter = 31;
h_dvbpsi->b_discontinuity = 1;
h_dvbpsi->p_current_section = NULL;
/* Sutables demux configuration */
p_demux->p_decoder = h_dvbpsi;
p_demux->p_first_subdec = NULL;
p_demux->pf_new_callback = pf_new_cb;
p_demux->p_new_cb_data = p_new_cb_data;
return h_dvbpsi;
assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t*)malloc(sizeof(dvbpsi_demux_t));
if (p_demux == NULL)
return NULL;
/* PSI decoder configuration */
p_demux->pf_callback = &dvbpsi_Demux;
p_demux->i_section_max_size = 4096;
/* PSI decoder initial state */
p_demux->i_continuity_counter = 31;
p_demux->b_discontinuity = 1;
p_demux->p_current_section = NULL;
/* Subtables demux configuration */
p_demux->p_first_subdec = NULL;
p_demux->pf_new_callback = pf_new_cb;
p_demux->p_new_cb_data = p_new_cb_data;
p_dvbpsi->p_private = (void *)p_demux;
return p_dvbpsi;
}
/*****************************************************************************
......@@ -90,18 +86,18 @@ dvbpsi_demux_subdec_t * dvbpsi_demuxGetSubDec(dvbpsi_demux_t * p_demux,
uint8_t i_table_id,
uint16_t i_extension)
{
uint32_t i_id = (uint32_t)i_table_id << 16 |(uint32_t)i_extension;
dvbpsi_demux_subdec_t * p_subdec = p_demux->p_first_subdec;
uint32_t i_id = (uint32_t)i_table_id << 16 |(uint32_t)i_extension;
dvbpsi_demux_subdec_t * p_subdec = p_demux->p_first_subdec;
while(p_subdec)
{
if(p_subdec->i_id == i_id)
break;
while (p_subdec)
{
if (p_subdec->i_id == i_id)
break;
p_subdec = p_subdec->p_next;
}
p_subdec = p_subdec->p_next;
}
return p_subdec;
return p_subdec;
}
/*****************************************************************************
......@@ -109,37 +105,35 @@ dvbpsi_demux_subdec_t * dvbpsi_demuxGetSubDec(dvbpsi_demux_t * p_demux,
*****************************************************************************
* Sends a PSI section to the right subtable decoder
*****************************************************************************/
void dvbpsi_Demux(dvbpsi_handle p_decoder, dvbpsi_psi_section_t * p_section)
void dvbpsi_Demux(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
{
dvbpsi_demux_t * p_demux;
dvbpsi_demux_subdec_t * p_subdec;
p_demux = (dvbpsi_demux_t *)p_decoder->p_private_decoder;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, p_section->i_table_id,
p_section->i_extension);
if(p_subdec == NULL)
{
/* Tell the application we found a new subtable, so that it may attach a
* subtable decoder */
p_demux->pf_new_callback(p_demux->p_new_cb_data, p_decoder,
p_section->i_table_id,
p_section->i_extension);
/* Check if a new subtable decoder is available */
p_subdec = dvbpsi_demuxGetSubDec(p_demux, p_section->i_table_id,
p_section->i_extension);
}
if(p_subdec)
{
p_subdec->pf_callback(p_demux->p_decoder, p_subdec->p_cb_data, p_section);
}
else
{
dvbpsi_DeletePSISections(p_section);
}
assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
dvbpsi_demux_t * p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t * p_subdec = dvbpsi_demuxGetSubDec(p_demux, p_section->i_table_id,
p_section->i_extension);
if (p_subdec == NULL)
{
/* Tell the application we found a new subtable, so that it may attach a
* subtable decoder */
p_demux->pf_new_callback(p_demux->p_new_cb_data, (dvbpsi_decoder_t *)p_demux,
p_section->i_table_id, p_section->i_extension);
/* Check if a new subtable decoder is available */
p_subdec = dvbpsi_demuxGetSubDec(p_demux, p_section->i_table_id,
p_section->i_extension);
}
if (p_subdec)
{
p_subdec->pf_callback(p_dvbpsi, p_subdec->p_cb_data, p_section);
}
else
{
dvbpsi_DeletePSISections(p_section);
}
}
/*****************************************************************************
......@@ -147,26 +141,28 @@ void dvbpsi_Demux(dvbpsi_handle p_decoder, dvbpsi_psi_section_t * p_section)
*****************************************************************************
* Destroys a demux structure
*****************************************************************************/
void dvbpsi_DetachDemux(dvbpsi_handle h_dvbpsi)
void dvbpsi_DetachDemux(dvbpsi_t *p_dvbpsi)
{
dvbpsi_demux_t* p_demux
= (dvbpsi_demux_t*)h_dvbpsi->p_private_decoder;
dvbpsi_demux_subdec_t* p_subdec
= p_demux->p_first_subdec;
dvbpsi_demux_subdec_t* p_subdec_temp;
while(p_subdec)
{
p_subdec_temp = p_subdec;
p_subdec = p_subdec->p_next;
if(p_subdec_temp->pf_detach)
p_subdec_temp->pf_detach(p_demux, (p_subdec_temp->i_id >> 16) & 0xFFFF,
p_subdec_temp->i_id & 0xFFFF);
else free(p_subdec_temp);
}
free(p_demux);
if(h_dvbpsi->p_current_section)
dvbpsi_DeletePSISections(h_dvbpsi->p_current_section);
free(h_dvbpsi);
assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec = p_demux->p_first_subdec;
while (p_subdec)
{
dvbpsi_demux_subdec_t* p_subdec_temp = p_subdec;
p_subdec = p_subdec->p_next;
if (p_subdec_temp->pf_detach)
p_subdec_temp->pf_detach(p_dvbpsi, (p_subdec_temp->i_id >> 16) & 0xFFFF,
p_subdec_temp->i_id & 0xFFFF);
else free(p_subdec_temp);
}
if (p_demux->p_current_section)
dvbpsi_DeletePSISections(p_demux->p_current_section);
p_dvbpsi->p_private = NULL;
free(p_demux);
}
......@@ -5,6 +5,7 @@
* $Id$
*
* Authors: Johan Bilien <jobi@via.ecp.fr>
* Jean-Paul Saman <jpsaman@videolan.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -37,19 +38,18 @@
extern "C" {
#endif
/*****************************************************************************
* dvbpsi_demux_new_cb_t
*****************************************************************************/
/*!
* \typedef void(* dvbpsi_demux_new_cb_t) (void * p_cb_data,
dvbpsi_handle h_dvbpsi,
dvbpsi_decoder_t *p_decoder,
uint8_t i_table_id,
uint16_t i_extension);
* \brief Callback used in case of a new subtable detected.
*/
typedef void (*dvbpsi_demux_new_cb_t) (void * p_cb_data,
dvbpsi_handle h_dvbpsi,
dvbpsi_decoder_t *p_decoder,
uint8_t i_table_id,
uint16_t i_extension);
......@@ -58,15 +58,15 @@ typedef void (*dvbpsi_demux_new_cb_t) (void * p_cb_data,
*****************************************************************************/
/*!
* \typedef void (*dvbpsi_demux_subdec_cb_t)
(dvbpsi_decoder_t* p_psi_decoder,
void* p_private_decoder,
dvbpsi_psi_section_t* p_section);
(dvbpsi_t *p_dvbpsi,
void *p_private_decoder,
dvbpsi_psi_section_t *p_section);
* \brief Subtable specific decoder.
*/
typedef void (*dvbpsi_demux_subdec_cb_t)
(dvbpsi_decoder_t* p_psi_decoder,
void* p_private_decoder,
dvbpsi_psi_section_t* p_section);
(dvbpsi_t *p_dvbpsi,
void *p_private_decoder,
dvbpsi_psi_section_t *p_section);
/*****************************************************************************
* dvbpsi_demux_subdec_t
......@@ -90,12 +90,12 @@ typedef struct dvbpsi_demux_subdec_s
void * p_cb_data;
struct dvbpsi_demux_subdec_s * p_next;
void (*pf_detach)(struct dvbpsi_demux_s *, uint8_t, uint16_t);
void (*pf_detach)(dvbpsi_t *, uint8_t, uint16_t);
} dvbpsi_demux_subdec_t;
/*****************************************************************************
* dvbpsi_demux_t
* dvbpsi_demux_s
*****************************************************************************/
/*!
* \struct dvbpsi_demux_s
......@@ -108,41 +108,44 @@ typedef struct dvbpsi_demux_subdec_s
* \typedef struct dvbpsi_demux_s dvbpsi_demux_t
* \brief dvbpsi_demux_t type definition.
*/
typedef struct dvbpsi_demux_s
typedef struct dvbpsi_demux_s dvbpsi_demux_t;
struct dvbpsi_demux_s
{
dvbpsi_handle p_decoder; /*!< Parent PSI Decoder */
dvbpsi_demux_subdec_t * p_first_subdec; /*!< First subtable decoder */
/* New subtable callback */
dvbpsi_demux_new_cb_t pf_new_callback; /*!< New subtable callback */
void * p_new_cb_data; /*!< Data provided to the
previous callback */
DVBPSI_DECODER_COMMON
} dvbpsi_demux_t;
dvbpsi_demux_subdec_t * p_first_subdec; /*!< First subtable decoder */
/* New subtable callback */
dvbpsi_demux_new_cb_t pf_new_callback; /*!< New subtable callback */
void * p_new_cb_data; /*!< Data provided to the
previous callback */
};
/*****************************************************************************
* dvbpsi_AttachDemux
*****************************************************************************/
/*!
* \fn dvbpsi_handle_t dvbpsi_NewPSISection(dvbpsi_demux_new_cb_t pf_new_cb, void * p_new_cb_data)
* \fn dvbpsi_t *dvbpsi_NewPSISection(dvbpsi_t *p_dvbpsi, dvbpsi_demux_new_cb_t pf_new_cb, void * p_new_cb_data)
* \brief Creates a new demux structure.
* \param p_dvbpsi pointer to dvbpsi_t handle
* \param pf_new_cb A callcack called when a new type of subtable is found.
* \param p_new_cb_data Data given to the previous callback.
* \return a handle to the new demux structure.
* \return a handle to the new attached demux structure.
*/
dvbpsi_handle dvbpsi_AttachDemux(dvbpsi_demux_new_cb_t pf_new_cb,
void * p_new_cb_data);
dvbpsi_t *dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi,
dvbpsi_demux_new_cb_t pf_new_cb,
void * p_new_cb_data);
/*****************************************************************************
* dvbpsi_DetachDemux
*****************************************************************************/
/*!
* \fn void dvbpsi_DetachDemux(dvbpsi_handle h_dvbpsi)
* \fn void dvbpsi_DetachDemux(dvbpsi_decoder_t *p_decoder)
* \brief Destroys a demux structure.
* \param h_dvbpsi The handle of the demux to be destroyed.
*/
void dvbpsi_DetachDemux(dvbpsi_handle h_dvbpsi);
void dvbpsi_DetachDemux(dvbpsi_t *p_dvbpsi);
/*****************************************************************************
* dvbpsi_demuxGetSubDec
......@@ -163,14 +166,13 @@ dvbpsi_demux_subdec_t * dvbpsi_demuxGetSubDec(dvbpsi_demux_t * p_demux,
* dvbpsi_Demux
*****************************************************************************/
/*!
* \fn void dvbpsi_Demux(dvbpsi_handle h_dvbpsi,
* \fn void dvbpsi_Demux(dvbpsi_t *p_dvbpsi,
dvbpsi_psi_section_t * p_section)
* \brief Sends the PSI sections to the right subtable decoder according to their table ID and extension.
* \param h_dvbpsi PSI decoder handle.
* \param p_dvbpsi PSI decoder handle.
* \param p_section PSI section.
*/
void dvbpsi_Demux(dvbpsi_handle h_dvbpsi,
dvbpsi_psi_section_t * p_section);
void dvbpsi_Demux(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section);
#ifdef __cplusplus
};
......
......@@ -5,6 +5,7 @@
* $Id$
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* Jean-Paul Saman <jpsaman@videolan.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -30,6 +31,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdbool.h>
#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
......@@ -37,6 +39,8 @@
#include <stdint.h>
#endif
#include <assert.h>
#include "dvbpsi.h"
#include "dvbpsi_private.h"
#include "psi.h"
......@@ -137,13 +141,66 @@ uint32_t dvbpsi_crc32_table[256] =
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
};
/*****************************************************************************
* dvbpsi_NewHandle
*****************************************************************************/
dvbpsi_t *dvbpsi_NewHandle(dvbpsi_message_cb callback, int level)
{
dvbpsi_t *handle = calloc(1, sizeof(dvbpsi_t));
if (handle != NULL)
{
handle->p_private = NULL;
handle->pf_message = callback;
handle->i_msg_level = level;
}
return handle;
}
/*****************************************************************************
* dvbpsi_DeleteHandle
*****************************************************************************/
void dvbpsi_DeleteHandle(dvbpsi_t *handle)
{
assert(handle->p_private != NULL);
handle->pf_message = NULL;
free(handle);
}
/*****************************************************************************
* dvbpsi_NewDecoder
*****************************************************************************/
dvbpsi_decoder_t *dvbpsi_NewDecoder(dvbpsi_t *handle, dvbpsi_callback *callback)
{
dvbpsi_decoder_t *p_decoder = calloc(1, sizeof(dvbpsi_decoder_t));
if (p_decoder == NULL)
return NULL;
p_decoder->pf_callback = NULL;
p_decoder->p_current_section = NULL;
return p_decoder;
}
/*****************************************************************************
* dvbpsi_DeletDecoder
*****************************************************************************/
void dvbpsi_DeleteDecoder(dvbpsi_t *handle)
{
assert(handle);
assert(handle->p_private);
dvbpsi_decoder_t *p_decoder = (dvbpsi_decoder_t *) handle->p_private;
handle->p_private = NULL;
free(p_decoder);
}
/*****************************************************************************
* dvbpsi_PushPacket
*****************************************************************************
* Injection of a TS packet into a PSI decoder.
*****************************************************************************/
void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
void dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
{
uint8_t i_expected_counter; /* Expected continuity counter */
dvbpsi_psi_section_t* p_section; /* Current section */
......@@ -154,38 +211,41 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
int i_available; /* Byte count available in the
packet */
dvbpsi_decoder_t *p_decoder = (dvbpsi_decoder_t *)handle->p_private;
assert(p_decoder);
/* TS start code */
if(p_data[0] != 0x47)
{
dvbpsi_error(h_dvbpsi, "PSI decoder", "not a TS packet");
dvbpsi_error(handle, "PSI decoder", "not a TS packet");
return;
}
/* Continuity check */
i_expected_counter = (h_dvbpsi->i_continuity_counter + 1) & 0xf;
h_dvbpsi->i_continuity_counter = p_data[3] & 0xf;
i_expected_counter = (p_decoder->i_continuity_counter + 1) & 0xf;
p_decoder->i_continuity_counter = p_data[3] & 0xf;
if(i_expected_counter == ((h_dvbpsi->i_continuity_counter + 1) & 0xf)
&& !h_dvbpsi->b_discontinuity)
if(i_expected_counter == ((p_decoder->i_continuity_counter + 1) & 0xf)
&& !p_decoder->b_discontinuity)
{
dvbpsi_error(h_dvbpsi, "PSI decoder",
dvbpsi_error(handle, "PSI decoder",
"TS duplicate (received %d, expected %d) for PID %d",
h_dvbpsi->i_continuity_counter, i_expected_counter,
p_decoder->i_continuity_counter, i_expected_counter,
((uint16_t)(p_data[1] & 0x1f) << 8) | p_data[2]);
return;
}
if(i_expected_counter != h_dvbpsi->i_continuity_counter)
if(i_expected_counter != p_decoder->i_continuity_counter)
{
dvbpsi_error(h_dvbpsi, "PSI decoder",
dvbpsi_error(handle, "PSI decoder",
"TS discontinuity (received %d, expected %d) for PID %d",
h_dvbpsi->i_continuity_counter, i_expected_counter,
p_decoder->i_continuity_counter, i_expected_counter,
((uint16_t)(p_data[1] & 0x1f) << 8) | p_data[2]);
h_dvbpsi->b_discontinuity = 1;
if(h_dvbpsi->p_current_section)
p_decoder->b_discontinuity = 1;
if(p_decoder->p_current_section)
{
dvbpsi_DeletePSISections(h_dvbpsi->p_current_section);
h_dvbpsi->p_current_section = NULL;
dvbpsi_DeletePSISections(p_decoder->p_current_section);
p_decoder->p_current_section = NULL;
}
}
......@@ -208,7 +268,7 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
p_payload_pos += 1;
}
p_section = h_dvbpsi->p_current_section;
p_section = p_decoder->p_current_section;
/* If the psi decoder needs a begginning of section and a new section
begins in the packet then initialize the dvbpsi_psi_section_t structure */
......@@ -217,16 +277,16 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
if(p_new_pos)
{
/* Allocation of the structure */
h_dvbpsi->p_current_section
p_decoder->p_current_section
= p_section
= dvbpsi_NewPSISection(h_dvbpsi->i_section_max_size);
= dvbpsi_NewPSISection(p_decoder->i_section_max_size);
/* Update the position in the packet */
p_payload_pos = p_new_pos;
/* New section is being handled */
p_new_pos = NULL;
/* Just need the header to know how long is the section */
h_dvbpsi->i_need = 3;
h_dvbpsi->b_complete_header = 0;
p_decoder->i_need = 3;
p_decoder->b_complete_header = 0;
}
else
{
......@@ -240,40 +300,40 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
while(i_available > 0)
{
if(i_available >= h_dvbpsi->i_need)
if(i_available >= p_decoder->i_need)
{
/* There are enough bytes in this packet to complete the
header/section */
memcpy(p_section->p_payload_end, p_payload_pos, h_dvbpsi->i_need);
p_payload_pos += h_dvbpsi->i_need;
p_section->p_payload_end += h_dvbpsi->i_need;
i_available -= h_dvbpsi->i_need;
memcpy(p_section->p_payload_end, p_payload_pos, p_decoder->i_need);
p_payload_pos += p_decoder->i_need;
p_section->p_payload_end += p_decoder->i_need;
i_available -= p_decoder->i_need;
if(!h_dvbpsi->b_complete_header)
if(!p_decoder->b_complete_header)
{
/* Header is complete */
h_dvbpsi->b_complete_header = 1;
/* Compute p_section->i_length and update h_dvbpsi->i_need */
h_dvbpsi->i_need = p_section->i_length
p_decoder->b_complete_header = 1;
/* Compute p_section->i_length and update p_decoder->i_need */
p_decoder->i_need = p_section->i_length
= ((uint16_t)(p_section->p_data[1] & 0xf)) << 8
| p_section->p_data[2];
/* Check that the section isn't too long */
if(h_dvbpsi->i_need > h_dvbpsi->i_section_max_size - 3)
if(p_decoder->i_need > p_decoder->i_section_max_size - 3)
{
dvbpsi_error(h_dvbpsi, "PSI decoder", "PSI section too long");
dvbpsi_error(handle, "PSI decoder", "PSI section too long");
dvbpsi_DeletePSISections(p_section);
h_dvbpsi->p_current_section = NULL;
p_decoder->p_current_section = NULL;
/* If there is a new section not being handled then go forward
in the packet */
if(p_new_pos)
{
h_dvbpsi->p_current_section
p_decoder->p_current_section
= p_section
= dvbpsi_NewPSISection(h_dvbpsi->i_section_max_size);
= dvbpsi_NewPSISection(p_decoder->i_section_max_size);
p_payload_pos = p_new_pos;
p_new_pos = NULL;
h_dvbpsi->i_need = 3;
h_dvbpsi->b_complete_header = 0;
p_decoder->i_need = 3;
p_decoder->b_complete_header = 0;
i_available = 188 + p_data - p_payload_pos;
}
else
......@@ -315,16 +375,16 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
p_section->p_payload_start = p_section->p_data + 3;
}
h_dvbpsi->pf_callback(h_dvbpsi, p_section);
h_dvbpsi->p_current_section = NULL;
p_decoder->pf_callback(handle, p_section);
p_decoder->p_current_section = NULL;
}
else
{
dvbpsi_error(h_dvbpsi, "misc PSI", "Bad CRC_32 !!!");
dvbpsi_error(handle, "misc PSI", "Bad CRC_32 !!!");
/* PSI section isn't valid => trash it */
dvbpsi_DeletePSISections(p_section);
h_dvbpsi->p_current_section = NULL;
p_decoder->p_current_section = NULL;
}
/* A TS packet may contain any number of sections, only the first
......@@ -337,13 +397,13 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
in the packet */
if(p_new_pos)
{
h_dvbpsi->p_current_section
p_decoder->p_current_section
= p_section
= dvbpsi_NewPSISection(h_dvbpsi->i_section_max_size);
= dvbpsi_NewPSISection(p_decoder->i_section_max_size);
p_payload_pos = p_new_pos;
p_new_pos = NULL;
h_dvbpsi->i_need = 3;
h_dvbpsi->b_complete_header = 0;
p_decoder->i_need = 3;
p_decoder->b_complete_header = 0;
i_available = 188 + p_data - p_payload_pos;
}
else
......@@ -358,7 +418,7 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
header/section */
memcpy(p_section->p_payload_end, p_payload_pos, i_available);
p_section->p_payload_end += i_available;
h_dvbpsi->i_need -= i_available;
p_decoder->i_need -= i_available;
i_available = 0;
}
}
......@@ -375,7 +435,7 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
#define DVBPSI_MSG_FORMAT "libdvbpsi (%s): "
#ifdef HAVE_VARIADIC_MACROS
void message(dvbpsi_handle dvbpsi, const int level, const char *fmt, ...)
void message(dvbpsi_t *dvbpsi, const int level, const char *fmt, ...)
{
if ((dvbpsi->i_msg_level > DVBPSI_MSG_NONE) &&
(level <= dvbpsi->i_msg_level))
......@@ -400,7 +460,7 @@ void message(dvbpsi_handle dvbpsi, const int level, const char *fmt, ...)
}
}
#else
void dvbpsi_error(dvbpsi_handle dvbpsi, const char *src, const char *fmt, ...)
void dvbpsi_error(dvbpsi_t *dvbpsi, const char *src, const char *fmt, ...)
{
if (DVBPSI_MSG_ERROR <= dvbpsi->i_msg_level)
{
......@@ -430,7 +490,7 @@ void dvbpsi_error(dvbpsi_handle dvbpsi, const char *src, const char *fmt, ...)
}
}
void dvbpsi_warning(dvbpsi_handle dvbpsi, const char *src, const char *fmt, ...)
void dvbpsi_warning(dvbpsi_t *dvbpsi, const char *src, const char *fmt, ...)
{
if (DVBPSI_MSG_WARNING <= dvbpsi->i_msg_level)
{
......@@ -460,7 +520,7 @@ void dvbpsi_warning(dvbpsi_handle dvbpsi, const char *src, const char *fmt, ...)
}
}
void dvbpsi_debug(dvbpsi_handle dvbpsi, const char *src, const char *fmt, ...)
void dvbpsi_debug(dvbpsi_t *dvbpsi, const char *src, const char *fmt, ...)
{
if (DVBPSI_MSG_DEBUG <= dvbpsi->i_msg_level)
{
......
......@@ -4,6 +4,7 @@
* $Id$
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* Jean-Paul Saman <jpsaman@videolan.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -40,16 +41,82 @@
extern "C" {
#endif
/*****************************************************************************
* dvbpsi_handle
*****************************************************************************/
/*!
* \typedef struct dvbpsi_decoder_s * dvbpsi_handle
* \brief Decoder abstration.
* \typedef struct dvbpsi_s dvbpsi_t
* \brief DVBPSI handle structure abstration.
*/
typedef struct dvbpsi_decoder_s * dvbpsi_handle;
typedef struct dvbpsi_s dvbpsi_t;
/*****************************************************************************
* dvbpsi_message_cb
*****************************************************************************/
/*!
* \typedef void (* dvbpsi_message_cb)(dvbpsi_handle p_decoder,
* const char* msg)
* \brief Callback type definition.
*/
typedef void (* dvbpsi_message_cb)(dvbpsi_t *handle,
const char* msg);
/*****************************************************************************
* dvbpsi_t
*****************************************************************************/
/*!
* \struct dvbpsi_s
* \brief DVBPSI handle structure
*
* This structure provides a handle to libdvbpsi API and should be used instead