[vlc-commits] vlc_epg: store description items

Francois Cartegnie git at videolan.org
Tue Jul 4 20:25:59 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jul  3 10:29:50 2017 +0200| [78a23f2daaa2ca9dd54eef7840ce866ee495dad5] | committer: Francois Cartegnie

vlc_epg: store description items

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=78a23f2daaa2ca9dd54eef7840ce866ee495dad5
---

 include/vlc_epg.h |  6 ++++++
 src/misc/epg.c    | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/include/vlc_epg.h b/include/vlc_epg.h
index 7b39edc418..e95d111ad5 100644
--- a/include/vlc_epg.h
+++ b/include/vlc_epg.h
@@ -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;
diff --git a/src/misc/epg.c b/src/misc/epg.c
index d06d3448b4..dbb6501a2c 100644
--- a/src/misc/epg.c
+++ b/src/misc/epg.c
@@ -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;



More information about the vlc-commits mailing list