Commit 1f223e37 authored by Jean-Paul Saman's avatar Jean-Paul Saman

unify error, debug and warning messages

Libdvbpsi used printf and fprintf to return debug and error information to the caller.
This bypasses any logging mechanism the calling application uses and does not take
multi-threaded applications into account.
The unifying of messages (error, debug or warning) allows a calling application to
filter (message level: -1, 0, 1 or 2) and handle the messages in its own way.
parent d4a47c1f
......@@ -51,7 +51,7 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if(p_descriptor->i_tag != 0x02)
{
DVBPSI_ERROR_ARG("dr_02 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_02 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -61,11 +61,7 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor)
/* Allocate memory */
p_decoded = (dvbpsi_vstream_dr_t*)malloc(sizeof(dvbpsi_vstream_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_02 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
p_decoded->b_mpeg2 = (p_descriptor->p_data[0] & 0x04) ? 1 : 0;
......@@ -73,7 +69,7 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor)
if( (!p_decoded->b_mpeg2 && (p_descriptor->i_length != 1))
|| (p_decoded->b_mpeg2 && (p_descriptor->i_length != 3)))
{
DVBPSI_ERROR_ARG("dr_02 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_02 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
......
......@@ -51,7 +51,7 @@ dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if(p_descriptor->i_tag != 0x03)
{
DVBPSI_ERROR_ARG("dr_03 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_03 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -61,16 +61,12 @@ dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor)
/* Allocate memory */
p_decoded = (dvbpsi_astream_dr_t*)malloc(sizeof(dvbpsi_astream_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_03 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 1)
{
DVBPSI_ERROR_ARG("dr_03 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_03 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_hierarchy_dr_t * dvbpsi_DecodeHierarchyDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x04)
{
DVBPSI_ERROR_ARG("dr_04 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_04 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -62,16 +62,12 @@ dvbpsi_hierarchy_dr_t * dvbpsi_DecodeHierarchyDr(
/* Allocate memory */
p_decoded = (dvbpsi_hierarchy_dr_t*)malloc(sizeof(dvbpsi_hierarchy_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_04 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 4)
{
DVBPSI_ERROR_ARG("dr_04 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_04 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_registration_dr_t * dvbpsi_DecodeRegistrationDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x05)
{
DVBPSI_ERROR_ARG("dr_05 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_05 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_registration_dr_t * dvbpsi_DecodeRegistrationDr(
/* Allocate memory */
p_decoded = (dvbpsi_registration_dr_t*)
malloc(sizeof(dvbpsi_registration_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_05 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 4)
{
DVBPSI_ERROR_ARG("dr_05 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_05 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_ds_alignment_dr_t * dvbpsi_DecodeDSAlignmentDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x06)
{
DVBPSI_ERROR_ARG("dr_06 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_06 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_ds_alignment_dr_t * dvbpsi_DecodeDSAlignmentDr(
/* Allocate memory */
p_decoded = (dvbpsi_ds_alignment_dr_t*)
malloc(sizeof(dvbpsi_ds_alignment_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_06 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 1)
{
DVBPSI_ERROR_ARG("dr_06 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_06 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_target_bg_grid_dr_t * dvbpsi_DecodeTargetBgGridDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x07)
{
DVBPSI_ERROR_ARG("dr_07 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_07 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_target_bg_grid_dr_t * dvbpsi_DecodeTargetBgGridDr(
/* Allocate memory */
p_decoded = (dvbpsi_target_bg_grid_dr_t*)
malloc(sizeof(dvbpsi_target_bg_grid_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_07 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 4)
{
DVBPSI_ERROR_ARG("dr_07 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_07 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -51,7 +51,7 @@ dvbpsi_vwindow_dr_t * dvbpsi_DecodeVWindowDr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if(p_descriptor->i_tag != 0x08)
{
DVBPSI_ERROR_ARG("dr_08 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_08 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -61,16 +61,12 @@ dvbpsi_vwindow_dr_t * dvbpsi_DecodeVWindowDr(dvbpsi_descriptor_t * p_descriptor)
/* Allocate memory */
p_decoded = (dvbpsi_vwindow_dr_t*)malloc(sizeof(dvbpsi_vwindow_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_08 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 4)
{
DVBPSI_ERROR_ARG("dr_08 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_08 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -51,7 +51,7 @@ dvbpsi_ca_dr_t * dvbpsi_DecodeCADr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if(p_descriptor->i_tag != 0x09)
{
DVBPSI_ERROR_ARG("dr_09 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_09 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -61,16 +61,12 @@ dvbpsi_ca_dr_t * dvbpsi_DecodeCADr(dvbpsi_descriptor_t * p_descriptor)
/* Allocate memory */
p_decoded = (dvbpsi_ca_dr_t*)malloc(sizeof(dvbpsi_ca_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_09 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 4)
{
DVBPSI_ERROR_ARG("dr_09 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_09 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if(p_descriptor->i_tag != 0x0a)
{
DVBPSI_ERROR_ARG("dr_0a decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_0a decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -62,16 +62,12 @@ dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor)
/* Allocate memory */
p_decoded = (dvbpsi_iso639_dr_t*)malloc(sizeof(dvbpsi_iso639_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_0a decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if((p_descriptor->i_length < 1) || (p_descriptor->i_length % 4 != 0))
{
DVBPSI_ERROR_ARG("dr_0a decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_0a decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_system_clock_dr_t * dvbpsi_DecodeSystemClockDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x0b)
{
DVBPSI_ERROR_ARG("dr_0b decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_0b decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_system_clock_dr_t * dvbpsi_DecodeSystemClockDr(
/* Allocate memory */
p_decoded =
(dvbpsi_system_clock_dr_t*)malloc(sizeof(dvbpsi_system_clock_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_0b decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 2)
{
DVBPSI_ERROR_ARG("dr_0b decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_0b decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_mx_buff_utilization_dr_t * dvbpsi_DecodeMxBuffUtilizationDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x0c)
{
DVBPSI_ERROR_ARG("dr_0c decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_0c decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_mx_buff_utilization_dr_t * dvbpsi_DecodeMxBuffUtilizationDr(
/* Allocate memory */
p_decoded = (dvbpsi_mx_buff_utilization_dr_t*)
malloc(sizeof(dvbpsi_mx_buff_utilization_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_0c decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 3)
{
DVBPSI_ERROR_ARG("dr_0c decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_0c decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_copyright_dr_t * dvbpsi_DecodeCopyrightDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x0d)
{
DVBPSI_ERROR_ARG("dr_0d decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_0d decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_copyright_dr_t * dvbpsi_DecodeCopyrightDr(
/* Allocate memory */
p_decoded = (dvbpsi_copyright_dr_t*)
malloc(sizeof(dvbpsi_copyright_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_0d decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 4)
{
DVBPSI_ERROR_ARG("dr_0c decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_0c decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_max_bitrate_dr_t * dvbpsi_DecodeMaxBitrateDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x0e)
{
DVBPSI_ERROR_ARG("dr_0e decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_0e decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -62,16 +62,12 @@ dvbpsi_max_bitrate_dr_t * dvbpsi_DecodeMaxBitrateDr(
/* Allocate memory */
p_decoded = (dvbpsi_max_bitrate_dr_t*)malloc(sizeof(dvbpsi_max_bitrate_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_0e decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 3)
{
DVBPSI_ERROR_ARG("dr_0e decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_0e decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_private_data_dr_t * dvbpsi_DecodePrivateDataDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x0f)
{
DVBPSI_ERROR_ARG("dr_0f decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_0f decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_private_data_dr_t * dvbpsi_DecodePrivateDataDr(
/* Allocate memory */
p_decoded =
(dvbpsi_private_data_dr_t*)malloc(sizeof(dvbpsi_private_data_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_0f decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 4)
{
DVBPSI_ERROR_ARG("dr_0f decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_0f decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -53,7 +53,7 @@ dvbpsi_stuffing_dr_t * dvbpsi_DecodeStuffingDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x42)
{
DVBPSI_ERROR_ARG("dr_42 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_42 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -64,11 +64,7 @@ dvbpsi_stuffing_dr_t * dvbpsi_DecodeStuffingDr(
/* 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;
}
if(!p_decoded) return NULL;
/* Decode data */
p_decoded->i_stuffing_length = p_descriptor->i_length;
......
......@@ -52,7 +52,7 @@ dvbpsi_sat_deliv_sys_dr_t * dvbpsi_DecodeSatDelivSysDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x43)
{
DVBPSI_ERROR_ARG("dr_43 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_43 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,11 +63,7 @@ dvbpsi_sat_deliv_sys_dr_t * dvbpsi_DecodeSatDelivSysDr(
/* Allocate memory */
p_decoded =
(dvbpsi_sat_deliv_sys_dr_t*)malloc(sizeof(dvbpsi_sat_deliv_sys_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_43 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data */
p_decoded->i_frequency = (uint32_t)(p_descriptor->p_data[0] << 24)
......
......@@ -51,7 +51,7 @@ dvbpsi_vbi_dr_t * dvbpsi_DecodeVBIDataDr(
/* Check the tag */
if( p_descriptor->i_tag != 0x45 )
{
DVBPSI_ERROR_ARG("dr_45 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_45 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -62,14 +62,14 @@ dvbpsi_vbi_dr_t * dvbpsi_DecodeVBIDataDr(
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
{
DVBPSI_ERROR_ARG("dr_45 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_45 decoder", "bad length (%d)",
p_descriptor->i_length);
return NULL;
}
if(p_descriptor->i_length % 2)
{
DVBPSI_ERROR_ARG("dr_45 decoder", "length not multiple of 3(%d)",
dvbpsi_error(h_dvbpsi, "dr_45 decoder", "length not multiple of 3(%d)",
p_descriptor->i_length);
return NULL;
}
......@@ -79,11 +79,7 @@ dvbpsi_vbi_dr_t * dvbpsi_DecodeVBIDataDr(
/* Allocate memory */
p_decoded =
(dvbpsi_vbi_dr_t*)malloc(sizeof(dvbpsi_vbi_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_45 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
p_decoded->i_services_number = i_services_number;
......
......@@ -53,7 +53,7 @@ dvbpsi_bouquet_name_dr_t * dvbpsi_DecodeBouquetNameDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x47)
{
DVBPSI_ERROR_ARG("dr_47 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_47 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -64,11 +64,7 @@ dvbpsi_bouquet_name_dr_t * dvbpsi_DecodeBouquetNameDr(
/* 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;
}
if(!p_decoded) return NULL;
/* Decode data */
p_decoded->i_name_length = p_descriptor->i_length;
......
......@@ -53,7 +53,7 @@ dvbpsi_service_dr_t * dvbpsi_DecodeServiceDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x48)
{
DVBPSI_ERROR_ARG("dr_48 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_48 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -64,16 +64,12 @@ dvbpsi_service_dr_t * dvbpsi_DecodeServiceDr(
/* 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;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
{
DVBPSI_ERROR_ARG("dr_07 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_07 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -53,7 +53,7 @@ dvbpsi_short_event_dr_t * dvbpsi_DecodeShortEventDr(dvbpsi_descriptor_t * p_desc
if(p_descriptor->i_tag != 0x4d ||
p_descriptor->i_length < 5 )
{
DVBPSI_ERROR_ARG("dr_4d decoder", "bad tag or corrupted(0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_4d decoder", "bad tag or corrupted(0x%x)", p_descriptor->i_tag);
return NULL;
}
/* Check length */
......@@ -61,7 +61,7 @@ dvbpsi_short_event_dr_t * dvbpsi_DecodeShortEventDr(dvbpsi_descriptor_t * p_desc
i_len2 = p_descriptor->p_data[4+i_len1];
if( p_descriptor->i_length < 5 + i_len1 + i_len2 )
{
DVBPSI_ERROR_ARG("dr_4d decoder", "invalid length/content (tag=0x%x)", p_descriptor->i_tag );
dvbpsi_error(h_dvbpsi, "dr_4d decoder", "invalid length/content (tag=0x%x)", p_descriptor->i_tag );
return NULL;
}
......@@ -71,11 +71,7 @@ dvbpsi_short_event_dr_t * dvbpsi_DecodeShortEventDr(dvbpsi_descriptor_t * p_desc
/* Allocate memory */
p_decoded = malloc(sizeof(dvbpsi_short_event_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_4d decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
memcpy( p_decoded->i_iso_639_code, &p_descriptor->p_data[0], 3 );
......
......@@ -54,7 +54,7 @@ dvbpsi_extended_event_dr_t * dvbpsi_DecodeExtendedEventDr(dvbpsi_descriptor_t *
if(p_descriptor->i_tag != 0x4e ||
p_descriptor->i_length < 6 )
{
DVBPSI_ERROR_ARG("dr_4e decoder", "bad tag or corrupted(0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_4e decoder", "bad tag or corrupted(0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -64,11 +64,8 @@ dvbpsi_extended_event_dr_t * dvbpsi_DecodeExtendedEventDr(dvbpsi_descriptor_t *
/* Allocate memory */
p_decoded = malloc(sizeof(dvbpsi_extended_event_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_4e decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode */
p_decoded->i_descriptor_number = (p_descriptor->p_data[0] >> 4)&0xf;
......
......@@ -51,7 +51,7 @@ dvbpsi_stream_identifier_dr_t * dvbpsi_DecodeStreamIdentifierDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x52)
{
DVBPSI_ERROR_ARG("dr_52 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_52 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -62,16 +62,12 @@ dvbpsi_stream_identifier_dr_t * dvbpsi_DecodeStreamIdentifierDr(
/* Allocate memory */
p_decoded =
(dvbpsi_stream_identifier_dr_t*)malloc(sizeof(dvbpsi_stream_identifier_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_52 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 1)
{
DVBPSI_ERROR_ARG("dr_52 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_52 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -53,7 +53,7 @@ dvbpsi_parental_rating_dr_t * dvbpsi_DecodeParentalRatingDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x55)
{
DVBPSI_ERROR_ARG("dr_55 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_55 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -64,16 +64,12 @@ dvbpsi_parental_rating_dr_t * dvbpsi_DecodeParentalRatingDr(
/* Allocate memory */
p_decoded =
(dvbpsi_parental_rating_dr_t*)malloc(sizeof(dvbpsi_parental_rating_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_55 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length % 4)
{
DVBPSI_ERROR_ARG("dr_55 decoder", "length not multiple of 4 (%d)",
dvbpsi_error(h_dvbpsi, "dr_55 decoder", "length not multiple of 4 (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -51,7 +51,7 @@ dvbpsi_teletext_dr_t * dvbpsi_DecodeTeletextDr(
/* Check the tag */
if( (p_descriptor->i_tag != 0x56) && (p_descriptor->i_tag != 0x46) )
{
DVBPSI_ERROR_ARG("dr_46/56 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_46/56 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -62,14 +62,14 @@ dvbpsi_teletext_dr_t * dvbpsi_DecodeTeletextDr(
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
{
DVBPSI_ERROR_ARG("dr_46/dr_56 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_46/dr_56 decoder", "bad length (%d)",
p_descriptor->i_length);
return NULL;
}
if(p_descriptor->i_length % 5)
{
DVBPSI_ERROR_ARG("dr_46/dr_56 decoder", "length not multiple of 5(%d)",
dvbpsi_error(h_dvbpsi, "dr_46/dr_56 decoder", "length not multiple of 5(%d)",
p_descriptor->i_length);
return NULL;
}
......@@ -79,11 +79,7 @@ dvbpsi_teletext_dr_t * dvbpsi_DecodeTeletextDr(
/* Allocate memory */
p_decoded =
(dvbpsi_teletext_dr_t*)malloc(sizeof(dvbpsi_teletext_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_46/dr_56 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
p_decoded->i_pages_number = i_pages_number;
......
......@@ -54,7 +54,7 @@ dvbpsi_local_time_offset_dr_t * dvbpsi_DecodeLocalTimeOffsetDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x58)
{
DVBPSI_ERROR_ARG("dr_58 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_58 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -65,11 +65,7 @@ dvbpsi_local_time_offset_dr_t * dvbpsi_DecodeLocalTimeOffsetDr(
/* Allocate memory */
p_decoded =
(dvbpsi_local_time_offset_dr_t*)malloc(sizeof(dvbpsi_local_time_offset_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_58 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data */
p_decoded->i_local_time_offsets_number = 0;
......
......@@ -54,7 +54,7 @@ dvbpsi_subtitling_dr_t * dvbpsi_DecodeSubtitlingDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x59)
{
DVBPSI_ERROR_ARG("dr_59 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_59 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -65,16 +65,12 @@ dvbpsi_subtitling_dr_t * dvbpsi_DecodeSubtitlingDr(
/* Allocate memory */
p_decoded =
(dvbpsi_subtitling_dr_t*)malloc(sizeof(dvbpsi_subtitling_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_59 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
{
DVBPSI_ERROR_ARG("dr_59 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_59 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......@@ -82,7 +78,7 @@ dvbpsi_subtitling_dr_t * dvbpsi_DecodeSubtitlingDr(
if(p_descriptor->i_length % 8)
{
DVBPSI_ERROR_ARG("dr_59 decoder", "length not multiple of 8 (%d)",
dvbpsi_error(h_dvbpsi, "dr_59 decoder", "length not multiple of 8 (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_terr_deliv_sys_dr_t * dvbpsi_DecodeTerrDelivSysDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x5a)
{
DVBPSI_ERROR_ARG("dr_5a decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_5a decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,11 +63,7 @@ dvbpsi_terr_deliv_sys_dr_t * dvbpsi_DecodeTerrDelivSysDr(
/* Allocate memory */
p_decoded =
(dvbpsi_terr_deliv_sys_dr_t*)malloc(sizeof(dvbpsi_terr_deliv_sys_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_5a decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data */
p_decoded->i_centre_frequency = (uint32_t)(p_descriptor->p_data[0] << 24)
......
......@@ -51,7 +51,7 @@ dvbpsi_PDC_dr_t * dvbpsi_DecodePDCDr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if(p_descriptor->i_tag != 0x69)
{
DVBPSI_ERROR_ARG("dr_69 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_69 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -62,18 +62,14 @@ dvbpsi_PDC_dr_t * dvbpsi_DecodePDCDr(dvbpsi_descriptor_t * p_descriptor)
/* Decode data and check the length */
if( p_descriptor->i_length != 3)
{
DVBPSI_ERROR_ARG("dr_69 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "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;
}
if(!p_decoded) return NULL;
p_decoded->i_PDC[0] = ((p_descriptor->p_data[0] & 0x0f) << 1) |
(p_descriptor->p_data[1] >> 7);
......
......@@ -49,7 +49,7 @@ dvbpsi_cuei_dr_t * dvbpsi_DecodeCUEIDr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if (p_descriptor->i_tag != 0x8a)
{
DVBPSI_ERROR_ARG("dr_8a decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_8a decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -59,16 +59,12 @@ dvbpsi_cuei_dr_t * dvbpsi_DecodeCUEIDr(dvbpsi_descriptor_t * p_descriptor)
/* Allocate memory */
p_decoded = (dvbpsi_cuei_dr_t*)malloc(sizeof(dvbpsi_cuei_dr_t));
if (!p_decoded)
{
DVBPSI_ERROR("dr_8a decoder", "out of memory");
return NULL;
}
if (!p_decoded) return NULL;
/* Decode data and check the length */
if (p_descriptor->i_length == 0x01)
{
DVBPSI_ERROR_ARG("dr_8a decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_8a decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -24,11 +24,12 @@
*
*****************************************************************************/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
......@@ -46,7 +47,7 @@
*****************************************************************************
* This table is used to compute a PSI CRC byte per byte instead of bit per
* bit. It's been generated by 'gen_crc' in the 'misc' directory:
*
*
* uint32_t table[256];
* uint32_t i, j, k;
*
......@@ -156,7 +157,7 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
/* TS start code */
if(p_data[0] != 0x47)
{
DVBPSI_ERROR("PSI decoder", "not a TS packet");
dvbpsi_error(h_dvbpsi, "PSI decoder", "not a TS packet");
return;
}
......@@ -167,7 +168,7 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
if(i_expected_counter == ((h_dvbpsi->i_continuity_counter + 1) & 0xf)
&& !h_dvbpsi->b_discontinuity)
{
DVBPSI_ERROR_ARG("PSI decoder",
dvbpsi_error(h_dvbpsi, "PSI decoder",
"TS duplicate (received %d, expected %d) for PID %d",
h_dvbpsi->i_continuity_counter, i_expected_counter,
((uint16_t)(p_data[1] & 0x1f) << 8) | p_data[2]);
......@@ -176,7 +177,7 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
if(i_expected_counter != h_dvbpsi->i_continuity_counter)
{
DVBPSI_ERROR_ARG("PSI decoder",
dvbpsi_error(h_dvbpsi, "PSI decoder",
"TS discontinuity (received %d, expected %d) for PID %d",
h_dvbpsi->i_continuity_counter, i_expected_counter,
((uint16_t)(p_data[1] & 0x1f) << 8) | p_data[2]);
......@@ -259,7 +260,7 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
/* Check that the section isn't too long */
if(h_dvbpsi->i_need > h_dvbpsi->i_section_max_size - 3)
{
DVBPSI_ERROR("PSI decoder", "PSI section too long");
dvbpsi_error(h_dvbpsi, "PSI decoder", "PSI section too long");
dvbpsi_DeletePSISections(p_section);
h_dvbpsi->p_current_section = NULL;
/* If there is a new section not being handled then go forward
......@@ -319,6 +320,8 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
}
else
{
dvbpsi_error(h_dvbpsi, "misc PSI", "Bad CRC_32 !!!");
/* PSI section isn't valid => trash it */
dvbpsi_DeletePSISections(p_section);
h_dvbpsi->p_current_section = NULL;
......@@ -361,3 +364,129 @@ void dvbpsi_PushPacket(dvbpsi_handle h_dvbpsi, uint8_t* p_data)
}
}
/*****************************************************************************
* Message error level:
* -1 is disabled,
* 0 is errors only
* 1 is warning and errors
* 2 is debug, warning and errors
*****************************************************************************/
#define DVBPSI_MSG_FORMAT "libdvbpsi (%s): "
#ifdef HAVE_VARIADIC_MACROS
void message(dvbpsi_handle dvbpsi, const int level, const char *fmt, ...)
{
if ((dvbpsi->i_msg_level > DVBPSI_MSG_NONE) &&
(level <= dvbpsi->i_msg_level))
{
va_list ap;
va_start(ap, fmt);
#if defined(_GNU_SOURCE)
char *msg = NULL;
int err = vasprintf(&msg, fmt, ap);
#else
char msg[1024];
int err = vsnprintf(&msg, 1024, fmt, ap);
#endif
va_end(ap);
if (err > DVBPSI_MSG_NONE) {
if (dvbpsi->pf_message)
dvbpsi->pf_message(dvbpsi, msg);
#if defined(_GNU_SOURCE)
free(msg);
#endif
}
}
}
#else
void dvbpsi_error(dvbpsi_handle dvbpsi, const char *src, const char *fmt, ...)
{
if (DVBPSI_MSG_ERROR <= dvbpsi->i_msg_level)
{
va_list ap;
va_start(ap, fmt);
#if defined(_GNU_SOURCE)
char *msg = NULL;
if (asprintf(&msg, DVBPSI_MSG_FORMAT, src) < 0)
return;
int err = vasprintf(&msg, fmt, ap);
#else
char *msg = malloc(1024);
if (msg == NULL)
return;
if (snprintf(&msg, 1024, DVBPSI_MSG_FORMAT, src) < 0)
return;
int err = vsnprintf(&msg, 1024, fmt, ap);
#endif
va_end(ap);
if (err > 0) {
if (dvbpsi->pf_message)
dvbpsi->pf_message(dvbpsi, msg);
#if defined(_GNU_SOURCE)
free(msg);
#endif
}
}
}
void dvbpsi_warning(dvbpsi_handle dvbpsi, const char *src, const char *fmt, ...)
{
if (DVBPSI_MSG_WARNING <= dvbpsi->i_msg_level)
{
va_list ap;
va_start(ap, fmt);
#if defined(_GNU_SOURCE)
char *msg = NULL;
if (asprintf(&msg, DVBPSI_MSG_FORMAT, src) < 0)
return;
int err = vasprintf(&msg, fmt, ap);
#else
char *msg = malloc(1024);
if (msg == NULL)
return;
if (snprintf(&msg, 1024, DVBPSI_MSG_FORMAT, src) < 0)
return;
int err = vsnprintf(&msg, 1024, fmt, ap);
#endif
va_end(ap);
if (err > 0) {
if (dvbpsi->pf_message)
dvbpsi->pf_message(dvbpsi, msg);
#if defined(_GNU_SOURCE)
free(msg);
#endif
}
}
}
void dvbpsi_debug(dvbpsi_handle dvbpsi, const char *src, const char *fmt, ...)
{
if (DVBPSI_MSG_DEBUG <= dvbpsi->i_msg_level)
{
va_list ap;
va_start(ap, fmt);
#if defined(_GNU_SOURCE)
char *msg = NULL;
if (asprintf(&msg, DVBPSI_MSG_FORMAT, src) < 0)
return;
int err = vasprintf(&msg, fmt, ap);
#else
char *msg = malloc(1024);
if (msg == NULL)
return;
if (snprintf(&msg, 1024, DVBPSI_MSG_FORMAT, src) < 0)
return;
int err = vsnprintf(&msg, 1024, fmt, ap);
#endif
va_end(ap);
if (err > 0) {
if (dvbpsi->pf_message)
dvbpsi->pf_message(dvbpsi, msg);
#if defined(_GNU_SOURCE)
free(msg);
#endif
}
}
}
#endif
/*****************************************************************************
* dvbpsi.h
* Copyright (C) 2001-2010 VideoLAN
* Copyright (C) 2001-2011 VideoLAN
* $Id$
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -33,8 +33,8 @@
#ifndef _DVBPSI_DVBPSI_H_
#define _DVBPSI_DVBPSI_H_
#define DVBPSI_VERSION 0.1.7
#define DVBPSI_VERSION_INT ((0<<16)+(1<<8)+7)
#define DVBPSI_VERSION 1.0.0
#define DVBPSI_VERSION_INT ((1<<16)+(0<<8)+0)
#ifdef __cplusplus
extern "C" {
......@@ -89,6 +89,17 @@ typedef struct dvbpsi_psi_section_s dvbpsi_psi_section_t;
typedef void (* dvbpsi_callback)(dvbpsi_handle p_decoder,
dvbpsi_psi_section_t* p_section);
/*****************************************************************************
* 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_handle p_decoder,
const char* msg);
/*****************************************************************************
* dvbpsi_decoder_t
......@@ -126,6 +137,11 @@ typedef struct dvbpsi_decoder_s
int b_complete_header; /*!< Flag for header
completion */
/* Messages callback */
dvbpsi_message_cb pf_message; /*!< Log message callback */
int i_msg_level; /*!< Log level -1, 0, 1 or 2
(-1=none, 0=error, 1=warning,
2=debug) */
} dvbpsi_decoder_t;
......
......@@ -33,39 +33,30 @@ extern uint32_t dvbpsi_crc32_table[];
/*****************************************************************************
* Error management
*
* libdvbpsi messages have the following format:
* "libdvbpsi [error | warning | debug] (<component>): <msg>"
*****************************************************************************/
#define DVBPSI_ERROR(src, str) \
fprintf(stderr, "libdvbpsi error (" src "): " str "\n");
#ifdef HAVE_VARIADIC_MACROS
# define DVBPSI_ERROR_ARG(src, str, x...) \
fprintf(stderr, "libdvbpsi error (" src "): " str "\n", x);
#else
static inline void DVBPSI_ERROR_ARG( char *src, const char *str, ... )
{ va_list ap; va_start( ap, str );
vfprintf(stderr, str, ap); fprintf(stderr,"\n"); va_end( ap ); }
#endif
#define DVBPSI_MSG_NONE -1 /* No messages */
#define DVBPSI_MSG_ERROR 0 /* Error messages, only */
#define DVBPSI_MSG_WARNING 1 /* Error and Warning messages */
#define DVBPSI_MSG_DEBUG 2 /* Error, warning and debug messages */
#ifdef DEBUG
# define DVBPSI_DEBUG(src, str) \
fprintf(stderr, "libdvbpsi debug (" src "): " str "\n");
# ifdef HAVE_VARIADIC_MACROS
# define DVBPSI_DEBUG_ARG(src, str, x...) \
fprintf(stderr, "libdvbpsi debug (" src "): " str "\n", x);
# else
static inline void DVBPSI_DEBUG_ARG( char *src, const char *str, ... )
{ va_list ap; va_start( ap, str );
vfprintf(stderr, str, ap); fprintf(stderr,"\n"); va_end( ap ); }
# endif
#ifdef HAVE_VARIADIC_MACROS
void message(dvbpsi_handle dvbpsi, const int level, const char *fmt, ...);
# define dvbpsi_error(hnd, src, str, x...) \
message(hnd, DVBPSI_MSG_ERROR, "libdvbpsi error ("src"): " str, x)
# define dvbpsi_warning(hnd, str, x...) \
message(hnd, DVBPSI_MSG_WARNING, "libdvbpsi warning ("src"): " str, x)
# define dvbpsi_debug(hnd, str, x...) \
message(hnd, DVBPSI_MSG_DEBUG, "libdvbpsi debug ("src"): " str, x)
#else
# define DVBPSI_DEBUG(src, str)
# ifdef HAVE_VARIADIC_MACROS
# define DVBPSI_DEBUG_ARG(src, str, x...)
# else
static inline void DVBPSI_DEBUG_ARG( char *src, const char *str, ... ) {}
# endif
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_debug(dvbpsi_handle dvbpsi, const char *src, const char *fmt, ...);
#endif
#else
#error "Multiple inclusions of dvbpsi_private.h"
#endif
......
......@@ -119,8 +119,6 @@ int dvbpsi_ValidPSISection(dvbpsi_psi_section_t* p_section)
}
else
{
DVBPSI_ERROR_ARG("misc PSI",
"Bad CRC_32 (0x%08x) !!!", i_crc);
return 0;
}
}
......@@ -182,14 +180,14 @@ void dvbpsi_BuildPSISection(dvbpsi_psi_section_t* p_section)
p_section->p_payload_end[1] = (p_section->i_crc >> 16) & 0xff;
p_section->p_payload_end[2] = (p_section->i_crc >> 8) & 0xff;
p_section->p_payload_end[3] = p_section->i_crc & 0xff;
#ifdef DEBUG
#if 0
if(!dvbpsi_ValidPSISection(p_section))
{
DVBPSI_ERROR("misc PSI", "********************************************");
DVBPSI_ERROR("misc PSI", "* Generated PSI section has a bad CRC_32. *");
DVBPSI_ERROR("misc PSI", "* THIS IS A BUG, PLEASE REPORT TO THE LIST *");
DVBPSI_ERROR("misc PSI", "* --- libdvbpsi-devel@videolan.org --- *");
DVBPSI_ERROR("misc PSI", "********************************************");
dvbpsi_error(h_dvbpsi,"misc PSI", "********************************************");
dvbpsi_error(h_dvbpsi,"misc PSI", "* Generated PSI section has a bad CRC_32. *");
dvbpsi_error(h_dvbpsi,"misc PSI", "* THIS IS A BUG, PLEASE REPORT TO THE LIST *");
dvbpsi_error(h_dvbpsi,"misc PSI", "* --- libdvbpsi-devel@videolan.org --- *");
dvbpsi_error(h_dvbpsi,"misc PSI", "********************************************");
}
#endif
}
......
......@@ -61,7 +61,7 @@ int dvbpsi_AttachBAT(dvbpsi_decoder_t * p_psi_decoder, uint8_t i_table_id,
if(dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{
DVBPSI_ERROR_ARG("BAT decoder",
dvbpsi_error(h_dvbpsi, "BAT decoder",
"Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)",
i_table_id, i_extension);
......@@ -120,7 +120,7 @@ void dvbpsi_DetachBAT(dvbpsi_demux_t * p_demux, uint8_t i_table_id,
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if(p_subdec == NULL)
{
DVBPSI_ERROR_ARG("BAT Decoder",
dvbpsi_error(h_dvbpsi, "BAT Decoder",
"No such BAT decoder (table_id == 0x%02x,"
"extension == 0x%02x)",
i_table_id, i_extension);
......@@ -292,7 +292,7 @@ void dvbpsi_GatherBATSections(dvbpsi_decoder_t * p_psi_decoder,
int b_append = 1;
int b_reinit = 0;
DVBPSI_DEBUG_ARG("BAT decoder",
dvbpsi_debug(h_dvbpsi, "BAT decoder",
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_table_id,
......@@ -303,7 +303,7 @@ void dvbpsi_GatherBATSections(dvbpsi_decoder_t * p_psi_decoder,
if(!p_section->b_syntax_indicator)
{
/* Invalid section_syntax_indicator */
DVBPSI_ERROR("BAT decoder",
dvbpsi_error(h_dvbpsi, "BAT decoder",
"invalid section (section_syntax_indicator == 0)");
b_append = 0;
}
......@@ -325,7 +325,7 @@ void dvbpsi_GatherBATSections(dvbpsi_decoder_t * p_psi_decoder,
if(p_bat_decoder->p_building_bat->i_bouquet_id != p_section->i_extension)
{
/* bouquet_id */
DVBPSI_ERROR("BAT decoder",
dvbpsi_error(h_dvbpsi, "BAT decoder",
"'bouquet_id' differs"
" whereas no TS discontinuity has occured");
b_reinit = 1;
......@@ -334,7 +334,7 @@ void dvbpsi_GatherBATSections(dvbpsi_decoder_t * p_psi_decoder,
!= p_section->i_version)
{
/* version_number */
DVBPSI_ERROR("BAT decoder",
dvbpsi_error(h_dvbpsi, "BAT decoder",
"'version_number' differs"
" whereas no discontinuity has occured");
b_reinit = 1;
......@@ -343,7 +343,7 @@ void dvbpsi_GatherBATSections(dvbpsi_decoder_t * p_psi_decoder,
p_section->i_last_number)
{
/* last_section_number */
DVBPSI_ERROR("BAT decoder",
dvbpsi_error(h_dvbpsi, "BAT decoder",
"'last_section_number' differs"
" whereas no discontinuity has occured");
b_reinit = 1;
......@@ -413,7 +413,7 @@ void dvbpsi_GatherBATSections(dvbpsi_decoder_t * p_psi_decoder,
/* Fill the section array */
if(p_bat_decoder->ap_sections[p_section->i_number] != NULL)
{
DVBPSI_DEBUG_ARG("BAT decoder", "overwrite section number %d",
dvbpsi_debug(h_dvbpsi, "BAT decoder", "overwrite section number %d",
p_section->i_number);
dvbpsi_DeletePSISections(p_bat_decoder->ap_sections[p_section->i_number]);
}
......@@ -640,7 +640,7 @@ dvbpsi_psi_section_t* dvbpsi_GenBATSections(dvbpsi_bat_t* p_bat)
p_transport_stream_loop_length[1] = i_transport_stream_loop_length;
/* will put more descriptors in an empty section */
DVBPSI_DEBUG("BAT generator",
dvbpsi_debug(h_dvbpsi, "BAT generator",
"create a new section to carry more TS descriptors");
p_prev = p_current;
p_current = dvbpsi_NewPSISection(1024);
......@@ -700,7 +700,7 @@ dvbpsi_psi_section_t* dvbpsi_GenBATSections(dvbpsi_bat_t* p_bat)
}
if(p_descriptor != NULL)
DVBPSI_ERROR("BAT generator", "unable to carry all the TS descriptors");
dvbpsi_error(h_dvbpsi, "BAT generator", "unable to carry all the TS descriptors");
/* transport_descriptors_length */
i_transport_descriptors_length = p_current->p_payload_end - p_ts_start - 5;
......
......@@ -187,7 +187,7 @@ void dvbpsi_GatherCATSections(dvbpsi_decoder_t* p_decoder,
int b_append = 1;
int b_reinit = 0;
DVBPSI_DEBUG_ARG("CAT decoder",
dvbpsi_debug(h_dvbpsi, "CAT decoder",
"Table version %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_extension,
......@@ -197,7 +197,7 @@ void dvbpsi_GatherCATSections(dvbpsi_decoder_t* p_decoder,
if(p_section->i_table_id != 0x01)
{
/* Invalid table_id value */
DVBPSI_ERROR_ARG("CAT decoder",
dvbpsi_error(h_dvbpsi, "CAT decoder",
"invalid section (table_id == 0x%02x)",
p_section->i_table_id);
b_append = 0;
......@@ -206,7 +206,7 @@ void dvbpsi_GatherCATSections(dvbpsi_decoder_t* p_decoder,
if(b_append && !p_section->b_syntax_indicator)
{
/* Invalid section_syntax_indicator */
DVBPSI_ERROR("CAT decoder",
dvbpsi_error(h_dvbpsi, "CAT decoder",
"invalid section (section_syntax_indicator == 0)");
b_append = 0;
}
......@@ -227,7 +227,7 @@ void dvbpsi_GatherCATSections(dvbpsi_decoder_t* p_decoder,
if(p_cat_decoder->p_building_cat->i_version != p_section->i_version)
{
/* version_number */
DVBPSI_ERROR("CAT decoder",
dvbpsi_error(h_dvbpsi, "CAT decoder",
"'version_number' differs"
" whereas no discontinuity has occured");
b_reinit = 1;
......@@ -236,7 +236,7 @@ void dvbpsi_GatherCATSections(dvbpsi_decoder_t* p_decoder,
!= p_section->i_last_number)
{
/* last_section_number */
DVBPSI_ERROR("CAT decoder",
dvbpsi_error(h_dvbpsi, "CAT decoder",
"'last_section_number' differs"
" whereas no discontinuity has occured");
b_reinit = 1;
......@@ -297,7 +297,7 @@ void dvbpsi_GatherCATSections(dvbpsi_decoder_t* p_decoder,
/* Fill the section array */
if(p_cat_decoder->ap_sections[p_section->i_number] != NULL)
{
DVBPSI_DEBUG_ARG("CAT decoder", "overwrite section number %d",
dvbpsi_debug(h_dvbpsi, "CAT decoder", "overwrite section number %d",
p_section->i_number);
dvbpsi_DeletePSISections(p_cat_decoder->ap_sections[p_section->i_number]);
}
......
......@@ -62,7 +62,7 @@ int dvbpsi_AttachEIT(dvbpsi_decoder_t * p_psi_decoder, uint8_t i_table_id,
if(dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{
DVBPSI_ERROR_ARG("EIT decoder",
dvbpsi_error(h_dvbpsi, "EIT decoder",
"Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)",
i_table_id, i_extension);
......@@ -123,7 +123,7 @@ void dvbpsi_DetachEIT(dvbpsi_demux_t * p_demux, uint8_t i_table_id,
if(p_demux == NULL)
{
DVBPSI_ERROR_ARG("EIT Decoder",
dvbpsi_error(h_dvbpsi, "EIT Decoder",
"No such EIT decoder (table_id == 0x%02x,"
"extension == 0x%02x)",
i_table_id, i_extension);
......@@ -278,7 +278,7 @@ void dvbpsi_GatherEITSections(dvbpsi_decoder_t * p_psi_decoder,
int b_append = 1;
int b_reinit = 0;
DVBPSI_DEBUG_ARG("EIT decoder",
dvbpsi_debug(h_dvbpsi, "EIT decoder",
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_table_id,
......@@ -289,7 +289,7 @@ void dvbpsi_GatherEITSections(dvbpsi_decoder_t * p_psi_decoder,
if(!p_section->b_syntax_indicator)
{
/* Invalid section_syntax_indicator */
DVBPSI_ERROR("EIT decoder",
dvbpsi_error(h_dvbpsi, "EIT decoder",
"invalid section (section_syntax_indicator == 0)");
b_append = 0;
}
......@@ -311,7 +311,7 @@ void dvbpsi_GatherEITSections(dvbpsi_decoder_t * p_psi_decoder,
if(p_eit_decoder->p_building_eit->i_service_id != p_section->i_extension)
{
/* service_id */
DVBPSI_ERROR("EIT decoder",
dvbpsi_error(h_dvbpsi, "EIT decoder",
"'service_id' differs"
" whereas no TS discontinuity has occurred");
b_reinit = 1;
......@@ -320,7 +320,7 @@ void dvbpsi_GatherEITSections(dvbpsi_decoder_t * p_psi_decoder,
!= p_section->i_version)
{
/* version_number */
DVBPSI_ERROR("EIT decoder",
dvbpsi_error(h_dvbpsi, "EIT decoder",
"'version_number' differs"
" whereas no discontinuity has occurred");
b_reinit = 1;
......@@ -329,7 +329,7 @@ void dvbpsi_GatherEITSections(dvbpsi_decoder_t * p_psi_decoder,
p_section->i_last_number)
{
/* last_section_number */
DVBPSI_ERROR("EIT decoder",
dvbpsi_error(h_dvbpsi, "EIT decoder",
"'last_section_number' differs"
" whereas no discontinuity has occured");
b_reinit = 1;
......@@ -398,7 +398,7 @@ void dvbpsi_GatherEITSections(dvbpsi_decoder_t * p_psi_decoder,
/* Fill the section array */
if(p_eit_decoder->ap_sections[p_section->i_number] != NULL)
{
DVBPSI_DEBUG_ARG("EIT decoder", "overwrite section number %d",
dvbpsi_debug(h_dvbpsi, "EIT decoder", "overwrite section number %d",
p_section->i_number);
dvbpsi_DeletePSISections(p_eit_decoder->ap_sections[p_section->i_number]);
}
......
......@@ -63,7 +63,7 @@ int dvbpsi_AttachNIT(dvbpsi_decoder_t * p_psi_decoder, uint8_t i_table_id,
if(dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{
DVBPSI_ERROR_ARG("NIT decoder",
dvbpsi_error(h_dvbpsi, "NIT decoder",
"Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)",
i_table_id, i_extension);
......@@ -125,7 +125,7 @@ void dvbpsi_DetachNIT(dvbpsi_demux_t * p_demux, uint8_t i_table_id,
if(p_demux == NULL)
{
DVBPSI_ERROR_ARG("NIT Decoder",
dvbpsi_error(h_dvbpsi, "NIT Decoder",
"No such NIT decoder (table_id == 0x%02x,"
"extension == 0x%02x)",
i_table_id, i_extension);
......@@ -303,7 +303,7 @@ void dvbpsi_GatherNITSections(dvbpsi_decoder_t * p_decoder,
int b_append = 1;
int b_reinit = 0;
DVBPSI_DEBUG_ARG("NIT decoder",
dvbpsi_debug(h_dvbpsi, "NIT decoder",
"Table version %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_extension,
......@@ -313,7 +313,7 @@ void dvbpsi_GatherNITSections(dvbpsi_decoder_t * p_decoder,
if(p_section->i_table_id != 0x40 && p_section->i_table_id != 0x41)
{
/* Invalid table_id value */
DVBPSI_ERROR_ARG("NIT decoder",
dvbpsi_error(h_dvbpsi, "NIT decoder",
"invalid section (table_id == 0x%02x)",
p_section->i_table_id);
b_append = 0;
......@@ -322,7 +322,7 @@ void dvbpsi_GatherNITSections(dvbpsi_decoder_t * p_decoder,
if(b_append && !p_section->b_syntax_indicator)
{
/* Invalid section_syntax_indicator */
DVBPSI_ERROR("NIT decoder",
dvbpsi_error(h_dvbpsi, "NIT decoder",
"invalid section (section_syntax_indicator == 0)");
b_append = 0;
}
......@@ -332,7 +332,7 @@ void dvbpsi_GatherNITSections(dvbpsi_decoder_t * p_decoder,
{
/* Invalid program_number */
#if 0
DVBPSI_ERROR("NIT decoder", "'network_id' don't match");
dvbpsi_error(h_dvbpsi, "NIT decoder", "'network_id' don't match");
#endif
b_append = 0;
}
......@@ -353,7 +353,7 @@ void dvbpsi_GatherNITSections(dvbpsi_decoder_t * p_decoder,
if(p_nit_decoder->p_building_nit->i_version != p_section->i_version)
{
/* version_number */
DVBPSI_ERROR("NIT decoder",
dvbpsi_error(h_dvbpsi, "NIT decoder",
"'version_number' differs"
" whereas no discontinuity has occured");
b_reinit = 1;
......@@ -362,7 +362,7 @@ void dvbpsi_GatherNITSections(dvbpsi_decoder_t * p_decoder,
!= p_section->i_last_number)
{
/* last_section_number */
DVBPSI_ERROR("NIT decoder",
dvbpsi_error(h_dvbpsi, "NIT decoder",
"'last_section_number' differs"
" whereas no discontinuity has occured");
b_reinit = 1;
......@@ -424,7 +424,7 @@ void dvbpsi_GatherNITSections(dvbpsi_decoder_t * p_decoder,
/* Fill the section array */
if(p_nit_decoder->ap_sections[p_section->i_number] != NULL)
{
DVBPSI_DEBUG_ARG("NIT decoder", "overwrite section number %d",
dvbpsi_debug(h_dvbpsi, "NIT decoder", "overwrite section number %d",
p_section->i_number);
dvbpsi_DeletePSISections(p_nit_decoder->ap_sections[p_section->i_number]);
}
......@@ -650,7 +650,7 @@ dvbpsi_psi_section_t* dvbpsi_GenNITSections(dvbpsi_nit_t* p_nit,
p_transport_stream_loop_length[1] = i_transport_stream_loop_length;
/* will put more descriptors in an empty section */
DVBPSI_DEBUG("NIT generator",
dvbpsi_debug(h_dvbpsi, "NIT generator",
"create a new section to carry more TS descriptors");
p_prev = p_current;
p_current = dvbpsi_NewPSISection(1024);
......@@ -710,7 +710,7 @@ dvbpsi_psi_section_t* dvbpsi_GenNITSections(dvbpsi_nit_t* p_nit,
}
if(p_descriptor != NULL)
DVBPSI_ERROR("NIT generator", "unable to carry all the TS descriptors");
dvbpsi_error(h_dvbpsi, "NIT generator", "unable to carry all the TS descriptors");
/* TS_info_length */
i_ts_length = p_current->p_payload_end - p_ts_start - 5;
......
......@@ -189,12 +189,13 @@ dvbpsi_pat_program_t* dvbpsi_PATAddProgram(dvbpsi_pat_t* p_pat,
void dvbpsi_GatherPATSections(dvbpsi_decoder_t* p_decoder,
dvbpsi_psi_section_t* p_section)
{
dvbpsi_handle h_dvbpsi = (dvbpsi_handle) p_decoder;
dvbpsi_pat_decoder_t* p_pat_decoder
= (dvbpsi_pat_decoder_t*)p_decoder->p_private_decoder;
int b_append = 1;
int b_reinit = 0;
DVBPSI_DEBUG_ARG("PAT decoder",
dvbpsi_debug(h_dvbpsi, "PAT decoder",
"Table version %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_extension,
......@@ -204,7 +205,7 @@ void dvbpsi_GatherPATSections(dvbpsi_decoder_t* p_decoder,
if(p_section->i_table_id != 0x00)
{
/* Invalid table_id value */
DVBPSI_ERROR_ARG("PAT decoder",
dvbpsi_error(h_dvbpsi, "PAT decoder",
"invalid section (table_id == 0x%02x)",
p_section->i_table_id);
b_append = 0;
......@@ -213,7 +214,7 @@ void dvbpsi_GatherPATSections(dvbpsi_decoder_t* p_decoder,
if(b_append && !p_section->b_syntax_indicator)
{
/* Invalid section_syntax_indicator */
DVBPSI_ERROR("PAT decoder",
dvbpsi_error(h_dvbpsi, "PAT decoder",
"invalid section (section_syntax_indicator == 0)");
b_append = 0;
}
......@@ -235,7 +236,7 @@ void dvbpsi_GatherPATSections(dvbpsi_decoder_t* p_decoder,
if(p_pat_decoder->p_building_pat->i_ts_id != p_section->i_extension)
{
/* transport_stream_id */
DVBPSI_ERROR("PAT decoder",
dvbpsi_error(h_dvbpsi, "PAT decoder",
"'transport_stream_id' differs"
" whereas no TS discontinuity has occured");
b_reinit = 1;
......@@ -244,7 +245,7 @@ void dvbpsi_GatherPATSections(dvbpsi_decoder_t* p_decoder,
!= p_section->i_version)
{
/* version_number */
DVBPSI_ERROR("PAT decoder",
dvbpsi_error(h_dvbpsi, "PAT decoder",
"'version_number' differs"
" whereas no discontinuity has occured");
b_reinit = 1;
......@@ -253,7 +254,7 @@ void dvbpsi_GatherPATSections(dvbpsi_decoder_t* p_decoder,
p_section->i_last_number)
{
/* last_section_number */
DVBPSI_ERROR("PAT decoder",
dvbpsi_error(h_dvbpsi, "PAT decoder",
"'last_section_number' differs"
" whereas no discontinuity has occured");
b_reinit = 1;
......@@ -315,7 +316,7 @@ void dvbpsi_GatherPATSections(dvbpsi_decoder_t* p_decoder,
/* Fill the section array */
if(p_pat_decoder->ap_sections[p_section->i_number] != NULL)
{
DVBPSI_DEBUG_ARG("PAT decoder", "overwrite section number %d",
dvbpsi_debug(h_dvbpsi, "PAT decoder", "overwrite section number %d",
p_section->i_number);
dvbpsi_DeletePSISections(p_pat_decoder->ap_sections[p_section->i_number]);
}
......
......@@ -261,12 +261,13 @@ dvbpsi_descriptor_t* dvbpsi_PMTESAddDescriptor(dvbpsi_pmt_es_t* p_es,
void dvbpsi_GatherPMTSections(dvbpsi_decoder_t* p_decoder,
dvbpsi_psi_section_t* p_section)
{
dvbpsi_handle h_dvbpsi = (dvbpsi_handle) p_decoder;
dvbpsi_pmt_decoder_t* p_pmt_decoder
= (dvbpsi_pmt_decoder_t*)p_decoder->p_private_decoder;
int b_append = 1;
int b_reinit = 0;
DVBPSI_DEBUG_ARG("PMT decoder",
dvbpsi_debug(h_dvbpsi, "PMT decoder",
"Table version %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_extension,
......@@ -276,7 +277,7 @@ void dvbpsi_GatherPMTSections(dvbpsi_decoder_t* p_decoder,
if(p_section->i_table_id != 0x02)
{
/* Invalid table_id value */
DVBPSI_ERROR_ARG("PMT decoder",
dvbpsi_error(h_dvbpsi, "PMT decoder",
"invalid section (table_id == 0x%02x)",
p_section->i_table_id);
b_append = 0;
......@@ -285,7 +286,7 @@ void dvbpsi_GatherPMTSections(dvbpsi_decoder_t* p_decoder,
if(b_append && !p_section->b_syntax_indicator)
{
/* Invalid section_syntax_indicator */
DVBPSI_ERROR("PMT decoder",
dvbpsi_error(h_dvbpsi, "PMT decoder",
"invalid section (section_syntax_indicator == 0)");
b_append = 0;
}
......@@ -295,7 +296,7 @@ void dvbpsi_GatherPMTSections(dvbpsi_decoder_t* p_decoder,
{
/* Invalid program_number */
#if 0
DVBPSI_ERROR("PMT decoder", \
dvbpsi_error(h_dvbpsi, "PMT decoder", \
"'program_number' don't match");
#endif
b_append = 0;
......@@ -317,7 +318,7 @@ void dvbpsi_GatherPMTSections(dvbpsi_decoder_t* p_decoder,
if(p_pmt_decoder->p_building_pmt->i_version != p_section->i_version)
{
/* version_number */
DVBPSI_ERROR("PMT decoder",
dvbpsi_error(h_dvbpsi, "PMT decoder",
"'version_number' differs"
" whereas no discontinuity has occured");
b_reinit = 1;
......@@ -326,7 +327,7 @@ void dvbpsi_GatherPMTSections(dvbpsi_decoder_t* p_decoder,
!= p_section->i_last_number)
{
/* last_section_number */
DVBPSI_ERROR("PMT decoder",
dvbpsi_error(h_dvbpsi, "PMT decoder",
"'last_section_number' differs"
" whereas no discontinuity has occured");
b_reinit = 1;
......@@ -390,7 +391,7 @@ void dvbpsi_GatherPMTSections(dvbpsi_decoder_t* p_decoder,
/* Fill the section array */
if(p_pmt_decoder->ap_sections[p_section->i_number] != NULL)
{
DVBPSI_DEBUG_ARG("PMT decoder", "overwrite section number %d",
dvbpsi_debug(h_dvbpsi, "PMT decoder", "overwrite section number %d",
p_section->i_number);
dvbpsi_DeletePSISections(p_pmt_decoder->ap_sections[p_section->i_number]);
}
......@@ -598,7 +599,7 @@ dvbpsi_psi_section_t* dvbpsi_GenPMTSections(dvbpsi_pmt_t* p_pmt)
&& (i_es_length <= 1008))
{
/* will put more descriptors in an empty section */
DVBPSI_DEBUG("PMT generator",
dvbpsi_debug(h_dvbpsi, "PMT generator",
"create a new section to carry more ES descriptors");
p_prev = p_current;
p_current = dvbpsi_NewPSISection(1024);
......@@ -657,7 +658,7 @@ dvbpsi_psi_section_t* dvbpsi_GenPMTSections(dvbpsi_pmt_t* p_pmt)
}
if(p_descriptor != NULL)
DVBPSI_ERROR("PMT generator", "unable to carry all the ES descriptors");
dvbpsi_error(h_dvbpsi, "PMT generator", "unable to carry all the ES descriptors");
/* ES_info_length */
i_es_length = p_current->p_payload_end - p_es_start - 5;
......
......@@ -61,7 +61,7 @@ int dvbpsi_AttachSDT(dvbpsi_decoder_t * p_psi_decoder, uint8_t i_table_id,
if(dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{
DVBPSI_ERROR_ARG("SDT decoder",
dvbpsi_error(h_dvbpsi, "SDT decoder",
"Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)",
i_table_id, i_extension);
......@@ -122,7 +122,7 @@ void dvbpsi_DetachSDT(dvbpsi_demux_t * p_demux, uint8_t i_table_id,
if(p_demux == NULL)
{
DVBPSI_ERROR_ARG("SDT Decoder",
dvbpsi_error(h_dvbpsi, "SDT Decoder",
"No such SDT decoder (table_id == 0x%02x,"
"extension == 0x%02x)",
i_table_id, i_extension);
......@@ -275,7 +275,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_decoder_t * p_psi_decoder,
int b_append = 1;
int b_reinit = 0;
DVBPSI_DEBUG_ARG("SDT decoder",
dvbpsi_debug(h_dvbpsi, "SDT decoder",
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_table_id,
......@@ -286,7 +286,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_decoder_t * p_psi_decoder,
if(!p_section->b_syntax_indicator)
{
/* Invalid section_syntax_indicator */
DVBPSI_ERROR("SDT decoder",
dvbpsi_error(h_dvbpsi, "SDT decoder",
"invalid section (section_syntax_indicator == 0)");
b_append = 0;
}
......@@ -308,7 +308,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_decoder_t * p_psi_decoder,
if(p_sdt_decoder->p_building_sdt->i_ts_id != p_section->i_extension)
{
/* transport_stream_id */
DVBPSI_ERROR("SDT decoder",
dvbpsi_error(h_dvbpsi, "SDT decoder",
"'transport_stream_id' differs"
" whereas no TS discontinuity has occured");
b_reinit = 1;
......@@ -317,7 +317,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_decoder_t * p_psi_decoder,
!= p_section->i_version)
{
/* version_number */
DVBPSI_ERROR("SDT decoder",
dvbpsi_error(h_dvbpsi, "SDT decoder",
"'version_number' differs"
" whereas no discontinuity has occured");
b_reinit = 1;
......@@ -326,7 +326,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_decoder_t * p_psi_decoder,
p_section->i_last_number)
{
/* last_section_number */
DVBPSI_ERROR("SDT decoder",
dvbpsi_error(h_dvbpsi, "SDT decoder",
"'last_section_number' differs"
" whereas no discontinuity has occured");
b_reinit = 1;
......@@ -390,7 +390,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_decoder_t * p_psi_decoder,
/* Fill the section array */
if(p_sdt_decoder->ap_sections[p_section->i_number] != NULL)
{
DVBPSI_DEBUG_ARG("SDT decoder", "overwrite section number %d",
dvbpsi_debug(h_dvbpsi, "SDT decoder", "overwrite section number %d",
p_section->i_number);
dvbpsi_DeletePSISections(p_sdt_decoder->ap_sections[p_section->i_number]);
}
......@@ -532,7 +532,7 @@ dvbpsi_psi_section_t *dvbpsi_GenSDTSections(dvbpsi_sdt_t* p_sdt)
if ( (p_descriptor != NULL) && (p_service_start - p_current->p_data != 11) && (i_service_length <= 1009) )
{
/* will put more descriptors in an empty section */
DVBPSI_DEBUG("SDT generator","create a new section to carry more Service descriptors");
dvbpsi_debug(h_dvbpsi, "SDT generator","create a new section to carry more Service descriptors");
p_prev = p_current;
p_current = dvbpsi_NewPSISection(1024);
p_prev->p_next = p_current;
......@@ -581,7 +581,7 @@ dvbpsi_psi_section_t *dvbpsi_GenSDTSections(dvbpsi_sdt_t* p_sdt)
}
if(p_descriptor != NULL)
DVBPSI_ERROR("SDT generator", "unable to carry all the descriptors");
dvbpsi_error(h_dvbpsi, "SDT generator", "unable to carry all the descriptors");
/* ES_info_length */
i_service_length = p_current->p_payload_end - p_service_start - 5;
......
......@@ -64,7 +64,7 @@ int dvbpsi_AttachSIS(dvbpsi_decoder_t *p_psi_decoder, uint8_t i_table_id,
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{
DVBPSI_ERROR_ARG("SIS decoder",
dvbpsi_error(h_dvbpsi, "SIS decoder",
"Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)",
i_table_id, i_extension);
......@@ -119,7 +119,7 @@ void dvbpsi_DetachSIS(dvbpsi_demux_t * p_demux, uint8_t i_table_id,
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if (p_demux == NULL)
{
DVBPSI_ERROR_ARG("SIS Decoder",
dvbpsi_error(h_dvbpsi, "SIS Decoder",
"No such SIS decoder (table_id == 0x%02x,"
"extension == 0x%02x)",
i_table_id, i_extension);
......@@ -229,7 +229,7 @@ void dvbpsi_GatherSISSections(dvbpsi_decoder_t * p_psi_decoder,
int b_append = 1;
int b_reinit = 0;
DVBPSI_DEBUG_ARG("SIS decoder",
dvbpsi_debug(h_dvbpsi, "SIS decoder",
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_table_id,
......@@ -240,7 +240,7 @@ void dvbpsi_GatherSISSections(dvbpsi_decoder_t * p_psi_decoder,
if (p_section->i_table_id != 0xFC)
{
/* Invalid table_id value */
DVBPSI_ERROR_ARG("SIS decoder",
dvbpsi_error(h_dvbpsi, "SIS decoder",
"invalid section (table_id == 0x%02x)",
p_section->i_table_id);
b_append = 0;
......@@ -249,7 +249,7 @@ void dvbpsi_GatherSISSections(dvbpsi_decoder_t * p_psi_decoder,
if (p_section->b_syntax_indicator != 0)
{
/* Invalid section_syntax_indicator */
DVBPSI_ERROR("SIS decoder",
dvbpsi_error(h_dvbpsi, "SIS decoder",
"invalid section (section_syntax_indicator != 0)");
b_append = 0;
}
......@@ -257,7 +257,7 @@ void dvbpsi_GatherSISSections(dvbpsi_decoder_t * p_psi_decoder,
if (p_section->b_private_indicator != 0)
{
/* Invalid private_syntax_indicator */
DVBPSI_ERROR("SIS decoder",
dvbpsi_error(h_dvbpsi, "SIS decoder",
"invalid private section (private_syntax_indicator != 0)");
b_append = 0;
}
......@@ -279,7 +279,7 @@ void dvbpsi_GatherSISSections(dvbpsi_decoder_t * p_psi_decoder,
if (p_sis_decoder->p_building_sis->i_protocol_version != 0)
{
/* transport_stream_id */
DVBPSI_ERROR("SIS decoder",
dvbpsi_error(h_dvbpsi, "SIS decoder",
"'protocol_version' differs");\
b_reinit = 1;
}
......
......@@ -63,7 +63,7 @@ int dvbpsi_AttachTOT(dvbpsi_decoder_t * p_psi_decoder, uint8_t i_table_id,
if(dvbpsi_demuxGetSubDec(p_demux, i_table_id, 0))
{
DVBPSI_ERROR_ARG("TDT/TOT decoder",
dvbpsi_error(h_dvbpsi, "TDT/TOT decoder",
"Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)",
i_table_id, 0);
......@@ -117,7 +117,7 @@ void dvbpsi_DetachTOT(dvbpsi_demux_t * p_demux, uint8_t i_table_id,
if(p_demux == NULL)
{
DVBPSI_ERROR_ARG("TDT/TOT Decoder",
dvbpsi_error(h_dvbpsi, "TDT/TOT Decoder",
"No such TDT/TOT decoder (table_id == 0x%02x,"
"extension == 0x%02x)",
i_table_id, 0);
......@@ -205,12 +205,12 @@ void dvbpsi_GatherTOTSections(dvbpsi_decoder_t* p_decoder,
int b_append = 1;
dvbpsi_tot_t* p_building_tot;
DVBPSI_DEBUG("TDT/TOT decoder", "got a section");
dvbpsi_debug(h_dvbpsi, "TDT/TOT decoder", "got a section");
if(p_section->i_table_id != 0x70 && p_section->i_table_id != 0x73)
{
/* Invalid table_id value */
DVBPSI_ERROR_ARG("TDT/TOT decoder",
dvbpsi_error(h_dvbpsi, "TDT/TOT decoder",
"invalid section (table_id == 0x%02x)",
p_section->i_table_id);
b_append = 0;
......@@ -219,7 +219,7 @@ void dvbpsi_GatherTOTSections(dvbpsi_decoder_t* p_decoder,
if(b_append && p_section->b_syntax_indicator != 0)
{
/* Invalid section_syntax_indicator */
DVBPSI_ERROR("TDT/TOT decoder",
dvbpsi_error(h_dvbpsi, "TDT/TOT decoder",
"invalid section (section_syntax_indicator != 0)");
b_append = 0;
}
......@@ -282,7 +282,7 @@ int dvbpsi_ValidTOTSection(dvbpsi_psi_section_t* p_section)
}
else
{
DVBPSI_ERROR_ARG("TDT/TOT decoder",
dvbpsi_error(h_dvbpsi, "TDT/TOT decoder",
"Bad CRC_32 (0x%08x) !!!", i_crc);
return 0;
}
......@@ -291,7 +291,7 @@ int dvbpsi_ValidTOTSection(dvbpsi_psi_section_t* p_section)
{
/* A TDT always has a length of 5 bytes (which is only the UTC time) */
if(p_section->i_length != 5) {
DVBPSI_ERROR_ARG("TDT/TOT decoder",
dvbpsi_error(h_dvbpsi, "TDT/TOT decoder",
"TDT has an invalid payload size (%d bytes) !!!",
p_section->i_length);
return 0;
......@@ -395,7 +395,7 @@ dvbpsi_psi_section_t* dvbpsi_GenTOTSections(dvbpsi_tot_t* p_tot)
if( (p_result->p_payload_end - p_result->p_data)
+ p_descriptor->i_length > 4090)
{
DVBPSI_ERROR("TDT/TOT generator",
dvbpsi_error(h_dvbpsi, "TDT/TOT generator",
"TOT does not fit into one section as it ought to be !!!");
break;
}
......@@ -449,11 +449,11 @@ dvbpsi_psi_section_t* dvbpsi_GenTOTSections(dvbpsi_tot_t* p_tot)
#ifdef DEBUG
if(!dvbpsi_ValidTOTSection(p_result))
{
DVBPSI_ERROR("TDT/TOT generator", "********************************************");
DVBPSI_ERROR("TDT/TOT generator", "* Generated TDT/TOT section is invalid. *");
DVBPSI_ERROR("TDT/TOT generator", "* THIS IS A BUG, PLEASE REPORT TO THE LIST *");
DVBPSI_ERROR("TDT/TOT generator", "* --- libdvbpsi-devel@videolan.org --- *");
DVBPSI_ERROR("TDT/TOT generator", "********************************************");
dvbpsi_error(h_dvbpsi, "TDT/TOT generator", "********************************************");
dvbpsi_error(h_dvbpsi, "TDT/TOT generator", "* Generated TDT/TOT section is invalid. *");
dvbpsi_error(h_dvbpsi, "TDT/TOT generator", "* THIS IS A BUG, PLEASE REPORT TO THE LIST *");
dvbpsi_error(h_dvbpsi, "TDT/TOT generator", "* --- libdvbpsi-devel@videolan.org --- *");
dvbpsi_error(h_dvbpsi, "TDT/TOT generator", "********************************************");
}
#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