Commit 9da92fa4 authored by Jean-Paul Saman's avatar Jean-Paul Saman

dr_a1.*: apply coding style fixes

Fix weird indentation introduced by commit: 9afd8b97103181a8d68699d368cac9ad27ad6c5c

The preferred coding style is:
- 4 spaces indentation (no tabs)
- indent '{' and '}' on the same column as the 'if', eg:
  if (...)
  {
  }
- function declarations always start in the first column
parent 70b55cdd
......@@ -47,50 +47,48 @@ Service Location Descriptor.
dvbpsi_service_location_dr_t *
dvbpsi_DecodeServiceLocationDr (dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_service_location_dr_t *p_decoded;
uint8_t *buf = p_descriptor->p_data;
dvbpsi_service_location_dr_t *p_decoded;
uint8_t *buf = p_descriptor->p_data;
/* Check the tag */
if (p_descriptor->i_tag != 0xa1)
return NULL;
/* Check the tag */
if (p_descriptor->i_tag != 0xa1)
return NULL;
/* Don't decode twice */
if (p_descriptor->p_decoded)
return p_descriptor->p_decoded;
/* Don't decode twice */
if (p_descriptor->p_decoded)
return p_descriptor->p_decoded;
/* Check length */
if ((p_descriptor->i_length - 3) % 6)
return NULL;
/* Check length */
if ((p_descriptor->i_length - 3) % 6)
return NULL;
/* Allocate memory */
p_decoded =
(dvbpsi_service_location_dr_t *)
malloc (sizeof (dvbpsi_service_location_dr_t));
if (!p_decoded)
return NULL;
/* Allocate memory */
p_decoded = (dvbpsi_service_location_dr_t *)
malloc (sizeof (dvbpsi_service_location_dr_t));
if (!p_decoded)
return NULL;
memset (p_decoded, 0, sizeof (dvbpsi_service_location_dr_t));
memset (p_decoded, 0, sizeof (dvbpsi_service_location_dr_t));
p_descriptor->p_decoded = (void *) p_decoded;
p_descriptor->p_decoded = (void *) p_decoded;
p_decoded->i_pcr_pid = ((uint16_t) (buf[0] & 0x1f) << 8) | buf[1];
p_decoded->i_number_elements = buf[2];
p_decoded->i_pcr_pid = ((uint16_t) (buf[0] & 0x1f) << 8) | buf[1];
p_decoded->i_number_elements = buf[2];
buf += 3;
buf += 3;
for (int i = 0; i < p_decoded->i_number_elements; i++)
for (int i = 0; i < p_decoded->i_number_elements; i++)
{
dvbpsi_service_location_element_t *p_element = &p_decoded->elements[i];
dvbpsi_service_location_element_t *p_element = &p_decoded->elements[i];
p_element->i_stream_type = buf[0];
p_element->i_elementary_pid = ((uint16_t) (buf[1] & 0x1f) << 8) | buf[2];
memcpy (p_element->i_iso_639_code, &buf[3], 3);
p_element->i_stream_type = buf[0];
p_element->i_elementary_pid = ((uint16_t) (buf[1] & 0x1f) << 8) | buf[2];
memcpy (p_element->i_iso_639_code, &buf[3], 3);
buf += 6;
buf += 6;
}
return p_decoded;
return p_decoded;
}
#if 0
......@@ -101,41 +99,41 @@ dvbpsi_descriptor_t *
dvbpsi_GenServiceDr (dvbpsi_service_location_dr_t * p_decoded,
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t *p_descriptor =
dvbpsi_NewDescriptor (0x48,
3 + p_decoded->i_service_location_name_length +
p_decoded->i_service_location_provider_name_length,
NULL);
if (p_descriptor)
/* Create the descriptor */
dvbpsi_descriptor_t *p_descriptor =
dvbpsi_NewDescriptor (0x48,
3 + p_decoded->i_service_location_name_length +
p_decoded->i_service_location_provider_name_length,
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);
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);
if (b_duplicate)
{
/* Duplicate decoded data */
dvbpsi_service_dr_t *p_dup_decoded =
(dvbpsi_service_dr_t *) malloc (sizeof (dvbpsi_service_dr_t));
if (p_dup_decoded)
memcpy (p_dup_decoded, p_decoded, sizeof (dvbpsi_service_dr_t));
p_descriptor->p_decoded = (void *) p_dup_decoded;
}
/* 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);
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);
if (b_duplicate)
{
/* Duplicate decoded data */
dvbpsi_service_dr_t *p_dup_decoded =
(dvbpsi_service_dr_t *) malloc (sizeof (dvbpsi_service_dr_t));
if (p_dup_decoded)
memcpy (p_dup_decoded, p_decoded, sizeof (dvbpsi_service_dr_t));
p_descriptor->p_decoded = (void *) p_dup_decoded;
}
}
return p_descriptor;
return p_descriptor;
}
#endif
......@@ -36,12 +36,12 @@ extern "C"
#endif
typedef struct dvbpsi_service_location_element_s
{
typedef struct dvbpsi_service_location_element_s
{
uint8_t i_stream_type;
uint16_t i_elementary_pid;
char i_iso_639_code[3];
} dvbpsi_service_location_element_t;
} dvbpsi_service_location_element_t;
/*****************************************************************************
* dvbpsi_service_location_dr_s
......@@ -57,14 +57,14 @@ extern "C"
* \typedef struct dvbpsi_service_location_dr_s dvbpsi_service_location_dr_t
* \brief dvbpsi_service_dr_t type definition.
*/
typedef struct dvbpsi_service_location_dr_s
{
typedef struct dvbpsi_service_location_dr_s
{
uint16_t i_pcr_pid; /*!< PCR_PID */
uint8_t i_number_elements; /*!< number of elements used for this service */
dvbpsi_service_location_element_t elements[0xff];
} dvbpsi_service_location_dr_t;
} dvbpsi_service_location_dr_t;
/*****************************************************************************
......@@ -78,7 +78,7 @@ extern "C"
* \return a pointer to a new "service" descriptor structure
* which contains the decoded data.
*/
dvbpsi_service_location_dr_t
dvbpsi_service_location_dr_t
*dvbpsi_DecodeServiceLocationDr (dvbpsi_descriptor_t * p_descriptor);
#if 0
......@@ -95,7 +95,7 @@ extern "C"
* the descriptor
* \return a pointer to a new descriptor structure which contains encoded data.
*/
dvbpsi_descriptor_t *dvbpsi_GenServiceLocationDr (dvbpsi_service_dr_t *
dvbpsi_descriptor_t *dvbpsi_GenServiceLocationDr (dvbpsi_service_dr_t *
p_decoded,
bool b_duplicate);
#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