mirror of https://code.videolan.org/videolan/vlc
vlc_epg: store description items
This commit is contained in:
parent
c5f0aec32a
commit
78a23f2daa
|
@ -38,6 +38,12 @@ typedef struct
|
|||
char *psz_name;
|
||||
char *psz_short_description;
|
||||
char *psz_description;
|
||||
struct /* Description items in tranmission order */
|
||||
{
|
||||
char *psz_key;
|
||||
char *psz_value;
|
||||
} * description_items;
|
||||
int i_description_items;
|
||||
|
||||
uint8_t i_rating; /* Parental control, set to 0 when undefined */
|
||||
} vlc_epg_event_t;
|
||||
|
|
|
@ -32,8 +32,20 @@
|
|||
#include <vlc_common.h>
|
||||
#include <vlc_epg.h>
|
||||
|
||||
static void dictionnary_free_value(void *val, void *obj)
|
||||
{
|
||||
VLC_UNUSED(obj);
|
||||
free((char *)val);
|
||||
}
|
||||
|
||||
static void vlc_epg_event_Clean(vlc_epg_event_t *p_event)
|
||||
{
|
||||
for(int i=0; i<p_event->i_description_items; i++)
|
||||
{
|
||||
free(p_event->description_items[i].psz_key);
|
||||
free(p_event->description_items[i].psz_value);
|
||||
}
|
||||
free(p_event->description_items);
|
||||
free(p_event->psz_description);
|
||||
free(p_event->psz_short_description);
|
||||
free(p_event->psz_name);
|
||||
|
@ -52,6 +64,8 @@ static void vlc_epg_event_Init(vlc_epg_event_t *p_event, uint16_t i_id,
|
|||
p_event->i_start = i_start;
|
||||
p_event->i_id = i_id;
|
||||
p_event->i_duration = i_duration;
|
||||
p_event->i_description_items = 0;
|
||||
p_event->description_items = NULL;
|
||||
}
|
||||
|
||||
vlc_epg_event_t * vlc_epg_event_New(uint16_t i_id,
|
||||
|
@ -76,6 +90,29 @@ vlc_epg_event_t * vlc_epg_event_Duplicate( const vlc_epg_event_t *p_src )
|
|||
p_evt->psz_name = strdup( p_src->psz_name );
|
||||
if( p_src->psz_short_description )
|
||||
p_evt->psz_short_description = strdup( p_src->psz_short_description );
|
||||
if( p_src->i_description_items )
|
||||
{
|
||||
p_evt->description_items = malloc( sizeof(*p_evt->description_items) *
|
||||
p_src->i_description_items );
|
||||
if( p_evt->description_items )
|
||||
{
|
||||
for( int i=0; i<p_src->i_description_items; i++ )
|
||||
{
|
||||
p_evt->description_items[i].psz_key =
|
||||
strdup( p_src->description_items[i].psz_key );
|
||||
p_evt->description_items[i].psz_value =
|
||||
strdup( p_src->description_items[i].psz_value );
|
||||
if(!p_evt->description_items[i].psz_value ||
|
||||
!p_evt->description_items[i].psz_key)
|
||||
{
|
||||
free(p_evt->description_items[i].psz_key);
|
||||
free(p_evt->description_items[i].psz_value);
|
||||
break;
|
||||
}
|
||||
p_evt->i_description_items++;
|
||||
}
|
||||
}
|
||||
}
|
||||
p_evt->i_rating = p_src->i_rating;
|
||||
}
|
||||
return p_evt;
|
||||
|
|
Loading…
Reference in New Issue