[vlc-devel] [PATCH] Fix libvlc_media_get_tracks_info()
Rafaël Carré
rafael.carre at gmail.com
Thu Dec 2 22:00:12 CET 2010
Thanks to nefrir for help
---
src/input/es_out.c | 3 ++-
src/input/item.c | 22 +++++++++++++++++++---
src/input/item.h | 3 ++-
3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 788f338..ed1548c 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -2856,7 +2856,8 @@ 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;
- input_item_UpdateTracksInfo(input_GetItem(p_input), fmt);
+ input_item_UpdateTracksInfo(input_GetItem(p_input), fmt, p_fmt_es,
+ es->i_meta_id);
/* Create category */
char psz_cat[128];
diff --git a/src/input/item.c b/src/input/item.c
index e47a1e1..2d99cd2 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -1052,10 +1052,17 @@ void input_item_node_PostAndDelete( input_item_node_t *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)
+void input_item_UpdateTracksInfo(input_item_t *item, const es_format_t *fmt,
+ const es_format_t *orig_fmt, int meta_id)
{
int i;
- es_format_t *fmt_copy = malloc(sizeof *fmt_copy);
+ es_format_t *fmt_copy;
+
+ /* We don't want the decoder output format, only input */
+ if( fmt->i_cat == orig_fmt->i_cat && fmt->i_codec != orig_fmt->i_codec )
+ return;
+
+ fmt_copy = malloc(sizeof *fmt_copy);
if (!fmt_copy)
return;
@@ -1063,11 +1070,20 @@ void input_item_UpdateTracksInfo(input_item_t *item, const es_format_t *fmt)
/* XXX: we could free p_extra to save memory, we will likely not need
* the decoder specific data */
+ fmt_copy->i_id = meta_id;
+ /* a decoder can change a type into another one,
+ * the only case probably being subtitle->video with CDG tracks */
+ if( orig_fmt->i_cat != fmt_copy->i_cat )
+ {
+ fmt_copy->i_codec = orig_fmt->i_codec;
+ fmt_copy->i_original_fourcc = orig_fmt->i_original_fourcc;
+ }
+
vlc_mutex_lock( &item->lock );
for( i = 0; i < item->i_es; i++ )
{
- if (item->es[i]->i_id != fmt->i_id)
+ if (item->es[i]->i_id != meta_id)
continue;
/* We've found the right ES, replace it */
diff --git a/src/input/item.h b/src/input/item.h
index 9b02136..e35b420 100644
--- a/src/input/item.h
+++ b/src/input/item.h
@@ -27,6 +27,7 @@
#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 );
+void input_item_UpdateTracksInfo( input_item_t *item, const es_format_t *fmt,
+ const es_format_t *orig_fmt, int meta_id );
#endif
--
1.7.3.2
More information about the vlc-devel
mailing list