Commit fdae10cd authored by Jean-Paul Saman's avatar Jean-Paul Saman

descriptors: implement some helper functions

- add dvbpsi_CanDecodeAsDescriptor() helper function
- add dvbpsi_IsDescriptorDecoded() helper function
- update descriptors
parent 2d8ba47b
...@@ -39,6 +39,41 @@ ...@@ -39,6 +39,41 @@
#include "dvbpsi.h" #include "dvbpsi.h"
#include "descriptor.h" #include "descriptor.h"
/*****************************************************************************
* dvbpsi_IsDescriptor
*****************************************************************************
* Is this descriptor of type i_tag?
*****************************************************************************/
static inline bool dvbpsi_IsDescriptor(dvbpsi_descriptor_t *p_descriptor, const uint8_t i_tag)
{
return (p_descriptor->i_tag == i_tag);
}
/*****************************************************************************
* IsDescriptorDecoded
*****************************************************************************
* Is this descriptor already decoded?
*****************************************************************************/
bool dvbpsi_IsDescriptorDecoded(dvbpsi_descriptor_t *p_descriptor)
{
return (p_descriptor->p_decoded != NULL);
}
/*****************************************************************************
* dvbpsi_CanDescodeAsDescriptor
*****************************************************************************
* Can Decode this descriptor as?
*****************************************************************************/
bool dvbpsi_CanDecodeAsDescriptor(dvbpsi_descriptor_t *p_descriptor, const uint8_t i_tag)
{
if (!p_descriptor)
return false;
if (!dvbpsi_IsDescriptor(p_descriptor, i_tag))
return false;
return true;
}
/***************************************************************************** /*****************************************************************************
* dvbpsi_NewDescriptor * dvbpsi_NewDescriptor
...@@ -85,10 +120,10 @@ void dvbpsi_DeleteDescriptors(dvbpsi_descriptor_t* p_descriptor) ...@@ -85,10 +120,10 @@ void dvbpsi_DeleteDescriptors(dvbpsi_descriptor_t* p_descriptor)
dvbpsi_descriptor_t* p_next = p_descriptor->p_next; dvbpsi_descriptor_t* p_next = p_descriptor->p_next;
if (p_descriptor->p_data != NULL) if (p_descriptor->p_data != NULL)
free(p_descriptor->p_data); free(p_descriptor->p_data);
if (p_descriptor->p_decoded != NULL) if (p_descriptor->p_decoded != NULL)
free(p_descriptor->p_decoded); free(p_descriptor->p_decoded);
free(p_descriptor); free(p_descriptor);
p_descriptor = p_next; p_descriptor = p_next;
......
...@@ -68,7 +68,6 @@ typedef struct dvbpsi_descriptor_s ...@@ -68,7 +68,6 @@ typedef struct dvbpsi_descriptor_s
} dvbpsi_descriptor_t; } dvbpsi_descriptor_t;
/***************************************************************************** /*****************************************************************************
* dvbpsi_NewDescriptor * dvbpsi_NewDescriptor
*****************************************************************************/ *****************************************************************************/
...@@ -97,6 +96,28 @@ dvbpsi_descriptor_t* dvbpsi_NewDescriptor(uint8_t i_tag, uint8_t i_length, ...@@ -97,6 +96,28 @@ dvbpsi_descriptor_t* dvbpsi_NewDescriptor(uint8_t i_tag, uint8_t i_length,
*/ */
void dvbpsi_DeleteDescriptors(dvbpsi_descriptor_t* p_descriptor); void dvbpsi_DeleteDescriptors(dvbpsi_descriptor_t* p_descriptor);
/*****************************************************************************
* dvbpsi_CanDecodeAsDescriptor
*****************************************************************************/
/*!
* \fn bool dvbpsi_CanDecodeAsDescriptor(dvbpsi_descriptor_t *p_descriptor, const uint8_t i_tag);
* \brief Checks if descriptor tag matches.
* \param p_descriptor pointer to descriptor allocated with @see dvbpsi_NewDescriptor
* \param i_tag descriptor tag to evaluate against
* \return true if descriptor can be decoded, false if not.
*/
bool dvbpsi_CanDecodeAsDescriptor(dvbpsi_descriptor_t *p_descriptor, const uint8_t i_tag);
/*****************************************************************************
* dvbpsi_IsDescriptorDecoded
*****************************************************************************/
/*!
* \fn bool dvbpsi_IsDescriptorDecoded(dvbpsi_descriptor_t *p_descriptor);
* \brief Checks if descriptor was already decoded.
* \param p_descriptor pointer to descriptor allocated with @see dvbpsi_NewDescriptor
* \return true if descriptor can be decoded, false if already decoded.
*/
bool dvbpsi_IsDescriptorDecoded(dvbpsi_descriptor_t *p_descriptor);
#ifdef __cplusplus #ifdef __cplusplus
}; };
......
...@@ -48,12 +48,12 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor) ...@@ -48,12 +48,12 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor)
dvbpsi_vstream_dr_t * p_decoded; dvbpsi_vstream_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x02) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x02))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_vstream_dr_t*)malloc(sizeof(dvbpsi_vstream_dr_t)); p_decoded = (dvbpsi_vstream_dr_t*)malloc(sizeof(dvbpsi_vstream_dr_t));
......
...@@ -49,12 +49,12 @@ dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor) ...@@ -49,12 +49,12 @@ dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor)
dvbpsi_astream_dr_t * p_decoded; dvbpsi_astream_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x03) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x03))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_astream_dr_t*)malloc(sizeof(dvbpsi_astream_dr_t)); p_decoded = (dvbpsi_astream_dr_t*)malloc(sizeof(dvbpsi_astream_dr_t));
...@@ -67,10 +67,10 @@ dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor) ...@@ -67,10 +67,10 @@ dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor)
return NULL; return NULL;
} }
p_decoded->b_free_format = (p_descriptor->p_data[0] & 0x80); p_decoded->b_free_format = (p_descriptor->p_data[0] & 0x80) ? true : false;
p_decoded->i_id = (p_descriptor->p_data[0] & 0x40) >> 6; p_decoded->i_id = (p_descriptor->p_data[0] & 0x40) >> 6;
p_decoded->i_layer = (p_descriptor->p_data[0] & 0x30) >> 4; p_decoded->i_layer = (p_descriptor->p_data[0] & 0x30) >> 4;
p_decoded->b_variable_rate_audio_indicator = (p_descriptor->p_data[0] & 0x08) >> 3; p_decoded->b_variable_rate_audio_indicator = ((p_descriptor->p_data[0] & 0x08) >> 3) ? true : false;
p_descriptor->p_decoded = (void*)p_decoded; p_descriptor->p_decoded = (void*)p_decoded;
......
...@@ -50,12 +50,12 @@ dvbpsi_hierarchy_dr_t * dvbpsi_DecodeHierarchyDr( ...@@ -50,12 +50,12 @@ dvbpsi_hierarchy_dr_t * dvbpsi_DecodeHierarchyDr(
dvbpsi_hierarchy_dr_t * p_decoded; dvbpsi_hierarchy_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x04) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x04))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_hierarchy_dr_t*)malloc(sizeof(dvbpsi_hierarchy_dr_t)); p_decoded = (dvbpsi_hierarchy_dr_t*)malloc(sizeof(dvbpsi_hierarchy_dr_t));
......
...@@ -50,12 +50,12 @@ dvbpsi_registration_dr_t * dvbpsi_DecodeRegistrationDr( ...@@ -50,12 +50,12 @@ dvbpsi_registration_dr_t * dvbpsi_DecodeRegistrationDr(
dvbpsi_registration_dr_t * p_decoded; dvbpsi_registration_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x05) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x05))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_registration_dr_t*) p_decoded = (dvbpsi_registration_dr_t*)
......
...@@ -50,13 +50,9 @@ dvbpsi_ds_alignment_dr_t * dvbpsi_DecodeDSAlignmentDr( ...@@ -50,13 +50,9 @@ dvbpsi_ds_alignment_dr_t * dvbpsi_DecodeDSAlignmentDr(
dvbpsi_ds_alignment_dr_t * p_decoded; dvbpsi_ds_alignment_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x06) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x06))
return NULL; return NULL;
/* Don't decode twice */
if(p_descriptor->p_decoded)
return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_ds_alignment_dr_t*) p_decoded = (dvbpsi_ds_alignment_dr_t*)
malloc(sizeof(dvbpsi_ds_alignment_dr_t)); malloc(sizeof(dvbpsi_ds_alignment_dr_t));
......
...@@ -50,12 +50,12 @@ dvbpsi_target_bg_grid_dr_t * dvbpsi_DecodeTargetBgGridDr( ...@@ -50,12 +50,12 @@ dvbpsi_target_bg_grid_dr_t * dvbpsi_DecodeTargetBgGridDr(
dvbpsi_target_bg_grid_dr_t * p_decoded; dvbpsi_target_bg_grid_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x07) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x07))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_target_bg_grid_dr_t*) p_decoded = (dvbpsi_target_bg_grid_dr_t*)
......
...@@ -49,12 +49,12 @@ dvbpsi_vwindow_dr_t * dvbpsi_DecodeVWindowDr(dvbpsi_descriptor_t * p_descriptor) ...@@ -49,12 +49,12 @@ dvbpsi_vwindow_dr_t * dvbpsi_DecodeVWindowDr(dvbpsi_descriptor_t * p_descriptor)
dvbpsi_vwindow_dr_t * p_decoded; dvbpsi_vwindow_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x08) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x08))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_vwindow_dr_t*)malloc(sizeof(dvbpsi_vwindow_dr_t)); p_decoded = (dvbpsi_vwindow_dr_t*)malloc(sizeof(dvbpsi_vwindow_dr_t));
......
...@@ -49,12 +49,12 @@ dvbpsi_ca_dr_t * dvbpsi_DecodeCADr(dvbpsi_descriptor_t * p_descriptor) ...@@ -49,12 +49,12 @@ dvbpsi_ca_dr_t * dvbpsi_DecodeCADr(dvbpsi_descriptor_t * p_descriptor)
dvbpsi_ca_dr_t * p_decoded; dvbpsi_ca_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x09) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x09))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_ca_dr_t*)malloc(sizeof(dvbpsi_ca_dr_t)); p_decoded = (dvbpsi_ca_dr_t*)malloc(sizeof(dvbpsi_ca_dr_t));
......
...@@ -50,12 +50,12 @@ dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor) ...@@ -50,12 +50,12 @@ dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor)
int i; int i;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x0a) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0a))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_iso639_dr_t*)malloc(sizeof(dvbpsi_iso639_dr_t)); p_decoded = (dvbpsi_iso639_dr_t*)malloc(sizeof(dvbpsi_iso639_dr_t));
......
...@@ -50,12 +50,12 @@ dvbpsi_system_clock_dr_t * dvbpsi_DecodeSystemClockDr( ...@@ -50,12 +50,12 @@ dvbpsi_system_clock_dr_t * dvbpsi_DecodeSystemClockDr(
dvbpsi_system_clock_dr_t * p_decoded; dvbpsi_system_clock_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x0b) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0b))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = p_decoded =
......
...@@ -50,12 +50,12 @@ dvbpsi_mx_buff_utilization_dr_t * dvbpsi_DecodeMxBuffUtilizationDr( ...@@ -50,12 +50,12 @@ dvbpsi_mx_buff_utilization_dr_t * dvbpsi_DecodeMxBuffUtilizationDr(
dvbpsi_mx_buff_utilization_dr_t * p_decoded; dvbpsi_mx_buff_utilization_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x0c) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0c))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_mx_buff_utilization_dr_t*) p_decoded = (dvbpsi_mx_buff_utilization_dr_t*)
......
...@@ -50,12 +50,12 @@ dvbpsi_copyright_dr_t * dvbpsi_DecodeCopyrightDr( ...@@ -50,12 +50,12 @@ dvbpsi_copyright_dr_t * dvbpsi_DecodeCopyrightDr(
dvbpsi_copyright_dr_t * p_decoded; dvbpsi_copyright_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x0d) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0d))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_copyright_dr_t*) p_decoded = (dvbpsi_copyright_dr_t*)
......
...@@ -50,12 +50,12 @@ dvbpsi_max_bitrate_dr_t * dvbpsi_DecodeMaxBitrateDr( ...@@ -50,12 +50,12 @@ dvbpsi_max_bitrate_dr_t * dvbpsi_DecodeMaxBitrateDr(
dvbpsi_max_bitrate_dr_t * p_decoded; dvbpsi_max_bitrate_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x0e) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0e))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_max_bitrate_dr_t*)malloc(sizeof(dvbpsi_max_bitrate_dr_t)); p_decoded = (dvbpsi_max_bitrate_dr_t*)malloc(sizeof(dvbpsi_max_bitrate_dr_t));
......
...@@ -50,12 +50,12 @@ dvbpsi_private_data_dr_t * dvbpsi_DecodePrivateDataDr( ...@@ -50,12 +50,12 @@ dvbpsi_private_data_dr_t * dvbpsi_DecodePrivateDataDr(
dvbpsi_private_data_dr_t * p_decoded; dvbpsi_private_data_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x0f) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0f))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = p_decoded =
......
...@@ -48,12 +48,12 @@ dvbpsi_network_name_dr_t* dvbpsi_DecodeNetworkNameDr( ...@@ -48,12 +48,12 @@ dvbpsi_network_name_dr_t* dvbpsi_DecodeNetworkNameDr(
dvbpsi_network_name_dr_t * p_decoded; dvbpsi_network_name_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if (p_descriptor->i_tag != 0x40) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x40))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if (p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_network_name_dr_t*)calloc(1, sizeof(dvbpsi_network_name_dr_t)); p_decoded = (dvbpsi_network_name_dr_t*)calloc(1, sizeof(dvbpsi_network_name_dr_t));
......
...@@ -51,12 +51,12 @@ dvbpsi_stuffing_dr_t * dvbpsi_DecodeStuffingDr( ...@@ -51,12 +51,12 @@ dvbpsi_stuffing_dr_t * dvbpsi_DecodeStuffingDr(
dvbpsi_stuffing_dr_t * p_decoded; dvbpsi_stuffing_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x42) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x42))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = p_decoded =
......
...@@ -50,12 +50,12 @@ dvbpsi_sat_deliv_sys_dr_t * dvbpsi_DecodeSatDelivSysDr( ...@@ -50,12 +50,12 @@ dvbpsi_sat_deliv_sys_dr_t * dvbpsi_DecodeSatDelivSysDr(
dvbpsi_sat_deliv_sys_dr_t * p_decoded; dvbpsi_sat_deliv_sys_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x43) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x43))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = p_decoded =
......
...@@ -50,12 +50,12 @@ dvbpsi_cable_deliv_sys_dr_t * dvbpsi_DecodeCableDelivSysDr( ...@@ -50,12 +50,12 @@ dvbpsi_cable_deliv_sys_dr_t * dvbpsi_DecodeCableDelivSysDr(
dvbpsi_cable_deliv_sys_dr_t * p_decoded; dvbpsi_cable_deliv_sys_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if (p_descriptor->i_tag != 0x44) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x44))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = p_decoded =
......
...@@ -50,12 +50,12 @@ dvbpsi_vbi_dr_t * dvbpsi_DecodeVBIDataDr( ...@@ -50,12 +50,12 @@ dvbpsi_vbi_dr_t * dvbpsi_DecodeVBIDataDr(
dvbpsi_vbi_dr_t * p_decoded; dvbpsi_vbi_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if( p_descriptor->i_tag != 0x45 ) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x45))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Decode data and check the length */ /* Decode data and check the length */
if(p_descriptor->i_length < 3) if(p_descriptor->i_length < 3)
......
...@@ -51,12 +51,12 @@ dvbpsi_bouquet_name_dr_t * dvbpsi_DecodeBouquetNameDr( ...@@ -51,12 +51,12 @@ dvbpsi_bouquet_name_dr_t * dvbpsi_DecodeBouquetNameDr(
dvbpsi_bouquet_name_dr_t * p_decoded; dvbpsi_bouquet_name_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x47) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x47))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = p_decoded =
......
...@@ -51,12 +51,12 @@ dvbpsi_service_dr_t * dvbpsi_DecodeServiceDr( ...@@ -51,12 +51,12 @@ dvbpsi_service_dr_t * dvbpsi_DecodeServiceDr(
dvbpsi_service_dr_t * p_decoded; dvbpsi_service_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x48) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x48))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = p_decoded =
......
...@@ -50,10 +50,14 @@ dvbpsi_short_event_dr_t * dvbpsi_DecodeShortEventDr(dvbpsi_descriptor_t * p_desc ...@@ -50,10 +50,14 @@ dvbpsi_short_event_dr_t * dvbpsi_DecodeShortEventDr(dvbpsi_descriptor_t * p_desc
int i_len2; int i_len2;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x4d || if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x4d) ||
p_descriptor->i_length < 5 ) p_descriptor->i_length < 5 )
return NULL; return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Check length */ /* Check length */
i_len1 = p_descriptor->p_data[3]; i_len1 = p_descriptor->p_data[3];
i_len2 = p_descriptor->p_data[4+i_len1]; i_len2 = p_descriptor->p_data[4+i_len1];
......
...@@ -51,13 +51,13 @@ dvbpsi_extended_event_dr_t * dvbpsi_DecodeExtendedEventDr(dvbpsi_descriptor_t * ...@@ -51,13 +51,13 @@ dvbpsi_extended_event_dr_t * dvbpsi_DecodeExtendedEventDr(dvbpsi_descriptor_t *
uint8_t *p; uint8_t *p;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x4e || if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x4e) ||
p_descriptor->i_length < 6 ) p_descriptor->i_length < 6 )
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = malloc(sizeof(dvbpsi_extended_event_dr_t)); p_decoded = malloc(sizeof(dvbpsi_extended_event_dr_t));
......
...@@ -49,12 +49,12 @@ dvbpsi_stream_identifier_dr_t * dvbpsi_DecodeStreamIdentifierDr( ...@@ -49,12 +49,12 @@ dvbpsi_stream_identifier_dr_t * dvbpsi_DecodeStreamIdentifierDr(
dvbpsi_stream_identifier_dr_t * p_decoded; dvbpsi_stream_identifier_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x52) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x52))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = p_decoded =
......
...@@ -51,12 +51,12 @@ dvbpsi_parental_rating_dr_t * dvbpsi_DecodeParentalRatingDr( ...@@ -51,12 +51,12 @@ dvbpsi_parental_rating_dr_t * dvbpsi_DecodeParentalRatingDr(
dvbpsi_parental_rating_dr_t * p_decoded; dvbpsi_parental_rating_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x55) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x55))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = p_decoded =
......
...@@ -50,12 +50,13 @@ dvbpsi_teletext_dr_t * dvbpsi_DecodeTeletextDr( ...@@ -50,12 +50,13 @@ dvbpsi_teletext_dr_t * dvbpsi_DecodeTeletextDr(
dvbpsi_teletext_dr_t * p_decoded; dvbpsi_teletext_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if( (p_descriptor->i_tag != 0x56) && (p_descriptor->i_tag != 0x46) ) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x56) &&
!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x46))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Decode data and check the length */ /* Decode data and check the length */
if(p_descriptor->i_length < 3) if(p_descriptor->i_length < 3)
......
...@@ -52,12 +52,12 @@ dvbpsi_local_time_offset_dr_t * dvbpsi_DecodeLocalTimeOffsetDr( ...@@ -52,12 +52,12 @@ dvbpsi_local_time_offset_dr_t * dvbpsi_DecodeLocalTimeOffsetDr(
dvbpsi_local_time_offset_t * p_current; dvbpsi_local_time_offset_t * p_current;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x58) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x58))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = p_decoded =
......
...@@ -52,12 +52,16 @@ dvbpsi_subtitling_dr_t * dvbpsi_DecodeSubtitlingDr( ...@@ -52,12 +52,16 @@ dvbpsi_subtitling_dr_t * dvbpsi_DecodeSubtitlingDr(
dvbpsi_subtitling_dr_t * p_decoded; dvbpsi_subtitling_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x59) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x59))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
return NULL;
/* Allocate memory */ /* Allocate memory */
p_decoded = p_decoded =
......
...@@ -50,12 +50,12 @@ dvbpsi_terr_deliv_sys_dr_t * dvbpsi_DecodeTerrDelivSysDr( ...@@ -50,12 +50,12 @@ dvbpsi_terr_deliv_sys_dr_t * dvbpsi_DecodeTerrDelivSysDr(
dvbpsi_terr_deliv_sys_dr_t * p_decoded; dvbpsi_terr_deliv_sys_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x5a) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x5a))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = p_decoded =
......
...@@ -49,14 +49,14 @@ dvbpsi_PDC_dr_t * dvbpsi_DecodePDCDr(dvbpsi_descriptor_t * p_descriptor) ...@@ -49,14 +49,14 @@ dvbpsi_PDC_dr_t * dvbpsi_DecodePDCDr(dvbpsi_descriptor_t * p_descriptor)
dvbpsi_PDC_dr_t * p_decoded; dvbpsi_PDC_dr_t * p_decoded;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x69) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x69))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Decode data and check the length */ /* Check the length */
if( p_descriptor->i_length != 3) if( p_descriptor->i_length != 3)
return NULL; return NULL;
......
...@@ -48,12 +48,12 @@ dvbpsi_cuei_dr_t * dvbpsi_DecodeCUEIDr(dvbpsi_descriptor_t * p_descriptor) ...@@ -48,12 +48,12 @@ dvbpsi_cuei_dr_t * dvbpsi_DecodeCUEIDr(dvbpsi_descriptor_t * p_descriptor)
dvbpsi_cuei_dr_t *p_decoded; dvbpsi_cuei_dr_t *p_decoded;
/* Check the tag */ /* Check the tag */
if (p_descriptor->i_tag != 0x8a) if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x8a))
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if (p_descriptor->p_decoded) if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Allocate memory */ /* Allocate memory */
p_decoded = (dvbpsi_cuei_dr_t*)malloc(sizeof(dvbpsi_cuei_dr_t)); p_decoded = (dvbpsi_cuei_dr_t*)malloc(sizeof(dvbpsi_cuei_dr_t));
......
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