Commit dc60d88e authored by mbenoit's avatar mbenoit Committed by Jean-Paul Saman

descriptors/dr_83: Add support for generation of Logical Channel Number descriptor

Signed-off-by: default avatarJean-Paul Saman <jpsaman@videolan.org>
parent 339b5f21
......@@ -83,3 +83,34 @@ dvbpsi_lcn_dr_t *dvbpsi_DecodeLCNDr(dvbpsi_descriptor_t *p_descriptor)
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenLCNDr
*****************************************************************************/
dvbpsi_descriptor_t* dvbpsi_GenLCNDr(dvbpsi_lcn_dr_t* p_decoded,
bool b_duplicate)
{
dvbpsi_descriptor_t* p_descriptor = dvbpsi_NewDescriptor(0x83, p_decoded->i_number_of_entries * 4, 0);
if (NULL == p_descriptor) {
return NULL;
}
for (int i = 0; i < p_decoded->i_number_of_entries; i++ )
{
p_descriptor->p_data[4 * i] = p_decoded->p_entries[i].i_service_id >> 8;
p_descriptor->p_data[4 * i + 1] = p_decoded->p_entries[i].i_service_id;
p_descriptor->p_data[4 * i + 2] = (p_decoded->p_entries[i].b_visible_service_flag << 7);
p_descriptor->p_data[4 * i + 2] |= (p_decoded->p_entries[i].i_logical_channel_number >> 8);
p_descriptor->p_data[4 * i + 3] = p_decoded->p_entries[i].i_logical_channel_number;
}
if (b_duplicate)
{
dvbpsi_lcn_dr_t * p_dup = (dvbpsi_lcn_dr_t*) malloc(sizeof (dvbpsi_lcn_dr_t));
if (NULL != p_dup)
memcpy(p_dup, p_decoded, sizeof(dvbpsi_lcn_dr_t));
p_descriptor->p_decoded = (void*)p_dup;
}
return p_descriptor;
}
\ No newline at end of file
......@@ -85,9 +85,24 @@ typedef struct dvbpsi_lcn_dr_s
*/
dvbpsi_lcn_dr_t *dvbpsi_DecodeLCNDr(dvbpsi_descriptor_t *p_descriptor);
/*****************************************************************************
* dvbpsi_GenLCNDr
*****************************************************************************/
/*!
* \fn dvbpsi_descriptor_t * dvbpsi_GenLogicalChannelDr(
dvbpsi_lcn_dr_t* p_decoded, bool b_duplicate)
* \brief "logical_channel" descriptor generator.
* \param p_decoded pointer to a decoded "logical_channel" descriptor
* structure
* \param b_duplicate if true then duplicate the p_decoded structure into
* the descriptor
* \return a pointer to a new descriptor structure which contains encoded data.
*/
dvbpsi_descriptor_t* dvbpsi_GenLCNDr(dvbpsi_lcn_dr_t* p_decoded, bool b_duplicate);
#ifdef __cplusplus
};
#endif
#endif
#endif // _DR_83_H
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