GESTimelineFileSource: Add a 'mute' property.

This property deactivates the audio trackobjects if set to TRUE
This commit is contained in:
Edward Hervey 2009-09-30 16:44:12 +02:00
parent 1489c583af
commit 3deb1fc885
2 changed files with 51 additions and 3 deletions

View file

@ -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;
}
/**

View file

@ -49,6 +49,8 @@ struct _GESTimelineFileSource {
/*< private >*/
gchar *uri;
gboolean mute;
};
struct _GESTimelineFileSourceClass {