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