From 12a2d3b3fe33e54d842a00e04b73642aa5ef200a Mon Sep 17 00:00:00 2001 From: Brandon Lewis Date: Fri, 2 Jul 2010 15:42:48 +0200 Subject: [PATCH] expose freq and volume props in GESTimelineTestSource --- ges/ges-timeline-test-source.c | 84 +++++++++++++++++++++++++++++++++++++- ges/ges-timeline-test-source.h | 4 +- ges/ges-track-audio-test-source.c | 2 +- tests/check/ges/backgroundsource.c | 35 +++++++++++++++- 4 files changed, 120 insertions(+), 5 deletions(-) diff --git a/ges/ges-timeline-test-source.c b/ges/ges-timeline-test-source.c index 48e2210..519ff78 100644 --- a/ges/ges-timeline-test-source.c +++ b/ges/ges-timeline-test-source.c @@ -43,6 +43,8 @@ enum PROP_0, PROP_MUTE, PROP_VPATTERN, + PROP_FREQ, + PROP_VOLUME, }; static void @@ -52,6 +54,13 @@ static void ges_timeline_test_source_set_vpattern (GESTimelineTestSource * self, gint vpattern); +static void +ges_timeline_test_source_set_freq (GESTimelineTestSource * self, gdouble freq); + +static void +ges_timeline_test_source_set_volume (GESTimelineTestSource * self, + gdouble volume); + static GESTrackObject * ges_timeline_test_source_create_track_object (GESTimelineObject * obj, GESTrack * track); @@ -69,6 +78,12 @@ ges_timeline_test_source_get_property (GObject * object, guint property_id, case PROP_VPATTERN: g_value_set_enum (value, tfs->vpattern); break; + case PROP_FREQ: + g_value_set_double (value, tfs->freq); + break; + case PROP_VOLUME: + g_value_set_double (value, tfs->volume); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -87,6 +102,12 @@ ges_timeline_test_source_set_property (GObject * object, guint property_id, case PROP_VPATTERN: ges_timeline_test_source_set_vpattern (tfs, g_value_get_enum (value)); break; + case PROP_FREQ: + ges_timeline_test_source_set_freq (tfs, g_value_get_double (value)); + break; + case PROP_VOLUME: + ges_timeline_test_source_set_volume (tfs, g_value_get_double (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -127,6 +148,27 @@ ges_timeline_test_source_class_init (GESTimelineTestSourceClass * klass) GES_VIDEO_TEST_PATTERN_BLACK, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); /** + * GESTimelineTestSource:freq + * + * The frequency to generate for audio track objects. + */ + g_object_class_install_property (object_class, PROP_FREQ, + g_param_spec_double ("freq", "Audio Frequency", + "The frequency to generate. See audiotestsrc element", + 0, 20000, 440, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + /** + * GESTimelineTestSource:volume + * + * The volume for the audio track objects. + */ + g_object_class_install_property (object_class, PROP_VOLUME, + g_param_spec_double ("volume", "Audio Volume", + "The volume of the test audio signal.", + 0, 1, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + + /** * GESTimelineTestSource:mute: * * Whether the sound will be played or not. @@ -143,6 +185,8 @@ ges_timeline_test_source_class_init (GESTimelineTestSourceClass * klass) static void ges_timeline_test_source_init (GESTimelineTestSource * self) { + self->freq = 0; + self->volume = 0; GES_TIMELINE_OBJECT (self)->duration = 0; } @@ -182,6 +226,39 @@ ges_timeline_test_source_set_vpattern (GESTimelineTestSource * self, } } +static void +ges_timeline_test_source_set_freq (GESTimelineTestSource * self, gdouble freq) +{ + GList *tmp; + GESTimelineObject *object = (GESTimelineObject *) self; + + self->freq = freq; + + for (tmp = object->trackobjects; tmp; tmp = tmp->next) { + GESTrackObject *trackobject = (GESTrackObject *) tmp->data; + if (GES_IS_TRACK_AUDIO_TEST_SOURCE (trackobject)) + ges_track_audio_test_source_set_freq ( + (GESTrackAudioTestSource *) trackobject, freq); + } +} + +static void +ges_timeline_test_source_set_volume (GESTimelineTestSource * self, + gdouble volume) +{ + GList *tmp; + GESTimelineObject *object = (GESTimelineObject *) self; + + self->volume = volume; + + for (tmp = object->trackobjects; tmp; tmp = tmp->next) { + GESTrackObject *trackobject = (GESTrackObject *) tmp->data; + if (GES_IS_TRACK_AUDIO_TEST_SOURCE (trackobject)) + ges_track_audio_test_source_set_volume ( + (GESTrackAudioTestSource *) trackobject, volume); + } +} + static GESTrackObject * ges_timeline_test_source_create_track_object (GESTimelineObject * obj, GESTrack * track) @@ -199,8 +276,13 @@ ges_timeline_test_source_create_track_object (GESTimelineObject * obj, else if (track->type == GES_TRACK_TYPE_AUDIO) { res = (GESTrackObject *) ges_track_audio_test_source_new (); - if (tfs->mute) + if (tfs->mute) { ges_track_object_set_active (res, FALSE); + ges_track_audio_test_source_set_freq ((GESTrackAudioTestSource *) res, + tfs->freq); + ges_track_audio_test_source_set_volume ((GESTrackAudioTestSource *) res, + tfs->volume); + } } else diff --git a/ges/ges-timeline-test-source.h b/ges/ges-timeline-test-source.h index 8728b30..2c8c4aa 100644 --- a/ges/ges-timeline-test-source.h +++ b/ges/ges-timeline-test-source.h @@ -57,7 +57,9 @@ struct _GESTimelineTestSource { /*< private >*/ gboolean mute; - gint vpattern; + GESVideoTestPattern vpattern; + gdouble freq; + gdouble volume; }; /** diff --git a/ges/ges-track-audio-test-source.c b/ges/ges-track-audio-test-source.c index 5dbd2e6..f5ab9f8 100644 --- a/ges/ges-track-audio-test-source.c +++ b/ges/ges-track-audio-test-source.c @@ -139,7 +139,7 @@ ges_track_audio_test_source_set_volume (GESTrackAudioTestSource * self, self->volume = volume; element = ((GESTrackSource *) self)->element; if (element) - g_object_set (element, "freq", (gdouble) volume, NULL); + g_object_set (element, "volume", (gdouble) volume, NULL); } GESTrackAudioTestSource * diff --git a/tests/check/ges/backgroundsource.c b/tests/check/ges/backgroundsource.c index 00df7f3..033060f 100644 --- a/tests/check/ges/backgroundsource.c +++ b/tests/check/ges/backgroundsource.c @@ -116,6 +116,7 @@ GST_START_TEST (test_test_source_in_layer) GESTrackObject *trobj; GESTimelineTestSource *source; GESVideoTestPattern ptrn; + gdouble freq, volume; ges_init (); @@ -147,14 +148,44 @@ GST_START_TEST (test_test_source_in_layer) ptrn = ((GESTrackVideoTestSource *) trobj)->pattern; assert_equals_int (ptrn, GES_VIDEO_TEST_PATTERN_WHITE); + g_object_unref (trobj); + + /* test audio properties as well */ + + trobj = ges_timeline_object_find_track_object (GES_TIMELINE_OBJECT (source), + a); + g_assert (GES_IS_TRACK_AUDIO_TEST_SOURCE (trobj)); + assert_equals_float (source->freq, 440); + assert_equals_float (source->volume, 0); + + g_object_get (source, "freq", &freq, "volume", &volume, NULL); + assert_equals_float (freq, 440); + assert_equals_float (volume, 0); + + freq = ((GESTrackAudioTestSource *) trobj)->freq; + volume = ((GESTrackAudioTestSource *) trobj)->volume; + g_assert (freq == 440); + g_assert (volume == 0); + - GST_DEBUG ("removing the source"); + g_object_set (source, "freq", (gdouble) 2000, "volume", (gdouble) 0.5, NULL); + + g_object_get (source, "freq", &freq, "volume", &volume, NULL); + assert_equals_float (freq, 2000); + assert_equals_float (volume, 0.5); + + freq = ((GESTrackAudioTestSource *) trobj)->freq; + volume = ((GESTrackAudioTestSource *) trobj)->volume; + + g_assert (freq == 2000); + g_assert (volume == 0.5); + + g_object_unref (trobj); ges_timeline_layer_remove_object (layer, (GESTimelineObject *) source); GST_DEBUG ("removing the layer"); - g_object_unref (trobj); g_object_unref (timeline); } -- 2.7.4