mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 00:11:59 +02:00
clapper: reactable: Inform which properties were updated
This commit is contained in:
@@ -151,4 +151,23 @@ typedef enum
|
||||
CLAPPER_ENHANCER_PARAM_DIRPATH = 1 << 20,
|
||||
} ClapperEnhancerParamFlags;
|
||||
|
||||
/**
|
||||
* ClapperReactableItemUpdatedFlags:
|
||||
* @CLAPPER_REACTABLE_ITEM_UPDATED_TITLE: Media item title was updated.
|
||||
* @CLAPPER_REACTABLE_ITEM_UPDATED_DURATION: Media item duration was updated.
|
||||
* @CLAPPER_REACTABLE_ITEM_UPDATED_TIMELINE: Media item timeline was updated.
|
||||
* @CLAPPER_REACTABLE_ITEM_UPDATED_TAGS: Media item tags were updated.
|
||||
*
|
||||
* Flags informing which properties were updated within [class@Clapper.MediaItem].
|
||||
*
|
||||
* Since: 0.10
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CLAPPER_REACTABLE_ITEM_UPDATED_TITLE = 1 << 0,
|
||||
CLAPPER_REACTABLE_ITEM_UPDATED_DURATION = 1 << 1,
|
||||
CLAPPER_REACTABLE_ITEM_UPDATED_TIMELINE = 1 << 2,
|
||||
CLAPPER_REACTABLE_ITEM_UPDATED_TAGS = 1 << 3,
|
||||
} ClapperReactableItemUpdatedFlags;
|
||||
|
||||
G_END_DECLS
|
||||
|
@@ -471,7 +471,7 @@ _tags_replace_func (const GstTagList *tags, const gchar *tag, ClapperMediaItemTa
|
||||
|
||||
static gboolean
|
||||
clapper_media_item_insert_tags_internal (ClapperMediaItem *self, const GstTagList *tags,
|
||||
ClapperAppBus *app_bus, gboolean from_user)
|
||||
ClapperAppBus *app_bus, gboolean from_user, ClapperReactableItemUpdatedFlags *flags)
|
||||
{
|
||||
ClapperMediaItemTagIterData data;
|
||||
gboolean title_changed = FALSE, cont_changed = FALSE;
|
||||
@@ -486,8 +486,12 @@ clapper_media_item_insert_tags_internal (ClapperMediaItem *self, const GstTagLis
|
||||
gst_tag_list_foreach (tags, (GstTagForeachFunc) _tags_replace_func, &data);
|
||||
|
||||
if (data.changed) {
|
||||
title_changed = _refresh_tag_prop_unlocked (self, GST_TAG_TITLE,
|
||||
from_user, &self->title);
|
||||
*flags |= CLAPPER_REACTABLE_ITEM_UPDATED_TAGS;
|
||||
|
||||
if ((title_changed = _refresh_tag_prop_unlocked (self, GST_TAG_TITLE,
|
||||
from_user, &self->title))) {
|
||||
*flags |= CLAPPER_REACTABLE_ITEM_UPDATED_TITLE;
|
||||
}
|
||||
cont_changed = _refresh_tag_prop_unlocked (self, GST_TAG_CONTAINER_FORMAT,
|
||||
from_user, &self->container_format);
|
||||
}
|
||||
@@ -548,6 +552,7 @@ clapper_media_item_populate_tags (ClapperMediaItem *self, const GstTagList *tags
|
||||
{
|
||||
ClapperPlayer *player;
|
||||
ClapperAppBus *app_bus = NULL;
|
||||
ClapperReactableItemUpdatedFlags flags = 0;
|
||||
gboolean changed;
|
||||
|
||||
g_return_val_if_fail (CLAPPER_IS_MEDIA_ITEM (self), FALSE);
|
||||
@@ -561,13 +566,13 @@ clapper_media_item_populate_tags (ClapperMediaItem *self, const GstTagList *tags
|
||||
if ((player = clapper_player_get_from_ancestor (GST_OBJECT_CAST (self))))
|
||||
app_bus = player->app_bus;
|
||||
|
||||
changed = clapper_media_item_insert_tags_internal (self, tags, app_bus, TRUE);
|
||||
changed = clapper_media_item_insert_tags_internal (self, tags, app_bus, TRUE, &flags);
|
||||
|
||||
if (changed && player) {
|
||||
ClapperFeaturesManager *features_manager;
|
||||
|
||||
if (player->reactables_manager)
|
||||
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, self);
|
||||
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, self, flags);
|
||||
if ((features_manager = clapper_player_get_features_manager (player)))
|
||||
clapper_features_manager_trigger_item_updated (features_manager, self);
|
||||
}
|
||||
@@ -600,13 +605,14 @@ clapper_media_item_update_from_tag_list (ClapperMediaItem *self, const GstTagLis
|
||||
GstTagScope scope = gst_tag_list_get_scope (tags);
|
||||
|
||||
if (scope == GST_TAG_SCOPE_GLOBAL) {
|
||||
gboolean changed = clapper_media_item_insert_tags_internal (self, tags, player->app_bus, FALSE);
|
||||
ClapperReactableItemUpdatedFlags flags = 0;
|
||||
gboolean changed = clapper_media_item_insert_tags_internal (self, tags, player->app_bus, FALSE, &flags);
|
||||
|
||||
if (changed) {
|
||||
ClapperFeaturesManager *features_manager;
|
||||
|
||||
if (player->reactables_manager)
|
||||
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, self);
|
||||
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, self, flags);
|
||||
if ((features_manager = clapper_player_get_features_manager (player)))
|
||||
clapper_features_manager_trigger_item_updated (features_manager, self);
|
||||
}
|
||||
@@ -619,6 +625,7 @@ clapper_media_item_update_from_discoverer_info (ClapperMediaItem *self, GstDisco
|
||||
ClapperPlayer *player;
|
||||
GstDiscovererStreamInfo *sinfo;
|
||||
GstClockTime duration;
|
||||
ClapperReactableItemUpdatedFlags flags = 0;
|
||||
gdouble val_dbl;
|
||||
gboolean changed = FALSE;
|
||||
|
||||
@@ -634,7 +641,7 @@ clapper_media_item_update_from_discoverer_info (ClapperMediaItem *self, GstDisco
|
||||
GstDiscovererContainerInfo *cinfo = (GstDiscovererContainerInfo *) sinfo;
|
||||
|
||||
if ((tags = gst_discoverer_container_info_get_tags (cinfo)))
|
||||
changed |= clapper_media_item_insert_tags_internal (self, tags, player->app_bus, FALSE);
|
||||
changed |= clapper_media_item_insert_tags_internal (self, tags, player->app_bus, FALSE, &flags);
|
||||
}
|
||||
gst_discoverer_stream_info_unref (sinfo);
|
||||
}
|
||||
@@ -645,13 +652,16 @@ clapper_media_item_update_from_discoverer_info (ClapperMediaItem *self, GstDisco
|
||||
duration = 0;
|
||||
|
||||
val_dbl = (gdouble) duration / GST_SECOND;
|
||||
changed |= clapper_media_item_set_duration (self, val_dbl, player->app_bus);
|
||||
if (clapper_media_item_set_duration (self, val_dbl, player->app_bus)) {
|
||||
changed = TRUE;
|
||||
flags |= CLAPPER_REACTABLE_ITEM_UPDATED_DURATION;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
ClapperFeaturesManager *features_manager;
|
||||
|
||||
if (player->reactables_manager)
|
||||
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, self);
|
||||
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, self, flags);
|
||||
if ((features_manager = clapper_player_get_features_manager (player)))
|
||||
clapper_features_manager_trigger_item_updated (features_manager, self);
|
||||
}
|
||||
|
@@ -173,8 +173,10 @@ _update_current_duration (ClapperPlayer *player)
|
||||
if (clapper_media_item_set_duration (player->played_item, duration_dbl, player->app_bus)) {
|
||||
ClapperFeaturesManager *features_manager;
|
||||
|
||||
if (player->reactables_manager)
|
||||
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, player->played_item);
|
||||
if (player->reactables_manager) {
|
||||
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, player->played_item,
|
||||
CLAPPER_REACTABLE_ITEM_UPDATED_DURATION);
|
||||
}
|
||||
if ((features_manager = clapper_player_get_features_manager (player)))
|
||||
clapper_features_manager_trigger_item_updated (features_manager, player->played_item);
|
||||
}
|
||||
|
@@ -130,6 +130,7 @@ struct _ClapperReactableInterface
|
||||
* ClapperReactableInterface::item_updated:
|
||||
* @reactable: a #ClapperReactable
|
||||
* @item: a #ClapperMediaItem that was updated
|
||||
* @flags: flags informing which properties were updated
|
||||
*
|
||||
* An item in queue got updated.
|
||||
*
|
||||
@@ -140,7 +141,7 @@ struct _ClapperReactableInterface
|
||||
*
|
||||
* Since: 0.10
|
||||
*/
|
||||
void (* item_updated) (ClapperReactable *reactable, ClapperMediaItem *item);
|
||||
void (* item_updated) (ClapperReactable *reactable, ClapperMediaItem *item, ClapperReactableItemUpdatedFlags flags);
|
||||
|
||||
/**
|
||||
* ClapperReactableInterface::queue_item_added:
|
||||
|
@@ -62,7 +62,7 @@ G_GNUC_INTERNAL
|
||||
void clapper_reactables_manager_trigger_played_item_changed (ClapperReactablesManager *manager, ClapperMediaItem *item);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void clapper_reactables_manager_trigger_item_updated (ClapperReactablesManager *manager, ClapperMediaItem *item);
|
||||
void clapper_reactables_manager_trigger_item_updated (ClapperReactablesManager *manager, ClapperMediaItem *item, ClapperReactableItemUpdatedFlags flags);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void clapper_reactables_manager_trigger_queue_item_added (ClapperReactablesManager *manager, ClapperMediaItem *item, guint index);
|
||||
|
@@ -271,7 +271,8 @@ clapper_reactables_manager_handle_event (ClapperReactablesManager *self, const G
|
||||
case _EVENT (ITEM_UPDATED):
|
||||
if (reactable_iface->item_updated) {
|
||||
reactable_iface->item_updated (data->reactable,
|
||||
CLAPPER_MEDIA_ITEM_CAST (g_value_get_object (value)));
|
||||
CLAPPER_MEDIA_ITEM_CAST (g_value_get_object (value)),
|
||||
g_value_get_flags (extra_value));
|
||||
}
|
||||
break;
|
||||
case _EVENT (QUEUE_ITEM_ADDED):
|
||||
@@ -428,9 +429,9 @@ clapper_reactables_manager_trigger_played_item_changed (ClapperReactablesManager
|
||||
}
|
||||
|
||||
void
|
||||
clapper_reactables_manager_trigger_item_updated (ClapperReactablesManager *self, ClapperMediaItem *item)
|
||||
clapper_reactables_manager_trigger_item_updated (ClapperReactablesManager *self, ClapperMediaItem *item, ClapperReactableItemUpdatedFlags _flags)
|
||||
{
|
||||
_BUS_POST_EVENT_SINGLE (_EVENT (ITEM_UPDATED), object, CLAPPER_TYPE_MEDIA_ITEM, item);
|
||||
_BUS_POST_EVENT_DUAL (_EVENT (ITEM_UPDATED), object, CLAPPER_TYPE_MEDIA_ITEM, item, flags, CLAPPER_TYPE_REACTABLE_ITEM_UPDATED_FLAGS, _flags);
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -113,8 +113,10 @@ clapper_timeline_post_item_updated (ClapperTimeline *self)
|
||||
if ((item = CLAPPER_MEDIA_ITEM_CAST (gst_object_get_parent (GST_OBJECT_CAST (self))))) {
|
||||
ClapperFeaturesManager *features_manager;
|
||||
|
||||
if (player->reactables_manager)
|
||||
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, item);
|
||||
if (player->reactables_manager) {
|
||||
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, item,
|
||||
CLAPPER_REACTABLE_ITEM_UPDATED_TIMELINE);
|
||||
}
|
||||
if ((features_manager = clapper_player_get_features_manager (player)))
|
||||
clapper_features_manager_trigger_item_updated (features_manager, item);
|
||||
|
||||
|
Reference in New Issue
Block a user