mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
Examples: Use GESTimelineTestSource instead of GESCustomTimelineSource in test1
This commit is contained in:
parent
49867a95fc
commit
61f298690d
1 changed files with 13 additions and 60 deletions
|
@ -20,39 +20,14 @@
|
||||||
#include <ges/ges.h>
|
#include <ges/ges.h>
|
||||||
|
|
||||||
/* A simple timeline with 3 audio/video sources */
|
/* 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
|
int
|
||||||
main (int argc, gchar ** argv)
|
main (int argc, gchar ** argv)
|
||||||
{
|
{
|
||||||
|
GESAsset *src_asset;
|
||||||
GESTimelinePipeline *pipeline;
|
GESTimelinePipeline *pipeline;
|
||||||
GESTimeline *timeline;
|
GESTimeline *timeline;
|
||||||
GESTrack *trackv, *tracka;
|
GESTimelineObject *source;
|
||||||
GESTimelineLayer *layer;
|
GESTimelineLayer *layer;
|
||||||
GESCustomTimelineSource *src1, *src2, *src3;
|
|
||||||
GMainLoop *mainloop;
|
GMainLoop *mainloop;
|
||||||
|
|
||||||
/* Initialize GStreamer (this will parse environment variables and commandline
|
/* Initialize GStreamer (this will parse environment variables and commandline
|
||||||
|
@ -65,12 +40,7 @@ main (int argc, gchar ** argv)
|
||||||
/* Setup of a A/V timeline */
|
/* Setup of a A/V timeline */
|
||||||
|
|
||||||
/* This is our main GESTimeline */
|
/* This is our main GESTimeline */
|
||||||
timeline = ges_timeline_new ();
|
timeline = ges_timeline_new_audio_video ();
|
||||||
|
|
||||||
/* 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 ();
|
|
||||||
|
|
||||||
/* We are only going to be doing one layer of timeline objects */
|
/* We are only going to be doing one layer of timeline objects */
|
||||||
layer = ges_timeline_layer_new ();
|
layer = ges_timeline_layer_new ();
|
||||||
|
@ -78,35 +48,18 @@ main (int argc, gchar ** argv)
|
||||||
/* Add the tracks and the layer to the timeline */
|
/* Add the tracks and the layer to the timeline */
|
||||||
if (!ges_timeline_add_layer (timeline, layer))
|
if (!ges_timeline_add_layer (timeline, layer))
|
||||||
return -1;
|
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
|
/* We create a simple asset able to extract GESTimelineTestSource */
|
||||||
* ready to start using it... by solely working with the layer !*/
|
src_asset = ges_asset_request (GES_TYPE_TIMELINE_TEST_SOURCE, NULL, NULL);
|
||||||
|
|
||||||
|
/* Add sources to our layer */
|
||||||
|
ges_timeline_layer_add_asset (layer, src_asset, 0, 0, GST_SECOND, 1,
|
||||||
/* We are here creating 3 sources of 1s each which we will put one after
|
GES_TRACK_TYPE_UNKNOWN);
|
||||||
* the other.
|
source = ges_timeline_layer_add_asset (layer, src_asset, GST_SECOND, 0,
|
||||||
*
|
GST_SECOND, 1, GES_TRACK_TYPE_UNKNOWN);
|
||||||
* For our sources, and since we want to prototype quickly, we just use
|
g_object_set (source, "freq", 480.0, "vpattern", 2, NULL);
|
||||||
* a GESCustomTimelineSource. This will use the callback we provide to
|
ges_timeline_layer_add_asset (layer, src_asset, 2 * GST_SECOND, 0,
|
||||||
* fill in the GESTrackObject.
|
GST_SECOND, 1, GES_TRACK_TYPE_UNKNOWN);
|
||||||
* */
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
/* In order to view our timeline, let's grab a convenience pipeline to put
|
/* In order to view our timeline, let's grab a convenience pipeline to put
|
||||||
|
|
Loading…
Reference in a new issue