Commit fd2f88c8 authored by Michael Krufky's avatar Michael Krufky Committed by Jean-Paul Saman

dr_a1: whitespace cleanup using 'indent'

Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
parent c09ed74b
...@@ -44,56 +44,62 @@ Service Location Descriptor. ...@@ -44,56 +44,62 @@ Service Location Descriptor.
/***************************************************************************** /*****************************************************************************
* dvbpsi_DecodeServiceLocationDr * dvbpsi_DecodeServiceLocationDr
*****************************************************************************/ *****************************************************************************/
dvbpsi_service_location_dr_t * dvbpsi_DecodeServiceLocationDr( dvbpsi_service_location_dr_t *
dvbpsi_descriptor_t * p_descriptor) dvbpsi_DecodeServiceLocationDr (dvbpsi_descriptor_t * p_descriptor)
{ {
dvbpsi_service_location_dr_t * p_decoded; dvbpsi_service_location_dr_t *p_decoded;
uint8_t * buf = p_descriptor->p_data; uint8_t *buf = p_descriptor->p_data;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0xa1) if (p_descriptor->i_tag != 0xa1)
return NULL; return NULL;
/* Don't decode twice */ /* Don't decode twice */
if(p_descriptor->p_decoded) if (p_descriptor->p_decoded)
return p_descriptor->p_decoded; return p_descriptor->p_decoded;
/* Check length */ /* Check length */
if((p_descriptor->i_length - 3) % 6) if ((p_descriptor->i_length - 3) % 6)
return NULL; return NULL;
/* Allocate memory */ /* Allocate memory */
p_decoded = p_decoded =
(dvbpsi_service_location_dr_t*)malloc(sizeof(dvbpsi_service_location_dr_t)); (dvbpsi_service_location_dr_t *)
if(!p_decoded) return NULL; 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_pcr_pid = ((uint16_t) (buf[0] & 0x1f) << 8) | buf[1];
p_decoded->i_number_elements = buf[2]; 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 = dvbpsi_service_location_element_t *p_element =
(dvbpsi_service_location_element_t*)malloc(sizeof(dvbpsi_service_location_element_t)); (dvbpsi_service_location_element_t *)
malloc (sizeof (dvbpsi_service_location_element_t));
if(!p_element) return NULL; if (!p_element)
return NULL;
memset(p_element, 0, sizeof(dvbpsi_service_location_element_t)); memset (p_element, 0, sizeof (dvbpsi_service_location_element_t));
p_element->i_stream_type = buf[0]; p_element->i_stream_type = buf[0];
p_element->i_elementary_pid = ((uint16_t)(buf[1] & 0x1f) << 8) | buf[2]; p_element->i_elementary_pid =
memcpy(p_element->i_iso_639_code, &buf[3], 3); ((uint16_t) (buf[1] & 0x1f) << 8) | buf[2];
memcpy (p_element->i_iso_639_code, &buf[3], 3);
if (p_decoded->p_first_element == NULL) if (p_decoded->p_first_element == NULL)
p_decoded->p_first_element = p_element; p_decoded->p_first_element = p_element;
else else
{ {
dvbpsi_service_location_element_t* p_last_element = p_decoded->p_first_element; dvbpsi_service_location_element_t *p_last_element =
p_decoded->p_first_element;
while (p_last_element->p_next != NULL) while (p_last_element->p_next != NULL)
p_last_element = p_last_element->p_next; p_last_element = p_last_element->p_next;
p_last_element->p_next = p_element; p_last_element->p_next = p_element;
...@@ -109,19 +115,20 @@ dvbpsi_service_location_dr_t * dvbpsi_DecodeServiceLocationDr( ...@@ -109,19 +115,20 @@ dvbpsi_service_location_dr_t * dvbpsi_DecodeServiceLocationDr(
/***************************************************************************** /*****************************************************************************
* dvbpsi_FreeServiceLocationDr * dvbpsi_FreeServiceLocationDr
*****************************************************************************/ *****************************************************************************/
void dvbpsi_FreeServiceLocationDr(dvbpsi_service_location_dr_t * descriptor) void
dvbpsi_FreeServiceLocationDr (dvbpsi_service_location_dr_t * descriptor)
{ {
dvbpsi_service_location_element_t* p_element = NULL; dvbpsi_service_location_element_t *p_element = NULL;
if (descriptor == NULL) if (descriptor == NULL)
return; return;
p_element = descriptor->p_first_element; p_element = descriptor->p_first_element;
while(p_element) while (p_element)
{ {
dvbpsi_service_location_element_t* p_next = p_element->p_next; dvbpsi_service_location_element_t *p_next = p_element->p_next;
free(p_element); free (p_element);
p_element = p_next; p_element = p_next;
} }
} }
...@@ -130,40 +137,42 @@ void dvbpsi_FreeServiceLocationDr(dvbpsi_service_location_dr_t * descriptor) ...@@ -130,40 +137,42 @@ void dvbpsi_FreeServiceLocationDr(dvbpsi_service_location_dr_t * descriptor)
/***************************************************************************** /*****************************************************************************
* dvbpsi_GenServiceDr * dvbpsi_GenServiceDr
*****************************************************************************/ *****************************************************************************/
dvbpsi_descriptor_t * dvbpsi_GenServiceDr( dvbpsi_descriptor_t *
dvbpsi_service_location_dr_t * p_decoded, dvbpsi_GenServiceDr (dvbpsi_service_location_dr_t * p_decoded,
bool b_duplicate) bool b_duplicate)
{ {
/* Create the descriptor */ /* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_descriptor_t *p_descriptor =
dvbpsi_NewDescriptor(0x48, 3 + p_decoded->i_service_location_name_length + dvbpsi_NewDescriptor (0x48,
p_decoded->i_service_location_provider_name_length , NULL); 3 + p_decoded->i_service_location_name_length +
p_decoded->i_service_location_provider_name_length,
NULL);
if(p_descriptor) if (p_descriptor)
{ {
/* Encode data */ /* Encode data */
p_descriptor->p_data[0] = p_decoded->i_service_type; p_descriptor->p_data[0] = p_decoded->i_service_type;
p_descriptor->p_data[1] = p_decoded->i_service_provider_name_length; p_descriptor->p_data[1] = p_decoded->i_service_provider_name_length;
if(p_decoded->i_service_provider_name_length) if (p_decoded->i_service_provider_name_length)
memcpy(p_descriptor->p_data + 2, memcpy (p_descriptor->p_data + 2,
p_decoded->i_service_provider_name, p_decoded->i_service_provider_name,
p_decoded->i_service_provider_name_length); p_decoded->i_service_provider_name_length);
p_descriptor->p_data[2+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; p_decoded->i_service_name_length;
if(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, memcpy (p_descriptor->p_data + 3 +
p_decoded->i_service_name, p_decoded->i_service_provider_name_length,
p_decoded->i_service_name_length); p_decoded->i_service_name, p_decoded->i_service_name_length);
if(b_duplicate) if (b_duplicate)
{ {
/* Duplicate decoded data */ /* Duplicate decoded data */
dvbpsi_service_dr_t * p_dup_decoded = dvbpsi_service_dr_t *p_dup_decoded =
(dvbpsi_service_dr_t*)malloc(sizeof(dvbpsi_service_dr_t)); (dvbpsi_service_dr_t *) malloc (sizeof (dvbpsi_service_dr_t));
if(p_dup_decoded) if (p_dup_decoded)
memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_service_dr_t)); memcpy (p_dup_decoded, p_decoded, sizeof (dvbpsi_service_dr_t));
p_descriptor->p_decoded = (void*)p_dup_decoded; p_descriptor->p_decoded = (void *) p_dup_decoded;
} }
} }
......
...@@ -25,19 +25,20 @@ Service Location Descriptor. ...@@ -25,19 +25,20 @@ Service Location Descriptor.
#define _DVBPSI_DR_A1_H_ #define _DVBPSI_DR_A1_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C"
{
#endif #endif
typedef struct dvbpsi_service_location_element_s typedef struct dvbpsi_service_location_element_s
{ {
uint8_t i_stream_type; uint8_t i_stream_type;
uint16_t i_elementary_pid; uint16_t i_elementary_pid;
char i_iso_639_code[3]; char i_iso_639_code[3];
struct dvbpsi_service_location_element_s * p_next; struct dvbpsi_service_location_element_s *p_next;
} dvbpsi_service_location_element_t; } dvbpsi_service_location_element_t;
/***************************************************************************** /*****************************************************************************
* dvbpsi_service_location_dr_s * dvbpsi_service_location_dr_s
...@@ -53,14 +54,14 @@ typedef struct dvbpsi_service_location_element_s ...@@ -53,14 +54,14 @@ typedef struct dvbpsi_service_location_element_s
* \typedef struct dvbpsi_service_location_dr_s dvbpsi_service_location_dr_t * \typedef struct dvbpsi_service_location_dr_s dvbpsi_service_location_dr_t
* \brief dvbpsi_service_dr_t type definition. * \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 */ uint16_t i_pcr_pid; /*!< PCR_PID */
uint8_t i_number_elements; /*!< number of elements used for this service */ uint8_t i_number_elements; /*!< number of elements used for this service */
dvbpsi_service_location_element_t * p_first_element; dvbpsi_service_location_element_t *p_first_element;
} dvbpsi_service_location_dr_t; } dvbpsi_service_location_dr_t;
/***************************************************************************** /*****************************************************************************
...@@ -74,8 +75,8 @@ typedef struct dvbpsi_service_location_dr_s ...@@ -74,8 +75,8 @@ typedef struct dvbpsi_service_location_dr_s
* \return a pointer to a new "service" descriptor structure * \return a pointer to a new "service" descriptor structure
* which contains the decoded data. * which contains the decoded data.
*/ */
dvbpsi_service_location_dr_t* dvbpsi_DecodeServiceLocationDr( dvbpsi_service_location_dr_t
dvbpsi_descriptor_t * p_descriptor); *dvbpsi_DecodeServiceLocationDr (dvbpsi_descriptor_t * p_descriptor);
/***************************************************************************** /*****************************************************************************
...@@ -87,7 +88,8 @@ dvbpsi_service_location_dr_t* dvbpsi_DecodeServiceLocationDr( ...@@ -87,7 +88,8 @@ dvbpsi_service_location_dr_t* dvbpsi_DecodeServiceLocationDr(
* \brief frees service location descriptor * \brief frees service location descriptor
* \param p_descriptor pointer to the descriptor structure * \param p_descriptor pointer to the descriptor structure
*/ */
void dvbpsi_FreeServiceLocationDr(dvbpsi_service_location_dr_t * p_descriptor); void dvbpsi_FreeServiceLocationDr (dvbpsi_service_location_dr_t *
p_descriptor);
#if 0 #if 0
/***************************************************************************** /*****************************************************************************
* dvbpsi_GenServiceDataDr * dvbpsi_GenServiceDataDr
...@@ -102,8 +104,8 @@ void dvbpsi_FreeServiceLocationDr(dvbpsi_service_location_dr_t * p_descriptor); ...@@ -102,8 +104,8 @@ void dvbpsi_FreeServiceLocationDr(dvbpsi_service_location_dr_t * p_descriptor);
* the descriptor * the descriptor
* \return a pointer to a new descriptor structure which contains encoded data. * \return a pointer to a new descriptor structure which contains encoded data.
*/ */
dvbpsi_descriptor_t * dvbpsi_GenServiceLocationDr( dvbpsi_descriptor_t *dvbpsi_GenServiceLocationDr (dvbpsi_service_dr_t *
dvbpsi_service_dr_t * p_decoded, p_decoded,
bool b_duplicate); bool b_duplicate);
#endif #endif
...@@ -115,4 +117,3 @@ dvbpsi_descriptor_t * dvbpsi_GenServiceLocationDr( ...@@ -115,4 +117,3 @@ dvbpsi_descriptor_t * dvbpsi_GenServiceLocationDr(
#else #else
#error "Multiple inclusions of dr_a1.h" #error "Multiple inclusions of dr_a1.h"
#endif #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