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

descriptors: refactor and cleanup

- dvbpsi_Decode*() first check length then allocate memory
- dvbpsi_Gen*() refactor
parent 4a7ee37e
......@@ -93,40 +93,39 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor)
dvbpsi_descriptor_t * dvbpsi_GenVStreamDr(dvbpsi_vstream_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x02, p_decoded->b_mpeg2 ? 3 : 1, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x02, p_decoded->b_mpeg2 ? 3 : 1, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = 0;
if(p_decoded->b_multiple_frame_rate)
p_descriptor->p_data[0] |= 0x80;
if (p_decoded->b_multiple_frame_rate)
p_descriptor->p_data[0] |= 0x80;
p_descriptor->p_data[0] |= (p_decoded->i_frame_rate_code & 0x0f) << 3;
if(p_decoded->b_constrained_parameter)
p_descriptor->p_data[0] |= 0x02;
if(p_decoded->b_still_picture)
p_descriptor->p_data[0] |= 0x01;
if (p_decoded->b_constrained_parameter)
p_descriptor->p_data[0] |= 0x02;
if (p_decoded->b_still_picture)
p_descriptor->p_data[0] |= 0x01;
if(p_decoded->b_mpeg2)
if (p_decoded->b_mpeg2)
{
p_descriptor->p_data[0] |= 0x04;
p_descriptor->p_data[1] = p_decoded->i_profile_level_indication;
p_descriptor->p_data[2] = 0x1f;
p_descriptor->p_data[2] |= (p_decoded->i_chroma_format & 0x03) << 6;
if(p_decoded->b_frame_rate_extension)
p_descriptor->p_data[2] |= 0x20;
p_descriptor->p_data[0] |= 0x04;
p_descriptor->p_data[1] = p_decoded->i_profile_level_indication;
p_descriptor->p_data[2] = 0x1f;
p_descriptor->p_data[2] |= (p_decoded->i_chroma_format & 0x03) << 6;
if (p_decoded->b_frame_rate_extension)
p_descriptor->p_data[2] |= 0x20;
}
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_vstream_dr_t));
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_vstream_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -81,32 +81,31 @@ dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor)
/*****************************************************************************
* dvbpsi_GenAStreamDr
*****************************************************************************/
dvbpsi_descriptor_t * dvbpsi_GenAStreamDr(dvbpsi_astream_dr_t * p_decoded,
bool b_duplicate)
dvbpsi_descriptor_t *dvbpsi_GenAStreamDr(dvbpsi_astream_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x03, 1, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t *p_descriptor = dvbpsi_NewDescriptor(0x03, 1, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
*p_descriptor->p_data = 0x0f;
if(p_decoded->b_free_format)
*p_descriptor->p_data |= 0x80;
if (p_decoded->b_free_format)
*p_descriptor->p_data |= 0x80;
*p_descriptor->p_data |= (p_decoded->i_id & 0x01) << 6;
*p_descriptor->p_data |= (p_decoded->i_layer & 0x03) << 4;
if(p_decoded->b_variable_rate_audio_indicator)
*p_descriptor->p_data |= 0x08;
if (p_decoded->b_variable_rate_audio_indicator)
*p_descriptor->p_data |= 0x08;
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_astream_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -85,26 +85,25 @@ dvbpsi_hierarchy_dr_t * dvbpsi_DecodeHierarchyDr(
dvbpsi_descriptor_t * dvbpsi_GenHierarchyDr(dvbpsi_hierarchy_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x04, 4, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x04, 4, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = 0xf0 | p_decoded->i_h_type;
p_descriptor->p_data[1] = 0xc0 | p_decoded->i_h_layer_index;
p_descriptor->p_data[2] = 0xc0 | p_decoded->i_h_embedded_layer;
p_descriptor->p_data[3] = 0xc0 | p_decoded->i_h_priority;
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_hierarchy_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -92,31 +92,31 @@ dvbpsi_descriptor_t * dvbpsi_GenRegistrationDr(
dvbpsi_registration_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x05, p_decoded->i_additional_length + 4, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x05, p_decoded->i_additional_length + 4, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = p_decoded->i_format_identifier >> 24;
p_descriptor->p_data[1] = p_decoded->i_format_identifier >> 16;
p_descriptor->p_data[2] = p_decoded->i_format_identifier >> 8;
p_descriptor->p_data[3] = p_decoded->i_format_identifier;
if(p_decoded->i_additional_length)
memcpy(p_descriptor->p_data + 4,
p_decoded->i_additional_info,
p_decoded->i_additional_length);
if (p_decoded->i_additional_length)
memcpy(p_descriptor->p_data + 4,
p_decoded->i_additional_info,
p_decoded->i_additional_length);
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_registration_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -47,29 +47,28 @@
dvbpsi_ds_alignment_dr_t * dvbpsi_DecodeDSAlignmentDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_ds_alignment_dr_t * p_decoded;
dvbpsi_ds_alignment_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x06))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x06))
return NULL;
/* Allocate memory */
p_decoded = (dvbpsi_ds_alignment_dr_t*)
malloc(sizeof(dvbpsi_ds_alignment_dr_t));
if(!p_decoded) return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Decode data and check the length */
if(p_descriptor->i_length != 1)
{
free(p_decoded);
return NULL;
}
if (p_descriptor->i_length != 1)
return NULL;
p_decoded->i_alignment_type = p_descriptor->p_data[0];
/* Allocate memory */
p_decoded = (dvbpsi_ds_alignment_dr_t*) malloc(sizeof(dvbpsi_ds_alignment_dr_t));
if(!p_decoded) return NULL;
p_descriptor->p_decoded = (void*)p_decoded;
p_decoded->i_alignment_type = p_descriptor->p_data[0];
return p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
......@@ -80,26 +79,22 @@ dvbpsi_descriptor_t * dvbpsi_GenDSAlignmentDr(
dvbpsi_ds_alignment_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x06, 1, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x06, 1, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = p_decoded->i_alignment_type;
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
dvbpsi_ds_alignment_dr_t * p_dup_decoded =
(dvbpsi_ds_alignment_dr_t*)malloc(sizeof(dvbpsi_ds_alignment_dr_t));
if(p_dup_decoded)
memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_ds_alignment_dr_t));
p_descriptor->p_decoded = (void*)p_dup_decoded;
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_ds_alignment_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -47,39 +47,35 @@
dvbpsi_target_bg_grid_dr_t * dvbpsi_DecodeTargetBgGridDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_target_bg_grid_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x07))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = (dvbpsi_target_bg_grid_dr_t*)
malloc(sizeof(dvbpsi_target_bg_grid_dr_t));
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 4)
{
free(p_decoded);
return NULL;
}
p_decoded->i_horizontal_size = ((uint16_t)(p_descriptor->p_data[0]) << 6)
| ((p_descriptor->p_data[1] & 0xfc) >> 2);
p_decoded->i_vertical_size =
((uint16_t)(p_descriptor->p_data[1] & 0x03) << 12)
| ((uint16_t)(p_descriptor->p_data[2]) << 4)
| ((p_descriptor->p_data[3] & 0xf0) >> 4);
p_decoded->i_pel_aspect_ratio = p_descriptor->p_data[3] & 0x0f;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
dvbpsi_target_bg_grid_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x07))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
if (p_descriptor->i_length != 4)
return NULL;
/* Allocate memory */
p_decoded = (dvbpsi_target_bg_grid_dr_t*) malloc(sizeof(dvbpsi_target_bg_grid_dr_t));
if (!p_decoded)
return NULL;
p_decoded->i_horizontal_size = ((uint16_t)(p_descriptor->p_data[0]) << 6)
| ((p_descriptor->p_data[1] & 0xfc) >> 2);
p_decoded->i_vertical_size =
((uint16_t)(p_descriptor->p_data[1] & 0x03) << 12)
| ((uint16_t)(p_descriptor->p_data[2]) << 4)
| ((p_descriptor->p_data[3] & 0xf0) >> 4);
p_decoded->i_pel_aspect_ratio = p_descriptor->p_data[3] & 0x0f;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
......@@ -90,28 +86,27 @@ dvbpsi_descriptor_t * dvbpsi_GenTargetBgGridDr(
dvbpsi_target_bg_grid_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x07, 4, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x07, 4, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = p_decoded->i_horizontal_size >> 6;
p_descriptor->p_data[1] = (((uint8_t)p_decoded->i_horizontal_size) << 2)
| (p_decoded->i_vertical_size >> 12);
| (p_decoded->i_vertical_size >> 12);
p_descriptor->p_data[2] = p_decoded->i_vertical_size >> 4;
p_descriptor->p_data[3] = (((uint8_t)p_decoded->i_vertical_size) << 4)
| (p_decoded->i_pel_aspect_ratio & 0x0f);
| (p_decoded->i_pel_aspect_ratio & 0x0f);
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_target_bg_grid_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -46,38 +46,35 @@
*****************************************************************************/
dvbpsi_vwindow_dr_t * dvbpsi_DecodeVWindowDr(dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_vwindow_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x08))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = (dvbpsi_vwindow_dr_t*)malloc(sizeof(dvbpsi_vwindow_dr_t));
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 4)
{
free(p_decoded);
return NULL;
}
p_decoded->i_horizontal_offset = ((uint16_t)(p_descriptor->p_data[0]) << 6)
| ((p_descriptor->p_data[1] & 0xfc) >> 2);
p_decoded->i_vertical_offset =
((uint16_t)(p_descriptor->p_data[1] & 0x03) << 12)
| ((uint16_t)(p_descriptor->p_data[2]) << 4)
| ((p_descriptor->p_data[3] & 0xf0) >> 4);
p_decoded->i_window_priority = p_descriptor->p_data[3] & 0x0f;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
dvbpsi_vwindow_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x08))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
if (p_descriptor->i_length != 4)
return NULL;
/* Allocate memory */
p_decoded = (dvbpsi_vwindow_dr_t*)malloc(sizeof(dvbpsi_vwindow_dr_t));
if (!p_decoded)
return NULL;
p_decoded->i_horizontal_offset = ((uint16_t)(p_descriptor->p_data[0]) << 6)
| ((p_descriptor->p_data[1] & 0xfc) >> 2);
p_decoded->i_vertical_offset =
((uint16_t)(p_descriptor->p_data[1] & 0x03) << 12)
| ((uint16_t)(p_descriptor->p_data[2]) << 4)
| ((p_descriptor->p_data[3] & 0xf0) >> 4);
p_decoded->i_window_priority = p_descriptor->p_data[3] & 0x0f;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
......@@ -87,28 +84,28 @@ dvbpsi_vwindow_dr_t * dvbpsi_DecodeVWindowDr(dvbpsi_descriptor_t * p_descriptor)
dvbpsi_descriptor_t * dvbpsi_GenVWindowDr(dvbpsi_vwindow_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x08, 4, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x08, 4, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = p_decoded->i_horizontal_offset >> 6;
p_descriptor->p_data[1] = (((uint8_t)p_decoded->i_horizontal_offset) << 2)
| (p_decoded->i_vertical_offset >> 12);
| (p_decoded->i_vertical_offset >> 12);
p_descriptor->p_data[2] = p_decoded->i_vertical_offset >> 4;
p_descriptor->p_data[3] = (((uint8_t)p_decoded->i_vertical_offset) << 4)
| (p_decoded->i_window_priority & 0x0f);
| (p_decoded->i_window_priority & 0x0f);
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_vwindow_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -46,42 +46,38 @@
*****************************************************************************/
dvbpsi_ca_dr_t * dvbpsi_DecodeCADr(dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_ca_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x09))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = (dvbpsi_ca_dr_t*)malloc(sizeof(dvbpsi_ca_dr_t));
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 4)
{
free(p_decoded);
return NULL;
}
p_decoded->i_ca_system_id = ((uint16_t)(p_descriptor->p_data[0]) << 8)
| p_descriptor->p_data[1];
p_decoded->i_ca_pid = ((uint16_t)(p_descriptor->p_data[2] & 0x1f) << 8)
| p_descriptor->p_data[3];
p_decoded->i_private_length = p_descriptor->i_length - 4;
if(p_decoded->i_private_length)
memcpy(p_decoded->i_private_data,
p_descriptor->p_data + 4,
p_decoded->i_private_length);
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
dvbpsi_ca_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x09))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
if (p_descriptor->i_length < 4)
return NULL;
/* Allocate memory */
p_decoded = (dvbpsi_ca_dr_t*)malloc(sizeof(dvbpsi_ca_dr_t));
if (!p_decoded)
return NULL;
p_decoded->i_ca_system_id = ((uint16_t)(p_descriptor->p_data[0]) << 8)
| p_descriptor->p_data[1];
p_decoded->i_ca_pid = ((uint16_t)(p_descriptor->p_data[2] & 0x1f) << 8)
| p_descriptor->p_data[3];
p_decoded->i_private_length = p_descriptor->i_length - 4;
if (p_decoded->i_private_length)
memcpy(p_decoded->i_private_data,
p_descriptor->p_data + 4,
p_decoded->i_private_length);
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenCADr
......@@ -89,31 +85,29 @@ dvbpsi_ca_dr_t * dvbpsi_DecodeCADr(dvbpsi_descriptor_t * p_descriptor)
dvbpsi_descriptor_t * dvbpsi_GenCADr(dvbpsi_ca_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x09, p_decoded->i_private_length + 4, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x09, p_decoded->i_private_length + 4, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = p_decoded->i_ca_system_id >> 8;
p_descriptor->p_data[1] = p_decoded->i_ca_system_id;
p_descriptor->p_data[2] = 0xe0 | ((p_decoded->i_ca_pid >> 8) & 0x1f);
p_descriptor->p_data[3] = p_decoded->i_ca_pid;
if(p_decoded->i_private_length)
memcpy(p_descriptor->p_data + 4,
p_decoded->i_private_data,
p_decoded->i_private_length);
if (p_decoded->i_private_length)
memcpy(p_descriptor->p_data + 4,
p_decoded->i_private_data,
p_decoded->i_private_length);
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_ca_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -46,40 +46,39 @@
*****************************************************************************/
dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_iso639_dr_t * p_decoded;
int i;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0a))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = (dvbpsi_iso639_dr_t*)malloc(sizeof(dvbpsi_iso639_dr_t));
if(!p_decoded) return NULL;
/* Decode data and check the length */
if((p_descriptor->i_length < 1) || (p_descriptor->i_length % 4 != 0))
{
free(p_decoded);
return NULL;
}
p_decoded->i_code_count = p_descriptor->i_length / 4;
i = 0;
while( i < p_decoded->i_code_count ) {
p_decoded->code[i].iso_639_code[0] = p_descriptor->p_data[i*4];
p_decoded->code[i].iso_639_code[1] = p_descriptor->p_data[i*4+1];
p_decoded->code[i].iso_639_code[2] = p_descriptor->p_data[i*4+2];
p_decoded->code[i].i_audio_type = p_descriptor->p_data[i*4+3];
i++;
}
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
dvbpsi_iso639_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0a))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
if ((p_descriptor->i_length < 1) ||
(p_descriptor->i_length % 4 != 0))
return NULL;
/* Allocate memory */
p_decoded = (dvbpsi_iso639_dr_t*)malloc(sizeof(dvbpsi_iso639_dr_t));
if (!p_decoded)
return NULL;
p_decoded->i_code_count = p_descriptor->i_length / 4;
int i = 0;
while( i < p_decoded->i_code_count )
{
p_decoded->code[i].iso_639_code[0] = p_descriptor->p_data[i*4];
p_decoded->code[i].iso_639_code[1] = p_descriptor->p_data[i*4+1];
p_decoded->code[i].iso_639_code[2] = p_descriptor->p_data[i*4+2];
p_decoded->code[i].i_audio_type = p_descriptor->p_data[i*4+3];
i++;
}
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
......@@ -89,30 +88,31 @@ dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor)
dvbpsi_descriptor_t * dvbpsi_GenISO639Dr(dvbpsi_iso639_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x0a, p_decoded->i_code_count * 4, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x0a, p_decoded->i_code_count * 4, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
int i = 0;
while( i < p_decoded->i_code_count ) {
p_descriptor->p_data[i*4] = p_decoded->code[i].iso_639_code[0];
p_descriptor->p_data[i*4+1] = p_decoded->code[i].iso_639_code[1];
p_descriptor->p_data[i*4+2] = p_decoded->code[i].iso_639_code[2];
p_descriptor->p_data[i*4+3] = p_decoded->code[i].i_audio_type;
i++;
while( i < p_decoded->i_code_count )
{
p_descriptor->p_data[i*4] = p_decoded->code[i].iso_639_code[0];
p_descriptor->p_data[i*4+1] = p_decoded->code[i].iso_639_code[1];
p_descriptor->p_data[i*4+2] = p_decoded->code[i].iso_639_code[2];
p_descriptor->p_data[i*4+3] = p_decoded->code[i].i_audio_type;
i++;
}
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_iso639_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -47,38 +47,35 @@
dvbpsi_system_clock_dr_t * dvbpsi_DecodeSystemClockDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_system_clock_dr_t * p_decoded;
dvbpsi_system_clock_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0b))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0b))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded =
(dvbpsi_system_clock_dr_t*)malloc(sizeof(dvbpsi_system_clock_dr_t));
if(!p_decoded) return NULL;
/* Check the length */
if (p_descriptor->i_length != 2)
return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 2)
{
free(p_decoded);
return NULL;
}
/* Allocate memory */
p_decoded =
(dvbpsi_system_clock_dr_t*)malloc(sizeof(dvbpsi_system_clock_dr_t));
if (!p_decoded)
return NULL;
p_decoded->b_external_clock_ref = (p_descriptor->p_data[0] & 0x80) ? true : false;
p_decoded->i_clock_accuracy_integer = p_descriptor->p_data[0] & 0x3f;
p_decoded->i_clock_accuracy_exponent = (p_descriptor->p_data[1] & 0xe0) >> 5;
p_decoded->b_external_clock_ref = (p_descriptor->p_data[0] & 0x80) ? true : false;
p_decoded->i_clock_accuracy_integer = p_descriptor->p_data[0] & 0x3f;
p_decoded->i_clock_accuracy_exponent = (p_descriptor->p_data[1] & 0xe0) >> 5;
p_descriptor->p_decoded = (void*)p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenSystemClockDr
*****************************************************************************/
......@@ -86,28 +83,26 @@ dvbpsi_descriptor_t * dvbpsi_GenSystemClockDr(
dvbpsi_system_clock_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x0b, 2, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x0b, 2, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] =
0x40 | (p_decoded->i_clock_accuracy_integer & 0x3f);
if(p_decoded->b_external_clock_ref)
p_descriptor->p_data[0] |= 0x80;
0x40 | (p_decoded->i_clock_accuracy_integer & 0x3f);
if (p_decoded->b_external_clock_ref)
p_descriptor->p_data[0] |= 0x80;
p_descriptor->p_data[1] = 0x1f | p_decoded->i_clock_accuracy_exponent << 5;
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_system_clock_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -47,37 +47,34 @@
dvbpsi_mx_buff_utilization_dr_t * dvbpsi_DecodeMxBuffUtilizationDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_mx_buff_utilization_dr_t * p_decoded;
dvbpsi_mx_buff_utilization_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0c))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0c))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = (dvbpsi_mx_buff_utilization_dr_t*)
malloc(sizeof(dvbpsi_mx_buff_utilization_dr_t));
if(!p_decoded) return NULL;
if (p_descriptor->i_length != 3)
return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 3)
{
free(p_decoded);
return NULL;
}
/* Allocate memory */
p_decoded = (dvbpsi_mx_buff_utilization_dr_t*)
malloc(sizeof(dvbpsi_mx_buff_utilization_dr_t));
if (!p_decoded)
return NULL;
p_decoded->b_mdv_valid = (p_descriptor->p_data[0] & 0x80) ? true : false;
p_decoded->i_mx_delay_variation =
((uint16_t)(p_descriptor->p_data[0] & 0x7f) << 8)
| p_descriptor->p_data[1];
p_decoded->i_mx_strategy = (p_descriptor->p_data[2] & 0xe0) >> 5;
p_decoded->b_mdv_valid = (p_descriptor->p_data[0] & 0x80) ? true : false;
p_decoded->i_mx_delay_variation =
((uint16_t)(p_descriptor->p_data[0] & 0x7f) << 8)
| p_descriptor->p_data[1];
p_decoded->i_mx_strategy = (p_descriptor->p_data[2] & 0xe0) >> 5;
p_descriptor->p_decoded = (void*)p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
return p_decoded;
}
......@@ -88,28 +85,26 @@ dvbpsi_descriptor_t * dvbpsi_GenMxBuffUtilizationDr(
dvbpsi_mx_buff_utilization_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x0c, 3, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x0c, 3, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = (p_decoded->i_mx_delay_variation >> 8) & 0x7f;
if(p_decoded->b_mdv_valid)
p_descriptor->p_data[0] |= 0x80;
p_descriptor->p_data[0] |= 0x80;
p_descriptor->p_data[1] = p_decoded->i_mx_delay_variation;
p_descriptor->p_data[2] = 0x1f | p_decoded->i_mx_strategy << 5;
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_mx_buff_utilization_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -47,42 +47,39 @@
dvbpsi_copyright_dr_t * dvbpsi_DecodeCopyrightDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_copyright_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0d))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = (dvbpsi_copyright_dr_t*)
malloc(sizeof(dvbpsi_copyright_dr_t));
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 4)
{
free(p_decoded);
return NULL;
}
p_decoded->i_copyright_identifier =
((uint32_t)(p_descriptor->p_data[0]) << 24)
| ((uint32_t)(p_descriptor->p_data[1]) << 16)
| ((uint32_t)(p_descriptor->p_data[2]) << 8)
| (uint32_t)(p_descriptor->p_data[3]);
p_decoded->i_additional_length = p_descriptor->i_length - 4;
if(p_decoded->i_additional_length)
memcpy(p_decoded->i_additional_info,
p_descriptor->p_data + 4,
p_decoded->i_additional_length);
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
dvbpsi_copyright_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0d))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
if (p_descriptor->i_length < 4)
return NULL;
/* Allocate memory */
p_decoded = (dvbpsi_copyright_dr_t*)
malloc(sizeof(dvbpsi_copyright_dr_t));
if (!p_decoded)
return NULL;
p_decoded->i_copyright_identifier =
((uint32_t)(p_descriptor->p_data[0]) << 24)
| ((uint32_t)(p_descriptor->p_data[1]) << 16)
| ((uint32_t)(p_descriptor->p_data[2]) << 8)
| (uint32_t)(p_descriptor->p_data[3]);
p_decoded->i_additional_length = p_descriptor->i_length - 4;
if (p_decoded->i_additional_length)
memcpy(p_decoded->i_additional_info,
p_descriptor->p_data + 4,
p_decoded->i_additional_length);
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
......@@ -93,31 +90,30 @@ dvbpsi_descriptor_t * dvbpsi_GenCopyrightDr(
dvbpsi_copyright_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x0d, p_decoded->i_additional_length + 4, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x0d, p_decoded->i_additional_length + 4, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = p_decoded->i_copyright_identifier >> 24;
p_descriptor->p_data[1] = p_decoded->i_copyright_identifier >> 16;
p_descriptor->p_data[2] = p_decoded->i_copyright_identifier >> 8;
p_descriptor->p_data[3] = p_decoded->i_copyright_identifier;
if(p_decoded->i_additional_length)
memcpy(p_descriptor->p_data + 4,
p_decoded->i_additional_info,
p_decoded->i_additional_length);
memcpy(p_descriptor->p_data + 4,
p_decoded->i_additional_info,
p_decoded->i_additional_length);
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_copyright_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -47,38 +47,34 @@
dvbpsi_max_bitrate_dr_t * dvbpsi_DecodeMaxBitrateDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_max_bitrate_dr_t * p_decoded;
dvbpsi_max_bitrate_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0e))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0e))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = (dvbpsi_max_bitrate_dr_t*)malloc(sizeof(dvbpsi_max_bitrate_dr_t));
if(!p_decoded) return NULL;
if (p_descriptor->i_length != 3)
return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 3)
{
free(p_decoded);
return NULL;
}
/* Allocate memory */
p_decoded = (dvbpsi_max_bitrate_dr_t*)malloc(sizeof(dvbpsi_max_bitrate_dr_t));
if (!p_decoded)
return NULL;
p_decoded->i_max_bitrate =
((uint32_t)(p_descriptor->p_data[0] & 0x3f) << 16)
| ((uint32_t)(p_descriptor->p_data[1]) << 8)
| p_descriptor->p_data[2];
p_decoded->i_max_bitrate =
((uint32_t)(p_descriptor->p_data[0] & 0x3f) << 16)
| ((uint32_t)(p_descriptor->p_data[1]) << 8)
| p_descriptor->p_data[2];
p_descriptor->p_decoded = (void*)p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenMaxBitrateDr
*****************************************************************************/
......@@ -86,26 +82,23 @@ dvbpsi_descriptor_t * dvbpsi_GenMaxBitrateDr(
dvbpsi_max_bitrate_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x0e, 3, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x0e, 3, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = 0xc0 | ((p_decoded->i_max_bitrate >> 16) & 0x3f);
p_descriptor->p_data[1] = p_decoded->i_max_bitrate >> 8;
p_descriptor->p_data[2] = p_decoded->i_max_bitrate;
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_max_bitrate_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -47,36 +47,32 @@
dvbpsi_private_data_dr_t * dvbpsi_DecodePrivateDataDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_private_data_dr_t * p_decoded;
dvbpsi_private_data_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0f))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x0f))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded =
(dvbpsi_private_data_dr_t*)malloc(sizeof(dvbpsi_private_data_dr_t));
if(!p_decoded) return NULL;
if (p_descriptor->i_length != 4)
return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 4)
{
free(p_decoded);
return NULL;
}
/* Allocate memory */
p_decoded = (dvbpsi_private_data_dr_t*)malloc(sizeof(dvbpsi_private_data_dr_t));
if (!p_decoded)
return NULL;
p_decoded->i_private_data = ((uint32_t)(p_descriptor->p_data[0]) << 24)
| ((uint32_t)(p_descriptor->p_data[1]) << 16)
| ((uint32_t)(p_descriptor->p_data[2]) << 8)
| p_descriptor->p_data[3];
p_decoded->i_private_data = ((uint32_t)(p_descriptor->p_data[0]) << 24)
| ((uint32_t)(p_descriptor->p_data[1]) << 16)
| ((uint32_t)(p_descriptor->p_data[2]) << 8)
| p_descriptor->p_data[3];
p_descriptor->p_decoded = (void*)p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
return p_decoded;
}
......@@ -87,27 +83,25 @@ dvbpsi_descriptor_t * dvbpsi_GenPrivateDataDr(
dvbpsi_private_data_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x0f, 4, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x0f, 4, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = p_decoded->i_private_data >> 24;
p_descriptor->p_data[1] = p_decoded->i_private_data >> 16;
p_descriptor->p_data[2] = p_decoded->i_private_data >> 8;
p_descriptor->p_data[3] = p_decoded->i_private_data;
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_private_data_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -84,7 +84,6 @@ dvbpsi_descriptor_t * dvbpsi_GenNetworkNameDr(
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x40, p_decoded->i_name_length, NULL);
if (!p_descriptor)
return NULL;
......
......@@ -48,31 +48,31 @@
dvbpsi_stuffing_dr_t * dvbpsi_DecodeStuffingDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_stuffing_dr_t * p_decoded;
dvbpsi_stuffing_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x42))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x42))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded =
(dvbpsi_stuffing_dr_t*)malloc(sizeof(dvbpsi_stuffing_dr_t));
if(!p_decoded) return NULL;
/* Allocate memory */
p_decoded = (dvbpsi_stuffing_dr_t*)malloc(sizeof(dvbpsi_stuffing_dr_t));
if (!p_decoded)
return NULL;
/* Decode data */
p_decoded->i_stuffing_length = p_descriptor->i_length;
if(p_decoded->i_stuffing_length)
memcpy(p_decoded->i_stuffing_byte,
p_descriptor->p_data,
p_decoded->i_stuffing_length);
/* Decode data */
p_decoded->i_stuffing_length = p_descriptor->i_length;
if (p_decoded->i_stuffing_length)
memcpy(p_decoded->i_stuffing_byte,
p_descriptor->p_data,
p_decoded->i_stuffing_length);
p_descriptor->p_decoded = (void*)p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
return p_decoded;
}
......@@ -83,27 +83,26 @@ dvbpsi_descriptor_t * dvbpsi_GenStuffingDr(
dvbpsi_stuffing_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x42, p_decoded->i_stuffing_length, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x42, p_decoded->i_stuffing_length, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
if(p_decoded->i_stuffing_length)
memcpy(p_descriptor->p_data,
p_decoded->i_stuffing_byte,
p_decoded->i_stuffing_length);
if (p_decoded->i_stuffing_length)
memcpy(p_descriptor->p_data,
p_decoded->i_stuffing_byte,
p_decoded->i_stuffing_length);
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_stuffing_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -47,40 +47,40 @@
dvbpsi_sat_deliv_sys_dr_t * dvbpsi_DecodeSatDelivSysDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_sat_deliv_sys_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x43))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded =
(dvbpsi_sat_deliv_sys_dr_t*)malloc(sizeof(dvbpsi_sat_deliv_sys_dr_t));
if(!p_decoded) return NULL;
/* Decode data */
p_decoded->i_frequency = (uint32_t)(p_descriptor->p_data[0] << 24)
| (uint32_t)(p_descriptor->p_data[1] << 16)
| (uint32_t)(p_descriptor->p_data[2] << 8)
| (uint32_t)(p_descriptor->p_data[3]);
p_decoded->i_orbital_position = (uint16_t)(p_descriptor->p_data[4] << 8)
| (uint16_t)(p_descriptor->p_data[5]);
p_decoded->i_west_east_flag = (p_descriptor->p_data[6] >> 7) & 0x01;
p_decoded->i_polarization = (p_descriptor->p_data[6] >> 5) & 0x03;
p_decoded->i_roll_off = (p_descriptor->p_data[6] >> 3) & 0x03;
p_decoded->i_modulation_system = (p_descriptor->p_data[6] >> 2) & 0x01;
p_decoded->i_modulation_type = p_descriptor->p_data[6] & 0x03;
p_decoded->i_symbol_rate = (uint32_t)(p_descriptor->p_data[7] << 20)
| (uint32_t)(p_descriptor->p_data[8] << 12)
| (uint32_t)(p_descriptor->p_data[9] << 4)
| (uint32_t)((p_descriptor->p_data[10] >> 4) & 0x0f);
p_decoded->i_fec_inner = p_descriptor->p_data[10] & 0x0f;
p_descriptor->p_decoded = (void*)p_decoded;
dvbpsi_sat_deliv_sys_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x43))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = (dvbpsi_sat_deliv_sys_dr_t*)malloc(sizeof(dvbpsi_sat_deliv_sys_dr_t));
if (!p_decoded)
return NULL;
/* Decode data */
p_decoded->i_frequency = (uint32_t)(p_descriptor->p_data[0] << 24)
| (uint32_t)(p_descriptor->p_data[1] << 16)
| (uint32_t)(p_descriptor->p_data[2] << 8)
| (uint32_t)(p_descriptor->p_data[3]);
p_decoded->i_orbital_position = (uint16_t)(p_descriptor->p_data[4] << 8)
| (uint16_t)(p_descriptor->p_data[5]);
p_decoded->i_west_east_flag = (p_descriptor->p_data[6] >> 7) & 0x01;
p_decoded->i_polarization = (p_descriptor->p_data[6] >> 5) & 0x03;
p_decoded->i_roll_off = (p_descriptor->p_data[6] >> 3) & 0x03;
p_decoded->i_modulation_system = (p_descriptor->p_data[6] >> 2) & 0x01;
p_decoded->i_modulation_type = p_descriptor->p_data[6] & 0x03;
p_decoded->i_symbol_rate = (uint32_t)(p_descriptor->p_data[7] << 20)
| (uint32_t)(p_descriptor->p_data[8] << 12)
| (uint32_t)(p_descriptor->p_data[9] << 4)
| (uint32_t)((p_descriptor->p_data[10] >> 4) & 0x0f);
p_decoded->i_fec_inner = p_descriptor->p_data[10] & 0x0f;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
......@@ -93,38 +93,36 @@ dvbpsi_descriptor_t * dvbpsi_GenSatDelivSysDr(
dvbpsi_sat_deliv_sys_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x43, 11, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x43, 11, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = (p_decoded->i_frequency >> 24) & 0xff;
p_descriptor->p_data[1] = (p_decoded->i_frequency >> 16) & 0xff;
p_descriptor->p_data[2] = (p_decoded->i_frequency >> 8) & 0xff;
p_descriptor->p_data[3] = p_decoded->i_frequency & 0xff;
p_descriptor->p_data[4] = (p_decoded->i_orbital_position >> 8) & 0xff;
p_descriptor->p_data[5] = p_decoded->i_orbital_position & 0xff;
p_descriptor->p_data[6] = ((p_decoded->i_west_east_flag & 0x01) << 7)
| ((p_decoded->i_polarization & 0x03) << 5)
| ((p_decoded->i_roll_off & 0x03) << 3)
| ((p_decoded->i_modulation_system & 0x01) << 2)
| (p_decoded->i_modulation_type & 0x03);
p_descriptor->p_data[7] = (p_decoded->i_symbol_rate >> 20) & 0xff;
p_descriptor->p_data[8] = (p_decoded->i_symbol_rate >> 12) & 0xff;
p_descriptor->p_data[9] = (p_decoded->i_symbol_rate >> 4) & 0xff;
p_descriptor->p_data[10] = ((p_decoded->i_symbol_rate << 4) & 0xf0)
| (p_decoded->i_fec_inner & 0x0f);
if(b_duplicate)
p_descriptor->p_data[0] = (p_decoded->i_frequency >> 24) & 0xff;
p_descriptor->p_data[1] = (p_decoded->i_frequency >> 16) & 0xff;
p_descriptor->p_data[2] = (p_decoded->i_frequency >> 8) & 0xff;
p_descriptor->p_data[3] = p_decoded->i_frequency & 0xff;
p_descriptor->p_data[4] = (p_decoded->i_orbital_position >> 8) & 0xff;
p_descriptor->p_data[5] = p_decoded->i_orbital_position & 0xff;
p_descriptor->p_data[6] = ((p_decoded->i_west_east_flag & 0x01) << 7)
| ((p_decoded->i_polarization & 0x03) << 5)
| ((p_decoded->i_roll_off & 0x03) << 3)
| ((p_decoded->i_modulation_system & 0x01) << 2)
| (p_decoded->i_modulation_type & 0x03);
p_descriptor->p_data[7] = (p_decoded->i_symbol_rate >> 20) & 0xff;
p_descriptor->p_data[8] = (p_decoded->i_symbol_rate >> 12) & 0xff;
p_descriptor->p_data[9] = (p_decoded->i_symbol_rate >> 4) & 0xff;
p_descriptor->p_data[10] = ((p_decoded->i_symbol_rate << 4) & 0xf0)
| (p_decoded->i_fec_inner & 0x0f);
if (b_duplicate)
{
/* Duplicate decoded data */
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_sat_deliv_sys_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -60,7 +60,7 @@ dvbpsi_cable_deliv_sys_dr_t * dvbpsi_DecodeCableDelivSysDr(
/* Allocate memory */
p_decoded =
(dvbpsi_cable_deliv_sys_dr_t*)malloc(sizeof(dvbpsi_cable_deliv_sys_dr_t));
if(!p_decoded)
if (!p_decoded)
return NULL;
/* Decode data */
......@@ -88,12 +88,12 @@ dvbpsi_descriptor_t * dvbpsi_GenCableDelivSysDr(
dvbpsi_cable_deliv_sys_dr_t * p_decoded,
int b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x44, 11, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x44, 11, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = (p_decoded->i_frequency >> 24) & 0xff;
p_descriptor->p_data[1] = (p_decoded->i_frequency >> 16) & 0xff;
......@@ -114,7 +114,6 @@ dvbpsi_descriptor_t * dvbpsi_GenCableDelivSysDr(
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_cable_deliv_sys_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -46,60 +46,57 @@
dvbpsi_vbi_dr_t * dvbpsi_DecodeVBIDataDr(
dvbpsi_descriptor_t * p_descriptor)
{
int i_services_number, i;
dvbpsi_vbi_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x45))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x45))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Check the length */
if (p_descriptor->i_length < 3)
return NULL;
if (p_descriptor->i_length % 2)
return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
return NULL;
/* */
dvbpsi_vbi_dr_t * p_decoded;
int i_services_number = p_descriptor->i_length / 2;
if(p_descriptor->i_length % 2)
return NULL;
/* Allocate memory */
p_decoded = (dvbpsi_vbi_dr_t*)malloc(sizeof(dvbpsi_vbi_dr_t));
if (!p_decoded)
return NULL;
i_services_number = p_descriptor->i_length / 2;
p_decoded->i_services_number = i_services_number;
/* Allocate memory */
p_decoded =
(dvbpsi_vbi_dr_t*)malloc(sizeof(dvbpsi_vbi_dr_t));
if(!p_decoded) return NULL;
p_decoded->i_services_number = i_services_number;
for(i=0; i < i_services_number; i++)
{
int n, i_lines = 0, i_data_service_id;
i_data_service_id = ((uint8_t)(p_descriptor->p_data[3 * i + 2 + i_lines]));
p_decoded->p_services[i].i_data_service_id = i_data_service_id;
i_lines = ((uint8_t)(p_descriptor->p_data[3 * i + 3]));
p_decoded->p_services[i].i_lines = i_lines;
for(n=0; n < i_lines; n++ )
for (int i = 0; i < i_services_number; i++)
{
if( (i_data_service_id >= 0x01) && (i_data_service_id <= 0x07) )
{
p_decoded->p_services[i].p_lines[n].i_parity =
((uint8_t)((p_descriptor->p_data[3 * i + 3 + n])&0x20)>>5);
p_decoded->p_services[i].p_lines[n].i_line_offset =
((uint8_t)(p_descriptor->p_data[3 * i + 3 + n])&0x1f);
}
int i_lines = 0, i_data_service_id;
i_data_service_id = ((uint8_t)(p_descriptor->p_data[3 * i + 2 + i_lines]));
p_decoded->p_services[i].i_data_service_id = i_data_service_id;
i_lines = ((uint8_t)(p_descriptor->p_data[3 * i + 3]));
p_decoded->p_services[i].i_lines = i_lines;
for (int n = 0; n < i_lines; n++ )
{
if( (i_data_service_id >= 0x01) && (i_data_service_id <= 0x07) )
{
p_decoded->p_services[i].p_lines[n].i_parity =
((uint8_t)((p_descriptor->p_data[3 * i + 3 + n])&0x20)>>5);
p_decoded->p_services[i].p_lines[n].i_line_offset =
((uint8_t)(p_descriptor->p_data[3 * i + 3 + n])&0x1f);
}
}
}
}
p_descriptor->p_decoded = (void*)p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenVBIDataDr
*****************************************************************************/
......@@ -107,43 +104,39 @@ dvbpsi_descriptor_t * dvbpsi_GenVBIDataDr(
dvbpsi_vbi_dr_t * p_decoded,
bool b_duplicate)
{
int i;
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x45, p_decoded->i_services_number * 5 , NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x45, p_decoded->i_services_number * 5 , NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
for (i=0; i < p_decoded->i_services_number; i++ )
for (int i = 0; i < p_decoded->i_services_number; i++ )
{
int n;
p_descriptor->p_data[5 * i + 3] =
( (uint8_t) p_decoded->p_services[i].i_data_service_id );
p_descriptor->p_data[5 * i + 4] = p_decoded->p_services[i].i_lines;
for (n=0; n < p_decoded->p_services[i].i_lines; n++ )
{
if( (p_decoded->p_services[i].i_data_service_id >= 0x01) &&
(p_decoded->p_services[i].i_data_service_id <= 0x07) )
{
p_descriptor->p_data[5 * i + 4 + n] = (uint8_t)
( (((uint8_t) p_decoded->p_services[i].p_lines[n].i_parity)&0x20)<<5) |
( ((uint8_t) p_decoded->p_services[i].p_lines[n].i_line_offset)&0x1f);
}
else p_descriptor->p_data[5 * i + 3 + n] = 0xFF; /* Stuffing byte */
}
p_descriptor->p_data[5 * i + 3] =
( (uint8_t) p_decoded->p_services[i].i_data_service_id );
p_descriptor->p_data[5 * i + 4] = p_decoded->p_services[i].i_lines;
for (int n=0; n < p_decoded->p_services[i].i_lines; n++ )
{
if( (p_decoded->p_services[i].i_data_service_id >= 0x01) &&
(p_decoded->p_services[i].i_data_service_id <= 0x07) )
{
p_descriptor->p_data[5 * i + 4 + n] = (uint8_t)
( (((uint8_t) p_decoded->p_services[i].p_lines[n].i_parity)&0x20)<<5) |
( ((uint8_t) p_decoded->p_services[i].p_lines[n].i_line_offset)&0x1f);
}
else p_descriptor->p_data[5 * i + 3 + n] = 0xFF; /* Stuffing byte */
}
}
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_vbi_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -48,31 +48,31 @@
dvbpsi_bouquet_name_dr_t * dvbpsi_DecodeBouquetNameDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_bouquet_name_dr_t * p_decoded;
dvbpsi_bouquet_name_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x47))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x47))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded =
(dvbpsi_bouquet_name_dr_t*)malloc(sizeof(dvbpsi_bouquet_name_dr_t));
if(!p_decoded) return NULL;
/* Allocate memory */
p_decoded = (dvbpsi_bouquet_name_dr_t*)malloc(sizeof(dvbpsi_bouquet_name_dr_t));
if (!p_decoded)
return NULL;
/* Decode data */
p_decoded->i_name_length = p_descriptor->i_length;
if(p_decoded->i_name_length)
memcpy(p_decoded->i_char,
p_descriptor->p_data,
p_decoded->i_name_length);
/* Decode data */
p_decoded->i_name_length = p_descriptor->i_length;
if(p_decoded->i_name_length)
memcpy(p_decoded->i_char,
p_descriptor->p_data,
p_decoded->i_name_length);
p_descriptor->p_decoded = (void*)p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
return p_decoded;
}
......@@ -83,26 +83,25 @@ dvbpsi_descriptor_t * dvbpsi_GenBouquetNameDr(
dvbpsi_bouquet_name_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x47, p_decoded->i_name_length, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x47, p_decoded->i_name_length, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
if(p_decoded->i_name_length)
memcpy(p_descriptor->p_data,
p_decoded->i_char,
p_decoded->i_name_length);
memcpy(p_descriptor->p_data,
p_decoded->i_char,
p_decoded->i_name_length);
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_bouquet_name_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -48,63 +48,57 @@
dvbpsi_service_dr_t * dvbpsi_DecodeServiceDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_service_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x48))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x48))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
if (p_descriptor->i_length < 3)
return NULL;
/* Allocate memory */
p_decoded =
(dvbpsi_service_dr_t*)malloc(sizeof(dvbpsi_service_dr_t));
if(!p_decoded) return NULL;
/* Allocate memory */
dvbpsi_service_dr_t * p_decoded;
p_decoded = (dvbpsi_service_dr_t*)malloc(sizeof(dvbpsi_service_dr_t));
if (!p_decoded)
return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
{
free(p_decoded);
return NULL;
}
p_descriptor->p_decoded = (void*)p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
p_decoded->i_service_type = p_descriptor->p_data[0];
p_decoded->i_service_provider_name_length = p_descriptor->p_data[1];
p_decoded->i_service_name_length = 0;
p_decoded->i_service_provider_name[0] = 0;
p_decoded->i_service_name[0] = 0;
p_decoded->i_service_type = p_descriptor->p_data[0];
p_decoded->i_service_provider_name_length = p_descriptor->p_data[1];
p_decoded->i_service_name_length = 0;
p_decoded->i_service_provider_name[0] = 0;
p_decoded->i_service_name[0] = 0;
if (p_decoded->i_service_provider_name_length + 2 > p_descriptor->i_length)
return p_decoded;
if(p_decoded->i_service_provider_name_length + 2 > p_descriptor->i_length)
return p_decoded;
if (p_decoded->i_service_provider_name_length)
memcpy(p_decoded->i_service_provider_name,
p_descriptor->p_data + 2,
p_decoded->i_service_provider_name_length);
if(p_decoded->i_service_provider_name_length)
memcpy(p_decoded->i_service_provider_name,
p_descriptor->p_data + 2,
p_decoded->i_service_provider_name_length);
if (p_decoded->i_service_provider_name_length + 3 > p_descriptor->i_length)
return p_decoded;
if(p_decoded->i_service_provider_name_length + 3 > p_descriptor->i_length)
return p_decoded;
p_decoded->i_service_name_length =
p_descriptor->p_data[2+p_decoded->i_service_provider_name_length];
p_decoded->i_service_name_length =
p_descriptor->p_data[2+p_decoded->i_service_provider_name_length];
if (p_decoded->i_service_provider_name_length + 3 +
p_decoded->i_service_name_length > p_descriptor->i_length)
return p_decoded;
if(p_decoded->i_service_provider_name_length + 3 +
p_decoded->i_service_name_length > p_descriptor->i_length)
return p_decoded;
if (p_decoded->i_service_name_length)
memcpy(p_decoded->i_service_name,
p_descriptor->p_data + 3 + p_decoded->i_service_provider_name_length,
p_decoded->i_service_name_length);
if(p_decoded->i_service_name_length)
memcpy(p_decoded->i_service_name,
p_descriptor->p_data + 3 + p_decoded->i_service_provider_name_length,
p_decoded->i_service_name_length);
return p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenServiceDr
*****************************************************************************/
......@@ -112,36 +106,34 @@ dvbpsi_descriptor_t * dvbpsi_GenServiceDr(
dvbpsi_service_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x48, 3 + p_decoded->i_service_name_length +
p_decoded->i_service_provider_name_length , NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x48, 3 + p_decoded->i_service_name_length +
p_decoded->i_service_provider_name_length , NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = p_decoded->i_service_type;
p_descriptor->p_data[1] = p_decoded->i_service_provider_name_length;
if(p_decoded->i_service_provider_name_length)
memcpy(p_descriptor->p_data + 2,
p_decoded->i_service_provider_name,
p_decoded->i_service_provider_name_length);
if (p_decoded->i_service_provider_name_length)
memcpy(p_descriptor->p_data + 2,
p_decoded->i_service_provider_name,
p_decoded->i_service_provider_name_length);
p_descriptor->p_data[2+p_decoded->i_service_provider_name_length] =
p_decoded->i_service_name_length;
if(p_decoded->i_service_name_length)
memcpy(p_descriptor->p_data + 3 + p_decoded->i_service_provider_name_length,
p_decoded->i_service_name,
p_decoded->i_service_name_length);
p_decoded->i_service_name_length;
if (p_decoded->i_service_name_length)
memcpy(p_descriptor->p_data + 3 + p_decoded->i_service_provider_name_length,
p_decoded->i_service_name,
p_decoded->i_service_name_length);
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_service_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -62,24 +62,25 @@ dvbpsi_short_event_dr_t * dvbpsi_DecodeShortEventDr(dvbpsi_descriptor_t * p_desc
i_len1 = p_descriptor->p_data[3];
i_len2 = p_descriptor->p_data[4+i_len1];
if( p_descriptor->i_length < 5 + i_len1 + i_len2 )
if (p_descriptor->i_length < 5 + i_len1 + i_len2)
return NULL;
/* Don't decode twice */
if(p_descriptor->p_decoded)
if (p_descriptor->p_decoded)
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = malloc(sizeof(dvbpsi_short_event_dr_t));
if(!p_decoded) 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 );
p_decoded->i_event_name_length = i_len1;
if( i_len1 > 0 )
if (i_len1 > 0)
memcpy( p_decoded->i_event_name, &p_descriptor->p_data[3+1], i_len1 );
p_decoded->i_text_length = i_len2;
if( i_len2 > 0 )
if (i_len2 > 0)
memcpy( p_decoded->i_text, &p_descriptor->p_data[4+i_len1+1], i_len2 );
p_descriptor->p_decoded = (void*)p_decoded;
......@@ -87,39 +88,37 @@ dvbpsi_short_event_dr_t * dvbpsi_DecodeShortEventDr(dvbpsi_descriptor_t * p_desc
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenShortEventDr
*****************************************************************************/
dvbpsi_descriptor_t * dvbpsi_GenShortEventDr(dvbpsi_short_event_dr_t * p_decoded,
bool b_duplicate)
{
int i_len1 = p_decoded->i_event_name_length;
int i_len2 = p_decoded->i_text_length;
int i_len1 = p_decoded->i_event_name_length;
int i_len2 = p_decoded->i_text_length;
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x4d, 5 + i_len1 + i_len2, NULL );
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x4d, 5 + i_len1 + i_len2, NULL );
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
memcpy( &p_descriptor->p_data[0], p_decoded->i_iso_639_code, 3 );
p_descriptor->p_data[3] = i_len1;
if( i_len1 )
if (i_len1)
memcpy( &p_descriptor->p_data[4], p_decoded->i_event_name, i_len1 );
p_descriptor->p_data[3+1+i_len1] = i_len2;
if( i_len2 )
if (i_len2)
memcpy( &p_descriptor->p_data[3+1+i_len1+1], p_decoded->i_text, i_len2 );
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_short_event_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -45,59 +45,60 @@
*****************************************************************************/
dvbpsi_extended_event_dr_t * dvbpsi_DecodeExtendedEventDr(dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_extended_event_dr_t * p_decoded;
int i_len;
int i_pos;
uint8_t *p;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x4e) ||
p_descriptor->i_length < 6 )
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = malloc(sizeof(dvbpsi_extended_event_dr_t));
if(!p_decoded) return NULL;
/* Decode */
p_decoded->i_descriptor_number = (p_descriptor->p_data[0] >> 4)&0xf;
p_decoded->i_last_descriptor_number = p_descriptor->p_data[0]&0x0f;
memcpy( &p_decoded->i_iso_639_code[0], &p_descriptor->p_data[1], 3 );
p_decoded->i_entry_count = 0;
i_len = p_descriptor->p_data[4];
i_pos = 0;
for( p = &p_descriptor->p_data[5]; p < &p_descriptor->p_data[5+i_len]; )
{
int idx = p_decoded->i_entry_count;
p_decoded->i_item_description_length[idx] = p[0];
p_decoded->i_item_description[idx] = &p_decoded->i_buffer[i_pos];
memcpy( &p_decoded->i_buffer[i_pos], &p[1], p[0] );
i_pos += p[0];
p += 1 + p[0];
p_decoded->i_item_length[idx] = p[0];
p_decoded->i_item[idx] = &p_decoded->i_buffer[i_pos];
memcpy( &p_decoded->i_buffer[i_pos], &p[1], p[0] );
i_pos += p[0];
p += 1 + p[0];
p_decoded->i_entry_count++;
}
p_decoded->i_text_length = p_descriptor->p_data[5+i_len];
if( p_decoded->i_text_length > 0 )
memcpy( &p_decoded->i_buffer[i_pos],
&p_descriptor->p_data[5+i_len+1], p_decoded->i_text_length );
p_decoded->i_text = &p_decoded->i_buffer[i_pos];
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
dvbpsi_extended_event_dr_t * p_decoded;
int i_len;
int i_pos;
uint8_t *p;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x4e) ||
p_descriptor->i_length < 6 )
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = malloc(sizeof(dvbpsi_extended_event_dr_t));
if (!p_decoded)
return NULL;
/* Decode */
p_decoded->i_descriptor_number = (p_descriptor->p_data[0] >> 4)&0xf;
p_decoded->i_last_descriptor_number = p_descriptor->p_data[0]&0x0f;
memcpy( &p_decoded->i_iso_639_code[0], &p_descriptor->p_data[1], 3 );
p_decoded->i_entry_count = 0;
i_len = p_descriptor->p_data[4];
i_pos = 0;
for( p = &p_descriptor->p_data[5]; p < &p_descriptor->p_data[5+i_len]; )
{
int idx = p_decoded->i_entry_count;
p_decoded->i_item_description_length[idx] = p[0];
p_decoded->i_item_description[idx] = &p_decoded->i_buffer[i_pos];
memcpy( &p_decoded->i_buffer[i_pos], &p[1], p[0] );
i_pos += p[0];
p += 1 + p[0];
p_decoded->i_item_length[idx] = p[0];
p_decoded->i_item[idx] = &p_decoded->i_buffer[i_pos];
memcpy( &p_decoded->i_buffer[i_pos], &p[1], p[0] );
i_pos += p[0];
p += 1 + p[0];
p_decoded->i_entry_count++;
}
p_decoded->i_text_length = p_descriptor->p_data[5+i_len];
if( p_decoded->i_text_length > 0 )
memcpy( &p_decoded->i_buffer[i_pos],
&p_descriptor->p_data[5+i_len+1], p_decoded->i_text_length );
p_decoded->i_text = &p_decoded->i_buffer[i_pos];
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
......@@ -107,32 +108,31 @@ dvbpsi_extended_event_dr_t * dvbpsi_DecodeExtendedEventDr(dvbpsi_descriptor_t *
dvbpsi_descriptor_t * dvbpsi_GenExtendedEventDr(dvbpsi_extended_event_dr_t * p_decoded,
bool b_duplicate)
{
int i_len;
int i_len2;
dvbpsi_descriptor_t * p_descriptor;
int i;
int i_len;
int i_len2;
dvbpsi_descriptor_t * p_descriptor;
i_len2 = 0;
for( i = 0; i < p_decoded->i_entry_count; i++ )
i_len2 += 2 + p_decoded->i_item_description_length[i] + p_decoded->i_item_length[i];
i_len = 1 + 3 + 1 + i_len2 + 1 + p_decoded->i_text_length;
i_len2 = 0;
for (int i = 0; i < p_decoded->i_entry_count; i++)
i_len2 += 2 + p_decoded->i_item_description_length[i] + p_decoded->i_item_length[i];
i_len = 1 + 3 + 1 + i_len2 + 1 + p_decoded->i_text_length;
/* Create the descriptor */
p_descriptor = dvbpsi_NewDescriptor(0x4e, i_len, NULL );
/* Create the descriptor */
p_descriptor = dvbpsi_NewDescriptor(0x4e, i_len, NULL );
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
uint8_t *p = &p_descriptor->p_data[0];
/* Encode data */
p[0] = (p_decoded->i_descriptor_number << 4 ) |
p_decoded->i_last_descriptor_number;
p_decoded->i_last_descriptor_number;
memcpy( &p[1], p_decoded->i_iso_639_code, 3 );
p[4] = i_len2;
p += 4;
for( i = 0; i < p_decoded->i_entry_count; i++ )
for (int i = 0; i < p_decoded->i_entry_count; i++)
{
p[0] = p_decoded->i_item_description_length[i];
memcpy( &p[1], p_decoded->i_item_description[i], p[0] );
......@@ -146,14 +146,13 @@ dvbpsi_descriptor_t * dvbpsi_GenExtendedEventDr(dvbpsi_extended_event_dr_t * p_d
p[0] = p_decoded->i_text_length;
memcpy( &p[1], p_decoded->i_text, p[0] );
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_extended_event_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -46,33 +46,29 @@
dvbpsi_stream_identifier_dr_t * dvbpsi_DecodeStreamIdentifierDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_stream_identifier_dr_t * p_decoded;
dvbpsi_stream_identifier_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x52))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x52))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded =
(dvbpsi_stream_identifier_dr_t*)malloc(sizeof(dvbpsi_stream_identifier_dr_t));
if(!p_decoded) return NULL;
if (p_descriptor->i_length < 1)
return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 1)
{
free(p_decoded);
return NULL;
}
/* Allocate memory */
p_decoded = (dvbpsi_stream_identifier_dr_t*)malloc(sizeof(dvbpsi_stream_identifier_dr_t));
if (!p_decoded)
return NULL;
p_decoded->i_component_tag = p_descriptor->p_data[0];
p_decoded->i_component_tag = p_descriptor->p_data[0];
p_descriptor->p_decoded = (void*)p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
return p_decoded;
}
......@@ -83,24 +79,22 @@ dvbpsi_descriptor_t * dvbpsi_GenStreamIdentifierDr(
dvbpsi_stream_identifier_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x52, 1, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x52, 1, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = p_decoded->i_component_tag;
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_stream_identifier_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -47,46 +47,40 @@
dvbpsi_parental_rating_dr_t * dvbpsi_DecodeParentalRatingDr(
dvbpsi_descriptor_t * p_descriptor)
{
int i_ratings_number, i;
dvbpsi_parental_rating_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x55))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x55))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Decode data and check the length */
if(p_descriptor->i_length % 4)
return NULL;
/* Allocate memory */
p_decoded =
(dvbpsi_parental_rating_dr_t*)malloc(sizeof(dvbpsi_parental_rating_dr_t));
if(!p_decoded) return NULL;
/* Allocate memory */
dvbpsi_parental_rating_dr_t * p_decoded;
p_decoded = (dvbpsi_parental_rating_dr_t*)malloc(sizeof(dvbpsi_parental_rating_dr_t));
if (!p_decoded)
return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length % 4)
{
free(p_decoded);
return NULL;
}
int i_ratings_number = p_descriptor->i_length / 4;
p_decoded->i_ratings_number = i_ratings_number;
i_ratings_number = p_descriptor->i_length / 4;
p_decoded->i_ratings_number = i_ratings_number;
for (i=0; i < i_ratings_number; i++)
{
p_decoded->p_parental_rating[i].i_country_code =
((uint32_t)p_descriptor->p_data[4 * i] << 16)
| ((uint32_t)p_descriptor->p_data[4 * i + 1] << 8)
| p_descriptor->p_data[4 * i + 2];
for (int i = 0; i < i_ratings_number; i++)
{
p_decoded->p_parental_rating[i].i_country_code =
((uint32_t)p_descriptor->p_data[4 * i] << 16)
| ((uint32_t)p_descriptor->p_data[4 * i + 1] << 8)
| p_descriptor->p_data[4 * i + 2];
p_decoded->p_parental_rating[i].i_rating = p_descriptor->p_data[4 * i + 3];
}
p_decoded->p_parental_rating[i].i_rating = p_descriptor->p_data[4 * i + 3];
}
p_descriptor->p_decoded = (void*)p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
return p_decoded;
}
......@@ -97,37 +91,35 @@ dvbpsi_descriptor_t * dvbpsi_GenParentalRatingDr(
dvbpsi_parental_rating_dr_t * p_decoded,
bool b_duplicate)
{
int i;
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x55, p_decoded->i_ratings_number * 4 , NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x55, p_decoded->i_ratings_number * 4 , NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
for (i=0; i < p_decoded->i_ratings_number; i++ )
for (int i = 0; i < p_decoded->i_ratings_number; i++ )
{
p_descriptor->p_data[8 * i] =
p_decoded->p_parental_rating[i].i_country_code >> 16;
p_descriptor->p_data[8 * i + 1] =
(p_decoded->p_parental_rating[i].i_country_code >> 8) & 0xff;
p_descriptor->p_data[8 * i + 2] =
p_decoded->p_parental_rating[i].i_country_code & 0xff;
p_descriptor->p_data[8 * i + 3] =
p_decoded->p_parental_rating[i].i_rating;
p_descriptor->p_data[8 * i] =
p_decoded->p_parental_rating[i].i_country_code >> 16;
p_descriptor->p_data[8 * i + 1] =
(p_decoded->p_parental_rating[i].i_country_code >> 8) & 0xff;
p_descriptor->p_data[8 * i + 2] =
p_decoded->p_parental_rating[i].i_country_code & 0xff;
p_descriptor->p_data[8 * i + 3] =
p_decoded->p_parental_rating[i].i_rating;
}
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_parental_rating_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -46,51 +46,50 @@
dvbpsi_teletext_dr_t * dvbpsi_DecodeTeletextDr(
dvbpsi_descriptor_t * p_descriptor)
{
int i_pages_number, i;
dvbpsi_teletext_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x56) &&
!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x46))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x56) &&
!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x46))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
return NULL;
if(p_descriptor->i_length % 5)
return NULL;
if(p_descriptor->i_length % 5)
return NULL;
int i_pages_number;
i_pages_number = p_descriptor->i_length / 5;
i_pages_number = p_descriptor->i_length / 5;
/* Allocate memory */
dvbpsi_teletext_dr_t * p_decoded;
p_decoded = (dvbpsi_teletext_dr_t*)malloc(sizeof(dvbpsi_teletext_dr_t));
if (!p_decoded)
return NULL;
/* Allocate memory */
p_decoded =
(dvbpsi_teletext_dr_t*)malloc(sizeof(dvbpsi_teletext_dr_t));
if(!p_decoded) return NULL;
p_decoded->i_pages_number = i_pages_number;
p_decoded->i_pages_number = i_pages_number;
for(i=0; i < i_pages_number; i++)
{
memcpy(p_decoded->p_pages[i].i_iso6392_language_code,
p_descriptor->p_data + 5 * i, 3);
for (int i = 0; i < i_pages_number; i++)
{
memcpy(p_decoded->p_pages[i].i_iso6392_language_code,
p_descriptor->p_data + 5 * i, 3);
p_decoded->p_pages[i].i_teletext_type =
p_decoded->p_pages[i].i_teletext_type =
((uint8_t)(p_descriptor->p_data[5 * i + 3]) >> 3);
p_decoded->p_pages[i].i_teletext_magazine_number =
((uint16_t)(p_descriptor->p_data[5 * i + 3]) & 0x07);
p_decoded->p_pages[i].i_teletext_magazine_number =
((uint16_t)(p_descriptor->p_data[5 * i + 3]) & 0x07);
p_decoded->p_pages[i].i_teletext_page_number = p_descriptor->p_data[5 * i + 4];
}
p_decoded->p_pages[i].i_teletext_page_number = p_descriptor->p_data[5 * i + 4];
}
p_descriptor->p_decoded = (void*)p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
return p_decoded;
}
......@@ -101,37 +100,34 @@ dvbpsi_descriptor_t * dvbpsi_GenTeletextDr(
dvbpsi_teletext_dr_t * p_decoded,
bool b_duplicate)
{
int i;
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x56, p_decoded->i_pages_number * 8 , NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x56, p_decoded->i_pages_number * 8 , NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
for (i=0; i < p_decoded->i_pages_number; i++ )
for (int i = 0; i < p_decoded->i_pages_number; i++ )
{
memcpy( p_descriptor->p_data + 8 * i,
p_decoded->p_pages[i].i_iso6392_language_code,
3);
memcpy( p_descriptor->p_data + 8 * i,
p_decoded->p_pages[i].i_iso6392_language_code,
3);
p_descriptor->p_data[8 * i + 3] =
(uint8_t) ( ( (uint8_t) p_decoded->p_pages[i].i_teletext_type << 3 ) |
p_descriptor->p_data[8 * i + 3] =
(uint8_t) ( ( (uint8_t) p_decoded->p_pages[i].i_teletext_type << 3 ) |
( (uint8_t) p_decoded->p_pages[i].i_teletext_magazine_number & 0x07 ) );
p_descriptor->p_data[8 * i + 4] =
p_decoded->p_pages[i].i_teletext_page_number;
p_descriptor->p_data[8 * i + 4] =
p_decoded->p_pages[i].i_teletext_page_number;
}
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_teletext_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -47,52 +47,52 @@
dvbpsi_local_time_offset_dr_t * dvbpsi_DecodeLocalTimeOffsetDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_local_time_offset_dr_t * p_decoded;
uint8_t * p_data, * p_end;
dvbpsi_local_time_offset_t * p_current;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x58))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded =
(dvbpsi_local_time_offset_dr_t*)malloc(sizeof(dvbpsi_local_time_offset_dr_t));
if(!p_decoded) return NULL;
/* Decode data */
p_decoded->i_local_time_offsets_number = 0;
p_current = p_decoded->p_local_time_offset;
p_end = p_descriptor->p_data + p_descriptor->i_length;
p_data = p_descriptor->p_data;
while(p_data + 13 <= p_end) {
memcpy(p_current->i_country_code, p_data, 3);
p_current->i_country_region_id = (p_data[3] >> 2) & 0x3f;
p_current->i_local_time_offset_polarity = p_data[3] & 0x01;
p_current->i_local_time_offset = ((uint16_t)p_data[4] << 8)
| (uint16_t)p_data[5];
p_current->i_time_of_change = ((uint64_t)p_data[6] << 32)
| ((uint64_t)p_data[7] << 24)
| ((uint64_t)p_data[8] << 16)
| ((uint64_t)p_data[9] << 8)
| (uint64_t)p_data[10];
p_current->i_next_time_offset = ((uint16_t)p_data[11] << 8)
| (uint16_t)p_data[12];
p_decoded->i_local_time_offsets_number++;
p_data += 13;
p_current++;
}
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
dvbpsi_local_time_offset_dr_t * p_decoded;
uint8_t * p_data, * p_end;
dvbpsi_local_time_offset_t * p_current;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x58))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = (dvbpsi_local_time_offset_dr_t*)malloc(sizeof(dvbpsi_local_time_offset_dr_t));
if (!p_decoded)
return NULL;
/* Decode data */
p_decoded->i_local_time_offsets_number = 0;
p_current = p_decoded->p_local_time_offset;
p_end = p_descriptor->p_data + p_descriptor->i_length;
p_data = p_descriptor->p_data;
while(p_data + 13 <= p_end)
{
memcpy(p_current->i_country_code, p_data, 3);
p_current->i_country_region_id = (p_data[3] >> 2) & 0x3f;
p_current->i_local_time_offset_polarity = p_data[3] & 0x01;
p_current->i_local_time_offset = ((uint16_t)p_data[4] << 8)
| (uint16_t)p_data[5];
p_current->i_time_of_change = ((uint64_t)p_data[6] << 32)
| ((uint64_t)p_data[7] << 24)
| ((uint64_t)p_data[8] << 16)
| ((uint64_t)p_data[9] << 8)
| (uint64_t)p_data[10];
p_current->i_next_time_offset = ((uint16_t)p_data[11] << 8)
| (uint16_t)p_data[12];
p_decoded->i_local_time_offsets_number++;
p_data += 13;
p_current++;
}
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenLocalTimeOffsetDr
......@@ -101,48 +101,46 @@ dvbpsi_descriptor_t * dvbpsi_GenLocalTimeOffsetDr(
dvbpsi_local_time_offset_dr_t * p_decoded,
bool b_duplicate)
{
uint8_t i_num;
dvbpsi_local_time_offset_t * p_current;
uint8_t * p_data;
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x58, p_decoded->i_local_time_offsets_number * 13, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x58, p_decoded->i_local_time_offsets_number * 13, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
dvbpsi_local_time_offset_t * p_current;
uint8_t * p_data;
p_current = p_decoded->p_local_time_offset;
p_data = p_descriptor->p_data;
for(i_num = 0; i_num < p_decoded->i_local_time_offsets_number; i_num++) {
memcpy(p_data, p_current->i_country_code, 3);
p_data[3] = ((p_current->i_country_region_id & 0x3f) << 2)
| 0x02
| (p_current->i_local_time_offset_polarity & 0x01);
p_data[4] = (p_current->i_local_time_offset >> 8) & 0xff;
p_data[5] = p_current->i_local_time_offset & 0xff;
p_data[6] = (p_current->i_time_of_change >> 32) & 0xff;
p_data[7] = (p_current->i_time_of_change >> 24) & 0xff;
p_data[8] = (p_current->i_time_of_change >> 16) & 0xff;
p_data[9] = (p_current->i_time_of_change >> 8) & 0xff;
p_data[10] = p_current->i_time_of_change & 0xff;
p_data[11] = (p_current->i_next_time_offset >> 8) & 0xff;
p_data[12] = p_current->i_next_time_offset & 0xff;
p_data += 13;
p_current++;
for (uint8_t i_num = 0; i_num < p_decoded->i_local_time_offsets_number; i_num++)
{
memcpy(p_data, p_current->i_country_code, 3);
p_data[3] = ((p_current->i_country_region_id & 0x3f) << 2)
| 0x02
| (p_current->i_local_time_offset_polarity & 0x01);
p_data[4] = (p_current->i_local_time_offset >> 8) & 0xff;
p_data[5] = p_current->i_local_time_offset & 0xff;
p_data[6] = (p_current->i_time_of_change >> 32) & 0xff;
p_data[7] = (p_current->i_time_of_change >> 24) & 0xff;
p_data[8] = (p_current->i_time_of_change >> 16) & 0xff;
p_data[9] = (p_current->i_time_of_change >> 8) & 0xff;
p_data[10] = p_current->i_time_of_change & 0xff;
p_data[11] = (p_current->i_next_time_offset >> 8) & 0xff;
p_data[12] = p_current->i_next_time_offset & 0xff;
p_data += 13;
p_current++;
}
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_local_time_offset_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -48,63 +48,53 @@
dvbpsi_subtitling_dr_t * dvbpsi_DecodeSubtitlingDr(
dvbpsi_descriptor_t * p_descriptor)
{
int i_subtitles_number, i;
dvbpsi_subtitling_dr_t * p_decoded;
int i_subtitles_number;
dvbpsi_subtitling_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x59))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x59))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
return NULL;
/* Decode data and check the length */
if (p_descriptor->i_length < 3)
return NULL;
/* Allocate memory */
p_decoded =
(dvbpsi_subtitling_dr_t*)malloc(sizeof(dvbpsi_subtitling_dr_t));
if(!p_decoded) return NULL;
if (p_descriptor->i_length % 8)
return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
{
free(p_decoded);
return NULL;
}
/* Allocate memory */
p_decoded = (dvbpsi_subtitling_dr_t*)malloc(sizeof(dvbpsi_subtitling_dr_t));
if (!p_decoded)
return NULL;
if(p_descriptor->i_length % 8)
{
free(p_decoded);
return NULL;
}
i_subtitles_number = p_descriptor->i_length / 8;
i_subtitles_number = p_descriptor->i_length / 8;
p_decoded->i_subtitles_number = i_subtitles_number;
p_decoded->i_subtitles_number = i_subtitles_number;
for (i=0; i < i_subtitles_number; i++)
{
memcpy(p_decoded->p_subtitle[i].i_iso6392_language_code,
p_descriptor->p_data + 8 * i, 3);
for (int i = 0; i < i_subtitles_number; i++)
{
memcpy(p_decoded->p_subtitle[i].i_iso6392_language_code,
p_descriptor->p_data + 8 * i, 3);
p_decoded->p_subtitle[i].i_subtitling_type =
p_descriptor->p_data[8 * i + 3];
p_decoded->p_subtitle[i].i_subtitling_type =
p_descriptor->p_data[8 * i + 3];
p_decoded->p_subtitle[i].i_composition_page_id =
((uint16_t)(p_descriptor->p_data[8 * i + 4]) << 8)
| p_descriptor->p_data[8 * i + 5];
p_decoded->p_subtitle[i].i_composition_page_id =
((uint16_t)(p_descriptor->p_data[8 * i + 4]) << 8)
| p_descriptor->p_data[8 * i + 5];
p_decoded->p_subtitle[i].i_ancillary_page_id =
((uint16_t)(p_descriptor->p_data[8 * i + 6]) << 8)
| p_descriptor->p_data[8 * i + 7];
}
p_decoded->p_subtitle[i].i_ancillary_page_id =
((uint16_t)(p_descriptor->p_data[8 * i + 6]) << 8)
| p_descriptor->p_data[8 * i + 7];
}
p_descriptor->p_decoded = (void*)p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
return p_decoded;
}
......@@ -115,43 +105,40 @@ dvbpsi_descriptor_t * dvbpsi_GenSubtitlingDr(
dvbpsi_subtitling_dr_t * p_decoded,
bool b_duplicate)
{
int i;
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x59, p_decoded->i_subtitles_number * 8 , NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x59, p_decoded->i_subtitles_number * 8 , NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
for (i=0; i < p_decoded->i_subtitles_number; i++ )
for (int i = 0; i < p_decoded->i_subtitles_number; i++ )
{
memcpy( p_descriptor->p_data + 8 * i,
p_decoded->p_subtitle[i].i_iso6392_language_code,
3);
p_descriptor->p_data[8 * i + 3] =
p_decoded->p_subtitle[i].i_subtitling_type;
p_descriptor->p_data[8 * i + 4] =
p_decoded->p_subtitle[i].i_composition_page_id >> 8;
p_descriptor->p_data[8 * i + 5] =
p_decoded->p_subtitle[i].i_composition_page_id % 0xFF;
p_descriptor->p_data[8 * i + 6] =
p_decoded->p_subtitle[i].i_ancillary_page_id >> 8;
p_descriptor->p_data[8 * i + 7] =
p_decoded->p_subtitle[i].i_ancillary_page_id % 0xFF;
memcpy( p_descriptor->p_data + 8 * i,
p_decoded->p_subtitle[i].i_iso6392_language_code,
3);
p_descriptor->p_data[8 * i + 3] =
p_decoded->p_subtitle[i].i_subtitling_type;
p_descriptor->p_data[8 * i + 4] =
p_decoded->p_subtitle[i].i_composition_page_id >> 8;
p_descriptor->p_data[8 * i + 5] =
p_decoded->p_subtitle[i].i_composition_page_id % 0xFF;
p_descriptor->p_data[8 * i + 6] =
p_decoded->p_subtitle[i].i_ancillary_page_id >> 8;
p_descriptor->p_data[8 * i + 7] =
p_decoded->p_subtitle[i].i_ancillary_page_id % 0xFF;
}
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_subtitling_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -47,44 +47,42 @@
dvbpsi_terr_deliv_sys_dr_t * dvbpsi_DecodeTerrDelivSysDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_terr_deliv_sys_dr_t * p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x5a))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded =
(dvbpsi_terr_deliv_sys_dr_t*)malloc(sizeof(dvbpsi_terr_deliv_sys_dr_t));
if(!p_decoded) return NULL;
/* Decode data */
p_decoded->i_centre_frequency = (uint32_t)(p_descriptor->p_data[0] << 24)
| (uint32_t)(p_descriptor->p_data[1] << 16)
| (uint32_t)(p_descriptor->p_data[2] << 8)
| (uint32_t)(p_descriptor->p_data[3]);
p_decoded->i_bandwidth = (p_descriptor->p_data[4] >> 5) & 0x07;
p_decoded->i_priority = (p_descriptor->p_data[4] >> 4) & 0x01;
p_decoded->i_time_slice_indicator = (p_descriptor->p_data[4] >> 3) & 0x01;
p_decoded->i_mpe_fec_indicator = (p_descriptor->p_data[4] >> 2) & 0x01;
p_decoded->i_constellation = (p_descriptor->p_data[5] >> 6) & 0x03;
p_decoded->i_hierarchy_information = (p_descriptor->p_data[5] >> 3) & 0x07;
p_decoded->i_code_rate_hp_stream = p_descriptor->p_data[5] & 0x07;
p_decoded->i_code_rate_lp_stream = (p_descriptor->p_data[6] >> 5) & 0x07;
p_decoded->i_guard_interval = (p_descriptor->p_data[6] >> 3) & 0x03;
p_decoded->i_transmission_mode = (p_descriptor->p_data[6] >> 1) & 0x03;
p_decoded->i_other_frequency_flag = p_descriptor->p_data[6] & 0x01;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x5a))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
dvbpsi_terr_deliv_sys_dr_t * p_decoded;
p_decoded = (dvbpsi_terr_deliv_sys_dr_t*)malloc(sizeof(dvbpsi_terr_deliv_sys_dr_t));
if (!p_decoded)
return NULL;
/* Decode data */
p_decoded->i_centre_frequency = (uint32_t)(p_descriptor->p_data[0] << 24)
| (uint32_t)(p_descriptor->p_data[1] << 16)
| (uint32_t)(p_descriptor->p_data[2] << 8)
| (uint32_t)(p_descriptor->p_data[3]);
p_decoded->i_bandwidth = (p_descriptor->p_data[4] >> 5) & 0x07;
p_decoded->i_priority = (p_descriptor->p_data[4] >> 4) & 0x01;
p_decoded->i_time_slice_indicator = (p_descriptor->p_data[4] >> 3) & 0x01;
p_decoded->i_mpe_fec_indicator = (p_descriptor->p_data[4] >> 2) & 0x01;
p_decoded->i_constellation = (p_descriptor->p_data[5] >> 6) & 0x03;
p_decoded->i_hierarchy_information = (p_descriptor->p_data[5] >> 3) & 0x07;
p_decoded->i_code_rate_hp_stream = p_descriptor->p_data[5] & 0x07;
p_decoded->i_code_rate_lp_stream = (p_descriptor->p_data[6] >> 5) & 0x07;
p_decoded->i_guard_interval = (p_descriptor->p_data[6] >> 3) & 0x03;
p_decoded->i_transmission_mode = (p_descriptor->p_data[6] >> 1) & 0x03;
p_decoded->i_other_frequency_flag = p_descriptor->p_data[6] & 0x01;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenTerrDelivSysDr
*****************************************************************************/
......@@ -92,12 +90,11 @@ dvbpsi_descriptor_t * dvbpsi_GenTerrDelivSysDr(
dvbpsi_terr_deliv_sys_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x5a, 11, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x5a, 11, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = (p_decoded->i_centre_frequency >> 24) & 0xff;
p_descriptor->p_data[1] = (p_decoded->i_centre_frequency >> 16) & 0xff;
......@@ -120,14 +117,13 @@ dvbpsi_descriptor_t * dvbpsi_GenTerrDelivSysDr(
p_descriptor->p_data[9] = 0xff;
p_descriptor->p_data[10] = 0xff;
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_terr_deliv_sys_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -46,34 +46,35 @@
*****************************************************************************/
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 */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x69))
return NULL;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x69))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Check the length */
if( p_descriptor->i_length != 3)
return NULL;
/* Check the length */
if (p_descriptor->i_length != 3)
return NULL;
/* Allocate memory */
p_decoded = (dvbpsi_PDC_dr_t*)malloc(sizeof(dvbpsi_PDC_dr_t));
if(!p_decoded) return NULL;
/* Allocate memory */
p_decoded = (dvbpsi_PDC_dr_t*)malloc(sizeof(dvbpsi_PDC_dr_t));
if (!p_decoded)
return NULL;
p_decoded->i_PDC[0] = ((p_descriptor->p_data[0] & 0x0f) << 1) |
(p_descriptor->p_data[1] >> 7);
p_decoded->i_PDC[1] = ((p_descriptor->p_data[1] >> 3) & 0x0f);
p_decoded->i_PDC[2] = ((p_descriptor->p_data[1] << 2) & 0x1c) |
(p_descriptor->p_data[2] >> 6);
p_decoded->i_PDC[3] = p_descriptor->p_data[2] & 0x3f;
p_decoded->i_PDC[0] = ((p_descriptor->p_data[0] & 0x0f) << 1) |
(p_descriptor->p_data[1] >> 7);
p_decoded->i_PDC[1] = ((p_descriptor->p_data[1] >> 3) & 0x0f);
p_decoded->i_PDC[2] = ((p_descriptor->p_data[1] << 2) & 0x1c) |
(p_descriptor->p_data[2] >> 6);
p_decoded->i_PDC[3] = p_descriptor->p_data[2] & 0x3f;
p_descriptor->p_decoded = (void*)p_decoded;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
return p_decoded;
}
......@@ -83,28 +84,27 @@ dvbpsi_PDC_dr_t * dvbpsi_DecodePDCDr(dvbpsi_descriptor_t * p_descriptor)
dvbpsi_descriptor_t * dvbpsi_GenPDCDr(dvbpsi_PDC_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x69, 3, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x69, 3, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = 0xf0 | (p_decoded->i_PDC[0] >> 1);
p_descriptor->p_data[1] = (p_decoded->i_PDC[0] << 7) |
(p_decoded->i_PDC[1] << 3) | (p_decoded->i_PDC[2] >> 2);
(p_decoded->i_PDC[1] << 3) |
(p_decoded->i_PDC[2] >> 2);
p_descriptor->p_data[2] = (p_decoded->i_PDC[2] << 6 ) |
p_decoded->i_PDC[3];
p_decoded->i_PDC[3];
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_PDC_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
......@@ -45,42 +45,38 @@
*****************************************************************************/
dvbpsi_cuei_dr_t * dvbpsi_DecodeCUEIDr(dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_cuei_dr_t *p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x8a))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = (dvbpsi_cuei_dr_t*)malloc(sizeof(dvbpsi_cuei_dr_t));
if (!p_decoded) return NULL;
/* Decode data and check the length */
if (p_descriptor->i_length == 0x01)
{
free(p_decoded);
return NULL;
}
/* cue_stream_type according to: SCTE 35 2004 - p15 - table 6.3
* cue_stream_type PID usage
* 0x00 splice_insert, splice_null, splice_schedule
* 0x01 All Commands
* 0x02 Segmentation
* 0x03 Tiered Splicing
* 0x04 Tiered Segmentation
* 0x05 - 0x7f Reserved
* 0x80 - 0xff User Defined
*/
p_decoded->i_cue_stream_type = p_descriptor->p_data[0];
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
/* Check the tag */
if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x8a))
return NULL;
/* Don't decode twice */
if (dvbpsi_IsDescriptorDecoded(p_descriptor))
return p_descriptor->p_decoded;
if (p_descriptor->i_length == 0x01)
return NULL;
/* Allocate memory */
dvbpsi_cuei_dr_t *p_decoded;
p_decoded = (dvbpsi_cuei_dr_t*)malloc(sizeof(dvbpsi_cuei_dr_t));
if (!p_decoded)
return NULL;
/* cue_stream_type according to: SCTE 35 2004 - p15 - table 6.3
* cue_stream_type PID usage
* 0x00 splice_insert, splice_null, splice_schedule
* 0x01 All Commands
* 0x02 Segmentation
* 0x03 Tiered Splicing
* 0x04 Tiered Segmentation
* 0x05 - 0x7f Reserved
* 0x80 - 0xff User Defined
*/
p_decoded->i_cue_stream_type = p_descriptor->p_data[0];
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
/*****************************************************************************
......@@ -88,24 +84,22 @@ dvbpsi_cuei_dr_t * dvbpsi_DecodeCUEIDr(dvbpsi_descriptor_t * p_descriptor)
*****************************************************************************/
dvbpsi_descriptor_t * dvbpsi_GenCUEIDr(dvbpsi_cuei_dr_t * p_decoded, bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x8a, 0x01, NULL);
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x8a, 0x01, NULL);
if (!p_descriptor)
return NULL;
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = p_decoded->i_cue_stream_type;
if(b_duplicate)
if (b_duplicate)
{
/* Duplicate decoded data */
/* Duplicate decoded data */
p_descriptor->p_decoded =
dvbpsi_DuplicateDecodedDescriptor(p_descriptor->p_decoded,
sizeof(dvbpsi_cuei_dr_t));
}
}
return p_descriptor;
return p_descriptor;
}
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