Commit 9e4ce232 authored by Jean-Paul Saman's avatar Jean-Paul Saman

dbus.c: Rewrite GetEsMetadata() to use current playing item instead of current input.

By using playlist item the metadata information can also be queried when the item is not playing. When using current input this can only be done when the input is instatiated (aka: playing).
parent 1cd99d07
...@@ -1219,16 +1219,11 @@ DBUS_METHOD( GetEsMetadata ) ...@@ -1219,16 +1219,11 @@ DBUS_METHOD( GetEsMetadata )
} }
playlist_t *p_playlist = pl_Hold( (vlc_object_t*) p_this ); playlist_t *p_playlist = pl_Hold( (vlc_object_t*) p_this );
input_thread_t *p_input = playlist_CurrentInput( p_playlist ); PL_LOCK;
if( p_input ) playlist_item_t* p_item = playlist_CurrentPlayingItem( p_playlist );
{
input_item_t *p_item = input_GetItem( p_input );
if( p_item ) if( p_item )
{ GetInputEsMeta( p_item->p_input, i_es, &args );
GetInputEsMeta( p_item, i_es, &args ); PL_UNLOCK;
}
vlc_object_release( p_input );
}
pl_Release( (vlc_object_t*) p_this ); pl_Release( (vlc_object_t*) p_this );
REPLY_SEND; REPLY_SEND;
...@@ -2242,26 +2237,20 @@ static int GetInputEsMeta( input_item_t * p_item, int32_t i_es, ...@@ -2242,26 +2237,20 @@ static int GetInputEsMeta( input_item_t * p_item, int32_t i_es,
dbus_message_iter_open_container( args, DBUS_TYPE_ARRAY, "{sv}", &dict ); dbus_message_iter_open_container( args, DBUS_TYPE_ARRAY, "{sv}", &dict );
for( int i = 0; i < p_item->i_categories ; i++) if( i_es < p_item->i_categories )
{
const char *psz_cat = p_item->pp_categories[i]->psz_name;
char *psz_stream = NULL;
if( asprintf( &psz_stream, "Stream %d", i_es ) &&
( strncmp( psz_cat, psz_stream, strlen( psz_stream ) ) == 0 ) )
{ {
for( int j = 0 ; j < p_item->pp_categories[i]->i_infos ; j++ ) for( int j = 0 ; j < p_item->pp_categories[i_es]->i_infos ; j++ )
{ {
const char *psz_name = p_item->pp_categories[i]->pp_infos[j]->psz_name; const char *psz_name = p_item->pp_categories[i_es]->pp_infos[j]->psz_name;
const char *psz_value = p_item->pp_categories[i]->pp_infos[j]->psz_value; const char *psz_value = p_item->pp_categories[i_es]->pp_infos[j]->psz_value;
char *psz_variant = NULL; char *psz_variant = NULL;
dbus_message_iter_open_container( &dict, DBUS_TYPE_DICT_ENTRY, dbus_message_iter_open_container( &dict, DBUS_TYPE_DICT_ENTRY,
NULL, &dict_entry ); NULL, &dict_entry );
dbus_message_iter_append_basic( &dict_entry, DBUS_TYPE_STRING, dbus_message_iter_append_basic( &dict_entry, DBUS_TYPE_STRING,
&psz_cat ); &psz_name );
if( asprintf( &psz_variant, "%s : %s", psz_name, psz_value ) != -1 ) if( asprintf( &psz_variant, "%s", psz_value ) != -1 )
{ {
dbus_message_iter_open_container( &dict_entry, DBUS_TYPE_VARIANT, dbus_message_iter_open_container( &dict_entry, DBUS_TYPE_VARIANT,
DBUS_TYPE_STRING_AS_STRING, &variant ); DBUS_TYPE_STRING_AS_STRING, &variant );
...@@ -2274,8 +2263,6 @@ static int GetInputEsMeta( input_item_t * p_item, int32_t i_es, ...@@ -2274,8 +2263,6 @@ static int GetInputEsMeta( input_item_t * p_item, int32_t i_es,
dbus_message_iter_close_container( &dict, &dict_entry ); dbus_message_iter_close_container( &dict, &dict_entry );
} }
} }
free( psz_stream );
}
dbus_message_iter_close_container( args, &dict ); dbus_message_iter_close_container( args, &dict );
return VLC_SUCCESS; return VLC_SUCCESS;
......
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