testsource: Handle child properties as child properties

Makes $make check pass.
Standardizes property handling.
This commit is contained in:
Simon Corsin 2013-07-03 18:27:00 +02:00 committed by Thibault Saunier
parent e50a86d0d9
commit 7fcc6e4b08
2 changed files with 52 additions and 20 deletions

View file

@ -102,12 +102,15 @@ ges_audio_test_source_create_source (GESTrackElement * trksrc)
{
GESAudioTestSource *self;
GstElement *ret;
const gchar *props[] = { "volume", "freq", NULL };
self = (GESAudioTestSource *) trksrc;
ret = gst_element_factory_make ("audiotestsrc", NULL);
g_object_set (ret, "volume", (gdouble) self->priv->volume, "freq", (gdouble)
self->priv->freq, NULL);
ges_track_element_add_children_props (trksrc, ret, NULL, NULL, props);
return ret;
}
@ -125,8 +128,14 @@ ges_audio_test_source_set_freq (GESAudioTestSource * self, gdouble freq)
ges_track_element_get_element (GES_TRACK_ELEMENT (self));
self->priv->freq = freq;
if (element)
g_object_set (element, "freq", (gdouble) freq, NULL);
if (element) {
GValue val = { 0 };
g_value_init (&val, G_TYPE_DOUBLE);
g_value_set_double (&val, freq);
ges_track_element_set_child_property (GES_TRACK_ELEMENT (self), "freq",
&val);
}
}
/**
@ -143,8 +152,14 @@ ges_audio_test_source_set_volume (GESAudioTestSource * self, gdouble volume)
ges_track_element_get_element (GES_TRACK_ELEMENT (self));
self->priv->volume = volume;
if (element)
g_object_set (element, "volume", (gdouble) volume, NULL);
if (element) {
GValue val = { 0 };
g_value_init (&val, G_TYPE_DOUBLE);
g_value_set_double (&val, volume);
ges_track_element_set_child_property (GES_TRACK_ELEMENT (self), "volume",
&val);
}
}
/**
@ -158,7 +173,10 @@ ges_audio_test_source_set_volume (GESAudioTestSource * self, gdouble volume)
double
ges_audio_test_source_get_freq (GESAudioTestSource * self)
{
return self->priv->freq;
GValue val = { 0 };
ges_track_element_get_child_property (GES_TRACK_ELEMENT (self), "freq", &val);
return g_value_get_double (&val);
}
/**
@ -172,7 +190,11 @@ ges_audio_test_source_get_freq (GESAudioTestSource * self)
double
ges_audio_test_source_get_volume (GESAudioTestSource * self)
{
return self->priv->volume;
GValue val = { 0 };
ges_track_element_get_child_property (GES_TRACK_ELEMENT (self), "volume",
&val);
return g_value_get_double (&val);
}
/**

View file

@ -61,19 +61,20 @@ static GstElement *
ges_video_test_source_create_source (GESTrackElement * self)
{
gint pattern;
GstElement *ret;
gchar *bin_desc;
GstElement *testsrc, *capsfilter;
const gchar *props[] = { "pattern", NULL };
testsrc = gst_element_factory_make ("videotestsrc", NULL);
capsfilter = gst_element_factory_make ("capsfilter", NULL);
pattern = ((GESVideoTestSource *) self)->priv->pattern;
bin_desc =
g_strdup_printf
("videotestsrc pattern=%i name=testsrc ! capsfilter caps=video/x-raw",
pattern);
ret = gst_parse_bin_from_description (bin_desc, TRUE, NULL);
g_free (bin_desc);
return ret;
g_object_set (testsrc, "pattern", pattern, NULL);
g_object_set (capsfilter, "caps", gst_caps_new_empty_simple ("video/x-raw"),
NULL);
ges_track_element_add_children_props (self, testsrc, NULL, NULL, props);
return create_bin ("videotestsrc", testsrc, capsfilter, NULL);
}
/**
@ -92,9 +93,14 @@ ges_video_test_source_set_pattern (GESVideoTestSource
self->priv->pattern = pattern;
if (element)
gst_child_proxy_set (GST_CHILD_PROXY (element), "testsrc::pattern",
(gint) pattern, NULL);
if (element) {
GValue val = { 0 };
g_value_init (&val, GES_VIDEO_TEST_PATTERN_TYPE);
g_value_set_enum (&val, pattern);
ges_track_element_set_child_property (GES_TRACK_ELEMENT (self), "pattern",
&val);
}
}
/**
@ -108,7 +114,11 @@ ges_video_test_source_set_pattern (GESVideoTestSource
GESVideoTestPattern
ges_video_test_source_get_pattern (GESVideoTestSource * source)
{
return source->priv->pattern;
GValue val = { 0 };
ges_track_element_get_child_property (GES_TRACK_ELEMENT (source), "pattern",
&val);
return g_value_get_enum (&val);
}
/**