[vlc-devel] [PATCH] input: Fill in the input_item es

Rafaël Carré rafael.carre at gmail.com
Wed Oct 20 16:46:16 CEST 2010


Based on pdherbemont's patch
Re-use existing es_format_t, do not worry about memory footprint
It is meant to replace sout_stream_description
---
 src/input/es_out.c |    4 ++++
 src/input/item.c   |   31 +++++++++++++++++++++++++++++++
 src/input/item.h   |    1 +
 3 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/input/es_out.c b/src/input/es_out.c
index 635b2e9..9908c70 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -45,6 +45,7 @@
 #include "es_out.h"
 #include "event.h"
 #include "info.h"
+#include "item.h"
 
 #include "../stream_output/stream_output.h"
 
@@ -2855,6 +2856,9 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
     const es_format_t *p_fmt_es = &es->fmt;
     lldiv_t         div;
 
+    /* Update the item tracks_info field */
+    input_item_UpdateTracksInfo(input_GetItem(p_input), fmt);
+
     /* Create category */
     char psz_cat[128];
     snprintf( psz_cat, sizeof(psz_cat),_("Stream %d"), es->i_meta_id );
diff --git a/src/input/item.c b/src/input/item.c
index df4e159..dcd8319 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -1047,3 +1047,34 @@ void input_item_node_PostAndDelete( input_item_node_t *p_root )
 
   input_item_node_Delete( p_root );
 }
+
+/* Called by es_out when a new Elementary Stream is added or updated. */
+void input_item_UpdateTracksInfo(input_item_t *item, const es_format_t *fmt)
+{
+    int i;
+    es_format_t *fmt_copy = malloc(sizeof *fmt_copy);
+    if (!fmt_copy)
+        return;
+
+    es_format_Copy(fmt_copy, fmt);
+    /* XXX: free p_extra ? */
+
+    vlc_mutex_lock( &item->lock );
+
+    for( i = 0; i < item->i_es; i++ )
+    {
+        if (item->es[i]->i_id != fmt->i_id)
+            continue;
+
+        /* We've found the right ES, replace it */
+        es_format_Clean(item->es[i]);
+        free(item->es[i]);
+        item->es[i] = fmt_copy;
+        vlc_mutex_unlock( &item->lock );
+        return;
+    }
+
+    /* ES not found, insert it */
+    TAB_APPEND(item->i_es, item->es, fmt_copy);
+    vlc_mutex_unlock( &item->lock );
+}
diff --git a/src/input/item.h b/src/input/item.h
index 971620a..ecf78cf 100644
--- a/src/input/item.h
+++ b/src/input/item.h
@@ -31,5 +31,6 @@
 #include "input_interface.h"
 
 void input_item_SetErrorWhenReading( input_item_t *p_i, bool b_error );
+void input_item_UpdateTracksInfo( input_item_t *item, const es_format_t *fmt );
 
 #endif
-- 
1.7.3.1





More information about the vlc-devel mailing list