Examples: Use GESTimelineTestSource instead of GESCustomTimelineSource in test1

This commit is contained in:
Thibault Saunier 2012-09-20 12:16:38 +02:00
parent 49867a95fc
commit 61f298690d

View file

@ -20,39 +20,14 @@
#include <ges/ges.h>
/* A simple timeline with 3 audio/video sources */
static gboolean
fill_customsrc (GESTimelineObject * object, GESTrackObject * trobject,
GstElement * gnlobj, gpointer user_data)
{
GstElement *src;
guint var = GPOINTER_TO_UINT (user_data);
GESTrack *track = ges_track_object_get_track (trobject);
/* Based on the Track type, we will either put a videotestsrc
* or an audiotestsrc */
if (track->type == GES_TRACK_TYPE_VIDEO) {
src = gst_element_factory_make ("videotestsrc", NULL);
g_object_set (src, "pattern", var, NULL);
} else if (track->type == GES_TRACK_TYPE_AUDIO) {
src = gst_element_factory_make ("audiotestsrc", NULL);
g_object_set (src, "freq", 440.0 * (var + 1), NULL);
} else
return FALSE;
/* Finally we fill in the gnlobject */
return gst_bin_add (GST_BIN (gnlobj), src);
}
int
main (int argc, gchar ** argv)
{
GESAsset *src_asset;
GESTimelinePipeline *pipeline;
GESTimeline *timeline;
GESTrack *trackv, *tracka;
GESTimelineObject *source;
GESTimelineLayer *layer;
GESCustomTimelineSource *src1, *src2, *src3;
GMainLoop *mainloop;
/* Initialize GStreamer (this will parse environment variables and commandline
@ -65,12 +40,7 @@ main (int argc, gchar ** argv)
/* Setup of a A/V timeline */
/* This is our main GESTimeline */
timeline = ges_timeline_new ();
/* We want to output both audio and video, therefore we
* grab two tracks, one for each output type. */
trackv = ges_track_video_raw_new ();
tracka = ges_track_audio_raw_new ();
timeline = ges_timeline_new_audio_video ();
/* We are only going to be doing one layer of timeline objects */
layer = ges_timeline_layer_new ();
@ -78,35 +48,18 @@ main (int argc, gchar ** argv)
/* Add the tracks and the layer to the timeline */
if (!ges_timeline_add_layer (timeline, layer))
return -1;
if (!ges_timeline_add_track (timeline, trackv))
return -1;
if (!ges_timeline_add_track (timeline, tracka))
return -1;
/* Here we've finished initializing our timeline, we're
* ready to start using it... by solely working with the layer !*/
/* We create a simple asset able to extract GESTimelineTestSource */
src_asset = ges_asset_request (GES_TYPE_TIMELINE_TEST_SOURCE, NULL, NULL);
/* We are here creating 3 sources of 1s each which we will put one after
* the other.
*
* For our sources, and since we want to prototype quickly, we just use
* a GESCustomTimelineSource. This will use the callback we provide to
* fill in the GESTrackObject.
* */
src1 = ges_custom_timeline_source_new (fill_customsrc, GUINT_TO_POINTER (0));
g_object_set (src1, "start", (guint64) 0, "duration", GST_SECOND, NULL);
src2 = ges_custom_timeline_source_new (fill_customsrc, GUINT_TO_POINTER (1));
g_object_set (src2, "start", GST_SECOND, "duration", GST_SECOND, NULL);
src3 = ges_custom_timeline_source_new (fill_customsrc, GUINT_TO_POINTER (0));
g_object_set (src3, "start", 2 * GST_SECOND, "duration", GST_SECOND, NULL);
/* Add those sources to our layer */
ges_timeline_layer_add_object (layer, (GESTimelineObject *) src1);
ges_timeline_layer_add_object (layer, (GESTimelineObject *) src2);
ges_timeline_layer_add_object (layer, (GESTimelineObject *) src3);
/* Add sources to our layer */
ges_timeline_layer_add_asset (layer, src_asset, 0, 0, GST_SECOND, 1,
GES_TRACK_TYPE_UNKNOWN);
source = ges_timeline_layer_add_asset (layer, src_asset, GST_SECOND, 0,
GST_SECOND, 1, GES_TRACK_TYPE_UNKNOWN);
g_object_set (source, "freq", 480.0, "vpattern", 2, NULL);
ges_timeline_layer_add_asset (layer, src_asset, 2 * GST_SECOND, 0,
GST_SECOND, 1, GES_TRACK_TYPE_UNKNOWN);
/* In order to view our timeline, let's grab a convenience pipeline to put