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
......@@ -359,7 +359,7 @@ DBUS_METHOD( GetCurrentMetadata )
OUT_ARGUMENTS;
playlist_t* p_playlist = pl_Hold( (vlc_object_t*) p_this );
PL_LOCK;
playlist_item_t* p_item = playlist_CurrentPlayingItem( p_playlist );
playlist_item_t* p_item = playlist_CurrentPlayingItem( p_playlist );
if( p_item )
GetInputMeta( p_item->p_input, &args );
PL_UNLOCK;
......@@ -1219,16 +1219,11 @@ DBUS_METHOD( GetEsMetadata )
}
playlist_t *p_playlist = pl_Hold( (vlc_object_t*) p_this );
input_thread_t *p_input = playlist_CurrentInput( p_playlist );
if( p_input )
{
input_item_t *p_item = input_GetItem( p_input );
if( p_item )
{
GetInputEsMeta( p_item, i_es, &args );
}
vlc_object_release( p_input );
}
PL_LOCK;
playlist_item_t* p_item = playlist_CurrentPlayingItem( p_playlist );
if( p_item )
GetInputEsMeta( p_item->p_input, i_es, &args );
PL_UNLOCK;
pl_Release( (vlc_object_t*) p_this );
REPLY_SEND;
......@@ -2242,39 +2237,31 @@ static int GetInputEsMeta( input_item_t * p_item, int32_t i_es,
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_es]->i_infos ; j++ )
{
for( int j = 0 ; j < p_item->pp_categories[i]->i_infos ; j++ )
{
const char *psz_name = p_item->pp_categories[i]->pp_infos[j]->psz_name;
const char *psz_value = p_item->pp_categories[i]->pp_infos[j]->psz_value;
char *psz_variant = NULL;
dbus_message_iter_open_container( &dict, DBUS_TYPE_DICT_ENTRY,
NULL, &dict_entry );
dbus_message_iter_append_basic( &dict_entry, DBUS_TYPE_STRING,
&psz_cat );
const char *psz_name = p_item->pp_categories[i_es]->pp_infos[j]->psz_name;
const char *psz_value = p_item->pp_categories[i_es]->pp_infos[j]->psz_value;
char *psz_variant = NULL;
if( asprintf( &psz_variant, "%s : %s", psz_name, psz_value ) != -1 )
{
dbus_message_iter_open_container( &dict_entry, DBUS_TYPE_VARIANT,
DBUS_TYPE_STRING_AS_STRING, &variant );
dbus_message_iter_append_basic( &variant,
DBUS_TYPE_STRING, &psz_variant );
dbus_message_iter_close_container( &dict_entry, &variant );
free( psz_variant );
}
dbus_message_iter_open_container( &dict, DBUS_TYPE_DICT_ENTRY,
NULL, &dict_entry );
dbus_message_iter_append_basic( &dict_entry, DBUS_TYPE_STRING,
&psz_name );
dbus_message_iter_close_container( &dict, &dict_entry );
if( asprintf( &psz_variant, "%s", psz_value ) != -1 )
{
dbus_message_iter_open_container( &dict_entry, DBUS_TYPE_VARIANT,
DBUS_TYPE_STRING_AS_STRING, &variant );
dbus_message_iter_append_basic( &variant,
DBUS_TYPE_STRING, &psz_variant );
dbus_message_iter_close_container( &dict_entry, &variant );
free( psz_variant );
}
dbus_message_iter_close_container( &dict, &dict_entry );
}
free( psz_stream );
}
dbus_message_iter_close_container( args, &dict );
......
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