Commit 81d3a7c9 authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/tables/pmt.*: Make dvbpsi_NewPMT() and dvbpsi_DeletePMT() functions.

parent 774d741b
...@@ -112,6 +112,8 @@ void dvbpsi_DetachPMT(dvbpsi_t *p_dvbpsi) ...@@ -112,6 +112,8 @@ void dvbpsi_DetachPMT(dvbpsi_t *p_dvbpsi)
void dvbpsi_InitPMT(dvbpsi_pmt_t* p_pmt, uint16_t i_program_number, void dvbpsi_InitPMT(dvbpsi_pmt_t* p_pmt, uint16_t i_program_number,
uint8_t i_version, bool b_current_next, uint16_t i_pcr_pid) uint8_t i_version, bool b_current_next, uint16_t i_pcr_pid)
{ {
assert(p_pmt);
p_pmt->i_program_number = i_program_number; p_pmt->i_program_number = i_program_number;
p_pmt->i_version = i_version; p_pmt->i_version = i_version;
p_pmt->b_current_next = b_current_next; p_pmt->b_current_next = b_current_next;
...@@ -120,6 +122,21 @@ void dvbpsi_InitPMT(dvbpsi_pmt_t* p_pmt, uint16_t i_program_number, ...@@ -120,6 +122,21 @@ void dvbpsi_InitPMT(dvbpsi_pmt_t* p_pmt, uint16_t i_program_number,
p_pmt->p_first_es = NULL; p_pmt->p_first_es = NULL;
} }
/*****************************************************************************
* dvbpsi_NewPMT
*****************************************************************************
* Allocate and Initialize a new dvbpsi_pmt_t structure.
*****************************************************************************/
dvbpsi_pmt_t* dvbpsi_NewPMT(uint16_t i_program_number, uint8_t i_version,
bool b_current_next, uint16_t i_pcr_pid)
{
dvbpsi_pmt_t *p_pmt = (dvbpsi_pmt_t*)malloc(sizeof(dvbpsi_pmt_t));
if(p_pmt != NULL)
dvbpsi_InitPMT(p_pmt, i_program_number, i_version,
b_current_next, i_pcr_pid);
return p_pmt;
}
/***************************************************************************** /*****************************************************************************
* dvbpsi_EmptyPMT * dvbpsi_EmptyPMT
***************************************************************************** *****************************************************************************
...@@ -143,6 +160,18 @@ void dvbpsi_EmptyPMT(dvbpsi_pmt_t* p_pmt) ...@@ -143,6 +160,18 @@ void dvbpsi_EmptyPMT(dvbpsi_pmt_t* p_pmt)
p_pmt->p_first_es = NULL; p_pmt->p_first_es = NULL;
} }
/*****************************************************************************
* dvbpsi_DeletePMT
*****************************************************************************
* Clean a dvbpsi_pmt_t structure.
*****************************************************************************/
void dvbpsi_DeletePMT(dvbpsi_pmt_t* p_pmt)
{
if (p_pmt)
dvbpsi_EmptyPMT(p_pmt);
free(p_pmt);
}
/***************************************************************************** /*****************************************************************************
* dvbpsi_PMTAddDescriptor * dvbpsi_PMTAddDescriptor
***************************************************************************** *****************************************************************************
......
...@@ -153,24 +153,18 @@ void dvbpsi_InitPMT(dvbpsi_pmt_t* p_pmt, uint16_t i_program_number, ...@@ -153,24 +153,18 @@ void dvbpsi_InitPMT(dvbpsi_pmt_t* p_pmt, uint16_t i_program_number,
uint8_t i_version, bool b_current_next, uint16_t i_pcr_pid); uint8_t i_version, bool b_current_next, uint16_t i_pcr_pid);
/*! /*!
* \def dvbpsi_NewPMT(p_pmt, i_program_number, * \fn dvbpsi_pmt_t* dvbpsi_NewPMT(uint16_t i_program_number,
i_version, b_current_next, i_pcr_pid) uint8_t i_version, bool b_current_next,
uint16_t i_pcr_pid)
* \brief Allocate and initialize a new dvbpsi_pmt_t structure. * \brief Allocate and initialize a new dvbpsi_pmt_t structure.
* \param p_pmt pointer to the PMT structure
* \param i_program_number program number * \param i_program_number program number
* \param i_version PMT version * \param i_version PMT version
* \param b_current_next current next indicator * \param b_current_next current next indicator
* \param i_pcr_pid PCR_PID * \param i_pcr_pid PCR_PID
* \return nothing. * \return p_pmt pointer to the PMT structure
*/ */
#define dvbpsi_NewPMT(p_pmt, i_program_number, \ dvbpsi_pmt_t* dvbpsi_NewPMT(uint16_t i_program_number, uint8_t i_version,
i_version, b_current_next, i_pcr_pid) \ bool b_current_next, uint16_t i_pcr_pid);
do { \
p_pmt = (dvbpsi_pmt_t*)malloc(sizeof(dvbpsi_pmt_t)); \
if(p_pmt != NULL) \
dvbpsi_InitPMT(p_pmt, i_program_number, i_version, b_current_next, \
i_pcr_pid); \
} while(0);
/***************************************************************************** /*****************************************************************************
* dvbpsi_EmptyPMT/dvbpsi_DeletePMT * dvbpsi_EmptyPMT/dvbpsi_DeletePMT
...@@ -184,16 +178,12 @@ do { \ ...@@ -184,16 +178,12 @@ do { \
void dvbpsi_EmptyPMT(dvbpsi_pmt_t* p_pmt); void dvbpsi_EmptyPMT(dvbpsi_pmt_t* p_pmt);
/*! /*!
* \def dvbpsi_DeletePMT(p_pmt) * \fn void dvbpsi_DeletePMT(dvbpsi_pmt_t* p_pmt)
* \brief Clean and free a dvbpsi_pmt_t structure. * \brief Clean and free a dvbpsi_pmt_t structure.
* \param p_pmt pointer to the PMT structure * \param p_pmt pointer to the PMT structure
* \return nothing. * \return nothing.
*/ */
#define dvbpsi_DeletePMT(p_pmt) \ void dvbpsi_DeletePMT(dvbpsi_pmt_t* p_pmt);
do { \
dvbpsi_EmptyPMT(p_pmt); \
free(p_pmt); \
} while(0);
/***************************************************************************** /*****************************************************************************
* dvbpsi_PMTAddDescriptor * dvbpsi_PMTAddDescriptor
......
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