From 3deb1fc8851eba97e8e936c12553049c5cfc419a Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 30 Sep 2009 16:44:12 +0200 Subject: [PATCH] GESTimelineFileSource: Add a 'mute' property. This property deactivates the audio trackobjects if set to TRUE --- ges/ges-timeline-file-source.c | 52 ++++++++++++++++++++++++++++++++-- ges/ges-timeline-file-source.h | 2 ++ 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/ges/ges-timeline-file-source.c b/ges/ges-timeline-file-source.c index ed18df1c4e..a66937a5cc 100644 --- a/ges/ges-timeline-file-source.c +++ b/ges/ges-timeline-file-source.c @@ -28,9 +28,13 @@ G_DEFINE_TYPE (GESTimelineFileSource, ges_tl_filesource, enum { PROP_0, - PROP_URI + PROP_URI, + PROP_MUTE }; +static void +ges_tl_filesource_set_mute (GESTimelineFileSource * self, gboolean mute); + static GESTrackObject * ges_tl_filesource_create_track_object (GESTimelineObject * obj, GESTrack * track); @@ -45,6 +49,9 @@ ges_tl_filesource_get_property (GObject * object, guint property_id, case PROP_URI: g_value_set_string (value, tfs->uri); break; + case PROP_MUTE: + g_value_set_boolean (value, tfs->mute); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -60,6 +67,9 @@ ges_tl_filesource_set_property (GObject * object, guint property_id, case PROP_URI: tfs->uri = g_value_dup_string (value); break; + case PROP_MUTE: + ges_tl_filesource_set_mute (tfs, g_value_get_boolean (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -98,6 +108,15 @@ ges_tl_filesource_class_init (GESTimelineFileSourceClass * klass) g_param_spec_string ("uri", "URI", "uri of the resource", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + /** + * GESTimelineFileSource:mute + * + * Whether the sound will be played or not. + */ + g_object_class_install_property (object_class, PROP_MUTE, + g_param_spec_boolean ("mute", "Mute", "Mute audio track", + FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + timobj_class->create_track_object = ges_tl_filesource_create_track_object; timobj_class->need_fill_track = FALSE; } @@ -107,15 +126,42 @@ ges_tl_filesource_init (GESTimelineFileSource * self) { } +static void +ges_tl_filesource_set_mute (GESTimelineFileSource * self, gboolean mute) +{ + GList *tmp; + GESTimelineObject *object = (GESTimelineObject *) self; + + GST_DEBUG ("self:%p, mute:%d", self, mute); + + self->mute = mute; + + /* Go over tracked objects, and update 'active' status on all audio objects */ + for (tmp = object->trackobjects; tmp; tmp = tmp->next) { + GESTrackObject *trackobject = (GESTrackObject *) tmp->data; + + if (trackobject->track->type == GES_TRACK_TYPE_AUDIO) + ges_track_object_set_active (trackobject, mute); + } +} + static GESTrackObject * ges_tl_filesource_create_track_object (GESTimelineObject * obj, GESTrack * track) { + GESTimelineFileSource *tfs = (GESTimelineFileSource *) obj; + GESTrackObject *res; + GST_DEBUG ("Creating a GESTrackFileSource"); /* FIXME : Implement properly ! */ - return (GESTrackObject *) ges_track_filesource_new (((GESTimelineFileSource *) - obj)->uri); + res = (GESTrackObject *) ges_track_filesource_new (tfs->uri); + + /* If mute and track is audio, deactivate the track object */ + if (track->type == GES_TRACK_TYPE_AUDIO) + ges_track_object_set_active (res, tfs->mute); + + return res; } /** diff --git a/ges/ges-timeline-file-source.h b/ges/ges-timeline-file-source.h index 8ad6148104..82b5fa10a0 100644 --- a/ges/ges-timeline-file-source.h +++ b/ges/ges-timeline-file-source.h @@ -49,6 +49,8 @@ struct _GESTimelineFileSource { /*< private >*/ gchar *uri; + + gboolean mute; }; struct _GESTimelineFileSourceClass {